mirror of
https://git.dev.opencascade.org/repos/occt.git
synced 2025-04-21 10:13:43 +03:00
0030747: Modeling Algorithms - 2d Curves concatenator doesn't properly process closed contours.
Corrected Geom2dConvert_CompCurveToBSplineCurve::Add in Geom2dConvert_CompCurveToBSplineCurve.cxx; Added the test for this problem; Corrected "gluing" curves in ProjLib_ProjectedCurve.cxx.
This commit is contained in:
parent
c1638a8db8
commit
eb78d737d4
@ -84,59 +84,53 @@ Add(const Handle(Geom2d_BoundedCurve)& NewCurve,
|
|||||||
}
|
}
|
||||||
|
|
||||||
myTol = Tolerance;
|
myTol = Tolerance;
|
||||||
|
const Standard_Real aSqTol = Tolerance * Tolerance;
|
||||||
|
|
||||||
Standard_Integer LBs = Bs->NbPoles(), LCb = myCurve->NbPoles();
|
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));
|
||||||
|
|
||||||
// myCurve est elle fermee ?
|
Standard_Boolean isBeforeReversed = (myCurve->Pole(1).SquareDistance(Bs->Pole(1)) < aSqTol) && (d1 < d2);
|
||||||
if (myCurve->Pole(LCb).Distance(myCurve->Pole(1)) < myTol){
|
Standard_Boolean isBefore = (myCurve->Pole(1).SquareDistance(Bs->Pole(LBs)) < aSqTol) || isBeforeReversed;
|
||||||
if(After){
|
|
||||||
// Ajout Apres ?
|
d1 = myCurve->Pole(LCb).SquareDistance(Bs->Pole(1));
|
||||||
Standard_Real d1 = myCurve->Pole(LCb).Distance(Bs->Pole(1));
|
d2 = myCurve->Pole(LCb).SquareDistance(Bs->Pole(LBs));
|
||||||
Standard_Real d2 = myCurve->Pole(LCb).Distance(Bs->Pole(LBs));
|
|
||||||
if (d2 < d1) {
|
Standard_Boolean isAfterReversed = (myCurve->Pole(LCb).SquareDistance(Bs->Pole(LBs)) < aSqTol) && (d2 < d1);
|
||||||
Bs->Reverse();
|
Standard_Boolean isAfter = (myCurve->Pole(LCb).SquareDistance(Bs->Pole(1)) < aSqTol) || isAfterReversed;
|
||||||
d1 = d2;
|
|
||||||
}
|
// myCurve and NewCurve together form a closed curve
|
||||||
if (d1 < myTol) {
|
if (isBefore && isAfter)
|
||||||
Add(myCurve, Bs, Standard_True);
|
{
|
||||||
return Standard_True;
|
if (After)
|
||||||
}
|
{
|
||||||
|
isBefore = Standard_False;
|
||||||
}
|
}
|
||||||
else{
|
else
|
||||||
// Ajout avant ?
|
{
|
||||||
Standard_Real d1 = myCurve->Pole(1).Distance(Bs->Pole(1));
|
isAfter = Standard_False;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Ajout Apres ?
|
if (isAfter)
|
||||||
else {
|
{
|
||||||
|
if (isAfterReversed)
|
||||||
|
{
|
||||||
|
Bs->Reverse();
|
||||||
|
}
|
||||||
|
Add(myCurve, Bs, Standard_True);
|
||||||
|
return Standard_True;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
// 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
else if (isBefore)
|
||||||
|
{
|
||||||
|
if (isBeforeReversed)
|
||||||
|
{
|
||||||
|
Bs->Reverse();
|
||||||
|
}
|
||||||
|
Add(Bs, myCurve, Standard_False);
|
||||||
|
return Standard_True;
|
||||||
|
}
|
||||||
|
|
||||||
return Standard_False;
|
return Standard_False;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +263,8 @@ static void ExtendC2d (Handle(Geom2d_BSplineCurve)& aRes,
|
|||||||
new Geom2d_TrimmedCurve(aSegLine, ParOnLin, 0.) :
|
new Geom2d_TrimmedCurve(aSegLine, ParOnLin, 0.) :
|
||||||
new Geom2d_TrimmedCurve(aSegLine, 0., ParOnLin);
|
new Geom2d_TrimmedCurve(aSegLine, 0., ParOnLin);
|
||||||
|
|
||||||
aCompCurve.Add(aSegment, aTol);
|
Standard_Boolean anAfter = FirstOrLast != 0;
|
||||||
|
aCompCurve.Add(aSegment, aTol, anAfter);
|
||||||
aRes = aCompCurve.BSplineCurve();
|
aRes = aCompCurve.BSplineCurve();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3514,6 +3514,53 @@ static Standard_Integer OCC30708_2 (Draw_Interpretor& di, Standard_Integer, cons
|
|||||||
return 0;
|
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
|
//function : OCC30869
|
||||||
//purpose :
|
//purpose :
|
||||||
@ -4042,6 +4089,7 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
|
|||||||
theCommands.Add("OCC30391", "OCC30391 result face LenBeforeUfirst LenAfterUlast LenBeforeVfirst LenAfterVlast", __FILE__, OCC30391, group);
|
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("OCC29195", "OCC29195 [nbRep] doc1 [doc2 [doc3 [doc4]]]", __FILE__, OCC29195, group);
|
||||||
theCommands.Add("OCC30435", "OCC30435 result curve inverse nbit", __FILE__, OCC30435, 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("OCC30990", "OCC30990 surface", __FILE__, OCC30990, group);
|
||||||
|
|
||||||
theCommands.Add("QAStartsWith",
|
theCommands.Add("QAStartsWith",
|
||||||
|
8
tests/bugs/modalg_7/bug30747
Normal file
8
tests/bugs/modalg_7/bug30747
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
puts "================================================================="
|
||||||
|
puts "OCC30747: Modeling Algorithms - 2d Curves concatenator doesn't properly process closed contours."
|
||||||
|
puts "================================================================="
|
||||||
|
puts ""
|
||||||
|
|
||||||
|
pload QAcommands
|
||||||
|
|
||||||
|
OCC30747 res
|
Loading…
x
Reference in New Issue
Block a user