Revision: 73907
http://sourceforge.net/p/brlcad/code/73907
Author: starseeker
Date: 2019-09-12 15:56:29 +0000 (Thu, 12 Sep 2019)
Log Message:
-----------
Get more aggressive about keeping points away from 3D edges. Unfortunately,
the 3D rtrees are currently messed up somehow (per NIST2 face 259.)
Modified Paths:
--------------
brlcad/trunk/src/libbrep/cdt.cpp
brlcad/trunk/src/libbrep/cdt_edge.cpp
brlcad/trunk/src/libbrep/cdt_mesh.cpp
brlcad/trunk/src/libbrep/cdt_surf.cpp
Modified: brlcad/trunk/src/libbrep/cdt.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt.cpp 2019-09-12 15:06:25 UTC (rev 73906)
+++ brlcad/trunk/src/libbrep/cdt.cpp 2019-09-12 15:56:29 UTC (rev 73907)
@@ -648,7 +648,7 @@
// Calculate 2D neighbor distances for polyedges
//cpolyedge_nearest_dists(s_cdt);
-#if 0
+#if 1
for (int index = 0; index < brep->m_F.Count(); index++) {
struct bu_vls fname = BU_VLS_INIT_ZERO;
bu_vls_sprintf(&fname, "%d-rtree_outer_polygon.plot3", index);
@@ -655,9 +655,10 @@
cdt_mesh::cdt_mesh_t *fmesh = &s_cdt->fmeshes[index];
fmesh->polygon_plot_2d(&fmesh->outer_loop, bu_vls_cstr(&fname));
bu_vls_sprintf(&fname, "%d-rtree_2d.plot3", index);
- plot_rtree_2d2(s_cdt->trim_segs[index], bu_vls_cstr(&fname));
+ plot_rtree_2d2(s_cdt->face_rtrees_2d[index], bu_vls_cstr(&fname));
+ // TODO - NIST2 259 3D rtree is clearly wrong
bu_vls_sprintf(&fname, "%d-rtree_3d.plot3", index);
- plot_rtree_3d(s_cdt->edge_segs_3d[index], bu_vls_cstr(&fname));
+ plot_rtree_3d(s_cdt->face_rtrees_3d[index], bu_vls_cstr(&fname));
}
#endif
Modified: brlcad/trunk/src/libbrep/cdt_edge.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_edge.cpp 2019-09-12 15:06:25 UTC (rev
73906)
+++ brlcad/trunk/src/libbrep/cdt_edge.cpp 2019-09-12 15:56:29 UTC (rev
73907)
@@ -240,9 +240,17 @@
{
if (!pe->eseg) return;
ON_BrepTrim& trim = s_cdt->brep->m_T[pe->trim_ind];
+ double tcparam = (pe->trim_start + pe->trim_end) / 2.0;
+ ON_3dPoint trim_2d = trim.PointAt(tcparam);
+ const ON_Surface *s = trim.SurfaceOf();
+ ON_3dPoint trim_3d = s->PointAt(trim_2d.x, trim_2d.y);
+
ON_3dPoint *p3d1 = pe->eseg->e_start;
ON_3dPoint *p3d2 = pe->eseg->e_end;
ON_Line line(*p3d1, *p3d2);
+
+ double arc_dist = 2*trim_3d.DistanceTo(line.ClosestPointTo(trim_3d));
+
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;
@@ -252,7 +260,7 @@
bb.m_min.z = bb.m_min.z - ON_ZERO_TOLERANCE;
double dist = p3d1->DistanceTo(*p3d2);
- double bdist = 0.5*dist;
+ double bdist = (0.5*dist > arc_dist) ? 0.5*dist : arc_dist;
double xdist = bb.m_max.x - bb.m_min.x;
double ydist = bb.m_max.y - bb.m_min.y;
double zdist = bb.m_max.z - bb.m_min.z;
@@ -1014,7 +1022,7 @@
}
}
-#if 1
+#if 0
for (int face_index = 0; face_index < s_cdt->brep->m_F.Count();
face_index++) {
struct bu_vls fname = BU_VLS_INIT_ZERO;
bu_vls_sprintf(&fname, "%d-rtree_2d_after_initial_splits.plot3",
face_index);
@@ -1275,10 +1283,13 @@
}
}
}
+
+#if 0
struct bu_vls fname = BU_VLS_INIT_ZERO;
bu_vls_sprintf(&fname, "%d-rtree_2d_initial.plot3", face_index);
plot_rtree_2d2(s_cdt->face_rtrees_2d[face_index], bu_vls_cstr(&fname));
bu_vls_free(&fname);
+#endif
}
return true;
}
@@ -1683,7 +1694,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->face_rtrees_2d[face_index],
bu_vls_cstr(&fname));
Modified: brlcad/trunk/src/libbrep/cdt_mesh.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_mesh.cpp 2019-09-12 15:06:25 UTC (rev
73906)
+++ brlcad/trunk/src/libbrep/cdt_mesh.cpp 2019-09-12 15:56:29 UTC (rev
73907)
@@ -2349,8 +2349,8 @@
if (polygon->visited_triangles.find(target) !=
polygon->visited_triangles.end() && stop_on_contained && !h_uc &&
(polygon->interior_points.size() > 1 || polygon->poly.size() > 3)) {
polygon->print();
- polygon->cdt_inputs_print("cdt_poly.c");
- polygon->polygon_plot("cdt_poly.plot3");
+ //polygon->cdt_inputs_print("cdt_poly.c");
+ //polygon->polygon_plot("cdt_poly.plot3");
bool cdt_status = oriented_polycdt(polygon);
if (cdt_status) {
//tris_set_plot(tris, "patch.plot3");
@@ -2539,8 +2539,8 @@
}
}
- cdt_inputs_print("cdt_inputs.c");
- cdt_inputs_plot("cdt_inputs.plot3");
+ //cdt_inputs_print("cdt_inputs.c");
+ //cdt_inputs_plot("cdt_inputs.plot3");
point2d_t *bgp_2d = (point2d_t *)bu_calloc(m_pnts_2d.size() + 1,
sizeof(point2d_t), "2D points array");
for (size_t i = 0; i < m_pnts_2d.size(); i++) {
Modified: brlcad/trunk/src/libbrep/cdt_surf.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_surf.cpp 2019-09-12 15:06:25 UTC (rev
73906)
+++ brlcad/trunk/src/libbrep/cdt_surf.cpp 2019-09-12 15:56:29 UTC (rev
73907)
@@ -420,7 +420,7 @@
bool *use;
};
-#if 0
+#if 1
static bool UseTrimPntCallback(void *data, void *a_context) {
cdt_mesh::cpolyedge_t *tseg = (cdt_mesh::cpolyedge_t *)data;
struct rtree_trimpnt_context *context= (struct rtree_trimpnt_context
*)a_context;
@@ -475,7 +475,7 @@
sinfo->min_edge = (*s_cdt->min_edge_seg_len)[face_index];
sinfo->max_edge = (*s_cdt->max_edge_seg_len)[face_index];
-#if 0
+#if 1
// If the trims will be contributing points, we need to figure out which
ones
// and assemble an rtree for them. We can't insert points from the general
// build too close to them or we run the risk of duplicate points and very
small
@@ -626,17 +626,29 @@
// Populate m_interior_pnts with the final set
for (osp_it = sinfo->on_surf_points.begin(); osp_it !=
sinfo->on_surf_points.end(); osp_it++) {
ON_2dPoint n2dp(**osp_it);
- long f_ind2d = fmesh->add_point(n2dp);
- fmesh->m_interior_pnts.insert(f_ind2d);
-
- // Add new 3D point and normal values to the fmesh as well TODO - store
these during
- // the build-down in sinfo and then just look them up here...
+ // Calculate the 3D point and normal values.
ON_3dPoint p3d;
ON_3dVector norm = ON_3dVector::UnsetVector;
if (!surface_EvNormal(sinfo->s, n2dp.x, n2dp.y, p3d, norm)) {
p3d = sinfo->s->PointAt(n2dp.x, n2dp.y);
}
+
+ // If we're too close to an edge in 3D, the point is out.
+ double fMin[3];
+ fMin[0] = p3d.x - ON_ZERO_TOLERANCE;
+ fMin[1] = p3d.y - ON_ZERO_TOLERANCE;
+ fMin[2] = p3d.z - ON_ZERO_TOLERANCE;
+ double fMax[3];
+ fMax[0] = p3d.x + ON_ZERO_TOLERANCE;
+ fMax[1] = p3d.y + ON_ZERO_TOLERANCE;
+ fMax[2] = p3d.z + ON_ZERO_TOLERANCE;
+ size_t nhits =
sinfo->s_cdt->face_rtrees_3d[sinfo->f->m_face_index].Search(fMin, fMax, NULL,
NULL);
+ if (nhits) continue;
+
+
+ long f_ind2d = fmesh->add_point(n2dp);
+ fmesh->m_interior_pnts.insert(f_ind2d);
if (fmesh->m_bRev) {
norm = -1 * norm;
}
@@ -1072,7 +1084,7 @@
double px = p2d.x + (bn_rand_half(prand) * 0.3*ulen);
double py = p2d.y + (bn_rand_half(prand) * 0.3*vlen);
-#if 0
+#if 1
double tMin[2];
tMin[0] = (*b_it)->Min().x;
tMin[1] = (*b_it)->Min().y;
@@ -1083,9 +1095,9 @@
if (!nhits) {
sinfo.on_surf_points.insert(new ON_2dPoint(px,py));
- std::cout << "accept pnt\n";
+ //std::cout << "accept pnt\n";
} else {
- std::cout << "reject - already have trim point in here\n";
+ //std::cout << "reject - already have trim point in here\n";
}
#else
sinfo.on_surf_points.insert(new ON_2dPoint(px,py));
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