MCPcopy Create free account
hub / github.com/LiangliangNan/PolyFit / compute_proxy_mesh

Method compute_proxy_mesh

code/method/hypothesis_generator.cpp:335–480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

333
334
335Map* HypothesisGenerator::compute_proxy_mesh(Map* bbox_mesh) {
336 MapFacetAttribute<Plane3d*> bbox_mesh_face_supporting_plane(bbox_mesh, "FacetSupportingPlane");
337 MapHalfedgeAttribute< std::set<Plane3d*> > bbox_mesh_edge_source_planes(bbox_mesh, "EdgeSourcePlanes");
338 MapVertexAttribute< std::set<Plane3d*> > bbox_mesh_vertex_source_planes(bbox_mesh, "VertexSourcePlanes");
339
340 Map* mesh = new Map;
341 MapBuilder builder(mesh);
342
343 MapFacetAttribute<Color> color(mesh, "color");
344 MapFacetAttribute<VertexGroup*> facet_supporting_vertex_group(mesh, Method::facet_attrib_supporting_vertex_group);
345 MapFacetAttribute<Plane3d*> face_supporting_plane(mesh, "FacetSupportingPlane");
346 MapHalfedgeAttribute< std::set<Plane3d*> > edge_source_planes(mesh, "EdgeSourcePlanes");
347 MapVertexAttribute< std::set<Plane3d*> > vertex_source_planes(mesh, "VertexSourcePlanes");
348
349 builder.begin_surface();
350 int idx = 0;
351 for (std::size_t i = 0; i < plane_segments_.size(); ++i) {
352 VertexGroup* g = plane_segments_[i];
353 Plane3d* plane = vertex_group_plane_[g];
354
355 std::vector<vec3> points;
356 std::vector< std::set<Plane3d*> > point_source_planes;
357 FOR_EACH_EDGE_CONST(Map, bbox_mesh, it) {
358 const vec3& s = it->prev()->vertex()->point();
359 const vec3& t = it->vertex()->point();
360 Sign ss = plane->orient(s);
361 Sign st = plane->orient(t);
362 if ((ss == POSITIVE && st == NEGATIVE) || (ss == NEGATIVE && st == POSITIVE)) {
363 vec3 p;
364 if (plane->intersection(Line3d::from_two_points(s, t), p)) {
365 points.push_back(p);
366
367 std::set<Plane3d*> planes = bbox_mesh_edge_source_planes[it];
368 planes.insert(plane);
369 point_source_planes.push_back(planes);
370 }
371 else
372 Logger::err("-") << "fatal error. Should have intersection" << std::endl;
373 }
374 else {
375 if (ss == ZERO) {
376 points.push_back(s);
377
378 std::set<Plane3d*> planes = bbox_mesh_vertex_source_planes[it->prev()->vertex()];
379 point_source_planes.push_back(planes);
380 }
381 else if (st == ZERO) {
382 points.push_back(t);
383
384 std::set<Plane3d*> planes = bbox_mesh_vertex_source_planes[it->vertex()];
385 point_source_planes.push_back(planes);
386 }
387 else {
388 // no intersection with the plane
389 }
390 }
391 }
392

Callers

nothing calls this directly

Calls 15

check_source_planesFunction · 0.85
begin_surfaceMethod · 0.80
to_2dMethod · 0.80
add_vertexMethod · 0.80
current_vertexMethod · 0.80
begin_facetMethod · 0.80
add_vertex_to_facetMethod · 0.80
end_facetMethod · 0.80
current_facetMethod · 0.80
end_surfaceMethod · 0.80
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected