18 #ifndef MATLABPOLYHEDRON_H
19 #define MATLABPOLYHEDRON_H
21 #include <CGAL/Polyhedron_incremental_builder_3.h>
63 std::unique_ptr<Polyhedron>
MATLAB2Polyhedron(
const mxArray *mxV,
const mxArray *mxF);
90 std::vector<double> &coords;
91 std::vector<int> &tris;
100 polyhedron_builder(std::vector<double> &_coords, std::vector<int> &_tris ) : coords(_coords), tris(_tris) {}
105 CGAL::Polyhedron_incremental_builder_3<HDS> B(hds,
true);
106 B.begin_surface(coords.size() / 3, tris.size() / 3);
108 for (
int i = 0; i < (int) coords.size(); i+=3)
113 for(
int i = 0; i < (int) tris.size(); i+=3)
116 B.add_vertex_to_facet(tris[i+0]);
117 B.add_vertex_to_facet(tris[i+1]);
118 B.add_vertex_to_facet(tris[i+2]);
128 Polyhedron::Point_const_iterator pit = polyhedron.points_begin();
129 CGAL_For_all(pit, polyhedron.points_end())
131 *points++ = pit->x();
132 *points++ = pit->y();
133 *points++ = pit->z();
135 CGAL::Inverse_index<Polyhedron::Vertex_const_iterator> index(polyhedron.vertices_begin(), polyhedron.vertices_end());
136 Polyhedron::Facet_const_iterator fit = polyhedron.facets_begin();
137 CGAL_For_all(fit, polyhedron.facets_end())
139 auto hc = fit->facet_begin();
141 std::size_t n = circulator_size(hc);
142 CGAL_assertion(n == 3);
145 *facets++ =
static_cast<double>(1 + index[Polyhedron::Vertex_const_iterator(hc->vertex())]);
154 double* V = (
double*) mxGetData(mxV);
155 size_t nbv = mxGetN(mxV);
156 std::vector<double> coords(V, V + 3 * nbv);
157 size_t nbf = mxGetN(mxF);
158 double* F = (
double*) mxGetData(mxF);
159 std::vector<int> ids;
160 for (
size_t i = 0 ; i < nbf ; i++)
162 ids.push_back(static_cast<int>(*F++ - 1));
163 ids.push_back(static_cast<int>(*F++ - 1));
164 ids.push_back(static_cast<int>(*F++ - 1));
166 std::unique_ptr<Polyhedron> pP = std::unique_ptr<Polyhedron>(
new Polyhedron);
168 pP->delegate(builder);
void operator()(HDS &hds)
Perform the construction of the triangle surface mesh.
Definition: MatlabPolyhedron.h:102
std::unique_ptr< Polyhedron > MATLAB2Polyhedron(const mxArray *mxV, const mxArray *mxF)
Conversion from MATLAB mesh representation to CGAL polyhedron representation.
Definition: MatlabPolyhedron.h:152
void Polyhedron2MATLAB(const Polyhedron &polyhedron, double *points, double *facets)
Conversion from CGAL polyhedron to a MATLAB-compatible representation of the mesh.
Definition: MatlabPolyhedron.h:126
polyhedron_builder(std::vector< double > &_coords, std::vector< int > &_tris)
Construct a polyhedron builder class from a series of vertex coordinates and a series of triangle fac...
Definition: MatlabPolyhedron.h:100
Builder class for a triangle surface mesh based on a list of facets and vertices. ...
Definition: MatlabPolyhedron.h:87
Procedures to convert between MATLAB and CGAL mesh representations.
Definition: MatlabPolyhedron.h:51
Polyhedron class for the MSDM computation.
Definition: enriched_polyhedron.h:189