Revision: 73869
          http://sourceforge.net/p/brlcad/code/73869
Author:   starseeker
Date:     2019-09-10 13:19:59 +0000 (Tue, 10 Sep 2019)
Log Message:
-----------
near loops check should be redundant now...

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

Modified: brlcad/trunk/src/libbrep/cdt.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt.cpp    2019-09-10 13:07:56 UTC (rev 73868)
+++ brlcad/trunk/src/libbrep/cdt.cpp    2019-09-10 13:19:59 UTC (rev 73869)
@@ -613,12 +613,11 @@
 
        // Now, process the linear edges
        tol_linear_edges_split(s_cdt);
-
-       // Do another pass to break down edges that are close to other loops 
and have segment
-       // lengths that are large compared to the nearby loop polygons
-       refine_near_loops(s_cdt);
 #endif
 
+#if 0
+       // TODO - this step may be redundant with the close_edge refinement...
+       //
        // 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
        // to be cleaned up.
@@ -649,6 +648,7 @@
                }
            }
        }
+#endif
 
 #if 0
        // Build RTrees of 2D and 3D edge segments for edge aware processing

Modified: brlcad/trunk/src/libbrep/cdt_edge.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_edge.cpp       2019-09-10 13:07:56 UTC (rev 
73868)
+++ brlcad/trunk/src/libbrep/cdt_edge.cpp       2019-09-10 13:19:59 UTC (rev 
73869)
@@ -250,61 +250,6 @@
     s_cdt->edge_segs_3d[trim.Face()->m_face_index].Insert(p1, p2, (void *)pe);
 }
 
-struct rtree_loop_leaf {
-    struct ON_Brep_CDT_State *s_cdt;
-    int loop_index;
-};
-
-// Used for finding "close" loops that might require further edge splitting
-static void
-rtree_loop_2d(struct ON_Brep_CDT_State *s_cdt, int loop_index)
-{
-    ON_BrepLoop& loop = s_cdt->brep->m_L[loop_index];
-    ON_BrepFace *face = loop.Face();
-
-    struct rtree_loop_leaf *leaf = new struct rtree_loop_leaf;
-
-    leaf->s_cdt = s_cdt;
-    leaf->loop_index = loop_index;
-
-    ON_BoundingBox bb;
-    loop.GetBoundingBox(bb);
-    bb.m_max.x = bb.m_max.x + ON_ZERO_TOLERANCE;
-    bb.m_max.y = bb.m_max.y + ON_ZERO_TOLERANCE;
-    bb.m_min.x = bb.m_min.x - ON_ZERO_TOLERANCE;
-    bb.m_min.y = bb.m_min.y - ON_ZERO_TOLERANCE;
-    double p1[2];
-    p1[0] = bb.Min().x;
-    p1[1] = bb.Min().y;
-    double p2[2];
-    p2[0] = bb.Max().x;
-    p2[1] = bb.Max().y;
-    s_cdt->loops_2d[face->m_face_index].Insert(p1, p2, (void *)leaf);
-}
-
-struct rtree_loop_context {
-    double seg_len;
-    bool *split_edge;
-    double target_len;
-};
-
-static bool Loop2dCallback(void *data, void *a_context) {
-    struct rtree_loop_leaf *ldata = (struct rtree_loop_leaf *)data;
-    struct rtree_loop_context *edata = (struct rtree_loop_context *)a_context;
-
-    // Get loop's median distance
-    double lmed = ldata->s_cdt->l_median_len[ldata->loop_index];
-    if (edata->seg_len > 5*lmed) {
-       *edata->split_edge = true;
-    }
-    if (edata->target_len > 5*lmed) {
-       edata->target_len = 5*lmed;
-    }
-
-    // Keep checking for other loops - we want the smallest target length
-    return true;
-}
-
 struct rtree_minsplit_context {
     struct ON_Brep_CDT_State *s_cdt;
     cdt_mesh::cpolyedge_t *cseg;
@@ -1517,118 +1462,6 @@
 }
 
 void
-refine_near_loops(struct ON_Brep_CDT_State *s_cdt)
-{
-    ON_Brep* brep = s_cdt->brep;
-
-    // First, build the loop rtree and get the median lengths again.  This 
time we use all loop
-    // segments, not just curved segments.
-    for (int index = 0; index < brep->m_L.Count(); index++) {
-
-       // Build the rtree leaf
-       rtree_loop_2d(s_cdt, index);
-
-       // Get inclusive median length
-       const ON_BrepLoop &loop = brep->m_L[index];
-       std::vector<double> lsegs;
-       for (int lti = 0; lti < loop.TrimCount(); lti++) {
-           ON_BrepTrim *trim = loop.Trim(lti);
-           ON_BrepEdge *edge = trim->Edge();
-           if (!edge) continue;
-           const ON_Curve* crv = edge->EdgeCurveOf();
-           if (!crv) continue;
-           std::vector<cdt_mesh::bedge_seg_t *> &epsegs = 
s_cdt->e2polysegs[edge->m_edge_index];
-           if (!epsegs.size()) continue;
-           std::vector<cdt_mesh::bedge_seg_t *>::iterator e_it;
-           for (e_it = epsegs.begin(); e_it != epsegs.end(); e_it++) {
-               cdt_mesh::bedge_seg_t *b = *e_it;
-               double seg_dist = b->e_start->DistanceTo(*b->e_end);
-               lsegs.push_back(seg_dist);
-           }
-       }
-       s_cdt->l_median_len[index] = median_seg_len(lsegs);
-    }
-
-    // Now, check all the edge segments to see if we are close to a loop with
-    // smaller segments (or if our own loop has a median segment length smaller
-    // than the current segment.)  If so, split.
-    for (int index = 0; index < brep->m_E.Count(); index++) {
-       ON_BrepEdge& edge = brep->m_E[index];
-       const ON_Curve* crv = edge.EdgeCurveOf();
-       if (!crv) continue;
-       std::vector<cdt_mesh::bedge_seg_t *> &epsegs = 
s_cdt->e2polysegs[edge.m_edge_index];
-       std::vector<cdt_mesh::bedge_seg_t *>::iterator e_it;
-       std::set<cdt_mesh::bedge_seg_t *> new_segs;
-       std::set<cdt_mesh::bedge_seg_t *> ws1, ws2;
-       std::set<cdt_mesh::bedge_seg_t *> *ws = &ws1;
-       std::set<cdt_mesh::bedge_seg_t *> *ns = &ws2;
-       for (e_it = epsegs.begin(); e_it != epsegs.end(); e_it++) {
-           cdt_mesh::bedge_seg_t *b = *e_it;
-           ws->insert(b);
-       }
-       while (ws->size()) {
-           cdt_mesh::bedge_seg_t *b = *ws->begin();
-           ws->erase(ws->begin());
-           bool split_edge = false;
-           double target_len = DBL_MAX;
-           for (int i = 0; i < 2; i++) {
-               ON_BrepTrim *trim = edge.Trim(i);
-               ON_BrepFace *face = trim->Face();
-
-               // Get segment length - should be smaller than our target 
length.
-               cdt_mesh::cpolyedge_t *tseg = (b->tseg1->trim_ind == 
trim->m_trim_index) ? b->tseg1 : b->tseg2;
-               ON_2dPoint p2d1 = 
s_cdt->brep->m_T[tseg->trim_ind].PointAt(tseg->trim_start);
-               ON_2dPoint p2d2 = 
s_cdt->brep->m_T[tseg->trim_ind].PointAt(tseg->trim_end);
-               ON_Line l(p2d1, p2d2);
-               double slen = l.Length();
-               // Trim 2D bbox
-               ON_BoundingBox tbb(p2d1, p2d2);
-               double tMin[2];
-               double tMax[2];
-               double xbump = (fabs(tbb.Max().x - tbb.Min().x)) < slen ? 
0.8*slen : ON_ZERO_TOLERANCE;
-               double ybump = (fabs(tbb.Max().y - tbb.Min().y)) < slen ? 
0.8*slen : ON_ZERO_TOLERANCE;
-               tMin[0] = tbb.Min().x - xbump;
-               tMin[1] = tbb.Min().y - ybump;
-               tMax[0] = tbb.Max().x + xbump;
-               tMax[1] = tbb.Max().y + ybump;
-
-               // Edge context info
-               struct rtree_loop_context a_context;
-               a_context.seg_len = l.Length();
-               a_context.split_edge = &split_edge;
-               a_context.target_len = DBL_MAX;
-
-               // Do the search
-               if (!s_cdt->loops_2d[face->m_face_index].Search(tMin, tMax, 
Loop2dCallback, (void *)&a_context)) {
-                   continue;
-               } else {
-                   target_len = (a_context.target_len < target_len) ? 
a_context.target_len : target_len;
-               }
-           }
-
-           if (split_edge) {
-               // If we need to split, do so
-               std::set<cdt_mesh::bedge_seg_t *> esegs_split = 
split_edge_seg(s_cdt, b, 1);
-               if (esegs_split.size()) {
-                   ws->insert(esegs_split.begin(), esegs_split.end());
-               } else {
-                   new_segs.insert(b);
-               }
-           } else {
-               new_segs.insert(b);
-           }
-           if (!ws->size() && ns->size()) {
-               std::set<cdt_mesh::bedge_seg_t *> *tmp = ws;
-               ws = ns;
-               ns = tmp;
-           }
-       }
-       s_cdt->e2polysegs[edge.m_edge_index].clear();
-       std::copy(new_segs.begin(), new_segs.end(), 
std::back_inserter(s_cdt->e2polysegs[edge.m_edge_index]));
-    }
-}
-
-void
 refine_close_edges(struct ON_Brep_CDT_State *s_cdt)
 {
     ON_Brep* brep = s_cdt->brep;
@@ -1636,6 +1469,7 @@
     for (int face_index = 0; face_index < brep->m_F.Count(); face_index++) {
        ON_BrepFace &face = s_cdt->brep->m_F[face_index];
        cdt_mesh::cdt_mesh_t *fmesh = &s_cdt->fmeshes[face_index];
+       std::cout << "Face " << face_index << " close edge check...\n";
 
        std::vector<cdt_mesh::cpolyedge_t *> ws;
        std::vector<cdt_mesh::cpolyedge_t *>::iterator w_it;
@@ -1681,11 +1515,15 @@
 
            bool split_check = false;
 
-#if 1
+#if 0
            if (split_cnt) {
                std::cout << "Face " << face_index << " split_cnt " << 
split_cnt << "\n";
            }
 #endif
+           // TODO - with the status determination being recorded in the 
cpolyedge_t structure
+           // itself, this loop should be (in principle) suitable for 
bu_parallel - we're not
+           // doing any splitting at this point - searching is a read only 
activity once
+           // the initial data containers are set up
            for (w_it = ws.begin(); w_it != ws.end(); w_it++) {
                cdt_mesh::cpolyedge_t *tseg = *w_it;
                ON_2dPoint p2d1 = 
s_cdt->brep->m_T[tseg->trim_ind].PointAt(tseg->trim_start);
@@ -1795,7 +1633,7 @@
                std::copy(m_it->second.begin(), m_it->second.end(), 
std::back_inserter(s_cdt->e2polysegs[m_edge_index]));
            }
 
-#if 1
+#if 0
            struct bu_vls fname = BU_VLS_INIT_ZERO;
            bu_vls_sprintf(&fname, "%d-rtree_2d_split_update_%d.plot3", 
face.m_face_index, split_cnt);
            plot_rtree_2d2(s_cdt->trim_segs[face_index], bu_vls_cstr(&fname));

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