diff --git a/adm/UDLIST b/adm/UDLIST index 56446c378a..0e596d3014 100644 --- a/adm/UDLIST +++ b/adm/UDLIST @@ -67,6 +67,7 @@ n GeomLProp n GeomLib n GeomProjLib n GeomTools +n GeomEvaluator n Hermit n IntAna n IntAna2d diff --git a/src/Adaptor3d/Adaptor3d_IsoCurve.cxx b/src/Adaptor3d/Adaptor3d_IsoCurve.cxx index c583dacb23..5fc38f0664 100644 --- a/src/Adaptor3d/Adaptor3d_IsoCurve.cxx +++ b/src/Adaptor3d/Adaptor3d_IsoCurve.cxx @@ -15,7 +15,6 @@ #include #include #include -#include #include #include #include diff --git a/src/Adaptor3d/FILES b/src/Adaptor3d/FILES index ed0771ffd9..b48a53c683 100644 --- a/src/Adaptor3d/FILES +++ b/src/Adaptor3d/FILES @@ -18,10 +18,6 @@ Adaptor3d_HIsoCurve_0.cxx Adaptor3d_HSurface.cxx Adaptor3d_HSurface.hxx Adaptor3d_HSurface.lxx -Adaptor3d_HSurfaceOfLinearExtrusion.hxx -Adaptor3d_HSurfaceOfLinearExtrusion_0.cxx -Adaptor3d_HSurfaceOfRevolution.hxx -Adaptor3d_HSurfaceOfRevolution_0.cxx Adaptor3d_HSurfaceTool.cxx Adaptor3d_HSurfaceTool.hxx Adaptor3d_HSurfaceTool.lxx @@ -34,10 +30,6 @@ Adaptor3d_IsoCurve.hxx Adaptor3d_IsoCurve.lxx Adaptor3d_Surface.cxx Adaptor3d_Surface.hxx -Adaptor3d_SurfaceOfLinearExtrusion.cxx -Adaptor3d_SurfaceOfLinearExtrusion.hxx -Adaptor3d_SurfaceOfRevolution.cxx -Adaptor3d_SurfaceOfRevolution.hxx Adaptor3d_SurfacePtr.hxx Adaptor3d_TopolTool.cxx Adaptor3d_TopolTool.hxx diff --git a/src/BRepFill/BRepFill_TrimSurfaceTool.cxx b/src/BRepFill/BRepFill_TrimSurfaceTool.cxx index c28dbbac7f..a619d02aa6 100644 --- a/src/BRepFill/BRepFill_TrimSurfaceTool.cxx +++ b/src/BRepFill/BRepFill_TrimSurfaceTool.cxx @@ -15,7 +15,7 @@ // commercial license or contractual agreement. -#include +#include #include #include #include @@ -370,7 +370,7 @@ static void EvalParameters(const TopoDS_Edge& Edge, Handle(Geom_SurfaceOfRevolution)::DownCast(GS); Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(GSRev->BasisCurve()); - Adaptor3d_SurfaceOfRevolution ASRev(HC,GAS.AxeOfRevolution()); + GeomAdaptor_SurfaceOfRevolution ASRev(HC,GAS.AxeOfRevolution()); Axis = ASRev.Axis(); Phase = EvalPhase(Edge,Face,GAS,Axis); break; diff --git a/src/BRepSweep/BRepSweep_Rotation.cxx b/src/BRepSweep/BRepSweep_Rotation.cxx index a9b98a0081..400671e911 100644 --- a/src/BRepSweep/BRepSweep_Rotation.cxx +++ b/src/BRepSweep/BRepSweep_Rotation.cxx @@ -15,7 +15,7 @@ // commercial license or contractual agreement. -#include +#include #include #include #include @@ -346,7 +346,7 @@ TopoDS_Shape BRepSweep_Rotation::MakeEmptyFace Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(); HC->ChangeCurve().Load(C,First,Last); - Adaptor3d_SurfaceOfRevolution AS(HC,myAxe); + GeomAdaptor_SurfaceOfRevolution AS(HC,myAxe); switch(AS.GetType()){ case GeomAbs_Plane : { diff --git a/src/BRepSweep/BRepSweep_Translation.cxx b/src/BRepSweep/BRepSweep_Translation.cxx index 7889dbbece..289e12f7f5 100644 --- a/src/BRepSweep/BRepSweep_Translation.cxx +++ b/src/BRepSweep/BRepSweep_Translation.cxx @@ -15,7 +15,7 @@ // commercial license or contractual agreement. -#include +#include #include #include #include @@ -266,7 +266,7 @@ TopoDS_Shape BRepSweep_Translation::MakeEmptyFace if (myCanonize) { Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(C,First,Last); - Adaptor3d_SurfaceOfLinearExtrusion AS(HC,D); + GeomAdaptor_SurfaceOfLinearExtrusion AS(HC,D); switch(AS.GetType()){ case GeomAbs_Plane : diff --git a/src/Draft/Draft_Modification_1.cxx b/src/Draft/Draft_Modification_1.cxx index 08b053e0fb..57b0d8e065 100644 --- a/src/Draft/Draft_Modification_1.cxx +++ b/src/Draft/Draft_Modification_1.cxx @@ -16,7 +16,7 @@ #include #include -#include +#include #include #include #include @@ -630,7 +630,7 @@ Standard_Boolean Draft_Modification::Propagate () errStat = Draft_EdgeRecomputation; break; // leave from while } - Adaptor3d_SurfaceOfLinearExtrusion SLE(HCur,Direc); + GeomAdaptor_SurfaceOfLinearExtrusion SLE(HCur,Direc); switch(SLE.GetType()){ case GeomAbs_Plane : diff --git a/src/Extrema/Extrema_ExtPExtS.cxx b/src/Extrema/Extrema_ExtPExtS.cxx index bd82c1612d..2def513f06 100644 --- a/src/Extrema/Extrema_ExtPExtS.cxx +++ b/src/Extrema/Extrema_ExtPExtS.cxx @@ -33,7 +33,7 @@ #include #include #include -#include +#include static gp_Ax2 GetPosition (const Handle(Adaptor3d_HCurve)& C); @@ -158,7 +158,7 @@ Extrema_ExtPExtS::Extrema_ExtPExtS() //============================================================================= Extrema_ExtPExtS::Extrema_ExtPExtS (const gp_Pnt& theP, - const Handle(Adaptor3d_HSurfaceOfLinearExtrusion)& theS, + const Handle(GeomAdaptor_HSurfaceOfLinearExtrusion)& theS, const Standard_Real theUmin, const Standard_Real theUsup, const Standard_Real theVmin, @@ -189,7 +189,7 @@ Extrema_ExtPExtS::Extrema_ExtPExtS (const gp_Pnt& //============================================================================= Extrema_ExtPExtS::Extrema_ExtPExtS (const gp_Pnt& theP, - const Handle(Adaptor3d_HSurfaceOfLinearExtrusion)& theS, + const Handle(GeomAdaptor_HSurfaceOfLinearExtrusion)& theS, const Standard_Real theTolU, const Standard_Real theTolV) : myuinf(theS->FirstUParameter()), @@ -219,7 +219,7 @@ Extrema_ExtPExtS::Extrema_ExtPExtS (const gp_Pnt& //purpose : //======================================================================= -void Extrema_ExtPExtS::Initialize (const Handle(Adaptor3d_HSurfaceOfLinearExtrusion)& theS, +void Extrema_ExtPExtS::Initialize (const Handle(GeomAdaptor_HSurfaceOfLinearExtrusion)& theS, const Standard_Real theUinf, const Standard_Real theUsup, const Standard_Real theVinf, diff --git a/src/Extrema/Extrema_ExtPExtS.hxx b/src/Extrema/Extrema_ExtPExtS.hxx index 3a384fdbbb..de4ca15d6d 100644 --- a/src/Extrema/Extrema_ExtPExtS.hxx +++ b/src/Extrema/Extrema_ExtPExtS.hxx @@ -30,7 +30,7 @@ #include #include class Adaptor3d_HCurve; -class Adaptor3d_HSurfaceOfLinearExtrusion; +class GeomAdaptor_HSurfaceOfLinearExtrusion; class StdFail_NotDone; class Standard_OutOfRange; class gp_Pnt; @@ -54,14 +54,14 @@ public: //! It calculates all the distances between a point //! from gp and a Surface. - Standard_EXPORT Extrema_ExtPExtS(const gp_Pnt& P, const Handle(Adaptor3d_HSurfaceOfLinearExtrusion)& S, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV); + Standard_EXPORT Extrema_ExtPExtS(const gp_Pnt& P, const Handle(GeomAdaptor_HSurfaceOfLinearExtrusion)& S, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV); //! It calculates all the distances between a point //! from gp and a Surface. - Standard_EXPORT Extrema_ExtPExtS(const gp_Pnt& P, const Handle(Adaptor3d_HSurfaceOfLinearExtrusion)& S, const Standard_Real TolU, const Standard_Real TolV); + Standard_EXPORT Extrema_ExtPExtS(const gp_Pnt& P, const Handle(GeomAdaptor_HSurfaceOfLinearExtrusion)& S, const Standard_Real TolU, const Standard_Real TolV); //! Initializes the fields of the algorithm. - Standard_EXPORT void Initialize (const Handle(Adaptor3d_HSurfaceOfLinearExtrusion)& S, const Standard_Real Uinf, const Standard_Real Usup, const Standard_Real Vinf, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV); + Standard_EXPORT void Initialize (const Handle(GeomAdaptor_HSurfaceOfLinearExtrusion)& S, const Standard_Real Uinf, const Standard_Real Usup, const Standard_Real Vinf, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV); Standard_EXPORT void Perform (const gp_Pnt& P); @@ -100,7 +100,7 @@ private: Standard_Real mytolv; Extrema_FuncExtPS myF; Handle(Adaptor3d_HCurve) myC; - Handle(Adaptor3d_HSurfaceOfLinearExtrusion) myS; + Handle(GeomAdaptor_HSurfaceOfLinearExtrusion) myS; gp_Vec myDirection; gp_Ax2 myPosition; Extrema_GenExtPS myExtPS; diff --git a/src/Extrema/Extrema_ExtPRevS.cxx b/src/Extrema/Extrema_ExtPRevS.cxx index bede89bd15..5990864c94 100644 --- a/src/Extrema/Extrema_ExtPRevS.cxx +++ b/src/Extrema/Extrema_ExtPRevS.cxx @@ -16,7 +16,7 @@ #include -#include +#include #include #include #include @@ -35,7 +35,7 @@ #include #include -static gp_Ax2 GetPosition (const Adaptor3d_SurfaceOfRevolution& S)//const Handle(Adaptor_HCurve)& C) +static gp_Ax2 GetPosition (const GeomAdaptor_SurfaceOfRevolution& S)//const Handle(Adaptor_HCurve)& C) { Handle(Adaptor3d_HCurve) C = S.BasisCurve(); @@ -76,7 +76,7 @@ static gp_Ax2 GetPosition (const Adaptor3d_SurfaceOfRevolution& S)//const Handle //purpose : //======================================================================= -static Standard_Boolean HasSingularity(const Adaptor3d_SurfaceOfRevolution& S) +static Standard_Boolean HasSingularity(const GeomAdaptor_SurfaceOfRevolution& S) { const Handle(Adaptor3d_HCurve) C = S.BasisCurve(); @@ -216,7 +216,7 @@ Extrema_ExtPRevS::Extrema_ExtPRevS() //======================================================================= Extrema_ExtPRevS::Extrema_ExtPRevS (const gp_Pnt& theP, - const Handle(Adaptor3d_HSurfaceOfRevolution)& theS, + const Handle(GeomAdaptor_HSurfaceOfRevolution)& theS, const Standard_Real theUmin, const Standard_Real theUsup, const Standard_Real theVmin, @@ -240,7 +240,7 @@ Extrema_ExtPRevS::Extrema_ExtPRevS (const gp_Pnt& //======================================================================= Extrema_ExtPRevS::Extrema_ExtPRevS (const gp_Pnt& theP, - const Handle(Adaptor3d_HSurfaceOfRevolution)& theS, + const Handle(GeomAdaptor_HSurfaceOfRevolution)& theS, const Standard_Real theTolU, const Standard_Real theTolV) { @@ -259,7 +259,7 @@ Extrema_ExtPRevS::Extrema_ExtPRevS (const gp_Pnt& //purpose : //======================================================================= -void Extrema_ExtPRevS::Initialize (const Handle(Adaptor3d_HSurfaceOfRevolution)& theS, +void Extrema_ExtPRevS::Initialize (const Handle(GeomAdaptor_HSurfaceOfRevolution)& theS, const Standard_Real theUmin, const Standard_Real theUsup, const Standard_Real theVmin, diff --git a/src/Extrema/Extrema_ExtPRevS.hxx b/src/Extrema/Extrema_ExtPRevS.hxx index bbeee0d9d2..84f20c6e23 100644 --- a/src/Extrema/Extrema_ExtPRevS.hxx +++ b/src/Extrema/Extrema_ExtPRevS.hxx @@ -27,7 +27,7 @@ #include #include #include -class Adaptor3d_HSurfaceOfRevolution; +class GeomAdaptor_HSurfaceOfRevolution; class StdFail_NotDone; class Standard_OutOfRange; class gp_Pnt; @@ -50,13 +50,13 @@ public: //! It calculates all the distances between a point //! from gp and a SurfacePtr from Adaptor3d. - Standard_EXPORT Extrema_ExtPRevS(const gp_Pnt& P, const Handle(Adaptor3d_HSurfaceOfRevolution)& S, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV); + Standard_EXPORT Extrema_ExtPRevS(const gp_Pnt& P, const Handle(GeomAdaptor_HSurfaceOfRevolution)& S, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV); //! It calculates all the distances between a point //! from gp and a SurfacePtr from Adaptor3d. - Standard_EXPORT Extrema_ExtPRevS(const gp_Pnt& P, const Handle(Adaptor3d_HSurfaceOfRevolution)& S, const Standard_Real TolU, const Standard_Real TolV); + Standard_EXPORT Extrema_ExtPRevS(const gp_Pnt& P, const Handle(GeomAdaptor_HSurfaceOfRevolution)& S, const Standard_Real TolU, const Standard_Real TolV); - Standard_EXPORT void Initialize (const Handle(Adaptor3d_HSurfaceOfRevolution)& S, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV); + Standard_EXPORT void Initialize (const Handle(GeomAdaptor_HSurfaceOfRevolution)& S, const Standard_Real Umin, const Standard_Real Usup, const Standard_Real Vmin, const Standard_Real Vsup, const Standard_Real TolU, const Standard_Real TolV); Standard_EXPORT void Perform (const gp_Pnt& P); @@ -85,7 +85,7 @@ protected: private: - Handle(Adaptor3d_HSurfaceOfRevolution) myS; + Handle(GeomAdaptor_HSurfaceOfRevolution) myS; Standard_Real myvinf; Standard_Real myvsup; Standard_Real mytolv; diff --git a/src/Extrema/Extrema_ExtPS.cxx b/src/Extrema/Extrema_ExtPS.cxx index e006d2e1ab..97075e695f 100644 --- a/src/Extrema/Extrema_ExtPS.cxx +++ b/src/Extrema/Extrema_ExtPS.cxx @@ -14,8 +14,8 @@ //----------------------------------------------------------------- -#include -#include +#include +#include #include #include #include @@ -289,8 +289,8 @@ void Extrema_ExtPS::Perform(const gp_Pnt& thePoint) { if (myExtPExtS.IsNull()) { - Handle(Adaptor3d_HSurfaceOfLinearExtrusion) aS (new Adaptor3d_HSurfaceOfLinearExtrusion ( - Adaptor3d_SurfaceOfLinearExtrusion (myS->BasisCurve(), myS->Direction()))); + Handle(GeomAdaptor_HSurfaceOfLinearExtrusion) aS (new GeomAdaptor_HSurfaceOfLinearExtrusion ( + GeomAdaptor_SurfaceOfLinearExtrusion (myS->BasisCurve(), myS->Direction()))); myExtPExtS = new Extrema_ExtPExtS (thePoint, aS, myuinf, myusup, myvinf, myvsup, mytolu, mytolv); } @@ -315,8 +315,8 @@ void Extrema_ExtPS::Perform(const gp_Pnt& thePoint) { if (myExtPRevS.IsNull()) { - Handle(Adaptor3d_HSurfaceOfRevolution) aS (new Adaptor3d_HSurfaceOfRevolution ( - Adaptor3d_SurfaceOfRevolution (myS->BasisCurve(), myS->AxeOfRevolution()))); + Handle(GeomAdaptor_HSurfaceOfRevolution) aS (new GeomAdaptor_HSurfaceOfRevolution ( + GeomAdaptor_SurfaceOfRevolution (myS->BasisCurve(), myS->AxeOfRevolution()))); myExtPRevS = new Extrema_ExtPRevS (thePoint, aS, myuinf, myusup, myvinf, myvsup, mytolu, mytolv); } diff --git a/src/Geom/Geom_OffsetSurface.cxx b/src/Geom/Geom_OffsetSurface.cxx index dbaa10f1e8..2a02f62d50 100644 --- a/src/Geom/Geom_OffsetSurface.cxx +++ b/src/Geom/Geom_OffsetSurface.cxx @@ -49,6 +49,7 @@ #include #include #include +#include #include #include #include @@ -73,122 +74,6 @@ static const Standard_Real MyAngularToleranceForG1 = Precision::Angular(); -//======================================================================= -//function : derivatives -//purpose : -//======================================================================= - -static void derivatives(Standard_Integer MaxOrder, - Standard_Integer MinOrder, - const Standard_Real U, - const Standard_Real V, - const Handle(Geom_Surface)& basisSurf, - const Standard_Integer Nu, - const Standard_Integer Nv, - const Standard_Boolean AlongU, - const Standard_Boolean AlongV, - const Handle(Geom_BSplineSurface)& L, - TColgp_Array2OfVec& DerNUV, - TColgp_Array2OfVec& DerSurf) -{ - Standard_Integer i,j; - gp_Pnt P; - gp_Vec DL1U, DL1V, DL2U , DL2V , DL2UV ,DL3U, DL3UUV, DL3UVV, DL3V; - - if (AlongU || AlongV) - { - MaxOrder=0; - TColgp_Array2OfVec DerSurfL(0,MaxOrder+Nu+1,0,MaxOrder+Nv+1); - switch (MinOrder) - { - case 1 : - L->D1(U, V, P, DL1U, DL1V); - DerSurfL.SetValue(1, 0, DL1U); - DerSurfL.SetValue(0, 1, DL1V); - break; - case 2 : - L->D2(U, V, P, DL1U, DL1V, DL2U , DL2V , DL2UV); - DerSurfL.SetValue(1, 0, DL1U); - DerSurfL.SetValue(0, 1, DL1V); - DerSurfL.SetValue(1, 1, DL2UV); - DerSurfL.SetValue(2, 0, DL2U); - DerSurfL.SetValue(0, 2, DL2V); - break; - case 3 : - L->D3(U, V, P, DL1U, DL1V, DL2U , DL2V , DL2UV ,DL3U, DL3V ,DL3UUV, DL3UVV); - DerSurfL.SetValue(1, 0, DL1U); - DerSurfL.SetValue(0, 1, DL1V); - DerSurfL.SetValue(1, 1, DL2UV); - DerSurfL.SetValue(2, 0, DL2U); - DerSurfL.SetValue(0, 2, DL2V); - DerSurfL.SetValue(3, 0, DL3U); - DerSurfL.SetValue(2, 1, DL3UUV); - DerSurfL.SetValue(1, 2, DL3UVV); - DerSurfL.SetValue(0, 3, DL3V); - break; - default: - break; - } - - if(Nu <= Nv) - { - for(i=0;i<=MaxOrder+1+Nu;i++) - for(j=i;j<=MaxOrder+Nv+1;j++) - if(i+j> MinOrder) - { - DerSurfL.SetValue(i,j,L->DN(U,V,i,j)); - DerSurf.SetValue(i,j,basisSurf->DN(U,V,i,j)); - if (i!=j && j <= Nu+1) - { - DerSurf.SetValue(j,i,basisSurf->DN(U,V,j,i)); - DerSurfL.SetValue(j,i,L->DN(U,V,j,i)); - } - } - } - else - { - for(j=0;j<=MaxOrder+1+Nv;j++) - for(i=j;i<=MaxOrder+Nu+1;i++) - if(i+j> MinOrder) - { - DerSurfL.SetValue(i,j,L->DN(U,V,i,j)); - DerSurf.SetValue(i,j,basisSurf->DN(U,V,i,j)); - if (i!=j && i <= Nv+1) - { - DerSurf.SetValue(j,i,basisSurf->DN(U,V,j,i)); - DerSurfL.SetValue(j,i,L->DN(U,V,j,i)); - } - } - } - for(i=0;i<=MaxOrder+Nu;i++) - for(j=0;j<=MaxOrder+Nv;j++) - { - if (AlongU) - DerNUV.SetValue(i,j,CSLib::DNNUV(i,j,DerSurfL,DerSurf)); - if (AlongV) - DerNUV.SetValue(i,j,CSLib::DNNUV(i,j,DerSurf,DerSurfL)); - } - - } - else - { - - for(i=0;i<=MaxOrder+Nu+1;i++) - for(j=i;j<=MaxOrder+Nv+1;j++) - if(i+j>MinOrder) - { - - DerSurf.SetValue(i,j,basisSurf->DN(U,V,i,j)); - if (i!=j) DerSurf.SetValue(j,i,basisSurf->DN(U,V,j,i)); - } - for(i=0;i<=MaxOrder+Nu;i++) - for(j=0;j<=MaxOrder+Nv;j++) - { - DerNUV.SetValue(i,j,CSLib::DNNUV(i,j,DerSurf)); - } - } - -} //======================================================================= //function : Copy @@ -332,13 +217,21 @@ void Geom_OffsetSurface::SetBasisSurface (const Handle(Geom_Surface)& S, } equivSurf = Surface(); - // - // Tolerance en dur pour l'instant ,mais on devrait la proposer dans le constructeur - // et la mettre en champ, on pourrait utiliser par exemple pour l'extraction d'iso - // et aussi pour les singularite. Pour les surfaces osculatrices, on l'utilise pour - // detecter si une iso est degeneree. - const Standard_Real Tol = Precision::Confusion(); //0.0001; - myOscSurf.Init(basisSurf,Tol); + + if (basisSurf->IsKind(STANDARD_TYPE(Geom_BSplineSurface)) || + basisSurf->IsKind(STANDARD_TYPE(Geom_BezierSurface))) + { + // Tolerance en dur pour l'instant ,mais on devrait la proposer dans le constructeur + // et la mettre en champ, on pourrait utiliser par exemple pour l'extraction d'iso + // et aussi pour les singularite. Pour les surfaces osculatrices, on l'utilise pour + // detecter si une iso est degeneree. + const Standard_Real Tol = Precision::Confusion(); //0.0001; + myOscSurf = new Geom_OsculatingSurface(basisSurf, Tol); + } + + // Surface value calculator + if (equivSurf.IsNull()) + myEvaluator = new GeomEvaluator_OffsetSurface(basisSurf, offsetValue, myOscSurf); } //======================================================================= @@ -350,6 +243,13 @@ void Geom_OffsetSurface::SetOffsetValue (const Standard_Real D) { offsetValue = D; equivSurf = Surface(); + if (equivSurf.IsNull()) + { + if (myEvaluator.IsNull()) + myEvaluator = new GeomEvaluator_OffsetSurface(basisSurf, offsetValue, myOscSurf); + else + myEvaluator->SetOffsetValue(offsetValue); + } } //======================================================================= @@ -359,9 +259,12 @@ void Geom_OffsetSurface::SetOffsetValue (const Standard_Real D) void Geom_OffsetSurface::UReverse () { - basisSurf->UReverse(); + basisSurf->UReverse(); offsetValue = -offsetValue; - if(!equivSurf.IsNull()) equivSurf->UReverse(); + if (!equivSurf.IsNull()) + equivSurf->UReverse(); + else + myEvaluator->SetOffsetValue(offsetValue); } //======================================================================= @@ -383,7 +286,10 @@ void Geom_OffsetSurface::VReverse () { basisSurf->VReverse(); offsetValue = -offsetValue; - if(!equivSurf.IsNull()) equivSurf->VReverse(); + if (!equivSurf.IsNull()) + equivSurf->VReverse(); + else + myEvaluator->SetOffsetValue(offsetValue); } //======================================================================= @@ -430,15 +336,12 @@ GeomAbs_Shape Geom_OffsetSurface::Continuity () const void Geom_OffsetSurface::D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const { - gp_Vec D1U, D1V; #ifdef CHECK if (myBasisSurfContinuity == GeomAbs_C0) Geom_UndefinedValue::Raise(); #endif - if (equivSurf.IsNull()){ - basisSurf->D1(U, V, P, D1U, D1V); - SetD0(U,V,P,D1U,D1V); - } + if (equivSurf.IsNull()) + myEvaluator->D0(U, V, P); else equivSurf->D0(U,V,P); } @@ -457,12 +360,8 @@ void Geom_OffsetSurface::D1 (const Standard_Real U, const Standard_Real V, myBasisSurfContinuity == GeomAbs_C1) Geom_UndefinedDerivative::Raise(); #endif - if (equivSurf.IsNull()) - { - gp_Vec d2u, d2v, d2uv; - basisSurf->D2(U, V, P, D1U, D1V, d2u, d2v, d2uv); - SetD1(U,V,P,D1U,D1V,d2u,d2v,d2uv); - } + if (equivSurf.IsNull()) + myEvaluator->D1(U, V, P, D1U, D1V); else equivSurf->D1(U,V,P,D1U,D1V); } @@ -484,11 +383,7 @@ void Geom_OffsetSurface::D2 (const Standard_Real U, const Standard_Real V, Geom_UndefinedDerivative::Raise(); #endif if (equivSurf.IsNull()) - { - gp_Vec d3u, d3uuv, d3uvv, d3v; - basisSurf->D3(U, V, P, D1U, D1V, D2U, D2V, D2UV, d3u, d3v, d3uuv, d3uvv); - SetD2(U,V,P,D1U,D1V,D2U,D2V,D2UV,d3u,d3v,d3uuv,d3uvv); - } + myEvaluator->D2(U, V, P, D1U, D1V, D2U, D2V, D2UV); else equivSurf->D2(U,V,P,D1U,D1V,D2U,D2V,D2UV); } @@ -510,10 +405,7 @@ void Geom_OffsetSurface::D3 (const Standard_Real U, const Standard_Real V, } #endif if (equivSurf.IsNull()) - { - basisSurf->D3(U, V, P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); - SetD3(U, V, P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); - } + myEvaluator->D3(U, V, P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); else equivSurf->D3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); } @@ -535,510 +427,12 @@ gp_Vec Geom_OffsetSurface::DN (const Standard_Real U, const Standard_Real gp_Vec D(0,0,0); if (equivSurf.IsNull()) - { - gp_Pnt P; - gp_Vec D1U,D1V; - basisSurf->D1 (U, V, P, D1U, D1V); - - D = SetDN(U,V,Nu,Nv,D1U,D1V); - } + D = myEvaluator->DN(U, V, Nu, Nv); else D = equivSurf->DN(U,V,Nu,Nv); return D; } -//======================================================================= -//function : D1 -//purpose : -//======================================================================= - -void Geom_OffsetSurface::D1 - (const Standard_Real U, const Standard_Real V, - gp_Pnt& P, gp_Pnt& Pbasis, - gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D1Ubasis, gp_Vec& D1Vbasis, - gp_Vec& D2Ubasis, gp_Vec& D2Vbasis, gp_Vec& D2UVbasis) const -{ - const GeomAbs_Shape basisCont = basisSurf->Continuity(); - if (basisCont == GeomAbs_C0 || basisCont == GeomAbs_C1) - Geom_UndefinedDerivative::Raise(); - basisSurf->D2 (U, V, Pbasis, D1Ubasis, D1Vbasis, D2Ubasis, D2Vbasis, D2UVbasis); - gp_Vec Ndir = D1Ubasis.Crossed (D1Vbasis); - const Standard_Real R2 = Ndir.SquareMagnitude(); - const Standard_Real R = Sqrt (R2); - const Standard_Real R3 = R * R2; - gp_Vec DUNdir = D2Ubasis.Crossed (D1Vbasis); - DUNdir.Add (D1Ubasis.Crossed (D2UVbasis)); - gp_Vec DVNdir = D2UVbasis.Crossed (D1Vbasis); - DVNdir.Add (D1Ubasis.Crossed (D2Vbasis)); - const Standard_Real DRu = Ndir.Dot (DUNdir); - const Standard_Real DRv = Ndir.Dot (DVNdir); - if (R3 <= gp::Resolution()) { - if (R2 <= gp::Resolution()) - Geom_UndefinedDerivative::Raise(); - DUNdir.Multiply(R); - DUNdir.Subtract (Ndir.Multiplied (DRu/R)); - DUNdir.Multiply (offsetValue/R2); - D1U = D1Ubasis.Added (DUNdir); - DVNdir.Multiply(R); - DVNdir.Subtract (Ndir.Multiplied (DRv/R)); - DVNdir.Multiply (offsetValue/R2); - D1V = D1Vbasis.Added (DVNdir); - } - else { - DUNdir.Multiply (offsetValue / R); - DUNdir.Subtract (Ndir.Multiplied (offsetValue*DRu/R3)); - D1U = D1Ubasis.Added (DUNdir); - DVNdir.Multiply (offsetValue / R); - DVNdir.Subtract (Ndir.Multiplied (offsetValue*DRv/R3)); - D1V = D1Vbasis.Added (DVNdir); - } - Ndir.Multiply (offsetValue/R); - P.SetXYZ ((Ndir.XYZ()).Added (Pbasis.XYZ())); -} - -//======================================================================= -//function : D2 -//purpose : -//======================================================================= - -void Geom_OffsetSurface::D2 - (const Standard_Real U, const Standard_Real V, - gp_Pnt& P, gp_Pnt& Pbasis, - gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, - gp_Vec& D1Ubasis, gp_Vec& D1Vbasis, - gp_Vec& D2Ubasis, gp_Vec& D2Vbasis, gp_Vec& D2UVbasis, - gp_Vec& D3Ubasis, gp_Vec& D3Vbasis, gp_Vec& D3UUVbasis, gp_Vec& D3UVVbasis) const -{ - const GeomAbs_Shape basisCont = basisSurf->Continuity(); - if (basisCont == GeomAbs_C0 || basisCont == GeomAbs_C1 || basisCont == GeomAbs_C2) - Geom_UndefinedDerivative::Raise(); - basisSurf->D3 (U, V, P, D1Ubasis, D1Vbasis, D2Ubasis, D2Vbasis, D2UVbasis, D3Ubasis, D3Vbasis, D3UUVbasis, D3UVVbasis); - gp_Vec Ndir = D1Ubasis.Crossed (D1Vbasis); - const Standard_Real R2 = Ndir.SquareMagnitude(); - const Standard_Real R = Sqrt (R2); - const Standard_Real R3 = R2 * R; - const Standard_Real R4 = R2 * R2; - const Standard_Real R5 = R3 * R2; - gp_Vec DUNdir = D2Ubasis.Crossed (D1Vbasis); - DUNdir.Add (D1Ubasis.Crossed (D2UVbasis)); - gp_Vec DVNdir = D2UVbasis.Crossed (D1Vbasis); - DVNdir.Add (D1Ubasis.Crossed (D2Vbasis)); - const Standard_Real DRu = Ndir.Dot (DUNdir); - const Standard_Real DRv = Ndir.Dot (DVNdir); - gp_Vec D2UNdir = D3Ubasis.Crossed (D1Vbasis); - D2UNdir.Add (D1Ubasis.Crossed (D3UUVbasis)); - D2UNdir.Add (2.0 * (D2Ubasis.Crossed (D2UVbasis))); - gp_Vec D2VNdir = D3UVVbasis.Crossed (D1Vbasis); - D2VNdir.Add (D1Ubasis.Crossed (D3Vbasis)); - D2VNdir.Add (2.0 * (D2UVbasis.Crossed (D2Vbasis))); - gp_Vec D2UVNdir = D2UVbasis.Crossed (D1Vbasis); - D2UVNdir.Add (D1Ubasis.Crossed (D3UVVbasis)); - D2UVNdir.Add (D2Ubasis.Crossed (D2Vbasis)); - const Standard_Real D2Ru = Ndir.Dot (D2UNdir) + DUNdir.Dot (DUNdir); - const Standard_Real D2Rv = Ndir.Dot (D2VNdir) + DVNdir.Dot (DVNdir); - const Standard_Real D2Ruv = DVNdir.Dot (DUNdir) + Ndir.Dot (D2UVNdir); - - if (R5 <= gp::Resolution()) { - //We try another computation but the stability is not very good - //dixit ISG. - if (R4 <= gp::Resolution()) Geom_UndefinedDerivative::Raise(); - // V2 = P" (U) : - // Standard_Real R4 = R2 * R2; - D2UNdir.Subtract (DUNdir.Multiplied (2.0 * DRu / R2)); - D2UNdir.Subtract (Ndir.Multiplied (D2Ru/R2)); - D2UNdir.Add (Ndir.Multiplied (3.0 * DRu * DRu / R4)); - D2UNdir.Multiply (offsetValue / R); - D2U = D2Ubasis.Added (D2UNdir); - D2VNdir.Subtract (DVNdir.Multiplied (2.0 * DRv / R2)); - D2VNdir.Subtract (Ndir.Multiplied (D2Rv/R2)); - D2VNdir.Add (Ndir.Multiplied (3.0 * DRv * DRv / R4)); - D2VNdir.Multiply (offsetValue / R); - D2V = D2Vbasis.Added (D2VNdir); - - D2UVNdir.Subtract (DUNdir.Multiplied (DRv / R2)); - D2UVNdir.Subtract (DVNdir.Multiplied (DRu / R2)); - D2UVNdir.Subtract (Ndir.Multiplied (D2Ruv / R2)); - D2UVNdir.Add (Ndir.Multiplied (3.0 * DRu * DRv / R4)); - D2UVNdir.Multiply (offsetValue / R); - D2UV = D2UVbasis.Added (D2UVNdir); - - DUNdir.Multiply(R); - DUNdir.Subtract (Ndir.Multiplied (DRu/R)); - DUNdir.Multiply (offsetValue/R2); - D1U = D1Ubasis.Added (DUNdir); - DVNdir.Multiply(R); - DVNdir.Subtract (Ndir.Multiplied (DRv/R)); - DVNdir.Multiply (offsetValue/R2); - D1V = D1Vbasis.Added (DVNdir); - } - else { - D2UNdir.Multiply (offsetValue/R); - D2UNdir.Subtract (DUNdir.Multiplied (2.0 * offsetValue * DRu / R3)); - D2UNdir.Subtract (Ndir.Multiplied (offsetValue * D2Ru / R3)); - D2UNdir.Add (Ndir.Multiplied (offsetValue * 3.0 * DRu * DRu / R5)); - D2U = D2Ubasis.Added (D2UNdir); - - D2VNdir.Multiply (offsetValue/R); - D2VNdir.Subtract (DVNdir.Multiplied (2.0 * offsetValue * DRv / R3)); - D2VNdir.Subtract (Ndir.Multiplied (offsetValue * D2Rv / R3)); - D2VNdir.Add (Ndir.Multiplied (offsetValue * 3.0 * DRv * DRv / R5)); - D2V = D2Vbasis.Added (D2VNdir); - - D2UVNdir.Multiply (offsetValue/R); - D2UVNdir.Subtract (DUNdir.Multiplied (offsetValue * DRv / R3)); - D2UVNdir.Subtract (DVNdir.Multiplied (offsetValue * DRu / R3)); - D2UVNdir.Subtract (Ndir.Multiplied (offsetValue * D2Ruv / R3)); - D2UVNdir.Add (Ndir.Multiplied (3.0 * offsetValue * DRu * DRv / R5)); - D2UV = D2UVbasis.Added (D2UVNdir); - - DUNdir.Multiply (offsetValue / R); - DUNdir.Subtract (Ndir.Multiplied (offsetValue*DRu/R3)); - D1U = D1Ubasis.Added (DUNdir); - DVNdir.Multiply (offsetValue / R); - DVNdir.Subtract (Ndir.Multiplied (offsetValue*DRv/R3)); - D1V = D1Vbasis.Added (DVNdir); - } - Ndir.Multiply (offsetValue/R); - P.SetXYZ ((Ndir.XYZ()).Added (Pbasis.XYZ())); -} - -//======================================================================= -//function : LocalD0 -//purpose : -//======================================================================= - -void Geom_OffsetSurface::LocalD0 (const Standard_Real U, const Standard_Real V, - const Standard_Integer USide, const Standard_Integer VSide, - gp_Pnt& P) const -{ - if (equivSurf.IsNull()) { - gp_Vec D1U, D1V; - Handle(Geom_Surface) Basis = basisSurf; - - // if Basis is Trimmed we take the basis's basis - Handle(Geom_RectangularTrimmedSurface) RTS = - Handle(Geom_RectangularTrimmedSurface)::DownCast(Basis); - if (!RTS.IsNull()) - Basis = RTS->BasisSurface(); - - // BSpline case - Handle(Geom_BSplineSurface) BSplS = - Handle(Geom_BSplineSurface)::DownCast(Basis); - if (!BSplS.IsNull()) { - gp_Vec D2U,D2V,D2UV, D3U,D3V,D3UUV,D3UVV; - LocateSides(U,V,USide,VSide,BSplS,1,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - SetD0(U,V,P,D1U,D1V); - return; - } - - // Extrusion case - Handle( Geom_SurfaceOfLinearExtrusion) SE = - Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(Basis); - if (!SE.IsNull()) { - SE->LocalD1(U,V,USide,P,D1U,D1V); - SetD0(U,V,P,D1U,D1V); - return; - } - - // Revolution case - Handle(Geom_SurfaceOfRevolution) SR = - Handle(Geom_SurfaceOfRevolution)::DownCast(Basis); - if (!SR.IsNull()) { - SR->LocalD1(U,V,VSide,P,D1U,D1V); - SetD0(U,V,P,D1U,D1V); - return; - } - - // General cases - basisSurf->D1(U, V, P, D1U, D1V); - SetD0(U,V,P,D1U,D1V); - } - else - equivSurf-> D0(U,V,P); -} - -//======================================================================= -//function : LocalD1 -//purpose : -//======================================================================= - -void Geom_OffsetSurface::LocalD1 (const Standard_Real U, const Standard_Real V, - const Standard_Integer USide, const Standard_Integer VSide, - gp_Pnt& P, - gp_Vec& D1U, gp_Vec& D1V) const -{ - if (equivSurf.IsNull()) { - gp_Vec D2U,D2V,D2UV ; - Handle(Geom_Surface) Basis = basisSurf; - - // if Basis is Trimmed we take the basis's basis - Handle(Geom_RectangularTrimmedSurface) RTS = - Handle(Geom_RectangularTrimmedSurface)::DownCast(Basis); - if (!RTS.IsNull()) - Basis = RTS->BasisSurface(); - - // BSpline case - Handle(Geom_BSplineSurface) BSplS = - Handle(Geom_BSplineSurface)::DownCast(Basis); - if (!BSplS.IsNull()) { - gp_Vec D3U,D3V,D3UUV,D3UVV; - LocateSides(U,V,USide,VSide,BSplS,2,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - SetD1(U,V,P,D1U,D1V,D2U,D2V,D2UV); - return; - } - - // Extrusion case - Handle( Geom_SurfaceOfLinearExtrusion) SE = - Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(Basis); - if (!SE.IsNull()) { - SE->LocalD2(U,V,USide,P,D1U,D1V,D2U,D2V,D2UV); - SetD1(U,V,P,D1U,D1V,D2U,D2V,D2UV); - return; - } - - // Revolution case - Handle(Geom_SurfaceOfRevolution) SR = - Handle(Geom_SurfaceOfRevolution)::DownCast(Basis); - if (!SR.IsNull()) { - SR->LocalD2(U,V,VSide,P,D1U,D1V,D2U,D2V,D2UV); - SetD1(U,V,P,D1U,D1V,D2U,D2V,D2UV); - return; - } - - // General cases - basisSurf->D2(U, V, P, D1U, D1V, D2U, D2V, D2UV); - SetD1(U,V,P,D1U,D1V,D2U,D2V,D2UV); - } - else - equivSurf->D1(U,V,P,D1U,D1V); -} - -//======================================================================= -//function : LocalD2 -//purpose : -//======================================================================= - -void Geom_OffsetSurface::LocalD2 (const Standard_Real U, const Standard_Real V, - const Standard_Integer USide, const Standard_Integer VSide, - gp_Pnt& P, - gp_Vec& D1U, gp_Vec& D1V, - gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const -{ - if (equivSurf.IsNull()) { - Handle(Geom_Surface) Basis = basisSurf; - gp_Vec D3U,D3V,D3UUV,D3UVV; - - // if Basis is Trimmed we take the basis's basis - Handle(Geom_RectangularTrimmedSurface) RTS = - Handle(Geom_RectangularTrimmedSurface)::DownCast(Basis); - if (!RTS.IsNull()) - Basis = RTS->BasisSurface(); - - // BSpline case - Handle(Geom_BSplineSurface) BSplS = - Handle(Geom_BSplineSurface)::DownCast(Basis); - if (!BSplS.IsNull()) { - LocateSides(U,V,USide,VSide,BSplS,3,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - SetD2(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - return; - } - - // Extrusion case - Handle(Geom_SurfaceOfLinearExtrusion) SE = - Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(Basis); - if (!SE.IsNull()) { - SE->LocalD3(U,V,USide,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - SetD2(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - return; - } - - // Revolution case - Handle(Geom_SurfaceOfRevolution) SR = - Handle(Geom_SurfaceOfRevolution)::DownCast(Basis); - if (!SR.IsNull()) { - SR->LocalD3(U,V,VSide,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - SetD2(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - return; - } - - // General cases - basisSurf->D3(U, V, P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); - SetD2(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - } - else - equivSurf->D2(U,V,P,D1U,D1V,D2U,D2V,D2UV); -} - -//======================================================================= -//function : LocalD3 -//purpose : -//======================================================================= - -void Geom_OffsetSurface::LocalD3 (const Standard_Real U, const Standard_Real V, - const Standard_Integer USide, const Standard_Integer VSide, - gp_Pnt& P, - gp_Vec& D1U, gp_Vec& D1V, - gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, - gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const -{ - if (equivSurf.IsNull()) { - Handle(Geom_Surface) Basis = basisSurf; - - // if Basis is Trimmed we take the basis's basis - Handle(Geom_RectangularTrimmedSurface) RTS = - Handle(Geom_RectangularTrimmedSurface)::DownCast(Basis); - if (!RTS.IsNull()) - Basis = RTS->BasisSurface(); - - // BSpline case - Handle(Geom_BSplineSurface) BSplS = - Handle(Geom_BSplineSurface)::DownCast(Basis); - if (!BSplS.IsNull()) { - LocateSides(U,V,USide,VSide,BSplS,3,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - SetD3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - return; - } - - // Extrusion case - Handle(Geom_SurfaceOfLinearExtrusion) SE = - Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(Basis); - if (!SE.IsNull()) { - SE->LocalD3(U,V,USide,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - SetD3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - return; - } - - // Revolution case - Handle(Geom_SurfaceOfRevolution) SR = - Handle(Geom_SurfaceOfRevolution)::DownCast(Basis); - if (!SR.IsNull()) { - SR->LocalD3(U,V,VSide,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - SetD3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - return; - } - - // General cases - basisSurf->D3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - SetD3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - } - else - equivSurf->D3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); -} - -//======================================================================= -//function : LocalDN -//purpose : -//======================================================================= - -gp_Vec Geom_OffsetSurface::LocalDN (const Standard_Real U, const Standard_Real V, - const Standard_Integer USide, const Standard_Integer VSide, - const Standard_Integer Nu, const Standard_Integer Nv) const -{ - if(equivSurf.IsNull()) { - - gp_Vec D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV; - gp_Pnt P; - Handle(Geom_Surface) Basis = basisSurf; - - // if Basis is Trimmed we make the basis`s basis - Handle(Geom_RectangularTrimmedSurface) RTS = - Handle(Geom_RectangularTrimmedSurface)::DownCast(Basis); - if (!RTS.IsNull()) - Basis = RTS -> BasisSurface(); - - //BSpline case - Handle(Geom_BSplineSurface) BSplS = - Handle(Geom_BSplineSurface)::DownCast(Basis); - if(!BSplS.IsNull()) { - LocateSides(U,V,USide,VSide,BSplS,1,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - return SetDN(U,V,Nu,Nv,D1U,D1V); - } - - //Extrusion case - Handle( Geom_SurfaceOfLinearExtrusion) SE = - Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(Basis); - if(!SE.IsNull()) { - SE->LocalD1(U,V,USide,P,D1U,D1V); - return SetDN(U,V,Nu,Nv,D1U,D1V); - } - - //Revolution case - Handle(Geom_SurfaceOfRevolution) SR = - Handle(Geom_SurfaceOfRevolution)::DownCast(Basis); - if(!SR.IsNull()) { - SR->LocalDN(U,V,VSide,Nu,Nv); - return SetDN(U,V,Nu,Nv,D1U,D1V); - } - - //General cases - basisSurf->DN(U,V,Nu,Nv); - return SetDN(U,V,Nu,Nv,D1U,D1V); - } - else - return equivSurf->DN(U,V,Nu,Nv); -} - -//======================================================================= -//function : LocateSides -//purpose : -//======================================================================= - -void Geom_OffsetSurface::LocateSides(const Standard_Real U, const Standard_Real V, - const Standard_Integer USide, const Standard_Integer VSide, - const Handle(Geom_BSplineSurface)& BSplS, - const Standard_Integer NDir, - gp_Pnt& P, - gp_Vec& D1U,gp_Vec& D1V, - gp_Vec& D2U,gp_Vec& D2V,gp_Vec& D2UV, - gp_Vec& D3U,gp_Vec& D3V,gp_Vec& D3UUV,gp_Vec& D3UVV) const -{ - Standard_Boolean UIsKnot=Standard_False, VIsKnot=Standard_False; - Standard_Integer Ideb, Ifin, IVdeb, IVfin; - const Standard_Real ParTol=Precision::PConfusion()/10.; - BSplS->Geom_BSplineSurface::LocateU(U,ParTol,Ideb, Ifin, Standard_False); - BSplS->Geom_BSplineSurface::LocateV(V,ParTol,IVdeb,IVfin,Standard_False); - - if(Ideb == Ifin ) { //knot - - if(USide == 1) {Ifin++; UIsKnot=Standard_True;} - else if(USide == -1) {Ideb--; UIsKnot=Standard_True;} - else {Ideb--; Ifin++;} //USide == 0 - - } - - if(Ideb < BSplS->FirstUKnotIndex()) {Ideb = BSplS->FirstUKnotIndex(); Ifin = Ideb + 1;} - - if(Ifin > BSplS->LastUKnotIndex()) {Ifin = BSplS->LastUKnotIndex(); Ideb = Ifin - 1;} - - if(IVdeb == IVfin ) { //knot - - if(VSide == 1) {IVfin++; VIsKnot=Standard_True;} - else if(VSide == -1) {IVdeb--; VIsKnot=Standard_True;} - else {IVdeb--; IVfin++;} //VSide == 0 - - } - - if(IVdeb < BSplS->FirstVKnotIndex()) {IVdeb = BSplS->FirstVKnotIndex(); IVfin = IVdeb + 1;} - - if(IVfin > BSplS->LastVKnotIndex()) {IVfin = BSplS->LastVKnotIndex(); IVdeb = IVfin - 1;} - - if((UIsKnot)||(VIsKnot)) - switch(NDir) - { - case 0 : BSplS->Geom_BSplineSurface::LocalD0(U,V,Ideb,Ifin,IVdeb,IVfin,P); break; - case 1 : BSplS->Geom_BSplineSurface::LocalD1(U,V,Ideb,Ifin,IVdeb,IVfin,P,D1U,D1V); break; - case 2 : BSplS->Geom_BSplineSurface::LocalD2(U,V,Ideb,Ifin,IVdeb,IVfin,P,D1U,D1V,D2U,D2V,D2UV); break; - case 3 : BSplS->Geom_BSplineSurface::LocalD3(U,V,Ideb,Ifin,IVdeb,IVfin,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); break; - } - else - switch(NDir) - { - case 0 : basisSurf->D0(U,V,P); break; - case 1 : basisSurf->D1(U,V,P,D1U,D1V); break; - case 2 : basisSurf->D2(U,V,P,D1U,D1V,D2U,D2V,D2UV); break; - case 3 : basisSurf->D3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); break; - } -} ////************************************************* //// @@ -1174,22 +568,6 @@ Handle(Geom_Curve) Geom_OffsetSurface::UIso (const Standard_Real UU) const return equivSurf->UIso(UU); } -//======================================================================= -//function : Value -//purpose : -//======================================================================= - -void Geom_OffsetSurface::Value - (const Standard_Real U, const Standard_Real V, - gp_Pnt& P, gp_Pnt& , - gp_Vec& D1Ubasis, gp_Vec& D1Vbasis) const -{ - if (myBasisSurfContinuity == GeomAbs_C0) - Geom_UndefinedValue::Raise(); - - SetD0(U,V,P,D1Ubasis,D1Vbasis); -} - //======================================================================= //function : VIso //purpose : @@ -1382,6 +760,10 @@ void Geom_OffsetSurface::Transform (const gp_Trsf& T) basisSurf->Transform (T); offsetValue *= T.ScaleFactor(); equivSurf.Nullify(); + if (myEvaluator.IsNull()) + myEvaluator = new GeomEvaluator_OffsetSurface(basisSurf, offsetValue, myOscSurf); + else + myEvaluator->SetOffsetValue(offsetValue); } //======================================================================= @@ -1568,7 +950,7 @@ Handle(Geom_Surface) Geom_OffsetSurface::Surface() const Standard_Boolean Geom_OffsetSurface::UOsculatingSurface(const Standard_Real U, const Standard_Real V, Standard_Boolean& t, Handle(Geom_BSplineSurface)& L) const { - return myOscSurf.UOscSurf(U,V,t,L); + return !myOscSurf.IsNull() && myOscSurf->UOscSurf(U,V,t,L); } //======================================================================= @@ -1579,329 +961,5 @@ Standard_Boolean Geom_OffsetSurface::UOsculatingSurface(const Standard_Real U, c Standard_Boolean Geom_OffsetSurface::VOsculatingSurface(const Standard_Real U, const Standard_Real V, Standard_Boolean& t, Handle(Geom_BSplineSurface)& L) const { - return myOscSurf.VOscSurf(U,V,t,L); -} - -//======================================================================= -//function : -//purpose : private -//======================================================================= - -void Geom_OffsetSurface::SetD0(const Standard_Real U, const Standard_Real V, - gp_Pnt& P, - const gp_Vec& D1U, const gp_Vec& D1V) const // First Derivative -{ - const Standard_Real MagTol=0.000000001; - - gp_Vec aNorm = D1U.Crossed(D1V); - if (aNorm.SquareMagnitude() > MagTol * MagTol) - { - // Non singular case. Simple computations. - aNorm.Normalize(); - P.SetXYZ(P.XYZ() + offsetValue * aNorm.XYZ()); - } - else - { - Standard_Boolean AlongU = Standard_False, - AlongV = Standard_False; - Handle(Geom_BSplineSurface) L; - Standard_Boolean IsOpposite=Standard_False; - AlongU = UOsculatingSurface(U,V,IsOpposite,L); - AlongV = VOsculatingSurface(U,V,IsOpposite,L); - gp_Dir Normal; - CSLib_NormalStatus NStatus; - Standard_Integer MaxOrder=3; - TColgp_Array2OfVec DerNUV(0,MaxOrder,0,MaxOrder); - TColgp_Array2OfVec DerSurf(0,MaxOrder+1,0,MaxOrder+1); - Standard_Integer OrderU,OrderV; - Standard_Real Umin,Umax,Vmin,Vmax; - Bounds(Umin,Umax,Vmin,Vmax); - DerSurf.SetValue(1, 0, D1U); - DerSurf.SetValue(0, 1, D1V); - derivatives(MaxOrder,1,U,V,basisSurf,0,0,AlongU,AlongV,L,DerNUV,DerSurf); - - Standard_Real signe = 1.0; - if ((AlongV || AlongU) && IsOpposite) - signe = -1; - - CSLib::Normal(MaxOrder,DerNUV,MagTol,U,V,Umin,Umax,Vmin,Vmax,NStatus,Normal,OrderU,OrderV); - if (NStatus == CSLib_Defined) - P.SetXYZ(P.XYZ() + offsetValue * signe * Normal.XYZ()); - else - { - if (NStatus == CSLib_InfinityOfSolutions && - D1U.SquareMagnitude() + D1V.SquareMagnitude() > MagTol * MagTol) - { - // Use non-null derivative as normal direction in degenerated case. - aNorm = D1U.SquareMagnitude() > MagTol * MagTol ? D1U : D1V; - aNorm.Normalize(); - - P.SetXYZ(P.XYZ() + offsetValue * signe * aNorm.XYZ()); - return; - } - Geom_UndefinedValue::Raise(); - } - } -} - -//======================================================================= -//function : -//purpose : private -//=======================================================================/ - -void Geom_OffsetSurface::SetD1(const Standard_Real U, const Standard_Real V, - gp_Pnt& P, - gp_Vec& D1U, gp_Vec& D1V, // First derivative - const gp_Vec& D2UU, const gp_Vec& D2VV, const gp_Vec& D2UV) const // Second derivative -{ - const Standard_Real MagTol=0.000000001; - - // Check offset side. - Handle(Geom_BSplineSurface) L; - Standard_Boolean AlongU = Standard_False, - AlongV = Standard_False; - Standard_Boolean IsOpposite=Standard_False; - AlongU = UOsculatingSurface(U,V,IsOpposite,L); - AlongV = VOsculatingSurface(U,V,IsOpposite,L); - Standard_Real signe = 1.0; - if ((AlongV || AlongU) && IsOpposite) - signe = -1.0; - - Standard_Integer MaxOrder = 0; - gp_Vec aNorm = D1U.Crossed(D1V); - if (aNorm.SquareMagnitude() > MagTol * MagTol) - { - MaxOrder=0; - - if (!AlongV && !AlongU) - { - // AlongU or AlongV leads to more complex D1 computations, - // try to compute D0 and D1 much simpler. - aNorm.Normalize(); - P.SetXYZ(P.XYZ() + offsetValue * signe * aNorm.XYZ()); - - gp_Vec aN0(aNorm.XYZ()), aN1U, aN1V; - Standard_Real aScale = (D1U^D1V).Dot(aN0); - aN1U.SetX(D2UU.Y() * D1V.Z() + D1U.Y() * D2UV.Z() - - D2UU.Z() * D1V.Y() - D1U.Z() * D2UV.Y()); - aN1U.SetY((D2UU.X() * D1V.Z() + D1U.X() * D2UV.Z() - - D2UU.Z() * D1V.X() - D1U.Z() * D2UV.X() ) * -1.0); - aN1U.SetZ(D2UU.X() * D1V.Y() + D1U.X() * D2UV.Y() - - D2UU.Y() * D1V.X() - D1U.Y() * D2UV.X()); - Standard_Real aScaleU = aN1U.Dot(aN0); - aN1U.Subtract(aScaleU * aN0); - aN1U /= aScale; - - aN1V.SetX(D2UV.Y() * D1V.Z() + D2VV.Z() * D1U.Y() - - D2UV.Z() * D1V.Y() - D2VV.Y() * D1U.Z()); - aN1V.SetY((D2UV.X() * D1V.Z() + D2VV.Z() * D1U.X() - - D2UV.Z() * D1V.X() - D2VV.X() * D1U.Z()) * -1.0); - aN1V.SetZ(D2UV.X() * D1V.Y() + D2VV.Y() * D1U.X() - - D2UV.Y() * D1V.X() - D2VV.X() * D1U.Y()); - Standard_Real aScaleV = aN1V.Dot(aN0); - aN1V.Subtract(aScaleV * aN0); - aN1V /= aScale; - - D1U += offsetValue * signe * aN1U; - D1V += offsetValue * signe * aN1V; - - return; - } - } - else - MaxOrder=3; - - Standard_Integer OrderU,OrderV; - TColgp_Array2OfVec DerNUV(0,MaxOrder+1,0,MaxOrder+1); - TColgp_Array2OfVec DerSurf(0,MaxOrder+2,0,MaxOrder+2); - Standard_Real Umin,Umax,Vmin,Vmax; - Bounds(Umin,Umax,Vmin,Vmax); - DerSurf.SetValue(1, 0, D1U); - DerSurf.SetValue(0, 1, D1V); - DerSurf.SetValue(1, 1, D2UV); - DerSurf.SetValue(2, 0, D2UU); - DerSurf.SetValue(0, 2, D2VV); - derivatives(MaxOrder,2,U,V,basisSurf,1,1,AlongU,AlongV,L,DerNUV,DerSurf); - - gp_Dir Normal; - CSLib_NormalStatus NStatus; - CSLib::Normal(MaxOrder,DerNUV,MagTol,U,V,Umin,Umax,Vmin,Vmax,NStatus,Normal,OrderU,OrderV); - if (NStatus != CSLib_Defined) Geom_UndefinedValue::Raise(); - - P.SetXYZ(P.XYZ() + offsetValue * signe * Normal.XYZ()); - - D1U = DerSurf(1,0) - + offsetValue * signe * CSLib::DNNormal(1,0,DerNUV,OrderU,OrderV); - D1V = DerSurf(0,1) - + offsetValue * signe * CSLib::DNNormal(0,1,DerNUV,OrderU,OrderV); -} - -//======================================================================= -//function : -//purpose : private -//=======================================================================/ - -void Geom_OffsetSurface::SetD2(const Standard_Real U, const Standard_Real V, - gp_Pnt& P, - gp_Vec& D1U, gp_Vec& D1V, - gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, - const gp_Vec& d3u, const gp_Vec& d3v, - const gp_Vec& d3uuv, const gp_Vec& d3uvv) const -{ - const Standard_Real MagTol=0.000000001; - - gp_Dir Normal; - CSLib_NormalStatus NStatus; - CSLib::Normal (D1U, D1V, MagTol, NStatus, Normal); - - const Standard_Integer MaxOrder = (NStatus == CSLib_Defined)? 0 : 3; - Standard_Integer OrderU,OrderV; - TColgp_Array2OfVec DerNUV(0,MaxOrder+2,0,MaxOrder+2); - TColgp_Array2OfVec DerSurf(0,MaxOrder+3,0,MaxOrder+3); - Standard_Real Umin,Umax,Vmin,Vmax; - Bounds(Umin,Umax,Vmin,Vmax); - DerSurf.SetValue(1, 0, D1U); - DerSurf.SetValue(0, 1, D1V); - DerSurf.SetValue(1, 1, D2UV); - DerSurf.SetValue(2, 0, D2U); - DerSurf.SetValue(0, 2, D2V); - DerSurf.SetValue(3, 0, d3u); - DerSurf.SetValue(2, 1, d3uuv); - DerSurf.SetValue(1, 2, d3uvv); - DerSurf.SetValue(0, 3, d3v); - //********************* - - Handle(Geom_BSplineSurface) L; - Standard_Boolean IsOpposite=Standard_False; - const Standard_Boolean AlongU = UOsculatingSurface(U,V,IsOpposite,L); - const Standard_Boolean AlongV = VOsculatingSurface(U,V,IsOpposite,L); - const Standard_Real signe = ((AlongV || AlongU) && IsOpposite)? -1. : 1.; - derivatives(MaxOrder,3,U,V,basisSurf,2,2,AlongU,AlongV,L,DerNUV,DerSurf); - - CSLib::Normal(MaxOrder,DerNUV,MagTol,U,V,Umin,Umax,Vmin,Vmax,NStatus,Normal,OrderU,OrderV); - if (NStatus != CSLib_Defined) Geom_UndefinedValue::Raise(); - - P.SetXYZ(P.XYZ() + offsetValue * signe * Normal.XYZ()); - - D1U = DerSurf(1,0) - + offsetValue * signe * CSLib::DNNormal(1,0,DerNUV,OrderU,OrderV); - D1V = DerSurf(0,1) - + offsetValue * signe * CSLib::DNNormal(0,1,DerNUV,OrderU,OrderV); - - D2U = basisSurf->DN(U,V,2,0) - + signe * offsetValue * CSLib::DNNormal(2,0,DerNUV,OrderU,OrderV); - D2V = basisSurf->DN(U,V,0,2) - + signe * offsetValue * CSLib::DNNormal(0,2,DerNUV,OrderU,OrderV); - D2UV = basisSurf->DN(U,V,1,1) - + signe * offsetValue * CSLib::DNNormal(1,1,DerNUV,OrderU,OrderV); -} - -//======================================================================= -//function : -//purpose : private -//=======================================================================/ - -void Geom_OffsetSurface::SetD3(const Standard_Real U, const Standard_Real V, - gp_Pnt& P, - gp_Vec& D1U, gp_Vec& D1V, - gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, - gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const -{ - const Standard_Real MagTol=0.000000001; - - gp_Dir Normal; - CSLib_NormalStatus NStatus; - CSLib::Normal (D1U, D1V, MagTol, NStatus, Normal); - const Standard_Integer MaxOrder = (NStatus == CSLib_Defined)? 0 : 3; - Standard_Integer OrderU,OrderV; - TColgp_Array2OfVec DerNUV(0,MaxOrder+3,0,MaxOrder+3); - TColgp_Array2OfVec DerSurf(0,MaxOrder+4,0,MaxOrder+4); - Standard_Real Umin,Umax,Vmin,Vmax; - Bounds(Umin,Umax,Vmin,Vmax); - - DerSurf.SetValue(1, 0, D1U); - DerSurf.SetValue(0, 1, D1V); - DerSurf.SetValue(1, 1, D2UV); - DerSurf.SetValue(2, 0, D2U); - DerSurf.SetValue(0, 2, D2V); - DerSurf.SetValue(3, 0, D3U); - DerSurf.SetValue(2, 1, D3UUV); - DerSurf.SetValue(1, 2, D3UVV); - DerSurf.SetValue(0, 3, D3V); - - - //********************* - Handle(Geom_BSplineSurface) L; - Standard_Boolean IsOpposite=Standard_False; - const Standard_Boolean AlongU = UOsculatingSurface(U,V,IsOpposite,L); - const Standard_Boolean AlongV = VOsculatingSurface(U,V,IsOpposite,L); - const Standard_Real signe = ((AlongV || AlongU) && IsOpposite)? -1. : 1.; - derivatives(MaxOrder,3,U,V,basisSurf,3,3,AlongU,AlongV,L,DerNUV,DerSurf); - - CSLib::Normal(MaxOrder,DerNUV,MagTol,U,V,Umin,Umax,Vmin,Vmax,NStatus,Normal,OrderU,OrderV); - if (NStatus != CSLib_Defined) Geom_UndefinedValue::Raise(); - - P.SetXYZ(P.XYZ() + offsetValue * signe * Normal.XYZ()); - - D1U = DerSurf(1,0) - + offsetValue * signe * CSLib::DNNormal(1,0,DerNUV,OrderU,OrderV); - D1V = DerSurf(0,1) - + offsetValue * signe * CSLib::DNNormal(0,1,DerNUV,OrderU,OrderV); - - D2U = basisSurf->DN(U,V,2,0) - + signe * offsetValue * CSLib::DNNormal(2,0,DerNUV,OrderU,OrderV); - D2V = basisSurf->DN(U,V,0,2) - + signe * offsetValue * CSLib::DNNormal(0,2,DerNUV,OrderU,OrderV); - D2UV = basisSurf->DN(U,V,1,1) - + signe * offsetValue * CSLib::DNNormal(1,1,DerNUV,OrderU,OrderV); - D3U = basisSurf->DN(U,V,3,0) - + signe * offsetValue * CSLib::DNNormal(3,0,DerNUV,OrderU,OrderV); - D3V = basisSurf->DN(U,V,0,3) - + signe * offsetValue * CSLib::DNNormal(0,3,DerNUV,OrderU,OrderV); - D3UUV = basisSurf->DN(U,V,2,1) - + signe * offsetValue * CSLib::DNNormal(2,1,DerNUV,OrderU,OrderV); - D3UVV = basisSurf->DN(U,V,1,2) - + signe * offsetValue * CSLib::DNNormal(1,2,DerNUV,OrderU,OrderV); -} - -//======================================================================= -//function : SetDN -//purpose : -//======================================================================= - -gp_Vec Geom_OffsetSurface::SetDN ( const Standard_Real U, const Standard_Real V, - const Standard_Integer Nu, const Standard_Integer Nv, - const gp_Vec& D1U, const gp_Vec& D1V) const -{ - const Standard_Real MagTol=0.000000001; - - gp_Dir Normal; - CSLib_NormalStatus NStatus; - CSLib::Normal (D1U, D1V, MagTol, NStatus, Normal); - const Standard_Integer MaxOrder = (NStatus == CSLib_Defined)? 0 : 3; - Standard_Integer OrderU,OrderV; - TColgp_Array2OfVec DerNUV(0,MaxOrder+Nu,0,MaxOrder+Nu); - TColgp_Array2OfVec DerSurf(0,MaxOrder+Nu+1,0,MaxOrder+Nv+1); - Standard_Real Umin,Umax,Vmin,Vmax; - Bounds(Umin,Umax,Vmin,Vmax); - - DerSurf.SetValue(1, 0, D1U); - DerSurf.SetValue(0, 1, D1V); - - //********************* - Handle(Geom_BSplineSurface) L; - // Is there any osculatingsurface along U or V; - Standard_Boolean IsOpposite=Standard_False; - const Standard_Boolean AlongU = UOsculatingSurface(U,V,IsOpposite,L); - const Standard_Boolean AlongV = VOsculatingSurface(U,V,IsOpposite,L); - const Standard_Real signe = ((AlongV || AlongU) && IsOpposite)? -1. : 1.; - derivatives(MaxOrder,1,U,V,basisSurf,Nu,Nv,AlongU,AlongV,L,DerNUV,DerSurf); - - CSLib::Normal(MaxOrder,DerNUV,MagTol,U,V,Umin,Umax,Vmin,Vmax,NStatus,Normal,OrderU,OrderV); - if (NStatus != CSLib_Defined) Geom_UndefinedValue::Raise(); - - gp_Vec D = basisSurf->DN(U,V,Nu,Nv) - + signe * offsetValue * CSLib::DNNormal(Nu,Nv,DerNUV,OrderU,OrderV); - - return D; + return !myOscSurf.IsNull() && myOscSurf->VOscSurf(U, V, t, L); } diff --git a/src/Geom/Geom_OffsetSurface.hxx b/src/Geom/Geom_OffsetSurface.hxx index d224e954a6..bcbc6747db 100644 --- a/src/Geom/Geom_OffsetSurface.hxx +++ b/src/Geom/Geom_OffsetSurface.hxx @@ -26,6 +26,7 @@ #include #include #include +#include class Geom_Surface; class Standard_ConstructionError; class Standard_RangeError; @@ -120,6 +121,10 @@ public: //! Note: The basis surface can be an offset surface. inline const Handle(Geom_Surface) & BasisSurface() const { return basisSurf; } + + //! Returns osculating surface if base surface is B-spline or Bezier + inline const Handle(Geom_OsculatingSurface)& OsculatingSurface() const + { return myOscSurf; } //! Changes the orientation of this offset surface in the u //! parametric direction. The bounds of the surface @@ -289,44 +294,6 @@ public: //! raised if it is not possible to compute a unique offset //! direction. Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv) const; - - - //! P (U, V) = Pbasis + Offset * Ndir where - //! Ndir = D1Ubasis ^ D1Vbasis / ||D1Ubasis ^ D1Vbasis|| is - //! the normal direction of the surface. - //! If Ndir is undefined this method computes an approched normal - //! direction using the following limited development : - //! Ndir = N0 + DNdir/DU + DNdir/DV + Eps with Eps->0 which - //! requires to compute the second derivatives on the basis surface. - //! If the normal direction cannot be approximate for this order - //! of derivation the exception UndefinedValue is raised. - //! - //! Raised if the continuity of the basis surface is not C1. - //! Raised if the order of derivation required to compute the normal - //! direction is greater than the second order. - Standard_EXPORT void Value (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Pnt& Pbasis, gp_Vec& D1Ubasis, gp_Vec& D1Vbasis) const; - - - //! Raised if the continuity of the basis surface is not C2. - Standard_EXPORT void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Pnt& Pbasis, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D1Ubasis, gp_Vec& D1Vbasis, gp_Vec& D2Ubasis, gp_Vec& D2Vbasis, gp_Vec& D2UVbasis) const; - - - //! Raised if the continuity of the basis surface is not C3. - //! The following private methods - //! includes common part of local and global methods - //! of derivative evaluations. - Standard_EXPORT void D2 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Pnt& Pbasis, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D1Ubasis, gp_Vec& D1Vbasis, gp_Vec& D2Ubasis, gp_Vec& D2Vbasis, gp_Vec& D2UVbasis, gp_Vec& D3Ubasis, gp_Vec& D3Vbasis, gp_Vec& D3UUVbasis, gp_Vec& D3UVVbasis) const; - - Standard_EXPORT void LocalD0 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer VSide, gp_Pnt& P) const; - - Standard_EXPORT void LocalD1 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer VSide, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const; - - Standard_EXPORT void LocalD2 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer VSide, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const; - - Standard_EXPORT void LocalD3 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer VSide, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const; - - Standard_EXPORT gp_Vec LocalDN (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer VSide, const Standard_Integer Nu, const Standard_Integer Nv) const; - //! Applies the transformation T to this offset surface. //! Note: the basis surface is also modified. @@ -394,36 +361,12 @@ public: private: - - Standard_EXPORT void SetD0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, const gp_Vec& D1U, const gp_Vec& D1V) const; - - Standard_EXPORT void SetD1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, const gp_Vec& d2u, const gp_Vec& d2v, const gp_Vec& d2uv) const; - - Standard_EXPORT void SetD2 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, const gp_Vec& d3u, const gp_Vec& d3v, const gp_Vec& d3uuv, const gp_Vec& d3uvv) const; - - Standard_EXPORT void SetD3 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const; - - //! The following functions evaluates the local - //! derivatives on surface. Useful to manage discontinuities - //! on the surface. - //! if Side = 1 -> P = S( U+,V ) - //! if Side = -1 -> P = S( U-,V ) - //! else P is betveen discontinuities - //! can be evaluated using methods of - //! global evaluations P = S( U ,V ) - Standard_EXPORT gp_Vec SetDN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv, const gp_Vec& D1U, const gp_Vec& D1V) const; - - //! This method locates U,V parameters on basis BSpline surface - //! and calls LocalDi or Di methods corresponding an order - //! of derivative and position - //! of UV-point relatively the surface discontinuities. - Standard_EXPORT void LocateSides (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer VSide, const Handle(Geom_BSplineSurface)& BSplS, const Standard_Integer NDir, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const; - Handle(Geom_Surface) basisSurf; Handle(Geom_Surface) equivSurf; Standard_Real offsetValue; - Geom_OsculatingSurface myOscSurf; + Handle(Geom_OsculatingSurface) myOscSurf; GeomAbs_Shape myBasisSurfContinuity; + Handle(GeomEvaluator_OffsetSurface) myEvaluator; }; #endif // _Geom_OffsetSurface_HeaderFile diff --git a/src/Geom/Geom_OsculatingSurface.cxx b/src/Geom/Geom_OsculatingSurface.cxx index 9e5f2c191e..05c95f1b3c 100644 --- a/src/Geom/Geom_OsculatingSurface.cxx +++ b/src/Geom/Geom_OsculatingSurface.cxx @@ -37,6 +37,7 @@ Geom_OsculatingSurface::Geom_OsculatingSurface() : myAlong(1,4) { + myAlong.Init(Standard_False); } //======================================================================= //function : Geom_OffsetOsculatingSurface diff --git a/src/Geom/Geom_OsculatingSurface.hxx b/src/Geom/Geom_OsculatingSurface.hxx index da670e4faf..82c58b27f6 100644 --- a/src/Geom/Geom_OsculatingSurface.hxx +++ b/src/Geom/Geom_OsculatingSurface.hxx @@ -33,8 +33,10 @@ class Geom_Surface; class Geom_BSplineSurface; +class Geom_OsculatingSurface; +DEFINE_STANDARD_HANDLE(Geom_OsculatingSurface, MMgt_TShared) -class Geom_OsculatingSurface +class Geom_OsculatingSurface : public MMgt_TShared { public: @@ -64,7 +66,7 @@ public: Standard_EXPORT Standard_Boolean VOscSurf (const Standard_Real U, const Standard_Real V, Standard_Boolean& t, Handle(Geom_BSplineSurface)& L) const; - + DEFINE_STANDARD_RTTI(Geom_OsculatingSurface, MMgt_TShared) protected: diff --git a/src/Geom/Geom_SurfaceOfLinearExtrusion.cxx b/src/Geom/Geom_SurfaceOfLinearExtrusion.cxx index fee1510e82..e55c2f5a97 100644 --- a/src/Geom/Geom_SurfaceOfLinearExtrusion.cxx +++ b/src/Geom/Geom_SurfaceOfLinearExtrusion.cxx @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -60,62 +61,6 @@ typedef gp_Trsf Trsf; typedef gp_Vec Vec; typedef gp_XYZ XYZ; -static void LocateSide(const Standard_Real U, - const Standard_Integer Side, - const Handle(Geom_BSplineCurve)& BSplC, - const Standard_Integer NDir, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D2U, - gp_Vec& D3U) -{ - Standard_Integer Ideb, Ifin; - Standard_Real ParTol=Precision::PConfusion()/2; - BSplC->Geom_BSplineCurve::LocateU(U,ParTol,Ideb,Ifin,Standard_False); - if(Side == 1) - { - if(Ideb<1) Ideb=1; - if ((Ideb>=Ifin)) Ifin = Ideb+1; - }else - if(Side ==-1) - { - if(Ifin > BSplC -> NbKnots()) Ifin=BSplC->NbKnots(); - if ((Ideb>=Ifin)) Ideb = Ifin-1; - } - - switch(NDir) - { - case 0 : BSplC->Geom_BSplineCurve::LocalD0(U,Ideb,Ifin,P); break; - case 1 : BSplC->Geom_BSplineCurve::LocalD1(U,Ideb,Ifin,P,D1U); break; - case 2 : BSplC->Geom_BSplineCurve::LocalD2(U,Ideb,Ifin,P,D1U,D2U); break; - case 3 : BSplC->Geom_BSplineCurve::LocalD3(U,Ideb,Ifin,P,D1U,D2U,D3U);break; - } - -} - -static gp_Vec LocateSideN(const Standard_Real U, - const Standard_Integer Side, - const Handle(Geom_BSplineCurve)& BSplC, - const Standard_Integer Nu, -// const Standard_Integer Nv ) - const Standard_Integer ) -{ - Standard_Integer Ideb, Ifin; - Standard_Real ParTol=Precision::PConfusion()/2; - BSplC->Geom_BSplineCurve::LocateU(U,ParTol,Ideb,Ifin,Standard_False); - if(Side == 1) - { - if(Ideb<1) Ideb=1; - if ((Ideb>=Ifin)) Ifin = Ideb+1; - }else - if(Side ==-1) - { - if(Ifin > BSplC -> NbKnots()) Ifin=BSplC->NbKnots(); - if ((Ideb>=Ifin)) Ideb = Ifin-1; - } - return BSplC->Geom_BSplineCurve::LocalDN(U,Ideb,Ifin,Nu); -} - //======================================================================= @@ -144,6 +89,7 @@ Geom_SurfaceOfLinearExtrusion::Geom_SurfaceOfLinearExtrusion basisCurve = Handle(Geom_Curve)::DownCast(C->Copy()); // Copy 10-03-93 direction = V; smooth = C->Continuity(); + myEvaluator = new GeomEvaluator_SurfaceOfExtrusion(basisCurve, direction); } @@ -176,7 +122,8 @@ Standard_Real Geom_SurfaceOfLinearExtrusion::UReversedParameter(const Standard_R void Geom_SurfaceOfLinearExtrusion::VReverse () { - direction.Reverse(); + direction.Reverse(); + myEvaluator->SetDirection(direction); } @@ -196,12 +143,11 @@ Standard_Real Geom_SurfaceOfLinearExtrusion::VReversedParameter( const Standard_ //purpose : //======================================================================= -void Geom_SurfaceOfLinearExtrusion::SetDirection (const Dir& V) { - - Handle(Geom_Curve) C; - direction = V; - C = basisCurve; - } +void Geom_SurfaceOfLinearExtrusion::SetDirection (const Dir& V) +{ + direction = V; + myEvaluator->SetDirection(direction); +} //======================================================================= @@ -213,6 +159,7 @@ void Geom_SurfaceOfLinearExtrusion::SetBasisCurve (const Handle(Geom_Curve)& C) smooth = C->Continuity(); basisCurve = Handle(Geom_Curve)::DownCast(C->Copy()); // Copy 10-03-93 + myEvaluator = new GeomEvaluator_SurfaceOfExtrusion(basisCurve, direction); } @@ -236,13 +183,11 @@ void Geom_SurfaceOfLinearExtrusion::Bounds ( Standard_Real& U1, //purpose : //======================================================================= -void Geom_SurfaceOfLinearExtrusion::D0 (const Standard_Real U, const Standard_Real V, - Pnt& P ) const { - - XYZ Pxyz = direction.XYZ(); - Pxyz.Multiply (V); - Pxyz.Add (basisCurve->Value (U).XYZ()); - P.SetXYZ(Pxyz); +void Geom_SurfaceOfLinearExtrusion::D0 (const Standard_Real U, + const Standard_Real V, + Pnt& P) const +{ + myEvaluator->D0(U, V, P); } @@ -251,17 +196,12 @@ void Geom_SurfaceOfLinearExtrusion::D0 (const Standard_Real U, const Standard_Re //purpose : //======================================================================= -void Geom_SurfaceOfLinearExtrusion::D1 ( const Standard_Real U , - const Standard_Real V , - Pnt& P , - Vec& D1U, Vec& D1V) const { - - basisCurve->D1 (U, P, D1U); - D1V = direction; - XYZ Pxyz = direction.XYZ(); - Pxyz.Multiply (V); - Pxyz.Add (P.XYZ()); - P.SetXYZ (Pxyz); +void Geom_SurfaceOfLinearExtrusion::D1 (const Standard_Real U, + const Standard_Real V, + Pnt& P, + Vec& D1U, Vec& D1V) const +{ + myEvaluator->D1(U, V, P, D1U, D1V); } @@ -270,21 +210,13 @@ void Geom_SurfaceOfLinearExtrusion::D1 ( const Standard_Real U , //purpose : //======================================================================= -void Geom_SurfaceOfLinearExtrusion::D2 ( const Standard_Real U , - const Standard_Real V , - Pnt& P , - Vec& D1U, Vec& D1V, - Vec& D2U, Vec& D2V, Vec& D2UV) -const { - - basisCurve->D2 (U, P, D1U, D2U); - D1V = direction; - D2V.SetCoord (0.0, 0.0, 0.0); - D2UV.SetCoord (0.0, 0.0, 0.0); - XYZ Pxyz = direction.XYZ(); - Pxyz.Multiply (V); - Pxyz.Add (P.XYZ()); - P.SetXYZ (Pxyz); +void Geom_SurfaceOfLinearExtrusion::D2 (const Standard_Real U, + const Standard_Real V, + Pnt& P, + Vec& D1U, Vec& D1V, + Vec& D2U, Vec& D2V, Vec& D2UV) const +{ + myEvaluator->D2(U, V, P, D1U, D1V, D2U, D2V, D2UV); } @@ -293,192 +225,30 @@ const { //purpose : //======================================================================= -void Geom_SurfaceOfLinearExtrusion::D3 - ( const Standard_Real U, const Standard_Real V, - Pnt& P, - Vec& D1U, Vec& D1V, - Vec& D2U, Vec& D2V, Vec& D2UV, - Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV ) const { - - - basisCurve->D3 (U, P, D1U, D2U, D3U); - D1V = direction; - D2V.SetCoord (0.0, 0.0, 0.0); - D3V.SetCoord (0.0, 0.0, 0.0); - D3UUV.SetCoord (0.0, 0.0, 0.0); - D3UVV.SetCoord (0.0, 0.0, 0.0); - D2UV.SetCoord (0.0, 0.0, 0.0); - XYZ Pxyz = direction.XYZ(); - Pxyz.Multiply (V); - Pxyz.Add (P.XYZ()); - P.SetXYZ (Pxyz); +void Geom_SurfaceOfLinearExtrusion::D3 (const Standard_Real U, + const Standard_Real V, + Pnt& P, + Vec& D1U, Vec& D1V, + Vec& D2U, Vec& D2V, Vec& D2UV, + Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV) const +{ + myEvaluator->D3(U, V, P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); } + + //======================================================================= //function : DN //purpose : //======================================================================= -Vec Geom_SurfaceOfLinearExtrusion::DN - ( const Standard_Real U, const Standard_Real , - const Standard_Integer Nu, const Standard_Integer Nv) const { - - Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " "); - if (Nu == 0 && Nv == 1) return Vec (direction); - else if (Nv == 0) return basisCurve->DN (U, Nu); - else return Vec (0.0, 0.0, 0.0); -} - - -//======================================================================= -//function : LocalD0 -//purpose : -//======================================================================= - -void Geom_SurfaceOfLinearExtrusion::LocalD0 (const Standard_Real U, - const Standard_Real V, - const Standard_Integer USide, - gp_Pnt& P ) const -{ - if((USide != 0) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) - { - Vec D1U,D2U,D3U; - Handle( Geom_BSplineCurve) BSplC; - BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve); - - LocateSide(U,USide,BSplC,0,P,D1U,D2U,D3U); - XYZ Pxyz = direction.XYZ(); - Pxyz.Multiply (V); - Pxyz.Add (P.XYZ()); - P.SetXYZ (Pxyz); - } - else D0(U,V,P); -} - -//======================================================================= -//function : LocalD1 -//purpose : -//======================================================================= - -void Geom_SurfaceOfLinearExtrusion::LocalD1 (const Standard_Real U, - const Standard_Real V, - const Standard_Integer USide, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V) const -{ - if((USide != 0) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) - { - Vec D2U,D3U; - Handle( Geom_BSplineCurve) BSplC; - BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve); - - LocateSide(U,USide,BSplC,1,P,D1U,D2U,D3U); - D1V = direction; - XYZ Pxyz = direction.XYZ(); - Pxyz.Multiply (V); - Pxyz.Add (P.XYZ()); - P.SetXYZ (Pxyz); - } - else D1(U,V,P,D1U,D1V); -} - -//======================================================================= -//function : LocalD2 -//purpose : -//======================================================================= - -void Geom_SurfaceOfLinearExtrusion::LocalD2 (const Standard_Real U, - const Standard_Real V, - const Standard_Integer USide, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V, - gp_Vec& D2U, - gp_Vec& D2V, - gp_Vec& D2UV) const +Vec Geom_SurfaceOfLinearExtrusion::DN (const Standard_Real U, + const Standard_Real V, + const Standard_Integer Nu, + const Standard_Integer Nv) const { - if((USide != 0) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) - { - Vec D3U; - Handle( Geom_BSplineCurve) BSplC; - BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve); - - LocateSide(U,USide,BSplC,2,P,D1U,D2U,D3U); - D1V = direction; - D2V.SetCoord (0.0, 0.0, 0.0); - D2UV.SetCoord (0.0, 0.0, 0.0); - XYZ Pxyz = direction.XYZ(); - Pxyz.Multiply (V); - Pxyz.Add (P.XYZ()); - P.SetXYZ (Pxyz); - } - else D2(U,V,P,D1U,D1V,D2U,D2V,D2UV); + return myEvaluator->DN(U, V, Nu, Nv); } -//======================================================================= -//function : LocalD3 -//purpose : -//======================================================================= - -void Geom_SurfaceOfLinearExtrusion::LocalD3 (const Standard_Real U, - const Standard_Real V, - const Standard_Integer USide, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V, - gp_Vec& D2U, - gp_Vec& D2V, - gp_Vec& D2UV, - gp_Vec& D3U, - gp_Vec& D3V, - gp_Vec& D3UUV, - gp_Vec& D3UVV) const -{ - if((USide != 0) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) - { - Handle( Geom_BSplineCurve) BSplC; - BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve); - - LocateSide(U,USide,BSplC,3,P,D1U,D2U,D3U); - D1V = direction; - D2V.SetCoord (0.0, 0.0, 0.0); - D3V.SetCoord (0.0, 0.0, 0.0); - D3UUV.SetCoord (0.0, 0.0, 0.0); - D3UVV.SetCoord (0.0, 0.0, 0.0); - D2UV.SetCoord (0.0, 0.0, 0.0); - XYZ Pxyz = direction.XYZ(); - Pxyz.Multiply (V); - Pxyz.Add (P.XYZ()); - P.SetXYZ (Pxyz); - } - else D3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - -} - -//======================================================================= -//function : LocalDN -//purpose : -//======================================================================= - -gp_Vec Geom_SurfaceOfLinearExtrusion::LocalDN (const Standard_Real U, - const Standard_Real V, - const Standard_Integer USide, - const Standard_Integer Nu, - const Standard_Integer Nv) const -{ - Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv <0, " "); - if (Nu == 0 && Nv == 1) return Vec (direction); - else if (Nv == 0) { - if((USide != 0) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) { - Handle( Geom_BSplineCurve) BSplC; - BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve); - return LocateSideN(U,USide,BSplC,Nu,Nv); - } - else - return DN(U,V,Nu,Nv); - } - return Vec (0.0, 0.0, 0.0); -} //======================================================================= //function : UIso @@ -540,6 +310,7 @@ void Geom_SurfaceOfLinearExtrusion::Transform (const Trsf& T) { direction.Transform (T); basisCurve->Transform (T); + myEvaluator->SetDirection(direction); } diff --git a/src/Geom/Geom_SurfaceOfLinearExtrusion.hxx b/src/Geom/Geom_SurfaceOfLinearExtrusion.hxx index dd9a9bdf6f..5b80e792e9 100644 --- a/src/Geom/Geom_SurfaceOfLinearExtrusion.hxx +++ b/src/Geom/Geom_SurfaceOfLinearExtrusion.hxx @@ -21,6 +21,7 @@ #include #include +#include #include #include #include @@ -204,25 +205,7 @@ public: //! direction and CNv in the v direction. //! Raises RangeError if Nu + Nv < 1 or Nu < 0 or Nv < 0. Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv) const; - - //! The following functions evaluates the local - //! derivatives on surface. Useful to manage discontinuities - //! on the surface. - //! if Side = 1 -> P = S( U+,V ) - //! if Side = -1 -> P = S( U-,V ) - //! else P is betveen discontinuities - //! can be evaluated using methods of - //! global evaluations P = S( U ,V ) - Standard_EXPORT void LocalD0 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, gp_Pnt& P) const; - - Standard_EXPORT void LocalD1 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const; - - Standard_EXPORT void LocalD2 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const; - - Standard_EXPORT void LocalD3 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const; - - Standard_EXPORT gp_Vec LocalDN (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer Nu, const Standard_Integer Nv) const; - + //! Applies the transformation T to this surface of linear extrusion. Standard_EXPORT void Transform (const gp_Trsf& T); @@ -277,7 +260,7 @@ protected: private: - + Handle(GeomEvaluator_SurfaceOfExtrusion) myEvaluator; diff --git a/src/Geom/Geom_SurfaceOfRevolution.cxx b/src/Geom/Geom_SurfaceOfRevolution.cxx index c393920a12..77585b71bb 100644 --- a/src/Geom/Geom_SurfaceOfRevolution.cxx +++ b/src/Geom/Geom_SurfaceOfRevolution.cxx @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include @@ -59,70 +60,6 @@ typedef gp_Trsf Trsf; typedef gp_Vec Vec; typedef gp_XYZ XYZ; -//======================================================================= -//function : LocateSide -//purpose : This method locates U parameter on basis BSpline curve -// and calls LocalDi methods corresponding an order of -// derivative and position of the surface side contained -// the point relatively the curve knots. -//======================================================================= -static void LocateSide(const Standard_Real U, - const Standard_Integer Side, - const Handle(Geom_BSplineCurve)& BSplC, - const Standard_Integer NDir, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D2U, - gp_Vec& D3U) -{ - Standard_Integer Ideb, Ifin; - Standard_Real ParTol=Precision::PConfusion()/2; - BSplC->Geom_BSplineCurve::LocateU(U,ParTol,Ideb,Ifin,Standard_False); - if(Side == 1) - { - if(Ideb<1) Ideb=1; - if ((Ideb>=Ifin)) Ifin = Ideb+1; - }else - if(Side ==-1) - { - if(Ifin > BSplC -> NbKnots()) Ifin=BSplC->NbKnots(); - if ((Ideb>=Ifin)) Ideb = Ifin-1; - } - - switch(NDir) { - case 0 : BSplC->Geom_BSplineCurve::LocalD0(U,Ideb,Ifin,P); break; - case 1 : BSplC->Geom_BSplineCurve::LocalD1(U,Ideb,Ifin,P,D1U); break; - case 2 : BSplC->Geom_BSplineCurve::LocalD2(U,Ideb,Ifin,P,D1U,D2U); break; - case 3 : BSplC->Geom_BSplineCurve::LocalD3(U,Ideb,Ifin,P,D1U,D2U,D3U); break; - } -} - -//======================================================================= -//function : LocateSideN -//purpose : This method locates U parameter on basis BSpline curve -// and calls LocalDN method corresponding position of surface side -// contained the point relatively the curve knots. -//======================================================================= -static gp_Vec LocateSideN(const Standard_Real V, - const Standard_Integer Side, - const Handle(Geom_BSplineCurve)& BSplC, - const Standard_Integer Nv ) -{ - Standard_Integer Ideb, Ifin; - Standard_Real ParTol=Precision::PConfusion()/2; - BSplC->Geom_BSplineCurve::LocateU(V,ParTol,Ideb,Ifin,Standard_False); - if(Side == 1) - { - if(Ideb<1) Ideb=1; - if ((Ideb>=Ifin)) Ifin = Ideb+1; - }else - if(Side ==-1) - { - if(Ifin > BSplC -> NbKnots()) Ifin=BSplC->NbKnots(); - if ((Ideb>=Ifin)) Ideb = Ifin-1; - } - return BSplC->Geom_BSplineCurve::LocalDN(V,Ideb,Ifin,Nv); -} @@ -147,9 +84,8 @@ Geom_SurfaceOfRevolution::Geom_SurfaceOfRevolution (const Handle(Geom_Curve)& C , const Ax1& A1 ) : loc (A1.Location()) { - basisCurve = Handle(Geom_Curve)::DownCast(C->Copy()); direction = A1.Direction(); - smooth = C->Continuity(); + SetBasisCurve(C); } @@ -160,7 +96,8 @@ Geom_SurfaceOfRevolution::Geom_SurfaceOfRevolution void Geom_SurfaceOfRevolution::UReverse () { - direction.Reverse(); + direction.Reverse(); + myEvaluator->SetDirection(direction); } @@ -290,6 +227,7 @@ void Geom_SurfaceOfRevolution::SetAxis (const Ax1& A1) { direction = A1.Direction(); loc = A1.Location(); + myEvaluator->SetAxis(A1); } @@ -301,6 +239,7 @@ void Geom_SurfaceOfRevolution::SetAxis (const Ax1& A1) { void Geom_SurfaceOfRevolution::SetDirection (const Dir& V) { direction = V; + myEvaluator->SetDirection(direction); } @@ -313,6 +252,7 @@ void Geom_SurfaceOfRevolution::SetBasisCurve (const Handle(Geom_Curve)& C) { basisCurve = Handle(Geom_Curve)::DownCast(C->Copy()); smooth = C->Continuity(); + myEvaluator = new GeomEvaluator_SurfaceOfRevolution(basisCurve, direction, loc); } @@ -324,6 +264,7 @@ void Geom_SurfaceOfRevolution::SetBasisCurve (const Handle(Geom_Curve)& C) { void Geom_SurfaceOfRevolution::SetLocation (const Pnt& P) { loc = P; + myEvaluator->SetLocation(loc); } @@ -349,30 +290,10 @@ void Geom_SurfaceOfRevolution::Bounds ( Standard_Real& U1, //purpose : //======================================================================= -void Geom_SurfaceOfRevolution::D0 - (const Standard_Real U, const Standard_Real V, Pnt& P) const { - - // C origine sur l'axe de revolution - // Vdir vecteur unitaire definissant la direction de l'axe de revolution - // Q(v) point de parametre V sur la courbe de revolution - // OM (u,v) = OC + CQ * Cos(U) + (CQ.Vdir)(1-Cos(U)) * Vdir + - // (Vdir^CQ)* Sin(U) - - - Pnt Pc = basisCurve->Value (V); //Q(v) - XYZ Q = Pc.XYZ(); //Q - XYZ C = loc.XYZ(); //C - Q.Subtract(C); //CQ - XYZ Vdir = direction.XYZ(); //Vdir - XYZ VcrossCQ = Vdir.Crossed (Q); //Vdir^CQ - VcrossCQ.Multiply (Sin(U)); //(Vdir^CQ)*Sin(U) - XYZ VdotCQ = - Vdir.Multiplied ((Vdir.Dot(Q))*(1.0 - Cos(U)));//(CQ.Vdir)(1-Cos(U))Vdir - VdotCQ.Add (VcrossCQ); //addition des composantes - Q.Multiply (Cos(U)); - Q.Add (VdotCQ); - Q.Add (C); - P.SetXYZ(Q); +void Geom_SurfaceOfRevolution::D0 +(const Standard_Real U, const Standard_Real V, Pnt& P) const +{ + myEvaluator->D0(U, V, P); } @@ -384,56 +305,10 @@ void Geom_SurfaceOfRevolution::D0 void Geom_SurfaceOfRevolution::D1 (const Standard_Real U, const Standard_Real V, Pnt& P, - Vec& D1U, Vec& D1V ) const { - - // C origine sur l'axe de revolution - // Vdir vecteur unitaire definissant la direction de l'axe de revolution - // Q(v) point de parametre V sur la courbe de revolution - // Q'(v) = DQ/DV - // OM (u,v) = OC + CQ * Cos(U) + (CQ.Vdir)(1-Cos(U)) * Vdir + - // (Vdir^CQ) * Sin(U) - // D1U_M(u,v) = - CQ * Sin(U) + (CQ.Vdir)(Sin(U)) * Vdir + - // (Vdir^CQ) * Cos(U) - // D1V_M(u,v) = Q' * Cos(U) + (Q'.Vdir)(1-Cos(U)) * Vdir + - // (Vdir^Q') * Sin(U) - - Pnt Pc; - Vec V1; - basisCurve->D1 (V, Pc, V1); - XYZ Q = Pc.XYZ(); //Q - XYZ DQv = V1.XYZ(); //Q' - XYZ C = loc.XYZ(); //C - XYZ Vdir = direction.XYZ(); //Vdir - Q.Subtract(C); //CQ - XYZ VcrossCQ = Vdir.Crossed (Q); //Vdir^CQ - // If the point is placed on the axis of revolution then derivatives on U are undefined. - // Manually set them to zero. - if (VcrossCQ.SquareModulus() < Precision::SquareConfusion()) - VcrossCQ.SetCoord(0.0, 0.0, 0.0); - XYZ VcrossDQv = Vdir.Crossed (DQv); //(Vdir^Q') - XYZ VdotCQ = Vdir.Multiplied (Vdir.Dot(Q)); //(Vdir.CQ)Vdir - XYZ VdotDQv = Vdir.Multiplied (Vdir.Dot(DQv)); //(Vdir.Q')Vdir - - VcrossDQv.Multiply (Sin(U)); - VdotDQv.Multiply (1.0 - Cos(U)); - VdotDQv.Add (VcrossDQv); - DQv.Multiply (Cos(U)); - DQv.Add (VdotDQv); - D1V.SetXYZ (DQv); - - XYZ DQu = Q.Multiplied (-Sin(U)); - DQu.Add (VcrossCQ.Multiplied (Cos(U))); - DQu.Add (VdotCQ.Multiplied (Sin(U))); - D1U.SetXYZ (DQu); - - Q.Multiply (Cos(U)); - Q.Add (C); - VcrossCQ.Multiply (Sin(U)); - Q.Add (VcrossCQ); - VdotCQ.Multiply (1.0-Cos(U)); - Q.Add (VdotCQ); - P.SetXYZ (Q); - } + Vec& D1U, Vec& D1V ) const +{ + myEvaluator->D1(U, V, P, D1U, D1V); +} //======================================================================= //function : D2 @@ -444,83 +319,9 @@ void Geom_SurfaceOfRevolution::D2 (const Standard_Real U, const Standard_Real V, Pnt& P, Vec& D1U, Vec& D1V, - Vec& D2U, Vec& D2V, Vec& D2UV ) const { - - - // C origine sur l'axe de revolution - // V vecteur unitaire definissant la direction de l'axe de revolution - // Q(v) point de parametre V sur la courbe de revolution - // Q'(v) = D1Q/DV - // Q"(v) = D2Q/DV - // OM (u,v) = OC + CQ * Cos(U) + (CQ.Vdir)(1-Cos(U)) * Vdir + - // (Vdir^CQ) * Sin(U) - // D1U_M(u,v) = - CQ * Sin(U) + (CQ.Vdir)(Sin(U)) * Vdir + - // (Vdir^CQ) * Cos(U) - // D1V_M(u,v) = Q' * Cos(U) + (Q'.Vdir)(1-Cos(U)) * Vdir + - // (Vdir^Q') * Sin(U) - // D2U_M(u,v) = -CQ * Cos(U) + (CQ.Vdir)(Cos(U)) * Vdir + - // (Vdir^CQ) * -(Sin(U)) - // D2V_M(u,v) = Q" * Cos(U) + (Q".Vdir)(1-Cos(U)) * Vdir + - // (Vdir^Q") * Sin(U) - // D2UV_M(u,v)= -Q' * Sin(U) + (Q'.Vdir)(Sin(U)) * Vdir + - // (Vdir^Q') * Cos(U) - - - Pnt Pc; - Vec V1 , V2; - basisCurve->D2 (V, Pc, V1, V2); - XYZ Q = Pc.XYZ(); //Q - XYZ D1Qv = V1.XYZ(); //Q' - XYZ D2Qv = V2.XYZ(); //Q" - XYZ C = loc.XYZ(); //C - XYZ Vdir = direction.XYZ(); //Vdir - Q.Subtract(C); //CQ - XYZ VcrossCQ = Vdir.Crossed (Q); //Vdir^CQ - // If the point is placed on the axis of revolution then derivatives on U are undefined. - // Manually set them to zero. - if (VcrossCQ.SquareModulus() < Precision::SquareConfusion()) - VcrossCQ.SetCoord(0.0, 0.0, 0.0); - XYZ VcrossD1Qv = Vdir.Crossed (D1Qv); //(Vdir^Q') - XYZ VcrossD2Qv = Vdir.Crossed (D2Qv); //(Vdir^Q") - XYZ VdotCQ = Vdir.Multiplied (Vdir.Dot(Q)); //(Vdir.CQ)Vdir - XYZ VdotD1Qv = Vdir.Multiplied (Vdir.Dot(D1Qv)); //(Vdir.Q')Vdir - XYZ VdotD2Qv = Vdir.Multiplied (Vdir.Dot(D2Qv)); //(Vdir.Q")Vdir - - - XYZ D2Quv = D1Qv.Multiplied(-Sin(U)); - D2Quv.Add (VcrossD1Qv.Multiplied (Cos(U))); - D2Quv.Add (VdotD1Qv.Multiplied (Sin(U))); - D2UV.SetXYZ (D2Quv); - - D1Qv.Multiply (Cos(U)); - VcrossD1Qv.Multiply (Sin(U)); - VdotD1Qv.Multiply (1.0 - Cos(U)); - D1Qv.Add (VcrossD1Qv); - D1Qv.Add (VdotD1Qv); - D1V.SetXYZ (D1Qv); - - VcrossD2Qv.Multiply (Sin(U)); - VdotD2Qv.Multiply (1.0 - Cos(U)); - VdotD2Qv.Add (VcrossD2Qv); - D2Qv.Multiply (Cos(U)); - D2Qv.Add (VdotD2Qv); - D2V.SetXYZ (D2Qv); - - XYZ D1Qu = Q.Multiplied (-Sin(U)); - D1Qu.Add (VcrossCQ.Multiplied (Cos(U))); - D1Qu.Add (VdotCQ.Multiplied (Sin(U))); - D1U.SetXYZ (D1Qu); - - Q.Multiply (Cos(U)); - VcrossCQ.Multiply (Sin(U)); - Q.Add (VcrossCQ); - XYZ D2Qu = Q.Multiplied(-1.0); - D2Qu.Add (VdotCQ.Multiplied (Cos(U))); - D2U.SetXYZ (D2Qu); - VdotCQ.Multiply (1.0-Cos(U)); - Q.Add (VdotCQ); - Q.Add (C); - P.SetXYZ (Q); + Vec& D2U, Vec& D2V, Vec& D2UV ) const +{ + myEvaluator->D2(U, V, P, D1U, D1V, D2U, D2V, D2UV); } @@ -535,112 +336,9 @@ void Geom_SurfaceOfRevolution::D3 Pnt& P, Vec& D1U, Vec& D1V, Vec& D2U, Vec& D2V, Vec& D2UV, - Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV ) const { - - // C origine sur l'axe de revolution - // Vdir vecteur unitaire definissant la direction de l'axe de revolution - // Q(v) point de parametre V sur la courbe de revolution - // Q'(v) = D1Q/DV - // Q"(v) = D2Q/DV - // OM (u,v) = OC + CQ * Cos(u) + (CQ.Vdir)(1-Cos(u)) * Vdir + - // (Vdir^CQ) * Sin(u) - // D1U_M(u,v) = - CQ * Sin(u) + (CQ.Vdir)(Sin(u)) * Vdir + - // (Vdir^CQ) * Cos(u) - // D2U_M(u,v) = -CQ * Cos(u) + (CQ.Vdir)(Cos(u)) * Vdir + - // (Vdir^CQ) * -Sin(u) - // D2UV_M(u,v)= -Q' * Sin(u) + (Q'.Vdir)(Sin(u)) * Vdir + - // (Vdir^Q') * Cos(u) - // D3UUV_M(u,v) = -Q' * Cos(u) + (Q'.Vdir)(Cos(u)) * Vdir + - // (Vdir^Q') * -Sin(u) - // D3U_M(u,v) = CQ * Sin(u) + (CQ.Vdir)(-Sin(u)) * Vdir + - // (Vdir^CQ) * -Cos(u) - // D1V_M(u,v) = Q' * Cos(u) + (Q'.Vdir)(1-Cos(u)) * Vdir + - // (Vdir^Q') * Sin(u) - // D2V_M(u,v) = Q" * Cos(u) + (Q".Vdir)(1-Cos(u)) * Vdir + - // (Vdir^Q") * Sin(u) - // D3UVV_M(u,v) = -Q" * Sin(u) + (Q".Vdir)(Sin(u)) * Vdir + - // (Vdir^Q") * Cos(u) - // D3V_M(u,v) = Q'''* Cos(u) + (Q'''.Vdir)(1-Cos(u)) * Vdir + - // (Vdir^Q''') * Sin(u) - - - Pnt Pc; - Vec V1 , V2, V3; - basisCurve->D3 (V, Pc, V1, V2, V3); - XYZ Q = Pc.XYZ(); //Q - XYZ D1Qv = V1.XYZ(); //Q' - XYZ D2Qv = V2.XYZ(); //Q" - XYZ D3Qv = V3.XYZ(); //Q''' - XYZ C = loc.XYZ(); //C - XYZ Vdir = direction.XYZ(); //Vdir - Q.Subtract(C); //CQ - XYZ VcrossCQ = Vdir.Crossed (Q); //Vdir^CQ - // If the point is placed on the axis of revolution then derivatives on U are undefined. - // Manually set them to zero. - if (VcrossCQ.SquareModulus() < Precision::SquareConfusion()) - VcrossCQ.SetCoord(0.0, 0.0, 0.0); - XYZ VcrossD1Qv = Vdir.Crossed (D1Qv); //(Vdir^Q') - XYZ VcrossD2Qv = Vdir.Crossed (D2Qv); //(Vdir^Q") - XYZ VcrossD3Qv = Vdir.Crossed (D3Qv); //(Vdir^Q''') - XYZ VdotCQ = Vdir.Multiplied (Vdir.Dot(Q)); //(Vdir.CQ)Vdir - XYZ VdotD1Qv = Vdir.Multiplied (Vdir.Dot(D1Qv)); //(Vdir.Q')Vdir - XYZ VdotD2Qv = Vdir.Multiplied (Vdir.Dot(D2Qv)); //(Vdir.Q")Vdir - XYZ VdotD3Qv = Vdir.Multiplied (Vdir.Dot(D3Qv)); //(Vdir.Q''')Vdir - - XYZ D3Quuv = D1Qv.Multiplied (-Cos(U)); - D3Quuv.Add (VcrossD1Qv.Multiplied (-Sin(U))); - D3Quuv.Add (VdotD1Qv.Multiplied (Cos(U))); - D3UUV.SetXYZ (D3Quuv); - - XYZ D2Quv = D1Qv.Multiplied (-Sin(U)); - D2Quv.Add (VcrossD1Qv.Multiplied (Cos(U))); - D2Quv.Add (VdotD1Qv.Multiplied (Sin(U))); - D2UV.SetXYZ (D2Quv); - - D1Qv.Multiply (Cos(U)); - VcrossD1Qv.Multiply (Sin(U)); - VdotD1Qv.Multiply (1.0 - Cos(U)); - D1Qv.Add (VcrossD1Qv); - D1Qv.Add (VdotD1Qv); - D1V.SetXYZ (D1Qv); - - XYZ D3Qvvu = D2Qv.Multiplied (-Sin(U)); - D3Qvvu.Add (VcrossD2Qv.Multiplied (Cos(U))); - D3Qvvu.Add (VdotD2Qv.Multiplied (Sin(U))); - D3UVV.SetXYZ (D3Qvvu); - - VcrossD2Qv.Multiply (Sin(U)); - VdotD2Qv.Multiply (1.0 - Cos(U)); - VdotD2Qv.Add (VcrossD2Qv); - D2Qv.Multiply (Cos(U)); - D2Qv.Add (VdotD2Qv); - D2V.SetXYZ (D2Qv); - - VcrossD3Qv.Multiply (Sin(U)); - VdotD3Qv.Multiply (1.0 - Cos(U)); - VdotD3Qv.Add (VcrossD2Qv); - D3Qv.Multiply (Cos(U)); - D3Qv.Add (VdotD3Qv); - D3V.SetXYZ (D3Qv); - - XYZ D1Qu = Q.Multiplied (- Sin(U)); - D1Qu.Add (VcrossCQ.Multiplied (Cos(U))); - XYZ D3Qu = D1Qu.Multiplied (-1.0); - D1Qu.Add (VdotCQ.Multiplied (Sin(U))); - D3Qu.Add (VdotCQ.Multiplied (-Sin(U))); - D1U.SetXYZ (D1Qu); - D3U.SetXYZ (D3Qu); - - Q.Multiply (Cos(U)); - VcrossCQ.Multiply (Sin(U)); - Q.Add (VcrossCQ); - XYZ D2Qu = Q.Multiplied(-1.0); - D2Qu.Add (VdotCQ.Multiplied (Cos(U))); - D2U.SetXYZ (D2Qu); - VdotCQ.Multiply (1.0-Cos(U)); - Q.Add (VdotCQ); - Q.Add (C); - P.SetXYZ (Q); + Vec& D3U, Vec& D3V, Vec& D3UUV, Vec& D3UVV ) const +{ + myEvaluator->D3(U, V, P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); } @@ -650,458 +348,11 @@ void Geom_SurfaceOfRevolution::D3 //======================================================================= Vec Geom_SurfaceOfRevolution::DN (const Standard_Real U , const Standard_Real V, - const Standard_Integer Nu, const Standard_Integer Nv) const { - - Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv < 0, " "); - if (Nu == 0) { - XYZ Vn = (basisCurve->DN (V, Nv)).XYZ(); - XYZ Vdir = direction.XYZ(); - XYZ VDot = Vdir.Multiplied (Vn.Dot (Vdir)); - VDot.Multiply (1-Cos(U)); - XYZ VCross = Vdir.Crossed (Vn); - VCross.Multiply (Sin(U)); - Vn.Multiply (Cos(U)); - Vn.Add (VDot); - Vn.Add (VCross); - return Vec (Vn); - } - else if (Nv == 0) { - XYZ CQ = (basisCurve->Value (V)).XYZ() - loc.XYZ(); - XYZ Vdir = direction.XYZ(); - XYZ VDot = Vdir.Multiplied (CQ.Dot (Vdir)); - XYZ VCross = Vdir.Crossed (CQ); - if ((Nu + 6) % 4 == 0) { - CQ.Multiply (-Cos (U)); - VDot.Multiply (Cos(U)); - VCross.Multiply (-Sin(U)); - } - else if ((Nu + 5) % 4 == 0) { - CQ.Multiply (Sin (U)); - VDot.Multiply (-Sin(U)); - VCross.Multiply (-Cos(U)); - } - else if ((Nu+3) % 4 == 0) { - CQ.Multiply (-Sin (U)); - VDot.Multiply (+Sin(U)); - VCross.Multiply (Cos(U)); - } - else if (Nu+4 % 4 == 0) { - CQ.Multiply (Cos (U)); - VDot.Multiply (-Cos(U)); - VCross.Multiply (Sin(U)); - } - CQ.Add (VDot); - CQ.Add (VCross); - return Vec (CQ); - } - else { - XYZ Vn = (basisCurve->DN (V, Nv)).XYZ(); - XYZ Vdir = direction.XYZ(); - XYZ VDot = Vdir.Multiplied (Vn.Dot (Vdir)); - XYZ VCross = Vdir.Crossed (Vn); - if ((Nu + 6) % 4 == 0) { - Vn.Multiply (-Cos (U)); - VDot.Multiply (Cos(U)); - VCross.Multiply (-Sin(U)); - } - else if ((Nu + 5) % 4 == 0) { - Vn.Multiply (Sin (U)); - VDot.Multiply (-Sin(U)); - VCross.Multiply (-Cos(U)); - } - else if ((Nu+3) % 4 == 0) { - Vn.Multiply (-Sin (U)); - VDot.Multiply (+Sin(U)); - VCross.Multiply (Cos(U)); - } - else if (Nu+4 % 4 == 0) { - Vn.Multiply (Cos (U)); - VDot.Multiply (-Cos(U)); - VCross.Multiply (Sin(U)); - } - Vn.Add (VDot); - Vn.Add (VCross); - return Vec (Vn); - } -} - -//======================================================================= -//function : LocalD0 -//purpose : -//======================================================================= - -void Geom_SurfaceOfRevolution::LocalD0 (const Standard_Real U, - const Standard_Real V, - const Standard_Integer VSide, - gp_Pnt& P ) const + const Standard_Integer Nu, const Standard_Integer Nv) const { - if((VSide !=0 ) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) - { - gp_Vec D1V,D2V,D3V; - Handle( Geom_BSplineCurve) BSplC; - BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve); - - LocateSide(V,VSide,BSplC,0,P,D1V,D2V,D3V); - XYZ Q = P.XYZ(); //Q - XYZ C = loc.XYZ(); //C - Q.Subtract(C); //CQ - XYZ Vdir = direction.XYZ(); //Vdir - XYZ VcrossCQ = Vdir.Crossed (Q); //Vdir^CQ - VcrossCQ.Multiply (Sin(U)); //(Vdir^CQ)*Sin(U) - XYZ VdotCQ = - Vdir.Multiplied ((Vdir.Dot(Q))*(1.0 - Cos(U)));//(CQ.Vdir)(1-Cos(U))Vdir - VdotCQ.Add (VcrossCQ); //addition des composantes - Q.Multiply (Cos(U)); - Q.Add (VdotCQ); - Q.Add (C); - P.SetXYZ(Q); - } - else D0(U,V,P); + return myEvaluator->DN(U, V, Nu, Nv); } -//======================================================================= -//function : LocalD1 -//purpose : -//======================================================================= - -void Geom_SurfaceOfRevolution::LocalD1 (const Standard_Real U, - const Standard_Real V, - const Standard_Integer VSide, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V) const -{ - if((VSide !=0 ) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) - { - Handle( Geom_BSplineCurve) BSplC; - BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve); - Vec D2V,D3V; - Vec V1; - LocateSide(V,VSide,BSplC,1,P,V1,D2V,D3V); - XYZ Q = P.XYZ(); //Q - XYZ DQv = V1.XYZ(); //Q' - XYZ C = loc.XYZ(); //C - XYZ Vdir = direction.XYZ(); //Vdir - Q.Subtract(C); //CQ - XYZ VcrossCQ = Vdir.Crossed (Q); //Vdir^CQ - // If the point is placed on the axis of revolution then derivatives on U are undefined. - // Manually set them to zero. - if (VcrossCQ.SquareModulus() < Precision::SquareConfusion()) - VcrossCQ.SetCoord(0.0, 0.0, 0.0); - - XYZ VcrossDQv = Vdir.Crossed (DQv); //(Vdir^Q') - XYZ VdotCQ = Vdir.Multiplied (Vdir.Dot(Q)); //(Vdir.CQ)Vdir - XYZ VdotDQv = Vdir.Multiplied (Vdir.Dot(DQv)); //(Vdir.Q')Vdir - - VcrossDQv.Multiply (Sin(U)); - VdotDQv.Multiply (1.0 - Cos(U)); - VdotDQv.Add (VcrossDQv); - DQv.Multiply (Cos(U)); - DQv.Add (VdotDQv); - D1V.SetXYZ (DQv); - - XYZ DQu = Q.Multiplied (-Sin(U)); - DQu.Add (VcrossCQ.Multiplied (Cos(U))); - DQu.Add (VdotCQ.Multiplied (Sin(U))); - D1U.SetXYZ (DQu); - - Q.Multiply (Cos(U)); - Q.Add (C); - VcrossCQ.Multiply (Sin(U)); - Q.Add (VcrossCQ); - VdotCQ.Multiply (1.0-Cos(U)); - Q.Add (VdotCQ); - P.SetXYZ (Q); - }else - D1(U,V,P,D1U,D1V); -} - -//======================================================================= -//function : LocalD2 -//purpose : -//======================================================================= - -void Geom_SurfaceOfRevolution::LocalD2 (const Standard_Real U, - const Standard_Real V, - const Standard_Integer VSide, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V, - gp_Vec& D2U, - gp_Vec& D2V, - gp_Vec& D2UV) const -{ - if((VSide !=0 ) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) - { - Handle( Geom_BSplineCurve) BSplC; - BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve); - Vec d3v; - LocateSide(V,VSide,BSplC,2,P,D1V,D2V,d3v); - XYZ Q = P.XYZ(); //Q - XYZ D1Qv = D1V.XYZ(); //Q' - XYZ D2Qv = D2V.XYZ(); //Q" - XYZ C = loc.XYZ(); //C - XYZ Vdir = direction.XYZ(); //Vdir - Q.Subtract(C); //CQ - XYZ VcrossCQ = Vdir.Crossed (Q); //Vdir^CQ - // If the point is placed on the axis of revolution then derivatives on U are undefined. - // Manually set them to zero. - if (VcrossCQ.SquareModulus() < Precision::SquareConfusion()) - VcrossCQ.SetCoord(0.0, 0.0, 0.0); - - XYZ VcrossD1Qv = Vdir.Crossed (D1Qv); //(Vdir^Q') - XYZ VcrossD2Qv = Vdir.Crossed (D2Qv); //(Vdir^Q") - XYZ VdotCQ = Vdir.Multiplied (Vdir.Dot(Q)); //(Vdir.CQ)Vdir - XYZ VdotD1Qv = Vdir.Multiplied (Vdir.Dot(D1Qv)); //(Vdir.Q')Vdir - XYZ VdotD2Qv = Vdir.Multiplied (Vdir.Dot(D2Qv)); //(Vdir.Q")Vdir - - - XYZ D2Quv = D1Qv.Multiplied(-Sin(U)); - D2Quv.Add (VcrossD1Qv.Multiplied (Cos(U))); - D2Quv.Add (VdotD1Qv.Multiplied (Sin(U))); - D2UV.SetXYZ (D2Quv); - - D1Qv.Multiply (Cos(U)); - VcrossD1Qv.Multiply (Sin(U)); - VdotD1Qv.Multiply (1.0 - Cos(U)); - D1Qv.Add (VcrossD1Qv); - D1Qv.Add (VdotD1Qv); - D1V.SetXYZ (D1Qv); - - VcrossD2Qv.Multiply (Sin(U)); - VdotD2Qv.Multiply (1.0 - Cos(U)); - VdotD2Qv.Add (VcrossD2Qv); - D2Qv.Multiply (Cos(U)); - D2Qv.Add (VdotD2Qv); - D2V.SetXYZ (D2Qv); - - XYZ D1Qu = Q.Multiplied (-Sin(U)); - D1Qu.Add (VcrossCQ.Multiplied (Cos(U))); - D1Qu.Add (VdotCQ.Multiplied (Sin(U))); - D1U.SetXYZ (D1Qu); - - Q.Multiply (Cos(U)); - VcrossCQ.Multiply (Sin(U)); - Q.Add (VcrossCQ); - XYZ D2Qu = Q.Multiplied(-1.0); - D2Qu.Add (VdotCQ.Multiplied (Cos(U))); - D2U.SetXYZ (D2Qu); - VdotCQ.Multiply (1.0-Cos(U)); - Q.Add (VdotCQ); - Q.Add (C); - P.SetXYZ (Q); - } - else - D2(U,V,P,D1U,D1V,D2U,D2V,D2UV); -} -//======================================================================= -//function : LocalD3 -//purpose : -//======================================================================= - -void Geom_SurfaceOfRevolution::LocalD3 (const Standard_Real U, - const Standard_Real V, - const Standard_Integer VSide, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V, - gp_Vec& D2U, - gp_Vec& D2V, - gp_Vec& D2UV, - gp_Vec& D3U, - gp_Vec& D3V, - gp_Vec& D3UUV, - gp_Vec& D3UVV) const -{ - if((VSide !=0 ) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) - { - Handle( Geom_BSplineCurve) BSplC; - BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve); - - LocateSide(V,VSide,BSplC,3,P,D1V,D2V,D3V); - XYZ Q = P.XYZ(); //Q - XYZ D1Qv = D1V.XYZ(); //Q' - XYZ D2Qv = D2V.XYZ(); //Q" - XYZ D3Qv = D3V.XYZ(); //Q''' - XYZ C = loc.XYZ(); //C - XYZ Vdir = direction.XYZ(); //Vdir - Q.Subtract(C); //CQ - XYZ VcrossCQ = Vdir.Crossed (Q); //Vdir^CQ - // If the point is placed on the axis of revolution then derivatives on U are undefined. - // Manually set them to zero. - if (VcrossCQ.SquareModulus() < Precision::SquareConfusion()) - VcrossCQ.SetCoord(0.0, 0.0, 0.0); - - XYZ VcrossD1Qv = Vdir.Crossed (D1Qv); //(Vdir^Q') - XYZ VcrossD2Qv = Vdir.Crossed (D2Qv); //(Vdir^Q") - XYZ VcrossD3Qv = Vdir.Crossed (D3Qv); //(Vdir^Q''') - XYZ VdotCQ = Vdir.Multiplied (Vdir.Dot(Q)); //(Vdir.CQ)Vdir - XYZ VdotD1Qv = Vdir.Multiplied (Vdir.Dot(D1Qv)); //(Vdir.Q')Vdir - XYZ VdotD2Qv = Vdir.Multiplied (Vdir.Dot(D2Qv)); //(Vdir.Q")Vdir - XYZ VdotD3Qv = Vdir.Multiplied (Vdir.Dot(D3Qv)); //(Vdir.Q''')Vdir - - XYZ D3Quuv = D1Qv.Multiplied (-Cos(U)); - D3Quuv.Add (VcrossD1Qv.Multiplied (-Sin(U))); - D3Quuv.Add (VdotD1Qv.Multiplied (Cos(U))); - D3UUV.SetXYZ (D3Quuv); - - XYZ D2Quv = D1Qv.Multiplied (-Sin(U)); - D2Quv.Add (VcrossD1Qv.Multiplied (Cos(U))); - D2Quv.Add (VdotD1Qv.Multiplied (Sin(U))); - D2UV.SetXYZ (D2Quv); - - D1Qv.Multiply (Cos(U)); - VcrossD1Qv.Multiply (Sin(U)); - VdotD1Qv.Multiply (1.0 - Cos(U)); - D1Qv.Add (VcrossD1Qv); - D1Qv.Add (VdotD1Qv); - D1V.SetXYZ (D1Qv); - - XYZ D3Qvvu = D2Qv.Multiplied (-Sin(U)); - D3Qvvu.Add (VcrossD2Qv.Multiplied (Cos(U))); - D3Qvvu.Add (VdotD2Qv.Multiplied (Sin(U))); - D3UVV.SetXYZ (D3Qvvu); - - VcrossD2Qv.Multiply (Sin(U)); - VdotD2Qv.Multiply (1.0 - Cos(U)); - VdotD2Qv.Add (VcrossD2Qv); - D2Qv.Multiply (Cos(U)); - D2Qv.Add (VdotD2Qv); - D2V.SetXYZ (D2Qv); - - VcrossD3Qv.Multiply (Sin(U)); - VdotD3Qv.Multiply (1.0 - Cos(U)); - VdotD3Qv.Add (VcrossD2Qv); - D3Qv.Multiply (Cos(U)); - D3Qv.Add (VdotD3Qv); - D3V.SetXYZ (D3Qv); - - XYZ D1Qu = Q.Multiplied (- Sin(U)); - D1Qu.Add (VcrossCQ.Multiplied (Cos(U))); - XYZ D3Qu = D1Qu.Multiplied (-1.0); - D1Qu.Add (VdotCQ.Multiplied (Sin(U))); - D3Qu.Add (VdotCQ.Multiplied (-Sin(U))); - D1U.SetXYZ (D1Qu); - D3U.SetXYZ (D3Qu); - - Q.Multiply (Cos(U)); - VcrossCQ.Multiply (Sin(U)); - Q.Add (VcrossCQ); - XYZ D2Qu = Q.Multiplied(-1.0); - D2Qu.Add (VdotCQ.Multiplied (Cos(U))); - D2U.SetXYZ (D2Qu); - VdotCQ.Multiply (1.0-Cos(U)); - Q.Add (VdotCQ); - Q.Add (C); - P.SetXYZ (Q); - } - else - D3(U,V,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); -} -//======================================================================= -//function : LocalDN -//purpose : -//======================================================================= - -gp_Vec Geom_SurfaceOfRevolution::LocalDN (const Standard_Real U, - const Standard_Real V, - const Standard_Integer VSide, - const Standard_Integer Nu, - const Standard_Integer Nv) const -{ - Standard_RangeError_Raise_if (Nu + Nv < 1 || Nu < 0 || Nv < 0, " "); - XYZ Vn, CQ; - if (Nu == 0) { - if((VSide !=0 ) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) - { - Handle( Geom_BSplineCurve) BSplC; - BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve); - Vn = LocateSideN(V,VSide,BSplC,Nv).XYZ(); - }else - return DN(U,V,Nu,Nv); - XYZ Vdir = direction.XYZ(); - XYZ VDot = Vdir.Multiplied (Vn.Dot (Vdir)); - VDot.Multiply (1-Cos(U)); - XYZ VCross = Vdir.Crossed (Vn); - VCross.Multiply (Sin(U)); - Vn.Multiply (Cos(U)); - Vn.Add (VDot); - Vn.Add (VCross); - return Vec (Vn); - } - - else if (Nv == 0) { - if((VSide !=0 ) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) - { - Handle( Geom_BSplineCurve) BSplC; - BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve); - CQ = LocateSideN(V,VSide,BSplC,Nv).XYZ() - loc.XYZ(); - }else - return DN(U,V,Nu,Nv); - XYZ Vdir = direction.XYZ(); - XYZ VDot = Vdir.Multiplied (CQ.Dot (Vdir)); - XYZ VCross = Vdir.Crossed (CQ); - if ((Nu + 6) % 4 == 0) { - CQ.Multiply (-Cos (U)); - VDot.Multiply (Cos(U)); - VCross.Multiply (-Sin(U)); - } - else if ((Nu + 5) % 4 == 0) { - CQ.Multiply (Sin (U)); - VDot.Multiply (-Sin(U)); - VCross.Multiply (-Cos(U)); - } - else if ((Nu+3) % 4 == 0) { - CQ.Multiply (-Sin (U)); - VDot.Multiply (+Sin(U)); - VCross.Multiply (Cos(U)); - } - else if (Nu+4 % 4 == 0) { - CQ.Multiply (Cos (U)); - VDot.Multiply (-Cos(U)); - VCross.Multiply (Sin(U)); - } - CQ.Add (VDot); - CQ.Add (VCross); - return Vec (CQ); - } - - else { - if((VSide !=0 ) && basisCurve->IsKind(STANDARD_TYPE(Geom_BSplineCurve))) - { - Handle( Geom_BSplineCurve) BSplC; - BSplC= Handle(Geom_BSplineCurve)::DownCast(basisCurve); - Vn = LocateSideN(V,VSide,BSplC,Nv).XYZ(); - }else - return DN(U,V,Nu,Nv); - XYZ Vdir = direction.XYZ(); - XYZ VDot = Vdir.Multiplied (Vn.Dot (Vdir)); - XYZ VCross = Vdir.Crossed (Vn); - if ((Nu + 6) % 4 == 0) { - Vn.Multiply (-Cos (U)); - VDot.Multiply (Cos(U)); - VCross.Multiply (-Sin(U)); - } - else if ((Nu + 5) % 4 == 0) { - Vn.Multiply (Sin (U)); - VDot.Multiply (-Sin(U)); - VCross.Multiply (-Cos(U)); - } - else if ((Nu+3) % 4 == 0) { - Vn.Multiply (-Sin (U)); - VDot.Multiply (+Sin(U)); - VCross.Multiply (Cos(U)); - } - else if (Nu+4 % 4 == 0) { - Vn.Multiply (Cos (U)); - VDot.Multiply (-Cos(U)); - VCross.Multiply (Sin(U)); - } - Vn.Add (VDot); - Vn.Add (VCross); - return Vec (Vn); - } -} //======================================================================= //function : ReferencePlane @@ -1174,6 +425,8 @@ void Geom_SurfaceOfRevolution::Transform (const Trsf& T) { direction.Transform (T); basisCurve->Transform (T); if(T.ScaleFactor()*T.HVectorialPart().Determinant() < 0.) UReverse(); + myEvaluator->SetDirection(direction); + myEvaluator->SetLocation(loc); } //======================================================================= diff --git a/src/Geom/Geom_SurfaceOfRevolution.hxx b/src/Geom/Geom_SurfaceOfRevolution.hxx index 3a3280b110..d1e41f08f4 100644 --- a/src/Geom/Geom_SurfaceOfRevolution.hxx +++ b/src/Geom/Geom_SurfaceOfRevolution.hxx @@ -22,6 +22,7 @@ #include #include +#include #include #include #include @@ -264,25 +265,21 @@ public: //! The direction of this axis gives the sense of rotation. //! V is the parameter of the revolved curve. Standard_EXPORT void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const; - //! Computes the current point and the first derivatives //! in the directions U and V. //! Raised if the continuity of the surface is not C1. Standard_EXPORT void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const; - //! Computes the current point, the first and the second derivatives //! in the directions U and V. //! Raised if the continuity of the surface is not C2. Standard_EXPORT void D2 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const; - //! Computes the current point, the first,the second and the third //! derivatives in the directions U and V. //! Raised if the continuity of the surface is not C3. Standard_EXPORT void D3 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const; - //! Computes the derivative of order Nu in the direction u and //! Nv in the direction v. @@ -299,17 +296,7 @@ public: //! can be evaluated using methods of //! global evaluations P = S( U ,V ) Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv) const; - - Standard_EXPORT void LocalD0 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, gp_Pnt& P) const; - - Standard_EXPORT void LocalD1 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const; - - Standard_EXPORT void LocalD2 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const; - - Standard_EXPORT void LocalD3 (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const; - - Standard_EXPORT gp_Vec LocalDN (const Standard_Real U, const Standard_Real V, const Standard_Integer USide, const Standard_Integer Nu, const Standard_Integer Nv) const; - + //! Applies the transformation T to this surface of revolution. Standard_EXPORT void Transform (const gp_Trsf& T); @@ -317,27 +304,11 @@ public: Standard_EXPORT Handle(Geom_Geometry) Copy() const; - - DEFINE_STANDARD_RTTI(Geom_SurfaceOfRevolution,Geom_SweptSurface) -protected: - - - - private: - - + Handle(GeomEvaluator_SurfaceOfRevolution) myEvaluator; gp_Pnt loc; - - }; - - - - - - #endif // _Geom_SurfaceOfRevolution_HeaderFile diff --git a/src/GeomAdaptor/FILES b/src/GeomAdaptor/FILES index abe907b81c..26f7c52d81 100644 --- a/src/GeomAdaptor/FILES +++ b/src/GeomAdaptor/FILES @@ -13,6 +13,14 @@ GeomAdaptor_HCurve.lxx GeomAdaptor_HSurface.cxx GeomAdaptor_HSurface.hxx GeomAdaptor_HSurface.lxx +GeomAdaptor_HSurfaceOfLinearExtrusion_0.cxx +GeomAdaptor_HSurfaceOfLinearExtrusion.hxx +GeomAdaptor_HSurfaceOfRevolution_0.cxx +GeomAdaptor_HSurfaceOfRevolution.hxx GeomAdaptor_Surface.cxx GeomAdaptor_Surface.hxx GeomAdaptor_Surface.lxx +GeomAdaptor_SurfaceOfLinearExtrusion.cxx +GeomAdaptor_SurfaceOfLinearExtrusion.hxx +GeomAdaptor_SurfaceOfRevolution.cxx +GeomAdaptor_SurfaceOfRevolution.hxx diff --git a/src/Adaptor3d/Adaptor3d_HSurfaceOfLinearExtrusion.hxx b/src/GeomAdaptor/GeomAdaptor_HSurfaceOfLinearExtrusion.hxx similarity index 55% rename from src/Adaptor3d/Adaptor3d_HSurfaceOfLinearExtrusion.hxx rename to src/GeomAdaptor/GeomAdaptor_HSurfaceOfLinearExtrusion.hxx index a0eef627b3..9c7766b7ad 100644 --- a/src/Adaptor3d/Adaptor3d_HSurfaceOfLinearExtrusion.hxx +++ b/src/GeomAdaptor/GeomAdaptor_HSurfaceOfLinearExtrusion.hxx @@ -14,56 +14,56 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#ifndef _Adaptor3d_HSurfaceOfLinearExtrusion_HeaderFile -#define _Adaptor3d_HSurfaceOfLinearExtrusion_HeaderFile +#ifndef _GeomAdaptor_HSurfaceOfLinearExtrusion_HeaderFile +#define _GeomAdaptor_HSurfaceOfLinearExtrusion_HeaderFile #include #include -#include +#include #include class Standard_OutOfRange; class Standard_NoSuchObject; class Standard_DomainError; -class Adaptor3d_SurfaceOfLinearExtrusion; +class GeomAdaptor_SurfaceOfLinearExtrusion; class Adaptor3d_Surface; -class Adaptor3d_HSurfaceOfLinearExtrusion; -DEFINE_STANDARD_HANDLE(Adaptor3d_HSurfaceOfLinearExtrusion, Adaptor3d_HSurface) +class GeomAdaptor_HSurfaceOfLinearExtrusion; +DEFINE_STANDARD_HANDLE(GeomAdaptor_HSurfaceOfLinearExtrusion, Adaptor3d_HSurface) -class Adaptor3d_HSurfaceOfLinearExtrusion : public Adaptor3d_HSurface +class GeomAdaptor_HSurfaceOfLinearExtrusion : public Adaptor3d_HSurface { public: //! Creates an empty GenHSurface. - Standard_EXPORT Adaptor3d_HSurfaceOfLinearExtrusion(); + Standard_EXPORT GeomAdaptor_HSurfaceOfLinearExtrusion(); //! Creates a GenHSurface from a Surface. - Standard_EXPORT Adaptor3d_HSurfaceOfLinearExtrusion(const Adaptor3d_SurfaceOfLinearExtrusion& S); + Standard_EXPORT GeomAdaptor_HSurfaceOfLinearExtrusion(const GeomAdaptor_SurfaceOfLinearExtrusion& S); //! Sets the field of the GenHSurface. - Standard_EXPORT void Set (const Adaptor3d_SurfaceOfLinearExtrusion& S); + Standard_EXPORT void Set (const GeomAdaptor_SurfaceOfLinearExtrusion& S); //! Returns a reference to the Surface inside the HSurface. //! This is redefined from HSurface, cannot be inline. Standard_EXPORT const Adaptor3d_Surface& Surface() const; //! Returns the surface used to create the GenHSurface. - Adaptor3d_SurfaceOfLinearExtrusion& ChangeSurface(); + GeomAdaptor_SurfaceOfLinearExtrusion& ChangeSurface(); - DEFINE_STANDARD_RTTI(Adaptor3d_HSurfaceOfLinearExtrusion,Adaptor3d_HSurface) + DEFINE_STANDARD_RTTI(GeomAdaptor_HSurfaceOfLinearExtrusion,Adaptor3d_HSurface) protected: - Adaptor3d_SurfaceOfLinearExtrusion mySurf; + GeomAdaptor_SurfaceOfLinearExtrusion mySurf; private: @@ -73,11 +73,11 @@ private: }; -#define TheSurface Adaptor3d_SurfaceOfLinearExtrusion -#define TheSurface_hxx -#define Adaptor3d_GenHSurface Adaptor3d_HSurfaceOfLinearExtrusion -#define Adaptor3d_GenHSurface_hxx -#define Handle_Adaptor3d_GenHSurface Handle(Adaptor3d_HSurfaceOfLinearExtrusion) +#define TheSurface GeomAdaptor_SurfaceOfLinearExtrusion +#define TheSurface_hxx +#define Adaptor3d_GenHSurface GeomAdaptor_HSurfaceOfLinearExtrusion +#define Adaptor3d_GenHSurface_hxx +#define Handle_Adaptor3d_GenHSurface Handle(GeomAdaptor_HSurfaceOfLinearExtrusion) #include @@ -90,4 +90,4 @@ private: -#endif // _Adaptor3d_HSurfaceOfLinearExtrusion_HeaderFile +#endif // _GeomAdaptor_HSurfaceOfLinearExtrusion_HeaderFile diff --git a/src/Adaptor3d/Adaptor3d_HSurfaceOfLinearExtrusion_0.cxx b/src/GeomAdaptor/GeomAdaptor_HSurfaceOfLinearExtrusion_0.cxx similarity index 67% rename from src/Adaptor3d/Adaptor3d_HSurfaceOfLinearExtrusion_0.cxx rename to src/GeomAdaptor/GeomAdaptor_HSurfaceOfLinearExtrusion_0.cxx index d9360595c1..647780fb66 100644 --- a/src/Adaptor3d/Adaptor3d_HSurfaceOfLinearExtrusion_0.cxx +++ b/src/GeomAdaptor/GeomAdaptor_HSurfaceOfLinearExtrusion_0.cxx @@ -14,29 +14,22 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include +#include #include #include #include #include -#include +#include #include - - - - - - - -#define TheSurface Adaptor3d_SurfaceOfLinearExtrusion -#define TheSurface_hxx -#define Adaptor3d_GenHSurface Adaptor3d_HSurfaceOfLinearExtrusion -#define Adaptor3d_GenHSurface_hxx -#define Handle_Adaptor3d_GenHSurface Handle(Adaptor3d_HSurfaceOfLinearExtrusion) +#define TheSurface GeomAdaptor_SurfaceOfLinearExtrusion +#define TheSurface_hxx +#define Adaptor3d_GenHSurface GeomAdaptor_HSurfaceOfLinearExtrusion +#define Adaptor3d_GenHSurface_hxx +#define Handle_Adaptor3d_GenHSurface Handle(GeomAdaptor_HSurfaceOfLinearExtrusion) #include diff --git a/src/Adaptor3d/Adaptor3d_HSurfaceOfRevolution.hxx b/src/GeomAdaptor/GeomAdaptor_HSurfaceOfRevolution.hxx similarity index 57% rename from src/Adaptor3d/Adaptor3d_HSurfaceOfRevolution.hxx rename to src/GeomAdaptor/GeomAdaptor_HSurfaceOfRevolution.hxx index 56a54646be..6a33f6d160 100644 --- a/src/Adaptor3d/Adaptor3d_HSurfaceOfRevolution.hxx +++ b/src/GeomAdaptor/GeomAdaptor_HSurfaceOfRevolution.hxx @@ -14,56 +14,56 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#ifndef _Adaptor3d_HSurfaceOfRevolution_HeaderFile -#define _Adaptor3d_HSurfaceOfRevolution_HeaderFile +#ifndef _GeomAdaptor_HSurfaceOfRevolution_HeaderFile +#define _GeomAdaptor_HSurfaceOfRevolution_HeaderFile #include #include -#include +#include #include class Standard_OutOfRange; class Standard_NoSuchObject; class Standard_DomainError; -class Adaptor3d_SurfaceOfRevolution; +class GeomAdaptor_SurfaceOfRevolution; class Adaptor3d_Surface; -class Adaptor3d_HSurfaceOfRevolution; -DEFINE_STANDARD_HANDLE(Adaptor3d_HSurfaceOfRevolution, Adaptor3d_HSurface) +class GeomAdaptor_HSurfaceOfRevolution; +DEFINE_STANDARD_HANDLE(GeomAdaptor_HSurfaceOfRevolution, Adaptor3d_HSurface) -class Adaptor3d_HSurfaceOfRevolution : public Adaptor3d_HSurface +class GeomAdaptor_HSurfaceOfRevolution : public Adaptor3d_HSurface { public: //! Creates an empty GenHSurface. - Standard_EXPORT Adaptor3d_HSurfaceOfRevolution(); + Standard_EXPORT GeomAdaptor_HSurfaceOfRevolution(); //! Creates a GenHSurface from a Surface. - Standard_EXPORT Adaptor3d_HSurfaceOfRevolution(const Adaptor3d_SurfaceOfRevolution& S); + Standard_EXPORT GeomAdaptor_HSurfaceOfRevolution(const GeomAdaptor_SurfaceOfRevolution& S); //! Sets the field of the GenHSurface. - Standard_EXPORT void Set (const Adaptor3d_SurfaceOfRevolution& S); + Standard_EXPORT void Set (const GeomAdaptor_SurfaceOfRevolution& S); //! Returns a reference to the Surface inside the HSurface. //! This is redefined from HSurface, cannot be inline. Standard_EXPORT const Adaptor3d_Surface& Surface() const; //! Returns the surface used to create the GenHSurface. - Adaptor3d_SurfaceOfRevolution& ChangeSurface(); + GeomAdaptor_SurfaceOfRevolution& ChangeSurface(); - DEFINE_STANDARD_RTTI(Adaptor3d_HSurfaceOfRevolution,Adaptor3d_HSurface) + DEFINE_STANDARD_RTTI(GeomAdaptor_HSurfaceOfRevolution,Adaptor3d_HSurface) protected: - Adaptor3d_SurfaceOfRevolution mySurf; + GeomAdaptor_SurfaceOfRevolution mySurf; private: @@ -73,11 +73,11 @@ private: }; -#define TheSurface Adaptor3d_SurfaceOfRevolution -#define TheSurface_hxx -#define Adaptor3d_GenHSurface Adaptor3d_HSurfaceOfRevolution -#define Adaptor3d_GenHSurface_hxx -#define Handle_Adaptor3d_GenHSurface Handle(Adaptor3d_HSurfaceOfRevolution) +#define TheSurface GeomAdaptor_SurfaceOfRevolution +#define TheSurface_hxx +#define Adaptor3d_GenHSurface GeomAdaptor_HSurfaceOfRevolution +#define Adaptor3d_GenHSurface_hxx +#define Handle_Adaptor3d_GenHSurface Handle(GeomAdaptor_HSurfaceOfRevolution) #include @@ -90,4 +90,4 @@ private: -#endif // _Adaptor3d_HSurfaceOfRevolution_HeaderFile +#endif // _GeomAdaptor_HSurfaceOfRevolution_HeaderFile diff --git a/src/Adaptor3d/Adaptor3d_HSurfaceOfRevolution_0.cxx b/src/GeomAdaptor/GeomAdaptor_HSurfaceOfRevolution_0.cxx similarity index 69% rename from src/Adaptor3d/Adaptor3d_HSurfaceOfRevolution_0.cxx rename to src/GeomAdaptor/GeomAdaptor_HSurfaceOfRevolution_0.cxx index e8d2c0c2a3..86278861d9 100644 --- a/src/Adaptor3d/Adaptor3d_HSurfaceOfRevolution_0.cxx +++ b/src/GeomAdaptor/GeomAdaptor_HSurfaceOfRevolution_0.cxx @@ -14,29 +14,22 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#include +#include #include #include #include #include -#include +#include #include - - - - - - - -#define TheSurface Adaptor3d_SurfaceOfRevolution -#define TheSurface_hxx -#define Adaptor3d_GenHSurface Adaptor3d_HSurfaceOfRevolution -#define Adaptor3d_GenHSurface_hxx -#define Handle_Adaptor3d_GenHSurface Handle(Adaptor3d_HSurfaceOfRevolution) +#define TheSurface GeomAdaptor_SurfaceOfRevolution +#define TheSurface_hxx +#define Adaptor3d_GenHSurface GeomAdaptor_HSurfaceOfRevolution +#define Adaptor3d_GenHSurface_hxx +#define Handle_Adaptor3d_GenHSurface Handle(GeomAdaptor_HSurfaceOfRevolution) #include diff --git a/src/GeomAdaptor/GeomAdaptor_Surface.cxx b/src/GeomAdaptor/GeomAdaptor_Surface.cxx index 63524e7a01..c7ad0b6572 100644 --- a/src/GeomAdaptor/GeomAdaptor_Surface.cxx +++ b/src/GeomAdaptor/GeomAdaptor_Surface.cxx @@ -45,6 +45,9 @@ #include #include #include +#include +#include +#include #include #include #include @@ -67,12 +70,6 @@ #include #include -//#include -#define myBspl Handle(Geom_BSplineSurface)::DownCast (mySurface) -#define myExtSurf Handle(Geom_SurfaceOfLinearExtrusion)::DownCast (mySurface) -#define myRevSurf Handle(Geom_SurfaceOfRevolution)::DownCast (mySurface) -#define myOffSurf Handle(Geom_OffsetSurface)::DownCast (mySurface) - //======================================================================= //function : LocalContinuity //purpose : @@ -138,7 +135,9 @@ void GeomAdaptor_Surface::load(const Handle(Geom_Surface)& S, if ( mySurface != S) { mySurface = S; - + mySurfaceCache = Handle(BSplSLib_Cache)(); + myNestedEvaluator = Handle(GeomEvaluator_Surface)(); + const Handle(Standard_Type)& TheType = S->DynamicType(); if ( TheType == STANDARD_TYPE(Geom_BezierSurface)) mySurfaceType = GeomAbs_BezierSurface; @@ -156,21 +155,51 @@ void GeomAdaptor_Surface::load(const Handle(Geom_Surface)& S, mySurfaceType = GeomAbs_Sphere; else if ( TheType == STANDARD_TYPE(Geom_ToroidalSurface)) mySurfaceType = GeomAbs_Torus; - else if ( TheType == STANDARD_TYPE(Geom_SurfaceOfRevolution)) + else if (TheType == STANDARD_TYPE(Geom_SurfaceOfRevolution)) + { mySurfaceType = GeomAbs_SurfaceOfRevolution; - else if ( TheType == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) + Handle(Geom_SurfaceOfRevolution) myRevSurf = + Handle(Geom_SurfaceOfRevolution)::DownCast(mySurface); + // Create nested adaptor for base curve + Handle(Geom_Curve) aBaseCurve = myRevSurf->BasisCurve(); + Handle(GeomAdaptor_HCurve) aBaseAdaptor = new GeomAdaptor_HCurve(aBaseCurve); + // Create corresponding evaluator + myNestedEvaluator = new GeomEvaluator_SurfaceOfRevolution( + Handle(Adaptor3d_HCurve)::DownCast(aBaseAdaptor), + myRevSurf->Direction(), myRevSurf->Location()); + } + else if (TheType == STANDARD_TYPE(Geom_SurfaceOfLinearExtrusion)) + { mySurfaceType = GeomAbs_SurfaceOfExtrusion; + Handle(Geom_SurfaceOfLinearExtrusion) myExtSurf = + Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(mySurface); + // Create nested adaptor for base curve + Handle(Geom_Curve) aBaseCurve = myExtSurf->BasisCurve(); + Handle(GeomAdaptor_HCurve) aBaseAdaptor = new GeomAdaptor_HCurve(aBaseCurve); + // Create corresponding evaluator + myNestedEvaluator = new GeomEvaluator_SurfaceOfExtrusion( + Handle(Adaptor3d_HCurve)::DownCast(aBaseAdaptor), myExtSurf->Direction()); + } else if ( TheType == STANDARD_TYPE(Geom_BSplineSurface)) { mySurfaceType = GeomAbs_BSplineSurface; - myBspl = Handle(Geom_BSplineSurface)::DownCast (mySurface); + Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface); // Create cache for B-spline - mySurfaceCache = new BSplSLib_Cache( + mySurfaceCache = new BSplSLib_Cache( myBspl->UDegree(), myBspl->IsUPeriodic(), myBspl->UKnotSequence(), myBspl->VDegree(), myBspl->IsVPeriodic(), myBspl->VKnotSequence(), myBspl->Poles(), myBspl->Weights()); } - else if ( TheType == STANDARD_TYPE(Geom_OffsetSurface)) + else if (TheType == STANDARD_TYPE(Geom_OffsetSurface)) + { mySurfaceType = GeomAbs_OffsetSurface; + Handle(Geom_OffsetSurface) myOffSurf = Handle(Geom_OffsetSurface)::DownCast(mySurface); + // Create nested adaptor for base surface + Handle(Geom_Surface) aBaseSurf = myOffSurf->BasisSurface(); + Handle(GeomAdaptor_HSurface) aBaseAdaptor = + new GeomAdaptor_HSurface(aBaseSurf, myUFirst, myULast, myVFirst, myVLast, myTolU, myTolV); + myNestedEvaluator = new GeomEvaluator_OffsetSurface( + aBaseAdaptor, myOffSurf->Offset(), myOffSurf->OsculatingSurface()); + } else mySurfaceType = GeomAbs_OtherSurface; } @@ -192,6 +221,7 @@ GeomAbs_Shape GeomAdaptor_Surface::UContinuity() const { case GeomAbs_BSplineSurface: { + Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface); const Standard_Integer N = myBspl->NbUKnots(); TColStd_Array1OfReal TK(1,N); TColStd_Array1OfInteger TM(1,N); @@ -217,8 +247,9 @@ GeomAbs_Shape GeomAdaptor_Surface::UContinuity() const } case GeomAbs_SurfaceOfExtrusion: { - GeomAdaptor_Curve GC - (Handle(Geom_SurfaceOfLinearExtrusion)::DownCast (mySurface)->BasisCurve(),myUFirst,myULast); + Handle(Geom_SurfaceOfLinearExtrusion) myExtSurf = + Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(mySurface); + GeomAdaptor_Curve GC(myExtSurf->BasisCurve(), myUFirst, myULast); return GC.Continuity(); } case GeomAbs_OtherSurface: @@ -245,6 +276,7 @@ GeomAbs_Shape GeomAdaptor_Surface::VContinuity() const { case GeomAbs_BSplineSurface: { + Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface); const Standard_Integer N = myBspl->NbVKnots(); TColStd_Array1OfReal TK(1,N); TColStd_Array1OfInteger TM(1,N); @@ -270,8 +302,9 @@ GeomAbs_Shape GeomAdaptor_Surface::VContinuity() const } case GeomAbs_SurfaceOfRevolution: { - GeomAdaptor_Curve GC - (Handle(Geom_SurfaceOfRevolution)::DownCast (mySurface)->BasisCurve(),myVFirst,myVLast); + Handle(Geom_SurfaceOfRevolution) myRevSurf = + Handle(Geom_SurfaceOfRevolution)::DownCast(mySurface); + GeomAdaptor_Curve GC(myRevSurf->BasisCurve(), myVFirst, myVLast); return GC.Continuity(); } case GeomAbs_OtherSurface: @@ -298,15 +331,17 @@ Standard_Integer GeomAdaptor_Surface::NbUIntervals(const GeomAbs_Shape S) const { case GeomAbs_BSplineSurface: { + Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface); GeomAdaptor_Curve myBasisCurve (myBspl->VIso(myBspl->VKnot(myBspl->FirstVKnotIndex())),myUFirst,myULast); return myBasisCurve.NbIntervals(S); } case GeomAbs_SurfaceOfExtrusion: { - GeomAdaptor_Curve myBasisCurve - (Handle(Geom_SurfaceOfLinearExtrusion)::DownCast (mySurface)->BasisCurve(),myUFirst,myULast); - if (myBasisCurve.GetType() == GeomAbs_BSplineCurve) + Handle(Geom_SurfaceOfLinearExtrusion) myExtSurf = + Handle(Geom_SurfaceOfLinearExtrusion)::DownCast(mySurface); + GeomAdaptor_Curve myBasisCurve(myExtSurf->BasisCurve(), myUFirst, myULast); + if (myBasisCurve.GetType() == GeomAbs_BSplineCurve) return myBasisCurve.NbIntervals(S); break; } @@ -323,7 +358,8 @@ Standard_Integer GeomAdaptor_Surface::NbUIntervals(const GeomAbs_Shape S) const case GeomAbs_C3: case GeomAbs_CN: break; } - GeomAdaptor_Surface Sur(Handle(Geom_OffsetSurface)::DownCast (mySurface)->BasisSurface()); + Handle(Geom_OffsetSurface) myOffSurf = Handle(Geom_OffsetSurface)::DownCast(mySurface); + GeomAdaptor_Surface Sur(myOffSurf->BasisSurface()); return Sur.NbUIntervals(BaseS); } case GeomAbs_Plane: @@ -349,19 +385,21 @@ Standard_Integer GeomAdaptor_Surface::NbVIntervals(const GeomAbs_Shape S) const { case GeomAbs_BSplineSurface: { + Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface); GeomAdaptor_Curve myBasisCurve (myBspl->UIso(myBspl->UKnot(myBspl->FirstUKnotIndex())),myVFirst,myVLast); return myBasisCurve.NbIntervals(S); } - case GeomAbs_SurfaceOfRevolution: + case GeomAbs_SurfaceOfRevolution: { - GeomAdaptor_Curve myBasisCurve - (Handle(Geom_SurfaceOfRevolution)::DownCast (mySurface)->BasisCurve(),myVFirst,myVLast); - if (myBasisCurve.GetType() == GeomAbs_BSplineCurve) + Handle(Geom_SurfaceOfRevolution) myRevSurf = + Handle(Geom_SurfaceOfRevolution)::DownCast(mySurface); + GeomAdaptor_Curve myBasisCurve(myRevSurf->BasisCurve(), myVFirst, myVLast); + if (myBasisCurve.GetType() == GeomAbs_BSplineCurve) return myBasisCurve.NbIntervals(S); break; } - case GeomAbs_OffsetSurface: + case GeomAbs_OffsetSurface: { GeomAbs_Shape BaseS = GeomAbs_CN; switch(S) @@ -374,9 +412,10 @@ Standard_Integer GeomAdaptor_Surface::NbVIntervals(const GeomAbs_Shape S) const case GeomAbs_C3: case GeomAbs_CN: break; } - GeomAdaptor_Surface Sur(Handle(Geom_OffsetSurface)::DownCast (mySurface)->BasisSurface()); + Handle(Geom_OffsetSurface) myOffSurf = Handle(Geom_OffsetSurface)::DownCast(mySurface); + GeomAdaptor_Surface Sur(myOffSurf->BasisSurface()); return Sur.NbVIntervals(BaseS); - } + } case GeomAbs_Plane: case GeomAbs_Cylinder: case GeomAbs_Cone: @@ -402,13 +441,14 @@ void GeomAdaptor_Surface::UIntervals(TColStd_Array1OfReal& T, const GeomAbs_Shap { case GeomAbs_BSplineSurface: { + Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface); GeomAdaptor_Curve myBasisCurve (myBspl->VIso(myBspl->VKnot(myBspl->FirstVKnotIndex())),myUFirst,myULast); myNbUIntervals = myBasisCurve.NbIntervals(S); myBasisCurve.Intervals(T,S); break; } - case GeomAbs_SurfaceOfExtrusion: + case GeomAbs_SurfaceOfExtrusion: { GeomAdaptor_Curve myBasisCurve (Handle(Geom_SurfaceOfLinearExtrusion)::DownCast (mySurface)->BasisCurve(),myUFirst,myULast); @@ -419,7 +459,7 @@ void GeomAdaptor_Surface::UIntervals(TColStd_Array1OfReal& T, const GeomAbs_Shap } break; } - case GeomAbs_OffsetSurface: + case GeomAbs_OffsetSurface: { GeomAbs_Shape BaseS = GeomAbs_CN; switch(S) @@ -432,7 +472,8 @@ void GeomAdaptor_Surface::UIntervals(TColStd_Array1OfReal& T, const GeomAbs_Shap case GeomAbs_C3: case GeomAbs_CN: break; } - GeomAdaptor_Surface Sur(Handle(Geom_OffsetSurface)::DownCast (mySurface)->BasisSurface()); + Handle(Geom_OffsetSurface) myOffSurf = Handle(Geom_OffsetSurface)::DownCast(mySurface); + GeomAdaptor_Surface Sur(myOffSurf->BasisSurface()); myNbUIntervals = Sur.NbUIntervals(BaseS); Sur.UIntervals(T, BaseS); } @@ -463,16 +504,18 @@ void GeomAdaptor_Surface::VIntervals(TColStd_Array1OfReal& T, const GeomAbs_Shap { case GeomAbs_BSplineSurface: { + Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface); GeomAdaptor_Curve myBasisCurve (myBspl->UIso(myBspl->UKnot(myBspl->FirstUKnotIndex())),myVFirst,myVLast); myNbVIntervals = myBasisCurve.NbIntervals(S); myBasisCurve.Intervals(T,S); break; } - case GeomAbs_SurfaceOfRevolution: + case GeomAbs_SurfaceOfRevolution: { - GeomAdaptor_Curve myBasisCurve - (Handle(Geom_SurfaceOfRevolution)::DownCast (mySurface)->BasisCurve(),myVFirst,myVLast); + Handle(Geom_SurfaceOfRevolution) myRevSurf = + Handle(Geom_SurfaceOfRevolution)::DownCast(mySurface); + GeomAdaptor_Curve myBasisCurve(myRevSurf->BasisCurve(), myVFirst, myVLast); if (myBasisCurve.GetType() == GeomAbs_BSplineCurve) { myNbVIntervals = myBasisCurve.NbIntervals(S); @@ -480,7 +523,7 @@ void GeomAdaptor_Surface::VIntervals(TColStd_Array1OfReal& T, const GeomAbs_Shap } break; } - case GeomAbs_OffsetSurface: + case GeomAbs_OffsetSurface: { GeomAbs_Shape BaseS = GeomAbs_CN; switch(S) @@ -493,7 +536,8 @@ void GeomAdaptor_Surface::VIntervals(TColStd_Array1OfReal& T, const GeomAbs_Shap case GeomAbs_C3: case GeomAbs_CN: break; } - GeomAdaptor_Surface Sur(Handle(Geom_OffsetSurface)::DownCast (mySurface)->BasisSurface()); + Handle(Geom_OffsetSurface) myOffSurf = Handle(Geom_OffsetSurface)::DownCast(mySurface); + GeomAdaptor_Surface Sur(myOffSurf->BasisSurface()); myNbVIntervals = Sur.NbVIntervals(BaseS); Sur.VIntervals(T, BaseS); } @@ -624,7 +668,8 @@ Standard_Real GeomAdaptor_Surface::VPeriod() const void GeomAdaptor_Surface::RebuildCache(const Standard_Real theU, const Standard_Real theV) const { - mySurfaceCache->BuildCache(theU, theV, + Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface); + mySurfaceCache->BuildCache(theU, theV, myBspl->UDegree(), myBspl->IsUPeriodic(), myBspl->UKnotSequence(), myBspl->VDegree(), myBspl->IsVPeriodic(), myBspl->VKnotSequence(), myBspl->Poles(), myBspl->Weights()); @@ -638,16 +683,9 @@ void GeomAdaptor_Surface::RebuildCache(const Standard_Real theU, gp_Pnt GeomAdaptor_Surface::Value(const Standard_Real U, const Standard_Real V) const { - if (mySurfaceType == GeomAbs_BSplineSurface && !mySurfaceCache.IsNull()) - { - if (!mySurfaceCache->IsCacheValid(U, V)) - RebuildCache(U, V); - gp_Pnt P; - mySurfaceCache->D0(U, V, P); - return P; - } - - return mySurface->Value(U,V); + gp_Pnt aValue; + D0(U, V, aValue); + return aValue; } //======================================================================= @@ -658,15 +696,30 @@ gp_Pnt GeomAdaptor_Surface::Value(const Standard_Real U, void GeomAdaptor_Surface::D0(const Standard_Real U, const Standard_Real V, gp_Pnt& P) const { - if (mySurfaceType == GeomAbs_BSplineSurface && !mySurfaceCache.IsNull()) + switch (mySurfaceType) { - if (!mySurfaceCache->IsCacheValid(U, V)) - RebuildCache(U, V); - mySurfaceCache->D0(U, V, P); - return; - } + case GeomAbs_BSplineSurface: + if (!mySurfaceCache.IsNull()) + { + if (!mySurfaceCache->IsCacheValid(U, V)) + RebuildCache(U, V); + mySurfaceCache->D0(U, V, P); + } + else + mySurface->D0(U, V, P); + break; - mySurface->D0(U,V,P); + case GeomAbs_OffsetSurface: + case GeomAbs_SurfaceOfExtrusion: + case GeomAbs_SurfaceOfRevolution: + Standard_NoSuchObject_Raise_if(myNestedEvaluator.IsNull(), + "GeomAdaptor_Surface::D0: evaluator is not initialized"); + myNestedEvaluator->D0(U, V, P); + break; + + default: + mySurface->D0(U, V, P); + } } @@ -689,8 +742,9 @@ void GeomAdaptor_Surface::D1(const Standard_Real U, else if (Abs(V-myVLast) <= myTolV) {VSide= -1; v = myVLast;} switch(mySurfaceType) { - case GeomAbs_BSplineSurface: - if ((USide != 0 || VSide != 0) && + case GeomAbs_BSplineSurface: { + Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface); + if ((USide != 0 || VSide != 0) && IfUVBound(u, v, Ideb, Ifin, IVdeb, IVfin, USide, VSide)) myBspl->LocalD1(u, v, Ideb, Ifin, IVdeb, IVfin, P, D1U, D1V); else if (!mySurfaceCache.IsNull()) @@ -702,27 +756,16 @@ void GeomAdaptor_Surface::D1(const Standard_Real U, else myBspl->D1(u, v, P, D1U, D1V); break; + } case GeomAbs_SurfaceOfExtrusion: - if (USide==0) - myExtSurf->D1(u, v, P, D1U, D1V); - else - myExtSurf->LocalD1(u, v, USide, P, D1U, D1V); - break; - case GeomAbs_SurfaceOfRevolution: - if (VSide==0) - myRevSurf->D1(u, v, P, D1U, D1V); - else - myRevSurf->LocalD1(u, v, VSide, P, D1U, D1V); + case GeomAbs_OffsetSurface: + Standard_NoSuchObject_Raise_if(myNestedEvaluator.IsNull(), + "GeomAdaptor_Surface::D1: evaluator is not initialized"); + myNestedEvaluator->D1(u, v, P, D1U, D1V); break; - case GeomAbs_OffsetSurface: - if (USide==0 && VSide==0) - myOffSurf->D1(u, v, P, D1U, D1V); - else - myOffSurf->LocalD1(u, v, USide, VSide, P, D1U, D1V); - break; default: mySurface->D1(u, v, P, D1U, D1V); } @@ -750,9 +793,10 @@ void GeomAdaptor_Surface::D2(const Standard_Real U, else if (Abs(V-myVLast) <= myTolV) {VSide= -1; v = myVLast;} switch(mySurfaceType) { - case GeomAbs_BSplineSurface: - if((USide != 0 || VSide != 0) && - IfUVBound(u, v, Ideb, Ifin, IVdeb, IVfin, USide, VSide)) + case GeomAbs_BSplineSurface: { + Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface); + if ((USide != 0 || VSide != 0) && + IfUVBound(u, v, Ideb, Ifin, IVdeb, IVfin, USide, VSide)) myBspl->LocalD2(u, v, Ideb, Ifin, IVdeb, IVfin, P, D1U, D1V, D2U, D2V, D2UV); else if (!mySurfaceCache.IsNull()) { @@ -760,28 +804,19 @@ void GeomAdaptor_Surface::D2(const Standard_Real U, RebuildCache(U, V); mySurfaceCache->D2(U, V, P, D1U, D1V, D2U, D2V, D2UV); } - else myBspl->D2(u,v,P,D1U,D1V,D2U,D2V,D2UV); - break; - - case GeomAbs_SurfaceOfExtrusion : - - if(USide==0) myExtSurf->D2(u,v,P,D1U,D1V,D2U,D2V,D2UV); - else myExtSurf->LocalD2(u,v,USide,P,D1U,D1V,D2U,D2V,D2UV); - break; - - case GeomAbs_SurfaceOfRevolution : - - if(VSide==0) myRevSurf->D2 (u, v, P,D1U,D1V,D2U,D2V,D2UV ); - else myRevSurf->LocalD2 (u, v, VSide, P,D1U,D1V,D2U,D2V,D2UV ); + else myBspl->D2(u, v, P, D1U, D1V, D2U, D2V, D2UV); break; + } + case GeomAbs_SurfaceOfExtrusion: + case GeomAbs_SurfaceOfRevolution: case GeomAbs_OffsetSurface : - { - if((USide==0)&&(VSide==0)) myOffSurf->D2 (u, v,P,D1U,D1V,D2U,D2V,D2UV ); - else myOffSurf->LocalD2 (u, v, USide, VSide ,P,D1U,D1V,D2U,D2V,D2UV ); - break; - } - default : { mySurface->D2(u,v,P,D1U,D1V,D2U,D2V,D2UV); + Standard_NoSuchObject_Raise_if(myNestedEvaluator.IsNull(), + "GeomAdaptor_Surface::D2: evaluator is not initialized"); + myNestedEvaluator->D2(u, v, P, D1U, D1V, D2U, D2V, D2UV); + break; + + default: { mySurface->D2(u, v, P, D1U, D1V, D2U, D2V, D2UV); break;} } } @@ -806,43 +841,29 @@ void GeomAdaptor_Surface::D3(const Standard_Real U, const Standard_Real V, else if (Abs(V-myVLast) <= myTolV) {VSide= -1; v = myVLast;} switch(mySurfaceType) { - case GeomAbs_BSplineSurface: - - if((USide==0)&&(VSide==0)) - myBspl->D3(u,v,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - else { - if(IfUVBound(u,v,Ideb,Ifin,IVdeb,IVfin,USide,VSide)) - myBspl-> LocalD3 (u, v, Ideb, Ifin,IVdeb ,IVfin , - P ,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - else - myBspl->D3(u,v,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - } - break; - - case GeomAbs_SurfaceOfExtrusion : - - if(USide==0) myExtSurf->D3(u,v,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); - else myExtSurf->LocalD3(u,v,USide,P,D1U,D1V,D2U,D2V,D2UV, - D3U,D3V,D3UUV,D3UVV); - break; - - case GeomAbs_SurfaceOfRevolution : - - if(VSide==0) myRevSurf->D3 (u, v, P ,D1U,D1V,D2U,D2V,D2UV, - D3U,D3V,D3UUV,D3UVV); - else myRevSurf->LocalD3 (u, v, VSide, P,D1U,D1V,D2U,D2V,D2UV, - D3U,D3V,D3UUV,D3UVV ); - break; - - case GeomAbs_OffsetSurface : - { - if((USide==0)&&(VSide==0)) myOffSurf->D3 (u, v,P ,D1U,D1V,D2U,D2V,D2UV, - D3U,D3V,D3UUV,D3UVV); - else myOffSurf->LocalD3 (u, v, USide, VSide ,P ,D1U,D1V,D2U,D2V,D2UV, - D3U,D3V,D3UUV,D3UVV); - break; + case GeomAbs_BSplineSurface: { + Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface); + if ((USide == 0) && (VSide == 0)) + myBspl->D3(u, v, P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); + else { + if (IfUVBound(u, v, Ideb, Ifin, IVdeb, IVfin, USide, VSide)) + myBspl->LocalD3(u, v, Ideb, Ifin, IVdeb, IVfin, + P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); + else + myBspl->D3(u, v, P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); } - default : { mySurface->D3(u,v,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); + break; + } + + case GeomAbs_SurfaceOfExtrusion: + case GeomAbs_SurfaceOfRevolution: + case GeomAbs_OffsetSurface: + Standard_NoSuchObject_Raise_if(myNestedEvaluator.IsNull(), + "GeomAdaptor_Surface::D3: evaluator is not initialized"); + myNestedEvaluator->D3(u, v, P, D1U, D1V, D2U, D2V, D2UV, D3U, D3V, D3UUV, D3UVV); + break; + + default : { mySurface->D3(u,v,P,D1U,D1V,D2U,D2V,D2UV,D3U,D3V,D3UUV,D3UVV); break;} } } @@ -866,30 +887,24 @@ gp_Vec GeomAdaptor_Surface::DN(const Standard_Real U, switch(mySurfaceType) { - case GeomAbs_BSplineSurface: - - if((USide==0)&&(VSide==0)) return myBspl->DN(u,v,Nu,Nv); + case GeomAbs_BSplineSurface: { + Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface); + if ((USide == 0) && (VSide == 0)) + return myBspl->DN(u, v, Nu, Nv); else { - if(IfUVBound(u,v,Ideb,Ifin,IVdeb,IVfin,USide,VSide)) - return myBspl->LocalDN (u, v, Ideb, Ifin,IVdeb ,IVfin ,Nu,Nv ); + if (IfUVBound(u, v, Ideb, Ifin, IVdeb, IVfin, USide, VSide)) + return myBspl->LocalDN(u, v, Ideb, Ifin, IVdeb, IVfin, Nu, Nv); else - return myBspl->DN(u,v,Nu,Nv); + return myBspl->DN(u, v, Nu, Nv); } - - case GeomAbs_SurfaceOfExtrusion: - - if(USide==0) return myExtSurf-> DN (u, v,Nu,Nv ); - else return myExtSurf->LocalDN (u, v, USide,Nu,Nv ); - - case GeomAbs_SurfaceOfRevolution: + } - if(VSide==0) return myRevSurf->DN (u, v, Nu, Nv ); - else return myRevSurf->LocalDN (u, v,VSide, Nu, Nv ); - + case GeomAbs_SurfaceOfExtrusion: + case GeomAbs_SurfaceOfRevolution: case GeomAbs_OffsetSurface: - - if((USide==0)&&(VSide==0)) return myOffSurf->DN (u, v, Nu, Nv ); - else return myOffSurf->LocalDN (u, v, USide, VSide, Nu, Nv ); + Standard_NoSuchObject_Raise_if(myNestedEvaluator.IsNull(), + "GeomAdaptor_Surface::DN: evaluator is not initialized"); + return myNestedEvaluator->DN(u, v, Nu, Nv); case GeomAbs_Plane: case GeomAbs_Cylinder: @@ -1370,7 +1385,8 @@ Standard_Boolean GeomAdaptor_Surface::IfUVBound(const Standard_Real U, const Standard_Integer VSide) const { Standard_Integer Ideb,Ifin; - Standard_Integer anUFKIndx = myBspl->FirstUKnotIndex(), + Handle(Geom_BSplineSurface) myBspl = Handle(Geom_BSplineSurface)::DownCast(mySurface); + Standard_Integer anUFKIndx = myBspl->FirstUKnotIndex(), anULKIndx = myBspl->LastUKnotIndex(), aVFKIndx = myBspl->FirstVKnotIndex(), aVLKIndx = myBspl->LastVKnotIndex(); myBspl->LocateU(U, PosTol, Ideb, Ifin, Standard_False); diff --git a/src/GeomAdaptor/GeomAdaptor_Surface.hxx b/src/GeomAdaptor/GeomAdaptor_Surface.hxx index 1baa0c7a74..24bfcaf3b7 100644 --- a/src/GeomAdaptor/GeomAdaptor_Surface.hxx +++ b/src/GeomAdaptor/GeomAdaptor_Surface.hxx @@ -29,6 +29,7 @@ #include #include #include +#include class Geom_Surface; class Standard_NoSuchObject; class Standard_OutOfRange; @@ -259,16 +260,17 @@ private: Handle(Geom_Surface) mySurface; - GeomAbs_SurfaceType mySurfaceType; Standard_Real myUFirst; Standard_Real myULast; Standard_Real myVFirst; Standard_Real myVLast; Standard_Real myTolU; Standard_Real myTolV; - Handle(BSplSLib_Cache) mySurfaceCache; - + Handle(BSplSLib_Cache) mySurfaceCache; ///< Cached data for B-spline surface +protected: + GeomAbs_SurfaceType mySurfaceType; + Handle(GeomEvaluator_Surface) myNestedEvaluator; ///< Calculates values of nested complex surfaces (offset surface, surface of extrusion or revolution) }; diff --git a/src/GeomAdaptor/GeomAdaptor_Surface.lxx b/src/GeomAdaptor/GeomAdaptor_Surface.lxx index 92e58bc299..5b6f2eb10c 100644 --- a/src/GeomAdaptor/GeomAdaptor_Surface.lxx +++ b/src/GeomAdaptor/GeomAdaptor_Surface.lxx @@ -24,13 +24,13 @@ //======================================================================= inline GeomAdaptor_Surface::GeomAdaptor_Surface() - : mySurfaceType(GeomAbs_OtherSurface), - myUFirst(0.), + : myUFirst(0.), myULast(0.), myVFirst(0.), myVLast (0.), myTolU(0.), - myTolV(0.) + myTolV(0.), + mySurfaceType(GeomAbs_OtherSurface) { } diff --git a/src/Adaptor3d/Adaptor3d_SurfaceOfLinearExtrusion.cxx b/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.cxx similarity index 51% rename from src/Adaptor3d/Adaptor3d_SurfaceOfLinearExtrusion.cxx rename to src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.cxx index 6eec03e0c6..1333b6c0b9 100644 --- a/src/Adaptor3d/Adaptor3d_SurfaceOfLinearExtrusion.cxx +++ b/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.cxx @@ -14,57 +14,45 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include -#include //======================================================================= -//function : Adaptor3d_SurfaceOfLinearExtrusion +//function : GeomAdaptor_SurfaceOfLinearExtrusion //purpose : //======================================================================= -Adaptor3d_SurfaceOfLinearExtrusion::Adaptor3d_SurfaceOfLinearExtrusion() +GeomAdaptor_SurfaceOfLinearExtrusion::GeomAdaptor_SurfaceOfLinearExtrusion() + : myHaveDir(Standard_False) {} //======================================================================= -//function : Adaptor3d_SurfaceOfLinearExtrusion +//function : GeomAdaptor_SurfaceOfLinearExtrusion //purpose : //======================================================================= -Adaptor3d_SurfaceOfLinearExtrusion::Adaptor3d_SurfaceOfLinearExtrusion +GeomAdaptor_SurfaceOfLinearExtrusion::GeomAdaptor_SurfaceOfLinearExtrusion (const Handle(Adaptor3d_HCurve)& C) + : myHaveDir(Standard_False) { - Load( C); + Load(C); } //======================================================================= -//function : Adaptor3d_SurfaceOfLinearExtrusion +//function : GeomAdaptor_SurfaceOfLinearExtrusion //purpose : //======================================================================= -Adaptor3d_SurfaceOfLinearExtrusion::Adaptor3d_SurfaceOfLinearExtrusion +GeomAdaptor_SurfaceOfLinearExtrusion::GeomAdaptor_SurfaceOfLinearExtrusion (const Handle(Adaptor3d_HCurve)& C, const gp_Dir& V) + : myHaveDir(Standard_False) { - Load( C); - Load( V); + Load(C); + Load(V); } //======================================================================= @@ -72,9 +60,11 @@ Adaptor3d_SurfaceOfLinearExtrusion::Adaptor3d_SurfaceOfLinearExtrusion //purpose : //======================================================================= -void Adaptor3d_SurfaceOfLinearExtrusion::Load( const Handle(Adaptor3d_HCurve)& C) +void GeomAdaptor_SurfaceOfLinearExtrusion::Load(const Handle(Adaptor3d_HCurve)& C) { myBasisCurve = C; + if (myHaveDir) + Load(myDirection); } //======================================================================= @@ -82,9 +72,13 @@ void Adaptor3d_SurfaceOfLinearExtrusion::Load( const Handle(Adaptor3d_HCurve)& C //purpose : //======================================================================= -void Adaptor3d_SurfaceOfLinearExtrusion::Load( const gp_Dir& V) +void GeomAdaptor_SurfaceOfLinearExtrusion::Load(const gp_Dir& V) { + myHaveDir = Standard_True; myDirection = V; + + mySurfaceType = GeomAbs_SurfaceOfExtrusion; + myNestedEvaluator = new GeomEvaluator_SurfaceOfExtrusion(myBasisCurve, myDirection); } //======================================================================= @@ -92,7 +86,7 @@ void Adaptor3d_SurfaceOfLinearExtrusion::Load( const gp_Dir& V) //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::FirstUParameter() const +Standard_Real GeomAdaptor_SurfaceOfLinearExtrusion::FirstUParameter() const { return myBasisCurve->FirstParameter(); } @@ -102,7 +96,7 @@ Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::FirstUParameter() const //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::LastUParameter() const +Standard_Real GeomAdaptor_SurfaceOfLinearExtrusion::LastUParameter() const { return myBasisCurve->LastParameter(); } @@ -112,7 +106,7 @@ Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::LastUParameter() const //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::FirstVParameter() const +Standard_Real GeomAdaptor_SurfaceOfLinearExtrusion::FirstVParameter() const { return RealFirst(); } @@ -122,7 +116,7 @@ Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::FirstVParameter() const //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::LastVParameter() const +Standard_Real GeomAdaptor_SurfaceOfLinearExtrusion::LastVParameter() const { return RealLast(); } @@ -132,7 +126,7 @@ Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::LastVParameter() const //purpose : //======================================================================= -GeomAbs_Shape Adaptor3d_SurfaceOfLinearExtrusion::UContinuity() const +GeomAbs_Shape GeomAdaptor_SurfaceOfLinearExtrusion::UContinuity() const { return myBasisCurve->Continuity(); } @@ -142,7 +136,7 @@ GeomAbs_Shape Adaptor3d_SurfaceOfLinearExtrusion::UContinuity() const //purpose : //======================================================================= -GeomAbs_Shape Adaptor3d_SurfaceOfLinearExtrusion::VContinuity() const +GeomAbs_Shape GeomAdaptor_SurfaceOfLinearExtrusion::VContinuity() const { return GeomAbs_CN; } @@ -152,7 +146,7 @@ GeomAbs_Shape Adaptor3d_SurfaceOfLinearExtrusion::VContinuity() const //purpose : //======================================================================= -Standard_Integer Adaptor3d_SurfaceOfLinearExtrusion::NbUIntervals +Standard_Integer GeomAdaptor_SurfaceOfLinearExtrusion::NbUIntervals (const GeomAbs_Shape S) const { return myBasisCurve->NbIntervals(S); @@ -163,7 +157,7 @@ Standard_Integer Adaptor3d_SurfaceOfLinearExtrusion::NbUIntervals //purpose : //======================================================================= -Standard_Integer Adaptor3d_SurfaceOfLinearExtrusion::NbVIntervals +Standard_Integer GeomAdaptor_SurfaceOfLinearExtrusion::NbVIntervals (const GeomAbs_Shape ) const { return 1; @@ -174,7 +168,7 @@ Standard_Integer Adaptor3d_SurfaceOfLinearExtrusion::NbVIntervals //purpose : //======================================================================= -void Adaptor3d_SurfaceOfLinearExtrusion::UIntervals +void GeomAdaptor_SurfaceOfLinearExtrusion::UIntervals (TColStd_Array1OfReal& T, const GeomAbs_Shape S) const { myBasisCurve->Intervals(T,S); @@ -185,8 +179,7 @@ void Adaptor3d_SurfaceOfLinearExtrusion::UIntervals //purpose : //======================================================================= -void Adaptor3d_SurfaceOfLinearExtrusion::VIntervals -//(TColStd_Array1OfReal& T, const GeomAbs_Shape S) const +void GeomAdaptor_SurfaceOfLinearExtrusion::VIntervals (TColStd_Array1OfReal& T, const GeomAbs_Shape ) const { T(T.Lower()) = FirstVParameter() ; @@ -198,18 +191,15 @@ void Adaptor3d_SurfaceOfLinearExtrusion::VIntervals //purpose : //======================================================================= -Handle(Adaptor3d_HSurface) Adaptor3d_SurfaceOfLinearExtrusion::VTrim -(const Standard_Real First , +Handle(Adaptor3d_HSurface) GeomAdaptor_SurfaceOfLinearExtrusion::VTrim +(const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const { - Handle(Adaptor3d_HCurve) newBasisCurve = - myBasisCurve->Trim(First, Last, Tol); - - Adaptor3d_SurfaceOfLinearExtrusion * SurfacePtr = - new Adaptor3d_SurfaceOfLinearExtrusion(newBasisCurve, myDirection) ; - - return new Adaptor3d_HSurfaceOfLinearExtrusion(*SurfacePtr); + Handle(Adaptor3d_HCurve) HC = BasisCurve()->Trim(First,Last,Tol); + Handle(GeomAdaptor_HSurfaceOfLinearExtrusion) HR = new GeomAdaptor_HSurfaceOfLinearExtrusion( + GeomAdaptor_SurfaceOfLinearExtrusion(HC, myDirection)); + return HR; } //======================================================================= @@ -217,18 +207,14 @@ Handle(Adaptor3d_HSurface) Adaptor3d_SurfaceOfLinearExtrusion::VTrim //purpose : //======================================================================= -Handle(Adaptor3d_HSurface) Adaptor3d_SurfaceOfLinearExtrusion::UTrim -//(const Standard_Real First , -// const Standard_Real Last, -// const Standard_Real Tol) const +Handle(Adaptor3d_HSurface) GeomAdaptor_SurfaceOfLinearExtrusion::UTrim (const Standard_Real , const Standard_Real , const Standard_Real ) const { - Adaptor3d_SurfaceOfLinearExtrusion * SurfacePtr = - new Adaptor3d_SurfaceOfLinearExtrusion(myBasisCurve,myDirection); - - return new Adaptor3d_HSurfaceOfLinearExtrusion(*SurfacePtr) ; + Handle(GeomAdaptor_HSurfaceOfLinearExtrusion) HR = new GeomAdaptor_HSurfaceOfLinearExtrusion( + GeomAdaptor_SurfaceOfLinearExtrusion(myBasisCurve, myDirection)); + return HR; } //======================================================================= @@ -236,7 +222,7 @@ Handle(Adaptor3d_HSurface) Adaptor3d_SurfaceOfLinearExtrusion::UTrim //purpose : //======================================================================= -Standard_Boolean Adaptor3d_SurfaceOfLinearExtrusion::IsUClosed() const +Standard_Boolean GeomAdaptor_SurfaceOfLinearExtrusion::IsUClosed() const { return myBasisCurve->IsClosed(); } @@ -246,9 +232,9 @@ Standard_Boolean Adaptor3d_SurfaceOfLinearExtrusion::IsUClosed() const //purpose : //======================================================================= -Standard_Boolean Adaptor3d_SurfaceOfLinearExtrusion::IsVClosed() const +Standard_Boolean GeomAdaptor_SurfaceOfLinearExtrusion::IsVClosed() const { - return Standard_True; + return Standard_False; } //======================================================================= @@ -256,7 +242,7 @@ Standard_Boolean Adaptor3d_SurfaceOfLinearExtrusion::IsVClosed() const //purpose : //======================================================================= -Standard_Boolean Adaptor3d_SurfaceOfLinearExtrusion::IsUPeriodic() const +Standard_Boolean GeomAdaptor_SurfaceOfLinearExtrusion::IsUPeriodic() const { return myBasisCurve->IsPeriodic(); } @@ -266,7 +252,7 @@ Standard_Boolean Adaptor3d_SurfaceOfLinearExtrusion::IsUPeriodic() const //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::UPeriod() const +Standard_Real GeomAdaptor_SurfaceOfLinearExtrusion::UPeriod() const { return myBasisCurve->Period() ; } @@ -276,7 +262,7 @@ Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::UPeriod() const //purpose : //======================================================================= -Standard_Boolean Adaptor3d_SurfaceOfLinearExtrusion::IsVPeriodic() const +Standard_Boolean GeomAdaptor_SurfaceOfLinearExtrusion::IsVPeriodic() const { return Standard_False; } @@ -286,128 +272,18 @@ Standard_Boolean Adaptor3d_SurfaceOfLinearExtrusion::IsVPeriodic() const //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::VPeriod() const +Standard_Real GeomAdaptor_SurfaceOfLinearExtrusion::VPeriod() const { - Standard_DomainError::Raise("Adaptor3d_SurfaceOfLinearExtrusion::VPeriod"); + Standard_DomainError::Raise("GeomAdaptor_SurfaceOfLinearExtrusion::VPeriod"); return 0.0e0 ; } -//======================================================================= -//function : Value -//purpose : -//======================================================================= - -gp_Pnt Adaptor3d_SurfaceOfLinearExtrusion::Value(const Standard_Real U, - const Standard_Real V) - const -{ - gp_Pnt P; - P = myBasisCurve->Value(U); - P.Translate( V * gp_Vec(myDirection)); - return P; -} - -//======================================================================= -//function : D0 -//purpose : -//======================================================================= - -void Adaptor3d_SurfaceOfLinearExtrusion::D0(const Standard_Real U, - const Standard_Real V, - gp_Pnt& P) const -{ - myBasisCurve->D0(U,P); - P.Translate( V * gp_Vec(myDirection)); -} - -//======================================================================= -//function : D1 -//purpose : -//======================================================================= - -void Adaptor3d_SurfaceOfLinearExtrusion::D1(const Standard_Real U, - const Standard_Real V, - gp_Pnt& P, - gp_Vec& D1U, - gp_Vec& D1V) const -{ - myBasisCurve->D1(U,P,D1U); - D0(U,V,P); - D1V = gp_Vec(myDirection); -} - -//======================================================================= -//function : D2 -//purpose : -//======================================================================= - -void Adaptor3d_SurfaceOfLinearExtrusion::D2(const Standard_Real U, - const Standard_Real V, - gp_Pnt& P, - gp_Vec& D1U, gp_Vec& D1V, - gp_Vec& D2U, gp_Vec& D2V, - gp_Vec& D2UV) const -{ - myBasisCurve->D2(U,P,D1U,D2U); - D1V = gp_Vec(myDirection); - D2V.SetCoord( 0., 0., 0.); - D2UV.SetCoord( 0., 0., 0.); - D0(U,V,P); -} - -//======================================================================= -//function : D3 -//purpose : -//======================================================================= - -void Adaptor3d_SurfaceOfLinearExtrusion::D3(const Standard_Real U, - const Standard_Real V, - gp_Pnt& P, - gp_Vec& D1U, gp_Vec& D1V, - gp_Vec& D2U, gp_Vec& D2V, - gp_Vec& D2UV, - gp_Vec& D3U, gp_Vec& D3V, - gp_Vec& D3UUV, gp_Vec& D3UVV) const -{ - myBasisCurve->D3(U,P,D1U,D2U,D3U); - D1V = gp_Vec(myDirection); - D2V.SetCoord( 0., 0., 0.); - D2UV.SetCoord( 0., 0., 0.); - D3V.SetCoord( 0., 0., 0.); - D3UUV.SetCoord( 0., 0., 0.); - D3UVV.SetCoord( 0., 0., 0.); - D0(U,V,P); -} - -//======================================================================= -//function : DN -//purpose : -//======================================================================= - -gp_Vec Adaptor3d_SurfaceOfLinearExtrusion::DN -(const Standard_Real U, -// const Standard_Real V, - const Standard_Real , - const Standard_Integer NU, - const Standard_Integer NV) const -{ - if ( (NU+NV)<1 || NU<0 || NV<0) { - Standard_DomainError::Raise("Adaptor3d_SurfaceOfLinearExtrusion::DN"); - return gp_Vec(); - } - else { - if (NU == 0 && NV ==1) return gp_Vec( myDirection); - else if (NV == 0) return myBasisCurve->DN(U,NU); - else return gp_Vec( 0., 0., 0.); - } -} - //======================================================================= //function : UResolution //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::UResolution +Standard_Real GeomAdaptor_SurfaceOfLinearExtrusion::UResolution (const Standard_Real R3d) const { return myBasisCurve->Resolution(R3d); @@ -418,7 +294,7 @@ Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::UResolution //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::VResolution +Standard_Real GeomAdaptor_SurfaceOfLinearExtrusion::VResolution (const Standard_Real R3d) const { return R3d; @@ -429,74 +305,57 @@ Standard_Real Adaptor3d_SurfaceOfLinearExtrusion::VResolution //purpose : //======================================================================= -GeomAbs_SurfaceType Adaptor3d_SurfaceOfLinearExtrusion::GetType() const +GeomAbs_SurfaceType GeomAdaptor_SurfaceOfLinearExtrusion::GetType() const { switch ( myBasisCurve->GetType()) { case GeomAbs_Line: { gp_Dir D = myBasisCurve->Line().Direction(); - if (myDirection.IsParallel( D, Precision::Angular())) { - return GeomAbs_SurfaceOfExtrusion; - } - else { + if (!myDirection.IsParallel( D, Precision::Angular())) return GeomAbs_Plane; - } + break; } case GeomAbs_Circle: { gp_Dir D = (myBasisCurve->Circle()).Axis().Direction(); - if ( myDirection.IsParallel( D, Precision::Angular())) { + if ( myDirection.IsParallel( D, Precision::Angular())) return GeomAbs_Cylinder; - } - // JAG 10.11.95 - else if (myDirection.IsNormal(D, Precision::Angular())) { + else if (myDirection.IsNormal(D, Precision::Angular())) return GeomAbs_Plane; - } - else { - return GeomAbs_SurfaceOfExtrusion; - } + break; } - // JAG 10.11.95 case GeomAbs_Ellipse: { gp_Dir D = (myBasisCurve->Ellipse()).Axis().Direction(); - if (myDirection.IsNormal(D, Precision::Angular())) { + if (myDirection.IsNormal(D, Precision::Angular())) return GeomAbs_Plane; - } - else { - return GeomAbs_SurfaceOfExtrusion; - } + break; } case GeomAbs_Parabola: { gp_Dir D = (myBasisCurve->Parabola()).Axis().Direction(); - if (myDirection.IsNormal(D, Precision::Angular())) { + if (myDirection.IsNormal(D, Precision::Angular())) return GeomAbs_Plane; - } - else { - return GeomAbs_SurfaceOfExtrusion; - } + break; } case GeomAbs_Hyperbola: { gp_Dir D = (myBasisCurve->Hyperbola()).Axis().Direction(); - if (myDirection.IsNormal(D, Precision::Angular())) { + if (myDirection.IsNormal(D, Precision::Angular())) return GeomAbs_Plane; - } - else { - return GeomAbs_SurfaceOfExtrusion; - } + break; } default: - return GeomAbs_SurfaceOfExtrusion; - + break; } + + return GeomAbs_SurfaceOfExtrusion; } //======================================================================= @@ -504,20 +363,10 @@ GeomAbs_SurfaceType Adaptor3d_SurfaceOfLinearExtrusion::GetType() const //purpose : //======================================================================= -gp_Pln Adaptor3d_SurfaceOfLinearExtrusion::Plane() const +gp_Pln GeomAdaptor_SurfaceOfLinearExtrusion::Plane() const { Standard_NoSuchObject_Raise_if (GetType() != GeomAbs_Plane, - "Adaptor3d_SurfaceOfLinearExtrusion::Plane"); -/* - gp_Pnt P; - gp_Vec Ox, Oy; - D1( 0., 0., P, Ox, Oy); - gp_Ax3 Ax3(P,gp_Dir(Ox^Oy),gp_Dir(Ox)); - if (gp_Dir(Oy).Dot(Ax3.YDirection())<0.){ - Ax3.YReverse(); - } - return gp_Pln(Ax3); -*/ + "GeomAdaptor_SurfaceOfLinearExtrusion::Plane"); gp_Pnt P; gp_Vec D1u, newZ; @@ -554,11 +403,11 @@ gp_Pln Adaptor3d_SurfaceOfLinearExtrusion::Plane() const //purpose : //======================================================================= -gp_Cylinder Adaptor3d_SurfaceOfLinearExtrusion::Cylinder() const +gp_Cylinder GeomAdaptor_SurfaceOfLinearExtrusion::Cylinder() const { Standard_NoSuchObject_Raise_if (GetType() != GeomAbs_Cylinder, - "Adaptor3d_SurfaceOfLinearExtrusion::Cylinder"); + "GeomAdaptor_SurfaceOfLinearExtrusion::Cylinder"); gp_Circ C = myBasisCurve->Circle() ; gp_Ax3 Ax3(C.Position()); @@ -573,9 +422,9 @@ gp_Cylinder Adaptor3d_SurfaceOfLinearExtrusion::Cylinder() const //purpose : //======================================================================= -gp_Cone Adaptor3d_SurfaceOfLinearExtrusion::Cone() const +gp_Cone GeomAdaptor_SurfaceOfLinearExtrusion::Cone() const { - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfLinearExtrusion::Cone"); + Standard_NoSuchObject::Raise("GeomAdaptor_SurfaceOfLinearExtrusion::Cone"); return gp_Cone(); } @@ -584,9 +433,9 @@ gp_Cone Adaptor3d_SurfaceOfLinearExtrusion::Cone() const //purpose : //======================================================================= -gp_Sphere Adaptor3d_SurfaceOfLinearExtrusion::Sphere() const +gp_Sphere GeomAdaptor_SurfaceOfLinearExtrusion::Sphere() const { - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfLinearExtrusion::Sphere"); + Standard_NoSuchObject::Raise("GeomAdaptor_SurfaceOfLinearExtrusion::Sphere"); return gp_Sphere(); } @@ -595,9 +444,9 @@ gp_Sphere Adaptor3d_SurfaceOfLinearExtrusion::Sphere() const //purpose : //======================================================================= -gp_Torus Adaptor3d_SurfaceOfLinearExtrusion::Torus() const +gp_Torus GeomAdaptor_SurfaceOfLinearExtrusion::Torus() const { - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfLinearExtrusion::Torus"); + Standard_NoSuchObject::Raise("GeomAdaptor_SurfaceOfLinearExtrusion::Torus"); return gp_Torus(); } @@ -607,9 +456,9 @@ gp_Torus Adaptor3d_SurfaceOfLinearExtrusion::Torus() const //purpose : //======================================================================= -gp_Ax1 Adaptor3d_SurfaceOfLinearExtrusion::AxeOfRevolution() const +gp_Ax1 GeomAdaptor_SurfaceOfLinearExtrusion::AxeOfRevolution() const { - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfLinearExtrusion::Axes"); + Standard_NoSuchObject::Raise("GeomAdaptor_SurfaceOfLinearExtrusion::Axes"); return gp_Ax1(); } @@ -618,71 +467,29 @@ gp_Ax1 Adaptor3d_SurfaceOfLinearExtrusion::AxeOfRevolution() const //purpose : //======================================================================= -Standard_Integer Adaptor3d_SurfaceOfLinearExtrusion::UDegree() const +Standard_Integer GeomAdaptor_SurfaceOfLinearExtrusion::UDegree() const { - return myBasisCurve -> Degree(); + return myBasisCurve->Degree(); } //======================================================================= //function : NbUPoles //purpose : //======================================================================= -Standard_Integer Adaptor3d_SurfaceOfLinearExtrusion::NbUPoles() const +Standard_Integer GeomAdaptor_SurfaceOfLinearExtrusion::NbUPoles() const { return myBasisCurve->NbPoles(); } -//======================================================================= -//function : VDegree -//purpose : -//======================================================================= -Standard_Integer Adaptor3d_SurfaceOfLinearExtrusion::VDegree() const -{ - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfLinearExtrusion::VDegree"); - return 0; -} - -//======================================================================= -//function : NbVPoles -//purpose : -//======================================================================= - -Standard_Integer Adaptor3d_SurfaceOfLinearExtrusion::NbVPoles() const -{ - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfLinearExtrusion::NbVPoles"); - return 0; -} - -//======================================================================= -//function : NbUKnots -//purpose : -//======================================================================= - -Standard_Integer Adaptor3d_SurfaceOfLinearExtrusion::NbUKnots() const -{ - Standard_NoSuchObject::Raise - ("Adaptor3d_SurfaceOfLinearExtrusion::NbUKnots"); - return 0; -} -//======================================================================= -//function : NbVKnots -//purpose : -//======================================================================= - -Standard_Integer Adaptor3d_SurfaceOfLinearExtrusion::NbVKnots() const -{ - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfLinearExtrusion::NbVKnots"); - return 0; -} //======================================================================= //function : IsURational //purpose : //======================================================================= -Standard_Boolean Adaptor3d_SurfaceOfLinearExtrusion::IsURational() const +Standard_Boolean GeomAdaptor_SurfaceOfLinearExtrusion::IsURational() const { Standard_NoSuchObject::Raise - ("Adaptor3d_SurfaceOfLinearExtrusion::IsURational"); + ("GeomAdaptor_SurfaceOfLinearExtrusion::IsURational"); return Standard_False; } //======================================================================= @@ -690,10 +497,10 @@ Standard_Boolean Adaptor3d_SurfaceOfLinearExtrusion::IsURational() const //purpose : //======================================================================= -Standard_Boolean Adaptor3d_SurfaceOfLinearExtrusion::IsVRational() const +Standard_Boolean GeomAdaptor_SurfaceOfLinearExtrusion::IsVRational() const { Standard_NoSuchObject::Raise - ("Adaptor3d_SurfaceOfLinearExtrusion::IsVRational"); + ("GeomAdaptor_SurfaceOfLinearExtrusion::IsVRational"); return Standard_False; } //======================================================================= @@ -702,9 +509,9 @@ Standard_Boolean Adaptor3d_SurfaceOfLinearExtrusion::IsVRational() const //======================================================================= -Handle(Geom_BezierSurface) Adaptor3d_SurfaceOfLinearExtrusion::Bezier() const +Handle(Geom_BezierSurface) GeomAdaptor_SurfaceOfLinearExtrusion::Bezier() const { - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfLinearExtrusion::Axes"); + Standard_NoSuchObject::Raise("GeomAdaptor_SurfaceOfLinearExtrusion::Bezier"); return Handle(Geom_BezierSurface)() ; } @@ -713,9 +520,9 @@ Handle(Geom_BezierSurface) Adaptor3d_SurfaceOfLinearExtrusion::Bezier() const //purpose : //======================================================================= -Handle(Geom_BSplineSurface) Adaptor3d_SurfaceOfLinearExtrusion::BSpline() const +Handle(Geom_BSplineSurface) GeomAdaptor_SurfaceOfLinearExtrusion::BSpline() const { - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfLinearExtrusion::Axes"); + Standard_NoSuchObject::Raise("GeomAdaptor_SurfaceOfLinearExtrusion::BSpline"); return Handle(Geom_BSplineSurface)() ; } @@ -724,7 +531,7 @@ Handle(Geom_BSplineSurface) Adaptor3d_SurfaceOfLinearExtrusion::BSpline() const //purpose : //======================================================================= -gp_Dir Adaptor3d_SurfaceOfLinearExtrusion::Direction() const +gp_Dir GeomAdaptor_SurfaceOfLinearExtrusion::Direction() const { return myDirection; } @@ -734,7 +541,7 @@ gp_Dir Adaptor3d_SurfaceOfLinearExtrusion::Direction() const //purpose : //======================================================================= -Handle(Adaptor3d_HCurve) Adaptor3d_SurfaceOfLinearExtrusion::BasisCurve() const +Handle(Adaptor3d_HCurve) GeomAdaptor_SurfaceOfLinearExtrusion::BasisCurve() const { return myBasisCurve; } diff --git a/src/Adaptor3d/Adaptor3d_SurfaceOfLinearExtrusion.hxx b/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.hxx similarity index 67% rename from src/Adaptor3d/Adaptor3d_SurfaceOfLinearExtrusion.hxx rename to src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.hxx index 3a5d72b688..c67e10f8e9 100644 --- a/src/Adaptor3d/Adaptor3d_SurfaceOfLinearExtrusion.hxx +++ b/src/GeomAdaptor/GeomAdaptor_SurfaceOfLinearExtrusion.hxx @@ -14,21 +14,16 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#ifndef _Adaptor3d_SurfaceOfLinearExtrusion_HeaderFile -#define _Adaptor3d_SurfaceOfLinearExtrusion_HeaderFile +#ifndef _GeomAdaptor_SurfaceOfLinearExtrusion_HeaderFile +#define _GeomAdaptor_SurfaceOfLinearExtrusion_HeaderFile #include #include #include #include -#include -#include -#include -#include -#include -#include -#include +#include + class Adaptor3d_HCurve; class Standard_OutOfRange; class Standard_NoSuchObject; @@ -54,20 +49,20 @@ class gp_Ax1; //! The position of the curve gives the origin for the //! parameter V. //! The continuity of the surface is CN in the V direction. -class Adaptor3d_SurfaceOfLinearExtrusion : public Adaptor3d_Surface +class GeomAdaptor_SurfaceOfLinearExtrusion : public GeomAdaptor_Surface { public: DEFINE_STANDARD_ALLOC - Standard_EXPORT Adaptor3d_SurfaceOfLinearExtrusion(); + Standard_EXPORT GeomAdaptor_SurfaceOfLinearExtrusion(); //! The Curve is loaded. - Standard_EXPORT Adaptor3d_SurfaceOfLinearExtrusion(const Handle(Adaptor3d_HCurve)& C); + Standard_EXPORT GeomAdaptor_SurfaceOfLinearExtrusion(const Handle(Adaptor3d_HCurve)& C); //! Thew Curve and the Direction are loaded. - Standard_EXPORT Adaptor3d_SurfaceOfLinearExtrusion(const Handle(Adaptor3d_HCurve)& C, const gp_Dir& V); + Standard_EXPORT GeomAdaptor_SurfaceOfLinearExtrusion(const Handle(Adaptor3d_HCurve)& C, const gp_Dir& V); //! Changes the Curve Standard_EXPORT void Load (const Handle(Adaptor3d_HCurve)& C); @@ -128,38 +123,7 @@ public: Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; Standard_EXPORT Standard_Real VPeriod() const Standard_OVERRIDE; - - //! Computes the point of parameters U,V on the surface. - Standard_EXPORT gp_Pnt Value (const Standard_Real U, const Standard_Real V) const Standard_OVERRIDE; - - //! Computes the point of parameters U,V on the surface. - Standard_EXPORT void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const Standard_OVERRIDE; - - //! Computes the point and the first derivatives on - //! the surface. - //! Raised if the continuity of the current - //! intervals is not C1. - Standard_EXPORT void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const Standard_OVERRIDE; - - //! Computes the point, the first and second - //! derivatives on the surface. - //! Raised if the continuity of the current - //! intervals is not C2. - Standard_EXPORT void D2 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const Standard_OVERRIDE; - - //! Computes the point, the first, second and third - //! derivatives on the surface. - //! Raised if the continuity of the current - //! intervals is not C3. - Standard_EXPORT void D3 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const Standard_OVERRIDE; - - //! Computes the derivative of order Nu in the direction U and Nv - //! in the direction V at the point P(U, V). - //! Raised if the current U interval is not not CNu - //! and the current V interval is not CNv. - //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0. - Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv) const Standard_OVERRIDE; - + //! Returns the parametric U resolution corresponding //! to the real space resolution . Standard_EXPORT Standard_Real UResolution (const Standard_Real R3d) const Standard_OVERRIDE; @@ -187,15 +151,7 @@ public: Standard_EXPORT Standard_Integer UDegree() const Standard_OVERRIDE; Standard_EXPORT Standard_Integer NbUPoles() const Standard_OVERRIDE; - - Standard_EXPORT Standard_Integer VDegree() const Standard_OVERRIDE; - - Standard_EXPORT Standard_Integer NbVPoles() const Standard_OVERRIDE; - - Standard_EXPORT Standard_Integer NbUKnots() const Standard_OVERRIDE; - - Standard_EXPORT Standard_Integer NbVKnots() const Standard_OVERRIDE; - + Standard_EXPORT Standard_Boolean IsURational() const Standard_OVERRIDE; Standard_EXPORT Standard_Boolean IsVRational() const Standard_OVERRIDE; @@ -220,13 +176,9 @@ protected: private: - - - - Handle(Adaptor3d_HCurve) myBasisCurve; - gp_Dir myDirection; - - + Handle(Adaptor3d_HCurve) myBasisCurve; ///< extruded curve + gp_Dir myDirection; ///< direction of extrusion + Standard_Boolean myHaveDir; ///< whether the direction of extrusion is initialized }; @@ -235,4 +187,4 @@ private: -#endif // _Adaptor3d_SurfaceOfLinearExtrusion_HeaderFile +#endif // _GeomAdaptor_SurfaceOfLinearExtrusion_HeaderFile diff --git a/src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.cxx b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx similarity index 50% rename from src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.cxx rename to src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx index 944f6c11f7..336ff024a9 100644 --- a/src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.cxx +++ b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.cxx @@ -14,62 +14,46 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. +#include #include -#include -#include -#include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #include -#include //======================================================================= -//function : Adaptor3d_SurfaceOfRevolution +//function : GeomAdaptor_SurfaceOfRevolution //purpose : //======================================================================= -Adaptor3d_SurfaceOfRevolution::Adaptor3d_SurfaceOfRevolution() -:myHaveAxis(Standard_False) +GeomAdaptor_SurfaceOfRevolution::GeomAdaptor_SurfaceOfRevolution() + : myHaveAxis(Standard_False) {} //======================================================================= -//function : Adaptor3d_SurfaceOfRevolution +//function : GeomAdaptor_SurfaceOfRevolution //purpose : //======================================================================= -Adaptor3d_SurfaceOfRevolution::Adaptor3d_SurfaceOfRevolution -(const Handle(Adaptor3d_HCurve)& C) -:myHaveAxis(Standard_False) +GeomAdaptor_SurfaceOfRevolution::GeomAdaptor_SurfaceOfRevolution( + const Handle(Adaptor3d_HCurve)& C) + : myHaveAxis(Standard_False) { - Load( C); + Load(C); } //======================================================================= -//function : Adaptor3d_SurfaceOfRevolution +//function : GeomAdaptor_SurfaceOfRevolution //purpose : //======================================================================= -Adaptor3d_SurfaceOfRevolution::Adaptor3d_SurfaceOfRevolution -(const Handle(Adaptor3d_HCurve)& C, - const gp_Ax1& V) -:myHaveAxis(Standard_False) +GeomAdaptor_SurfaceOfRevolution::GeomAdaptor_SurfaceOfRevolution( + const Handle(Adaptor3d_HCurve)& C, + const gp_Ax1& V) + : myHaveAxis(Standard_False) { - Load( C); - Load( V); + Load(C); + Load(V); } //======================================================================= @@ -77,10 +61,11 @@ Adaptor3d_SurfaceOfRevolution::Adaptor3d_SurfaceOfRevolution //purpose : //======================================================================= -void Adaptor3d_SurfaceOfRevolution::Load( const Handle(Adaptor3d_HCurve)& C) +void GeomAdaptor_SurfaceOfRevolution::Load(const Handle(Adaptor3d_HCurve)& C) { myBasisCurve = C; - if ( myHaveAxis) Load(myAxis); // to evaluate the new myAxeRev. + if (myHaveAxis) + Load(myAxis); // to evaluate the new myAxeRev. } //======================================================================= @@ -88,11 +73,15 @@ void Adaptor3d_SurfaceOfRevolution::Load( const Handle(Adaptor3d_HCurve)& C) //purpose : //======================================================================= -void Adaptor3d_SurfaceOfRevolution::Load( const gp_Ax1& V) +void GeomAdaptor_SurfaceOfRevolution::Load(const gp_Ax1& V) { myHaveAxis = Standard_True; myAxis = V; - + + mySurfaceType = GeomAbs_SurfaceOfRevolution; + myNestedEvaluator = new GeomEvaluator_SurfaceOfRevolution(myBasisCurve, + myAxis.Direction(), myAxis.Location()); + // Eval myAxeRev : axe of revolution ( Determination de Ox). gp_Pnt P,Q; gp_Pnt O = myAxis.Location(); @@ -114,9 +103,9 @@ void Adaptor3d_SurfaceOfRevolution::Load( const gp_Ax1& V) P = Value( 0., 0.);// ce qui ne veut pas dire grand chose if ( GetType() == GeomAbs_Cone) { if ( gp_Lin(myAxis).Distance(P) <= Precision::Confusion()) - Q = ElCLib::Value(1.,myBasisCurve->Line()); + Q = ElCLib::Value(1.,myBasisCurve->Line()); else - Q = P; + Q = P; } else if (Precision::IsInfinite(First)) Q = P; @@ -143,8 +132,7 @@ void Adaptor3d_SurfaceOfRevolution::Load( const gp_Ax1& V) while ( Dist < Precision::Confusion() && Ratio < 100); if ( Ratio >= 100 ) { - Standard_ConstructionError::Raise - ("Adaptor3d_SurfaceOfRevolution : Axe and meridian are confused"); + Standard_ConstructionError::Raise("Adaptor3d_SurfaceOfRevolution : Axe and meridian are confused"); } Ox = ( (Oz^gp_Vec(PP.XYZ()-O.XYZ()))^Oz); } @@ -165,7 +153,7 @@ void Adaptor3d_SurfaceOfRevolution::Load( const gp_Ax1& V) //purpose : //======================================================================= -gp_Ax1 Adaptor3d_SurfaceOfRevolution::AxeOfRevolution() const +gp_Ax1 GeomAdaptor_SurfaceOfRevolution::AxeOfRevolution() const { return myAxis; } @@ -175,7 +163,7 @@ gp_Ax1 Adaptor3d_SurfaceOfRevolution::AxeOfRevolution() const //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfRevolution::FirstUParameter() const +Standard_Real GeomAdaptor_SurfaceOfRevolution::FirstUParameter() const { return 0.; } @@ -185,7 +173,7 @@ Standard_Real Adaptor3d_SurfaceOfRevolution::FirstUParameter() const //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfRevolution::LastUParameter() const +Standard_Real GeomAdaptor_SurfaceOfRevolution::LastUParameter() const { return 2*M_PI; } @@ -195,7 +183,7 @@ Standard_Real Adaptor3d_SurfaceOfRevolution::LastUParameter() const //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfRevolution::FirstVParameter() const +Standard_Real GeomAdaptor_SurfaceOfRevolution::FirstVParameter() const { return myBasisCurve->FirstParameter(); } @@ -205,7 +193,7 @@ Standard_Real Adaptor3d_SurfaceOfRevolution::FirstVParameter() const //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfRevolution::LastVParameter() const +Standard_Real GeomAdaptor_SurfaceOfRevolution::LastVParameter() const { return myBasisCurve->LastParameter(); } @@ -215,7 +203,7 @@ Standard_Real Adaptor3d_SurfaceOfRevolution::LastVParameter() const //purpose : //======================================================================= -GeomAbs_Shape Adaptor3d_SurfaceOfRevolution::UContinuity() const +GeomAbs_Shape GeomAdaptor_SurfaceOfRevolution::UContinuity() const { return GeomAbs_CN; } @@ -225,7 +213,7 @@ GeomAbs_Shape Adaptor3d_SurfaceOfRevolution::UContinuity() const //purpose : //======================================================================= -GeomAbs_Shape Adaptor3d_SurfaceOfRevolution::VContinuity() const +GeomAbs_Shape GeomAdaptor_SurfaceOfRevolution::VContinuity() const { return myBasisCurve->Continuity(); } @@ -235,9 +223,7 @@ GeomAbs_Shape Adaptor3d_SurfaceOfRevolution::VContinuity() const //purpose : //======================================================================= -Standard_Integer Adaptor3d_SurfaceOfRevolution::NbUIntervals -//(const GeomAbs_Shape S) const -(const GeomAbs_Shape ) const +Standard_Integer GeomAdaptor_SurfaceOfRevolution::NbUIntervals(const GeomAbs_Shape ) const { return 1; } @@ -247,8 +233,7 @@ Standard_Integer Adaptor3d_SurfaceOfRevolution::NbUIntervals //purpose : //======================================================================= -Standard_Integer Adaptor3d_SurfaceOfRevolution::NbVIntervals -( const GeomAbs_Shape S) const +Standard_Integer GeomAdaptor_SurfaceOfRevolution::NbVIntervals(const GeomAbs_Shape S) const { return myBasisCurve->NbIntervals(S); } @@ -258,9 +243,8 @@ Standard_Integer Adaptor3d_SurfaceOfRevolution::NbVIntervals //purpose : //======================================================================= -void Adaptor3d_SurfaceOfRevolution::UIntervals (TColStd_Array1OfReal& T, -// const GeomAbs_Shape S) const - const GeomAbs_Shape ) const +void GeomAdaptor_SurfaceOfRevolution::UIntervals(TColStd_Array1OfReal& T, + const GeomAbs_Shape ) const { T(T.Lower() ) = 0.; T(T.Lower()+1) = 2*M_PI; @@ -272,8 +256,8 @@ void Adaptor3d_SurfaceOfRevolution::UIntervals (TColStd_Array1OfReal& T, //purpose : //======================================================================= -void Adaptor3d_SurfaceOfRevolution::VIntervals(TColStd_Array1OfReal& T, - const GeomAbs_Shape S) const +void GeomAdaptor_SurfaceOfRevolution::VIntervals(TColStd_Array1OfReal& T, + const GeomAbs_Shape S) const { myBasisCurve->Intervals(T,S); } @@ -284,7 +268,7 @@ void Adaptor3d_SurfaceOfRevolution::VIntervals(TColStd_Array1OfReal& T, //purpose : //======================================================================= -Handle(Adaptor3d_HSurface) Adaptor3d_SurfaceOfRevolution::UTrim +Handle(Adaptor3d_HSurface) GeomAdaptor_SurfaceOfRevolution::UTrim (const Standard_Real #ifndef No_Exception First @@ -301,10 +285,10 @@ Handle(Adaptor3d_HSurface) Adaptor3d_SurfaceOfRevolution::UTrim #endif Standard_OutOfRange_Raise_if ( Abs(First) > Eps || Abs(Last - 2.*M_PI) > Eps, - "Adaptor3d_SurfaceOfRevolution : UTrim : Parameters out of range"); + "GeomAdaptor_SurfaceOfRevolution : UTrim : Parameters out of range"); - Handle(Adaptor3d_HSurfaceOfRevolution) HR = - new Adaptor3d_HSurfaceOfRevolution(*this); + Handle(GeomAdaptor_HSurfaceOfRevolution) HR = new GeomAdaptor_HSurfaceOfRevolution( + GeomAdaptor_SurfaceOfRevolution(myBasisCurve, myAxis)); return HR; } @@ -314,16 +298,14 @@ Handle(Adaptor3d_HSurface) Adaptor3d_SurfaceOfRevolution::UTrim //purpose : //======================================================================= -Handle(Adaptor3d_HSurface) Adaptor3d_SurfaceOfRevolution::VTrim +Handle(Adaptor3d_HSurface) GeomAdaptor_SurfaceOfRevolution::VTrim (const Standard_Real First, const Standard_Real Last, const Standard_Real Tol) const { - Handle(Adaptor3d_HSurfaceOfRevolution) HR = - new Adaptor3d_HSurfaceOfRevolution(*this); Handle(Adaptor3d_HCurve) HC = BasisCurve()->Trim(First,Last,Tol); - HR->ChangeSurface(). -Load(HC); + Handle(GeomAdaptor_HSurfaceOfRevolution) HR = new GeomAdaptor_HSurfaceOfRevolution( + GeomAdaptor_SurfaceOfRevolution(HC, myAxis)); return HR; } @@ -333,7 +315,7 @@ Load(HC); //purpose : //======================================================================= -Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsUClosed() const +Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsUClosed() const { return Standard_True; } @@ -343,7 +325,7 @@ Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsUClosed() const //purpose : //======================================================================= -Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsVClosed() const +Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsVClosed() const { return myBasisCurve->IsClosed(); } @@ -353,7 +335,7 @@ Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsVClosed() const //purpose : //======================================================================= -Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsUPeriodic() const +Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsUPeriodic() const { return Standard_True; } @@ -363,7 +345,7 @@ Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsUPeriodic() const //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfRevolution::UPeriod() const +Standard_Real GeomAdaptor_SurfaceOfRevolution::UPeriod() const { return 2*M_PI; } @@ -373,7 +355,7 @@ Standard_Real Adaptor3d_SurfaceOfRevolution::UPeriod() const //purpose : //======================================================================= -Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsVPeriodic() const +Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsVPeriodic() const { return myBasisCurve->IsPeriodic(); } @@ -383,154 +365,17 @@ Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsVPeriodic() const //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfRevolution::VPeriod() const +Standard_Real GeomAdaptor_SurfaceOfRevolution::VPeriod() const { return myBasisCurve->Period(); } -//======================================================================= -//function : Value -//purpose : -//======================================================================= - -gp_Pnt Adaptor3d_SurfaceOfRevolution::Value(const Standard_Real U, - const Standard_Real V) const -{ - gp_Pnt P; - myBasisCurve->D0(V,P); - P.Rotate( myAxis, U); - return P; -} - -//======================================================================= -//function : D0 -//purpose : -//======================================================================= - -void Adaptor3d_SurfaceOfRevolution::D0(const Standard_Real U, - const Standard_Real V, - gp_Pnt& P) const -{ - myBasisCurve->D0(V,P); - P.Rotate( myAxis, U); -} - -//======================================================================= -//function : D1 -//purpose : -//======================================================================= - -void Adaptor3d_SurfaceOfRevolution::D1(const Standard_Real U, - const Standard_Real V, - gp_Pnt& P, gp_Vec& D1U, - gp_Vec& D1V) const -{ - myBasisCurve->D1(V,P,D1V); - Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); - - D0( U,V,P); - D1V.Rotate( myAxis, U); - D1U = R*(myAxeRev.YDirection()); - D1U.Rotate( myAxis, U); -} - -//======================================================================= -//function : D2 -//purpose : -//======================================================================= - -void Adaptor3d_SurfaceOfRevolution::D2(const Standard_Real U, - const Standard_Real V, - gp_Pnt& P, gp_Vec& D1U, - gp_Vec& D1V, - gp_Vec& D2U, gp_Vec& D2V, - gp_Vec& D2UV) const -{ - myBasisCurve->D2(V,P,D1V,D2V); - - gp_Vec D1 = (myAxeRev.YDirection()).Rotated( myAxis, U); - gp_Vec D2 = (myAxeRev.XDirection()).Rotated( myAxis, U); - - Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); - Standard_Real D1R = D1V * myAxeRev.XDirection(); // D1R = dR/dV - // et R=AP*XDirection - - D0( U,V,P); - D1V.Rotate( myAxis, U); - D2V.Rotate( myAxis, U); - D1U = R * D1; - D2U = -R * D2; - D2UV = D1R * D1; -} - -//======================================================================= -//function : D3 -//purpose : -//======================================================================= - -void Adaptor3d_SurfaceOfRevolution::D3(const Standard_Real U, - const Standard_Real V, - gp_Pnt& P,gp_Vec& D1U, gp_Vec& D1V, - gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, - gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, - gp_Vec& D3UVV) const -{ - myBasisCurve->D3(V,P,D1V,D2V,D3V); - - gp_Vec D1 = (myAxeRev.YDirection()).Rotated( myAxis, U); - gp_Vec D2 = (myAxeRev.XDirection()).Rotated( myAxis, U); - - Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); - Standard_Real D1R = D1V * myAxeRev.XDirection(); // D1R = dR/dV et - // R=AP*XDirection - Standard_Real D2R = D2V * myAxeRev.XDirection(); - - D0( U,V,P); - D1V.Rotate( myAxis, U); - D2V.Rotate( myAxis, U); - D3V.Rotate( myAxis, U); - D1U = R * D1; - D2U = -R * D2; - D3U = -R * D1; - D2UV = D1R * D1; - D3UUV = -D1R * D2; - D3UVV = D2R * D1; -} - -//======================================================================= -//function : DN -//purpose : -//======================================================================= - -gp_Vec Adaptor3d_SurfaceOfRevolution::DN(const Standard_Real U, - const Standard_Real V, - const Standard_Integer NU, - const Standard_Integer NV) const -{ - if ( (NU+NV)<1 || NU<0 || NV<0) { - Standard_DomainError::Raise("Adaptor3d_SurfaceOfRevolution::DN"); - } - else { - gp_Vec DNv = myBasisCurve->DN( V, NV); - if ( NU == 0) { - return DNv.Rotated( myAxis, U); - } - else { - Standard_Real DNR = DNv * myAxeRev.XDirection(); - gp_Vec DNu = ( myAxeRev.XDirection()).Rotated( myAxis, U + NU*M_PI/2); - return ( DNR * DNu); - } - } - // portage WNT - return gp_Vec(); -} - //======================================================================= //function : UResolution //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfRevolution::UResolution +Standard_Real GeomAdaptor_SurfaceOfRevolution::UResolution (const Standard_Real R3d) const { return Precision::Parametric(R3d); @@ -541,7 +386,7 @@ Standard_Real Adaptor3d_SurfaceOfRevolution::UResolution //purpose : //======================================================================= -Standard_Real Adaptor3d_SurfaceOfRevolution::VResolution +Standard_Real GeomAdaptor_SurfaceOfRevolution::VResolution (const Standard_Real R3d) const { return myBasisCurve->Resolution(R3d); @@ -552,65 +397,49 @@ Standard_Real Adaptor3d_SurfaceOfRevolution::VResolution //purpose : //======================================================================= -GeomAbs_SurfaceType Adaptor3d_SurfaceOfRevolution::GetType() const +GeomAbs_SurfaceType GeomAdaptor_SurfaceOfRevolution::GetType() const { - Standard_Real TolConf, TolAng; - GeomAbs_SurfaceType bRet; - // - bRet=GeomAbs_SurfaceOfRevolution; - TolConf = Precision::Confusion(); - TolAng = Precision::Angular(); - // - switch ( myBasisCurve->GetType()) { + Standard_Real TolConf = Precision::Confusion(); + Standard_Real TolAng = Precision::Angular(); + + switch (myBasisCurve->GetType()) { case GeomAbs_Line: { gp_Ax1 Axe = myBasisCurve->Line().Position(); - if (myAxis.IsParallel(Axe, TolAng)) { - bRet=GeomAbs_Cylinder; - return bRet; - } - else if (myAxis.IsNormal( Axe, TolAng)) { - bRet=GeomAbs_Plane; - return bRet; - } - else { + if (myAxis.IsParallel(Axe, TolAng)) + return GeomAbs_Cylinder; + else if (myAxis.IsNormal(Axe, TolAng)) + return GeomAbs_Plane; + else + { Standard_Real uf = myBasisCurve->FirstParameter(); Standard_Real ul = myBasisCurve->LastParameter(); Standard_Boolean istrim = (!Precision::IsInfinite(uf) && - !Precision::IsInfinite(ul)); - if(istrim){ - gp_Pnt pf = myBasisCurve->Value(uf); - gp_Pnt pl = myBasisCurve->Value(ul); - Standard_Real len = pf.Distance(pl); - //on calcule la distance projetee sur l axe. - gp_Vec vlin(pf,pl); - gp_Vec vaxe(myAxis.Direction()); - Standard_Real projlen = Abs(vaxe.Dot(vlin)); - Standard_Real aTolConf = len*TolAng; - if ((len - projlen) <= aTolConf) { - bRet=GeomAbs_Cylinder; - return bRet; - } - else if (projlen <= aTolConf) { - bRet=GeomAbs_Plane; - return bRet; - } + !Precision::IsInfinite(ul)); + if(istrim) + { + gp_Pnt pf = myBasisCurve->Value(uf); + gp_Pnt pl = myBasisCurve->Value(ul); + Standard_Real len = pf.Distance(pl); + //on calcule la distance projetee sur l axe. + gp_Vec vlin(pf,pl); + gp_Vec vaxe(myAxis.Direction()); + Standard_Real projlen = Abs(vaxe.Dot(vlin)); + Standard_Real aTolConf = len*TolAng; + if ((len - projlen) <= aTolConf) + return GeomAbs_Cylinder; + else if (projlen <= aTolConf) + return GeomAbs_Plane; } - gp_Vec V(myAxis.Location(), - myBasisCurve->Line().Location()); + gp_Vec V(myAxis.Location(), myBasisCurve->Line().Location()); gp_Vec W(Axe.Direction()); - if (Abs(V.DotCross(myAxis.Direction(),W)) <= TolConf){ - bRet=GeomAbs_Cone; - return bRet; - } - else { - return bRet; - } + if (Abs(V.DotCross(myAxis.Direction(), W)) <= TolConf) + return GeomAbs_Cone; } + break; }//case GeomAbs_Line: - // + // case GeomAbs_Circle: { - Standard_Real MajorRadius, aR; gp_Lin aLin(myAxis); // @@ -619,43 +448,35 @@ GeomAbs_SurfaceType Adaptor3d_SurfaceOfRevolution::GetType() const aR=C.Radius(); // - if (!C.Position().IsCoplanar(myAxis, TolConf, TolAng)) { - return bRet; - } - else if(aLin.Distance(aLC) <= TolConf) { - bRet=GeomAbs_Sphere; - return bRet; - } - else { + if (!C.Position().IsCoplanar(myAxis, TolConf, TolAng)) + return GeomAbs_SurfaceOfRevolution; + else if(aLin.Distance(aLC) <= TolConf) + return GeomAbs_Sphere; + else + { MajorRadius = aLin.Distance(aLC); - if(MajorRadius>aR) { - //modified by NIZNHY-PKV Thu Feb 24 09:46:29 2011f - Standard_Real aT, aDx, dX; - gp_Pnt aPx; - // - aT=0.; - aPx=ElCLib::Value(aT, C); - aDx=aLin.Distance(aPx); - dX=aDx-MajorRadius-aR; - if (dX<0.) { - dX=-dX; - } - if (dX aR) + { + Standard_Real aT = 0., aDx, dX; + gp_Pnt aPx; + + aPx = ElCLib::Value(aT, C); + aDx = aLin.Distance(aPx); + dX = aDx - MajorRadius - aR; + if (dX < 0.) + dX = -dX; + if (dX < TolConf) + return GeomAbs_Torus; } - return bRet; } + break; } // default: break; } - return bRet; + return GeomAbs_SurfaceOfRevolution; } //======================================================================= @@ -663,25 +484,19 @@ GeomAbs_SurfaceType Adaptor3d_SurfaceOfRevolution::GetType() const //purpose : //======================================================================= -gp_Pln Adaptor3d_SurfaceOfRevolution::Plane() const +gp_Pln GeomAdaptor_SurfaceOfRevolution::Plane() const { Standard_NoSuchObject_Raise_if - (GetType() != GeomAbs_Plane, "Adaptor3d_SurfaceOfRevolution:Plane"); + (GetType() != GeomAbs_Plane, "GeomAdaptor_SurfaceOfRevolution:Plane"); gp_Ax3 Axe = myAxeRev; - gp_Pnt P; - - // P = Projection du Point Debut de la generatrice sur l axe de rotation. - P.SetXYZ((myAxis.Location()).XYZ() + - (Value(0.,0.).XYZ()-(myAxis.Location()).XYZ()). - Dot((myAxis.Direction()).XYZ()) - *(myAxis.Direction()).XYZ()); - Axe.SetLocation( P); - //// modified by jgv, 8.01.03 for OCC1226 //// - if (Axe.XDirection(). - Dot(myBasisCurve->Line().Direction()) >= -Precision::Confusion()) // > 0. + gp_Pnt aPonCurve = Value(0., 0.); + Standard_Real aDot = (aPonCurve.XYZ() - myAxis.Location().XYZ()).Dot(myAxis.Direction().XYZ()); + + gp_Pnt P(myAxis.Location().XYZ() + aDot * myAxis.Direction().XYZ()); + Axe.SetLocation(P); + if (Axe.XDirection().Dot(myBasisCurve->Line().Direction()) >= -Precision::Confusion()) Axe.XReverse(); - ////////////////////////////////////////////// return gp_Pln( Axe); } @@ -691,14 +506,14 @@ gp_Pln Adaptor3d_SurfaceOfRevolution::Plane() const //purpose : //======================================================================= -gp_Cylinder Adaptor3d_SurfaceOfRevolution::Cylinder() const +gp_Cylinder GeomAdaptor_SurfaceOfRevolution::Cylinder() const { Standard_NoSuchObject_Raise_if - (GetType() != GeomAbs_Cylinder, "Adaptor3d_SurfaceOfRevolution::Cylinder"); + (GetType() != GeomAbs_Cylinder, "GeomAdaptor_SurfaceOfRevolution::Cylinder"); - gp_Pnt P = Value( 0., 0.); - Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); - return gp_Cylinder( myAxeRev, R); + gp_Pnt P = Value(0., 0.); + Standard_Real R = gp_Vec(myAxeRev.Location(), P) * myAxeRev.XDirection(); + return gp_Cylinder(myAxeRev, R); } //======================================================================= @@ -706,10 +521,10 @@ gp_Cylinder Adaptor3d_SurfaceOfRevolution::Cylinder() const //purpose : //======================================================================= -gp_Cone Adaptor3d_SurfaceOfRevolution::Cone() const +gp_Cone GeomAdaptor_SurfaceOfRevolution::Cone() const { Standard_NoSuchObject_Raise_if - ( GetType() != GeomAbs_Cone, "Adaptor3d_SurfaceOfRevolution:Cone"); + ( GetType() != GeomAbs_Cone, "GeomAdaptor_SurfaceOfRevolution:Cone"); gp_Ax3 Axe = myAxeRev; gp_Dir ldir = (myBasisCurve->Line()).Direction(); @@ -733,15 +548,15 @@ gp_Cone Adaptor3d_SurfaceOfRevolution::Cone() const //purpose : //======================================================================= -gp_Sphere Adaptor3d_SurfaceOfRevolution::Sphere() const +gp_Sphere GeomAdaptor_SurfaceOfRevolution::Sphere() const { Standard_NoSuchObject_Raise_if - ( GetType() != GeomAbs_Sphere, "Adaptor3d_SurfaceOfRevolution:Sphere"); + ( GetType() != GeomAbs_Sphere, "GeomAdaptor_SurfaceOfRevolution:Sphere"); gp_Circ C = myBasisCurve->Circle(); gp_Ax3 Axe = myAxeRev; - Axe.SetLocation( C.Location()); - return gp_Sphere( Axe, C.Radius()); + Axe.SetLocation(C.Location()); + return gp_Sphere(Axe, C.Radius()); } @@ -750,36 +565,14 @@ gp_Sphere Adaptor3d_SurfaceOfRevolution::Sphere() const //purpose : //======================================================================= -gp_Torus Adaptor3d_SurfaceOfRevolution::Torus() const +gp_Torus GeomAdaptor_SurfaceOfRevolution::Torus() const { Standard_NoSuchObject_Raise_if - (GetType() != GeomAbs_Torus, "Adaptor3d_SurfaceOfRevolution:Torus"); + (GetType() != GeomAbs_Torus, "GeomAdaptor_SurfaceOfRevolution:Torus"); gp_Circ C = myBasisCurve->Circle(); Standard_Real MajorRadius = gp_Lin(myAxis).Distance(C.Location()); - return gp_Torus( myAxeRev, MajorRadius, C.Radius()); -} - -//======================================================================= -//function : UDegree -//purpose : -//======================================================================= - -Standard_Integer Adaptor3d_SurfaceOfRevolution::UDegree() const -{ - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::UDegree"); - return 0; -} - -//======================================================================= -//function : NbUPoles -//purpose : -//======================================================================= - -Standard_Integer Adaptor3d_SurfaceOfRevolution::NbUPoles() const -{ - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::NbUPoles"); - return 0; + return gp_Torus(myAxeRev, MajorRadius, C.Radius()); } //======================================================================= @@ -787,7 +580,7 @@ Standard_Integer Adaptor3d_SurfaceOfRevolution::NbUPoles() const //purpose : //======================================================================= -Standard_Integer Adaptor3d_SurfaceOfRevolution::VDegree() const +Standard_Integer GeomAdaptor_SurfaceOfRevolution::VDegree() const { return myBasisCurve->Degree(); } @@ -797,31 +590,19 @@ Standard_Integer Adaptor3d_SurfaceOfRevolution::VDegree() const //purpose : //======================================================================= -Standard_Integer Adaptor3d_SurfaceOfRevolution::NbVPoles() const +Standard_Integer GeomAdaptor_SurfaceOfRevolution::NbVPoles() const { - return myBasisCurve -> NbPoles(); + return myBasisCurve->NbPoles(); } -//======================================================================= -//function : NbUKnots -//purpose : -//======================================================================= - -Standard_Integer Adaptor3d_SurfaceOfRevolution::NbUKnots() const -{ - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::NbUKnots"); - return 0; -} - - //======================================================================= //function : NbVKnots //purpose : //======================================================================= -Standard_Integer Adaptor3d_SurfaceOfRevolution::NbVKnots() const +Standard_Integer GeomAdaptor_SurfaceOfRevolution::NbVKnots() const { - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::NbVKnots"); + Standard_NoSuchObject::Raise("GeomAdaptor_SurfaceOfRevolution::NbVKnots"); return 0; } @@ -832,9 +613,9 @@ Standard_Integer Adaptor3d_SurfaceOfRevolution::NbVKnots() const //purpose : //======================================================================= -Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsURational() const +Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsURational() const { - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::IsURational"); + Standard_NoSuchObject::Raise("GeomAdaptor_SurfaceOfRevolution::IsURational"); return Standard_False; } @@ -843,9 +624,9 @@ Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsURational() const //purpose : //======================================================================= -Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsVRational() const +Standard_Boolean GeomAdaptor_SurfaceOfRevolution::IsVRational() const { - Standard_NoSuchObject::Raise("Adaptor3d_SurfaceOfRevolution::IsVRational"); + Standard_NoSuchObject::Raise("GeomAdaptor_SurfaceOfRevolution::IsVRational"); return Standard_False; } @@ -855,11 +636,10 @@ Standard_Boolean Adaptor3d_SurfaceOfRevolution::IsVRational() const //purpose : //======================================================================= -Handle(Geom_BezierSurface) Adaptor3d_SurfaceOfRevolution::Bezier() const +Handle(Geom_BezierSurface) GeomAdaptor_SurfaceOfRevolution::Bezier() const { - Standard_NoSuchObject::Raise(""); - Handle(Geom_BezierSurface) Dummy; - return Dummy; + Standard_NoSuchObject::Raise("GeomAdaptor_SurfaceOfRevolution::Bezier"); + return Handle(Geom_BezierSurface)(); } @@ -868,42 +648,28 @@ Handle(Geom_BezierSurface) Adaptor3d_SurfaceOfRevolution::Bezier() const //purpose : //======================================================================= -Handle(Geom_BSplineSurface) Adaptor3d_SurfaceOfRevolution::BSpline() const +Handle(Geom_BSplineSurface) GeomAdaptor_SurfaceOfRevolution::BSpline() const { - Standard_NoSuchObject::Raise(""); - Handle(Geom_BSplineSurface) Dummy; - return Dummy; + Standard_NoSuchObject::Raise("GeomAdaptor_SurfaceOfRevolution::BSpline"); + return Handle(Geom_BSplineSurface)(); } - //======================================================================= //function : Axis //purpose : //======================================================================= -gp_Ax3 Adaptor3d_SurfaceOfRevolution::Axis() const +const gp_Ax3& GeomAdaptor_SurfaceOfRevolution::Axis() const { return myAxeRev; } -//======================================================================= -//function : Direction -//purpose : -//======================================================================= - -gp_Dir Adaptor3d_SurfaceOfRevolution::Direction() const -{ - Standard_NoSuchObject::Raise(""); - return gp_Dir(); -} - - //======================================================================= //function : BasisCurve //purpose : //======================================================================= -Handle(Adaptor3d_HCurve) Adaptor3d_SurfaceOfRevolution::BasisCurve() const +Handle(Adaptor3d_HCurve) GeomAdaptor_SurfaceOfRevolution::BasisCurve() const { return myBasisCurve; } diff --git a/src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.hxx b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.hxx similarity index 69% rename from src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.hxx rename to src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.hxx index 2d993b18c2..405d1a94af 100644 --- a/src/Adaptor3d/Adaptor3d_SurfaceOfRevolution.hxx +++ b/src/GeomAdaptor/GeomAdaptor_SurfaceOfRevolution.hxx @@ -14,22 +14,17 @@ // Alternatively, this file may be used under the terms of Open CASCADE // commercial license or contractual agreement. -#ifndef _Adaptor3d_SurfaceOfRevolution_HeaderFile -#define _Adaptor3d_SurfaceOfRevolution_HeaderFile +#ifndef _GeomAdaptor_SurfaceOfRevolution_HeaderFile +#define _GeomAdaptor_SurfaceOfRevolution_HeaderFile #include #include #include #include -#include #include -#include -#include -#include -#include -#include -#include +#include + class Adaptor3d_HCurve; class Standard_OutOfRange; class Standard_NoSuchObject; @@ -65,22 +60,20 @@ class gp_Dir; //! The derivatives are always defined for the u direction. //! For the v direction the definition of the derivatives depends on //! the degree of continuity of the referenced curve. -//! Curve and Axis are coplanar. -//! Curve doesn't intersect Axis. -class Adaptor3d_SurfaceOfRevolution : public Adaptor3d_Surface +class GeomAdaptor_SurfaceOfRevolution : public GeomAdaptor_Surface { public: DEFINE_STANDARD_ALLOC - Standard_EXPORT Adaptor3d_SurfaceOfRevolution(); + Standard_EXPORT GeomAdaptor_SurfaceOfRevolution(); //! The Curve is loaded. - Standard_EXPORT Adaptor3d_SurfaceOfRevolution(const Handle(Adaptor3d_HCurve)& C); + Standard_EXPORT GeomAdaptor_SurfaceOfRevolution(const Handle(Adaptor3d_HCurve)& C); //! The Curve and the Direction are loaded. - Standard_EXPORT Adaptor3d_SurfaceOfRevolution(const Handle(Adaptor3d_HCurve)& C, const gp_Ax1& V); + Standard_EXPORT GeomAdaptor_SurfaceOfRevolution(const Handle(Adaptor3d_HCurve)& C, const gp_Ax1& V); //! Changes the Curve Standard_EXPORT void Load (const Handle(Adaptor3d_HCurve)& C); @@ -143,39 +136,7 @@ public: Standard_EXPORT Standard_Boolean IsVPeriodic() const Standard_OVERRIDE; Standard_EXPORT Standard_Real VPeriod() const Standard_OVERRIDE; - - //! Computes the point of parameters U,V on the surface. - Standard_EXPORT gp_Pnt Value (const Standard_Real U, const Standard_Real V) const Standard_OVERRIDE; - - //! Computes the point of parameters U,V on the surface. - Standard_EXPORT void D0 (const Standard_Real U, const Standard_Real V, gp_Pnt& P) const Standard_OVERRIDE; - - //! Computes the point and the first derivatives on - //! the surface. - //! Raised if the continuity of the current - //! intervals is not C1. - Standard_EXPORT void D1 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V) const Standard_OVERRIDE; - - //! Computes the point, the first and second - //! derivatives on the surface. - //! Raised if the continuity of the current - //! intervals is not C2. - Standard_EXPORT void D2 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV) const Standard_OVERRIDE; - - //! Computes the point, the first, second and third - //! derivatives on the surface. - //! Raised if the continuity of the current - //! intervals is not C3. - Standard_EXPORT void D3 (const Standard_Real U, const Standard_Real V, gp_Pnt& P, gp_Vec& D1U, gp_Vec& D1V, gp_Vec& D2U, gp_Vec& D2V, gp_Vec& D2UV, gp_Vec& D3U, gp_Vec& D3V, gp_Vec& D3UUV, gp_Vec& D3UVV) const Standard_OVERRIDE; - - //! Computes the derivative of order Nu - //! in the direction U and Nv in the direction V - //! at the point P(U, V). - //! Raised if the current U interval is not not CNu - //! and the current V interval is not CNv. - //! Raised if Nu + Nv < 1 or Nu < 0 or Nv < 0. - Standard_EXPORT gp_Vec DN (const Standard_Real U, const Standard_Real V, const Standard_Integer Nu, const Standard_Integer Nv) const Standard_OVERRIDE; - + //! Returns the parametric U resolution corresponding //! to the real space resolution . Standard_EXPORT Standard_Real UResolution (const Standard_Real R3d) const Standard_OVERRIDE; @@ -201,17 +162,11 @@ public: Standard_EXPORT gp_Sphere Sphere() const Standard_OVERRIDE; Standard_EXPORT gp_Torus Torus() const Standard_OVERRIDE; - - Standard_EXPORT Standard_Integer UDegree() const Standard_OVERRIDE; - - Standard_EXPORT Standard_Integer NbUPoles() const Standard_OVERRIDE; - + Standard_EXPORT Standard_Integer VDegree() const Standard_OVERRIDE; Standard_EXPORT Standard_Integer NbVPoles() const Standard_OVERRIDE; - - Standard_EXPORT Standard_Integer NbUKnots() const Standard_OVERRIDE; - + Standard_EXPORT Standard_Integer NbVKnots() const Standard_OVERRIDE; Standard_EXPORT Standard_Boolean IsURational() const Standard_OVERRIDE; @@ -222,9 +177,7 @@ public: Standard_EXPORT Handle(Geom_BSplineSurface) BSpline() const Standard_OVERRIDE; - Standard_EXPORT gp_Ax3 Axis() const; - - Standard_EXPORT gp_Dir Direction() const Standard_OVERRIDE; + Standard_EXPORT const gp_Ax3& Axis() const; Standard_EXPORT Handle(Adaptor3d_HCurve) BasisCurve() const Standard_OVERRIDE; @@ -238,15 +191,10 @@ protected: private: - - - - Handle(Adaptor3d_HCurve) myBasisCurve; - gp_Ax1 myAxis; - Standard_Boolean myHaveAxis; - gp_Ax3 myAxeRev; - - + Handle(Adaptor3d_HCurve) myBasisCurve; ///< revolved curve + gp_Ax1 myAxis; ///< axis of revolution + Standard_Boolean myHaveAxis; ///< whether axis of revolution is initialized + gp_Ax3 myAxeRev; ///< auxiliary trihedron according to the curve position }; @@ -255,4 +203,4 @@ private: -#endif // _Adaptor3d_SurfaceOfRevolution_HeaderFile +#endif // _GeomAdaptor_SurfaceOfRevolution_HeaderFile diff --git a/src/GeomEvaluator/FILES b/src/GeomEvaluator/FILES new file mode 100644 index 0000000000..f6e1bdc0f9 --- /dev/null +++ b/src/GeomEvaluator/FILES @@ -0,0 +1,7 @@ +GeomEvaluator_OffsetSurface.cxx +GeomEvaluator_OffsetSurface.hxx +GeomEvaluator_Surface.hxx +GeomEvaluator_SurfaceOfExtrusion.cxx +GeomEvaluator_SurfaceOfExtrusion.hxx +GeomEvaluator_SurfaceOfRevolution.cxx +GeomEvaluator_SurfaceOfRevolution.hxx diff --git a/src/GeomEvaluator/GeomEvaluator_OffsetSurface.cxx b/src/GeomEvaluator/GeomEvaluator_OffsetSurface.cxx new file mode 100644 index 0000000000..acc7e30e03 --- /dev/null +++ b/src/GeomEvaluator/GeomEvaluator_OffsetSurface.cxx @@ -0,0 +1,796 @@ +// Created on: 2015-09-21 +// Copyright (c) 2015 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + + +template +static void derivatives(Standard_Integer theMaxOrder, + Standard_Integer theMinOrder, + const Standard_Real theU, + const Standard_Real theV, + const SurfOrAdapt& theBasisSurf, + const Standard_Integer theNU, + const Standard_Integer theNV, + const Standard_Boolean theAlongU, + const Standard_Boolean theAlongV, + const Handle(Geom_BSplineSurface)& theL, + TColgp_Array2OfVec& theDerNUV, + TColgp_Array2OfVec& theDerSurf); + + + +GeomEvaluator_OffsetSurface::GeomEvaluator_OffsetSurface( + const Handle(Geom_Surface)& theBase, + const Standard_Real theOffset, + const Handle(Geom_OsculatingSurface)& theOscSurf) + : GeomEvaluator_Surface(), + myBaseSurf(theBase), + myOffset(theOffset), + myOscSurf(theOscSurf) +{ + if (!myOscSurf.IsNull()) + return; // osculating surface already exists + + // Create osculating surface for B-spline and Besier surfaces only + if (myBaseSurf->IsKind(STANDARD_TYPE(Geom_BSplineSurface)) || + myBaseSurf->IsKind(STANDARD_TYPE(Geom_BezierSurface))) + myOscSurf = new Geom_OsculatingSurface(myBaseSurf, Precision::Confusion()); +} + +GeomEvaluator_OffsetSurface::GeomEvaluator_OffsetSurface( + const Handle(GeomAdaptor_HSurface)& theBase, + const Standard_Real theOffset, + const Handle(Geom_OsculatingSurface)& theOscSurf) + : GeomEvaluator_Surface(), + myBaseAdaptor(theBase), + myOffset(theOffset) +{ + if (theOscSurf.IsNull()) + return; // osculating surface already exists + + // Create osculating surface for B-spline and Besier surfaces only + Handle(Geom_Surface) aBSurf; + if (myBaseAdaptor->GetType() == GeomAbs_BSplineSurface) + aBSurf = myBaseAdaptor->BSpline(); + else if (myBaseAdaptor->GetType() == GeomAbs_BezierSurface) + aBSurf = myBaseAdaptor->Bezier(); + if (!aBSurf.IsNull()) + { + myBaseSurf = aBSurf; + myOscSurf = new Geom_OsculatingSurface(aBSurf, Precision::Confusion()); + } +} + +void GeomEvaluator_OffsetSurface::D0( + const Standard_Real theU, const Standard_Real theV, gp_Pnt& theValue) const +{ + gp_Vec aD1U, aD1V; + BaseD1(theU, theV, theValue, aD1U, aD1V); + CalculateD0(theU, theV, theValue, aD1U, aD1V); +} + +void GeomEvaluator_OffsetSurface::D1( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V) const +{ + gp_Vec aD2U, aD2V, aD2UV; + BaseD2(theU, theV, theValue, theD1U, theD1V, aD2U, aD2V, aD2UV); + CalculateD1(theU, theV, theValue, theD1U, theD1V, aD2U, aD2V, aD2UV); +} + +void GeomEvaluator_OffsetSurface::D2( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV) const +{ + gp_Vec aD3U, aD3V, aD3UUV, aD3UVV; + BaseD3(theU, theV, theValue, theD1U, theD1V, + theD2U, theD2V, theD2UV, aD3U, aD3V, aD3UUV, aD3UVV); + CalculateD2(theU, theV, theValue, theD1U, theD1V, + theD2U, theD2V, theD2UV, aD3U, aD3V, aD3UUV, aD3UVV); +} + +void GeomEvaluator_OffsetSurface::D3( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV, + gp_Vec& theD3U, gp_Vec& theD3V, gp_Vec& theD3UUV, gp_Vec& theD3UVV) const +{ + BaseD3(theU, theV, theValue, theD1U, theD1V, + theD2U, theD2V, theD2UV, theD3U, theD3V, theD3UUV, theD3UVV); + CalculateD3(theU, theV, theValue, theD1U, theD1V, + theD2U, theD2V, theD2UV, theD3U, theD3V, theD3UUV, theD3UVV); +} + +gp_Vec GeomEvaluator_OffsetSurface::DN( + const Standard_Real theU, const Standard_Real theV, + const Standard_Integer theDerU, const Standard_Integer theDerV) const +{ + Standard_RangeError_Raise_if(theDerU < 0, "GeomEvaluator_OffsetSurface::DN(): theDerU < 0"); + Standard_RangeError_Raise_if(theDerV < 0, "GeomEvaluator_OffsetSurface::DN(): theDerV < 0"); + Standard_RangeError_Raise_if(theDerU + theDerV < 1, + "GeomEvaluator_OffsetSurface::DN(): theDerU + theDerV < 1"); + + gp_Pnt aP; + gp_Vec aD1U, aD1V; + BaseD1(theU, theV, aP, aD1U, aD1V); + return CalculateDN(theU, theV, theDerU, theDerV, aD1U, aD1V); +} + + +void GeomEvaluator_OffsetSurface::BaseD0(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue) const +{ + if (!myBaseAdaptor.IsNull()) + myBaseAdaptor->D0(theU, theV, theValue); + else + myBaseSurf->D0(theU, theV, theValue); +} + +void GeomEvaluator_OffsetSurface::BaseD1(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V) const +{ + if (!myBaseAdaptor.IsNull()) + myBaseAdaptor->D1(theU, theV, theValue, theD1U, theD1V); + else + myBaseSurf->D1(theU, theV, theValue, theD1U, theD1V); +} + +void GeomEvaluator_OffsetSurface::BaseD2(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV) const +{ + if (!myBaseAdaptor.IsNull()) + myBaseAdaptor->D2(theU, theV, theValue, theD1U, theD1V, theD2U, theD2V, theD2UV); + else + myBaseSurf->D2(theU, theV, theValue, theD1U, theD1V, theD2U, theD2V, theD2UV); +} + +void GeomEvaluator_OffsetSurface::BaseD3( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV, + gp_Vec& theD3U, gp_Vec& theD3V, gp_Vec& theD3UUV, gp_Vec& theD3UVV) const +{ + if (!myBaseAdaptor.IsNull()) + myBaseAdaptor->D3(theU, theV, theValue, theD1U, theD1V, + theD2U, theD2V, theD2UV, theD3U, theD3V, theD3UUV, theD3UVV); + else + myBaseSurf->D3(theU, theV, theValue, theD1U, theD1V, + theD2U, theD2V, theD2UV, theD3U, theD3V, theD3UUV, theD3UVV); +} + + +void GeomEvaluator_OffsetSurface::CalculateD0( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, + const gp_Vec& theD1U, const gp_Vec& theD1V) const +{ + const Standard_Real MagTol = 1.e-9; + + // Normalize derivatives before normal calculation because it gives more stable result. + // There will be normalized only derivatives greater than 1.0 to avoid differences in last significant digit + gp_Vec aD1U(theD1U); + gp_Vec aD1V(theD1V); + Standard_Real aD1UNorm2 = aD1U.SquareMagnitude(); + Standard_Real aD1VNorm2 = aD1V.SquareMagnitude(); + if (aD1UNorm2 > 1.0) + aD1U /= Sqrt(aD1UNorm2); + if (aD1VNorm2 > 1.0) + aD1V /= Sqrt(aD1VNorm2); + + gp_Vec aNorm = aD1U.Crossed(aD1V); + if (aNorm.SquareMagnitude() > MagTol * MagTol) + { + // Non singular case. Simple computations. + aNorm.Normalize(); + theValue.SetXYZ(theValue.XYZ() + myOffset * aNorm.XYZ()); + } + else + { + const Standard_Integer MaxOrder = 3; + + Handle(Geom_BSplineSurface) L; + Standard_Boolean isOpposite = Standard_False; + Standard_Boolean AlongU = Standard_False; + Standard_Boolean AlongV = Standard_False; + if (!myOscSurf.IsNull()) + { + AlongU = myOscSurf->UOscSurf(theU, theV, isOpposite, L); + AlongV = myOscSurf->VOscSurf(theU, theV, isOpposite, L); + } + const Standard_Real aSign = ((AlongV || AlongU) && isOpposite) ? -1. : 1.; + + TColgp_Array2OfVec DerNUV(0, MaxOrder, 0, MaxOrder); + TColgp_Array2OfVec DerSurf(0, MaxOrder + 1, 0, MaxOrder + 1); + Standard_Integer OrderU, OrderV; + Standard_Real Umin = 0, Umax = 0, Vmin = 0, Vmax = 0; + Bounds(Umin, Umax, Vmin, Vmax); + + DerSurf.SetValue(1, 0, theD1U); + DerSurf.SetValue(0, 1, theD1V); + if (!myBaseSurf.IsNull()) + derivatives(MaxOrder, 1, theU, theV, myBaseSurf, 0, 0, AlongU, AlongV, L, DerNUV, DerSurf); + else + derivatives(MaxOrder, 1, theU, theV, myBaseAdaptor, 0, 0, AlongU, AlongV, L, DerNUV, DerSurf); + + gp_Dir Normal; + CSLib_NormalStatus NStatus; + CSLib::Normal(MaxOrder, DerNUV, MagTol, theU, theV, Umin, Umax, Vmin, Vmax, + NStatus, Normal, OrderU, OrderV); + if (NStatus == CSLib_InfinityOfSolutions) + { + // Replace zero derivative and try to calculate normal + gp_Vec aNewDU = theD1U; + gp_Vec aNewDV = theD1V; + if (ReplaceDerivative(theU, theV, aNewDU, aNewDV, MagTol * MagTol)) + CSLib::Normal(aNewDU, aNewDV, MagTol, NStatus, Normal); + } + + if (NStatus != CSLib_Defined) + Geom_UndefinedValue::Raise( + "GeomEvaluator_OffsetSurface::CalculateD0(): Unable to calculate normal"); + + theValue.SetXYZ(theValue.XYZ() + myOffset * aSign * Normal.XYZ()); + } +} + +void GeomEvaluator_OffsetSurface::CalculateD1( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + const gp_Vec& theD2U, const gp_Vec& theD2V, const gp_Vec& theD2UV) const +{ + const Standard_Real MagTol = 1.e-9; + + // Check offset side. + Handle(Geom_BSplineSurface) L; + Standard_Boolean isOpposite = Standard_False; + Standard_Boolean AlongU = Standard_False; + Standard_Boolean AlongV = Standard_False; + if (!myOscSurf.IsNull()) + { + AlongU = myOscSurf->UOscSurf(theU, theV, isOpposite, L); + AlongV = myOscSurf->VOscSurf(theU, theV, isOpposite, L); + } + const Standard_Real aSign = ((AlongV || AlongU) && isOpposite) ? -1. : 1.; + + // Normalize derivatives before normal calculation because it gives more stable result. + // There will be normalized only derivatives greater than 1.0 to avoid differences in last significant digit + gp_Vec aD1U(theD1U); + gp_Vec aD1V(theD1V); + Standard_Real aD1UNorm2 = aD1U.SquareMagnitude(); + Standard_Real aD1VNorm2 = aD1V.SquareMagnitude(); + if (aD1UNorm2 > 1.0) + aD1U /= Sqrt(aD1UNorm2); + if (aD1VNorm2 > 1.0) + aD1V /= Sqrt(aD1VNorm2); + + Standard_Integer MaxOrder = 0; + gp_Vec aNorm = aD1U.Crossed(aD1V); + if (aNorm.SquareMagnitude() > MagTol * MagTol) + { + if (!AlongV && !AlongU) + { + // AlongU or AlongV leads to more complex D1 computation + // Try to compute D0 and D1 much simpler + aNorm.Normalize(); + theValue.SetXYZ(theValue.XYZ() + myOffset * aSign * aNorm.XYZ()); + + gp_Vec aN0(aNorm.XYZ()), aN1U, aN1V; + Standard_Real aScale = (theD1U^theD1V).Dot(aN0); + aN1U.SetX(theD2U.Y() * theD1V.Z() + theD1U.Y() * theD2UV.Z() + - theD2U.Z() * theD1V.Y() - theD1U.Z() * theD2UV.Y()); + aN1U.SetY((theD2U.X() * theD1V.Z() + theD1U.X() * theD2UV.Z() + - theD2U.Z() * theD1V.X() - theD1U.Z() * theD2UV.X()) * -1.0); + aN1U.SetZ(theD2U.X() * theD1V.Y() + theD1U.X() * theD2UV.Y() + - theD2U.Y() * theD1V.X() - theD1U.Y() * theD2UV.X()); + Standard_Real aScaleU = aN1U.Dot(aN0); + aN1U.Subtract(aScaleU * aN0); + aN1U /= aScale; + + aN1V.SetX(theD2UV.Y() * theD1V.Z() + theD2V.Z() * theD1U.Y() + - theD2UV.Z() * theD1V.Y() - theD2V.Y() * theD1U.Z()); + aN1V.SetY((theD2UV.X() * theD1V.Z() + theD2V.Z() * theD1U.X() + - theD2UV.Z() * theD1V.X() - theD2V.X() * theD1U.Z()) * -1.0); + aN1V.SetZ(theD2UV.X() * theD1V.Y() + theD2V.Y() * theD1U.X() + - theD2UV.Y() * theD1V.X() - theD2V.X() * theD1U.Y()); + Standard_Real aScaleV = aN1V.Dot(aN0); + aN1V.Subtract(aScaleV * aN0); + aN1V /= aScale; + + theD1U += myOffset * aSign * aN1U; + theD1V += myOffset * aSign * aN1V; + + return; + } + } + else + MaxOrder = 3; + + Standard_Integer OrderU, OrderV; + TColgp_Array2OfVec DerNUV(0, MaxOrder + 1, 0, MaxOrder + 1); + TColgp_Array2OfVec DerSurf(0, MaxOrder + 2, 0, MaxOrder + 2); + Standard_Real Umin = 0, Umax = 0, Vmin = 0, Vmax = 0; + Bounds(Umin, Umax, Vmin, Vmax); + + DerSurf.SetValue(1, 0, theD1U); + DerSurf.SetValue(0, 1, theD1V); + DerSurf.SetValue(1, 1, theD2UV); + DerSurf.SetValue(2, 0, theD2U); + DerSurf.SetValue(0, 2, theD2V); + if (!myBaseSurf.IsNull()) + derivatives(MaxOrder, 2, theU, theV, myBaseSurf, 1, 1, AlongU, AlongV, L, DerNUV, DerSurf); + else + derivatives(MaxOrder, 2, theU, theV, myBaseAdaptor, 1, 1, AlongU, AlongV, L, DerNUV, DerSurf); + + gp_Dir Normal; + CSLib_NormalStatus NStatus; + CSLib::Normal(MaxOrder, DerNUV, MagTol, theU, theV, Umin, Umax, Vmin, Vmax, NStatus, Normal, OrderU, OrderV); + if (NStatus == CSLib_InfinityOfSolutions) + { + gp_Vec aNewDU = theD1U; + gp_Vec aNewDV = theD1V; + // Replace zero derivative and try to calculate normal + if (ReplaceDerivative(theU, theV, aNewDU, aNewDV, MagTol * MagTol)) + { + DerSurf.SetValue(1, 0, aNewDU); + DerSurf.SetValue(0, 1, aNewDV); + if (!myBaseSurf.IsNull()) + derivatives(MaxOrder, 2, theU, theV, myBaseSurf, 1, 1, AlongU, AlongV, L, DerNUV, DerSurf); + else + derivatives(MaxOrder, 2, theU, theV, myBaseAdaptor, 1, 1, AlongU, AlongV, L, DerNUV, DerSurf); + CSLib::Normal(MaxOrder, DerNUV, MagTol, theU, theV, Umin, Umax, Vmin, Vmax, + NStatus, Normal, OrderU, OrderV); + } + } + + if (NStatus != CSLib_Defined) + Geom_UndefinedValue::Raise( + "GeomEvaluator_OffsetSurface::CalculateD1(): Unable to calculate normal"); + + theValue.SetXYZ(theValue.XYZ() + myOffset * aSign * Normal.XYZ()); + + theD1U = DerSurf(1, 0) + myOffset * aSign * CSLib::DNNormal(1, 0, DerNUV, OrderU, OrderV); + theD1V = DerSurf(0, 1) + myOffset * aSign * CSLib::DNNormal(0, 1, DerNUV, OrderU, OrderV); +} + +void GeomEvaluator_OffsetSurface::CalculateD2( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV, + const gp_Vec& theD3U, const gp_Vec& theD3V, const gp_Vec& theD3UUV, const gp_Vec& theD3UVV) const +{ + const Standard_Real MagTol = 1.e-9; + + gp_Dir Normal; + CSLib_NormalStatus NStatus; + CSLib::Normal(theD1U, theD1V, MagTol, NStatus, Normal); + + const Standard_Integer MaxOrder = (NStatus == CSLib_Defined) ? 0 : 3; + Standard_Integer OrderU, OrderV; + TColgp_Array2OfVec DerNUV(0, MaxOrder + 2, 0, MaxOrder + 2); + TColgp_Array2OfVec DerSurf(0, MaxOrder + 3, 0, MaxOrder + 3); + + Standard_Real Umin = 0, Umax = 0, Vmin = 0, Vmax = 0; + Bounds(Umin, Umax, Vmin, Vmax); + + DerSurf.SetValue(1, 0, theD1U); + DerSurf.SetValue(0, 1, theD1V); + DerSurf.SetValue(1, 1, theD2UV); + DerSurf.SetValue(2, 0, theD2U); + DerSurf.SetValue(0, 2, theD2V); + DerSurf.SetValue(3, 0, theD3U); + DerSurf.SetValue(2, 1, theD3UUV); + DerSurf.SetValue(1, 2, theD3UVV); + DerSurf.SetValue(0, 3, theD3V); + //********************* + + Handle(Geom_BSplineSurface) L; + Standard_Boolean isOpposite = Standard_False; + Standard_Boolean AlongU = Standard_False; + Standard_Boolean AlongV = Standard_False; + if (!myOscSurf.IsNull()) + { + AlongU = myOscSurf->UOscSurf(theU, theV, isOpposite, L); + AlongV = myOscSurf->VOscSurf(theU, theV, isOpposite, L); + } + const Standard_Real aSign = ((AlongV || AlongU) && isOpposite) ? -1. : 1.; + + if (!myBaseSurf.IsNull()) + derivatives(MaxOrder, 3, theU, theV, myBaseSurf, 2, 2, AlongU, AlongV, L, DerNUV, DerSurf); + else + derivatives(MaxOrder, 3, theU, theV, myBaseAdaptor, 2, 2, AlongU, AlongV, L, DerNUV, DerSurf); + + CSLib::Normal(MaxOrder, DerNUV, MagTol, theU, theV, Umin, Umax, Vmin, Vmax, + NStatus, Normal, OrderU, OrderV); + if (NStatus != CSLib_Defined) + Geom_UndefinedValue::Raise( + "GeomEvaluator_OffsetSurface::CalculateD2(): Unable to calculate normal"); + + theValue.SetXYZ(theValue.XYZ() + myOffset * aSign * Normal.XYZ()); + + theD1U = DerSurf(1, 0) + myOffset * aSign * CSLib::DNNormal(1, 0, DerNUV, OrderU, OrderV); + theD1V = DerSurf(0, 1) + myOffset * aSign * CSLib::DNNormal(0, 1, DerNUV, OrderU, OrderV); + + if (!myBaseSurf.IsNull()) + { + theD2U = myBaseSurf->DN(theU, theV, 2, 0); + theD2V = myBaseSurf->DN(theU, theV, 0, 2); + theD2UV = myBaseSurf->DN(theU, theV, 1, 1); + } + else + { + theD2U = myBaseAdaptor->DN(theU, theV, 2, 0); + theD2V = myBaseAdaptor->DN(theU, theV, 0, 2); + theD2UV = myBaseAdaptor->DN(theU, theV, 1, 1); + } + + theD2U += aSign * myOffset * CSLib::DNNormal(2, 0, DerNUV, OrderU, OrderV); + theD2V += aSign * myOffset * CSLib::DNNormal(0, 2, DerNUV, OrderU, OrderV); + theD2UV += aSign * myOffset * CSLib::DNNormal(1, 1, DerNUV, OrderU, OrderV); +} + +void GeomEvaluator_OffsetSurface::CalculateD3( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV, + gp_Vec& theD3U, gp_Vec& theD3V, gp_Vec& theD3UUV, gp_Vec& theD3UVV) const +{ + const Standard_Real MagTol = 1.e-9; + + gp_Dir Normal; + CSLib_NormalStatus NStatus; + CSLib::Normal(theD1U, theD1V, MagTol, NStatus, Normal); + const Standard_Integer MaxOrder = (NStatus == CSLib_Defined) ? 0 : 3; + Standard_Integer OrderU, OrderV; + TColgp_Array2OfVec DerNUV(0, MaxOrder + 3, 0, MaxOrder + 3); + TColgp_Array2OfVec DerSurf(0, MaxOrder + 4, 0, MaxOrder + 4); + Standard_Real Umin = 0, Umax = 0, Vmin = 0, Vmax = 0; + Bounds(Umin, Umax, Vmin, Vmax); + + DerSurf.SetValue(1, 0, theD1U); + DerSurf.SetValue(0, 1, theD1V); + DerSurf.SetValue(1, 1, theD2UV); + DerSurf.SetValue(2, 0, theD2U); + DerSurf.SetValue(0, 2, theD2V); + DerSurf.SetValue(3, 0, theD3U); + DerSurf.SetValue(2, 1, theD3UUV); + DerSurf.SetValue(1, 2, theD3UVV); + DerSurf.SetValue(0, 3, theD3V); + + + //********************* + Handle(Geom_BSplineSurface) L; + Standard_Boolean isOpposite = Standard_False; + Standard_Boolean AlongU = Standard_False; + Standard_Boolean AlongV = Standard_False; + if (!myOscSurf.IsNull()) + { + AlongU = myOscSurf->UOscSurf(theU, theV, isOpposite, L); + AlongV = myOscSurf->VOscSurf(theU, theV, isOpposite, L); + } + const Standard_Real aSign = ((AlongV || AlongU) && isOpposite) ? -1. : 1.; + + if (!myBaseSurf.IsNull()) + derivatives(MaxOrder, 3, theU, theV, myBaseSurf, 3, 3, AlongU, AlongV, L, DerNUV, DerSurf); + else + derivatives(MaxOrder, 3, theU, theV, myBaseAdaptor, 3, 3, AlongU, AlongV, L, DerNUV, DerSurf); + + CSLib::Normal(MaxOrder, DerNUV, MagTol, theU, theV, Umin, Umax, Vmin, Vmax, + NStatus, Normal, OrderU, OrderV); + if (NStatus != CSLib_Defined) + Geom_UndefinedValue::Raise( + "GeomEvaluator_OffsetSurface::CalculateD3(): Unable to calculate normal"); + + theValue.SetXYZ(theValue.XYZ() + myOffset * aSign * Normal.XYZ()); + + theD1U = DerSurf(1, 0) + myOffset * aSign * CSLib::DNNormal(1, 0, DerNUV, OrderU, OrderV); + theD1V = DerSurf(0, 1) + myOffset * aSign * CSLib::DNNormal(0, 1, DerNUV, OrderU, OrderV); + + if (!myBaseSurf.IsNull()) + { + theD2U = myBaseSurf->DN(theU, theV, 2, 0); + theD2V = myBaseSurf->DN(theU, theV, 0, 2); + theD2UV = myBaseSurf->DN(theU, theV, 1, 1); + theD3U = myBaseSurf->DN(theU, theV, 3, 0); + theD3V = myBaseSurf->DN(theU, theV, 0, 3); + theD3UUV = myBaseSurf->DN(theU, theV, 2, 1); + theD3UVV = myBaseSurf->DN(theU, theV, 1, 2); + } + else + { + theD2U = myBaseAdaptor->DN(theU, theV, 2, 0); + theD2V = myBaseAdaptor->DN(theU, theV, 0, 2); + theD2UV = myBaseAdaptor->DN(theU, theV, 1, 1); + theD3U = myBaseAdaptor->DN(theU, theV, 3, 0); + theD3V = myBaseAdaptor->DN(theU, theV, 0, 3); + theD3UUV = myBaseAdaptor->DN(theU, theV, 2, 1); + theD3UVV = myBaseAdaptor->DN(theU, theV, 1, 2); + } + + theD2U += aSign * myOffset * CSLib::DNNormal(2, 0, DerNUV, OrderU, OrderV); + theD2V += aSign * myOffset * CSLib::DNNormal(0, 2, DerNUV, OrderU, OrderV); + theD2UV += aSign * myOffset * CSLib::DNNormal(1, 1, DerNUV, OrderU, OrderV); + theD3U += aSign * myOffset * CSLib::DNNormal(3, 0, DerNUV, OrderU, OrderV); + theD3V += aSign * myOffset * CSLib::DNNormal(0, 3, DerNUV, OrderU, OrderV); + theD3UUV += aSign * myOffset * CSLib::DNNormal(2, 1, DerNUV, OrderU, OrderV); + theD3UVV += aSign * myOffset * CSLib::DNNormal(1, 2, DerNUV, OrderU, OrderV); +} + +gp_Vec GeomEvaluator_OffsetSurface::CalculateDN( + const Standard_Real theU, const Standard_Real theV, + const Standard_Integer theNu, const Standard_Integer theNv, + const gp_Vec& theD1U, const gp_Vec& theD1V) const +{ + const Standard_Real MagTol = 1.e-9; + + gp_Dir Normal; + CSLib_NormalStatus NStatus; + CSLib::Normal(theD1U, theD1V, MagTol, NStatus, Normal); + const Standard_Integer MaxOrder = (NStatus == CSLib_Defined) ? 0 : 3; + Standard_Integer OrderU, OrderV; + TColgp_Array2OfVec DerNUV(0, MaxOrder + theNu, 0, MaxOrder + theNu); + TColgp_Array2OfVec DerSurf(0, MaxOrder + theNu + 1, 0, MaxOrder + theNv + 1); + + Standard_Real Umin = 0, Umax = 0, Vmin = 0, Vmax = 0; + Bounds(Umin, Umax, Vmin, Vmax); + + DerSurf.SetValue(1, 0, theD1U); + DerSurf.SetValue(0, 1, theD1V); + + //********************* + Handle(Geom_BSplineSurface) L; + // Is there any osculatingsurface along U or V; + Standard_Boolean isOpposite = Standard_False; + Standard_Boolean AlongU = Standard_False; + Standard_Boolean AlongV = Standard_False; + if (!myOscSurf.IsNull()) + { + AlongU = myOscSurf->UOscSurf(theU, theV, isOpposite, L); + AlongV = myOscSurf->VOscSurf(theU, theV, isOpposite, L); + } + const Standard_Real aSign = ((AlongV || AlongU) && isOpposite) ? -1. : 1.; + + if (!myBaseSurf.IsNull()) + derivatives(MaxOrder, 1, theU, theV, myBaseSurf, theNu, theNv, AlongU, AlongV, L, DerNUV, DerSurf); + else + derivatives(MaxOrder, 1, theU, theV, myBaseAdaptor, theNu, theNv, AlongU, AlongV, L, DerNUV, DerSurf); + + CSLib::Normal(MaxOrder, DerNUV, MagTol, theU, theV, Umin, Umax, Vmin, Vmax, + NStatus, Normal, OrderU, OrderV); + if (NStatus != CSLib_Defined) + Geom_UndefinedValue::Raise( + "GeomEvaluator_OffsetSurface::CalculateDN(): Unable to calculate normal"); + + gp_Vec D; + if (!myBaseSurf.IsNull()) + D = myBaseSurf->DN(theU, theV, theNu, theNv); + else + D = myBaseAdaptor->DN(theU, theV, theNu, theNv); + + D += aSign * myOffset * CSLib::DNNormal(theNu, theNv, DerNUV, OrderU, OrderV); + return D; +} + + +void GeomEvaluator_OffsetSurface::Bounds(Standard_Real& theUMin, Standard_Real& theUMax, + Standard_Real& theVMin, Standard_Real& theVMax) const +{ + if (!myBaseSurf.IsNull()) + myBaseSurf->Bounds(theUMin, theUMax, theVMin, theVMax); + else + { + theUMin = myBaseAdaptor->FirstUParameter(); + theUMax = myBaseAdaptor->LastUParameter(); + theVMin = myBaseAdaptor->FirstVParameter(); + theVMax = myBaseAdaptor->LastVParameter(); + } +} + + +Standard_Boolean GeomEvaluator_OffsetSurface::ReplaceDerivative( + const Standard_Real theU, const Standard_Real theV, + gp_Vec& theDU, gp_Vec& theDV, + const Standard_Real theSquareTol) const +{ + Standard_Boolean isReplaceDU = theDU.SquareMagnitude() < theSquareTol; + Standard_Boolean isReplaceDV = theDV.SquareMagnitude() < theSquareTol; + Standard_Boolean isReplaced = Standard_False; + if (isReplaceDU ^ isReplaceDV) + { + Standard_Real aU = theU; + Standard_Real aV = theV; + Standard_Real aUMin = 0, aUMax = 0, aVMin = 0, aVMax = 0; + Bounds(aUMin, aUMax, aVMin, aVMax); + + // Calculate step along non-zero derivative + Standard_Real aStep; + Handle(Adaptor3d_HSurface) aSurfAdapt; + if (!myBaseAdaptor.IsNull()) + aSurfAdapt = myBaseAdaptor; + else + aSurfAdapt = new GeomAdaptor_HSurface(myBaseSurf); + if (isReplaceDV) + { + aStep = Precision::Confusion() * theDU.Magnitude(); + if (aStep > aUMax - aUMin) + aStep = (aUMax - aUMin) / 100.; + } + else + { + aStep = Precision::Confusion() * theDV.Magnitude(); + if (aStep > aVMax - aVMin) + aStep = (aVMax - aVMin) / 100.; + } + + gp_Pnt aP; + gp_Vec aDU, aDV; + // Step away from currect parametric coordinates and calculate derivatives once again. + // Replace zero derivative by the obtained. + for (Standard_Real aStepSign = -1.0; aStepSign <= 1.0 && !isReplaced; aStepSign += 2.0) + { + if (isReplaceDV) + { + aU = theU + aStepSign * aStep; + if (aU < aUMin || aU > aUMax) + continue; + } + else + { + aV = theV + aStepSign * aStep; + if (aV < aVMin || aV > aVMax) + continue; + } + + BaseD1(aU, aV, aP, aDU, aDV); + + if (isReplaceDU && aDU.SquareMagnitude() > theSquareTol) + { + theDU = aDU; + isReplaced = Standard_True; + } + if (isReplaceDV && aDV.SquareMagnitude() > theSquareTol) + { + theDV = aDV; + isReplaced = Standard_True; + } + } + } + return isReplaced; +} + + + + + +// ===================== Auxiliary functions =================================== +template +void derivatives(Standard_Integer theMaxOrder, + Standard_Integer theMinOrder, + const Standard_Real theU, + const Standard_Real theV, + const SurfOrAdapt& theBasisSurf, + const Standard_Integer theNU, + const Standard_Integer theNV, + const Standard_Boolean theAlongU, + const Standard_Boolean theAlongV, + const Handle(Geom_BSplineSurface)& theL, + TColgp_Array2OfVec& theDerNUV, + TColgp_Array2OfVec& theDerSurf) +{ + Standard_Integer i, j; + gp_Pnt P; + gp_Vec DL1U, DL1V, DL2U, DL2V, DL2UV, DL3U, DL3UUV, DL3UVV, DL3V; + + if (theAlongU || theAlongV) + { + theMaxOrder = 0; + TColgp_Array2OfVec DerSurfL(0, theMaxOrder + theNU + 1, 0, theMaxOrder + theNV + 1); + switch (theMinOrder) + { + case 1: + theL->D1(theU, theV, P, DL1U, DL1V); + DerSurfL.SetValue(1, 0, DL1U); + DerSurfL.SetValue(0, 1, DL1V); + break; + case 2: + theL->D2(theU, theV, P, DL1U, DL1V, DL2U, DL2V, DL2UV); + DerSurfL.SetValue(1, 0, DL1U); + DerSurfL.SetValue(0, 1, DL1V); + DerSurfL.SetValue(1, 1, DL2UV); + DerSurfL.SetValue(2, 0, DL2U); + DerSurfL.SetValue(0, 2, DL2V); + break; + case 3: + theL->D3(theU, theV, P, DL1U, DL1V, DL2U, DL2V, DL2UV, DL3U, DL3V, DL3UUV, DL3UVV); + DerSurfL.SetValue(1, 0, DL1U); + DerSurfL.SetValue(0, 1, DL1V); + DerSurfL.SetValue(1, 1, DL2UV); + DerSurfL.SetValue(2, 0, DL2U); + DerSurfL.SetValue(0, 2, DL2V); + DerSurfL.SetValue(3, 0, DL3U); + DerSurfL.SetValue(2, 1, DL3UUV); + DerSurfL.SetValue(1, 2, DL3UVV); + DerSurfL.SetValue(0, 3, DL3V); + break; + default: + break; + } + + if (theNU <= theNV) + { + for (i = 0; i <= theMaxOrder + 1 + theNU; i++) + for (j = i; j <= theMaxOrder + theNV + 1; j++) + if (i + j > theMinOrder) + { + DerSurfL.SetValue(i, j, theL->DN(theU, theV, i, j)); + theDerSurf.SetValue(i, j, theBasisSurf->DN(theU, theV, i, j)); + if (i != j && j <= theNU + 1) + { + theDerSurf.SetValue(j, i, theBasisSurf->DN(theU, theV, j, i)); + DerSurfL.SetValue(j, i, theL->DN(theU, theV, j, i)); + } + } + } + else + { + for (j = 0; j <= theMaxOrder + 1 + theNV; j++) + for (i = j; i <= theMaxOrder + theNU + 1; i++) + if (i + j > theMinOrder) + { + DerSurfL.SetValue(i, j, theL->DN(theU, theV, i, j)); + theDerSurf.SetValue(i, j, theBasisSurf->DN(theU, theV, i, j)); + if (i != j && i <= theNV + 1) + { + theDerSurf.SetValue(j, i, theBasisSurf->DN(theU, theV, j, i)); + DerSurfL.SetValue(j, i, theL->DN(theU, theV, j, i)); + } + } + } + for (i = 0; i <= theMaxOrder + theNU; i++) + for (j = 0; j <= theMaxOrder + theNV; j++) + { + if (theAlongU) + theDerNUV.SetValue(i, j, CSLib::DNNUV(i, j, DerSurfL, theDerSurf)); + if (theAlongV) + theDerNUV.SetValue(i, j, CSLib::DNNUV(i, j, theDerSurf, DerSurfL)); + } + } + else + { + for (i = 0; i <= theMaxOrder + theNU+ 1; i++) + for (j = i; j <= theMaxOrder + theNV + 1; j++) + if (i + j > theMinOrder) + { + theDerSurf.SetValue(i, j, theBasisSurf->DN(theU, theV, i, j)); + if (i != j) + theDerSurf.SetValue(j, i, theBasisSurf->DN(theU, theV, j, i)); + } + for (i = 0; i <= theMaxOrder + theNU; i++) + for (j = 0; j <= theMaxOrder + theNV; j++) + theDerNUV.SetValue(i, j, CSLib::DNNUV(i, j, theDerSurf)); + } +} + diff --git a/src/GeomEvaluator/GeomEvaluator_OffsetSurface.hxx b/src/GeomEvaluator/GeomEvaluator_OffsetSurface.hxx new file mode 100644 index 0000000000..5bfda688e0 --- /dev/null +++ b/src/GeomEvaluator/GeomEvaluator_OffsetSurface.hxx @@ -0,0 +1,131 @@ +// Created on: 2015-09-21 +// Copyright (c) 2015 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _GeomEvaluator_OffsetSurface_HeaderFile +#define _GeomEvaluator_OffsetSurface_HeaderFile + +#include + +#include +#include + +class GeomAdaptor_HSurface; + +//! Allows to calculate values and derivatives for offset surfaces +class GeomEvaluator_OffsetSurface : public GeomEvaluator_Surface +{ +public: + //! Initialize evaluator by surface + Standard_EXPORT GeomEvaluator_OffsetSurface( + const Handle(Geom_Surface)& theBase, + const Standard_Real theOffset, + const Handle(Geom_OsculatingSurface)& theOscSurf = Handle(Geom_OsculatingSurface)()); + //! Initialize evaluator by surface adaptor + Standard_EXPORT GeomEvaluator_OffsetSurface( + const Handle(GeomAdaptor_HSurface)& theBase, + const Standard_Real theOffset, + const Handle(Geom_OsculatingSurface)& theOscSurf = Handle(Geom_OsculatingSurface)()); + + //! Change the offset value + void SetOffsetValue(Standard_Real theOffset) + { myOffset = theOffset; } + + //! Value of surface + Standard_EXPORT void D0(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue) const Standard_OVERRIDE; + //! Value and first derivatives of surface + Standard_EXPORT void D1(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V) const Standard_OVERRIDE; + //! Value, first and second derivatives of surface + Standard_EXPORT void D2(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV) const Standard_OVERRIDE; + //! Value, first, second and third derivatives of surface + Standard_EXPORT void D3(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV, + gp_Vec& theD3U, gp_Vec& theD3V, + gp_Vec& theD3UUV, gp_Vec& theD3UVV) const Standard_OVERRIDE; + //! Calculates N-th derivatives of surface, where N = theDerU + theDerV. + //! + //! Raises if N < 1 or theDerU < 0 or theDerV < 0 + Standard_EXPORT gp_Vec DN(const Standard_Real theU, + const Standard_Real theV, + const Standard_Integer theDerU, + const Standard_Integer theDerV) const Standard_OVERRIDE; + + DEFINE_STANDARD_RTTI(GeomEvaluator_OffsetSurface, GeomEvaluator_Surface) + +private: + //! Returns bounds of a base surface + void Bounds(Standard_Real& theUMin, Standard_Real& theUMax, + Standard_Real& theVMin, Standard_Real& theVMax) const; + + //! Recalculate D1 values of base surface into D0 value of offset surface + void CalculateD0(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, + const gp_Vec& theD1U, const gp_Vec& theD1V) const; + //! Recalculate D2 values of base surface into D1 values of offset surface + void CalculateD1(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + const gp_Vec& theD2U, const gp_Vec& theD2V, const gp_Vec& theD2UV) const; + //! Recalculate D3 values of base surface into D2 values of offset surface + void CalculateD2(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV, + const gp_Vec& theD3U, const gp_Vec& theD3V, + const gp_Vec& theD3UUV, const gp_Vec& theD3UVV) const; + //! Recalculate D3 values of base surface into D3 values of offset surface + void CalculateD3(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV, + gp_Vec& theD3U, gp_Vec& theD3V, gp_Vec& theD3UUV, gp_Vec& theD3UVV) const; + //! Calculate DN of offset surface based on derivatives of base surface + gp_Vec CalculateDN(const Standard_Real theU, const Standard_Real theV, + const Standard_Integer theNu, const Standard_Integer theNv, + const gp_Vec& theD1U, const gp_Vec& theD1V) const; + + //! Calculate value of base surface/adaptor + void BaseD0(const Standard_Real theU, const Standard_Real theV, gp_Pnt& theValue) const; + //! Calculate value and first derivatives of base surface/adaptor + void BaseD1(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V) const; + //! Calculate value, first and second derivatives of base surface/adaptor + void BaseD2(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV) const; + //! Calculate value, first, second and third derivatives of base surface/adaptor + void BaseD3(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV, + gp_Vec& theD3U, gp_Vec& theD3V, gp_Vec& theD3UUV, gp_Vec& theD3UVV) const; + + //! Replace zero derivative by the corresponding derivative in a near point. + //! Return true, if the derivative was replaced. + Standard_Boolean ReplaceDerivative(const Standard_Real theU, const Standard_Real theV, + gp_Vec& theDU, gp_Vec& theDV, + const Standard_Real theSquareTol) const; + +private: + Handle(Geom_Surface) myBaseSurf; + Handle(GeomAdaptor_HSurface) myBaseAdaptor; + + Standard_Real myOffset; ///< offset value + Handle(Geom_OsculatingSurface) myOscSurf; ///< auxiliary osculating surface +}; + +DEFINE_STANDARD_HANDLE(GeomEvaluator_OffsetSurface, GeomEvaluator_Surface) + + +#endif // _GeomEvaluator_OffsetSurface_HeaderFile diff --git a/src/GeomEvaluator/GeomEvaluator_Surface.hxx b/src/GeomEvaluator/GeomEvaluator_Surface.hxx new file mode 100644 index 0000000000..3d24938b97 --- /dev/null +++ b/src/GeomEvaluator/GeomEvaluator_Surface.hxx @@ -0,0 +1,58 @@ +// Created on: 2015-09-21 +// Copyright (c) 2015 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _GeomEvaluator_Surface_HeaderFile +#define _GeomEvaluator_Surface_HeaderFile + +#include +#include + +class gp_Pnt; +class gp_Vec; + +//! Interface for calculation of values and derivatives for different kinds of surfaces. +//! Works both with adaptors and surfaces. +class GeomEvaluator_Surface : public Standard_Transient +{ +public: + GeomEvaluator_Surface() {} + + //! Value of surface + virtual void D0(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue) const = 0; + //! Value and first derivatives of surface + virtual void D1(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V) const = 0; + //! Value, first and second derivatives of surface + virtual void D2(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV) const = 0; + //! Value, first, second and third derivatives of surface + virtual void D3(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV, + gp_Vec& theD3U, gp_Vec& theD3V, gp_Vec& theD3UUV, gp_Vec& theD3UVV) const = 0; + //! Calculates N-th derivatives of surface, where N = theDerU + theDerV. + //! + //! Raises if N < 1 or theDerU < 0 or theDerV < 0 + virtual gp_Vec DN(const Standard_Real theU, const Standard_Real theV, + const Standard_Integer theDerU, const Standard_Integer theDerV) const = 0; + + DEFINE_STANDARD_RTTI(GeomEvaluator_Surface, Standard_Transient) +}; + +DEFINE_STANDARD_HANDLE(GeomEvaluator_Surface, Standard_Transient) + + +#endif // _GeomEvaluator_Surface_HeaderFile diff --git a/src/GeomEvaluator/GeomEvaluator_SurfaceOfExtrusion.cxx b/src/GeomEvaluator/GeomEvaluator_SurfaceOfExtrusion.cxx new file mode 100644 index 0000000000..ece0d27543 --- /dev/null +++ b/src/GeomEvaluator/GeomEvaluator_SurfaceOfExtrusion.cxx @@ -0,0 +1,119 @@ +// Created on: 2015-09-21 +// Copyright (c) 2015 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include + +GeomEvaluator_SurfaceOfExtrusion::GeomEvaluator_SurfaceOfExtrusion( + const Handle(Geom_Curve)& theBase, const gp_Dir& theExtrusionDir) + : GeomEvaluator_Surface(), + myBaseCurve(theBase), + myDirection(theExtrusionDir) +{ +} + +GeomEvaluator_SurfaceOfExtrusion::GeomEvaluator_SurfaceOfExtrusion( + const Handle(Adaptor3d_HCurve)& theBase, const gp_Dir& theExtrusionDir) + : GeomEvaluator_Surface(), + myBaseAdaptor(theBase), + myDirection(theExtrusionDir) +{ +} + +void GeomEvaluator_SurfaceOfExtrusion::D0( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue) const +{ + if (!myBaseAdaptor.IsNull()) + myBaseAdaptor->D0(theU, theValue); + else + myBaseCurve->D0(theU, theValue); + + Shift(theV, theValue); +} + +void GeomEvaluator_SurfaceOfExtrusion::D1( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V) const +{ + if (!myBaseAdaptor.IsNull()) + myBaseAdaptor->D1(theU, theValue, theD1U); + else + myBaseCurve->D1(theU, theValue, theD1U); + + theD1V = myDirection; + Shift(theV, theValue); +} + +void GeomEvaluator_SurfaceOfExtrusion::D2( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV) const +{ + if (!myBaseAdaptor.IsNull()) + myBaseAdaptor->D2(theU, theValue, theD1U, theD2U); + else + myBaseCurve->D2(theU, theValue, theD1U, theD2U); + + theD1V = myDirection; + theD2V.SetCoord(0.0, 0.0, 0.0); + theD2UV.SetCoord(0.0, 0.0, 0.0); + + Shift(theV, theValue); +} + +void GeomEvaluator_SurfaceOfExtrusion::D3( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV, + gp_Vec& theD3U, gp_Vec& theD3V, gp_Vec& theD3UUV, gp_Vec& theD3UVV) const +{ + if (!myBaseAdaptor.IsNull()) + myBaseAdaptor->D3(theU, theValue, theD1U, theD2U, theD3U); + else + myBaseCurve->D3(theU, theValue, theD1U, theD2U, theD3U); + + theD1V = myDirection; + theD2V.SetCoord(0.0, 0.0, 0.0); + theD2UV.SetCoord(0.0, 0.0, 0.0); + theD3V.SetCoord(0.0, 0.0, 0.0); + theD3UUV.SetCoord(0.0, 0.0, 0.0); + theD3UVV.SetCoord(0.0, 0.0, 0.0); + + Shift(theV, theValue); +} + +gp_Vec GeomEvaluator_SurfaceOfExtrusion::DN( + const Standard_Real theU, const Standard_Real , + const Standard_Integer theDerU, const Standard_Integer theDerV) const +{ + Standard_RangeError_Raise_if(theDerU < 0, "GeomEvaluator_SurfaceOfExtrusion::DN(): theDerU < 0"); + Standard_RangeError_Raise_if(theDerV < 0, "GeomEvaluator_SurfaceOfExtrusion::DN(): theDerV < 0"); + Standard_RangeError_Raise_if(theDerU + theDerV < 1, + "GeomEvaluator_SurfaceOfExtrusion::DN(): theDerU + theDerV < 1"); + + gp_Vec aResult(0.0, 0.0, 0.0); + if (theDerV == 0) + { + if (!myBaseAdaptor.IsNull()) + aResult = myBaseAdaptor->DN(theU, theDerU); + else + aResult = myBaseCurve->DN(theU, theDerU); + } + else if (theDerU == 0 && theDerV == 1) + aResult = gp_Vec(myDirection); + return aResult; +} + diff --git a/src/GeomEvaluator/GeomEvaluator_SurfaceOfExtrusion.hxx b/src/GeomEvaluator/GeomEvaluator_SurfaceOfExtrusion.hxx new file mode 100644 index 0000000000..ce42a49c37 --- /dev/null +++ b/src/GeomEvaluator/GeomEvaluator_SurfaceOfExtrusion.hxx @@ -0,0 +1,83 @@ +// Created on: 2015-09-21 +// Copyright (c) 2015 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _GeomEvaluator_SurfaceOfExtrusion_HeaderFile +#define _GeomEvaluator_SurfaceOfExtrusion_HeaderFile + +#include + +#include +#include + +class Adaptor3d_HCurve; + +//! Allows to calculate values and derivatives for surfaces of linear extrusion +class GeomEvaluator_SurfaceOfExtrusion : public GeomEvaluator_Surface +{ +public: + //! Initialize evaluator by surface + Standard_EXPORT GeomEvaluator_SurfaceOfExtrusion(const Handle(Geom_Curve)& theBase, + const gp_Dir& theExtrusionDir); + //! Initialize evaluator by surface adaptor + Standard_EXPORT GeomEvaluator_SurfaceOfExtrusion(const Handle(Adaptor3d_HCurve)& theBase, + const gp_Dir& theExtrusionDir); + + ///! Changes the direction of extrusion + void SetDirection(const gp_Dir& theDirection) + { myDirection = theDirection; } + + //! Value of surface + Standard_EXPORT void D0(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue) const Standard_OVERRIDE; + //! Value and first derivatives of surface + Standard_EXPORT void D1(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V) const Standard_OVERRIDE; + //! Value, first and second derivatives of surface + Standard_EXPORT void D2(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV) const Standard_OVERRIDE; + //! Value, first, second and third derivatives of surface + Standard_EXPORT void D3(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV, + gp_Vec& theD3U, gp_Vec& theD3V, + gp_Vec& theD3UUV, gp_Vec& theD3UVV) const Standard_OVERRIDE; + //! Calculates N-th derivatives of surface, where N = theDerU + theDerV. + //! + //! Raises if N < 1 or theDerU < 0 or theDerV < 0 + Standard_EXPORT gp_Vec DN(const Standard_Real theU, + const Standard_Real theV, + const Standard_Integer theDerU, + const Standard_Integer theDerV) const Standard_OVERRIDE; + + DEFINE_STANDARD_RTTI(GeomEvaluator_SurfaceOfExtrusion, GeomEvaluator_Surface) + +private: + //! Shift the point along direction to the given distance (theShift) + void Shift(const Standard_Real theShift, gp_Pnt& thePoint) const + { + thePoint.ChangeCoord() += myDirection.XYZ() * theShift; + } + +private: + Handle(Geom_Curve) myBaseCurve; + Handle(Adaptor3d_HCurve) myBaseAdaptor; + + gp_Dir myDirection; +}; + +DEFINE_STANDARD_HANDLE(GeomEvaluator_SurfaceOfExtrusion, GeomEvaluator_Surface) + + +#endif // _GeomEvaluator_SurfaceOfExtrusion_HeaderFile diff --git a/src/GeomEvaluator/GeomEvaluator_SurfaceOfRevolution.cxx b/src/GeomEvaluator/GeomEvaluator_SurfaceOfRevolution.cxx new file mode 100644 index 0000000000..b93932eff1 --- /dev/null +++ b/src/GeomEvaluator/GeomEvaluator_SurfaceOfRevolution.cxx @@ -0,0 +1,202 @@ +// Created on: 2015-09-21 +// Copyright (c) 2015 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#include + +#include +#include + +GeomEvaluator_SurfaceOfRevolution::GeomEvaluator_SurfaceOfRevolution( + const Handle(Geom_Curve)& theBase, + const gp_Dir& theRevolDir, + const gp_Pnt& theRevolLoc) + : GeomEvaluator_Surface(), + myBaseCurve(theBase), + myRotAxis(theRevolLoc, theRevolDir) +{ +} + +GeomEvaluator_SurfaceOfRevolution::GeomEvaluator_SurfaceOfRevolution( + const Handle(Adaptor3d_HCurve)& theBase, + const gp_Dir& theRevolDir, + const gp_Pnt& theRevolLoc) + : GeomEvaluator_Surface(), + myBaseAdaptor(theBase), + myRotAxis(theRevolLoc, theRevolDir) +{ +} + +void GeomEvaluator_SurfaceOfRevolution::D0( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue) const +{ + if (!myBaseAdaptor.IsNull()) + myBaseAdaptor->D0(theV, theValue); + else + myBaseCurve->D0(theV, theValue); + + gp_Trsf aRotation; + aRotation.SetRotation(myRotAxis, theU); + theValue.Transform(aRotation); +} + +void GeomEvaluator_SurfaceOfRevolution::D1( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V) const +{ + if (!myBaseAdaptor.IsNull()) + myBaseAdaptor->D1(theV, theValue, theD1V); + else + myBaseCurve->D1(theV, theValue, theD1V); + + // vector from center of rotation to the point on rotated curve + gp_XYZ aCQ = theValue.XYZ() - myRotAxis.Location().XYZ(); + theD1U = gp_Vec(myRotAxis.Direction().XYZ().Crossed(aCQ)); + // If the point is placed on the axis of revolution then derivatives on U are undefined. + // Manually set them to zero. + if (theD1U.SquareMagnitude() < Precision::SquareConfusion()) + theD1U.SetCoord(0.0, 0.0, 0.0); + + gp_Trsf aRotation; + aRotation.SetRotation(myRotAxis, theU); + theValue.Transform(aRotation); + theD1U.Transform(aRotation); + theD1V.Transform(aRotation); +} + +void GeomEvaluator_SurfaceOfRevolution::D2( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV) const +{ + if (!myBaseAdaptor.IsNull()) + myBaseAdaptor->D2(theV, theValue, theD1V, theD2V); + else + myBaseCurve->D2(theV, theValue, theD1V, theD2V); + + // vector from center of rotation to the point on rotated curve + gp_XYZ aCQ = theValue.XYZ() - myRotAxis.Location().XYZ(); + const gp_XYZ& aDir = myRotAxis.Direction().XYZ(); + theD1U = gp_Vec(aDir.Crossed(aCQ)); + // If the point is placed on the axis of revolution then derivatives on U are undefined. + // Manually set them to zero. + if (theD1U.SquareMagnitude() < Precision::SquareConfusion()) + theD1U.SetCoord(0.0, 0.0, 0.0); + theD2U = gp_Vec(aDir.Dot(aCQ) * aDir - aCQ); + theD2UV = gp_Vec(aDir.Crossed(theD1V.XYZ())); + + gp_Trsf aRotation; + aRotation.SetRotation(myRotAxis, theU); + theValue.Transform(aRotation); + theD1U.Transform(aRotation); + theD1V.Transform(aRotation); + theD2U.Transform(aRotation); + theD2V.Transform(aRotation); + theD2UV.Transform(aRotation); +} + +void GeomEvaluator_SurfaceOfRevolution::D3( + const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV, + gp_Vec& theD3U, gp_Vec& theD3V, gp_Vec& theD3UUV, gp_Vec& theD3UVV) const +{ + if (!myBaseAdaptor.IsNull()) + myBaseAdaptor->D3(theV, theValue, theD1V, theD2V, theD3V); + else + myBaseCurve->D3(theV, theValue, theD1V, theD2V, theD3V); + + // vector from center of rotation to the point on rotated curve + gp_XYZ aCQ = theValue.XYZ() - myRotAxis.Location().XYZ(); + const gp_XYZ& aDir = myRotAxis.Direction().XYZ(); + theD1U = gp_Vec(aDir.Crossed(aCQ)); + // If the point is placed on the axis of revolution then derivatives on U are undefined. + // Manually set them to zero. + if (theD1U.SquareMagnitude() < Precision::SquareConfusion()) + theD1U.SetCoord(0.0, 0.0, 0.0); + theD2U = gp_Vec(aDir.Dot(aCQ) * aDir - aCQ); + theD2UV = gp_Vec(aDir.Crossed(theD1V.XYZ())); + theD3U = -theD1U; + theD3UUV = gp_Vec(aDir.Dot(theD1V.XYZ()) * aDir - theD1V.XYZ()); + theD3UVV = gp_Vec(aDir.Crossed(theD2V.XYZ())); + + gp_Trsf aRotation; + aRotation.SetRotation(myRotAxis, theU); + theValue.Transform(aRotation); + theD1U.Transform(aRotation); + theD1V.Transform(aRotation); + theD2U.Transform(aRotation); + theD2V.Transform(aRotation); + theD2UV.Transform(aRotation); + theD3U.Transform(aRotation); + theD3V.Transform(aRotation); + theD3UUV.Transform(aRotation); + theD3UVV.Transform(aRotation); +} + +gp_Vec GeomEvaluator_SurfaceOfRevolution::DN( + const Standard_Real theU, const Standard_Real theV, + const Standard_Integer theDerU, const Standard_Integer theDerV) const +{ + Standard_RangeError_Raise_if(theDerU < 0, "GeomEvaluator_SurfaceOfRevolution::DN(): theDerU < 0"); + Standard_RangeError_Raise_if(theDerV < 0, "GeomEvaluator_SurfaceOfRevolution::DN(): theDerV < 0"); + Standard_RangeError_Raise_if(theDerU + theDerV < 1, + "GeomEvaluator_SurfaceOfRevolution::DN(): theDerU + theDerV < 1"); + + gp_Trsf aRotation; + aRotation.SetRotation(myRotAxis, theU); + + gp_Pnt aP; + gp_Vec aDV; + gp_Vec aResult; + if (theDerU == 0) + { + if (!myBaseAdaptor.IsNull()) + aResult = myBaseAdaptor->DN(theV, theDerV); + else + aResult = myBaseCurve->DN(theV, theDerV); + } + else + { + if (theDerV == 0) + { + if (!myBaseAdaptor.IsNull()) + myBaseAdaptor->D0(theV, aP); + else + myBaseCurve->D0(theV, aP); + aDV = gp_Vec(aP.XYZ() - myRotAxis.Location().XYZ()); + } + else + { + if (!myBaseAdaptor.IsNull()) + aDV = myBaseAdaptor->DN(theV, theDerV); + else + aDV = myBaseCurve->DN(theV, theDerV); + } + + const gp_XYZ& aDir = myRotAxis.Direction().XYZ(); + if (theDerU % 4 == 1) + aResult = gp_Vec(aDir.Crossed(aDV.XYZ())); + else if (theDerU % 4 == 2) + aResult = gp_Vec(aDir.Dot(aDV.XYZ()) * aDir - aDV.XYZ()); + else if (theDerU % 4 == 3) + aResult = gp_Vec(aDir.Crossed(aDV.XYZ())) * (-1.0); + else + aResult = gp_Vec(aDV.XYZ() - aDir.Dot(aDV.XYZ()) * aDir); + } + + aResult.Transform(aRotation); + return aResult; +} + diff --git a/src/GeomEvaluator/GeomEvaluator_SurfaceOfRevolution.hxx b/src/GeomEvaluator/GeomEvaluator_SurfaceOfRevolution.hxx new file mode 100644 index 0000000000..904b2ecf72 --- /dev/null +++ b/src/GeomEvaluator/GeomEvaluator_SurfaceOfRevolution.hxx @@ -0,0 +1,87 @@ +// Created on: 2015-09-21 +// Copyright (c) 2015 OPEN CASCADE SAS +// +// This file is part of Open CASCADE Technology software library. +// +// This library is free software; you can redistribute it and/or modify it under +// the terms of the GNU Lesser General Public License version 2.1 as published +// by the Free Software Foundation, with special exception defined in the file +// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT +// distribution for complete text of the license and disclaimer of any warranty. +// +// Alternatively, this file may be used under the terms of Open CASCADE +// commercial license or contractual agreement. + +#ifndef _GeomEvaluator_SurfaceOfRevolution_HeaderFile +#define _GeomEvaluator_SurfaceOfRevolution_HeaderFile + +#include + +#include +#include +#include +#include + +class Adaptor3d_HCurve; + +//! Allows to calculate values and derivatives for surfaces of revolution +class GeomEvaluator_SurfaceOfRevolution : public GeomEvaluator_Surface +{ +public: + //! Initialize evaluator by revolved curve, the axis of revolution and the location + Standard_EXPORT GeomEvaluator_SurfaceOfRevolution(const Handle(Geom_Curve)& theBase, + const gp_Dir& theRevolDir, + const gp_Pnt& theRevolLoc); + //! Initialize evaluator by adaptor of the revolved curve, the axis of revolution and the location + Standard_EXPORT GeomEvaluator_SurfaceOfRevolution(const Handle(Adaptor3d_HCurve)& theBase, + const gp_Dir& theRevolDir, + const gp_Pnt& theRevolLoc); + + //! Change direction of the axis of revolution + void SetDirection(const gp_Dir& theDirection) + { myRotAxis.SetDirection(theDirection); } + + //! Change location of the axis of revolution + void SetLocation(const gp_Pnt& theLocation) + { myRotAxis.SetLocation(theLocation); } + + //! Change the axis of revolution + void SetAxis(const gp_Ax1& theAxis) + { myRotAxis = theAxis; } + + //! Value of surface + Standard_EXPORT void D0(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue) const Standard_OVERRIDE; + //! Value and first derivatives of surface + Standard_EXPORT void D1(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V) const Standard_OVERRIDE; + //! Value, first and second derivatives of surface + Standard_EXPORT void D2(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV) const Standard_OVERRIDE; + //! Value, first, second and third derivatives of surface + Standard_EXPORT void D3(const Standard_Real theU, const Standard_Real theV, + gp_Pnt& theValue, gp_Vec& theD1U, gp_Vec& theD1V, + gp_Vec& theD2U, gp_Vec& theD2V, gp_Vec& theD2UV, + gp_Vec& theD3U, gp_Vec& theD3V, + gp_Vec& theD3UUV, gp_Vec& theD3UVV) const Standard_OVERRIDE; + //! Calculates N-th derivatives of surface, where N = theDerU + theDerV. + //! + //! Raises if N < 1 or theDerU < 0 or theDerV < 0 + Standard_EXPORT gp_Vec DN(const Standard_Real theU, + const Standard_Real theV, + const Standard_Integer theDerU, + const Standard_Integer theDerV) const Standard_OVERRIDE; + + DEFINE_STANDARD_RTTI(GeomEvaluator_SurfaceOfRevolution, GeomEvaluator_Surface) + +private: + Handle(Geom_Curve) myBaseCurve; + Handle(Adaptor3d_HCurve) myBaseAdaptor; + gp_Ax1 myRotAxis; +}; + +DEFINE_STANDARD_HANDLE(GeomEvaluator_SurfaceOfRevolution, GeomEvaluator_Surface) + + +#endif // _GeomEvaluator_SurfaceOfRevolution_HeaderFile diff --git a/src/GeomFill/GeomFill_LocationGuide.cxx b/src/GeomFill/GeomFill_LocationGuide.cxx index 07a6ebf941..bbbdc1f8e6 100644 --- a/src/GeomFill/GeomFill_LocationGuide.cxx +++ b/src/GeomFill/GeomFill_LocationGuide.cxx @@ -18,7 +18,6 @@ #include #include #include -#include #include #include #include diff --git a/src/ShapeCustom/ShapeCustom_SweptToElementary.cxx b/src/ShapeCustom/ShapeCustom_SweptToElementary.cxx index bc40f6823f..833ba0e33a 100644 --- a/src/ShapeCustom/ShapeCustom_SweptToElementary.cxx +++ b/src/ShapeCustom/ShapeCustom_SweptToElementary.cxx @@ -12,8 +12,8 @@ // commercial license or contractual agreement. -#include -#include +#include +#include #include #include #include @@ -112,7 +112,7 @@ Standard_Boolean ShapeCustom_SweptToElementary::NewSurface(const TopoDS_Face& F, gp_Ax1 ax1 = SR->Axis(); Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(); HC->ChangeCurve().Load(bc,bc->FirstParameter(),bc->LastParameter()); - Adaptor3d_SurfaceOfRevolution AS(HC,ax1); + GeomAdaptor_SurfaceOfRevolution AS(HC,ax1); switch(AS.GetType()){ // skl 18.12.2003 - plane not used, problems in PRO14665.igs //case GeomAbs_Plane : { @@ -150,7 +150,7 @@ Standard_Boolean ShapeCustom_SweptToElementary::NewSurface(const TopoDS_Face& F, gp_Dir dir = SLE->Direction(); Handle(GeomAdaptor_HCurve) HC = new GeomAdaptor_HCurve(); HC->ChangeCurve().Load(bc,bc->FirstParameter(),bc->LastParameter()); - Adaptor3d_SurfaceOfLinearExtrusion AS(HC,dir); + GeomAdaptor_SurfaceOfLinearExtrusion AS(HC,dir); switch(AS.GetType()){ // skl 18.12.2003 - plane not used, problems in ims013.igs //case GeomAbs_Plane : { diff --git a/src/TKG3d/CMakeLists.txt b/src/TKG3d/CMakeLists.txt index 55c94f05b7..3a55db2928 100644 --- a/src/TKG3d/CMakeLists.txt +++ b/src/TKG3d/CMakeLists.txt @@ -9,6 +9,7 @@ set (TOOLKIT_MODULES Adaptor3d LProp3d TopAbs + GeomEvaluator ) OCCT_INCLUDE_CMAKE_FILE (adm/cmake/occt_toolkit) diff --git a/src/TKG3d/PACKAGES b/src/TKG3d/PACKAGES index d831731c0a..a06b2eaf7d 100755 --- a/src/TKG3d/PACKAGES +++ b/src/TKG3d/PACKAGES @@ -6,3 +6,4 @@ GeomLProp Adaptor3d LProp3d TopAbs +GeomEvaluator diff --git a/tests/bugs/modalg_2/bug5805_18 b/tests/bugs/modalg_2/bug5805_18 index 722cd8476a..3b73c18644 100755 --- a/tests/bugs/modalg_2/bug5805_18 +++ b/tests/bugs/modalg_2/bug5805_18 @@ -1,7 +1,4 @@ -puts "TODO OCC25925 ALL: ERROR. offsetperform operation not done." -puts "TODO OCC25925 ALL: Faulty OCC5805 : result is not Closed shape" -puts "TODO OCC25925 ALL: Tcl Exception: Error : command \\\"nbshapes result\\\" gives an empty result" -puts "TODO OCC25925 ALL: TEST INCOMPLETE" +puts "TODO OCC25925 ALL: Faulty shapes in variables faulty_1 to" puts "============" puts "OCC5805" @@ -49,7 +46,7 @@ if {$index == -1} { } -checknbshapes result -vertex 2 -edge 3 -wire 3 -face 3 -shell 1 -solid 1 -compsolid 0 -compound 0 -shape 13 +checknbshapes result -vertex 4 -edge 5 -wire 5 -face 5 -shell 2 -solid 1 -compsolid 0 -compound 0 -shape 22 -set square 495.635 +set square 358.795 set 2dviewer 0 diff --git a/tests/bugs/modalg_6/bug26525_3 b/tests/bugs/modalg_6/bug26525_3 index bbc864ec31..1b3393cb33 100644 --- a/tests/bugs/modalg_6/bug26525_3 +++ b/tests/bugs/modalg_6/bug26525_3 @@ -30,9 +30,9 @@ if { $Number == 2} { regexp {point p_1 +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} $log full x1 y1 z1 - set expected_x1 39.0504 - set expected_y1 -12.8696 - set expected_z1 82.6099 + set expected_x1 43.1172 + set expected_y1 -17.16 + set expected_z1 82.6048 checkreal "x1" ${x1} ${expected_x1} ${tol_abs} ${tol_rel} checkreal "y1" ${y1} ${expected_y1} ${tol_abs} ${tol_rel} @@ -40,9 +40,9 @@ if { $Number == 2} { regexp {point p_2 +([-0-9.+eE]+) +([-0-9.+eE]+) +([-0-9.+eE]+)} $log full x2 y2 z2 - set expected_x2 43.1172 - set expected_y2 -17.16 - set expected_z2 82.6048 + set expected_x2 39.0504 + set expected_y2 -12.8696 + set expected_z2 82.6099 checkreal "x2" ${x2} ${expected_x2} ${tol_abs} ${tol_rel} checkreal "y2" ${y2} ${expected_y2} ${tol_abs} ${tol_rel} diff --git a/tests/de/iges_1/H8 b/tests/de/iges_1/H8 index b6cfa4353d..fd2a278104 100644 --- a/tests/de/iges_1/H8 +++ b/tests/de/iges_1/H8 @@ -1,16 +1,15 @@ # !!!! This file is generated automatically, do not edit manually! See end script puts "TODO CR23096 ALL: LABELS : Faulty" - set filename BUC60035.igs set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 5 ) Warnings = 82 ( 767 ) Summary = 82 ( 772 ) +TPSTAT : Faulties = 0 ( 5 ) Warnings = 86 ( 799 ) Summary = 86 ( 804 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 208 ( 208 ) Summary = 7763 ( 7763 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 208 ( 208 ) FreeWire = 0 ( 0 ) FreeEdge = 6 ( 6 ) SharedEdge = 3665 ( 3665 ) -TOLERANCE : MaxTol = 0.1393674657 ( 0.1393674657 ) AvgTol = 0.003094049943 ( 0.003079317701 ) +TOLERANCE : MaxTol = 0.1393674657 ( 0.1393674657 ) AvgTol = 0.003094503403 ( 0.003090745167 ) LABELS : N0Labels = 1 ( 1 ) N1Labels = 214 ( 3725 ) N2Labels = 0 ( 0 ) TotalLabels = 215 ( 3726 ) NameLabels = 215 ( 330 ) ColorLabels = 214 ( 3725 ) LayerLabels = 209 ( 3720 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 5 ( 5 ) diff --git a/tests/de/iges_1/N7 b/tests/de/iges_1/N7 index 44e5227ab2..2098d7f77f 100644 --- a/tests/de/iges_1/N7 +++ b/tests/de/iges_1/N7 @@ -1,16 +1,15 @@ # !!!! This file is generated automatically, do not edit manually! See end script puts "TODO CR23096 ALL: LABELS : Faulty" - set filename support_bobine.igs set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 2 ( 34 ) Summary = 2 ( 34 ) +TPSTAT : Faulties = 0 ( 0 ) Warnings = 2 ( 36 ) Summary = 2 ( 36 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 123 ( 123 ) Summary = 3349 ( 3349 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 123 ( 123 ) FreeWire = 7 ( 7 ) FreeEdge = 571 ( 571 ) SharedEdge = 1263 ( 1263 ) -TOLERANCE : MaxTol = 0.01306151266 ( 0.01306151266 ) AvgTol = 4.724224752e-005 ( 4.790122037e-005 ) +TOLERANCE : MaxTol = 0.01306151266 ( 0.01306151266 ) AvgTol = 4.924673849e-05 ( 4.96935472e-05 ) LABELS : N0Labels = 1 ( 1 ) N1Labels = 675 ( 1417 ) N2Labels = 0 ( 0 ) TotalLabels = 676 ( 1418 ) NameLabels = 676 ( 745 ) ColorLabels = 675 ( 1417 ) LayerLabels = 584 ( 1236 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 2 ( 2 ) diff --git a/tests/de/iges_1/Q3 b/tests/de/iges_1/Q3 index 6c0cf81710..ded39856d5 100644 --- a/tests/de/iges_1/Q3 +++ b/tests/de/iges_1/Q3 @@ -4,16 +4,15 @@ puts "TODO CR23096 ALL: NBSHAPES : Faulty" puts "TODO CR23096 ALL: LABELS : Faulty" puts "TODO CR23096 ALL: COLORS : Faulty" - set filename 919-001-T02-04-CP-VL.igs set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 101 ( 1433 ) Summary = 101 ( 1433 ) +TPSTAT : Faulties = 0 ( 0 ) Warnings = 101 ( 1430 ) Summary = 101 ( 1430 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 1 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 899 ( 899 ) Summary = 24030 ( 24038 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 899 ( 899 ) FreeWire = 366 ( 366 ) FreeEdge = 3783 ( 3783 ) SharedEdge = 9384 ( 9388 ) -TOLERANCE : MaxTol = 0.3151652209 ( 0.3151652209 ) AvgTol = 0.0007056494899 ( 0.0007458034854 ) +TOLERANCE : MaxTol = 0.3151652209 ( 0.3151652209 ) AvgTol = 0.0007056492227 ( 0.0007458035864 ) LABELS : N0Labels = 1 ( 1 ) N1Labels = 3581 ( 9530 ) N2Labels = 0 ( 0 ) TotalLabels = 3582 ( 9531 ) NameLabels = 3582 ( 4454 ) ColorLabels = 3581 ( 9530 ) LayerLabels = 3581 ( 9530 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 1 ( 2 ) diff --git a/tests/de/iges_1/R1 b/tests/de/iges_1/R1 index a63254594e..ff0efbc4fc 100755 --- a/tests/de/iges_1/R1 +++ b/tests/de/iges_1/R1 @@ -3,16 +3,15 @@ puts "TODO CR23096 ALL: DATA : Faulty" puts "TODO CR23096 ALL: TPSTAT : Faulty" puts "TODO CR23096 ALL: LABELS : Faulty" - set filename BUC50003.igs set ref_data { DATA : Faulties = 1 ( 0 ) Warnings = 0 ( 0 ) Summary = 1 ( 0 ) -TPSTAT : Faulties = 2 ( 0 ) Warnings = 18 ( 320 ) Summary = 20 ( 320 ) +TPSTAT : Faulties = 2 ( 0 ) Warnings = 21 ( 329 ) Summary = 23 ( 329 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 135 ( 135 ) Summary = 2223 ( 2223 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 135 ( 135 ) FreeWire = 0 ( 0 ) FreeEdge = 3 ( 3 ) SharedEdge = 974 ( 974 ) -TOLERANCE : MaxTol = 0.9794163281 ( 12.54323842 ) AvgTol = 0.02080508938 ( 0.1727731057 ) +TOLERANCE : MaxTol = 1.202431555 ( 12.54323842 ) AvgTol = 0.0237733737 ( 0.1727731055 ) LABELS : N0Labels = 1 ( 1 ) N1Labels = 138 ( 1033 ) N2Labels = 0 ( 0 ) TotalLabels = 139 ( 1034 ) NameLabels = 139 ( 205 ) ColorLabels = 138 ( 1033 ) LayerLabels = 138 ( 1033 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 4 ( 4 ) diff --git a/tests/de/iges_1/R5 b/tests/de/iges_1/R5 index 1708fb9616..96da0f2ef9 100644 --- a/tests/de/iges_1/R5 +++ b/tests/de/iges_1/R5 @@ -2,16 +2,15 @@ puts "TODO CR23096 ALL: LABELS : Faulty" puts "TODO CR23096 ALL: LAYERS : Faulty" - set filename BUC50048.igs set ref_data { -DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 0 ) Warnings = 1 ( 290 ) Summary = 1 ( 290 ) +DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 2 ) Summary = 0 ( 2 ) +TPSTAT : Faulties = 0 ( 0 ) Warnings = 2 ( 314 ) Summary = 2 ( 314 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 328 ( 328 ) Summary = 8546 ( 8546 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 328 ( 328 ) FreeWire = 53 ( 53 ) FreeEdge = 1431 ( 1431 ) SharedEdge = 3217 ( 3217 ) -TOLERANCE : MaxTol = 0.4274072109 ( 0.4274072101 ) AvgTol = 0.001821024602 ( 0.001852637256 ) +TOLERANCE : MaxTol = 0.4274072109 ( 0.4274072101 ) AvgTol = 0.001825084327 ( 0.001863351234 ) LABELS : N0Labels = 10 ( 10 ) N1Labels = 1565 ( 2865 ) N2Labels = 0 ( 0 ) TotalLabels = 1575 ( 2875 ) NameLabels = 1575 ( 1851 ) ColorLabels = 1570 ( 2870 ) LayerLabels = 1570 ( 2870 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 8 ( 8 ) diff --git a/tests/de/iges_2/A7 b/tests/de/iges_2/A7 index a522ba6995..e025f5c595 100644 --- a/tests/de/iges_2/A7 +++ b/tests/de/iges_2/A7 @@ -1,21 +1,18 @@ # !!!! This file is generated automatically, do not edit manually! See end script puts "TODO CR23096 ALL: CHECKSHAPE : Faulty" +puts "TODO CR23096 ALL: NBSHAPES : Faulty" puts "TODO CR23096 ALL: LABELS : Faulty" puts "TODO CR23096 ALL: COLORS : Faulty" -puts "TODO CR23096 ALL: NBSHAPES : Faulty" -puts "TODO CR25013 ALL: Error : 1 differences with reference data found" -set LinuxDiff 2 -set LinuxFaulties {NBSHAPES} set filename CTS18547.igs set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 49 ) Warnings = 41 ( 1012 ) Summary = 41 ( 1061 ) -CHECKSHAPE : Wires = 1 ( 1 ) Faces = 1 ( 1 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) +TPSTAT : Faulties = 0 ( 49 ) Warnings = 45 ( 1060 ) Summary = 45 ( 1109 ) +CHECKSHAPE : Wires = 1 ( 0 ) Faces = 1 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 539 ( 539 ) Summary = 12798 ( 12800 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 539 ( 539 ) FreeWire = 19 ( 21 ) FreeEdge = 1864 ( 1864 ) SharedEdge = 4957 ( 4957 ) -TOLERANCE : MaxTol = 0.7510769849 ( 0.7510769849 ) AvgTol = 0.006853010548 ( 0.007168795519 ) +TOLERANCE : MaxTol = 0.7510769849 ( 0.7510769849 ) AvgTol = 0.006912539764 ( 0.007275546898 ) LABELS : N0Labels = 65 ( 65 ) N1Labels = 2112 ( 4443 ) N2Labels = 0 ( 0 ) TotalLabels = 2177 ( 4508 ) NameLabels = 2177 ( 2778 ) ColorLabels = 2123 ( 4458 ) LayerLabels = 0 ( 0 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 3 ( 4 ) diff --git a/tests/de/iges_2/C6 b/tests/de/iges_2/C6 index f6ab2f0223..590296cc04 100644 --- a/tests/de/iges_2/C6 +++ b/tests/de/iges_2/C6 @@ -1,18 +1,16 @@ # !!!! This file is generated automatically, do not edit manually! See end script puts "TODO CR23096 ALL: LABELS : Faulty" puts "TODO CR23096 ALL: COLORS : Faulty" -puts "TODO 0025623 ALL: CHECKSHAPE : Faulty" - set filename PRO19800.igs set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) TPSTAT : Faulties = 0 ( 0 ) Warnings = 0 ( 1 ) Summary = 0 ( 1 ) -CHECKSHAPE : Wires = 1 ( 0 ) Faces = 1 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) -NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1 ( 1 ) Summary = 13 ( 11 ) -STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1 ( 1 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 6 ( 5 ) -TOLERANCE : MaxTol = 0.04476902169 ( 0.04476636368 ) AvgTol = 0.02402039477 ( 0.02401933664 ) +CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) +NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1 ( 1 ) Summary = 11 ( 11 ) +STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1 ( 1 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 5 ( 5 ) +TOLERANCE : MaxTol = 0.04476896343 ( 0.04476636368 ) AvgTol = 0.02404075037 ( 0.02403970427 ) LABELS : N0Labels = 1 ( 1 ) N1Labels = 0 ( 5 ) N2Labels = 0 ( 0 ) TotalLabels = 1 ( 6 ) NameLabels = 1 ( 1 ) ColorLabels = 1 ( 6 ) LayerLabels = 1 ( 6 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 1 ( 2 ) diff --git a/tests/de/iges_2/F9 b/tests/de/iges_2/F9 index b7e7384129..d5a7159743 100644 --- a/tests/de/iges_2/F9 +++ b/tests/de/iges_2/F9 @@ -3,16 +3,15 @@ puts "TODO CR23096 ALL: NBSHAPES : Faulty" puts "TODO CR23096 ALL: STATSHAPE : Faulty" puts "TODO CR23096 ALL: LABELS : Faulty" -set LinuxDiff 1 set filename 919-004-T03-04-CP-VL.igs set ref_data { DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) -TPSTAT : Faulties = 0 ( 2 ) Warnings = 312 ( 2188 ) Summary = 312 ( 2190 ) +TPSTAT : Faulties = 0 ( 2 ) Warnings = 310 ( 2179 ) Summary = 310 ( 2181 ) CHECKSHAPE : Wires = 0 ( 3 ) Faces = 0 ( 3 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1457 ( 1455 ) Summary = 38832 ( 38834 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1457 ( 1455 ) FreeWire = 516 ( 528 ) FreeEdge = 6208 ( 6208 ) SharedEdge = 15307 ( 15304 ) -TOLERANCE : MaxTol = 0.3053256329 ( 0.4653265763 ) AvgTol = 0.0008083573819 ( 0.0008563940583 ) +TOLERANCE : MaxTol = 0.3053256329 ( 0.4653265763 ) AvgTol = 0.0008083725785 ( 0.0008564007398 ) LABELS : N0Labels = 5 ( 5 ) N1Labels = 5689 ( 14639 ) N2Labels = 0 ( 0 ) TotalLabels = 5694 ( 14644 ) NameLabels = 5694 ( 7040 ) ColorLabels = 5689 ( 14643 ) LayerLabels = 5689 ( 14643 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 2 ( 2 ) diff --git a/tests/de/iges_2/G9 b/tests/de/iges_2/G9 index b76ff5e51f..a09bc95352 100755 --- a/tests/de/iges_2/G9 +++ b/tests/de/iges_2/G9 @@ -3,16 +3,15 @@ puts "TODO CR23096 ALL: DATA : Faulty" puts "TODO CR23096 ALL: TPSTAT : Faulty" puts "TODO CR23096 ALL: LABELS : Faulty" - set filename sabena.igs set ref_data { DATA : Faulties = 14 ( 0 ) Warnings = 0 ( 0 ) Summary = 14 ( 0 ) -TPSTAT : Faulties = 28 ( 16 ) Warnings = 44 ( 2964 ) Summary = 72 ( 2980 ) +TPSTAT : Faulties = 28 ( 16 ) Warnings = 44 ( 3039 ) Summary = 72 ( 3055 ) CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 2639 ( 2634 ) Summary = 64362 ( 64317 ) STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 2639 ( 2639 ) FreeWire = 1027 ( 1027 ) FreeEdge = 10489 ( 10489 ) SharedEdge = 24209 ( 24190 ) -TOLERANCE : MaxTol = 0.05705560511 ( 0.05705560511 ) AvgTol = 0.0002545958154 ( 0.0002529561285 ) +TOLERANCE : MaxTol = 0.05705560511 ( 0.05705560511 ) AvgTol = 0.0002632718893 ( 0.0002620014373 ) LABELS : N0Labels = 54 ( 54 ) N1Labels = 10590 ( 27260 ) N2Labels = 0 ( 0 ) TotalLabels = 10644 ( 27314 ) NameLabels = 10644 ( 13414 ) ColorLabels = 10590 ( 27312 ) LayerLabels = 7 ( 18 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 8 ( 8 ) diff --git a/tests/de/iges_3/A4 b/tests/de/iges_3/A4 index d92ce898b2..a82de43004 100755 --- a/tests/de/iges_3/A4 +++ b/tests/de/iges_3/A4 @@ -6,17 +6,16 @@ puts "TODO CR23096 ALL: LABELS : Faulty" puts "TODO CR23096 ALL: COLORS : Faulty" puts "TODO CR23096 ALL: LAYERS : Faulty" - set filename BUC40132.igs set ref_data { DATA : Faulties = 6 ( 0 ) Warnings = 0 ( 0 ) Summary = 6 ( 0 ) -TPSTAT : Faulties = 12 ( 238 ) Warnings = 473 ( 2623 ) Summary = 485 ( 2861 ) +TPSTAT : Faulties = 12 ( 238 ) Warnings = 473 ( 2625 ) Summary = 485 ( 2863 ) CHECKSHAPE : Wires = 4 ( 4 ) Faces = 4 ( 4 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) -NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1346 ( 1345 ) Summary = 22215 ( 22296 ) -STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1346 ( 1345 ) FreeWire = 96 ( 170 ) FreeEdge = 1061 ( 1061 ) SharedEdge = 9271 ( 9280 ) -TOLERANCE : MaxTol = 0.8099726869 ( 1.367966665 ) AvgTol = 0.008043971398 ( 0.008388581449 ) -LABELS : N0Labels = 27 ( 27 ) N1Labels = 2100 ( 6250 ) N2Labels = 0 ( 0 ) TotalLabels = 2127 ( 6277 ) NameLabels = 2127 ( 2596 ) ColorLabels = 2114 ( 6276 ) LayerLabels = 2114 ( 6276 ) +NBSHAPES : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1346 ( 1345 ) Summary = 22215 ( 22294 ) +STATSHAPE : Solid = 0 ( 0 ) Shell = 0 ( 0 ) Face = 1346 ( 1345 ) FreeWire = 96 ( 170 ) FreeEdge = 1061 ( 1061 ) SharedEdge = 9271 ( 9278 ) +TOLERANCE : MaxTol = 0.8099726869 ( 1.367966665 ) AvgTol = 0.008043732418 ( 0.008389831342 ) +LABELS : N0Labels = 27 ( 27 ) N1Labels = 2100 ( 6248 ) N2Labels = 0 ( 0 ) TotalLabels = 2127 ( 6275 ) NameLabels = 2127 ( 2596 ) ColorLabels = 2114 ( 6274 ) LayerLabels = 2114 ( 6274 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 11 ( 12 ) COLORS : Colors = BLUE1 CYAN1 CYAN2 DARKGOLDENROD GREEN MAGENTA1 PALEVIOLETRED1 RED TURQUOISE2 WHITE YELLOW ( BLUE1 CYAN1 CYAN2 DARKGOLDENROD GRAY53 GREEN MAGENTA1 PALEVIOLETRED1 RED TURQUOISE2 WHITE YELLOW ) diff --git a/tests/de/step_4/G7 b/tests/de/step_4/G7 index f1575c325c..24ed97a95d 100644 --- a/tests/de/step_4/G7 +++ b/tests/de/step_4/G7 @@ -1,17 +1,13 @@ # !!!! This file is generated automatically, do not edit manually! See end script -puts "TODO CR23096 ALL: CHECKSHAPE : Faulty" -puts "TODO CR23096 ALL: TOLERANCE : Faulty" - -set LinuxDiff 2 set filename BUC61004.stp set ref_data { -DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 0 ) Summary = 0 ( 0 ) +DATA : Faulties = 0 ( 0 ) Warnings = 0 ( 24851 ) Summary = 0 ( 24851 ) TPSTAT : Faulties = 0 ( 0 ) Warnings = 5 ( 43 ) Summary = 5 ( 43 ) -CHECKSHAPE : Wires = 1 ( 0 ) Faces = 1 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) +CHECKSHAPE : Wires = 0 ( 0 ) Faces = 0 ( 0 ) Shells = 0 ( 0 ) Solids = 0 ( 0 ) NBSHAPES : Solid = 1 ( 1 ) Shell = 1 ( 1 ) Face = 2523 ( 2523 ) Summary = 16185 ( 16185 ) STATSHAPE : Solid = 1 ( 1 ) Shell = 1 ( 1 ) Face = 2523 ( 2523 ) FreeWire = 0 ( 0 ) FreeEdge = 0 ( 0 ) SharedEdge = 6806 ( 6806 ) -TOLERANCE : MaxTol = 9.829787663 ( 7.812889886 ) AvgTol = 0.01764242132 ( 0.01681498017 ) +TOLERANCE : MaxTol = 7.812811758 ( 7.812811758 ) AvgTol = 0.01607232204 ( 0.01607241853 ) LABELS : N0Labels = 1 ( 1 ) N1Labels = 0 ( 0 ) N2Labels = 0 ( 0 ) TotalLabels = 1 ( 1 ) NameLabels = 1 ( 1 ) ColorLabels = 0 ( 0 ) LayerLabels = 0 ( 0 ) PROPS : Centroid = 0 ( 0 ) Volume = 0 ( 0 ) Area = 0 ( 0 ) NCOLORS : NColors = 0 ( 0 )