Revision: 73812
http://sourceforge.net/p/brlcad/code/73812
Author: starseeker
Date: 2019-08-31 21:50:33 +0000 (Sat, 31 Aug 2019)
Log Message:
-----------
Associating the edge segments with the trims isn't working reliably - some
segments seem to be referencing deleted edges. I'm still not completely sure
why that wasn't working - a trim shouldn't survive to reference an obsolete
edge container, so it may be an indication of a bookkeeping problem
somewhere... For now, just go with using the trim information directly.
Slightly less than ideal if the trims are far from the edge when building 3D
rtrees - boxes will have to be expanded enough to be sure we're capturing the
needed locality.
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:19:50 UTC (rev 73811)
+++ brlcad/trunk/src/libbrep/cdt2.cpp 2019-08-31 21:50:33 UTC (rev 73812)
@@ -70,7 +70,7 @@
std::cout << "\n";
}
#endif
-#if 0
+#if 1
void
debug_bseg(cdt_mesh::bedge_seg_t *bseg, int seg_id)
{
@@ -154,11 +154,14 @@
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];
- ON_3dPoint *p3d1 = pe->eseg->e_start;
- ON_3dPoint *p3d2 = pe->eseg->e_end;
- ON_Line line(*p3d1, *p3d2);
+ 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_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;
@@ -583,13 +586,13 @@
poly1_ne1->trim_ind = trim_ind;
poly1_ne1->trim_start = old_trim_start;
poly1_ne1->trim_end = t1mid;
- poly1_ne1->eseg = bseg1;
+ 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->eseg = bseg2;
+ poly1_ne2->brep = s_cdt->brep;
}
{
cdt_mesh::cpolygon_t *poly2 = bseg->tseg2->polygon;
@@ -606,13 +609,13 @@
poly2_ne1->trim_ind = trim_ind;
poly2_ne1->trim_start = old_trim_start;
poly2_ne1->trim_end = t2mid;
- poly2_ne1->eseg = bseg1;
+ 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->eseg = bseg2;
+ poly2_ne2->brep = s_cdt->brep;
}
// The new trim segments are then associated with the new bounding edge
@@ -631,6 +634,10 @@
nedges.insert(bseg2);
delete bseg;
+
+ //debug_bseg(bseg1, 1);
+ //debug_bseg(bseg2, 2);
+
return nedges;
}
@@ -668,13 +675,13 @@
poly_ne1->trim_ind = trim_ind;
poly_ne1->trim_start = old_trim_start;
poly_ne1->trim_end = tcparam;
- poly_ne1->eseg = NULL;
+ poly_ne1->brep = s_cdt->brep;
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->eseg = NULL;
+ poly_ne2->brep = s_cdt->brep;
nedges.insert(poly_ne1);
nedges.insert(poly_ne2);
@@ -951,7 +958,6 @@
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;
@@ -964,9 +970,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:19:50 UTC (rev
73811)
+++ brlcad/trunk/src/libbrep/cdt_mesh.cpp 2019-08-31 21:50:33 UTC (rev
73812)
@@ -171,35 +171,28 @@
void
cpolyedge_t::plot3d(const char *fname)
{
- // 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);
+ 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);
- } else {
- std::cout << "no brep information available on trim segment\n";
- }
-
+ fclose(plot_file);
}
void
Modified: brlcad/trunk/src/libbrep/cdt_mesh.h
===================================================================
--- brlcad/trunk/src/libbrep/cdt_mesh.h 2019-08-31 21:19:50 UTC (rev 73811)
+++ brlcad/trunk/src/libbrep/cdt_mesh.h 2019-08-31 21:50:33 UTC (rev 73812)
@@ -299,7 +299,7 @@
int trim_ind;
double trim_start;
double trim_end;
- bedge_seg_t *eseg;
+ ON_Brep *brep;
};
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