b311480e |
1 | // Created on: 1996-11-26 |
2 | // Created by: Philippe MANGIN |
3 | // Copyright (c) 1996-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | |
22 | |
23 | #include <BRepBlend_AppSurface.ixx> |
24 | |
25 | #include <TColgp_Array1OfPnt.hxx> |
26 | #include <TColgp_Array1OfPnt2d.hxx> |
27 | #include <TColgp_Array1OfVec.hxx> |
28 | #include <TColgp_Array1OfVec2d.hxx> |
29 | #include <TColStd_Array1OfReal.hxx> |
30 | |
31 | #include <StdFail_NotDone.hxx> |
32 | |
33 | |
34 | BRepBlend_AppSurface::BRepBlend_AppSurface( |
35 | Handle(Approx_SweepFunction)& Func, |
36 | const Standard_Real First, |
37 | const Standard_Real Last, |
38 | const Standard_Real Tol3d, |
39 | const Standard_Real Tol2d, |
40 | const Standard_Real TolAngular, |
41 | const GeomAbs_Shape Continuity, |
42 | const Standard_Integer Degmax, |
43 | const Standard_Integer Segmax) : |
44 | approx(Func) |
45 | { |
46 | Standard_Integer Nb2d = Func->Nb2dCurves(); |
47 | Standard_Integer NbPolSect, NbKnotSect, udeg; |
48 | GeomAbs_Shape continuity = Continuity; |
49 | |
50 | // (1) Verification de la possibilite de derivation |
51 | if (continuity != GeomAbs_C0) { |
52 | if (Nb2d == 0) Nb2d =1; |
53 | Func->SectionShape(NbPolSect, NbKnotSect, udeg); |
54 | TColStd_Array1OfReal W (1, NbPolSect); |
55 | TColgp_Array1OfPnt P (1, NbPolSect); |
56 | TColgp_Array1OfPnt2d P2d(1, Nb2d); |
57 | TColgp_Array1OfVec V (1, NbPolSect); |
58 | TColgp_Array1OfVec2d V2d(1, Nb2d); |
59 | Standard_Boolean Ok; |
60 | if (continuity == GeomAbs_C2) { |
61 | Ok = Func->D2( First, First, Last, P, V, V, P2d, V2d, V2d, W, W, W); |
62 | if (!Ok) { continuity = GeomAbs_C1; } |
63 | } |
64 | if (continuity == GeomAbs_C1) { |
65 | Ok = (Func->D1(First, First, Last, P, V, P2d, V2d, W, W)); |
66 | if (!Ok) { continuity = GeomAbs_C0; } |
67 | } |
68 | } |
69 | |
70 | |
71 | // (2) Approximation |
72 | approx.Perform(First, Last, |
73 | Tol3d, Tol3d, Tol2d, TolAngular, |
74 | continuity, Degmax, Segmax); |
75 | } |
76 | |
77 | void BRepBlend_AppSurface::SurfShape (Standard_Integer& UDegree, |
78 | Standard_Integer& VDegree, |
79 | Standard_Integer& NbUPoles, |
80 | Standard_Integer& NbVPoles, |
81 | Standard_Integer& NbUKnots, |
82 | Standard_Integer& NbVKnots) const |
83 | { |
84 | approx.SurfShape(UDegree, VDegree, |
85 | NbUPoles, NbVPoles, |
86 | NbUKnots,NbVKnots); |
87 | } |
88 | |
89 | |
90 | void BRepBlend_AppSurface::Surface(TColgp_Array2OfPnt& TPoles, |
91 | TColStd_Array2OfReal& TWeights, |
92 | TColStd_Array1OfReal& TUKnots, |
93 | TColStd_Array1OfReal& TVKnots, |
94 | TColStd_Array1OfInteger& TUMults, |
95 | TColStd_Array1OfInteger& TVMults) const |
96 | |
97 | { |
98 | approx.Surface(TPoles, TWeights, TUKnots,TVKnots, TUMults,TVMults); |
99 | } |
100 | |
101 | |
102 | Standard_Real BRepBlend_AppSurface::MaxErrorOnSurf() const |
103 | { |
104 | return approx.MaxErrorOnSurf(); |
105 | } |
106 | |
107 | |
108 | void BRepBlend_AppSurface::Curves2dShape(Standard_Integer& Degree, |
109 | Standard_Integer& NbPoles, |
110 | Standard_Integer& NbKnots) const |
111 | { |
112 | approx.Curves2dShape( Degree, NbPoles, NbKnots); |
113 | } |
114 | |
115 | void BRepBlend_AppSurface::Curve2d(const Standard_Integer Index, |
116 | TColgp_Array1OfPnt2d& TPoles, |
117 | TColStd_Array1OfReal& TKnots, |
118 | TColStd_Array1OfInteger& TMults) const |
119 | { |
120 | approx.Curve2d(Index, TPoles, TKnots, TMults); |
121 | } |
122 | |
123 | Standard_Real BRepBlend_AppSurface::Max2dError(const Standard_Integer Index) const |
124 | { |
125 | return approx.Max2dError(Index); |
126 | } |
127 | |
128 | |
129 | Standard_Real BRepBlend_AppSurface::TolCurveOnSurf(const Standard_Integer Index) const |
130 | { |
131 | return approx.TolCurveOnSurf(Index); |
132 | } |
133 | |
134 | inline void BRepBlend_AppSurface::TolReached (Standard_Real& Tol3d, |
135 | Standard_Real& Tol2d) const |
136 | { |
137 | Tol3d = approx.MaxErrorOnSurf(); |
138 | Tol2d = 0; |
139 | for (Standard_Integer ii=1; ii<=approx.NbCurves2d(); ii++) { |
140 | Tol2d = Max(Tol2d, approx.Max2dError(ii)); |
141 | } |
142 | } |
143 | |
144 | void BRepBlend_AppSurface::Dump(Standard_OStream& o) const |
145 | { |
146 | approx.Dump(o); |
147 | } |