Revision: 73898
          http://sourceforge.net/p/brlcad/code/73898
Author:   starseeker
Date:     2019-09-11 23:01:58 +0000 (Wed, 11 Sep 2019)
Log Message:
-----------
Try another approach to jittering the trim points, but even this isn't doing 
it...

Modified Paths:
--------------
    brlcad/trunk/src/libbrep/cdt_surf.cpp

Modified: brlcad/trunk/src/libbrep/cdt_surf.cpp
===================================================================
--- brlcad/trunk/src/libbrep/cdt_surf.cpp       2019-09-11 22:34:43 UTC (rev 
73897)
+++ brlcad/trunk/src/libbrep/cdt_surf.cpp       2019-09-11 23:01:58 UTC (rev 
73898)
@@ -503,17 +503,29 @@
        a_context.cseg = tseg;
        a_context.use = &include_pnt;
 
-       double dlen = tseg->bb.Diagonal().Length();
-       dlen = 0.1 * dlen;
-       double px = tseg->spnt.x + (bn_rand_half(prand) * dlen);
-       double py = tseg->spnt.y + (bn_rand_half(prand) * dlen);
+       ON_2dPoint p2d1(tseg->polygon->pnts_2d[tseg->v[0]].first, 
tseg->polygon->pnts_2d[tseg->v[0]].second);
+       ON_2dPoint p2d2(tseg->polygon->pnts_2d[tseg->v[1]].first, 
tseg->polygon->pnts_2d[tseg->v[1]].second);
+       double dist = p2d1.DistanceTo(p2d2);
+       double bdist = 0.3*dist * bn_rand_half(prand);
+       ON_3dPoint p13d(p2d1.x, p2d1.y, 0);
+       ON_3dPoint p23d(p2d2.x, p2d2.y, 0);
+       ON_3dPoint p1norm(p2d1.x, p2d1.y, 1);
+       ON_3dVector vtrim = p23d - p13d;
+       ON_3dVector vnorm = p1norm - p13d;
+       vtrim.Unitize();
+       vnorm.Unitize();
+       ON_3dVector ndir = ON_CrossProduct(vnorm, vtrim);
+       ndir.Unitize();
+       ndir = ndir * bdist;
+       ON_2dVector ndir2d(ndir.x, ndir.y);
+       ON_2dPoint npnt = tseg->spnt + ndir2d;
 
        double tMin[2];
-       tMin[0] = px - ON_ZERO_TOLERANCE;
-       tMin[1] = py - ON_ZERO_TOLERANCE;
+       tMin[0] = npnt.x - ON_ZERO_TOLERANCE;
+       tMin[1] = npnt.y - ON_ZERO_TOLERANCE;
        double tMax[2];
-       tMax[0] = px + ON_ZERO_TOLERANCE;
-       tMax[1] = py + ON_ZERO_TOLERANCE;
+       tMax[0] = npnt.x + ON_ZERO_TOLERANCE;
+       tMax[1] = npnt.y + ON_ZERO_TOLERANCE;
 
        s_cdt->face_rtrees_2d[face.m_face_index].Search(tMin, tMax, 
UseTrimPntCallback, (void *)&a_context);
 
@@ -521,7 +533,7 @@
            //std::cout << "Accept\n";
            sinfo->rtree_trim_spnts_2d.Insert(tMin, tMax, (void *)tseg);
 
-           sinfo->on_surf_points.insert(new ON_2dPoint(px, py));
+           sinfo->on_surf_points.insert(new ON_2dPoint(npnt.x, npnt.y));
        }
     }
 

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

Reply via email to