Revision: 73813
          http://sourceforge.net/p/brlcad/code/73813
Author:   starseeker
Date:     2019-09-01 00:33:49 +0000 (Sun, 01 Sep 2019)
Log Message:
-----------
Do the assignment of each trim segment's edge segment after all else is 
finalized.

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

Modified: brlcad/trunk/src/libbrep/cdt2.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt2.cpp   2019-08-31 21:50:33 UTC (rev 73812)
+++ brlcad/trunk/src/libbrep/cdt2.cpp   2019-09-01 00:33:49 UTC (rev 73813)
@@ -70,7 +70,7 @@
     std::cout << "\n";
 }
 #endif
-#if 1
+#if 0
 void
 debug_bseg(cdt_mesh::bedge_seg_t *bseg, int seg_id)
 {
@@ -154,14 +154,11 @@
 void
 rtree_bbox_3d(struct ON_Brep_CDT_State *s_cdt, cdt_mesh::cpolyedge_t *pe)
 {
+    if (!pe->eseg) return;
     ON_BrepTrim& trim = s_cdt->brep->m_T[pe->trim_ind];
-    if (trim.m_type == ON_BrepTrim::singular) return;
-    const ON_Surface *s = trim.Face()->SurfaceOf();
-    ON_2dPoint pt_s = trim.PointAt(pe->trim_start);
-    ON_2dPoint pt_e = trim.PointAt(pe->trim_end);
-    ON_3dPoint p3d1 = s->PointAt(pt_s.x, pt_s.y);
-    ON_3dPoint p3d2 = s->PointAt(pt_e.x, pt_e.y);
-    ON_Line line(p3d1, p3d2);
+    ON_3dPoint *p3d1 = pe->eseg->e_start;
+    ON_3dPoint *p3d2 = pe->eseg->e_end;
+    ON_Line line(*p3d1, *p3d2);
     ON_BoundingBox bb = line.BoundingBox();
     bb.m_max.x = bb.m_max.x + ON_ZERO_TOLERANCE;
     bb.m_max.y = bb.m_max.y + ON_ZERO_TOLERANCE;
@@ -586,13 +583,11 @@
        poly1_ne1->trim_ind = trim_ind;
        poly1_ne1->trim_start = old_trim_start;
        poly1_ne1->trim_end = t1mid;
-       poly1_ne1->brep = s_cdt->brep;
        struct cdt_mesh::edge_t poly1_edge2(poly1_2dind, v[1]);
        poly1_ne2 = poly1->add_ordered_edge(poly1_edge2);
        poly1_ne2->trim_ind = trim_ind;
        poly1_ne2->trim_start = t1mid;
        poly1_ne2->trim_end = old_trim_end;
-       poly1_ne2->brep = s_cdt->brep;
     }
     {
        cdt_mesh::cpolygon_t *poly2 = bseg->tseg2->polygon;
@@ -609,13 +604,11 @@
        poly2_ne1->trim_ind = trim_ind;
        poly2_ne1->trim_start = old_trim_start;
        poly2_ne1->trim_end = t2mid;
-       poly2_ne1->brep = s_cdt->brep;
        struct cdt_mesh::edge_t poly2_edge2(poly2_2dind, v[1]);
        poly2_ne2 = poly2->add_ordered_edge(poly2_edge2);
        poly2_ne2->trim_ind = trim_ind;
        poly2_ne2->trim_start = t2mid;
        poly2_ne2->trim_end = old_trim_end;
-       poly2_ne2->brep = s_cdt->brep;
     }
 
     // The new trim segments are then associated with the new bounding edge
@@ -630,14 +623,17 @@
     bseg2->tseg1 = (trim1->m_bRev3d) ? poly1_ne1 : poly1_ne2;
     bseg2->tseg2 = (trim2->m_bRev3d) ? poly2_ne1 : poly2_ne2;
 
+    // Associated the trim segments with the edge segment they actually
+    // wound up assigned to
+    bseg1->tseg1->eseg = bseg1;
+    bseg1->tseg2->eseg = bseg1;
+    bseg2->tseg1->eseg = bseg2;
+    bseg2->tseg2->eseg = bseg2;
+
     nedges.insert(bseg1);
     nedges.insert(bseg2);
 
     delete bseg;
-
-    //debug_bseg(bseg1, 1);
-    //debug_bseg(bseg2, 2);
-
     return nedges;
 }
 
@@ -675,13 +671,13 @@
     poly_ne1->trim_ind = trim_ind;
     poly_ne1->trim_start = old_trim_start;
     poly_ne1->trim_end = tcparam;
-    poly_ne1->brep = s_cdt->brep;
+    poly_ne1->eseg = NULL;
     struct cdt_mesh::edge_t poly_edge2(poly_2dind, v[1]);
     poly_ne2 = poly->add_edge(poly_edge2);
     poly_ne2->trim_ind = trim_ind;
     poly_ne2->trim_start = tcparam;
     poly_ne2->trim_end = old_trim_end;
-    poly_ne2->brep = s_cdt->brep;
+    poly_ne2->eseg = NULL;
 
     nedges.insert(poly_ne1);
     nedges.insert(poly_ne2);
@@ -958,6 +954,7 @@
                if (trim->m_ei >= 0) {
                    cdt_mesh::bedge_seg_t *eseg = 
*s_cdt->e2polysegs[trim->m_ei].begin();
                    // Associate the edge segment with the trim segment and 
vice versa
+                   ne->eseg = eseg;
                    if (eseg->tseg1 && eseg->tseg2) {
                        bu_log("error - more than two trims associated with an 
edge\n");
                        return -1;
@@ -970,9 +967,9 @@
                } else {
                    // A null eseg will indicate a singularity and a need for 
special case
                    // splitting of the 2D edge only
+                   ne->eseg = NULL;
                    singular_edges.insert(ne);
                }
-               ne->brep = s_cdt->brep;
            }
        }
     }

Modified: brlcad/trunk/src/libbrep/cdt_mesh.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_mesh.cpp       2019-08-31 21:50:33 UTC (rev 
73812)
+++ brlcad/trunk/src/libbrep/cdt_mesh.cpp       2019-09-01 00:33:49 UTC (rev 
73813)
@@ -171,28 +171,35 @@
 void
 cpolyedge_t::plot3d(const char *fname)
 {
-    ON_BrepTrim& trim = brep->m_T[trim_ind];
-    ON_3dPoint trim_s_2d = trim.PointAt(trim_start);
-    ON_3dPoint trim_e_2d = trim.PointAt(trim_end);
-    ON_3dPoint trim_s_3d, trim_e_3d;
-    ON_3dVector trim_s_norm, trim_e_norm;
-    surface_EvNormal(trim.SurfaceOf(), trim_s_2d.x, trim_s_2d.y, trim_s_3d, 
trim_s_norm);
-    surface_EvNormal(trim.SurfaceOf(), trim_e_2d.x, trim_e_2d.y, trim_e_3d, 
trim_e_norm);
-    double slen = trim_s_3d.DistanceTo(trim_e_3d);
+    // If our polygon is in 2D, use the Brep to calculate 3D info
+    if (eseg) {
+       ON_Brep *brep = eseg->brep;
+       ON_BrepTrim& trim = brep->m_T[trim_ind];
+       ON_3dPoint trim_s_2d = trim.PointAt(trim_start);
+       ON_3dPoint trim_e_2d = trim.PointAt(trim_end);
+       ON_3dPoint trim_s_3d, trim_e_3d;
+       ON_3dVector trim_s_norm, trim_e_norm;
+       surface_EvNormal(trim.SurfaceOf(), trim_s_2d.x, trim_s_2d.y, trim_s_3d, 
trim_s_norm);
+       surface_EvNormal(trim.SurfaceOf(), trim_e_2d.x, trim_e_2d.y, trim_e_3d, 
trim_e_norm);
+       double slen = trim_s_3d.DistanceTo(trim_e_3d);
 
-    FILE* plot_file = fopen(fname, "w");
+       FILE* plot_file = fopen(fname, "w");
 
-    pl_color(plot_file, 0, 0, 255);
-    plot_seg_3d(plot_file, &trim_s_3d, &trim_e_3d);
+       pl_color(plot_file, 0, 0, 255);
+       plot_seg_3d(plot_file, &trim_s_3d, &trim_e_3d);
 
-    pl_color(plot_file, 255, 0, 0);
-    plot_pnt_3d(plot_file, &trim_s_3d, 0.05*slen, 0);
-    plot_vec_3d(plot_file, &trim_s_3d, &trim_s_norm, 0.2*slen);
-    pl_color(plot_file, 0, 255, 0);
-    plot_pnt_3d(plot_file, &trim_e_3d, 0.05*slen, 0);
-    plot_vec_3d(plot_file, &trim_e_3d, &trim_e_norm, 0.2*slen);
+       pl_color(plot_file, 255, 0, 0);
+       plot_pnt_3d(plot_file, &trim_s_3d, 0.05*slen, 0);
+       plot_vec_3d(plot_file, &trim_s_3d, &trim_s_norm, 0.2*slen);
+       pl_color(plot_file, 0, 255, 0);
+       plot_pnt_3d(plot_file, &trim_e_3d, 0.05*slen, 0);
+       plot_vec_3d(plot_file, &trim_e_3d, &trim_e_norm, 0.2*slen);
 
-    fclose(plot_file);
+       fclose(plot_file);
+    } else {
+       std::cout << "no brep information available on trim segment\n";
+    }
+
 }
 
 void

Modified: brlcad/trunk/src/libbrep/cdt_mesh.h
===================================================================
--- brlcad/trunk/src/libbrep/cdt_mesh.h 2019-08-31 21:50:33 UTC (rev 73812)
+++ brlcad/trunk/src/libbrep/cdt_mesh.h 2019-09-01 00:33:49 UTC (rev 73813)
@@ -299,7 +299,7 @@
        int trim_ind;
        double trim_start;
        double trim_end;
-       ON_Brep *brep;
+       bedge_seg_t *eseg;
 
 };
 

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