Revision: 74208
http://sourceforge.net/p/brlcad/code/74208
Author: starseeker
Date: 2019-10-21 21:08:01 +0000 (Mon, 21 Oct 2019)
Log Message:
-----------
fmeshes aren't closed by themselves - inside/outside is only properly defined
at the object level.
Modified Paths:
--------------
brlcad/trunk/src/libbrep/cdt.h
brlcad/trunk/src/libbrep/cdt_mesh.cpp
brlcad/trunk/src/libbrep/cdt_mesh.h
brlcad/trunk/src/libbrep/cdt_ovlps.cpp
brlcad/trunk/src/libbrep/cdt_util.cpp
Modified: brlcad/trunk/src/libbrep/cdt.h
===================================================================
--- brlcad/trunk/src/libbrep/cdt.h 2019-10-21 20:20:31 UTC (rev 74207)
+++ brlcad/trunk/src/libbrep/cdt.h 2019-10-21 21:08:01 UTC (rev 74208)
@@ -151,7 +151,6 @@
std::map<int, std::map<int,ON_3dPoint *>> strim_pnts;
std::map<int, std::map<int,ON_3dPoint *>> strim_norms;
-
std::map<int, std::map<size_t, std::set<struct brep_face_ovlp_instance
*>>> face_tri_ovlps;
std::map<int, std::set<size_t>> face_ovlp_tris;
std::map<int, std::vector<struct brep_face_ovlp_instance *>> face_ovlps;
@@ -194,6 +193,8 @@
void refine_near_loops(struct ON_Brep_CDT_State *s_cdt);
void finalize_rtrees(struct ON_Brep_CDT_State *s_cdt);
void cpolyedge_nearest_dists(struct ON_Brep_CDT_State *s_cdt);
+bool point_inside(struct ON_Brep_CDT_State *s_cdt, point_t p);
+bool on_point_inside(struct ON_Brep_CDT_State *s_cdt, ON_3dPoint *p);
void plot_rtree_2d(ON_RTree *rtree, const char *filename);
void plot_rtree_2d2(RTree<void *, double, 2> &rtree, const char *filename);
Modified: brlcad/trunk/src/libbrep/cdt_mesh.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_mesh.cpp 2019-10-21 20:20:31 UTC (rev
74207)
+++ brlcad/trunk/src/libbrep/cdt_mesh.cpp 2019-10-21 21:08:01 UTC (rev
74208)
@@ -1985,38 +1985,6 @@
return false;
}
-bool
-cdt_mesh_t::point_inside(point_t p)
-{
- int wn = 0;
- int exact = 0;
- RTree<size_t, double, 3>::Iterator tree_it;
- tris_tree.GetFirst(tree_it);
- size_t t_ind;
- cdt_mesh::triangle_t tri;
- while (!tree_it.IsNull()) {
- t_ind = *tree_it;
- tri = tris_vect[t_ind];
- point_t v1, v2, v3;
- VSET(v1, pnts[tri.v[0]]->x, pnts[tri.v[0]]->y, pnts[tri.v[0]]->z);
- VSET(v2, pnts[tri.v[1]]->x, pnts[tri.v[1]]->y, pnts[tri.v[1]]->z);
- VSET(v3, pnts[tri.v[2]]->x, pnts[tri.v[2]]->y, pnts[tri.v[2]]->z);
- wn += bg_ptm_triangle_chain(v1, v2, v3, p, &exact);
- if (exact) return true;
- ++tree_it;
- }
-
- return (wn) ? true : false;
-}
-
-bool
-cdt_mesh_t::point_inside(ON_3dPoint *p)
-{
- point_t tp;
- VSET(tp, p->x, p->y, p->z);
- return point_inside(tp);
-}
-
double
cdt_mesh_t::max_angle_delta(triangle_t &seed, std::vector<triangle_t> &s_tris)
{
Modified: brlcad/trunk/src/libbrep/cdt_mesh.h
===================================================================
--- brlcad/trunk/src/libbrep/cdt_mesh.h 2019-10-21 20:20:31 UTC (rev 74207)
+++ brlcad/trunk/src/libbrep/cdt_mesh.h 2019-10-21 21:08:01 UTC (rev 74208)
@@ -505,8 +505,6 @@
/* Tests */
bool self_intersecting_mesh();
bool brep_edge_pnt(long v);
- bool point_inside(ON_3dPoint *p);
- bool point_inside(point_t p);
// Triangle geometry information
ON_3dPoint tcenter(const triangle_t &t);
Modified: brlcad/trunk/src/libbrep/cdt_ovlps.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_ovlps.cpp 2019-10-21 20:20:31 UTC (rev
74207)
+++ brlcad/trunk/src/libbrep/cdt_ovlps.cpp 2019-10-21 21:08:01 UTC (rev
74208)
@@ -2131,7 +2131,7 @@
if (omesh1->intruding_pnts.find(omesh2->overts[t2.v[i]]) !=
omesh1->intruding_pnts.end()) continue;
ON_3dPoint tp = *omesh2->fmesh->pnts[t2.v[i]];
double dist = plane1.DistanceTo(tp);
- if (dist < 0 && fabs(dist) > ON_ZERO_TOLERANCE &&
omesh1->fmesh->point_inside(&tp)) {
+ if (dist < 0 && fabs(dist) > ON_ZERO_TOLERANCE &&
on_point_inside(s_cdt1, &tp)) {
std::cout << s_cdt1->name << " face " <<
omesh1->fmesh->f_id << " test point inside:\n";
std::cout << "tp: " << tp.x << "," << tp.y << "," << tp.z
<< "\n";
std::cout << "ip: " << omesh2->overts[t2.v[i]]->vpnt().x <<
"," << omesh2->overts[t2.v[i]]->vpnt().y << "," <<
omesh2->overts[t2.v[i]]->vpnt().z << "\n";
@@ -2178,7 +2178,10 @@
if (omesh2->intruding_pnts.find(omesh1->overts[t1.v[i]]) !=
omesh2->intruding_pnts.end()) continue;
ON_3dPoint tp = *omesh1->fmesh->pnts[t1.v[i]];
double dist = plane2.DistanceTo(tp);
- if (dist < 0 && fabs(dist) > ON_ZERO_TOLERANCE &&
omesh2->fmesh->point_inside(&tp)) {
+ if (dist < 0 && fabs(dist) > ON_ZERO_TOLERANCE &&
on_point_inside(s_cdt2, &tp)) {
+ std::cout << s_cdt2->name << " face " <<
omesh2->fmesh->f_id << " test point inside:\n";
+ std::cout << "tp: " << tp.x << "," << tp.y << "," << tp.z
<< "\n";
+ std::cout << "ip: " << omesh1->overts[t1.v[i]]->vpnt().x <<
"," << omesh1->overts[t1.v[i]]->vpnt().y << "," <<
omesh1->overts[t1.v[i]]->vpnt().z << "\n";
omesh2->intruding_pnts.insert(omesh1->overts[t1.v[i]]);
}
}
Modified: brlcad/trunk/src/libbrep/cdt_util.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_util.cpp 2019-10-21 20:20:31 UTC (rev
74207)
+++ brlcad/trunk/src/libbrep/cdt_util.cpp 2019-10-21 21:08:01 UTC (rev
74208)
@@ -258,6 +258,42 @@
}
}
+
+bool
+point_inside(struct ON_Brep_CDT_State *s_cdt, point_t p)
+{
+ int wn = 0;
+ int exact = 0;
+ std::map<int, cdt_mesh::cdt_mesh_t>::iterator f_it;
+ for (f_it = s_cdt->fmeshes.begin(); f_it != s_cdt->fmeshes.end(); f_it++) {
+ RTree<size_t, double, 3>::Iterator tree_it;
+ f_it->second.tris_tree.GetFirst(tree_it);
+ size_t t_ind;
+ cdt_mesh::triangle_t tri;
+ while (!tree_it.IsNull()) {
+ t_ind = *tree_it;
+ tri = f_it->second.tris_vect[t_ind];
+ point_t v1, v2, v3;
+ VSET(v1, f_it->second.pnts[tri.v[0]]->x,
f_it->second.pnts[tri.v[0]]->y, f_it->second.pnts[tri.v[0]]->z);
+ VSET(v2, f_it->second.pnts[tri.v[1]]->x,
f_it->second.pnts[tri.v[1]]->y, f_it->second.pnts[tri.v[1]]->z);
+ VSET(v3, f_it->second.pnts[tri.v[2]]->x,
f_it->second.pnts[tri.v[2]]->y, f_it->second.pnts[tri.v[2]]->z);
+ wn += bg_ptm_triangle_chain(v1, v2, v3, p, &exact);
+ if (exact) return true;
+ ++tree_it;
+ }
+ }
+
+ return (wn) ? true : false;
+}
+
+bool
+on_point_inside(struct ON_Brep_CDT_State *s_cdt, ON_3dPoint *p)
+{
+ point_t tp;
+ VSET(tp, p->x, p->y, p->z);
+ return point_inside(s_cdt, tp);
+}
+
std::vector<cdt_mesh::cpolyedge_t *>
cdt_face_polyedges(struct ON_Brep_CDT_State *s_cdt, int face_index)
{
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