Revision: 56458
http://sourceforge.net/p/brlcad/code/56458
Author: phoenixyjll
Date: 2013-08-02 04:56:11 +0000 (Fri, 02 Aug 2013)
Log Message:
-----------
Reuse the surface trees and curve trees during multiple intersections to reduce
repeat computation.
Modified Paths:
--------------
brlcad/trunk/include/brep.h
brlcad/trunk/src/libbrep/intersect.cpp
Modified: brlcad/trunk/include/brep.h
===================================================================
--- brlcad/trunk/include/brep.h 2013-08-02 02:57:08 UTC (rev 56457)
+++ brlcad/trunk/include/brep.h 2013-08-02 04:56:11 UTC (rev 56458)
@@ -1733,61 +1733,11 @@
DumpSSXEvent(ON_SSX_EVENT &x, ON_TextLog &text_log);
/**
- * An overload of ON_Intersect for surface-surface intersection.
- *
- * Description:
- * Intersect surfaceA with surfaceB.
- *
- * Parameters:
- * surfaceA - [in]
- *
- * surfaceB - [in]
- *
- * x - [out]
- * Intersection events are appended to this array.
- *
- * intersection_tolerance - [in]
- * If the input intersection_tolerance <= 0.0, then 0.001 is used.
- *
- * overlap_tolerance - [in]
- * If positive, then overlap_tolerance must be
- * >= intersection_tolerance and is used to test for
- * overlapping regions. If the input
- * overlap_tolerance <= 0.0, then 2*intersection_tolerance
- * is used.
- *
- * fitting_tolerance - [in]
- * If fitting_tolerance is > 0 and >= intersection_tolerance,
- * then the intersection curves are fit to this tolerance.
- * If input fitting_tolerance <= 0.0 or < intersection_tolerance,
- * then intersection_tolerance is used.
- *
- * surfaceA_udomain - [in]
- * optional restriction on surfaceA u domain
- * surfaceA_vdomain - [in]
- * optional restriction on surfaceA v domain
- *
- * surfaceB_udomain - [in]
- * optional restriction on surfaceB u domain
- * surfaceB_vdomain - [in]
- * optional restriction on surfaceB v domain
- *
- * Returns:
- * Number of intersection events appended to x. -1 for error.
+ * Sub-division support for curves and surfaces
*/
+class BREP_EXPORT Subcurve;
+class BREP_EXPORT Subsurface;
-extern BREP_EXPORT int
-ON_Intersect(const ON_Surface* surfA,
- const ON_Surface* surfB,
- ON_ClassArray<ON_SSX_EVENT>& x,
- double intersection_tolerance = 0.0,
- double overlap_tolerance = 0.0,
- double fitting_tolerance = 0.0,
- const ON_Interval* surfaceA_udomain = 0,
- const ON_Interval* surfaceA_vdomain = 0,
- const ON_Interval* surfaceB_udomain = 0,
- const ON_Interval* surfaceB_vdomain = 0);
-
/* The ON_PX_EVENT class is used to report point-point, point-curve
* and point-surface intersection events.
*/
@@ -1918,6 +1868,9 @@
* curveB_domain - [in]
* optional restriction on curveB t domain
*
+ * treeB - [in]
+ * optional curve tree for curveB, to avoid re-computation
+ *
* Returns:
* True for an intersection. False for no intersection.
*/
@@ -1926,7 +1879,8 @@
const ON_Curve& curveB,
ON_ClassArray<ON_PX_EVENT>& x,
double tolerance = 0.0,
- const ON_Interval* curveB_domain = 0);
+ const ON_Interval* curveB_domain = 0,
+ Subcurve* treeB = 0);
/**
* An overload of ON_Intersect for point-surface intersection.
@@ -1951,7 +1905,7 @@
* surfaceB_vdomain - [in]
* optional restriction on surfaceB v domain
*
- * tree - [in]
+ * treeB - [in]
* optional surface tree for surfaceB, to avoid re-computation
*
* Returns:
@@ -1964,7 +1918,7 @@
double tolerance = 0.0,
const ON_Interval* surfaceB_udomain = 0,
const ON_Interval* surfaceB_vdomain = 0,
- brlcad::SurfaceTree* tree = 0);
+ Subsurface* treeB = 0);
/**
* An overload of ON_Intersect for curve-curve intersection.
@@ -1995,6 +1949,12 @@
*
* curveB_domain - [in] optional restriction on curveB domain
*
+ * treeA - [in]
+ * optional curve tree for curveA, to avoid re-computation
+ *
+ * treeB - [in]
+ * optional curve tree for curveB, to avoid re-computation
+ *
* Returns:
* Number of intersection events appended to x.
*/
@@ -2005,7 +1965,9 @@
double intersection_tolerance = 0.0,
double overlap_tolerance = 0.0,
const ON_Interval* curveA_domain = 0,
- const ON_Interval* curveB_domain = 0);
+ const ON_Interval* curveB_domain = 0,
+ Subcurve* treeA = 0,
+ Subcurve* treeB = 0);
/**
* An overload of ON_Intersect for curve-surface intersection.
@@ -2051,6 +2013,12 @@
* return the 2D overlap curves on surfaceB. overlap2d[i] is the
* curve for event x[i].
*
+ * treeA - [in]
+ * optional curve tree for curveA, to avoid re-computation
+ *
+ * treeB - [in]
+ * optional surface tree for surfaceB, to avoid re-computation
+ *
* Returns:
* Number of intersection events appended to x.
*/
@@ -2063,8 +2031,76 @@
const ON_Interval* curveA_domain = 0,
const ON_Interval* surfaceB_udomain = 0,
const ON_Interval* surfaceB_vdomain = 0,
- ON_CurveArray* overlap2d = 0);
+ ON_CurveArray* overlap2d = 0,
+ Subcurve* treeA = 0,
+ Subsurface* treeB = 0);
+/**
+ * An overload of ON_Intersect for surface-surface intersection.
+ *
+ * Description:
+ * Intersect surfaceA with surfaceB.
+ *
+ * Parameters:
+ * surfaceA - [in]
+ *
+ * surfaceB - [in]
+ *
+ * x - [out]
+ * Intersection events are appended to this array.
+ *
+ * intersection_tolerance - [in]
+ * If the input intersection_tolerance <= 0.0, then 0.001 is used.
+ *
+ * overlap_tolerance - [in]
+ * If positive, then overlap_tolerance must be
+ * >= intersection_tolerance and is used to test for
+ * overlapping regions. If the input
+ * overlap_tolerance <= 0.0, then 2*intersection_tolerance
+ * is used.
+ *
+ * fitting_tolerance - [in]
+ * If fitting_tolerance is > 0 and >= intersection_tolerance,
+ * then the intersection curves are fit to this tolerance.
+ * If input fitting_tolerance <= 0.0 or < intersection_tolerance,
+ * then intersection_tolerance is used.
+ *
+ * surfaceA_udomain - [in]
+ * optional restriction on surfaceA u domain
+ *
+ * surfaceA_vdomain - [in]
+ * optional restriction on surfaceA v domain
+ *
+ * surfaceB_udomain - [in]
+ * optional restriction on surfaceB u domain
+ *
+ * surfaceB_vdomain - [in]
+ * optional restriction on surfaceB v domain
+ *
+ * treeA - [in]
+ * optional surface tree for surfaceA, to avoid re-computation
+ *
+ * treeB - [in]
+ * optional surface tree for surfaceB, to avoid re-computation
+ *
+ * Returns:
+ * Number of intersection events appended to x. -1 for error.
+ */
+
+extern BREP_EXPORT int
+ON_Intersect(const ON_Surface* surfA,
+ const ON_Surface* surfB,
+ ON_ClassArray<ON_SSX_EVENT>& x,
+ double intersection_tolerance = 0.0,
+ double overlap_tolerance = 0.0,
+ double fitting_tolerance = 0.0,
+ const ON_Interval* surfaceA_udomain = 0,
+ const ON_Interval* surfaceA_vdomain = 0,
+ const ON_Interval* surfaceB_udomain = 0,
+ const ON_Interval* surfaceB_vdomain = 0,
+ Subsurface* treeA = 0,
+ Subsurface* treeB = 0);
+
} /* extern C++ */
#endif
Modified: brlcad/trunk/src/libbrep/intersect.cpp
===================================================================
--- brlcad/trunk/src/libbrep/intersect.cpp 2013-08-02 02:57:08 UTC (rev
56457)
+++ brlcad/trunk/src/libbrep/intersect.cpp 2013-08-02 04:56:11 UTC (rev
56458)
@@ -621,21 +621,36 @@
const ON_Curve& curveB,
ON_ClassArray<ON_PX_EVENT>& x,
double tolerance,
- const ON_Interval* curveB_domain)
+ const ON_Interval* curveB_domain,
+ Subcurve* treeB)
{
if (tolerance <= 0.0)
tolerance = PCI_DEFAULT_TOLERANCE;
check_domain(curveB_domain, curveB.Domain(), "curveB_domain");
- Subcurve root;
- if (!build_curve_root(&curveB, curveB_domain, root))
+ Subcurve* root;
+ if (treeB != NULL)
+ root = treeB;
+ else {
+ root = new Subcurve;
+ if (root == NULL)
+ return false;
+ }
+
+ if (!build_curve_root(&curveB, curveB_domain, *root)) {
+ if (treeB == NULL)
+ delete root;
return false;
+ }
- if (!root.IsPointIn(pointA, tolerance))
+ if (!root->IsPointIn(pointA, tolerance)) {
+ if (treeB == NULL)
+ delete root;
return false;
+ }
std::vector<Subcurve*> candidates, next_candidates;
- candidates.push_back(&root);
+ candidates.push_back(root);
// Find the sub-curves that are possibly intersected with the point.
for (int i = 0; i < MAX_PCI_DEPTH; i++) {
@@ -682,10 +697,14 @@
Event.m_Mid = (pointA + Event.m_B) * 0.5;
Event.m_radius = Event.m_B.DistanceTo(pointA) * 0.5;
x.Append(Event);
+ if (treeB == NULL)
+ delete root;
return true;
}
}
// All candidates have no intersection
+ if (treeB == NULL)
+ delete root;
return false;
}
@@ -695,7 +714,12 @@
*
* approach:
*
- * - Use brlcad::get_closest_point() to compute the closest point on
+ * - Sub-divide the surface, calculating bounding boxes.
+ *
+ * - If the bounding box intersects with the point, go deeper until
+ * we reach the maximal depth or the sub-surface is planar
+ *
+ * - Use Newton-Raphson iterations to compute the closest point on
* the surface to that point.
*
* - If the closest point is within the given tolerance, there is an
@@ -768,7 +792,7 @@
double tolerance,
const ON_Interval* surfaceB_udomain,
const ON_Interval* surfaceB_vdomain,
- brlcad::SurfaceTree* UNUSED(tree))
+ Subsurface* treeB)
{
if (tolerance <= 0.0)
tolerance = PCI_DEFAULT_TOLERANCE;
@@ -777,15 +801,29 @@
u_domain = check_domain(surfaceB_udomain, surfaceB.Domain(0),
"surfaceB_udomain");
v_domain = check_domain(surfaceB_vdomain, surfaceB.Domain(1),
"surfaceB_vdomain");
- Subsurface root;
- if (!build_surface_root(&surfaceB, &u_domain, &v_domain, root))
+ Subsurface* root;
+ if (treeB != NULL)
+ root = treeB;
+ else {
+ root = new Subsurface;
+ if (root == NULL)
+ return false;
+ }
+
+ if (!build_surface_root(&surfaceB, &u_domain, &v_domain, *root)) {
+ if (treeB == NULL)
+ delete root;
return false;
+ }
- if (!root.IsPointIn(pointA, tolerance))
+ if (!root->IsPointIn(pointA, tolerance)) {
+ if (treeB == NULL)
+ delete root;
return false;
+ }
std::vector<Subsurface*> candidates, next_candidates;
- candidates.push_back(&root);
+ candidates.push_back(root);
// Find the sub-curves that are possibly intersected with the point.
for (int i = 0; i < MAX_PSI_DEPTH; i++) {
@@ -819,11 +857,15 @@
Event.m_Mid = (pointA + Event.m_B) * 0.5;
Event.m_radius = Event.m_B.DistanceTo(pointA) * 0.5;
x.Append(Event);
+ if (treeB == NULL)
+ delete root;
return true;
}
}
// All candidates have no intersection
+ if (treeB == NULL)
+ delete root;
return false;
}
@@ -953,7 +995,9 @@
double intersection_tolerance,
double overlap_tolerance,
const ON_Interval* curveA_domain,
- const ON_Interval* curveB_domain)
+ const ON_Interval* curveB_domain,
+ Subcurve* treeA,
+ Subcurve* treeB)
{
if (curveA == NULL || curveB == NULL)
return 0;
@@ -1025,26 +1069,47 @@
return 0;
}
- Subcurve rootA, rootB;
- if (!build_curve_root(curveA, curveA_domain, rootA))
+ Subcurve *rootA, *rootB;
+ if (treeA == NULL) {
+ rootA = new Subcurve;
+ if (rootA == NULL)
+ return 0;
+ } else
+ rootA = treeA;
+ if (treeB == NULL) {
+ rootB = new Subcurve;
+ if (rootB == NULL) {
+ if (treeA == NULL) delete rootA;
+ return 0;
+ }
+ } else
+ rootB = treeB;
+
+ if (!build_curve_root(curveA, curveA_domain, *rootA)) {
+ if (treeA == NULL) delete rootA;
+ if (treeB == NULL) delete rootB;
return 0;
- if (!build_curve_root(curveB, curveB_domain, rootB))
+ }
+ if (!build_curve_root(curveB, curveB_domain, *rootB)) {
+ if (treeA == NULL) delete rootA;
+ if (treeB == NULL) delete rootB;
return 0;
+ }
// We adjust the tolerance from 3D scale to respective 2D scales.
- double l = rootA.m_curve->BoundingBox().Diagonal().Length();
+ double l = rootA->m_curve->BoundingBox().Diagonal().Length();
double dl = curveA_domain ? curveA_domain->Length() :
curveA->Domain().Length();
if (!ON_NearZero(l))
t1_tolerance = intersection_tolerance/l*dl;
- l = rootB.m_curve->BoundingBox().Diagonal().Length();
+ l = rootB->m_curve->BoundingBox().Diagonal().Length();
dl = curveB_domain ? curveB_domain->Length() : curveB->Domain().Length();
if (!ON_NearZero(l))
t2_tolerance = intersection_tolerance/l*dl;
typedef std::vector<std::pair<Subcurve*, Subcurve*> > NodePairs;
NodePairs candidates, next_candidates;
- if (rootA.Intersect(rootB, intersection_tolerance))
- candidates.push_back(std::make_pair(&rootA, &rootB));
+ if (rootA->Intersect(*rootB, intersection_tolerance))
+ candidates.push_back(std::make_pair(rootA, rootB));
// Use sub-division and bounding box intersections first.
for (int h = 0; h <= MAX_CCI_DEPTH; h++) {
@@ -1315,6 +1380,8 @@
x.Append(points[i]);
}
+ if (treeA == NULL) delete rootA;
+ if (treeB == NULL) delete rootB;
return x.Count() - original_count;
}
@@ -1359,7 +1426,7 @@
void
-newton_csi(double& t, double& u, double& v, const ON_Curve* curveA, const
ON_Surface* surfB, double intersection_tolerance, brlcad::SurfaceTree* tree)
+newton_csi(double& t, double& u, double& v, const ON_Curve* curveA, const
ON_Surface* surfB, double intersection_tolerance, Subsurface* tree)
{
// Equations:
// x_a(t) - x_b(u,v) = 0
@@ -1422,7 +1489,9 @@
const ON_Interval* curveA_domain,
const ON_Interval* surfaceB_udomain,
const ON_Interval* surfaceB_vdomain,
- ON_CurveArray* overlap2d)
+ ON_CurveArray* overlap2d,
+ Subcurve* treeA,
+ Subsurface* treeB)
{
if (curveA == NULL || surfaceB == NULL)
return 0;
@@ -1464,26 +1533,40 @@
return 0;
}
- Subcurve rootA;
- Subsurface rootB;
- if (!build_curve_root(curveA, curveA_domain, rootA))
+ Subcurve* rootA;
+ Subsurface* rootB;
+ if (treeA == NULL) {
+ rootA = new Subcurve;
+ if (rootA == NULL)
+ return 0;
+ } else
+ rootA = treeA;
+ if (treeB == NULL) {
+ rootB = new Subsurface;
+ if (rootB == NULL) {
+ if (treeA == NULL) delete rootA;
+ return 0;
+ }
+ } else
+ rootB = treeB;
+
+ if (!build_curve_root(curveA, curveA_domain, *rootA)) {
+ if (treeA == NULL) delete rootA;
+ if (treeB == NULL) delete rootB;
return 0;
- if (!build_surface_root(surfaceB, surfaceB_udomain, surfaceB_vdomain,
rootB))
+ }
+ if (!build_surface_root(surfaceB, surfaceB_udomain, surfaceB_vdomain,
*rootB)) {
+ if (treeA == NULL) delete rootA;
+ if (treeB == NULL) delete rootB;
return 0;
+ }
- // We need ON_BrepFace for get_closest_point().
- // This is used in point-surface intersections, in case we build the
- // tree again and again.
- ON_Brep *brep = surfaceB->BrepForm();
- if (!brep) return 0;
- brlcad::SurfaceTree *tree = new brlcad::SurfaceTree(brep->Face(0), false,
MAX_PSI_DEPTH);
-
// We adjust the tolerance from 3D scale to respective 2D scales.
- double l = rootA.m_curve->BoundingBox().Diagonal().Length();
+ double l = rootA->m_curve->BoundingBox().Diagonal().Length();
double dl = curveA_domain ? curveA_domain->Length() :
curveA->Domain().Length();
if (!ON_NearZero(l))
t_tolerance = intersection_tolerance/l*dl;
- l = rootB.m_surf->BoundingBox().Diagonal().Length();
+ l = rootB->m_surf->BoundingBox().Diagonal().Length();
dl = surfaceB_udomain ? surfaceB_udomain->Length() :
surfaceB->Domain(0).Length();
if (!ON_NearZero(l))
u_tolerance = intersection_tolerance/l*dl;
@@ -1493,8 +1576,8 @@
typedef std::vector<std::pair<Subcurve*, Subsurface*> > NodePairs;
NodePairs candidates, next_candidates;
- if (rootB.Intersect(rootA, intersection_tolerance))
- candidates.push_back(std::make_pair(&rootA, &rootB));
+ if (rootB->Intersect(*rootA, intersection_tolerance))
+ candidates.push_back(std::make_pair(rootA, rootB));
// Use sub-division and bounding box intersections first.
for (int h = 0; h <= MAX_CSI_DEPTH; h++) {
@@ -1559,7 +1642,7 @@
// First, we check the endpoints of the line segment
ON_ClassArray<ON_PX_EVENT> px_event1, px_event2;
int intersections = 0;
- if (ON_Intersect(line.from, *surfaceB, px_event1,
intersection_tolerance, 0, 0, tree)) {
+ if (ON_Intersect(line.from, *surfaceB, px_event1,
intersection_tolerance, 0, 0, treeB)) {
Event.m_A[intersections] = line.from;
Event.m_B[intersections] = px_event1[0].m_B;
Event.m_a[intersections] = i->first->m_t.Min();
@@ -1567,7 +1650,7 @@
Event.m_b[2*intersections+1] = px_event1[0].m_b[1];
intersections++;
}
- if (ON_Intersect(line.to, *surfaceB, px_event2,
intersection_tolerance, 0, 0, tree)) {
+ if (ON_Intersect(line.to, *surfaceB, px_event2,
intersection_tolerance, 0, 0, treeB)) {
Event.m_A[intersections] = line.to;
Event.m_B[intersections] = px_event2[0].m_B;
Event.m_a[intersections] = i->first->m_t.Max();
@@ -1666,7 +1749,7 @@
continue;
ON_3dPoint intersection = line.from +
line.Direction()*line_t;
ON_ClassArray<ON_PX_EVENT> px_event;
- if (!ON_Intersect(intersection, *(i->second->m_surf),
px_event, intersection_tolerance, 0, 0, tree))
+ if (!ON_Intersect(intersection, *(i->second->m_surf),
px_event, intersection_tolerance, 0, 0, treeB))
continue;
ON_X_EVENT Event;
@@ -1692,10 +1775,10 @@
// point)
double u1 = i->second->m_u.Mid(), v1 = i->second->m_v.Mid();
double t1 = i->first->m_t.Min();
- newton_csi(t1, u1, v1, curveA, surfaceB, intersection_tolerance, tree);
+ newton_csi(t1, u1, v1, curveA, surfaceB, intersection_tolerance, treeB);
double u2 = i->second->m_u.Mid(), v2 = i->second->m_v.Mid();
double t2 = i->first->m_t.Max();
- newton_csi(t2, u2, v2, curveA, surfaceB, intersection_tolerance, tree);
+ newton_csi(t2, u2, v2, curveA, surfaceB, intersection_tolerance, treeB);
if (isnan(u1) || isnan(v1) || isnan(t1)) {
u1 = u2; v1 = v2; t1 = t2;
@@ -1762,7 +1845,7 @@
ON_3dPoint test_point = curveA->PointAt(t1 +
(t2-t1)*j*strike);
ON_ClassArray<ON_PX_EVENT> psi_x;
// Use point-surface intersection
- if (!ON_Intersect(test_point, *surfaceB, psi_x,
overlap_tolerance, 0, 0, tree))
+ if (!ON_Intersect(test_point, *surfaceB, psi_x,
overlap_tolerance, 0, 0, treeB))
break;
}
if (j == CSI_OVERLAP_TEST_POINTS) {
@@ -1899,8 +1982,8 @@
}
}
- delete brep;
- delete tree;
+ if (treeA == NULL) delete rootA;
+ if (treeB == NULL) delete rootB;
return x.Count() - original_count;
}
@@ -2404,7 +2487,9 @@
const ON_Interval* surfaceA_udomain,
const ON_Interval* surfaceA_vdomain,
const ON_Interval* surfaceB_udomain,
- const ON_Interval* surfaceB_vdomain)
+ const ON_Interval* surfaceB_vdomain,
+ Subsurface* treeA,
+ Subsurface* treeB)
{
if (surfA == NULL || surfB == NULL) {
return 0;
@@ -2429,33 +2514,41 @@
*/
typedef std::vector<std::pair<Subsurface*, Subsurface*> > NodePairs;
NodePairs candidates, next_candidates;
- Subsurface rootA, rootB;
- build_surface_root(surfA, surfaceA_udomain, surfaceA_vdomain, rootA);
- build_surface_root(surfB, surfaceB_udomain, surfaceB_vdomain, rootB);
- if (rootA.Intersect(rootB, intersection_tolerance))
- candidates.push_back(std::make_pair(&rootA, &rootB));
- else
- return 0;
+ Subsurface *rootA, *rootB;
+ if (treeA == NULL) {
+ rootA = new Subsurface;
+ if (rootA == NULL)
+ return 0;
+ } else
+ rootA = treeA;
+ if (treeB == NULL) {
+ rootB = new Subsurface;
+ if (rootB == NULL) {
+ if (treeA == NULL) delete rootA;
+ return 0;
+ }
+ } else
+ rootB = treeB;
- // Generate brlcad::SurfaceTree() for point-surface intersections.
- ON_Brep *brepA = surfA->BrepForm();
- if (!brepA) return 0;
- brlcad::SurfaceTree *treeA = new brlcad::SurfaceTree(brepA->Face(0),
false, MAX_PSI_DEPTH);
-
- ON_Brep *brepB = surfB->BrepForm();
- if (!brepB) {
- delete brepA;
- delete treeA;
+ if (!build_surface_root(surfA, surfaceA_udomain, surfaceA_vdomain, *rootA)
+ || !build_surface_root(surfB, surfaceB_udomain, surfaceB_vdomain,
*rootB)) {
+ if (treeA == NULL) delete rootA;
+ if (treeB == NULL) delete rootB;
+ }
+ if (rootA->Intersect(*rootB, intersection_tolerance))
+ candidates.push_back(std::make_pair(rootA, rootB));
+ else {
+ if (treeA == NULL) delete rootA;
+ if (treeB == NULL) delete rootB;
return 0;
}
- brlcad::SurfaceTree *treeB = new brlcad::SurfaceTree(brepB->Face(0),
false, MAX_PSI_DEPTH);
// We adjust the tolerance from 3D scale to respective 2D scales.
double intersection_tolerance_A = intersection_tolerance;
double intersection_tolerance_B = intersection_tolerance;
double fitting_tolerance_A = fitting_tolerance;
double fitting_tolerance_B = fitting_tolerance;
- double l = rootA.m_surf->BoundingBox().Diagonal().Length();
+ double l = rootA->m_surf->BoundingBox().Diagonal().Length();
double ul = surfaceA_udomain ? surfaceA_udomain->Length() :
surfA->Domain(0).Length();
double vl = surfaceA_vdomain ? surfaceA_vdomain->Length() :
surfA->Domain(1).Length();
double dl = ON_2dVector(ul, vl).Length();
@@ -2491,7 +2584,7 @@
for (int i = 0; i < 4; i++) {
const ON_Surface* surf1 = i >= 2 ? surfB : surfA;
const ON_Surface* surf2 = i >= 2 ? surfA : surfB;
- brlcad::SurfaceTree* tree = i >= 2 ? treeA : treeB;
+ Subsurface* tree = i >= 2 ? treeA : treeB;
ON_2dPointArray& ptarray1 = i >= 2 ? tmp_curvest : tmp_curveuv;
ON_2dPointArray& ptarray2 = i >= 2 ? tmp_curveuv : tmp_curvest;
int dir = 1 - i%2;
@@ -2608,14 +2701,12 @@
ON_ClassArray<ON_PX_EVENT> e1, e2, e3, e4;
ON_2dPoint uv;
ON_2dPoint st;
- if (brlcad::get_closest_point(uv, brepA->Face(0),
x_event[k].m_A[0], treeA)
- && brlcad::get_closest_point(st, brepB->Face(0),
x_event[k].m_B[0], treeB)) {
- // get_closest_point() have bugs. Before fixing it, we use
this to detect an error and "fix" it.
- if (surfA->PointAt(uv.x,
uv.y).DistanceTo(x_event[k].m_A[0]) > surfA->PointAt(st.x,
st.y).DistanceTo(x_event[k].m_A[0]))
- uv = st;
- if (surfB->PointAt(st.x,
st.y).DistanceTo(x_event[k].m_B[0]) > surfB->PointAt(uv.x,
uv.y).DistanceTo(x_event[k].m_B[0]))
- st = uv;
+ ON_ClassArray<ON_PX_EVENT> pe1, pe2;
+ if (ON_Intersect(x_event[k].m_A[0], *surfA, pe1,
intersection_tolerance_A, 0, 0, treeA)
+ && ON_Intersect(x_event[k].m_B[0], *surfB, pe2,
intersection_tolerance_B, 0, 0, treeB)) {
// Pull the 3D curve back to the 2D space
+ uv = pe1[0].m_b;
+ st = pe2[0].m_b;
if (ON_Intersect(uv, *(overlaps[i]->m_curveA), e1,
intersection_tolerance_A)
&& ON_Intersect(st, *(overlaps[i]->m_curveB), e2,
intersection_tolerance_B)) {
param.x = x_event[k].m_a[0];
@@ -3118,10 +3209,8 @@
bu_log("%d points on the intersection curves.\n", curvept.Count());
if (!curvept.Count()) {
- delete brepA;
- delete treeA;
- delete brepB;
- delete treeB;
+ if (treeA == NULL) delete rootA;
+ if (treeB == NULL) delete rootB;
// Should not return 0 as there might be overlap events.
return x.Count() - original_count;
@@ -3134,7 +3223,7 @@
// (n is the number of points generated above)
// We need to automatically generate a threshold.
- double max_dis = std::min(rootA.m_surf->BoundingBox().Diagonal().Length(),
rootB.m_surf->BoundingBox().Diagonal().Length()) * 0.1;
+ double max_dis =
std::min(rootA->m_surf->BoundingBox().Diagonal().Length(),
rootB->m_surf->BoundingBox().Diagonal().Length()) * 0.1;
double max_dis_u = surfA->Domain(0).Length() * 0.05;
double max_dis_v = surfA->Domain(1).Length() * 0.05;
@@ -3468,10 +3557,8 @@
}
}
- delete brepA;
- delete treeA;
- delete brepB;
- delete treeB;
+ if (treeA == NULL) delete rootA;
+ if (treeB == NULL) delete rootB;
return x.Count() - original_count;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Get your SQL database under version control now!
Version control is standard for application code, but databases havent
caught up. So what steps can you take to put your SQL databases under
version control? Why should you start doing it? Read more to find out.
http://pubads.g.doubleclick.net/gampad/clk?id=49501711&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits