1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-10 18:51:21 +03:00

0024411: SplitShape produces shape with incorrectly parameterized periodic 3D curve

Implemented additional flag into Geom_TrimmedCurve to adjust or not the periodic curve inside the first period.

API of Geom2d_TrimmedCurve is changed according to Geom_TrimmedCurve.

Test-case for issue 
This commit is contained in:
azv 2014-12-25 17:57:55 +03:00 committed by bugmaster
parent 49b0c452e2
commit 8ac0cf5265
6 changed files with 70 additions and 38 deletions

@ -350,7 +350,7 @@ Handle(Geom2d_Curve) BRep_Tool::CurveOnSurface(const TopoDS_Edge& E,
GAS.Load(Plane); GAS.Load(Plane);
Handle(Geom_Curve) ProjOnPlane = Handle(Geom_Curve) ProjOnPlane =
GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,f,l), GeomProjLib::ProjectOnPlane(new Geom_TrimmedCurve(C3d,f,l,Standard_True,Standard_False),
Plane, Plane,
Plane->Position().Direction(), Plane->Position().Direction(),
Standard_True); Standard_True);

@ -46,7 +46,8 @@ raises ConstructionError from Standard,
is is
Create (C : Curve; U1, U2 : Real; Sense : Boolean = Standard_True) Create (C : Curve; U1, U2 : Real; Sense : Boolean = Standard_True;
theAdjustPeriodic : Boolean = Standard_True)
returns TrimmedCurve returns TrimmedCurve
---Purpose : Constructs a trimmed curve from the basis curve C ---Purpose : Constructs a trimmed curve from the basis curve C
-- which is limited between parameter values U1 and U2. -- which is limited between parameter values U1 and U2.
@ -70,12 +71,14 @@ is
-- Warning: The trimmed curve is built from a copy of curve C. -- Warning: The trimmed curve is built from a copy of curve C.
-- Therefore, when C is modified, the trimmed curve -- Therefore, when C is modified, the trimmed curve
-- is not modified. -- is not modified.
-- - If the basis curve is periodic, the bounds of the -- - If the basis curve is periodic and theAdjustPeriodic is True,
-- trimmed curve may be different from U1 and U2 -- the bounds of the trimmed curve may be different from U1 and U2
-- if the parametric origin of the basis curve is within -- if the parametric origin of the basis curve is within
-- the arc of the trimmed curve. In this case, the -- the arc of the trimmed curve. In this case, the
-- modified parameter will be equal to U1 or U2 -- modified parameter will be equal to U1 or U2
-- plus or minus the period. -- plus or minus the period.
-- When theAdjustPeriodic is False, parameters U1 and U2 will be
-- the same, without adjustment into the first period.
-- Exceptions -- Exceptions
-- Standard_ConstructionError if: -- Standard_ConstructionError if:
-- - C is not periodic and U1 or U2 is outside the -- - C is not periodic and U1 or U2 is outside the
@ -109,18 +112,21 @@ is
-- the point of parameter U on this trimmed curve. -- the point of parameter U on this trimmed curve.
SetTrim (me : mutable; U1, U2 : Real; Sense : Boolean = Standard_True) SetTrim (me : mutable; U1, U2 : Real; Sense : Boolean = Standard_True;
theAdjustPeriodic : Boolean = Standard_True)
---Purpose : Changes this trimmed curve, by redefining the ---Purpose : Changes this trimmed curve, by redefining the
-- parameter values U1 and U2 which limit its basis curve. -- parameter values U1 and U2 which limit its basis curve.
-- Note: If the basis curve is periodic, the trimmed curve -- Note: If the basis curve is periodic, the trimmed curve
-- has the same orientation as the basis curve if Sense -- has the same orientation as the basis curve if Sense
-- is true (default value) or the opposite orientation if Sense is false. -- is true (default value) or the opposite orientation if Sense is false.
-- Warning -- Warning
-- If the basis curve is periodic, the bounds of the -- If the basis curve is periodic and theAdjustPeriodic is True,
-- trimmed curve may be different from U1 and U2 if the -- the bounds of the trimmed curve may be different from U1 and U2 if the
-- parametric origin of the basis curve is within the arc of -- parametric origin of the basis curve is within the arc of
-- the trimmed curve. In this case, the modified -- the trimmed curve. In this case, the modified
-- parameter will be equal to U1 or U2 plus or minus the period. -- parameter will be equal to U1 or U2 plus or minus the period.
-- When theAdjustPeriodic is False, parameters U1 and U2 will be
-- the same, without adjustment into the first period.
-- Exceptions -- Exceptions
-- Standard_ConstructionError if: -- Standard_ConstructionError if:
-- - the basis curve is not periodic, and either U1 or U2 -- - the basis curve is not periodic, and either U1 or U2

@ -60,9 +60,10 @@ Handle(Geom_Geometry) Geom_TrimmedCurve::Copy () const {
//======================================================================= //=======================================================================
Geom_TrimmedCurve::Geom_TrimmedCurve (const Handle(Geom_Curve)& C, Geom_TrimmedCurve::Geom_TrimmedCurve (const Handle(Geom_Curve)& C,
const Standard_Real U1, const Standard_Real U1,
const Standard_Real U2, const Standard_Real U2,
const Standard_Boolean Sense) : const Standard_Boolean Sense,
const Standard_Boolean theAdjustPeriodic) :
uTrim1 (U1), uTrim1 (U1),
uTrim2 (U2) uTrim2 (U2)
{ {
@ -73,7 +74,7 @@ Geom_TrimmedCurve::Geom_TrimmedCurve (const Handle(Geom_Curve)& C,
else else
basisCurve = Handle(Curve)::DownCast(C->Copy()); basisCurve = Handle(Curve)::DownCast(C->Copy());
SetTrim(U1,U2,Sense); SetTrim(U1, U2, Sense, theAdjustPeriodic);
} }
//======================================================================= //=======================================================================
@ -86,7 +87,7 @@ void Geom_TrimmedCurve::Reverse ()
Standard_Real U1 = basisCurve->ReversedParameter(uTrim2); Standard_Real U1 = basisCurve->ReversedParameter(uTrim2);
Standard_Real U2 = basisCurve->ReversedParameter(uTrim1); Standard_Real U2 = basisCurve->ReversedParameter(uTrim1);
basisCurve->Reverse(); basisCurve->Reverse();
SetTrim(U1,U2); SetTrim(U1, U2, Standard_True, Standard_False);
} }
@ -108,8 +109,9 @@ Standard_Real Geom_TrimmedCurve::ReversedParameter
//======================================================================= //=======================================================================
void Geom_TrimmedCurve::SetTrim (const Standard_Real U1, void Geom_TrimmedCurve::SetTrim (const Standard_Real U1,
const Standard_Real U2, const Standard_Real U2,
const Standard_Boolean Sense) const Standard_Boolean Sense,
const Standard_Boolean theAdjustPeriodic)
{ {
Standard_Boolean sameSense = Standard_True; Standard_Boolean sameSense = Standard_True;
if (U1 == U2) if (U1 == U2)
@ -125,9 +127,10 @@ void Geom_TrimmedCurve::SetTrim (const Standard_Real U1,
// set uTrim2 in the range uTrim1 , uTrim1 + Period() // set uTrim2 in the range uTrim1 , uTrim1 + Period()
uTrim1 = U1; uTrim1 = U1;
uTrim2 = U2; uTrim2 = U2;
ElCLib::AdjustPeriodic(Udeb, Ufin, if (theAdjustPeriodic)
Min(Abs(uTrim2-uTrim1)/2,Precision::PConfusion()), ElCLib::AdjustPeriodic(Udeb, Ufin,
uTrim1, uTrim2); Min(Abs(uTrim2-uTrim1)/2,Precision::PConfusion()),
uTrim1, uTrim2);
} }
else { else {
@ -334,7 +337,7 @@ void Geom_TrimmedCurve::Transform (const Trsf& T)
basisCurve->Transform (T); basisCurve->Transform (T);
Standard_Real U1 = basisCurve->TransformedParameter(uTrim1,T); Standard_Real U1 = basisCurve->TransformedParameter(uTrim1,T);
Standard_Real U2 = basisCurve->TransformedParameter(uTrim2,T); Standard_Real U2 = basisCurve->TransformedParameter(uTrim2,T);
SetTrim(U1,U2); SetTrim(U1, U2, Standard_True, Standard_False);
} }

@ -43,7 +43,8 @@ raises ConstructionError from Standard,
is is
Create (C : Curve; U1, U2 : Real; Sense : Boolean = Standard_True) Create (C : Curve; U1, U2 : Real; Sense : Boolean = Standard_True;
theAdjustPeriodic : Boolean = Standard_True)
returns TrimmedCurve returns TrimmedCurve
--- Purpose : --- Purpose :
-- Creates a trimmed curve from the basis curve C limited between -- Creates a trimmed curve from the basis curve C limited between
@ -70,9 +71,9 @@ is
-- built with a copy of the curve C. So when C is modified the -- built with a copy of the curve C. So when C is modified the
-- TrimmedCurve is not modified -- TrimmedCurve is not modified
-- Warnings : -- Warnings :
-- If <C> is periodic, parametrics bounds of the TrimmedCurve, -- If <C> is periodic and <theAdjustPeriodic> is True, parametrics
-- can be different to [<U1>;<U2>}, if <U1> or <U2> are not in the -- bounds of the TrimmedCurve, can be different to [<U1>;<U2>},
-- principal period. -- if <U1> or <U2> are not in the principal period.
-- Include : -- Include :
-- For more explanation see the scheme given with this class. -- For more explanation see the scheme given with this class.
-- Raises ConstructionError the C is not periodic and U1 or U2 are out of -- Raises ConstructionError the C is not periodic and U1 or U2 are out of
@ -105,18 +106,20 @@ is
-- returns UFirst + ULast - U -- returns UFirst + ULast - U
SetTrim (me : mutable; U1, U2 : Real; Sense : Boolean = Standard_True) SetTrim (me : mutable; U1, U2 : Real; Sense : Boolean = Standard_True;
theAdjustPeriodic : Boolean = Standard_True)
--- Purpose : Changes this trimmed curve, by redefining the --- Purpose : Changes this trimmed curve, by redefining the
-- parameter values U1 and U2, which limit its basis curve. -- parameter values U1 and U2, which limit its basis curve.
-- Note: If the basis curve is periodic, the trimmed curve -- Note: If the basis curve is periodic, the trimmed curve
-- has the same orientation as the basis curve if Sense -- has the same orientation as the basis curve if Sense
-- is true (default value) or the opposite orientation if Sense is false. -- is true (default value) or the opposite orientation if Sense is false.
-- Warning -- Warning
-- If the basis curve is periodic, the bounds of the -- If the basis curve is periodic and theAdjustPeriodic is True,
-- trimmed curve may be different from U1 and U2 if the -- the bounds of the trimmed curve may be different from U1 and U2 if the
-- parametric origin of the basis curve is within the arc -- parametric origin of the basis curve is within the arc
-- of the trimmed curve. In this case, the modified -- of the trimmed curve. In this case, the modified
-- parameter will be equal to U1 or U2 plus or minus the period. -- parameter will be equal to U1 or U2 plus or minus the period.
-- If theAdjustPeriodic is False, parameters U1 and U2 will stay unchanged.
-- Exceptions -- Exceptions
-- Standard_ConstructionError if: -- Standard_ConstructionError if:
-- - the basis curve is not periodic, and either U1 or U2 -- - the basis curve is not periodic, and either U1 or U2

@ -62,9 +62,10 @@ Handle(Geom2d_Geometry) Geom2d_TrimmedCurve::Copy () const
//======================================================================= //=======================================================================
Geom2d_TrimmedCurve::Geom2d_TrimmedCurve (const Handle(Geom2d_Curve)& C, Geom2d_TrimmedCurve::Geom2d_TrimmedCurve (const Handle(Geom2d_Curve)& C,
const Standard_Real U1, const Standard_Real U1,
const Standard_Real U2, const Standard_Real U2,
const Standard_Boolean Sense) : const Standard_Boolean Sense,
const Standard_Boolean theAdjustPeriodic) :
uTrim1 (U1), uTrim1 (U1),
uTrim2 (U2) uTrim2 (U2)
{ {
@ -76,7 +77,7 @@ Geom2d_TrimmedCurve::Geom2d_TrimmedCurve (const Handle(Geom2d_Curve)& C,
else else
basisCurve = Handle(Curve)::DownCast(C->Copy()); basisCurve = Handle(Curve)::DownCast(C->Copy());
SetTrim(U1,U2,Sense); SetTrim(U1, U2, Sense, theAdjustPeriodic);
} }
//======================================================================= //=======================================================================
@ -89,7 +90,7 @@ void Geom2d_TrimmedCurve::Reverse ()
Standard_Real U1 = basisCurve->ReversedParameter(uTrim2); Standard_Real U1 = basisCurve->ReversedParameter(uTrim2);
Standard_Real U2 = basisCurve->ReversedParameter(uTrim1); Standard_Real U2 = basisCurve->ReversedParameter(uTrim1);
basisCurve->Reverse(); basisCurve->Reverse();
SetTrim(U1,U2); SetTrim(U1, U2, Standard_True, Standard_False);
} }
//======================================================================= //=======================================================================
@ -107,9 +108,10 @@ Standard_Real Geom2d_TrimmedCurve::ReversedParameter( const Standard_Real U) con
//purpose : //purpose :
//======================================================================= //=======================================================================
void Geom2d_TrimmedCurve::SetTrim (const Standard_Real U1, void Geom2d_TrimmedCurve::SetTrim (const Standard_Real U1,
const Standard_Real U2, const Standard_Real U2,
const Standard_Boolean Sense) const Standard_Boolean Sense,
const Standard_Boolean theAdjustPeriodic)
{ {
Standard_Boolean sameSense = Standard_True; Standard_Boolean sameSense = Standard_True;
if (U1 == U2) if (U1 == U2)
@ -124,10 +126,11 @@ void Geom2d_TrimmedCurve::SetTrim (const Standard_Real U1,
// set uTrim1 in the range Udeb , Ufin // set uTrim1 in the range Udeb , Ufin
// set uTrim2 in the range uTrim1 , uTrim1 + Period() // set uTrim2 in the range uTrim1 , uTrim1 + Period()
uTrim1 = U1; uTrim1 = U1;
uTrim2 = U2; uTrim2 = U2;
ElCLib::AdjustPeriodic(Udeb, Ufin, if (theAdjustPeriodic)
Min(Abs(uTrim2-uTrim1)/2,Precision::PConfusion()), ElCLib::AdjustPeriodic(Udeb, Ufin,
uTrim1, uTrim2); Min(Abs(uTrim2-uTrim1)/2,Precision::PConfusion()),
uTrim1, uTrim2);
} }
else { else {
if (U1 < U2) { if (U1 < U2) {
@ -316,7 +319,7 @@ void Geom2d_TrimmedCurve::Transform (const Trsf2d& T)
basisCurve->Transform (T); basisCurve->Transform (T);
Standard_Real U1 = basisCurve->TransformedParameter(uTrim1,T); Standard_Real U1 = basisCurve->TransformedParameter(uTrim1,T);
Standard_Real U2 = basisCurve->TransformedParameter(uTrim2,T); Standard_Real U2 = basisCurve->TransformedParameter(uTrim2,T);
SetTrim(U1,U2); SetTrim(U1, U2, Standard_True, Standard_False);
} }
//======================================================================= //=======================================================================

@ -0,0 +1,17 @@
puts "========"
puts "OCC24411"
puts "========"
puts ""
##############################################################################
# SplitShape produces shape with incorrectly parameterized periodic 3D curve
##############################################################################
restore [locate_data_file OCC24411_bug-ss.brep] s
explode s
splitshape r s_1 s_1 s_2
plane pl 0 0 0 0 0 1
mkface f pl
foreach e [explode r e] {
catch {pcurve c_$e $e f}
}