-- . A survey of curve and surface methods in CAGD (Wolfgang BOHM)
-- CAGD 1 1984
-uses Standard, TColStd, TColGeom2d,gp, Geom2d, Convert,GeomAbs
+uses Standard, TColStd, TColGeom2d,gp, Geom2d, Convert,GeomAbs, Adaptor2d
is
uses
Curve from Geom2d,
BSplineCurve from Geom2d,
+ HCurve2d from Adaptor2d,
Shape from GeomAbs,
OutOfRange from Standard
-- - the maximum number of segments allowed MaxSegments
-- - the highest degree MaxDegree which the
-- polynomial defining the BSpline is allowed to have.
-
+
+ Create (Curve: HCurve2d from Adaptor2d;
+ Tol2d: Real;
+ Order: Shape from GeomAbs;
+ MaxSegments: Integer;
+ MaxDegree: Integer) returns ApproxCurve from Geom2dConvert;
+ ---Purpose: Constructs an approximation framework defined by
+ -- - the 2D conic Curve
+ -- - the tolerance value Tol2d
+ -- - the degree of continuity Order
+ -- - the maximum number of segments allowed MaxSegments
+ -- - the highest degree MaxDegree which the
+ -- polynomial defining the BSpline is allowed to have.
+
Curve(me) returns BSplineCurve from Geom2d;
---Purpose: Returns the 2D BSpline curve resulting from the
-- approximation algorithm.
Dump(me; o: in out OStream);
---Purpose: Print on the stream o information about the object
+ Approximate(me: in out;
+ theCurve: HCurve2d from Adaptor2d;
+ theTol3d: Real;
+ theOrder: Shape from GeomAbs;
+ theMaxSegments: Integer;
+ theMaxDegree: Integer) is private;
+ ---Purpose: Converts a curve to B-spline
+
fields
- myCurve : Curve from Geom2d;
myIsDone : Boolean from Standard;
myHasResult : Boolean from Standard;
myBSplCurve : BSplineCurve from Geom2d;
Geom2dConvert_ApproxCurve::Geom2dConvert_ApproxCurve(const Handle(Geom2d_Curve)& Curve,const Standard_Real Tol2d,const GeomAbs_Shape Order,const Standard_Integer MaxSegments,const Standard_Integer MaxDegree)
{
Handle(Geom2dAdaptor_HCurve) HCurve = new Geom2dAdaptor_HCurve (Curve);
+ Approximate(HCurve, Tol2d, Order, MaxSegments, MaxDegree);
+}
+Geom2dConvert_ApproxCurve::Geom2dConvert_ApproxCurve(const Handle(Adaptor2d_HCurve2d)& Curve,
+ const Standard_Real Tol2d,
+ const GeomAbs_Shape Order,
+ const Standard_Integer MaxSegments,
+ const Standard_Integer MaxDegree)
+{
+ Approximate(Curve, Tol2d, Order, MaxSegments, MaxDegree);
+}
+
+void Geom2dConvert_ApproxCurve::Approximate(const Handle(Adaptor2d_HCurve2d)& theCurve,
+ const Standard_Real theTol2d,
+ const GeomAbs_Shape theOrder,
+ const Standard_Integer theMaxSegments,
+ const Standard_Integer theMaxDegree)
+{
// Initialisation of input parameters of AdvApprox
Standard_Integer Num1DSS=0, Num2DSS=1, Num3DSS=0;
- Handle(TColStd_HArray1OfReal) OneDTolNul, ThreeDTolNul;
+ Handle(TColStd_HArray1OfReal) OneDTolNul, ThreeDTolNul;
Handle(TColStd_HArray1OfReal) TwoDTol = new TColStd_HArray1OfReal(1,Num2DSS);
- TwoDTol->Init(Tol2d);
+ TwoDTol->Init(theTol2d);
- Standard_Real First = Curve->FirstParameter();
- Standard_Real Last = Curve->LastParameter();
+ Standard_Real First = theCurve->FirstParameter();
+ Standard_Real Last = theCurve->LastParameter();
- Standard_Integer NbInterv_C2 = HCurve->NbIntervals(GeomAbs_C2);
+ Standard_Integer NbInterv_C2 = theCurve->NbIntervals(GeomAbs_C2);
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2+1);
- HCurve->Intervals(CutPnts_C2,GeomAbs_C2);
- Standard_Integer NbInterv_C3 = HCurve->NbIntervals(GeomAbs_C3);
+ theCurve->Intervals(CutPnts_C2,GeomAbs_C2);
+ Standard_Integer NbInterv_C3 = theCurve->NbIntervals(GeomAbs_C3);
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3+1);
- HCurve->Intervals(CutPnts_C3,GeomAbs_C3);
+ theCurve->Intervals(CutPnts_C3,GeomAbs_C3);
AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
myMaxError = 0;
- Geom2dConvert_ApproxCurve_Eval ev (HCurve, First, Last);
+ Geom2dConvert_ApproxCurve_Eval ev (theCurve, First, Last);
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
- OneDTolNul, TwoDTol, ThreeDTolNul,
- First, Last, Order,
- MaxDegree, MaxSegments,
- ev, CutTool);
+ OneDTolNul, TwoDTol, ThreeDTolNul,
+ First, Last, theOrder,
+ theMaxDegree, theMaxSegments,
+ ev, CutTool);
myIsDone = aApprox.IsDone();
myHasResult = aApprox.HasResult();
Geom,
Geom2d,
Convert,
- AdvApp2Var
+ AdvApp2Var,
+ Adaptor3d
is
uses
Curve from Geom,
BSplineCurve from Geom,
+ HCurve from Adaptor3d,
Shape from GeomAbs,
OutOfRange from Standard
-- MaxSegments allowed in the resulting BSpline curve, and
-- - the highest degree MaxDeg which the
-- polynomial defining the BSpline curve may have.
+
+ Create (Curve: HCurve from Adaptor3d;
+ Tol3d: Real;
+ Order: Shape from GeomAbs;
+ MaxSegments: Integer;
+ MaxDegree: Integer) returns ApproxCurve;
+ ---Purpose: Constructs a curve approximation framework defined by -
+ -- - the Curve,
+ -- - the tolerance value Tol3d,
+ -- - the degree of continuity Order,
+ -- - the maximum number of segments
+ -- MaxSegments allowed in the resulting BSpline curve, and
+ -- - the highest degree MaxDeg which the
+ -- polynomial defining the BSpline curve may have.
Curve(me) returns BSplineCurve from Geom;
--- Purpose: Returns the BSpline curve resulting from the approximation algorithm.
Dump(me; o: in out OStream);
---Purpose: Print on the stream o information about the object
+ Approximate(me: in out;
+ theCurve: HCurve from Adaptor3d;
+ theTol3d: Real;
+ theOrder: Shape from GeomAbs;
+ theMaxSegments: Integer;
+ theMaxDegree: Integer) is private;
+ ---Purpose: Converts a curve to B-spline
+
fields
- myCurve : Curve from Geom;
myIsDone : Boolean from Standard;
myHasResult : Boolean from Standard;
myBSplCurve : BSplineCurve from Geom;
GeomConvert_ApproxCurve::GeomConvert_ApproxCurve(const Handle(Geom_Curve)& Curve,const Standard_Real Tol3d,const GeomAbs_Shape Order,const Standard_Integer MaxSegments,const Standard_Integer MaxDegree)
{
Handle(GeomAdaptor_HCurve) HCurve = new GeomAdaptor_HCurve (Curve);
+ Approximate(HCurve, Tol3d, Order, MaxSegments, MaxDegree);
+}
+
+GeomConvert_ApproxCurve::GeomConvert_ApproxCurve(const Handle(Adaptor3d_HCurve)& Curve,const Standard_Real Tol3d,const GeomAbs_Shape Order,const Standard_Integer MaxSegments,const Standard_Integer MaxDegree)
+{
+ Approximate(Curve, Tol3d, Order, MaxSegments, MaxDegree);
+}
+void GeomConvert_ApproxCurve::Approximate(
+ const Handle(Adaptor3d_HCurve)& theCurve,
+ const Standard_Real theTol3d,
+ const GeomAbs_Shape theOrder,
+ const Standard_Integer theMaxSegments,
+ const Standard_Integer theMaxDegree)
+{
// Initialisation of input parameters of AdvApprox
Standard_Integer Num1DSS=0, Num2DSS=0, Num3DSS=1;
- Handle(TColStd_HArray1OfReal) OneDTolNul, TwoDTolNul;
- Handle(TColStd_HArray1OfReal) ThreeDTol =
- new TColStd_HArray1OfReal(1,Num3DSS);
- ThreeDTol->Init(Tol3d);
+ Handle(TColStd_HArray1OfReal) OneDTolNul, TwoDTolNul;
+ Handle(TColStd_HArray1OfReal) ThreeDTol = new TColStd_HArray1OfReal(1,Num3DSS);
+ ThreeDTol->Init(theTol3d);
- Standard_Real First = Curve->FirstParameter();
- Standard_Real Last = Curve->LastParameter();
+ Standard_Real First = theCurve->FirstParameter();
+ Standard_Real Last = theCurve->LastParameter();
- Standard_Integer NbInterv_C2 = HCurve->NbIntervals(GeomAbs_C2);
+ Standard_Integer NbInterv_C2 = theCurve->NbIntervals(GeomAbs_C2);
TColStd_Array1OfReal CutPnts_C2(1, NbInterv_C2+1);
- HCurve->Intervals(CutPnts_C2,GeomAbs_C2);
- Standard_Integer NbInterv_C3 = HCurve->NbIntervals(GeomAbs_C3);
+ theCurve->Intervals(CutPnts_C2,GeomAbs_C2);
+ Standard_Integer NbInterv_C3 = theCurve->NbIntervals(GeomAbs_C3);
TColStd_Array1OfReal CutPnts_C3(1, NbInterv_C3+1);
- HCurve->Intervals(CutPnts_C3,GeomAbs_C3);
-
+ theCurve->Intervals(CutPnts_C3,GeomAbs_C3);
+
AdvApprox_PrefAndRec CutTool(CutPnts_C2,CutPnts_C3);
myMaxError = 0;
- GeomConvert_ApproxCurve_Eval ev (HCurve, First, Last);
+ GeomConvert_ApproxCurve_Eval ev (theCurve, First, Last);
AdvApprox_ApproxAFunction aApprox (Num1DSS, Num2DSS, Num3DSS,
- OneDTolNul, TwoDTolNul, ThreeDTol,
- First, Last, Order,
- MaxDegree, MaxSegments,
- ev, CutTool);
+ OneDTolNul, TwoDTolNul, ThreeDTol,
+ First, Last, theOrder,
+ theMaxDegree, theMaxSegments,
+ ev, CutTool);
myIsDone = aApprox.IsDone();
myHasResult = aApprox.HasResult();
Surface from Geom,
OffsetSurface from Geom,
BSplineSurface from Geom,
+ HSurface from Adaptor3d,
Shape from GeomAbs,
ApproxAFunc2Var from AdvApp2Var,
OutOfRange from Standard
-- - the maximum number of segments MaxSegments
-- allowed in the resulting BSpline curve
-- - the index of precision PrecisCode.
+
+ Create(Surf: HSurface from Adaptor3d;
+ Tol3d: Real;
+ UContinuity: Shape from GeomAbs;
+ VContinuity: Shape from GeomAbs;
+ MaxDegU: Integer;
+ MaxDegV: Integer;
+ MaxSegments: Integer;
+ PrecisCode : Integer) returns ApproxSurface ;
+ ---Purpose: Constructs a surface approximation framework defined by
+ -- - the Surf
+ -- - the tolerance value Tol3d
+ -- - the degree of continuity UContinuity, VContinuity
+ -- in the directions of the U and V parameters
+ -- - the highest degree MaxDegU, MaxDegV which
+ -- the polynomial defining the BSpline curve may
+ -- have in the directions of the U and V parameters
+ -- - the maximum number of segments MaxSegments
+ -- allowed in the resulting BSpline curve
+ -- - the index of precision PrecisCode.
Surface(me) returns BSplineSurface from Geom;
Dump(me ; o : in out OStream);
---Purpose: Prints on the stream o informations on the current state of the object.
+
+ Approximate(me: in out;
+ theSurf: HSurface from Adaptor3d;
+ theTol3d: Real;
+ theUContinuity: Shape from GeomAbs;
+ theVContinuity: Shape from GeomAbs;
+ theMaxDegU: Integer;
+ theMaxDegV: Integer;
+ theMaxSegments: Integer;
+ thePrecisCode : Integer) is private;
+ ---Purpose: Converts a surface to B-spline
fields
- mySurf : Surface from Geom;
myIsDone : Boolean from Standard;
myHasResult: Boolean from Standard;
myBSplSurf : BSplineSurface from Geom;
//=======================================================================
GeomConvert_ApproxSurface::GeomConvert_ApproxSurface(const Handle(Geom_Surface)& Surf,
- const Standard_Real Tol3d,
- const GeomAbs_Shape UContinuity,
- const GeomAbs_Shape VContinuity,
- const Standard_Integer MaxDegU,
- const Standard_Integer MaxDegV,
- const Standard_Integer MaxSegments,
- const Standard_Integer PrecisCode)
+ const Standard_Real Tol3d,
+ const GeomAbs_Shape UContinuity,
+ const GeomAbs_Shape VContinuity,
+ const Standard_Integer MaxDegU,
+ const Standard_Integer MaxDegV,
+ const Standard_Integer MaxSegments,
+ const Standard_Integer PrecisCode)
{
- Standard_Real U0, U1, V0, V1;
-
Handle(Adaptor3d_HSurface) aSurfAdaptor = new GeomAdaptor_HSurface (Surf);
- Surf->Bounds(U0, U1, V0, V1);
+ Approximate(aSurfAdaptor, Tol3d, UContinuity, VContinuity, MaxDegU, MaxDegV, MaxSegments, PrecisCode);
+}
+
+GeomConvert_ApproxSurface::GeomConvert_ApproxSurface(const Handle(Adaptor3d_HSurface)& Surf,
+ const Standard_Real Tol3d,
+ const GeomAbs_Shape UContinuity,
+ const GeomAbs_Shape VContinuity,
+ const Standard_Integer MaxDegU,
+ const Standard_Integer MaxDegV,
+ const Standard_Integer MaxSegments,
+ const Standard_Integer PrecisCode)
+{
+ Approximate(Surf, Tol3d, UContinuity, VContinuity, MaxDegU, MaxDegV, MaxSegments, PrecisCode);
+}
+
+void GeomConvert_ApproxSurface::Approximate(const Handle(Adaptor3d_HSurface)& theSurf,
+ const Standard_Real theTol3d,
+ const GeomAbs_Shape theUContinuity,
+ const GeomAbs_Shape theVContinuity,
+ const Standard_Integer theMaxDegU,
+ const Standard_Integer theMaxDegV,
+ const Standard_Integer theMaxSegments,
+ const Standard_Integer thePrecisCode)
+{
+ Standard_Real U0 = theSurf->FirstUParameter();
+ Standard_Real U1 = theSurf->LastUParameter();
+ Standard_Real V0 = theSurf->FirstVParameter();
+ Standard_Real V1 = theSurf->LastVParameter();
// " Init des nombres de sous-espaces et des tolerances"
Standard_Integer nb1 = 0, nb2 = 0, nb3 = 1;
- Handle(TColStd_HArray1OfReal) nul1 =
- new TColStd_HArray1OfReal(1,1);
- nul1->SetValue(1,0.);
- Handle(TColStd_HArray2OfReal) nul2 =
- new TColStd_HArray2OfReal(1,1,1,4);
- nul2->SetValue(1,1,0.);
- nul2->SetValue(1,2,0.);
- nul2->SetValue(1,3,0.);
- nul2->SetValue(1,4,0.);
- Handle(TColStd_HArray1OfReal) eps3D =
- new TColStd_HArray1OfReal(1,1);
- eps3D->SetValue(1,Tol3d);
- Handle(TColStd_HArray2OfReal) epsfr =
- new TColStd_HArray2OfReal(1,1,1,4);
- epsfr->SetValue(1,1,Tol3d);
- epsfr->SetValue(1,2,Tol3d);
- epsfr->SetValue(1,3,Tol3d);
- epsfr->SetValue(1,4,Tol3d);
+ Handle(TColStd_HArray1OfReal) nul1 = new TColStd_HArray1OfReal(1,1);
+ nul1->SetValue(1, 0.);
+ Handle(TColStd_HArray2OfReal) nul2 = new TColStd_HArray2OfReal(1,1,1,4);
+ nul2->SetValue(1, 1, 0.);
+ nul2->SetValue(1, 2, 0.);
+ nul2->SetValue(1, 3, 0.);
+ nul2->SetValue(1, 4, 0.);
+ Handle(TColStd_HArray1OfReal) eps3D = new TColStd_HArray1OfReal(1,1);
+ eps3D->SetValue(1, theTol3d);
+ Handle(TColStd_HArray2OfReal) epsfr = new TColStd_HArray2OfReal(1,1,1,4);
+ epsfr->SetValue(1, 1, theTol3d);
+ epsfr->SetValue(1, 2, theTol3d);
+ epsfr->SetValue(1, 3, theTol3d);
+ epsfr->SetValue(1, 4, theTol3d);
// " Init du type d'iso"
GeomAbs_IsoType IsoType = GeomAbs_IsoV;
Standard_Integer NbDec;
- NbDec = aSurfAdaptor->NbUIntervals(GeomAbs_C2);
+ NbDec = theSurf->NbUIntervals(GeomAbs_C2);
TColStd_Array1OfReal UDec_C2(1, NbDec+1);
- aSurfAdaptor->UIntervals(UDec_C2, GeomAbs_C2);
- NbDec = aSurfAdaptor->NbVIntervals(GeomAbs_C2);
+ theSurf->UIntervals(UDec_C2, GeomAbs_C2);
+ NbDec = theSurf->NbVIntervals(GeomAbs_C2);
TColStd_Array1OfReal VDec_C2(1, NbDec+1);
- aSurfAdaptor->VIntervals(VDec_C2, GeomAbs_C2);
+ theSurf->VIntervals(VDec_C2, GeomAbs_C2);
- NbDec = aSurfAdaptor->NbUIntervals(GeomAbs_C3);
+ NbDec = theSurf->NbUIntervals(GeomAbs_C3);
TColStd_Array1OfReal UDec_C3(1, NbDec+1);
- aSurfAdaptor->UIntervals(UDec_C3, GeomAbs_C3);
+ theSurf->UIntervals(UDec_C3, GeomAbs_C3);
- NbDec = aSurfAdaptor->NbVIntervals(GeomAbs_C3);
+ NbDec = theSurf->NbVIntervals(GeomAbs_C3);
TColStd_Array1OfReal VDec_C3(1, NbDec+1);
- aSurfAdaptor->VIntervals(VDec_C3, GeomAbs_C3);
+ theSurf->VIntervals(VDec_C3, GeomAbs_C3);
// Approximation avec decoupe preferentiel
// aux lieux de discontinuitees C2
AdvApprox_PrefAndRec pUDec(UDec_C2,UDec_C3);
AdvApprox_PrefAndRec pVDec(VDec_C2,VDec_C3);
//POP pour WNT
- GeomConvert_ApproxSurface_Eval ev (aSurfAdaptor);
+ GeomConvert_ApproxSurface_Eval ev (theSurf);
AdvApp2Var_ApproxAFunc2Var approx(nb1, nb2, nb3,
- nul1,nul1,eps3D,
- nul2,nul2,epsfr,
- U0,U1,V0,V1,
- IsoType,UContinuity,VContinuity,PrecisCode,
-// MaxDegU,MaxDegV,MaxSegments,mySurfEval1,
- MaxDegU,MaxDegV,MaxSegments,ev,
- pUDec,pVDec);
+ nul1,nul1,eps3D,
+ nul2,nul2,epsfr,
+ U0,U1,V0,V1,
+ IsoType,theUContinuity,theVContinuity,thePrecisCode,
+ theMaxDegU,theMaxDegV,theMaxSegments,ev,
+ pUDec,pVDec);
myMaxError = approx.MaxError(3,1);
myBSplSurf = approx.Surface(1);