1 // Created on: 1996-11-26
2 // Created by: Philippe MANGIN
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
8 // This library is free software; you can redistribute it and/or modify it under
9 // the terms of the GNU Lesser General Public License version 2.1 as published
10 // by the Free Software Foundation, with special exception defined in the file
11 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12 // distribution for complete text of the license and disclaimer of any warranty.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #include <BRepBlend_AppSurface.ixx>
19 #include <TColgp_Array1OfPnt.hxx>
20 #include <TColgp_Array1OfPnt2d.hxx>
21 #include <TColgp_Array1OfVec.hxx>
22 #include <TColgp_Array1OfVec2d.hxx>
23 #include <TColStd_Array1OfReal.hxx>
25 #include <StdFail_NotDone.hxx>
28 BRepBlend_AppSurface::BRepBlend_AppSurface(
29 Handle(Approx_SweepFunction)& Func,
30 const Standard_Real First,
31 const Standard_Real Last,
32 const Standard_Real Tol3d,
33 const Standard_Real Tol2d,
34 const Standard_Real TolAngular,
35 const GeomAbs_Shape Continuity,
36 const Standard_Integer Degmax,
37 const Standard_Integer Segmax) :
40 Standard_Integer Nb2d = Func->Nb2dCurves();
41 Standard_Integer NbPolSect, NbKnotSect, udeg;
42 GeomAbs_Shape continuity = Continuity;
44 // (1) Verification de la possibilite de derivation
45 if (continuity != GeomAbs_C0) {
46 if (Nb2d == 0) Nb2d =1;
47 Func->SectionShape(NbPolSect, NbKnotSect, udeg);
48 TColStd_Array1OfReal W (1, NbPolSect);
49 TColgp_Array1OfPnt P (1, NbPolSect);
50 TColgp_Array1OfPnt2d P2d(1, Nb2d);
51 TColgp_Array1OfVec V (1, NbPolSect);
52 TColgp_Array1OfVec2d V2d(1, Nb2d);
54 if (continuity == GeomAbs_C2) {
55 Ok = Func->D2( First, First, Last, P, V, V, P2d, V2d, V2d, W, W, W);
56 if (!Ok) { continuity = GeomAbs_C1; }
58 if (continuity == GeomAbs_C1) {
59 Ok = (Func->D1(First, First, Last, P, V, P2d, V2d, W, W));
60 if (!Ok) { continuity = GeomAbs_C0; }
66 approx.Perform(First, Last,
67 Tol3d, Tol3d, Tol2d, TolAngular,
68 continuity, Degmax, Segmax);
71 void BRepBlend_AppSurface::SurfShape (Standard_Integer& UDegree,
72 Standard_Integer& VDegree,
73 Standard_Integer& NbUPoles,
74 Standard_Integer& NbVPoles,
75 Standard_Integer& NbUKnots,
76 Standard_Integer& NbVKnots) const
78 approx.SurfShape(UDegree, VDegree,
84 void BRepBlend_AppSurface::Surface(TColgp_Array2OfPnt& TPoles,
85 TColStd_Array2OfReal& TWeights,
86 TColStd_Array1OfReal& TUKnots,
87 TColStd_Array1OfReal& TVKnots,
88 TColStd_Array1OfInteger& TUMults,
89 TColStd_Array1OfInteger& TVMults) const
92 approx.Surface(TPoles, TWeights, TUKnots,TVKnots, TUMults,TVMults);
96 Standard_Real BRepBlend_AppSurface::MaxErrorOnSurf() const
98 return approx.MaxErrorOnSurf();
102 void BRepBlend_AppSurface::Curves2dShape(Standard_Integer& Degree,
103 Standard_Integer& NbPoles,
104 Standard_Integer& NbKnots) const
106 approx.Curves2dShape( Degree, NbPoles, NbKnots);
109 void BRepBlend_AppSurface::Curve2d(const Standard_Integer Index,
110 TColgp_Array1OfPnt2d& TPoles,
111 TColStd_Array1OfReal& TKnots,
112 TColStd_Array1OfInteger& TMults) const
114 approx.Curve2d(Index, TPoles, TKnots, TMults);
117 Standard_Real BRepBlend_AppSurface::Max2dError(const Standard_Integer Index) const
119 return approx.Max2dError(Index);
123 Standard_Real BRepBlend_AppSurface::TolCurveOnSurf(const Standard_Integer Index) const
125 return approx.TolCurveOnSurf(Index);
128 inline void BRepBlend_AppSurface::TolReached (Standard_Real& Tol3d,
129 Standard_Real& Tol2d) const
131 Tol3d = approx.MaxErrorOnSurf();
133 for (Standard_Integer ii=1; ii<=approx.NbCurves2d(); ii++) {
134 Tol2d = Max(Tol2d, approx.Max2dError(ii));
138 void BRepBlend_AppSurface::Dump(Standard_OStream& o) const