Revision: 55312
http://sourceforge.net/p/brlcad/code/55312
Author: phoenixyjll
Date: 2013-05-07 04:48:48 +0000 (Tue, 07 May 2013)
Log Message:
-----------
Loop detection in 3D space and 2D space should be done separately.
Modified Paths:
--------------
brlcad/trunk/src/libbrep/opennurbs_ext.cpp
Modified: brlcad/trunk/src/libbrep/opennurbs_ext.cpp
===================================================================
--- brlcad/trunk/src/libbrep/opennurbs_ext.cpp 2013-05-07 03:46:47 UTC (rev
55311)
+++ brlcad/trunk/src/libbrep/opennurbs_ext.cpp 2013-05-07 04:48:48 UTC (rev
55312)
@@ -3425,7 +3425,11 @@
max_dis =
pow(surfA->BoundingBox().Volume()*surfB->BoundingBox().Volume(), 1.0/6.0) * 0.2;
}
}
+ double max_dis_2dA = ON_2dVector(surfA->Domain(0).Length(),
surfA->Domain(1).Length()).Length() * 0.01;
+ double max_dis_2dB = ON_2dVector(surfB->Domain(0).Length(),
surfB->Domain(1).Length()).Length() * 0.01;
bu_log("max_dis: %lf\n", max_dis);
+ bu_log("max_dis_2dA: %lf\n", max_dis_2dA);
+ bu_log("max_dis_2dB: %lf\n", max_dis_2dB);
// NOTE: More tests are needed to find a better threshold.
std::vector<PointPair> ptpairs;
@@ -3519,14 +3523,15 @@
if (polylines[i] != NULL) {
int startpoint = (*polylines[i])[0];
int endpoint = (*polylines[i])[polylines[i]->Count() - 1];
- if (curvept[startpoint].DistanceTo(curvept[endpoint]) < max_dis) {
- polylines[i]->Append(startpoint);
- }
// The intersection curves in the 3d space
ON_3dPointArray ptarray;
for (int j = 0; j < polylines[i]->Count(); j++)
ptarray.Append(curvept[(*polylines[i])[j]]);
+ // If it form a loop in the 3D space
+ if (curvept[startpoint].DistanceTo(curvept[endpoint]) < max_dis) {
+ ptarray.Append(curvept[startpoint]);
+ }
ON_PolylineCurve curve(ptarray);
ON_NurbsCurve *nurbscurve = ON_NurbsCurve::New();
if (curve.GetNurbForm(*nurbscurve)) {
@@ -3539,6 +3544,11 @@
ON_2dPoint &pt2d = curveuv[(*polylines[i])[j]];
ptarray.Append(ON_3dPoint(pt2d.x, pt2d.y, 0.0));
}
+ // If it form a loop in the 2D space (happens rarely compared to 3D)
+ if (curveuv[startpoint].DistanceTo(curveuv[endpoint]) <
max_dis_2dA) {
+ ON_2dPoint &pt2d = curveuv[startpoint];
+ ptarray.Append(ON_3dPoint(pt2d.x, pt2d.y, 0.0));
+ }
curve = ON_PolylineCurve(ptarray);
curve.ChangeDimension(2);
nurbscurve = ON_NurbsCurve::New();
@@ -3552,6 +3562,11 @@
ON_2dPoint &pt2d = curvest[(*polylines[i])[j]];
ptarray.Append(ON_3dPoint(pt2d.x, pt2d.y, 0.0));
}
+ // If it form a loop in the 2D space (happens rarely compared to 3D)
+ if (curvest[startpoint].DistanceTo(curvest[endpoint]) <
max_dis_2dB) {
+ ON_2dPoint &pt2d = curvest[startpoint];
+ ptarray.Append(ON_3dPoint(pt2d.x, pt2d.y, 0.0));
+ }
curve = ON_PolylineCurve(ptarray);
curve.ChangeDimension(2);
nurbscurve = ON_NurbsCurve::New();
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits