Revision: 74262
          http://sourceforge.net/p/brlcad/code/74262
Author:   starseeker
Date:     2019-10-29 21:42:56 +0000 (Tue, 29 Oct 2019)
Log Message:
-----------
Make closest uedge search more robust.  Still getting invalidity from somewhere.

Modified Paths:
--------------
    brlcad/trunk/src/libbrep/cdt_ovlps.cpp

Modified: brlcad/trunk/src/libbrep/cdt_ovlps.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_ovlps.cpp      2019-10-29 21:07:42 UTC (rev 
74261)
+++ brlcad/trunk/src/libbrep/cdt_ovlps.cpp      2019-10-29 21:42:56 UTC (rev 
74262)
@@ -379,6 +379,8 @@
     std::set<cdt_mesh::uedge_t> uedges;
     uedges.clear();
 
+    ON_3dPoint opnt = bb.Center();
+
     if (!fmesh->pnts.size()) return uedges;
 
     ON_BoundingBox fbbox = fmesh->bbox();
@@ -387,15 +389,18 @@
     // find the closest interior edge
     ON_BoundingBox s_bb = bb;
     std::set<size_t> ntris = tris_search(s_bb);
-    while (!ntris.size()) {
+    bool last_try = false;
+    while (!ntris.size() && !last_try) {
        ON_3dVector vmin = s_bb.Min() - s_bb.Center();
        ON_3dVector vmax = s_bb.Max() - s_bb.Center();
-       vmin = vmin * 2;
-       vmax = vmax * 2;
-       s_bb.m_min = s_bb.Center() + vmin;
-       s_bb.m_max = s_bb.Center() + vmax;
-       if (s_bb.Diagonal().Length() > fbbox.Diagonal().Length()) {
-           return uedges;
+       vmin.Unitize();
+       vmax.Unitize();
+       vmin = vmin * s_bb.Diagonal().Length() * 2;
+       vmax = vmax * s_bb.Diagonal().Length() * 2;
+       s_bb.m_min = opnt + vmin;
+       s_bb.m_max = opnt + vmax;
+       if (s_bb.Includes(fbbox, true)) {
+           last_try = true;
        }
        ntris = tris_search(s_bb);
     }
@@ -2235,7 +2240,9 @@
     std::set<omesh_t *>::iterator o_it;
     for (o_it = omeshes.begin(); o_it != omeshes.end(); o_it++) {
        omesh_t *omesh = *o_it;
-       
+
+       omesh->fmesh->valid(1);
+
        std::map<cdt_mesh::uedge_t, std::vector<revt_pt_t>> edge_sets;
 
        std::set<overt_t *>::iterator nv_it;
@@ -2256,7 +2263,7 @@
            ON_3dVector sn;
            double dist = ov->bb.Diagonal().Length() * 10;
 
-           if (!closest_surf_pnt(spnt, sn, *omesh->fmesh, &ovpnt, 200*dist)) {
+           if (!closest_surf_pnt(spnt, sn, *omesh->fmesh, &ovpnt, 2*dist)) {
                std::cout << "closest point failed\n";
                omesh->refine_pnt_remove(ov);
                continue;
@@ -2358,6 +2365,7 @@
 
        refine_edge_vert_sets(omesh, &edge_sets);
 
+       omesh->fmesh->valid(1);
     }
 }
 

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

Reply via email to