Revision: 73845
http://sourceforge.net/p/brlcad/code/73845
Author: starseeker
Date: 2019-09-06 15:44:12 +0000 (Fri, 06 Sep 2019)
Log Message:
-----------
BREP_PLANAR_TOL is too large for some objects - base it off of the surface
bounds.
Modified Paths:
--------------
brlcad/trunk/src/libbrep/cdt.cpp
Modified: brlcad/trunk/src/libbrep/cdt.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt.cpp 2019-09-06 13:40:06 UTC (rev 73844)
+++ brlcad/trunk/src/libbrep/cdt.cpp 2019-09-06 15:44:12 UTC (rev 73845)
@@ -31,7 +31,6 @@
#include "bg/chull.h"
#include "./cdt.h"
-#define BREP_PLANAR_TOL 0.05
#define MAX_TRIANGULATION_ATTEMPTS 5
#if 0
@@ -308,7 +307,8 @@
// face normal for this point on this surface.
ON_Plane fplane;
const ON_Surface *s = trim->SurfaceOf();
- if (s->IsPlanar(&fplane, BREP_PLANAR_TOL)) {
+ double ptol = s->BoundingBox().Diagonal().Length()*0.001;
+ if (s->IsPlanar(&fplane, ptol)) {
norm = fplane.Normal();
} else {
ON_3dPoint tmp1;
@@ -745,7 +745,7 @@
{
ON_BrepFace &face = s_cdt->brep->m_F[face_index];
int loop_cnt = face.LoopCount();
-
+
for (int li = 0; li < loop_cnt; li++) {
const ON_BrepLoop *loop = face.Loop(li);
double avg_seg_len = loop_avg_seg_len(s_cdt, loop->m_loop_index);
@@ -945,7 +945,7 @@
// Now, the hard part - create local subsets, remesh them, and replace the
original
// triangles with the new ones.
-#if 0
+#if 1
if (!fmesh->repair()) {
bu_log("Face %d: repair FAILED!\n", fmesh->f_id);
return false;
@@ -1074,7 +1074,8 @@
ON_Plane fplane;
const ON_Surface *s = trim->SurfaceOf();
- if (s->IsPlanar(&fplane, BREP_PLANAR_TOL)) {
+ double ptol = s->BoundingBox().Diagonal().Length()*0.001;
+ if (s->IsPlanar(&fplane, ptol)) {
trim_norm = fplane.Normal();
if (trim->Face()->m_bRev) {
trim_norm = trim_norm * -1;
@@ -1586,14 +1587,21 @@
loop_edges(fmesh, i_it->second);
}
- bool success = (fmesh->cdt() && fmesh->valid(0));
+ bool success = (fmesh->cdt() && fmesh->repair() && fmesh->valid(0));
if (!success) {
-
+
// Start iterating
int cnt = 0;
while (!fmesh->valid(0)) {
//std::cout << "Face " << face.m_face_index << " ,
iteration " << cnt << ": base mesh CDT invalid\n";
+#if 0
+ struct bu_vls fname = BU_VLS_INIT_ZERO;
+ bu_vls_sprintf(&fname, "iteration-%d-tris.p3", cnt);
+ fmesh->tris_plot(bu_vls_cstr(&fname));
+ bu_vls_free(&fname);
+#endif
+
fmesh->reset();
split_long_edges(s_cdt, index);
@@ -1606,14 +1614,9 @@
fmesh->boundary_edges_update();
fmesh->cdt();
+ fmesh->repair();
cnt++;
-#if 0
- struct bu_vls fname = BU_VLS_INIT_ZERO;
- bu_vls_sprintf(&fname, "iteration-%d-tris.p3", cnt);
- fmesh->tris_plot(bu_vls_cstr(&fname));
- bu_vls_free(&fname);
-#endif
}
}
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