]>
Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1996-11-26 |
2 | // Created by: Philippe MANGIN | |
3 | // Copyright (c) 1996-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 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 | |
973c2be1 | 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. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
7fd59977 | 17 | |
42cf5bc1 | 18 | #include <Approx_SweepFunction.hxx> |
19 | #include <BRepBlend_AppSurface.hxx> | |
7fd59977 | 20 | #include <TColgp_Array1OfPnt.hxx> |
21 | #include <TColgp_Array1OfPnt2d.hxx> | |
22 | #include <TColgp_Array1OfVec.hxx> | |
23 | #include <TColgp_Array1OfVec2d.hxx> | |
24 | #include <TColStd_Array1OfReal.hxx> | |
25 | ||
7fd59977 | 26 | BRepBlend_AppSurface::BRepBlend_AppSurface( |
7f22979e | 27 | const Handle(Approx_SweepFunction)& Func, |
7fd59977 | 28 | const Standard_Real First, |
29 | const Standard_Real Last, | |
30 | const Standard_Real Tol3d, | |
31 | const Standard_Real Tol2d, | |
32 | const Standard_Real TolAngular, | |
33 | const GeomAbs_Shape Continuity, | |
34 | const Standard_Integer Degmax, | |
35 | const Standard_Integer Segmax) : | |
36 | approx(Func) | |
37 | { | |
38 | Standard_Integer Nb2d = Func->Nb2dCurves(); | |
39 | Standard_Integer NbPolSect, NbKnotSect, udeg; | |
40 | GeomAbs_Shape continuity = Continuity; | |
41 | ||
42 | // (1) Verification de la possibilite de derivation | |
43 | if (continuity != GeomAbs_C0) { | |
44 | if (Nb2d == 0) Nb2d =1; | |
45 | Func->SectionShape(NbPolSect, NbKnotSect, udeg); | |
46 | TColStd_Array1OfReal W (1, NbPolSect); | |
47 | TColgp_Array1OfPnt P (1, NbPolSect); | |
48 | TColgp_Array1OfPnt2d P2d(1, Nb2d); | |
49 | TColgp_Array1OfVec V (1, NbPolSect); | |
50 | TColgp_Array1OfVec2d V2d(1, Nb2d); | |
51 | Standard_Boolean Ok; | |
52 | if (continuity == GeomAbs_C2) { | |
53 | Ok = Func->D2( First, First, Last, P, V, V, P2d, V2d, V2d, W, W, W); | |
54 | if (!Ok) { continuity = GeomAbs_C1; } | |
55 | } | |
56 | if (continuity == GeomAbs_C1) { | |
57 | Ok = (Func->D1(First, First, Last, P, V, P2d, V2d, W, W)); | |
58 | if (!Ok) { continuity = GeomAbs_C0; } | |
59 | } | |
60 | } | |
61 | ||
62 | ||
63 | // (2) Approximation | |
64 | approx.Perform(First, Last, | |
65 | Tol3d, Tol3d, Tol2d, TolAngular, | |
66 | continuity, Degmax, Segmax); | |
67 | } | |
68 | ||
69 | void BRepBlend_AppSurface::SurfShape (Standard_Integer& UDegree, | |
70 | Standard_Integer& VDegree, | |
71 | Standard_Integer& NbUPoles, | |
72 | Standard_Integer& NbVPoles, | |
73 | Standard_Integer& NbUKnots, | |
74 | Standard_Integer& NbVKnots) const | |
75 | { | |
76 | approx.SurfShape(UDegree, VDegree, | |
77 | NbUPoles, NbVPoles, | |
78 | NbUKnots,NbVKnots); | |
79 | } | |
80 | ||
81 | ||
82 | void BRepBlend_AppSurface::Surface(TColgp_Array2OfPnt& TPoles, | |
83 | TColStd_Array2OfReal& TWeights, | |
84 | TColStd_Array1OfReal& TUKnots, | |
85 | TColStd_Array1OfReal& TVKnots, | |
86 | TColStd_Array1OfInteger& TUMults, | |
87 | TColStd_Array1OfInteger& TVMults) const | |
88 | ||
89 | { | |
90 | approx.Surface(TPoles, TWeights, TUKnots,TVKnots, TUMults,TVMults); | |
91 | } | |
92 | ||
93 | ||
94 | Standard_Real BRepBlend_AppSurface::MaxErrorOnSurf() const | |
95 | { | |
96 | return approx.MaxErrorOnSurf(); | |
97 | } | |
98 | ||
99 | ||
100 | void BRepBlend_AppSurface::Curves2dShape(Standard_Integer& Degree, | |
101 | Standard_Integer& NbPoles, | |
102 | Standard_Integer& NbKnots) const | |
103 | { | |
104 | approx.Curves2dShape( Degree, NbPoles, NbKnots); | |
105 | } | |
106 | ||
107 | void BRepBlend_AppSurface::Curve2d(const Standard_Integer Index, | |
108 | TColgp_Array1OfPnt2d& TPoles, | |
109 | TColStd_Array1OfReal& TKnots, | |
110 | TColStd_Array1OfInteger& TMults) const | |
111 | { | |
112 | approx.Curve2d(Index, TPoles, TKnots, TMults); | |
113 | } | |
114 | ||
115 | Standard_Real BRepBlend_AppSurface::Max2dError(const Standard_Integer Index) const | |
116 | { | |
117 | return approx.Max2dError(Index); | |
118 | } | |
119 | ||
120 | ||
121 | Standard_Real BRepBlend_AppSurface::TolCurveOnSurf(const Standard_Integer Index) const | |
122 | { | |
123 | return approx.TolCurveOnSurf(Index); | |
124 | } | |
125 | ||
746cb7c3 | 126 | void BRepBlend_AppSurface::TolReached (Standard_Real& Tol3d, |
127 | Standard_Real& Tol2d) const | |
7fd59977 | 128 | { |
129 | Tol3d = approx.MaxErrorOnSurf(); | |
130 | Tol2d = 0; | |
131 | for (Standard_Integer ii=1; ii<=approx.NbCurves2d(); ii++) { | |
132 | Tol2d = Max(Tol2d, approx.Max2dError(ii)); | |
133 | } | |
134 | } | |
135 | ||
136 | void BRepBlend_AppSurface::Dump(Standard_OStream& o) const | |
137 | { | |
138 | approx.Dump(o); | |
139 | } |