Skip to content

Commit 4874984

Browse files
committed
cleaning up
1 parent e773ae5 commit 4874984

File tree

3 files changed

+18
-104
lines changed

3 files changed

+18
-104
lines changed

docs/examples/triangulation.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55
from compas.datastructures import Mesh
66
from compas_cgal.triangulation import constrained_delaunay_triangulation
77

8+
# ==============================================================================
9+
# Constraints
10+
# ==============================================================================
811

912
boundary = Polygon.from_sides_and_radius_xy(4, 10)
1013
boundary = np.array(boundary, dtype=np.float64)
@@ -16,10 +19,20 @@
1619
hole3 = hole.transformed(Translation.from_vector([0, 4, 0]))
1720
hole4 = hole.transformed(Translation.from_vector([0, -4, 0]))
1821

19-
V, F = constrained_delaunay_triangulation(boundary, [hole1, hole2, hole3, hole4], [], maxlength=1.0)
22+
holes = [hole1, hole2, hole3, hole4]
23+
24+
# ==============================================================================
25+
# Triangulation
26+
# ==============================================================================
27+
28+
V, F = constrained_delaunay_triangulation(boundary, holes, maxlength=1.0)
2029

2130
mesh = Mesh.from_vertices_and_faces(V, F)
2231

32+
# ==============================================================================
33+
# Viz
34+
# ==============================================================================
35+
2336
plotter = Plotter(figsize=(8, 8))
2437
plotter.add(mesh, sizepolicy='absolute', vertexsize=5)
2538
plotter.zoom_extents()

src/triangulations.cpp

Lines changed: 4 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -87,59 +87,6 @@ pmp_delaunay_triangulation(Eigen::Ref<const compas::RowMatrixXd> & V)
8787
return F;
8888
}
8989

90-
// ===========================================================================
91-
// ===========================================================================
92-
// ===========================================================================
93-
// CDT
94-
// ===========================================================================
95-
// ===========================================================================
96-
// ===========================================================================
97-
98-
// compas::RowMatrixXd
99-
// pmp_constrained_delaunay_triangulation(
100-
// Eigen::Ref<const compas::RowMatrixXd> & V,
101-
// Eigen::Ref<const compas::RowMatrixXi> & E)
102-
// {
103-
// CDT triangulation;
104-
105-
// std::vector< CDT::Vertex_handle > vertex_handles(V.rows());
106-
107-
// for (int i=0; i < V.rows(); i++) {
108-
// CDT::Point point = CDT::Point(V(i, 0), V(i, 1));
109-
// vertex_handles[i] = triangulation.insert(point);
110-
// }
111-
112-
// for (int i=0; i < E.rows(); i++) {
113-
// triangulation.insert_constraint(
114-
// vertex_handles[E(i, 0)],
115-
// vertex_handles[E(i, 1)]
116-
// );
117-
// }
118-
119-
// compas::RowMatrixXd F(triangulation.number_of_faces(), 6);
120-
121-
// int j = 0;
122-
// for (CDT::Finite_faces_iterator fit = triangulation.finite_faces_begin(); fit != triangulation.finite_faces_end(); fit++) {
123-
// CDT::Face_handle face = fit;
124-
125-
// CDT::Point a = face->vertex(0)->point();
126-
// CDT::Point b = face->vertex(1)->point();
127-
// CDT::Point c = face->vertex(2)->point();
128-
129-
// F(j, 0) = a.hx();
130-
// F(j, 1) = a.hy();
131-
132-
// F(j, 2) = b.hx();
133-
// F(j, 3) = b.hy();
134-
135-
// F(j, 4) = c.hx();
136-
// F(j, 5) = c.hy();
137-
138-
// j++;
139-
// }
140-
141-
// return F;
142-
// }
14390

14491
// ===========================================================================
14592
// ===========================================================================
@@ -167,7 +114,7 @@ pmp_delaunay_triangulation(Eigen::Ref<const compas::RowMatrixXd> & V)
167114
// CDT::Face_handle face = queue.front();
168115

169116
// queue.pop_front();
170-
117+
171118
// if (face->info().nesting_level == -1) {
172119
// face->info().nesting_level = index;
173120

@@ -201,11 +148,11 @@ pmp_delaunay_triangulation(Eigen::Ref<const compas::RowMatrixXd> & V)
201148
// for (CDT::Face_handle face : triangulation.all_face_handles()) {
202149
// face->info().nesting_level = -1;
203150
// }
204-
151+
205152
// std::list<CDT::Edge> border;
206153

207154
// mark_domains(triangulation, triangulation.infinite_face(), 0, border);
208-
155+
209156
// while (! border.empty()) {
210157
// CDT::Edge edge = border.front();
211158
// border.pop_front();
@@ -304,6 +251,7 @@ pmp_constrained_delaunay_triangulation(
304251
}
305252

306253
CGAL::refine_Delaunay_mesh_2(triangulation, seeds.begin(), seeds.end(), criteria);
254+
307255
CGAL::lloyd_optimize_mesh_2(triangulation,
308256
CGAL::parameters::max_iteration_number = 10,
309257
CGAL::parameters::seeds_begin = seeds.begin(),
@@ -352,7 +300,6 @@ pmp_constrained_delaunay_triangulation(
352300
for (CDT::Finite_faces_iterator fit = triangulation.finite_faces_begin(); fit != triangulation.finite_faces_end(); fit++) {
353301
CDT::Face_handle face = fit;
354302

355-
// if (face->info().in_domain()) {
356303
if (fit->is_in_domain()) {
357304
CDT::Vertex_handle a = face->vertex(0);
358305
CDT::Vertex_handle b = face->vertex(1);
@@ -371,39 +318,6 @@ pmp_constrained_delaunay_triangulation(
371318
}
372319

373320

374-
// /**
375-
// * Conforming delaunay triangulation of a given boundary
376-
// * with internal holes and constraint curves.
377-
// *
378-
// * @param B The vertices of the boundary.
379-
// * @param holes A list of holes in the triangulation.
380-
// * @param curves A list of internal polyline constraints.
381-
// */
382-
// std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
383-
// pmp_conforming_delaunay_triangulation(
384-
// Eigen::Ref<const compas::RowMatrixXd> & B,
385-
// std::vector< Eigen::Ref<const compas::RowMatrixXd> > & holes,
386-
// std::vector< Eigen::Ref<const compas::RowMatrixXd> > & curves)
387-
// {
388-
// std::tuple<compas::RowMatrixXd, compas::RowMatrixXi> cdt = pmp_constrained_delaunay_triangulation(B, holes, curves);
389-
390-
// std::list<CDT::Point> seeds;
391-
392-
// for (auto hit : holes) {
393-
// compas::RowMatrixXd H = hit;
394-
395-
// double n = (double) H.rows();
396-
397-
// double x = H.block(0, 0, H.rows(), 1).sum() / n;
398-
// double y = H.block(0, 1, H.rows(), 1).sum() / n;
399-
400-
// seeds.push_back(CDT::Point(x, y));
401-
// }
402-
403-
// CGAL::refine_Delaunay_mesh_2(cdt, seeds.begin(), seeds.end(), Criteria());
404-
// }
405-
406-
407321
// ===========================================================================
408322
// ===========================================================================
409323
// ===========================================================================
@@ -421,13 +335,6 @@ void init_triangulations(py::module & m) {
421335
py::arg("V").noconvert()
422336
);
423337

424-
// submodule.def(
425-
// "constrained_delaunay_triangulation",
426-
// &pmp_constrained_delaunay_triangulation,
427-
// py::arg("V").noconvert(),
428-
// py::arg("E").noconvert()
429-
// );
430-
431338
submodule.def(
432339
"constrained_delaunay_triangulation",
433340
&pmp_constrained_delaunay_triangulation,

src/triangulations.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,6 @@ pmp_delaunay_triangulation(
99
Eigen::Ref<const compas::RowMatrixXd> & V);
1010

1111

12-
// compas::RowMatrixXd
13-
// pmp_constrained_delaunay_triangulation(
14-
// Eigen::Ref<const compas::RowMatrixXd> & V,
15-
// Eigen::Ref<const compas::RowMatrixXi> & E);
16-
17-
1812
std::tuple<compas::RowMatrixXd, compas::RowMatrixXi>
1913
pmp_constrained_delaunay_triangulation(
2014
Eigen::Ref<const compas::RowMatrixXd> & B,

0 commit comments

Comments
 (0)