Revision: 74257
http://sourceforge.net/p/brlcad/code/74257
Author: starseeker
Date: 2019-10-28 21:15:43 +0000 (Mon, 28 Oct 2019)
Log Message:
-----------
If we're using the plain Delaunay method of triangulation, make sure any
triangles returned are inside the polygon.
Modified Paths:
--------------
brlcad/trunk/src/libbrep/cdt_mesh.cpp
brlcad/trunk/src/libbrep/cdt_mesh.h
Modified: brlcad/trunk/src/libbrep/cdt_mesh.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_mesh.cpp 2019-10-28 20:36:34 UTC (rev
74256)
+++ brlcad/trunk/src/libbrep/cdt_mesh.cpp 2019-10-28 21:15:43 UTC (rev
74257)
@@ -1046,7 +1046,27 @@
t.v[1] = faces[3*i+1];
t.v[2] = faces[3*i+2];
- ltris.insert(t);
+ bool inside = true;
+ if (ttype == TRI_DELAUNAY) {
+ double u = 0;
+ double v = 0;
+ for (int j = 0; j < 3; j++) {
+ u = u + pnts_2d[t.v[j]].first;
+ v = v + pnts_2d[t.v[j]].second;
+ }
+ u = u / 3.0;
+ v = v / 3.0;
+ std::pair<double, double> center_2d;
+ center_2d.first = u;
+ center_2d.second = v;
+ pnts_2d.push_back(center_2d);
+ inside = point_in_polygon(pnts_2d.size() - 1, false);
+ pnts_2d.pop_back();
+ }
+
+ if (inside) {
+ ltris.insert(t);
+ }
}
bu_free(faces, "faces array");
@@ -1780,6 +1800,20 @@
return uedges;
}
+bool
+cdt_mesh_t::face_edge_tri(const triangle_t &t)
+{
+ int edge_pts = 0;
+ for (int i = 0; i < 3; i++) {
+ if (ep.find(t.v[i]) != ep.end()) {
+ edge_pts++;
+ }
+ }
+
+ return (edge_pts > 1);
+}
+
+
ON_BoundingBox
cdt_mesh_t::bbox()
{
Modified: brlcad/trunk/src/libbrep/cdt_mesh.h
===================================================================
--- brlcad/trunk/src/libbrep/cdt_mesh.h 2019-10-28 20:36:34 UTC (rev 74256)
+++ brlcad/trunk/src/libbrep/cdt_mesh.h 2019-10-28 21:15:43 UTC (rev 74257)
@@ -513,6 +513,8 @@
ON_Plane tplane(const triangle_t &t);
std::set<uedge_t> uedges(const triangle_t &t);
+ bool face_edge_tri(const triangle_t &t);
+
ON_BoundingBox bbox();
// Find the edge of the triangle that is closest to the
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits