Revision: 73847
          http://sourceforge.net/p/brlcad/code/73847
Author:   starseeker
Date:     2019-09-06 18:17:10 +0000 (Fri, 06 Sep 2019)
Log Message:
-----------
This gets Solid1.s in NIST7-10 generating a solid bot, but NIST2 isn't quite 
happy.

Modified Paths:
--------------
    brlcad/trunk/src/libbrep/cdt.cpp
    brlcad/trunk/src/libbrep/cdt_mesh.cpp
    brlcad/trunk/src/libbrep/cdt_mesh.h

Modified: brlcad/trunk/src/libbrep/cdt.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt.cpp    2019-09-06 15:46:18 UTC (rev 73846)
+++ brlcad/trunk/src/libbrep/cdt.cpp    2019-09-06 18:17:10 UTC (rev 73847)
@@ -175,7 +175,6 @@
     s_cdt->edge_segs_3d[trim.Face()->m_face_index].Insert(p1, p2, (void *)pe);
 }
 
-#if 0
 struct rtree_loop_leaf {
     struct ON_Brep_CDT_State *s_cdt;
     int loop_index;
@@ -230,7 +229,6 @@
     // Keep checking for other loops - we want the smallest target length
     return true;
 }
-#endif
 
 double
 median_seg_len(std::vector<double> &lsegs)
@@ -947,12 +945,10 @@
 
     // Now, the hard part - create local subsets, remesh them, and replace the 
original
     // triangles with the new ones.
-#if 1
     if (!fmesh->repair()) {
        bu_log("Face %d: repair FAILED!\n", fmesh->f_id);
        return false;
     }
-#endif
 
     if (fmesh->valid(1)) {
        bu_log("Face %d: successful triangulation after %d passes\n", 
fmesh->f_id, cnt);
@@ -1024,7 +1020,7 @@
 
     // Sample the surface, independent of the trimming curves, to get points 
that
     // will tie the mesh to the interior surface.
-    //GetInteriorPoints(s_cdt, face.m_face_index);
+    GetInteriorPoints(s_cdt, face.m_face_index);
 
     cdt_mesh::cdt_mesh_t *fmesh = &s_cdt->fmeshes[face.m_face_index];
     fmesh->f_id = face.m_face_index;
@@ -1411,6 +1407,8 @@
            int loop_cnt = face.LoopCount();
            cdt_mesh::cdt_mesh_t *fmesh = &s_cdt->fmeshes[face_index];
            fmesh->f_id = face_index;
+           fmesh->m_bRev = face.m_bRev;
+           fmesh->has_singularities = false;
            cdt_mesh::cpolygon_t *cpoly = NULL;
 
            for (int li = 0; li < loop_cnt; li++) {
@@ -1524,6 +1522,7 @@
                        // splitting of the 2D edge only
                        ne->eseg = NULL;
                        singular_edges.insert(ne);
+                       fmesh->has_singularities = true;
                    }
                }
            }
@@ -1569,11 +1568,13 @@
        // in combination with the above this should give us the sparsest valid
        // triangulation we can return and provide a solid basis on which to
        // build.
+       //
+       // Note that while the face will report individually valid, without
+       // surface point sampling near the edges odd things may still happen in
+       // the final mesh.
        for (int index = 0; index < brep->m_F.Count(); index++) {
            ON_BrepFace &face = s_cdt->brep->m_F[index];
            cdt_mesh::cdt_mesh_t *fmesh = &s_cdt->fmeshes[face.m_face_index];
-           fmesh->f_id = face.m_face_index;
-           fmesh->m_bRev = face.m_bRev;
            // List singularities
            for (size_t i = 0; i < fmesh->pnts.size(); i++) {
                ON_3dPoint *p3d = fmesh->pnts[i];
@@ -1627,7 +1628,7 @@
            fmesh->reset();
 
        }
-#if 0
+
        // On to tolerance based splitting.  Process the non-linear edges first 
-
        // we will need information from them to handle the linear edges
        //
@@ -1961,7 +1962,6 @@
            s_cdt->e2polysegs[edge.m_edge_index].clear();
            s_cdt->e2polysegs[edge.m_edge_index].insert(new_segs.begin(), 
new_segs.end());
        }
-#endif
 
        // Split singularity trims in 2D to provide an easier input to the 2D 
CDT logic.  NOTE: these
        // splits will produce degenerate (zero area, two identical vertex) 
triangles in 3D that have
@@ -2007,6 +2007,7 @@
            }
        }
 
+#if 0
        for (int index = 0; index < brep->m_F.Count(); index++) {
            struct bu_vls fname = BU_VLS_INIT_ZERO;
            bu_vls_sprintf(&fname, "%d-rtree_2d.plot3", index);
@@ -2014,6 +2015,7 @@
            bu_vls_sprintf(&fname, "%d-rtree_3d.plot3", index);
            plot_rtree_3d(s_cdt->edge_segs_3d[index], bu_vls_cstr(&fname));
        }
+#endif
 
     } else {
        /* Clear the mesh state, if this container was previously used */

Modified: brlcad/trunk/src/libbrep/cdt_mesh.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_mesh.cpp       2019-09-06 15:46:18 UTC (rev 
73846)
+++ brlcad/trunk/src/libbrep/cdt_mesh.cpp       2019-09-06 18:17:10 UTC (rev 
73847)
@@ -2437,8 +2437,10 @@
        tri3d.v[0] = p2ind[pnts[p2d3d[tri2d.v[0]]]];
        tri3d.v[1] = p2ind[pnts[p2d3d[tri2d.v[1]]]];
        tri3d.v[2] = p2ind[pnts[p2d3d[tri2d.v[2]]]];
-
-       if (m_bRev) {
+       
+       ON_3dVector tdir = tnorm(tri3d);
+       ON_3dVector bdir = bnorm(tri3d);
+       if (tdir.Length() > 0 && bdir.Length() > 0 && ON_DotProduct(tdir, bdir) 
< 0.1) {
            long tmp = tri3d.v[1];
            tri3d.v[1] = tri3d.v[2];
            tri3d.v[2] = tmp;
@@ -2505,33 +2507,35 @@
     // remesh near singularities to try and produce more reasonable
     // triangles.
 
-    std::vector<triangle_t> s_tris = this->singularity_triangles();
-    seed_tris.insert(s_tris.begin(), s_tris.end());
+    if (has_singularities) {
+       std::vector<triangle_t> s_tris = this->singularity_triangles();
+       seed_tris.insert(s_tris.begin(), s_tris.end());
 
-    st_size = seed_tris.size();
-    while (seed_tris.size()) {
-       triangle_t seed = *seed_tris.begin();
+       st_size = seed_tris.size();
+       while (seed_tris.size()) {
+           triangle_t seed = *seed_tris.begin();
 
-       double deg = max_angle_delta(seed, s_tris);
-       bool pseed = process_seed_tri(seed, false, deg);
+           double deg = max_angle_delta(seed, s_tris);
+           bool pseed = process_seed_tri(seed, false, deg);
 
-       if (!pseed || seed_tris.size() >= st_size) {
-           std::cerr << f_id << ":  Error - failed to process refinement seed 
triangle!\n";
-           struct bu_vls fname = BU_VLS_INIT_ZERO;
-           bu_vls_sprintf(&fname, "%d-failed_seed.plot3", f_id);
-           tri_plot(seed, bu_vls_cstr(&fname));
-           bu_vls_sprintf(&fname, "%d-failed_seed_mesh.plot3", f_id);
-           tris_plot(bu_vls_cstr(&fname));
-           bu_vls_sprintf(&fname, "%d-failed_seed.cdtmesh", f_id);
-           serialize(bu_vls_cstr(&fname));
-           bu_vls_free(&fname);
-           return false;
-           break;
-       }
+           if (!pseed || seed_tris.size() >= st_size) {
+               std::cerr << f_id << ":  Error - failed to process refinement 
seed triangle!\n";
+               struct bu_vls fname = BU_VLS_INIT_ZERO;
+               bu_vls_sprintf(&fname, "%d-failed_seed.plot3", f_id);
+               tri_plot(seed, bu_vls_cstr(&fname));
+               bu_vls_sprintf(&fname, "%d-failed_seed_mesh.plot3", f_id);
+               tris_plot(bu_vls_cstr(&fname));
+               bu_vls_sprintf(&fname, "%d-failed_seed.cdtmesh", f_id);
+               serialize(bu_vls_cstr(&fname));
+               bu_vls_free(&fname);
+               return false;
+               break;
+           }
 
-       st_size = seed_tris.size();
+           st_size = seed_tris.size();
 
-       //tris_plot("mesh_post_pretty.plot3");
+           //tris_plot("mesh_post_pretty.plot3");
+       }
     }
 
     boundary_edges_update();

Modified: brlcad/trunk/src/libbrep/cdt_mesh.h
===================================================================
--- brlcad/trunk/src/libbrep/cdt_mesh.h 2019-09-06 15:46:18 UTC (rev 73846)
+++ brlcad/trunk/src/libbrep/cdt_mesh.h 2019-09-06 18:17:10 UTC (rev 73847)
@@ -475,6 +475,7 @@
 
 
     int f_id;
+    bool has_singularities;
 
     /* Data containers */
     std::map<ON_3dPoint *, long> p2ind;

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