Corrected Geom2dConvert_CompCurveToBSplineCurve::Add in Geom2dConvert_CompCurveToBSplineCurve.cxx;
Added the test for this problem;
Corrected "gluing" curves in ProjLib_ProjectedCurve.cxx.
}
myTol = Tolerance;
+ const Standard_Real aSqTol = Tolerance * Tolerance;
Standard_Integer LBs = Bs->NbPoles(), LCb = myCurve->NbPoles();
+ Standard_Real d1 = myCurve->Pole(1).SquareDistance(Bs->Pole(1));
+ Standard_Real d2 = myCurve->Pole(1).SquareDistance(Bs->Pole(LBs));
+
+ Standard_Boolean isBeforeReversed = (myCurve->Pole(1).SquareDistance(Bs->Pole(1)) < aSqTol) && (d1 < d2);
+ Standard_Boolean isBefore = (myCurve->Pole(1).SquareDistance(Bs->Pole(LBs)) < aSqTol) || isBeforeReversed;
+
+ d1 = myCurve->Pole(LCb).SquareDistance(Bs->Pole(1));
+ d2 = myCurve->Pole(LCb).SquareDistance(Bs->Pole(LBs));
+
+ Standard_Boolean isAfterReversed = (myCurve->Pole(LCb).SquareDistance(Bs->Pole(LBs)) < aSqTol) && (d2 < d1);
+ Standard_Boolean isAfter = (myCurve->Pole(LCb).SquareDistance(Bs->Pole(1)) < aSqTol) || isAfterReversed;
- // myCurve est elle fermee ?
- if (myCurve->Pole(LCb).Distance(myCurve->Pole(1)) < myTol){
- if(After){
- // Ajout Apres ?
- Standard_Real d1 = myCurve->Pole(LCb).Distance(Bs->Pole(1));
- Standard_Real d2 = myCurve->Pole(LCb).Distance(Bs->Pole(LBs));
- if (d2 < d1) {
- Bs->Reverse();
- d1 = d2;
- }
- if (d1 < myTol) {
- Add(myCurve, Bs, Standard_True);
- return Standard_True;
- }
+ // myCurve and NewCurve together form a closed curve
+ if (isBefore && isAfter)
+ {
+ if (After)
+ {
+ isBefore = Standard_False;
}
- else{
- // Ajout avant ?
- Standard_Real d1 = myCurve->Pole(1).Distance(Bs->Pole(1));
- Standard_Real d2 = myCurve->Pole(1).Distance(Bs->Pole(LBs));
- if (d1 < d2) {
- Bs->Reverse();
- d2 = d1;
- }
- if (d2 < myTol) {
- Add(Bs, myCurve, Standard_False);
- return Standard_True;
- }
+ else
+ {
+ isAfter = Standard_False;
}
}
- // Ajout Apres ?
- else {
-
- Standard_Real d1 = myCurve->Pole(LCb).Distance(Bs->Pole(1));
- Standard_Real d2 = myCurve->Pole(LCb).Distance(Bs->Pole(LBs));
- if (( d1 < myTol) || ( d2 < myTol)) {
- if (d2 < d1) {Bs->Reverse();}
- Add(myCurve, Bs, Standard_True);
- return Standard_True;
+ if (isAfter)
+ {
+ if (isAfterReversed)
+ {
+ Bs->Reverse();
}
- // Ajout avant ?
- else {
- d1 = myCurve->Pole(1).Distance(Bs->Pole(1));
- d2 = myCurve->Pole(1).Distance(Bs->Pole(LBs));
- if ( (d1 < myTol) || (d2 < myTol)) {
- if (d1 < d2) {Bs->Reverse();}
- Add(Bs, myCurve, Standard_False );
- return Standard_True;
- }
+ Add(myCurve, Bs, Standard_True);
+ return Standard_True;
+
+ }
+ else if (isBefore)
+ {
+ if (isBeforeReversed)
+ {
+ Bs->Reverse();
}
- }
+ Add(Bs, myCurve, Standard_False);
+ return Standard_True;
+ }
+
return Standard_False;
}
aSegment = (FirstOrLast == 0)?
new Geom2d_TrimmedCurve(aSegLine, ParOnLin, 0.) :
new Geom2d_TrimmedCurve(aSegLine, 0., ParOnLin);
-
- aCompCurve.Add(aSegment, aTol);
+
+ Standard_Boolean anAfter = FirstOrLast != 0;
+ aCompCurve.Add(aSegment, aTol, anAfter);
aRes = aCompCurve.BSplineCurve();
}
return 0;
}
+//=======================================================================
+//function : OCC30747
+//purpose :
+//=======================================================================
+#include <Geom2d_Circle.hxx>
+#include <GCE2d_MakeCircle.hxx>
+#include <Geom2d_TrimmedCurve.hxx>
+#include <Geom2dConvert_CompCurveToBSplineCurve.hxx>
+static Standard_Integer OCC30747(Draw_Interpretor& theDI, Standard_Integer theArgc, const char** theArgV)
+{
+ if (theArgc < 2)
+ {
+ return 1;
+ }
+
+ const Handle(Geom2d_Circle) aCirc = GCE2d_MakeCircle(gp_Pnt2d(0, 0), 50);
+
+ Standard_Real aF = aCirc->FirstParameter();
+ Standard_Real aL = aCirc->LastParameter();
+ Standard_Real aNb = 10;
+ Standard_Real aDelta = (aF + aL) / aNb;
+ Handle(Geom2d_TrimmedCurve) aFTrim = new Geom2d_TrimmedCurve(aCirc, aF, aDelta);
+ Geom2dConvert_CompCurveToBSplineCurve aRes(aFTrim);
+ for (Standard_Integer anId = 1; anId < aNb; anId++)
+ {
+ Handle(Geom2d_TrimmedCurve) aLTrim;
+ if (anId == (aNb - 1))
+ {
+ aLTrim = new Geom2d_TrimmedCurve(aCirc, anId * aDelta, aF);
+ }
+ else
+ {
+ aLTrim = new Geom2d_TrimmedCurve(aCirc, anId * aDelta, (anId + 1) * aDelta);
+ }
+ aRes.Add(aLTrim, Precision::PConfusion());
+ }
+
+ if (!aRes.BSplineCurve()->IsClosed())
+ {
+ theDI << "Error: curve isn't closed";
+ return 1;
+ }
+
+ DrawTrSurf::Set(theArgV[1], aRes.BSplineCurve());
+ return 0;
+}
+
//=======================================================================
//function : OCC30869
//purpose :
theCommands.Add("OCC30391", "OCC30391 result face LenBeforeUfirst LenAfterUlast LenBeforeVfirst LenAfterVlast", __FILE__, OCC30391, group);
theCommands.Add("OCC29195", "OCC29195 [nbRep] doc1 [doc2 [doc3 [doc4]]]", __FILE__, OCC29195, group);
theCommands.Add("OCC30435", "OCC30435 result curve inverse nbit", __FILE__, OCC30435, group);
+ theCommands.Add("OCC30747", "OCC30747: create a closed curve", __FILE__, OCC30747, group);
theCommands.Add("OCC30990", "OCC30990 surface", __FILE__, OCC30990, group);
theCommands.Add("QAStartsWith",
--- /dev/null
+puts "================================================================="
+puts "OCC30747: Modeling Algorithms - 2d Curves concatenator doesn't properly process closed contours."
+puts "================================================================="
+puts ""
+
+pload QAcommands
+
+OCC30747 res
\ No newline at end of file