Search code examples
c++cgal

How to determine if a vertex is on the border in a mesh in CGAL


I am trying to calculate the Gaussian curvature on a 3D mesh for each vertex, so I want to know if the vertex is on border or not, I checked the CGAL online manual, finding no method to check if a vertex is on border , so I write a function which loop through the halfedge around the vertex to check this, the code is:

bool is_border(Vertex_iterator& vi){
  HV_circulator hv = vi-> vertex_begin();
  //move around the vertex and check if there is a halfedge which
  //is on border
  for(; hv != vi -> vertex_begin(); vi++){
    if(hv -> is_border())
      return true;
  }
  return false;
}

so my question is, is there any other way to check if a vertex is on border?


Solution

  • No there is not. The solution you have implemented is the one that would I recommended, but with Vertex_handle instead of Vertex_iterator, because the later is implicitly cast to the former.

    That function is_border is rather costly. If you need to call it several time on the same vertex, for whatever reason, you should invest a way to cache the result.