// Static subfunction in ComputePurgedWLine and DeleteOuter.
//=========================================================================
static Handle(IntPatch_WLine) MakeNewWLine(const Handle(IntPatch_WLine) &theWLine,
- const NCollection_Array1<Standard_Integer> &thePointsHash)
+ NCollection_Array1<Standard_Integer> &thePointsHash,
+ const Standard_Boolean theIsOuter)
{
Standard_Integer i;
Handle(IntSurf_LineOn2S) aPurgedLineOn2S = new IntSurf_LineOn2S();
Handle(IntPatch_WLine) aLocalWLine = new IntPatch_WLine(aPurgedLineOn2S, Standard_False);
- Standard_Integer anOldLineIdx = 1, aVertexIdx = 1;
+ Standard_Integer anOldLineIdx = 1, aVertexIdx = 1, anIndexPrev = -1, anIdxOld = -1;
+ gp_Pnt aPPrev, aPOld;
for(i = 1; i <= thePointsHash.Upper(); i++)
{
if (thePointsHash(i) == 0)
{
- // Store this point.
- aPurgedLineOn2S->Add(theWLine->Point(i));
- anOldLineIdx++;
+ // Point has to be added
+
+ const gp_Pnt aP = theWLine->Point(i).Value();
+ const Standard_Real aSqDistPrev = aPPrev.SquareDistance(aPOld);
+ const Standard_Real aSqDist = aPPrev.SquareDistance(aP);
+
+ const Standard_Real aRatio = (aSqDistPrev < gp::Resolution()) ? 0.0 : 9.0*aSqDist / aSqDistPrev;
+
+ if(theIsOuter ||
+ (aRatio < gp::Resolution()) ||
+ ((1.0 < aRatio) && (aRatio < 81.0)) ||
+ (i - anIndexPrev <= 1) ||
+ (i - anIdxOld <= 1))
+ {
+ // difference in distances is satisfactory
+ // (1/9 < aSqDist/aSqDistPrev < 9)
+
+ // Store this point.
+ aPurgedLineOn2S->Add(theWLine->Point(i));
+ anOldLineIdx++;
+ aPOld = aPPrev;
+ aPPrev = aP;
+ anIdxOld = anIndexPrev;
+ anIndexPrev = i;
+ }
+ else if(aSqDist >= aSqDistPrev*9.0)
+ {
+ // current segment is much more longer
+ // (aSqDist/aSqDistPrev >= 9)
+
+ i = (i + anIndexPrev)/2;
+ thePointsHash(i) = 0;
+ i--;
+ }
+ else
+ {
+ //previous segment is much more longer
+ //(aSqDist/aSqDistPrev <= 1/9)
+
+ if(anIndexPrev - anIdxOld > 1)
+ {
+ //Delete aPPrev from WL
+ aPurgedLineOn2S->RemovePoint(aPurgedLineOn2S->NbPoints());
+ anOldLineIdx--;
+
+ // Insert point between aPOld and aPPrev
+ i = (anIdxOld + anIndexPrev) / 2;
+ thePointsHash(i) = 0;
+
+ aPPrev = aPOld;
+ anIndexPrev = anIdxOld;
+ }
+ else
+ {
+ aPOld = aPPrev;
+ anIdxOld = anIndexPrev;
+ }
+
+ //Next iterations will start from this inserted point.
+ i--;
+ }
}
else if (thePointsHash(i) == -1)
{
aVertex.SetParameter(anOldLineIdx++);
aLocalWLine->AddVertex(aVertex);
aPurgedLineOn2S->Add(theWLine->Point(i));
+ aPPrev = aPOld = theWLine->Point(i).Value();
+ anIndexPrev = anIdxOld = i;
}
+
+ //Other points will be rejected by purger.
}
return aLocalWLine;
}
// Build new line and modify geometry of necessary vertexes.
- Handle(IntPatch_WLine) aLocalWLine = MakeNewWLine(theWLine, aDelOuterPointsHash);
+ Handle(IntPatch_WLine) aLocalWLine = MakeNewWLine(theWLine, aDelOuterPointsHash, Standard_True);
if (aChangedFirst)
{
}
}
- return MakeNewWLine(theWLine, aNewPointsHash);
+ return MakeNewWLine(theWLine, aNewPointsHash, Standard_False);
}
//=======================================================================
--- /dev/null
+puts "========"
+puts "OCC28557"
+puts "========"
+puts ""
+#################################################
+# Test case bugs modalg_6 bug27615 works differently on VC10 and VC12
+#################################################
+
+set MaxTolReached 5.0e-6
+set GoodNbCurv 1
+
+brestore [locate_data_file bug27615.brep] b
+explode b f
+copy b_1 f1; copy b_19 f2;
+don f1 f2
+set log [bopcurves f1 f2 -2d -p 2.2023968513463648 29.150590232723459 2. 0.085664915040461045 -p 2.2023968513457164 31.082210390953925 2.9507808705284453 0.085823752287563393]
+
+smallview
+donly c_1
+fit
+disp f1 f2
+
+checkview -screenshot -2d -path ${imagedir}/${test_image}_1.png
+
+regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Toler NbCurv
+
+if {$Toler > $MaxTolReached} {
+ puts "Error: Big tolerance is returned by intersector"
+}
+
+if {$NbCurv != $GoodNbCurv} {
+ puts "Error: Please check NbCurves for intersector"
+}
--- /dev/null
+puts "========"
+puts "OCC29323"
+puts "========"
+puts ""
+#################################################
+# Intersection algorithm produces the curve with oscillation
+#################################################
+
+set MaxTolReached 0.15
+set GoodNbCurv 1
+set ExpLength 96.268040111795571
+
+restore [locate_data_file bug29323_hb.brep] h
+plane p 0 0 4 0 0 1
+mkface f p -200 200 -200 200
+explode h f
+
+set log [bopcurves h_4 f -2d]
+
+smallview
+donly c_1
+fit
+
+checkview -screenshot -2d -path ${imagedir}/${test_image}_1.png
+checklength c_1 -l $ExpLength
+
+regexp {Tolerance Reached=+([-0-9.+eE]+)\n+([-0-9.+eE]+)} ${log} full Toler NbCurv
+
+if {$Toler > $MaxTolReached} {
+ puts "Error: Big tolerance is returned by intersector"
+}
+
+if {$NbCurv != $GoodNbCurv} {
+ puts "Error: Please check NbCurves for intersector"
+}
\ No newline at end of file