1 // Copyright (c) 1997-1999 Matra Datavision
2 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 // This file is part of Open CASCADE Technology software library.
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
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.
12 // Alternatively, this file may be used under the terms of Open CASCADE
13 // commercial license or contractual agreement.
15 // Modifed: Portage NT 7-5-97 DPF (return)
17 #include <ChFi3d_FilletShape.hxx>
18 #include <FilletSurf_Builder.hxx>
19 #include <FilletSurf_ErrorTypeStatus.hxx>
20 #include <FilletSurf_InternalBuilder.hxx>
21 #include <Geom2d_Curve.hxx>
22 #include <Geom_Curve.hxx>
23 #include <Geom_Surface.hxx>
24 #include <Geom_TrimmedCurve.hxx>
25 #include <Standard_OutOfRange.hxx>
26 #include <StdFail_NotDone.hxx>
28 #include <TopoDS_Face.hxx>
29 #include <TopoDS_Shape.hxx>
31 //=======================================================================
32 //function : FilletSurf_Builder
34 //=======================================================================
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)
43 myisdone=FilletSurf_IsOk;
44 myerrorstatus = FilletSurf_EmptyList;
45 int add =myIntBuild.Add(E,R);
47 myisdone=FilletSurf_IsNotOk;
48 if (add==1) myerrorstatus=FilletSurf_EmptyList;
49 else if(add==2) myerrorstatus=FilletSurf_EdgeNotG1;
50 else if(add==3) myerrorstatus=FilletSurf_FacesNotG1;
51 else if(add==4) myerrorstatus=FilletSurf_EdgeNotOnShape;
52 else if(add==5) myerrorstatus=FilletSurf_NotSharpEdge;
55 //========================================================
57 //============================================================
59 void FilletSurf_Builder::Perform()
61 if (myisdone==FilletSurf_IsOk) {
63 if (myIntBuild.Done()) myisdone=FilletSurf_IsOk;
64 else if (myIntBuild.NbSurface()!=0) {
65 myisdone=FilletSurf_IsPartial;
66 myerrorstatus=FilletSurf_PbFilletCompute;
69 myisdone=FilletSurf_IsNotOk;
70 myerrorstatus=FilletSurf_PbFilletCompute;
75 //=======================================================================
77 //purpose : gives the status of the computation of the fillet
78 //=======================================================================
79 FilletSurf_StatusDone FilletSurf_Builder::IsDone() const
84 //=======================================================================
85 //function : ErrorTypeStatus
86 //purpose : gives the status of the error
87 //=======================================================================
88 FilletSurf_ErrorTypeStatus FilletSurf_Builder::StatusError() const
94 //=======================================================================
95 //function : NbSurface
96 //purpose : gives the number of NUBS surfaces of the Fillet
97 //=======================================================================
99 Standard_Integer FilletSurf_Builder::NbSurface() const
101 if (IsDone()!=FilletSurf_IsNotOk) return myIntBuild.NbSurface();
102 throw StdFail_NotDone("FilletSurf_Builder::NbSurface");
105 //=======================================================================
106 //function : SurfaceFillet
107 //purpose : gives the NUBS surface of index Index
108 //=======================================================================
110 const Handle(Geom_Surface)& FilletSurf_Builder::SurfaceFillet(const Standard_Integer Index) const
112 if ( (Index<1)||(Index>NbSurface())) throw Standard_OutOfRange("FilletSurf_Builder::SurfaceFillet");
113 return myIntBuild.SurfaceFillet(Index);
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
122 if ( (Index<1)||(Index>NbSurface()))
123 throw Standard_OutOfRange("FilletSurf_Builder::TolApp3d");
124 return myIntBuild.TolApp3d(Index);
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
133 if ( (Index<1)||(Index>NbSurface()))
134 throw Standard_OutOfRange("FilletSurf_Builder::SupportFace1");
135 return myIntBuild.SupportFace1(Index);
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
144 if ( (Index<1)||(Index>NbSurface()))
145 throw Standard_OutOfRange("FilletSurf_Builder::SupportFace2");
146 return myIntBuild.SupportFace2(Index);
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
156 if ( (Index<1)||(Index>NbSurface()))
157 throw Standard_OutOfRange("FilletSurf_Builder::CurveOnFace1");
158 return myIntBuild.CurveOnFace1(Index);
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
167 if ( (Index<1)||(Index>NbSurface()))
168 throw Standard_OutOfRange("FilletSurf_Builder::CurveOnFace2");
169 return myIntBuild.CurveOnFace2(Index);
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
178 if ( (Index<1)||(Index>NbSurface()))
179 throw Standard_OutOfRange( "FilletSurf_Builder::PCurveOnFace1");
180 return myIntBuild.PCurveOnFace1(Index);
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
189 if ( (Index<1)||(Index>NbSurface()))
190 throw Standard_OutOfRange("FilletSurf_Builder::PCurve1OnFillet");
191 return myIntBuild.PCurve1OnFillet(Index);
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
200 if ( (Index<1)||(Index>NbSurface()))
201 throw Standard_OutOfRange("FilletSurf_Builder::PCurveOnFace2");
202 return myIntBuild.PCurveOnFace2(Index);
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
211 if ( (Index<1)||(Index>NbSurface()))
212 throw Standard_OutOfRange("FilletSurf_Builder::PCurve2OnFillet");
213 return myIntBuild.PCurve2OnFillet(Index);
216 //=======================================================================
217 //function : FirstParameter
218 //purpose : gives the parameter of the fillet on the first edge
219 //=======================================================================
220 Standard_Real FilletSurf_Builder::FirstParameter() const
222 if (IsDone()==FilletSurf_IsNotOk)
223 throw StdFail_NotDone("FilletSurf_Builder::FirstParameter");
224 return myIntBuild.FirstParameter();
227 //=======================================================================
228 //function : LastParameter
229 //purpose : gives the parameter of the fillet on the last edge
230 //=======================================================================
231 Standard_Real FilletSurf_Builder::LastParameter() const
233 if (IsDone()==FilletSurf_IsNotOk)
234 throw StdFail_NotDone("FilletSurf_Builder::LastParameter");
235 return myIntBuild.LastParameter();
238 //=======================================================================
239 //function : StatusStartSection
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
250 if (IsDone()==FilletSurf_IsNotOk)
251 throw StdFail_NotDone("FilletSurf_Builder::StartSectionStatus" );
252 return myIntBuild.StartSectionStatus();
255 //=======================================================================
256 //function : StatusEndSection
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
267 if (IsDone()==FilletSurf_IsNotOk)
268 throw StdFail_NotDone("FilletSurf_Builder::StartSectionStatus");
269 return myIntBuild.EndSectionStatus();
272 //=======================================================================
273 //function : Simulate
274 //purpose : computes only the sections used in the computation of the fillet
275 //=======================================================================
276 void FilletSurf_Builder::Simulate()
278 if (myisdone==FilletSurf_IsOk) {
279 myIntBuild.Simulate();
281 if (myIntBuild.Done()) myisdone=FilletSurf_IsOk;
282 else { myisdone=FilletSurf_IsNotOk;
283 myerrorstatus=FilletSurf_PbFilletCompute;}
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
293 if (IsDone()==FilletSurf_IsNotOk)
294 throw StdFail_NotDone("FilletSurf_Builder::NbSection)");
295 else if ( (IndexSurf<1)||(IndexSurf>NbSurface())) throw Standard_OutOfRange("FilletSurf_Builder::NbSection");
296 return myIntBuild.NbSection(IndexSurf);
299 //=======================================================================
301 //purpose : gives the arc of circle corresponding to section number
302 // IndexSec of SurfaceFillet(IndexSurf) (The basis curve of the
303 // trimmed curve is a Geom_Circle)
304 //=======================================================================
305 void FilletSurf_Builder::Section(const Standard_Integer IndexSurf,
306 const Standard_Integer IndexSec,
307 Handle(Geom_TrimmedCurve)& Circ) const
309 if ((IndexSurf<1)||(IndexSurf>NbSurface()))
310 throw Standard_OutOfRange("FilletSurf_Builder::Section NbSurface");
312 else if ((IndexSec<1)||(IndexSec>NbSection(IndexSurf)))
313 throw Standard_OutOfRange("FilletSurf_Builder::Section NbSection");
315 else myIntBuild.Section(IndexSurf, IndexSec,Circ);