Revision: 55944
http://sourceforge.net/p/brlcad/code/55944
Author: phoenixyjll
Date: 2013-07-03 05:04:48 +0000 (Wed, 03 Jul 2013)
Log Message:
-----------
Comparing doubles cannot use minus directly. And if the starting point is good
enough, we don't need Newton iterations. When merging, m_b should be consistent
with m_a.
Modified Paths:
--------------
brlcad/trunk/src/libbrep/intersect.cpp
Modified: brlcad/trunk/src/libbrep/intersect.cpp
===================================================================
--- brlcad/trunk/src/libbrep/intersect.cpp 2013-07-03 04:46:20 UTC (rev
55943)
+++ brlcad/trunk/src/libbrep/intersect.cpp 2013-07-03 05:04:48 UTC (rev
55944)
@@ -637,7 +637,8 @@
int
compare_by_m_a0(const ON_X_EVENT* a, const ON_X_EVENT* b)
{
- return a->m_a[0] - b->m_a[0];
+ // We don't care whether they are equal
+ return a->m_a[0] < b->m_a[0] ? -1 : 1;
}
@@ -1035,6 +1036,13 @@
if (pointA.DistanceTo(pointB) < intersection_tolerance)
return;
+ ON_ClassArray<ON_PX_EVENT> px_event;
+ if (ON_Intersect(pointA, *surfB, px_event, intersection_tolerance, 0, 0,
tree)) {
+ u = px_event[0].m_b.x;
+ v = px_event[0].m_b.y;
+ return;
+ }
+
int iteration = 0;
while (fabs(last_t - t) + fabs(last_u - u) + fabs(last_v - v) >
ON_ZERO_TOLERANCE
&& iteration++ < CCI_MAX_ITERATIONS) {
@@ -1428,10 +1436,6 @@
bool merged = false;
for (int j = 0; j < pending.Count(); j++) {
if (pending[j].m_a[1] < overlap[i].m_a[0] - intersection_tolerance)
{
- pending[j].m_A[0] = curveA->PointAt(pending[j].m_a[0]);
- pending[j].m_A[1] = curveA->PointAt(pending[j].m_a[1]);
- pending[j].m_B[0] = surfaceB->PointAt(pending[j].m_b[0],
pending[j].m_b[1]);
- pending[j].m_B[1] = surfaceB->PointAt(pending[j].m_b[2],
pending[j].m_b[3]);
x.Append(pending[j]);
pending.Remove(j);
j--;
@@ -1440,11 +1444,13 @@
if (overlap[i].m_a[0] < pending[j].m_a[1] + intersection_tolerance)
{
// Need to merge (TODO: need some consideration for surfaceB)
merged = true;
- pending[j].m_a[1] = std::max(overlap[i].m_a[1],
pending[j].m_a[1]);
- pending[j].m_b[0] = std::min(overlap[i].m_b[0],
pending[j].m_b[0]);
- pending[j].m_b[1] = std::min(overlap[i].m_b[1],
pending[j].m_b[1]);
- pending[j].m_b[2] = std::max(overlap[i].m_b[2],
pending[j].m_b[2]);
- pending[j].m_b[3] = std::max(overlap[i].m_b[3],
pending[j].m_b[3]);
+ if (overlap[i].m_a[1] > pending[j].m_a[1]) {
+ pending[j].m_a[1] = overlap[i].m_a[1];
+ pending[j].m_b[2] = overlap[i].m_b[2];
+ pending[j].m_b[3] = overlap[i].m_b[3];
+ pending[j].m_A[1] = overlap[i].m_A[1];
+ pending[j].m_B[1] = overlap[i].m_B[1];
+ }
break;
}
}
@@ -1452,10 +1458,6 @@
pending.Append(overlap[i]);
}
for (int i = 0; i < pending.Count(); i++) {
- pending[i].m_A[0] = curveA->PointAt(pending[i].m_a[0]);
- pending[i].m_A[1] = curveA->PointAt(pending[i].m_a[1]);
- pending[i].m_B[0] = surfaceB->PointAt(pending[i].m_b[0],
pending[i].m_b[1]);
- pending[i].m_B[1] = surfaceB->PointAt(pending[i].m_b[2],
pending[i].m_b[3]);
x.Append(pending[i]);
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:
Build for Windows Store.
http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits