Subject: CGAL users discussion list
List archive
[cgal-discuss] Any ideas on how to make my segment extraction code given a mesh and its segments faster?
Chronological Thread
- From: Iasonm <>
- To:
- Subject: [cgal-discuss] Any ideas on how to make my segment extraction code given a mesh and its segments faster?
- Date: Tue, 13 Feb 2018 08:15:26 -0700 (MST)
- Authentication-results: mail3-smtp-sop.national.inria.fr; spf=None ; spf=SoftFail ; spf=Pass
- Ironport-phdr: 9a23:0zEuDxHqhIm/rsRzEUav551GYnF86YWxBRYc798ds5kLTJ79rsuwAkXT6L1XgUPTWs2DsrQY07OQ6/iocFdDyK7JiGoFfp1IWk1NouQttCtkPvS4D1bmJuXhdS0wEZcKflZk+3amLRodQ56mNBXdrXKo8DEdBAj0OxZrKeTpAI7SiNm82/yv95HJbAhEmCexbaluIBmqsA7cqtQYjYx+J6gr1xDHuGFIe+NYxWNpIVKcgRPx7dqu8ZBg7ipdpesv+9ZPXqvmcas4S6dYDCk9PGAu+MLrrxjDQhCR6XYaT24bjwBHAwnB7BH9Q5fxri73vfdz1SWGIcH7S60/VDK/5KlpVRDokj8KOTA5/m/JicJ+ka1Urw6uqRFk347ZYp2ZOOZicq/BY98XQ3dKUMZLVyxGB4Oxd4gBAPAaPeZfqYn9okYFoBynBQm1GOPvzTtIiWHw3aIkyOkhHgTG0xYhH9IKqnjbsNL1NKILXO2z0aLGwzLDb/ZM1jf87ojFahYhruuXUr1rdcre11MjGB/CjlWVr4HuIjCb1vwVvmSG7udsS/ijh3Anpgx/uDSj28khh4fTio8X1FzJ8zhyzpwvKt2iUkF7ZMapEJtOuCGeMIt7WsUiTm5ytCY80LIJooW0fCwUx5g92xHfbPmHf5CJ4hLlSumRPS91iG9kdb6hnRq+70itx+PmWsWp3ltHoDBJn9vSunwV0hzc8MmHSv9z/ke73jaP0hje6vhdIUAokqrbL4AuwrgumZcIvkTDGzX5mETyjKOMakok/e2o5/z9Yrr6vp+cK5N0igbmP6sylcywG+A4PhETUGia4uSzyKDj/VbiQLhRlf03kqzZsIjAKsgBp665BRVV0oc55BqlATemyodQoX5SJ11MfFeLjpPiJkrVCPH+F/a2xVq2wxlxwPWTH7T6BZPIZizaiavmebt75mZTzQMyyZZU4JcCWeJJG+76RkKk7I+QNRQ+KQHhm7+2WuU47ZsXXCe0OoHcNarTtVGS4ed2eruDYYYUvHD2LP13vKey3098okcUeOyS5bVScGqxR600LECQYH6qidAEQz9T41gOCdfygVjHagZ9Ina/W6Vlu2M9VMSgBI3JQo3ri7uEjn62
I am trying to make the following code faster. Initializing the size of
points and faces would make the code faster but is there a way to know the
number of unique vertices of a segment without traversing its faces? Any
other ideas are welcomed..
const auto &segmentMap = m_segmentFaceMap; //the output of the sdf
segmentation algorithm
std::vector<Kernel::Point_3> points;
std::vector<std::vector<size_t>> faces;
for (CGALSurfaceMesh::Face_iterator it = M.faces_begin();
it != M.faces_end(); it++) {
CGALSurfaceMesh::Face_index fIndex(*it);
if (segmentMap[fIndex] == segmentIndex) {
CGALSurfaceMesh::Halfedge_index h =
M.halfedge(fIndex);
CGALSurfaceMesh::Vertex_index v1; //= M.source(h);
CGALSurfaceMesh::Vertex_index v2; //= M.target(h);
CGALSurfaceMesh::Vertex_index v3; //=
M.target(hNext);
auto vri = M.vertices_around_face(h);
v1 = *vri.begin();
v2 = *(++vri.begin());
v3 = *(++++vri.begin());
CGALSurfaceMesh::Point p1(M.point(v1));
CGALSurfaceMesh::Point p2(M.point(v2));
CGALSurfaceMesh::Point p3(M.point(v3));
size_t i1 = std::distance(
points.begin(),
std::find(points.begin(), points.end(), p1));
//find index of p1
if (i1 == points.size()) { //if p1 does not exist in
points add it and update its index
points.push_back(p1);
i1 = points.size() - 1;
}
size_t i2 = std::distance(
points.begin(),
std::find(points.begin(), points.end(), p2));
//same as p1
if (i2 == points.size()) {
points.push_back(p2);
i2 = points.size() - 1;
}
size_t i3 = std::distance(
points.begin(),
std::find(points.begin(), points.end(), p3));
//same as p1
if (i3 == points.size()) {
points.push_back(p3);
i3 = points.size() - 1;
}
std::vector<size_t> face{i1, i2, i3};
faces.push_back(face);
}
}
CGALSurfaceMesh outputMesh;
CGAL::Polygon_mesh_processing::polygon_soup_to_polygon_mesh(
points, faces, outputMesh);
return outputMesh;
--
Sent from: http://cgal-discuss.949826.n4.nabble.com/
- [cgal-discuss] Any ideas on how to make my segment extraction code given a mesh and its segments faster?, Iasonm, 02/13/2018
- Re: [cgal-discuss] Any ideas on how to make my segment extraction code given a mesh and its segments faster?, Sebastien Loriot (GeometryFactory), 02/14/2018
Archive powered by MHonArc 2.6.18.