Revision: 74698 http://sourceforge.net/p/brlcad/code/74698 Author: starseeker Date: 2020-01-15 18:03:23 +0000 (Wed, 15 Jan 2020) Log Message: ----------- Make the initial search boxes slightly larger.
Modified Paths: -------------- brlcad/trunk/src/libbrep/cdt/mesh.h brlcad/trunk/src/libbrep/cdt/omesh.cpp brlcad/trunk/src/libbrep/cdt/ovlps_grps.cpp Modified: brlcad/trunk/src/libbrep/cdt/mesh.h =================================================================== --- brlcad/trunk/src/libbrep/cdt/mesh.h 2020-01-15 17:13:29 UTC (rev 74697) +++ brlcad/trunk/src/libbrep/cdt/mesh.h 2020-01-15 18:03:23 UTC (rev 74698) @@ -999,6 +999,9 @@ void plot(const char *fname, int ind); void plot(const char *fname); + std::set<uedge_t> interior_uedges(int ind); + bool split_interior_uedges(); + // -1 = invalid, 1 = valid, 2 = cleared int state; Modified: brlcad/trunk/src/libbrep/cdt/omesh.cpp =================================================================== --- brlcad/trunk/src/libbrep/cdt/omesh.cpp 2020-01-15 17:13:29 UTC (rev 74697) +++ brlcad/trunk/src/libbrep/cdt/omesh.cpp 2020-01-15 18:03:23 UTC (rev 74698) @@ -301,8 +301,14 @@ omesh_t::closest_pt(double *pdist, ON_3dPoint &op) { ON_BoundingBox fbbox = fmesh->bbox(); + if (!fmesh->tris_vect.size()) { + return ON_3dPoint::UnsetPoint; + } - ON_3dPoint ptol(ON_ZERO_TOLERANCE, ON_ZERO_TOLERANCE, ON_ZERO_TOLERANCE); + double lguess = fbbox.Diagonal().Length()/(double)fmesh->tris_vect.size(); + lguess = (lguess < ON_ZERO_TOLERANCE) ? ON_ZERO_TOLERANCE : lguess; + + ON_3dPoint ptol(lguess, lguess, lguess); ON_BoundingBox s_bb(op, op); ON_3dPoint npnt = op + ptol; s_bb.Set(npnt, true); @@ -367,18 +373,22 @@ if (!fmesh->pnts.size()) return uedge; ON_BoundingBox fbbox = fmesh->bbox(); + if (!fmesh->tris_vect.size()) { + return uedge_t(); + } - ON_BoundingBox bb(p, p); - bb.m_min.x = bb.Min().x - ON_ZERO_TOLERANCE; - bb.m_min.y = bb.Min().y - ON_ZERO_TOLERANCE; - bb.m_min.z = bb.Min().z - ON_ZERO_TOLERANCE; - bb.m_max.x = bb.Max().x + ON_ZERO_TOLERANCE; - bb.m_max.y = bb.Max().y + ON_ZERO_TOLERANCE; - bb.m_max.z = bb.Max().z + ON_ZERO_TOLERANCE; + double lguess = fbbox.Diagonal().Length()/(double)fmesh->tris_vect.size(); + lguess = (lguess < ON_ZERO_TOLERANCE) ? ON_ZERO_TOLERANCE : lguess; + ON_3dPoint ptol(lguess, lguess, lguess); + ON_BoundingBox s_bb(p, p); + ON_3dPoint npnt = p + ptol; + s_bb.Set(npnt, true); + npnt = p - ptol; + s_bb.Set(npnt, true); + // Find close triangles, iterate through them and // find the closest interior edge - ON_BoundingBox s_bb = bb; std::set<size_t> ntris = tris_search(s_bb); bool last_try = false; while (!ntris.size() && !last_try) { @@ -400,7 +410,7 @@ 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]; - ON_3dPoint tp = bb.Center(); + ON_3dPoint tp = p; uedge_t ue = fmesh->closest_uedge(t, tp); double ue_cdist = fmesh->uedge_dist(ue, p); if (ue_cdist < uedist) { Modified: brlcad/trunk/src/libbrep/cdt/ovlps_grps.cpp =================================================================== --- brlcad/trunk/src/libbrep/cdt/ovlps_grps.cpp 2020-01-15 17:13:29 UTC (rev 74697) +++ brlcad/trunk/src/libbrep/cdt/ovlps_grps.cpp 2020-01-15 18:03:23 UTC (rev 74698) @@ -330,31 +330,44 @@ return true; } -/* If the two polygons in a group are aligned (i.e. every vertex (interior or - * on the loop) has a nearby vertex in the other polygon) it is possible to - * replace the triangles in both polygons with a single CDT, rather than having - * to try to get compatible CDTs independently. */ +std::set<uedge_t> +ovlp_grp::interior_uedges(int ind) +{ + std::set<triangle_t> &tris = (!ind) ? tris1 : tris2; -// TODO - need to preserve the polygon generated by optimize() - being deleted -// right now... -// -// It's not 100% that the polygons from optimize will work, since they may be -// more aggressive about including triangles than they have to be (they're not -// constrained by points relevant to the ovlp groups, and for the initial pass -// we probably don't want that anyway - we may need "repair" behavior -// initially. We may also still need the fallback to re-building the polygons -// with a tight focus on just the group triangles and minimal additional -// inclusions to get aligned polygons... + std::map<uedge_t, int> ecnts; + std::set<triangle_t>::iterator t_it; + for (t_it = tris.begin(); t_it != tris.end(); t_it++) { + triangle_t tri = *t_it; + std::set<uedge_t> tedges = tri.uedges(); + std::set<uedge_t>::iterator u_it; + for (u_it = tedges.begin(); u_it != tedges.end(); u_it++) { + ecnts[*u_it]++; + } + } + + std::set<uedge_t> iedges; + std::map<uedge_t, int>::iterator m_it; + for (m_it = ecnts.begin(); m_it != ecnts.end(); m_it++) { + if (m_it->second > 1) { + // Two triangles used this edge in the group - it is interior + uedge_t iedge = m_it->first; + iedges.insert(iedge); + } + } + + return iedges; +} + bool -polygons_aligned(ovlp_grp &grp) +ovlp_grp::split_interior_uedges() { - if (!grp.tris1.size() || !grp.tris2.size()) { - return false; - } + std::set<uedge_t> u0 = interior_uedges(0); + std::set<uedge_t> u1 = interior_uedges(1); + std::set<uedge_t> u = (u0.size() > u1.size()) ? u0 : u1; - // First, check the sizes - if they're not the same, there's no point going any further. + std::cout << "have " << u.size() << " interior edges\n"; - // If we're passed all the rejection critieria, they're aligned. return true; } @@ -579,6 +592,19 @@ } } + for (size_t i = 0; i < bins.size(); i++) { + bool v1 = bins[i].om1->fmesh->valid(1); + bool v2 = bins[i].om2->fmesh->valid(1); + + if (!v1 || !v2) { + std::cout << "Starting bin processing with invalid inputs!\n"; + } + + if (bins[i].state == 1) { + bins[i].split_interior_uedges(); + } + } + bool have_invalid = false; bool have_unresolved = false; for (size_t i = 0; i < bins.size(); i++) { 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