Revision: 56464
http://sourceforge.net/p/brlcad/code/56464
Author: phoenixyjll
Date: 2013-08-02 13:20:28 +0000 (Fri, 02 Aug 2013)
Log Message:
-----------
Remove the curves that doesn't have shared points on both starting point and
end point (it's impossible for them to be a part of the loop)
Modified Paths:
--------------
brlcad/trunk/src/libbrep/intersect.cpp
Modified: brlcad/trunk/src/libbrep/intersect.cpp
===================================================================
--- brlcad/trunk/src/libbrep/intersect.cpp 2013-08-02 13:18:03 UTC (rev
56463)
+++ brlcad/trunk/src/libbrep/intersect.cpp 2013-08-02 13:20:28 UTC (rev
56464)
@@ -2855,10 +2855,62 @@
}
}
+ // Find the neighbors for every overlap segment.
+ ON_SimpleArray<bool> start_linked(overlaps.Count()),
end_linked(overlaps.Count());
for (int i = 0; i < overlaps.Count(); i++) {
+ // Initialization
+ start_linked[i] = end_linked[i] = false;
+ }
+ for (int i = 0; i < overlaps.Count(); i++) {
if (!overlaps[i] || !overlaps[i]->m_curveA || !overlaps[i]->m_curveB ||
!overlaps[i]->m_curve3d)
continue;
+
+ if (overlaps[i]->m_curve3d->IsClosed() &&
overlaps[i]->m_curveA->IsClosed() && overlaps[i]->m_curveB->IsClosed()) {
+ start_linked[i] = end_linked[i] = true;
+ }
+
+ for (int j = i + 1; j < overlaps.Count(); j++) {
+ if (!overlaps[j] || !overlaps[j]->m_curveA ||
!overlaps[j]->m_curveB || !overlaps[j]->m_curve3d)
+ continue;
+ // Merge the curves that link together.
+ if
(overlaps[i]->m_curve3d->PointAtStart().DistanceTo(overlaps[j]->m_curve3d->PointAtEnd())
< intersection_tolerance
+ &&
overlaps[i]->m_curveA->PointAtStart().DistanceTo(overlaps[j]->m_curveA->PointAtEnd())
< intersection_tolerance_A
+ &&
overlaps[i]->m_curveB->PointAtStart().DistanceTo(overlaps[j]->m_curveB->PointAtEnd())
< intersection_tolerance_B) {
+ // end -- start -- end -- start
+ start_linked[i] = end_linked[j] = true;
+ } else if
(overlaps[i]->m_curve3d->PointAtEnd().DistanceTo(overlaps[j]->m_curve3d->PointAtStart())
< intersection_tolerance
+ &&
overlaps[i]->m_curveA->PointAtEnd().DistanceTo(overlaps[j]->m_curveA->PointAtStart())
< intersection_tolerance_A
+ &&
overlaps[i]->m_curveB->PointAtEnd().DistanceTo(overlaps[j]->m_curveB->PointAtStart())
< intersection_tolerance_B) {
+ // start -- end -- start -- end
+ start_linked[j] = end_linked[i] = true;
+ } else if
(overlaps[i]->m_curve3d->PointAtStart().DistanceTo(overlaps[j]->m_curve3d->PointAtStart())
< intersection_tolerance
+ &&
overlaps[i]->m_curveA->PointAtStart().DistanceTo(overlaps[j]->m_curveA->PointAtStart())
< intersection_tolerance_A
+ &&
overlaps[i]->m_curveB->PointAtStart().DistanceTo(overlaps[j]->m_curveB->PointAtStart())
< intersection_tolerance_B) {
+ // end -- start -- start -- end
+ start_linked[i] = start_linked[j] = true;
+ } else if
(overlaps[i]->m_curve3d->PointAtEnd().DistanceTo(overlaps[j]->m_curve3d->PointAtEnd())
< intersection_tolerance
+ &&
overlaps[i]->m_curveA->PointAtEnd().DistanceTo(overlaps[j]->m_curveA->PointAtEnd())
< intersection_tolerance_A
+ &&
overlaps[i]->m_curveB->PointAtEnd().DistanceTo(overlaps[j]->m_curveB->PointAtEnd())
< intersection_tolerance_B) {
+ // start -- end -- end -- start
+ end_linked[i] = end_linked[j] = true;
+ }
+ }
+ }
+
+ for (int i = 0; i < overlaps.Count(); i++) {
+ if (!overlaps[i] || !overlaps[i]->m_curveA || !overlaps[i]->m_curveB ||
!overlaps[i]->m_curve3d)
+ continue;
+ if (!start_linked[i] || !end_linked[i]) {
+ delete overlaps[i];
+ overlaps[i] = NULL;
+ }
+ }
+
+ for (int i = 0; i < overlaps.Count(); i++) {
+ if (!overlaps[i] || !overlaps[i]->m_curveA || !overlaps[i]->m_curveB ||
!overlaps[i]->m_curve3d)
+ continue;
+
for (int j = 0; j <= overlaps.Count(); j++) {
if (overlaps[i]->m_curve3d->IsClosed() &&
overlaps[i]->m_curveA->IsClosed() && overlaps[i]->m_curveB->IsClosed()) {
// The i-th curve is close loop, we get a complete boundary of
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