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

Method run

tools/TetGen/TetgenWrapper.cpp:15–111  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

13using namespace PyMesh;
14
15void TetgenWrapper::run() {
16 tetgenio in, out, addin, bgmin;
17
18 const size_t num_points = m_points.rows();
19 const size_t num_triangles = m_triangles.rows();
20 const size_t num_tets = m_tets.rows();
21 const size_t num_point_markers = m_point_markers.size();
22 const size_t num_point_weights = m_point_weights.size();
23 const size_t num_triangle_markers = m_triangle_markers.size();
24
25 in.firstnumber = 0;
26 in.mesh_dim = 3;
27
28 in.numberofpoints = m_points.rows();
29 in.pointlist = new REAL[in.numberofpoints * 3];
30 std::copy(m_points.data(), m_points.data() + m_points.size(),
31 in.pointlist);
32
33 if (num_point_markers > 0) {
34 if (num_point_markers != num_points) {
35 throw RuntimeError(
36 "Size of point marker must equal to the number of points");
37 }
38 in.pointmarkerlist = new int[num_points];
39 std::copy(m_point_markers.data(), m_point_markers.data() + num_points,
40 in.pointmarkerlist);
41 }
42
43 if (num_point_weights > 0) {
44 if (num_point_weights != num_points) {
45 throw RuntimeError(
46 "Size of point weights must equal to the nubmer of points");
47 }
48 in.numberofpointattributes = num_points;
49 in.pointattributelist = new REAL[num_points];
50 std::copy(m_point_weights.data(), m_point_weights.data() + num_points,
51 in.pointattributelist);
52 }
53
54 if (num_triangles > 0) {
55 if (m_triangles.cols() != 3) {
56 throw NotImplementedError(
57 "Only triangles are supported as polygon input to tetgen");
58 }
59 in.numberoffacets = num_triangles;
60 in.facetlist = new tetgenio::facet[num_triangles];
61 for (size_t i=0; i<num_triangles; i++) {
62 auto& f = in.facetlist[i];
63 f.numberofpolygons = 1;
64 f.polygonlist = new tetgenio::polygon[1];
65 f.numberofholes = 0;
66 f.holelist = NULL;
67 auto& poly = f.polygonlist[0];
68 poly.numberofvertices = 3;
69 poly.vertexlist = new int[3];
70 poly.vertexlist[0] = m_triangles(i, 0);
71 poly.vertexlist[1] = m_triangles(i, 1);
72 poly.vertexlist[2] = m_triangles(i, 2);

Callers

nothing calls this directly

Calls 6

RuntimeErrorClass · 0.85
NotImplementedErrorClass · 0.85
IOErrorClass · 0.85
tetrahedralizeFunction · 0.85
TetgenExceptionClass · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected