MCPcopy Create free account
hub / github.com/PyMesh/PyMesh / cut_face

Function cut_face

tools/Wires/Inflator/PeriodicInflator2D.cpp:42–71  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40 }
41
42 void cut_face(
43 const Vector2F& bbox_min,
44 const Vector2F& bbox_max,
45 const Vector2F& p0,
46 const Vector2F& p1,
47 const Vector2F& p2,
48 MatrixFr& vertices, MatrixIr& faces) {
49 MatrixFr box_vertices(4,2);
50 box_vertices << bbox_min[0], bbox_min[1],
51 bbox_max[0], bbox_min[1],
52 bbox_max[0], bbox_max[1],
53 bbox_min[0], bbox_max[1];
54 MatrixIr box_faces(2, 3);
55 box_faces << 0, 1, 2,
56 0, 2, 3;
57
58 MatrixFr tri_vertices(3, 2);
59 tri_vertices << p0.transpose(),
60 p1.transpose(),
61 p2.transpose();
62 MatrixIr tri_faces(1, 3);
63 tri_faces << 0, 1, 2;
64
65 BooleanEngine::Ptr boolean_engine = BooleanEngine::create("clipper");
66 boolean_engine->set_mesh_1(tri_vertices, tri_faces);
67 boolean_engine->set_mesh_2(box_vertices, box_faces);
68 boolean_engine->compute_intersection();
69 vertices = boolean_engine->get_vertices();
70 faces = boolean_engine->get_faces();
71 }
72
73 template<typename M, typename T>
74 void append(const M& vertices, std::list<T>& flattened) {

Callers 1

clip_phantom_meshMethod · 0.85

Calls 5

set_mesh_1Method · 0.80
set_mesh_2Method · 0.80
compute_intersectionMethod · 0.45
get_verticesMethod · 0.45
get_facesMethod · 0.45

Tested by

no test coverage detected