Skip to content

Point inside given shape #494

Answered by lmontaut
Rennngw asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @Rennngw,
In the hppfcl3x branch, if your object is convex, you can load it by using a MeshLoader then call the buildConvexHull method of BVHs:

std::shared_ptr<ConvexBase> loadConvexShape(const std::string& file_name) {
  NODE_TYPE bv_type = BV_AABB;
  MeshLoader loader(bv_type);
  BVHModelPtr_t bvh = loader.load(file_name);
  bvh->buildConvexHull(true, "Qt");
  return bvh->convex;
}

// ...
// inside main function
std::shared_ptr<ConvexBase> shape = loadConvexShape("obj.stl");

You can then access the faces normals and faces offsets of the mesh to check if your points are inside/outside the shapes (by considering all hyperplanes defining your shape):

shape->normals[i];
shape->offsets[…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by jcarpent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #491 on December 05, 2023 19:04.