Revision: 56772
http://sourceforge.net/p/brlcad/code/56772
Author: phoenixyjll
Date: 2013-08-13 05:30:44 +0000 (Tue, 13 Aug 2013)
Log Message:
-----------
We should take care of the intersection tolerance, and "fix" the "gaps" if
necessary.
Modified Paths:
--------------
brlcad/trunk/src/libbrep/boolean.cpp
Modified: brlcad/trunk/src/libbrep/boolean.cpp
===================================================================
--- brlcad/trunk/src/libbrep/boolean.cpp 2013-08-13 03:30:32 UTC (rev
56771)
+++ brlcad/trunk/src/libbrep/boolean.cpp 2013-08-13 05:30:44 UTC (rev
56772)
@@ -38,6 +38,7 @@
#include "raytrace.h"
#define DEBUG 1
+#define INTERSECTION_TOL 0.001
struct TrimmedFace {
@@ -161,7 +162,7 @@
ON_2dPoint out = pt + ON_2dVector(bbox.Diagonal());
ON_LineCurve linecurve(pt, out);
ON_SimpleArray<ON_X_EVENT> x_event;
- ON_Intersect(&linecurve, &polycurve, x_event);
+ ON_Intersect(&linecurve, &polycurve, x_event, INTERSECTION_TOL);
int count = x_event.Count();
for (int i = 0; i < x_event.Count(); i++) {
// Find tangent intersections.
@@ -196,22 +197,23 @@
continue;
ON_Curve *c1 = NULL, *c2 = NULL;
+ double dis;
// Link curves that share an end point.
- if (tmp[i]->PointAtStart().DistanceTo(tmp[j]->PointAtEnd()) <
BREP_SAME_POINT_TOLERANCE) {
+ if ((dis = tmp[i]->PointAtStart().DistanceTo(tmp[j]->PointAtEnd()))
< INTERSECTION_TOL) {
// end -- start -- end -- start
c1 = tmp[j];
c2 = tmp[i];
- } else if (tmp[i]->PointAtEnd().DistanceTo(tmp[j]->PointAtStart())
< BREP_SAME_POINT_TOLERANCE) {
+ } else if ((dis =
tmp[i]->PointAtEnd().DistanceTo(tmp[j]->PointAtStart())) < INTERSECTION_TOL) {
// start -- end -- start -- end
c1 = tmp[i];
c2 = tmp[j];
- } else if
(tmp[i]->PointAtStart().DistanceTo(tmp[j]->PointAtStart()) <
BREP_SAME_POINT_TOLERANCE) {
+ } else if ((dis =
tmp[i]->PointAtStart().DistanceTo(tmp[j]->PointAtStart())) < INTERSECTION_TOL) {
// end -- start -- start -- end
if (tmp[i]->Reverse()) {
c1 = tmp[i];
c2 = tmp[j];
}
- } else if (tmp[i]->PointAtEnd().DistanceTo(tmp[j]->PointAtEnd()) <
BREP_SAME_POINT_TOLERANCE) {
+ } else if ((dis =
tmp[i]->PointAtEnd().DistanceTo(tmp[j]->PointAtEnd())) < INTERSECTION_TOL) {
// start -- end -- end -- start
if (tmp[j]->Reverse()) {
c1 = tmp[i];
@@ -223,10 +225,23 @@
if (c1 != NULL && c2 != NULL) {
ON_PolyCurve* polycurve = new ON_PolyCurve;
polycurve->Append(c1);
+ if (dis > ON_ZERO_TOLERANCE)
+ polycurve->Append(new ON_LineCurve(c1->PointAtEnd(),
c2->PointAtStart()));
polycurve->Append(c2);
tmp[i] = polycurve;
tmp[j] = NULL;
}
+
+ // Check whether tmp[i] is closed within a tolerance
+ if (tmp[i]->PointAtStart().DistanceTo(tmp[i]->PointAtEnd()) <
INTERSECTION_TOL && !tmp[i]->IsClosed()) {
+ // make IsClosed() true
+ c1 = tmp[i];
+ c2 = new ON_LineCurve(tmp[i]->PointAtEnd(),
tmp[i]->PointAtStart());
+ ON_PolyCurve* polycurve = new ON_PolyCurve;
+ polycurve->Append(c1);
+ polycurve->Append(c2);
+ tmp[i] = polycurve;
+ }
}
}
@@ -268,7 +283,7 @@
for (int i = 0; i < in->outerloop.Count(); i++) {
for (int j = 0; j < curves.Count(); j++) {
ON_SimpleArray<ON_X_EVENT> x_event;
- ON_Intersect(in->outerloop[i], curves[j], x_event);
+ ON_Intersect(in->outerloop[i], curves[j], x_event,
INTERSECTION_TOL);
for (int k = 0; k < x_event.Count(); k++) {
if (x_event[k].m_type == ON_X_EVENT::ccx_overlap)
continue; // Deal with it later
@@ -292,6 +307,7 @@
// The start point cannot be on the boundary of the loop, because
// there is no intersections between curves[i] and the loop.
if (IsPointInsideLoop(curves[i]->PointAtStart(), in->outerloop)) {
+ bu_log("*********inside loop.\n");
if (curves[i]->IsClosed()) {
ON_SimpleArray<ON_Curve*> iloop;
iloop.Append(curves[i]);
@@ -608,7 +624,8 @@
ON_ClassArray<ON_SSX_EVENT> events;
if (ON_Intersect(brepA->m_S[brepA->m_F[i].m_si],
brepB->m_S[brepB->m_F[j].m_si],
- events) <= 0)
+ events,
+ INTERSECTION_TOL) <= 0)
continue;
ON_SimpleArray<ON_Curve*> curve_uv, curve_st;
for (int k = 0; k < events.Count(); k++) {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Get 100% visibility into Java/.NET code with AppDynamics Lite!
It's a free troubleshooting tool designed for production.
Get down to code-level detail for bottlenecks, with <2% overhead.
Download for free and get started troubleshooting in minutes.
http://pubads.g.doubleclick.net/gampad/clk?id=48897031&iu=/4140/ostg.clktrk
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits