Revision: 74704 http://sourceforge.net/p/brlcad/code/74704 Author: starseeker Date: 2020-01-15 22:07:35 +0000 (Wed, 15 Jan 2020) Log Message: ----------- start experimenting with normal information - not at all sure about the behavior of the normal reporting... have to be cautious there as that's important in the initial meshing as well...
Modified Paths: -------------- brlcad/trunk/src/libbrep/cdt/mesh.h brlcad/trunk/src/libbrep/cdt/omesh.cpp brlcad/trunk/src/libbrep/cdt/tri_isect.cpp brlcad/trunk/src/libbrep/cdt/util.cpp Modified: brlcad/trunk/src/libbrep/cdt/mesh.h =================================================================== --- brlcad/trunk/src/libbrep/cdt/mesh.h 2020-01-15 21:02:55 UTC (rev 74703) +++ brlcad/trunk/src/libbrep/cdt/mesh.h 2020-01-15 22:07:35 UTC (rev 74704) @@ -928,7 +928,7 @@ overt_t * vert_closest(double *vdist, ON_3dPoint &opnt); // Find closest point on mesh - double closest_pt(ON_3dPoint &p, const ON_3dPoint &op); + double closest_pt(ON_3dPoint &p, ON_3dVector &n, const ON_3dPoint &op); // Find closest point on any nearby mesh face in the // specified brep. This isn't guaranteed to return @@ -944,7 +944,7 @@ // we just need to know if there's a very close point // to a nearby triangle that is closer (i.e. changes // the triangle status) for the local problem. - bool closest_nearby_mesh_point(ON_3dPoint &s_p, ON_3dPoint *p, struct ON_Brep_CDT_State *s_cdt); + bool closest_nearby_mesh_point(ON_3dPoint &s_p, ON_3dVector &s_n, ON_3dPoint *p, struct ON_Brep_CDT_State *s_cdt); bool validate_vtree(); Modified: brlcad/trunk/src/libbrep/cdt/omesh.cpp =================================================================== --- brlcad/trunk/src/libbrep/cdt/omesh.cpp 2020-01-15 21:02:55 UTC (rev 74703) +++ brlcad/trunk/src/libbrep/cdt/omesh.cpp 2020-01-15 22:07:35 UTC (rev 74704) @@ -298,7 +298,7 @@ } double -omesh_t::closest_pt(ON_3dPoint &cp, const ON_3dPoint &op) +omesh_t::closest_pt(ON_3dPoint &cp, ON_3dVector &cn, const ON_3dPoint &op) { ON_BoundingBox fbbox = fmesh->bbox(); if (!fmesh->tris_vect.size()) { @@ -336,6 +336,7 @@ double tdist = DBL_MAX; point_t closest_pt = VINIT_ZERO; + triangle_t ctri; std::set<size_t>::iterator tr_it; for (tr_it = ntris.begin(); tr_it != ntris.end(); tr_it++) { triangle_t t = fmesh->tris_vect[*tr_it]; @@ -353,13 +354,16 @@ if (ltdist < tdist) { VMOVE(closest_pt, lclosest_pt); + ctri = t; tdist = ltdist; } } ON_3dPoint on_cp(closest_pt[X], closest_pt[Y], closest_pt[Z]); + ON_3dVector on_cn = ctri.m->tnorm(ctri); cp = on_cp; + cn = on_cn; return tdist; } @@ -534,7 +538,7 @@ bool -omesh_t::closest_nearby_mesh_point(ON_3dPoint &s_p, ON_3dPoint *p, struct ON_Brep_CDT_State *s_cdt) +omesh_t::closest_nearby_mesh_point(ON_3dPoint &s_p, ON_3dVector &s_n, ON_3dPoint *p, struct ON_Brep_CDT_State *s_cdt) { std::set<omesh_t *> check_meshes = scdt_meshes(check_pairs, s_cdt); @@ -549,18 +553,21 @@ omesh_t *om = *om_it; if (om->fmesh->bbox().IsDisjoint(pbb)) continue; ON_3dPoint om_cp; - double ldist = om->closest_pt(om_cp, *p); + ON_3dVector om_cn; + double ldist = om->closest_pt(om_cp, om_cn, *p); if (ldist < DBL_MAX && cdist > ldist) { cdist = ldist; cp = om_cp; + cn = om_cn; have_dist = true; } } if (!have_dist) { - cdist = closest_pt(cp, *p); + cdist = closest_pt(cp, cn, *p); } s_p = cp; + s_n = cn; return (cdist < DBL_MAX); } Modified: brlcad/trunk/src/libbrep/cdt/tri_isect.cpp =================================================================== --- brlcad/trunk/src/libbrep/cdt/tri_isect.cpp 2020-01-15 21:02:55 UTC (rev 74703) +++ brlcad/trunk/src/libbrep/cdt/tri_isect.cpp 2020-01-15 22:07:35 UTC (rev 74704) @@ -461,6 +461,9 @@ return true; } + TRICHECK(t1); + TRICHECK(t2); + if (mode > 0) { // If the projections of the two triangles onto a common plane has a non-zero // area, we don't report this as an edge-only intersection - it is as far as the @@ -499,16 +502,23 @@ // surface may not be fmesh2... Need a s_cdt level closest_surf_pnt function if (on_point_inside(s_cdt, &lmid)) { ON_3dPoint bs_p; - bool cpeval = fmesh2->omesh->closest_nearby_mesh_point(bs_p, &lmid, s_cdt); + ON_3dVector bs_n; + bool cpeval = fmesh2->omesh->closest_nearby_mesh_point(bs_p, bs_n, &lmid, s_cdt); if (!cpeval) { std::cout << "Error - couldn't find closest point for mesh\n"; continue; } - //std::cout << "lmin_dist_to_sp vs elen_min: " << lmid.DistanceTo(bs_p) << "," << 0.001*elen_min << "\n"; if (lmid.DistanceTo(bs_p) > BN_TOL_DIST) { //std::cout << "center " << lmid.x << "," << lmid.y << "," << lmid.z << "\n"; //std::cout << s_cdt->name << " dist: " << lmid.DistanceTo(bs_p) << "\n"; + + ON_3dVector pt = (fmesh2->m_bRev) ? (bs_p - lmid) : lmid - bs_p; + pt.Unitize(); + double dp = ON_DotProduct(pt, bs_n); + std::cout << "dp: " << dp << "\n"; + + mid_inside_cnt++; } } @@ -520,16 +530,24 @@ // TODO - need some distance metric here - ON the mesh is fine, to within tolerance... if (on_point_inside(s_cdt, &lmid)) { ON_3dPoint bs_p; - bool cpeval = fmesh1->omesh->closest_nearby_mesh_point(bs_p, &lmid, s_cdt); + ON_3dVector bs_n; + bool cpeval = fmesh1->omesh->closest_nearby_mesh_point(bs_p, bs_n, &lmid, s_cdt); if (!cpeval) { std::cout << "Error - couldn't find closest point for mesh\n"; continue; } + //std::cout << "lmin_dist_to_sp vs elen_min: " << lmid.DistanceTo(bs_p) << "," << 0.001*elen_min << "\n"; if (lmid.DistanceTo(bs_p) > BN_TOL_DIST) { //std::cout << "center " << lmid.x << "," << lmid.y << "," << lmid.z << "\n"; //std::cout << s_cdt->name << " dist: " << lmid.DistanceTo(bs_p) << "\n"; + + ON_3dVector pt = (fmesh2->m_bRev) ? (bs_p - lmid) : lmid - bs_p; + pt.Unitize(); + double dp = ON_DotProduct(pt, bs_n); + std::cout << "dp: " << dp << "\n"; + mid_inside_cnt++; } } Modified: brlcad/trunk/src/libbrep/cdt/util.cpp =================================================================== --- brlcad/trunk/src/libbrep/cdt/util.cpp 2020-01-15 21:02:55 UTC (rev 74703) +++ brlcad/trunk/src/libbrep/cdt/util.cpp 2020-01-15 22:07:35 UTC (rev 74704) @@ -68,9 +68,9 @@ return false; } -#define PPOINT1 3.56554479743774344,7.98569858586419024,23.37338642522485799 -#define PPOINT2 3.56554479743774477,7.98112948296225078,23.71606012295672983 -#define PPOINT3 3.42047903513449203,7.64743233441400783,23.39883493871970188 +#define PPOINT1 23.25001595493834472,7.56258605501400005,4.69182363386541645 +#define PPOINT2 23.25001595493833406,7.50286345088642914,4.88080852489416639 +#define PPOINT3 23.49789824853833409,7.50415086359986816,4.86995210942060908 static int TPPCHECK(ON_3dPoint &p) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. _______________________________________________ BRL-CAD Source Commits mailing list brlcad-commits@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/brlcad-commits