b311480e |
1 | // Copyright (c) 1997-1999 Matra Datavision |
973c2be1 |
2 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
3 | // |
973c2be1 |
4 | // This file is part of Open CASCADE Technology software library. |
b311480e |
5 | // |
d5f74e42 |
6 | // This library is free software; you can redistribute it and/or modify it under |
7 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
8 | // by the Free Software Foundation, with special exception defined in the file |
9 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
10 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
11 | // |
973c2be1 |
12 | // Alternatively, this file may be used under the terms of Open CASCADE |
13 | // commercial license or contractual agreement. |
b311480e |
14 | |
7fd59977 |
15 | // Modifed: Portage NT 7-5-97 DPF (return) |
16 | |
42cf5bc1 |
17 | #include <ChFi3d_FilletShape.hxx> |
18 | #include <FilletSurf_Builder.hxx> |
19 | #include <FilletSurf_ErrorTypeStatus.hxx> |
7fd59977 |
20 | #include <FilletSurf_InternalBuilder.hxx> |
7fd59977 |
21 | #include <Geom2d_Curve.hxx> |
42cf5bc1 |
22 | #include <Geom_Curve.hxx> |
23 | #include <Geom_Surface.hxx> |
7fd59977 |
24 | #include <Geom_TrimmedCurve.hxx> |
42cf5bc1 |
25 | #include <Standard_OutOfRange.hxx> |
7fd59977 |
26 | #include <StdFail_NotDone.hxx> |
42cf5bc1 |
27 | #include <TopoDS.hxx> |
28 | #include <TopoDS_Face.hxx> |
29 | #include <TopoDS_Shape.hxx> |
7fd59977 |
30 | |
31 | //======================================================================= |
32 | //function : FilletSurf_Builder |
33 | //purpose : |
34 | //======================================================================= |
7fd59977 |
35 | FilletSurf_Builder::FilletSurf_Builder(const TopoDS_Shape& S, |
36 | const TopTools_ListOfShape& E, |
37 | const Standard_Real R, |
38 | const Standard_Real Ta, |
39 | const Standard_Real Tapp3d, |
40 | const Standard_Real Tapp2d ): |
41 | myIntBuild(S,ChFi3d_Polynomial,Ta,Tapp3d,Tapp2d) |
42 | { |
43 | myisdone=FilletSurf_IsOk; |
44 | int add =myIntBuild.Add(E,R); |
45 | if (add!=0) { |
46 | myisdone=FilletSurf_IsNotOk; |
47 | if (add==1) myerrorstatus=FilletSurf_EmptyList; |
48 | else if(add==2) myerrorstatus=FilletSurf_EdgeNotG1; |
49 | else if(add==3) myerrorstatus=FilletSurf_FacesNotG1; |
50 | else if(add==4) myerrorstatus=FilletSurf_EdgeNotOnShape; |
51 | else if(add==5) myerrorstatus=FilletSurf_NotSharpEdge; |
52 | } |
53 | } |
54 | //======================================================== |
55 | // |
56 | //============================================================ |
57 | |
58 | void FilletSurf_Builder::Perform() |
59 | { |
60 | if (myisdone==FilletSurf_IsOk) { |
61 | myIntBuild.Perform(); |
62 | if (myIntBuild.Done()) myisdone=FilletSurf_IsOk; |
63 | else if (myIntBuild.NbSurface()!=0) { |
64 | myisdone=FilletSurf_IsPartial; |
65 | myerrorstatus=FilletSurf_PbFilletCompute; |
66 | } |
67 | else { |
68 | myisdone=FilletSurf_IsNotOk; |
69 | myerrorstatus=FilletSurf_PbFilletCompute; |
70 | } |
71 | } |
72 | } |
73 | |
74 | //======================================================================= |
75 | //function : IsDone |
76 | //purpose : gives the status of the computation of the fillet |
77 | //======================================================================= |
78 | FilletSurf_StatusDone FilletSurf_Builder::IsDone() const |
79 | { |
80 | return myisdone; |
81 | } |
82 | |
83 | //======================================================================= |
84 | //function : ErrorTypeStatus |
85 | //purpose : gives the status of the error |
86 | //======================================================================= |
87 | FilletSurf_ErrorTypeStatus FilletSurf_Builder::StatusError() const |
88 | { |
89 | return myerrorstatus; |
90 | } |
91 | |
92 | |
93 | //======================================================================= |
94 | //function : NbSurface |
95 | //purpose : gives the number of NUBS surfaces of the Fillet |
96 | //======================================================================= |
97 | |
98 | Standard_Integer FilletSurf_Builder::NbSurface() const |
99 | { |
100 | if (IsDone()!=FilletSurf_IsNotOk) return myIntBuild.NbSurface(); |
101 | StdFail_NotDone::Raise("FilletSurf_Builder::NbSurface"); |
102 | return 0; |
103 | } |
104 | |
105 | //======================================================================= |
106 | //function : SurfaceFillet |
107 | //purpose : gives the NUBS surface of index Index |
108 | //======================================================================= |
109 | |
110 | const Handle(Geom_Surface)& FilletSurf_Builder::SurfaceFillet(const Standard_Integer Index) const |
111 | { |
112 | if ( (Index<1)||(Index>NbSurface())) Standard_OutOfRange::Raise("FilletSurf_Builder::SurfaceFillet"); |
113 | return myIntBuild.SurfaceFillet(Index); |
114 | } |
115 | |
116 | //======================================================================= |
117 | //function : TolApp3d |
118 | //purpose : gives the 3d tolerance reached during approximation |
119 | //======================================================================= |
120 | Standard_Real FilletSurf_Builder::TolApp3d(const Standard_Integer Index) const |
121 | { |
122 | if ( (Index<1)||(Index>NbSurface())) |
123 | Standard_OutOfRange::Raise("FilletSurf_Builder::TolApp3d"); |
124 | return myIntBuild.TolApp3d(Index); |
125 | } |
126 | |
127 | //======================================================================= |
128 | //function : SupportFace1 |
129 | //purpose : gives the first support face relative to SurfaceFillet(Index) |
130 | //======================================================================= |
131 | const TopoDS_Face& FilletSurf_Builder::SupportFace1(const Standard_Integer Index) const |
132 | { |
133 | if ( (Index<1)||(Index>NbSurface())) |
134 | Standard_OutOfRange::Raise("FilletSurf_Builder::SupportFace1"); |
135 | return myIntBuild.SupportFace1(Index); |
136 | } |
137 | |
138 | //======================================================================= |
139 | //function : SupportFace2 |
140 | //purpose : gives the second support face relative to SurfaceFillet(Index) |
141 | //======================================================================= |
142 | const TopoDS_Face& FilletSurf_Builder::SupportFace2(const Standard_Integer Index) const |
143 | { |
144 | if ( (Index<1)||(Index>NbSurface())) |
145 | Standard_OutOfRange::Raise("FilletSurf_Builder::SupportFace2"); |
146 | return myIntBuild.SupportFace2(Index); |
147 | |
148 | } |
149 | |
150 | //=============================================================================== |
151 | //function : CurveOnFace1 |
152 | //purpose : gives the 3d curve of SurfaceFillet(Index) on SupportFace1(Index) |
153 | //=============================================================================== |
154 | const Handle(Geom_Curve)& FilletSurf_Builder::CurveOnFace1(const Standard_Integer Index) const |
155 | { |
156 | if ( (Index<1)||(Index>NbSurface())) |
157 | Standard_OutOfRange::Raise("FilletSurf_Builder::CurveOnFace1"); |
158 | return myIntBuild.CurveOnFace1(Index); |
159 | } |
160 | |
161 | //======================================================================= |
162 | //function : CurveOnFace2 |
163 | //purpose : gives the 3d curve of SurfaceFillet(Index) on SupportFace2(Index |
164 | //======================================================================= |
165 | const Handle(Geom_Curve)& FilletSurf_Builder::CurveOnFace2(const Standard_Integer Index) const |
166 | { |
167 | if ( (Index<1)||(Index>NbSurface())) |
168 | Standard_OutOfRange::Raise("FilletSurf_Builder::CurveOnFace2"); |
169 | return myIntBuild.CurveOnFace2(Index); |
170 | } |
171 | |
172 | //======================================================================= |
173 | //function : PCurveOnFace1 |
174 | //purpose : gives the PCurve associated to CurveOnFace1(Index) on the support face |
175 | //======================================================================= |
176 | const Handle(Geom2d_Curve)& FilletSurf_Builder::PCurveOnFace1(const Standard_Integer Index) const |
177 | { |
178 | if ( (Index<1)||(Index>NbSurface())) |
179 | Standard_OutOfRange::Raise( "FilletSurf_Builder::PCurveOnFace1"); |
180 | return myIntBuild.PCurveOnFace1(Index); |
181 | } |
182 | |
183 | //======================================================================= |
184 | //function : PCurve1OnFillet |
185 | //purpose : gives the PCurve associated to CurveOnFace1(Index) on the Fillet |
186 | //======================================================================= |
187 | const Handle(Geom2d_Curve)& FilletSurf_Builder::PCurve1OnFillet(const Standard_Integer Index) const |
188 | { |
189 | if ( (Index<1)||(Index>NbSurface())) |
190 | Standard_OutOfRange::Raise("FilletSurf_Builder::PCurve1OnFillet"); |
191 | return myIntBuild.PCurve1OnFillet(Index); |
192 | } |
193 | |
194 | //======================================================================= |
195 | //function : PCurveOnFace2 |
196 | //purpose : gives the PCurve associated to CurveOnFace2(Index) on the support face |
197 | //======================================================================= |
198 | const Handle(Geom2d_Curve)& FilletSurf_Builder::PCurveOnFace2(const Standard_Integer Index) const |
199 | { |
200 | if ( (Index<1)||(Index>NbSurface())) |
201 | Standard_OutOfRange::Raise("FilletSurf_Builder::PCurveOnFace2"); |
202 | return myIntBuild.PCurveOnFace2(Index); |
203 | } |
204 | |
205 | //======================================================================= |
206 | //function : PCurve2OnFillet |
207 | //purpose : gives the PCurve associated to CurveOnFace2(Index) on the Fillet |
208 | //======================================================================= |
209 | const Handle(Geom2d_Curve)& FilletSurf_Builder::PCurve2OnFillet(const Standard_Integer Index) const |
210 | { |
211 | if ( (Index<1)||(Index>NbSurface())) |
212 | Standard_OutOfRange::Raise("FilletSurf_Builder::PCurve2OnFillet"); |
213 | return myIntBuild.PCurve2OnFillet(Index); |
214 | } |
215 | |
216 | //======================================================================= |
217 | //function : FirstParameter |
218 | //purpose : gives the parameter of the fillet on the first edge |
219 | //======================================================================= |
220 | Standard_Real FilletSurf_Builder::FirstParameter() const |
221 | { |
222 | if (IsDone()==FilletSurf_IsNotOk) |
223 | StdFail_NotDone::Raise("FilletSurf_Builder::FirstParameter"); |
224 | return myIntBuild.FirstParameter(); |
225 | } |
226 | |
227 | //======================================================================= |
228 | //function : LastParameter |
229 | //purpose : gives the parameter of the fillet on the last edge |
230 | //======================================================================= |
231 | Standard_Real FilletSurf_Builder::LastParameter() const |
232 | { |
233 | if (IsDone()==FilletSurf_IsNotOk) |
234 | StdFail_NotDone::Raise("FilletSurf_Builder::LastParameter"); |
235 | return myIntBuild.LastParameter(); |
236 | } |
237 | |
238 | //======================================================================= |
239 | //function : StatusStartSection |
240 | //purpose : returns: |
241 | // twoExtremityonEdge: each extremity of start section of the Fillet is |
242 | // on the edge of the corresponding support face. |
243 | // OneExtremityOnEdge: only one of the extremities of start section of the Fillet |
244 | // is on the edge of the corresponding support face. |
245 | // NoExtremityOnEdge: any extremity of the start section ofthe fillet is on |
246 | // the edge of the corresponding support face. |
247 | //======================================================================= |
248 | FilletSurf_StatusType FilletSurf_Builder::StartSectionStatus() const |
249 | { |
250 | if (IsDone()==FilletSurf_IsNotOk) |
251 | StdFail_NotDone::Raise("FilletSurf_Builder::StartSectionStatus" ); |
252 | return myIntBuild.StartSectionStatus(); |
253 | } |
254 | |
255 | //======================================================================= |
256 | //function : StatusEndSection |
257 | //purpose : returns: |
258 | // twoExtremityonEdge: each extremity of end section of the Fillet is |
259 | // on the edge of the corresponding support face. |
260 | // OneExtremityOnEdge: only one of the extremities of end section of the Fillet |
261 | // is on the edge of the corresponding support face. |
262 | // NoExtremityOnEdge: any extremity of the end section of the fillet is on |
263 | // the edge of the corresponding support face. |
264 | //======================================================================= |
265 | FilletSurf_StatusType FilletSurf_Builder::EndSectionStatus() const |
266 | { |
267 | if (IsDone()==FilletSurf_IsNotOk) |
268 | StdFail_NotDone::Raise("FilletSurf_Builder::StartSectionStatus"); |
269 | return myIntBuild.EndSectionStatus(); |
270 | } |
271 | |
272 | //======================================================================= |
273 | //function : Simulate |
274 | //purpose : computes only the sections used in the computation of the fillet |
275 | //======================================================================= |
276 | void FilletSurf_Builder::Simulate() |
277 | { |
278 | if (myisdone==FilletSurf_IsOk) { |
279 | myIntBuild.Simulate(); |
280 | |
281 | if (myIntBuild.Done()) myisdone=FilletSurf_IsOk; |
282 | else { myisdone=FilletSurf_IsNotOk; |
283 | myerrorstatus=FilletSurf_PbFilletCompute;} |
284 | } |
285 | } |
286 | |
287 | //======================================================================= |
288 | //function : NbSection |
289 | //purpose : gives the number of sections relative to SurfaceFillet(IndexSurf) |
290 | //======================================================================= |
291 | Standard_Integer FilletSurf_Builder::NbSection(const Standard_Integer IndexSurf) const |
292 | { |
293 | if (IsDone()==FilletSurf_IsNotOk) |
294 | StdFail_NotDone::Raise("FilletSurf_Builder::NbSection)"); |
295 | else if ( (IndexSurf<1)||(IndexSurf>NbSurface())) Standard_OutOfRange::Raise |
296 | ("FilletSurf_Builder::NbSection"); |
297 | return myIntBuild.NbSection(IndexSurf); |
298 | } |
299 | |
300 | //======================================================================= |
301 | //function : Section |
302 | //purpose : gives the arc of circle corresponding to section number |
303 | // IndexSec of SurfaceFillet(IndexSurf) (The basis curve of the |
304 | // trimmed curve is a Geom_Circle) |
305 | //======================================================================= |
306 | void FilletSurf_Builder::Section(const Standard_Integer IndexSurf, |
307 | const Standard_Integer IndexSec, |
308 | Handle(Geom_TrimmedCurve)& Circ) const |
309 | { |
310 | if ((IndexSurf<1)||(IndexSurf>NbSurface())) |
311 | Standard_OutOfRange::Raise("FilletSurf_Builder::Section NbSurface"); |
312 | |
313 | else if ((IndexSec<1)||(IndexSec>NbSection(IndexSurf))) |
314 | Standard_OutOfRange::Raise("FilletSurf_Builder::Section NbSection"); |
315 | |
316 | else myIntBuild.Section(IndexSurf, IndexSec,Circ); |
317 | } |