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 | |
42cf5bc1 |
16 | #include <Adaptor3d_TopolTool.hxx> |
17 | #include <BRep_Tool.hxx> |
18 | #include <BRepAdaptor_HCurve.hxx> |
19 | #include <BRepAdaptor_HCurve2d.hxx> |
20 | #include <BRepAdaptor_HSurface.hxx> |
21 | #include <BRepBlend_ConstRad.hxx> |
22 | #include <BRepBlend_ConstRadInv.hxx> |
23 | #include <BRepBlend_Line.hxx> |
24 | #include <BRepExtrema_DistShapeShape.hxx> |
7fd59977 |
25 | #include <ChFi3d_Builder_0.hxx> |
42cf5bc1 |
26 | #include <ChFi3d_FilBuilder.hxx> |
27 | #include <ChFiDS_CircSection.hxx> |
28 | #include <ChFiDS_CommonPoint.hxx> |
29 | #include <ChFiDS_FaceInterference.hxx> |
7fd59977 |
30 | #include <ChFiDS_FilSpine.hxx> |
42cf5bc1 |
31 | #include <ChFiDS_HData.hxx> |
7fd59977 |
32 | #include <ChFiDS_HElSpine.hxx> |
7fd59977 |
33 | #include <ChFiDS_ListIteratorOfListOfStripe.hxx> |
42cf5bc1 |
34 | #include <ChFiDS_ListOfStripe.hxx> |
7fd59977 |
35 | #include <ChFiDS_SecHArray1.hxx> |
42cf5bc1 |
36 | #include <ChFiDS_SequenceOfSurfData.hxx> |
37 | #include <ChFiDS_Spine.hxx> |
38 | #include <ChFiDS_Stripe.hxx> |
39 | #include <ChFiDS_SurfData.hxx> |
40 | #include <ElSLib.hxx> |
41 | #include <FilletSurf_ErrorTypeStatus.hxx> |
42 | #include <FilletSurf_InternalBuilder.hxx> |
43 | #include <FilletSurf_StatusDone.hxx> |
44 | #include <FilletSurf_StatusType.hxx> |
45 | #include <Geom2d_Curve.hxx> |
46 | #include <Geom_Circle.hxx> |
7fd59977 |
47 | #include <Geom_Curve.hxx> |
42cf5bc1 |
48 | #include <Geom_Plane.hxx> |
49 | #include <Geom_Surface.hxx> |
7fd59977 |
50 | #include <Geom_TrimmedCurve.hxx> |
42cf5bc1 |
51 | #include <GeomAbs_Shape.hxx> |
7fd59977 |
52 | #include <GeomAdaptor_HCurve.hxx> |
42cf5bc1 |
53 | #include <GeomAdaptor_HSurface.hxx> |
54 | #include <GeomAdaptor_Surface.hxx> |
7fd59977 |
55 | #include <gp_Circ.hxx> |
56 | #include <gp_Pln.hxx> |
7fd59977 |
57 | #include <IntCurveSurface_HInter.hxx> |
58 | #include <IntCurveSurface_IntersectionPoint.hxx> |
7fd59977 |
59 | #include <Precision.hxx> |
42cf5bc1 |
60 | #include <Standard_ConstructionError.hxx> |
61 | #include <TopoDS.hxx> |
62 | #include <TopoDS_Face.hxx> |
63 | #include <TopoDS_Shape.hxx> |
64 | #include <TopOpeBRepDS_HDataStructure.hxx> |
65 | #include <TopTools_ListIteratorOfListOfShape.hxx> |
7fd59977 |
66 | |
67 | static Standard_Boolean isinlist(const TopoDS_Shape& E, |
68 | const TopTools_ListOfShape& L){ |
69 | TopTools_ListIteratorOfListOfShape It; |
70 | for (It.Initialize(L); It.More(); It.Next()){ |
71 | if(E.IsSame(It.Value())) return 1; |
72 | } |
73 | return 0; |
74 | } |
75 | |
76 | static Standard_Boolean IntPlanEdge(Handle(BRepAdaptor_HCurve)& Ed, |
77 | const gp_Pln& P, |
78 | Standard_Real& w, |
79 | const Standard_Real tol3d) |
80 | { |
81 | Standard_Boolean done = 0; |
82 | Standard_Real f = Ed->FirstParameter(); |
83 | Standard_Real l = Ed->LastParameter(); |
84 | gp_Pnt Or = P.Location(); |
85 | Handle(Geom_Plane) Pln = new Geom_Plane(P); |
86 | Handle(GeomAdaptor_HSurface) |
87 | Plan = new GeomAdaptor_HSurface(GeomAdaptor_Surface(Pln)); |
88 | |
89 | IntCurveSurface_HInter Intersection; |
90 | Standard_Integer nbp ,iip; |
91 | IntCurveSurface_IntersectionPoint IP; |
92 | Standard_Real dist = RealLast(); |
93 | |
94 | Intersection.Perform(Ed,Plan); |
95 | |
96 | if(Intersection.IsDone()){ |
97 | nbp = Intersection.NbPoints(); |
98 | for (iip = 1; iip <= nbp; iip++){ |
99 | IP = Intersection.Point(iip); |
100 | gp_Pnt pint = IP.Pnt(); |
101 | Standard_Real d = pint.Distance(Or); |
102 | if(d<dist){ |
103 | done = 1; |
104 | w = IP.W(); |
105 | dist = d; |
106 | } |
107 | } |
108 | } |
109 | gp_Pnt pdeb = Ed->Value(f); |
110 | gp_Pnt pfin = Ed->Value(l); |
111 | Standard_Real u,v; |
81bba717 |
112 | //check if the extremities are not solution |
7fd59977 |
113 | ElSLib::Parameters(P,pdeb,u,v); |
114 | gp_Pnt projdeb = ElSLib::Value(u,v,P); |
115 | Standard_Real dprojdeb = pdeb.Distance(projdeb); |
116 | if(dprojdeb<tol3d){ |
117 | Standard_Real d = pdeb.Distance(Or); |
118 | if(d<dist){ |
119 | done = 1; |
120 | w = f; |
121 | dist = d; |
122 | } |
123 | } |
124 | ElSLib::Parameters(P,pfin,u,v); |
125 | gp_Pnt projfin = ElSLib::Value(u,v,P); |
126 | Standard_Real dprojfin = pfin.Distance(projfin); |
127 | if(dprojfin<tol3d){ |
128 | Standard_Real d = pfin.Distance(Or); |
129 | if(d<dist){ |
130 | done = 1; |
131 | w = l; |
132 | dist = d; |
133 | } |
134 | } |
135 | return done; |
136 | } |
137 | |
138 | static Standard_Boolean ComputeEdgeParameter(const Handle(ChFiDS_Spine)& Spine, |
139 | const Standard_Integer ind, |
140 | const Standard_Real pelsp, |
141 | Standard_Real& ped, |
142 | const Standard_Real tol3d) |
143 | { |
144 | Handle(ChFiDS_HElSpine) Guide = Spine->ElSpine(ind); |
145 | gp_Pnt P; gp_Vec V; |
146 | Guide->D1(pelsp,P,V); |
147 | gp_Pln pln(P,V); |
148 | Handle(BRepAdaptor_HCurve) ed = new BRepAdaptor_HCurve(); |
149 | ed->ChangeCurve() = Spine->CurrentElementarySpine(ind); |
150 | return IntPlanEdge(ed,pln,ped,tol3d); |
151 | } |
152 | |
153 | //======================================================================= |
154 | //function : FilletSurf_InternalBuilder |
155 | //purpose : |
156 | //======================================================================= |
157 | |
158 | FilletSurf_InternalBuilder::FilletSurf_InternalBuilder |
159 | (const TopoDS_Shape& S, |
160 | const ChFi3d_FilletShape FShape, |
161 | const Standard_Real Ta, |
162 | const Standard_Real Tapp3d, |
163 | const Standard_Real Tapp2d):ChFi3d_FilBuilder(S,FShape,Ta) |
164 | { |
165 | SetParams(Ta,Tapp3d,Tapp2d, |
166 | Tapp3d,Tapp2d,1.e-3); |
167 | SetContinuity(GeomAbs_C2,Ta); |
168 | } |
169 | |
170 | //======================================================================= |
171 | //function : Add |
81bba717 |
172 | //purpose : creation of spine on a set of edges |
7fd59977 |
173 | // |
81bba717 |
174 | // 0 : no problem |
175 | // 1 : empty list |
176 | // 2 : non g1 edges |
177 | // 3 : non G1 adjacent faces |
178 | // 4 : edge is not on the shape |
179 | // 5 : edge is not alive |
7fd59977 |
180 | //======================================================================= |
181 | |
182 | Standard_Integer FilletSurf_InternalBuilder::Add(const TopTools_ListOfShape& E, |
183 | const Standard_Real R) |
184 | { |
185 | if(E.IsEmpty()) return 1; |
186 | TopTools_ListIteratorOfListOfShape It; |
187 | for(It.Initialize(E); It.More(); It.Next()){ |
188 | TopoDS_Edge cured = TopoDS::Edge(It.Value()); |
189 | if(cured.IsNull()) return 4; |
190 | if(!myEFMap.Contains(cured)) return 4; |
81bba717 |
191 | //check if the edge is a fracture edge |
7fd59977 |
192 | TopoDS_Face ff1,ff2; |
193 | for(It.Initialize(myEFMap(cured));It.More();It.Next()){ |
194 | if (ff1.IsNull()) { |
195 | ff1 = TopoDS::Face(It.Value()); |
196 | } |
197 | else { |
198 | ff2 = TopoDS::Face(It.Value()); |
199 | if(!ff2.IsSame(ff1)){ |
200 | break; |
201 | } |
202 | } |
203 | } |
204 | if(ff1.IsNull() || ff2.IsNull()) return 5; |
205 | if(ff1.IsSame(ff2)) return 5; |
206 | if(BRep_Tool::Continuity(cured,ff1,ff2) != GeomAbs_C0) return 5; |
207 | } |
208 | TopoDS_Edge ed = TopoDS::Edge(E.First()); |
209 | ed.Orientation(TopAbs_FORWARD); |
210 | ChFi3d_FilBuilder::Add(R,ed); |
211 | Handle(ChFiDS_Stripe) st = myListStripe.First(); |
212 | Handle(ChFiDS_Spine)& sp = st->ChangeSpine(); |
213 | Standard_Boolean periodic = sp->IsPeriodic(); |
214 | |
81bba717 |
215 | //It is checked if edges of list E are in the contour, |
216 | //the edges that arenot in the list are removed from the contour, |
217 | //it is checked that the remainder is monoblock. |
7fd59977 |
218 | |
219 | for(It.Initialize(E); It.More(); It.Next()){ |
220 | TopoDS_Edge cured = TopoDS::Edge(It.Value()); |
221 | if(!Contains(cured)) return 2; |
222 | } |
223 | |
224 | Handle(ChFiDS_FilSpine) newsp = new ChFiDS_FilSpine(); |
225 | Standard_Boolean debut = 0; |
226 | Standard_Integer premierquinyestpas = 0; |
227 | Standard_Integer yatrou = 0; |
228 | for(Standard_Integer i = 1; i <= sp->NbEdges(); i++){ |
229 | TopoDS_Edge cured = sp->Edges(i); |
230 | if(isinlist(cured,E)){ |
231 | debut = 1; |
232 | if(premierquinyestpas) { |
233 | yatrou = 1; |
234 | break; |
235 | } |
236 | newsp->SetEdges(cured); |
237 | } |
238 | else if(debut && !premierquinyestpas) premierquinyestpas = i; |
239 | } |
240 | if(!periodic && yatrou) return 2; |
241 | if(periodic && yatrou){ |
51740958 |
242 | Standard_Boolean vraitrou = 0, aLocalDebut = 0; |
7fd59977 |
243 | for(Standard_Integer i = sp->NbEdges(); i > yatrou; i--){ |
244 | TopoDS_Edge cured = sp->Edges(i); |
245 | if(isinlist(cured,E)){ |
246 | if(vraitrou) return 2; |
247 | newsp->PutInFirst(cured); |
248 | } |
51740958 |
249 | else if(aLocalDebut) vraitrou = 1; |
250 | aLocalDebut = 1; |
7fd59977 |
251 | } |
252 | } |
253 | |
254 | if(newsp->NbEdges() != sp->NbEdges()) { |
255 | newsp->Load(); |
256 | newsp->SetRadius(R); |
257 | sp = newsp; |
258 | } |
259 | |
81bba717 |
260 | //ElSpine is immediately constructed |
7fd59977 |
261 | Handle(ChFiDS_HElSpine) hels = new ChFiDS_HElSpine(); |
262 | gp_Vec TFirst,TLast; |
263 | gp_Pnt PFirst,PLast; |
264 | sp->D1(sp->FirstParameter(),PFirst,TFirst); |
265 | sp->D1(sp->LastParameter(),PLast,TLast); |
266 | hels->ChangeCurve().FirstParameter(sp->FirstParameter()); |
267 | hels->ChangeCurve().SetFirstPointAndTgt(PFirst,TFirst); |
268 | hels->ChangeCurve().LastParameter(sp->LastParameter()); |
269 | hels->ChangeCurve().SetLastPointAndTgt(PLast,TLast); |
270 | ChFi3d_PerformElSpine(hels,sp,myConti,tolesp); |
271 | sp->AppendElSpine(hels); |
272 | sp->SplitDone(Standard_True); |
273 | return 0; |
274 | } |
275 | |
276 | //======================================================================= |
277 | //function : Perform |
278 | //purpose : |
279 | //======================================================================= |
280 | |
281 | void FilletSurf_InternalBuilder::Perform() |
282 | { |
81bba717 |
283 | //PerformSetOfSurfOnElSpine is enough. |
7fd59977 |
284 | |
285 | Handle(ChFiDS_Stripe) Stripe = myListStripe.First(); |
286 | Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData(); |
287 | HData = new ChFiDS_HData(); |
288 | Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine(); |
289 | TopAbs_Orientation RefOr1,RefOr2; |
290 | Standard_Integer RefChoix; |
291 | StripeOrientations(Spine,RefOr1,RefOr2,RefChoix); |
292 | Stripe->OrientationOnFace1(RefOr1); |
293 | Stripe->OrientationOnFace2(RefOr2); |
294 | Stripe->Choix(RefChoix); |
295 | PerformSetOfKGen(Stripe,0); |
296 | } |
297 | |
298 | //======================================================================= |
299 | //function : PerformSurf |
300 | //purpose : |
301 | //======================================================================= |
302 | |
303 | Standard_Boolean |
304 | FilletSurf_InternalBuilder::PerformSurf(ChFiDS_SequenceOfSurfData& SeqData, |
305 | const Handle(ChFiDS_HElSpine)& Guide, |
306 | const Handle(ChFiDS_Spine)& Spine, |
307 | const Standard_Integer Choix, |
308 | const Handle(BRepAdaptor_HSurface)& S1, |
309 | const Handle(Adaptor3d_TopolTool)& I1, |
310 | const Handle(BRepAdaptor_HSurface)& S2, |
311 | const Handle(Adaptor3d_TopolTool)& I2, |
312 | const Standard_Real MaxStep, |
313 | const Standard_Real Fleche, |
314 | const Standard_Real TolGuide, |
315 | Standard_Real& First, |
316 | Standard_Real& Last, |
317 | const Standard_Boolean Inside, |
318 | const Standard_Boolean Appro, |
319 | const Standard_Boolean Forward, |
320 | const Standard_Boolean RecOnS1, |
321 | const Standard_Boolean RecOnS2, |
322 | const math_Vector& Soldep, |
dde68833 |
323 | Standard_Integer& Intf, |
324 | Standard_Integer& Intl) |
7fd59977 |
325 | { |
326 | Handle(ChFiDS_SurfData) Data = SeqData(1); |
327 | Handle(ChFiDS_FilSpine) fsp = Handle(ChFiDS_FilSpine)::DownCast(Spine); |
9775fa61 |
328 | if(fsp.IsNull()) throw Standard_ConstructionError("PerformSurf : this is not the spine of a fillet"); |
7fd59977 |
329 | Handle(BRepBlend_Line) lin; |
330 | TopAbs_Orientation Or = S1->ChangeSurface().Face().Orientation(); |
9775fa61 |
331 | if(!fsp->IsConstant()) throw Standard_ConstructionError("PerformSurf : no variable radiuses"); |
7fd59977 |
332 | // Standard_Boolean maybesingular; //pour scinder les Surfdata singulieres |
333 | |
1d54b807 |
334 | Handle(ChFiDS_HElSpine) EmptyGuide; |
335 | |
7fd59977 |
336 | BRepBlend_ConstRad Func(S1,S2,Guide); |
337 | BRepBlend_ConstRadInv FInv(S1,S2,Guide); |
338 | Func.Set(fsp->Radius(),Choix); |
339 | FInv.Set(fsp->Radius(),Choix); |
340 | switch (GetFilletShape()) { |
341 | case ChFi3d_Rational: |
342 | Func.Set(BlendFunc_Rational); |
343 | break; |
344 | case ChFi3d_QuasiAngular: |
345 | Func.Set(BlendFunc_QuasiAngular); |
346 | break; |
347 | case ChFi3d_Polynomial: |
348 | Func.Set(BlendFunc_Polynomial); |
349 | } |
350 | Standard_Real PFirst = First; |
1d54b807 |
351 | done = SimulData(Data,Guide,EmptyGuide,lin,S1,I1, |
7fd59977 |
352 | S2,I2,Func,FInv,PFirst,MaxStep,Fleche, |
353 | TolGuide,First,Last,Inside,Appro,Forward,Soldep, |
354 | 20,RecOnS1,RecOnS2); |
355 | if(!done) return Standard_False; |
356 | if(lin->StartPointOnFirst().NbPointOnRst() !=0){ |
357 | ChFi3d_FilCommonPoint(lin->StartPointOnFirst(),lin->TransitionOnS1(), |
358 | Standard_True, Data->ChangeVertexFirstOnS1(), tolesp); |
359 | } |
360 | if(lin->EndPointOnFirst().NbPointOnRst() !=0){ |
361 | ChFi3d_FilCommonPoint(lin->EndPointOnFirst(),lin->TransitionOnS1(), |
362 | Standard_False,Data->ChangeVertexLastOnS1(), tolesp); |
363 | } |
364 | if(lin->StartPointOnSecond().NbPointOnRst() !=0){ |
365 | ChFi3d_FilCommonPoint(lin->StartPointOnSecond(),lin->TransitionOnS2(), |
366 | Standard_True, Data->ChangeVertexFirstOnS2(), tolesp); |
367 | } |
368 | if(lin->EndPointOnSecond().NbPointOnRst() !=0){ |
369 | ChFi3d_FilCommonPoint(lin->EndPointOnSecond(),lin->TransitionOnS2(), |
370 | Standard_False, Data->ChangeVertexLastOnS2(), tolesp); |
371 | } |
372 | done = CompleteData(Data,Func,lin,S1,S2,Or,0,0,0,0); |
9775fa61 |
373 | if(!done) throw Standard_Failure("PerformSurf : Failed approximation!"); |
7fd59977 |
374 | // maybesingular = (Func.GetMinimalDistance()<=100*tolapp3d); |
dde68833 |
375 | Standard_Boolean ok = Standard_False; |
7fd59977 |
376 | if(!Forward){ |
377 | Intf = 0; |
378 | const ChFiDS_CommonPoint& cpf1 = Data->VertexFirstOnS1(); |
379 | if(cpf1.IsOnArc()){ |
380 | TopoDS_Face F1 = S1->ChangeSurface().Face(); |
381 | TopoDS_Face bid; |
dde68833 |
382 | Intf = !SearchFace(Spine,cpf1,F1,bid); |
383 | ok = Intf != 0; |
7fd59977 |
384 | } |
385 | const ChFiDS_CommonPoint& cpf2 = Data->VertexFirstOnS2(); |
386 | if(cpf2.IsOnArc() && !ok){ |
387 | TopoDS_Face F2 = S2->ChangeSurface().Face(); |
388 | TopoDS_Face bid; |
389 | Intf = !SearchFace(Spine,cpf2,F2,bid); |
390 | } |
391 | } |
392 | Intl = 0; |
dde68833 |
393 | ok = Standard_False; |
7fd59977 |
394 | const ChFiDS_CommonPoint& cpl1 = Data->VertexLastOnS1(); |
395 | if(cpl1.IsOnArc()){ |
396 | TopoDS_Face F1 = S1->ChangeSurface().Face(); |
397 | TopoDS_Face bid; |
dde68833 |
398 | Intl = !SearchFace(Spine,cpl1,F1,bid); |
399 | ok = Intl != 0; |
7fd59977 |
400 | } |
401 | const ChFiDS_CommonPoint& cpl2 = Data->VertexLastOnS2(); |
402 | if(cpl2.IsOnArc() && !ok){ |
403 | TopoDS_Face F2 = S2->ChangeSurface().Face(); |
404 | TopoDS_Face bid; |
405 | Intl = !SearchFace(Spine,cpl2,F2,bid); |
406 | } |
407 | Data->FirstSpineParam(First); |
408 | Data->LastSpineParam (Last); |
409 | |
410 | // if (maybesingular) SplitSurf(SeqData, lin); |
411 | // Necessite de trimer resultats : A faire |
412 | return Standard_True; |
413 | } |
414 | |
dde68833 |
415 | void FilletSurf_InternalBuilder::PerformSurf (ChFiDS_SequenceOfSurfData& , const Handle(ChFiDS_HElSpine)& , const Handle(ChFiDS_Spine)& , const Standard_Integer , const Handle(BRepAdaptor_HSurface)& , const Handle(Adaptor3d_TopolTool)& , const Handle(BRepAdaptor_HCurve2d)& , const Handle(BRepAdaptor_HSurface)& , const Handle(BRepAdaptor_HCurve2d)& , Standard_Boolean& , const Handle(BRepAdaptor_HSurface)& , const Handle(Adaptor3d_TopolTool)& , const TopAbs_Orientation , const Standard_Real , const Standard_Real , const Standard_Real , Standard_Real& , Standard_Real& , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const math_Vector& ) |
7fd59977 |
416 | { |
9775fa61 |
417 | throw Standard_DomainError("BlendFunc_CSConstRad::Section : Not implemented"); |
7fd59977 |
418 | } |
419 | |
dde68833 |
420 | void FilletSurf_InternalBuilder::PerformSurf (ChFiDS_SequenceOfSurfData& , const Handle(ChFiDS_HElSpine)& , const Handle(ChFiDS_Spine)& , const Standard_Integer , const Handle(BRepAdaptor_HSurface)& , const Handle(Adaptor3d_TopolTool)& , const TopAbs_Orientation , const Handle(BRepAdaptor_HSurface)& , const Handle(Adaptor3d_TopolTool)& , const Handle(BRepAdaptor_HCurve2d)& , const Handle(BRepAdaptor_HSurface)& , const Handle(BRepAdaptor_HCurve2d)& , Standard_Boolean& , const Standard_Real , const Standard_Real , const Standard_Real , Standard_Real& , Standard_Real& , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const math_Vector& ) |
7fd59977 |
421 | { |
9775fa61 |
422 | throw Standard_DomainError("BlendFunc_CSConstRad::Section : Not implemented"); |
7fd59977 |
423 | } |
424 | |
dde68833 |
425 | void FilletSurf_InternalBuilder::PerformSurf (ChFiDS_SequenceOfSurfData& , const Handle(ChFiDS_HElSpine)& , const Handle(ChFiDS_Spine)& , const Standard_Integer , const Handle(BRepAdaptor_HSurface)& , const Handle(Adaptor3d_TopolTool)& , const Handle(BRepAdaptor_HCurve2d)& , const Handle(BRepAdaptor_HSurface)& , const Handle(BRepAdaptor_HCurve2d)& , Standard_Boolean& , const TopAbs_Orientation , const Handle(BRepAdaptor_HSurface)& , const Handle(Adaptor3d_TopolTool)& , const Handle(BRepAdaptor_HCurve2d)& , const Handle(BRepAdaptor_HSurface)& , const Handle(BRepAdaptor_HCurve2d)& , Standard_Boolean& , const TopAbs_Orientation , const Standard_Real , const Standard_Real , const Standard_Real , Standard_Real& , Standard_Real& , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const Standard_Boolean , const math_Vector& ) |
7fd59977 |
426 | { |
9775fa61 |
427 | throw Standard_DomainError("BlendFunc_CSConstRad::Section : Not implemented"); |
7fd59977 |
428 | } |
429 | |
430 | Standard_Boolean FilletSurf_InternalBuilder::Done() const |
431 | { |
432 | return done; |
433 | } |
434 | //======================================================================= |
435 | //function : NbSurface |
436 | //purpose : gives the number of NUBS surfaces of the Fillet |
437 | //======================================================================= |
438 | |
439 | Standard_Integer FilletSurf_InternalBuilder::NbSurface() const |
440 | { |
441 | return myListStripe.First()->SetOfSurfData()->Length(); |
442 | } |
443 | |
444 | //======================================================================= |
445 | //function : SurfaceFillet |
446 | //purpose : gives the NUBS surface of index Index |
447 | //======================================================================= |
448 | |
449 | const Handle(Geom_Surface)& FilletSurf_InternalBuilder::SurfaceFillet(const Standard_Integer Index) const |
450 | { |
451 | Standard_Integer isurf = myListStripe.First()->SetOfSurfData()->Value(Index)->Surf(); |
452 | |
453 | return myDS->Surface(isurf).Surface(); |
454 | } |
455 | |
456 | //======================================================================= |
457 | //function : TolApp3d |
458 | //purpose : gives the 3d tolerance reached during approximation |
459 | //======================================================================= |
460 | |
461 | Standard_Real FilletSurf_InternalBuilder::TolApp3d(const Standard_Integer Index) const |
462 | { |
463 | Standard_Integer isurf = myListStripe.First()->SetOfSurfData()->Value(Index)->Surf(); |
464 | |
465 | return myDS->Surface(isurf).Tolerance(); |
466 | } |
467 | |
468 | //======================================================================= |
469 | //function : SupportFace1 |
470 | //purpose : gives the first support face relative to SurfaceFillet(Index) |
471 | //======================================================================= |
472 | const TopoDS_Face& FilletSurf_InternalBuilder::SupportFace1(const Standard_Integer Index) const |
473 | { |
474 | Standard_Integer isurf = myListStripe.First()->SetOfSurfData()->Value(Index)->IndexOfS1(); |
475 | |
476 | return TopoDS::Face(myDS->Shape(isurf)); |
477 | } |
478 | //======================================================================= |
479 | //function : SupportFace2 |
480 | //purpose : gives the second support face relative to SurfaceFillet(Index) |
481 | //======================================================================= |
482 | const TopoDS_Face& FilletSurf_InternalBuilder::SupportFace2(const Standard_Integer Index) const |
483 | { |
484 | Standard_Integer isurf = myListStripe.First()->SetOfSurfData()->Value(Index)->IndexOfS2(); |
485 | |
486 | return TopoDS::Face(myDS->Shape(isurf)); |
487 | } |
488 | //=============================================================================== |
489 | //function : CurveOnSup1 |
490 | //purpose : gives the 3d curve of SurfaceFillet(Index) on SupportFace1(Index) |
491 | //=============================================================================== |
492 | |
493 | const Handle(Geom_Curve)& FilletSurf_InternalBuilder::CurveOnFace1(const Standard_Integer Index) const |
494 | { |
495 | Standard_Integer icurv = myListStripe.First()->SetOfSurfData()->Value(Index)-> |
496 | InterferenceOnS1().LineIndex(); |
497 | return myDS->Curve(icurv).Curve(); |
498 | } |
499 | |
500 | //======================================================================= |
501 | //function : CurveOnSup2 |
502 | //purpose : gives the 3d curve of SurfaceFillet(Index) on SupportFace2(Index |
503 | //======================================================================= |
504 | |
505 | const Handle(Geom_Curve)& FilletSurf_InternalBuilder::CurveOnFace2(const Standard_Integer Index) const |
506 | { |
507 | Standard_Integer icurv=myListStripe.First()->SetOfSurfData()->Value(Index)-> |
508 | InterferenceOnS2().LineIndex(); |
509 | return myDS->Curve(icurv).Curve(); |
510 | } |
511 | //======================================================================= |
512 | //function : PCurveOnFace1 |
513 | //purpose : gives the PCurve associated to CurvOnSup1(Index) on the support face |
514 | //======================================================================= |
515 | const Handle(Geom2d_Curve)& FilletSurf_InternalBuilder::PCurveOnFace1(const Standard_Integer Index) const |
516 | { |
517 | return myListStripe.First()->SetOfSurfData()->Value(Index)-> |
518 | InterferenceOnS1().PCurveOnFace(); |
519 | |
520 | } |
521 | |
522 | //======================================================================= |
523 | //function : PCurveOnFillet1 |
524 | //purpose : gives the PCurve associated to CurveOnFace1(Index) on the Fillet |
525 | //======================================================================= |
526 | |
527 | const Handle(Geom2d_Curve)& FilletSurf_InternalBuilder::PCurve1OnFillet(const Standard_Integer Index) const |
528 | {return myListStripe.First()->SetOfSurfData()->Value(Index)-> |
529 | InterferenceOnS1().PCurveOnSurf(); |
530 | |
531 | } |
532 | |
533 | //======================================================================= |
534 | //function : PCurveOnFace2 |
535 | //purpose : gives the PCurve associated to CurvOnSup2(Index) on the support face |
536 | //======================================================================= |
537 | const Handle(Geom2d_Curve)& FilletSurf_InternalBuilder::PCurveOnFace2(const Standard_Integer Index) const |
538 | { |
539 | return myListStripe.First()->SetOfSurfData()->Value(Index)-> |
540 | InterferenceOnS2().PCurveOnFace(); |
541 | } |
542 | |
543 | //======================================================================= |
544 | //function : PCurveOnFillet2 |
545 | //purpose : gives the PCurve associated to CurveOnFace2(Index) on the Fillet |
546 | //======================================================================= |
547 | const Handle(Geom2d_Curve)& FilletSurf_InternalBuilder::PCurve2OnFillet(const Standard_Integer Index) const |
548 | {return myListStripe.First()->SetOfSurfData()->Value(Index)-> |
549 | InterferenceOnS2().PCurveOnSurf(); |
550 | |
551 | } |
552 | |
553 | //======================================================================= |
554 | //function : FirstParameter |
555 | //purpose : gives the parameter of the fillet on the first edge |
556 | //======================================================================= |
557 | |
558 | Standard_Real FilletSurf_InternalBuilder::FirstParameter() const |
559 | { |
560 | const Handle(ChFiDS_Stripe)& st = myListStripe.First(); |
561 | const Handle(ChFiDS_Spine)& sp = st->Spine(); |
562 | const Handle(ChFiDS_SurfData)& sd = st->SetOfSurfData()->Value(1); |
563 | Standard_Real p = sd->FirstSpineParam(); |
564 | Standard_Integer ind = 1; |
565 | if(sp->IsPeriodic()) ind = sp->Index(p); |
566 | Standard_Real ep; |
567 | if(ComputeEdgeParameter(sp,ind,p,ep,tolesp)) return ep; |
568 | return 0.0; |
569 | } |
570 | //======================================================================= |
571 | //function : LastParameter |
572 | //purpose : gives the parameter of the fillet on the last edge |
573 | //======================================================================= |
574 | Standard_Real FilletSurf_InternalBuilder::LastParameter() const |
575 | { |
576 | const Handle(ChFiDS_Stripe)& st = myListStripe.First(); |
577 | const Handle(ChFiDS_Spine)& sp = st->Spine(); |
578 | const Handle(ChFiDS_SurfData)& sd = st->SetOfSurfData()->Value(NbSurface()); |
579 | Standard_Real p = sd->LastSpineParam(); |
580 | Standard_Integer ind = sp->NbEdges(); |
581 | if(sp->IsPeriodic()) ind = sp->Index(p); |
582 | Standard_Real ep; |
583 | if(ComputeEdgeParameter(sp,ind,p,ep,tolesp)) return ep; |
584 | return 0.0; |
585 | } |
586 | |
587 | //======================================================================= |
588 | //function : StatusStartSection |
589 | //purpose : returns: |
590 | // twoExtremityonEdge: each extremity of start section of the Fillet is |
591 | // on the edge of the corresponding support face. |
592 | // OneExtremityOnEdge: only one of the extremities of start section of the Fillet |
593 | // is on the edge of the corresponding support face. |
594 | // NoExtremityOnEdge: any extremity of start section of the fillet is on |
595 | // the edge of the corresponding support face. |
596 | //======================================================================= |
597 | |
598 | |
599 | FilletSurf_StatusType FilletSurf_InternalBuilder::StartSectionStatus() const |
600 | { |
601 | |
602 | Standard_Boolean isonedge1 = myListStripe.First()->SetOfSurfData()->Value(1)-> |
603 | VertexFirstOnS1().IsOnArc(); |
604 | Standard_Boolean isonedge2= myListStripe.First()->SetOfSurfData()->Value(1)-> |
605 | VertexFirstOnS2().IsOnArc();; |
606 | |
607 | if (isonedge1 && isonedge2) |
608 | {return FilletSurf_TwoExtremityOnEdge;} |
609 | else if ((!isonedge1)&& (!isonedge2)) |
610 | {return FilletSurf_NoExtremityOnEdge ;} |
611 | else |
612 | {return FilletSurf_OneExtremityOnEdge;} |
613 | } |
614 | //======================================================================= |
615 | //function : StatusEndSection() |
616 | //purpose : returns: |
617 | // twoExtremityonEdge: each extremity of end section of the Fillet is |
618 | // on the edge of the corresponding support face. |
619 | // OneExtremityOnEdge: only one of the extremities of end section of the Fillet |
620 | // is on the edge of the corresponding support face. |
621 | // NoExtremityOnEdge: any extremity of end section of the fillet is on |
622 | // the edge of the corresponding support face. |
623 | //======================================================================= |
624 | FilletSurf_StatusType FilletSurf_InternalBuilder::EndSectionStatus() const |
625 | { |
626 | Standard_Boolean isonedge1 = myListStripe.First()->SetOfSurfData()->Value(NbSurface())-> |
627 | VertexLastOnS1().IsOnArc(); |
628 | Standard_Boolean isonedge2= myListStripe.First()->SetOfSurfData()->Value(NbSurface())-> |
629 | VertexLastOnS2().IsOnArc(); |
630 | |
631 | if (isonedge1 && isonedge2) |
632 | { return FilletSurf_TwoExtremityOnEdge;} |
633 | else if ((!isonedge1)&& (!isonedge2)) |
634 | { return FilletSurf_NoExtremityOnEdge;} |
635 | else |
636 | { return FilletSurf_OneExtremityOnEdge;} |
637 | } |
638 | |
639 | |
640 | //======================================================================= |
641 | //function : Simulate |
642 | //purpose : computes only the sections used in the computation of the fillet |
643 | //======================================================================= |
644 | void FilletSurf_InternalBuilder::Simulate() |
645 | { |
646 | //ChFi3d_FilBuilder::Simulate(1); |
647 | Handle(ChFiDS_Stripe) Stripe = myListStripe.First(); |
648 | Handle(ChFiDS_HData)& HData = Stripe->ChangeSetOfSurfData(); |
649 | HData = new ChFiDS_HData(); |
650 | Handle(ChFiDS_Spine)& Spine = Stripe->ChangeSpine(); |
651 | TopAbs_Orientation RefOr1,RefOr2; |
652 | Standard_Integer RefChoix; |
653 | StripeOrientations(Spine,RefOr1,RefOr2,RefChoix); |
654 | Stripe->OrientationOnFace1(RefOr1); |
655 | Stripe->OrientationOnFace2(RefOr2); |
656 | Stripe->Choix(RefChoix); |
657 | PerformSetOfKGen(Stripe,1); |
658 | } |
659 | |
660 | |
661 | //======================================================================= |
662 | //function : NbSection |
663 | //purpose : gives the number of sections relative to SurfaceFillet(IndexSurf) |
664 | //======================================================================= |
665 | Standard_Integer FilletSurf_InternalBuilder::NbSection(const Standard_Integer IndexSurf) const |
666 | { |
667 | return Sect(1,IndexSurf)->Length(); |
668 | } |
669 | |
670 | //======================================================================= |
671 | //function : Section |
672 | //purpose : gives the arc of circle corresponding to section number |
673 | // IndexSec of SurfaceFillet(IndexSurf) (The basis curve of the |
674 | // trimmed curve is a Geom_Circle) |
675 | //======================================================================= |
676 | void FilletSurf_InternalBuilder::Section(const Standard_Integer IndexSurf, const Standard_Integer IndexSec, Handle(Geom_TrimmedCurve)& Circ) const |
677 | { |
678 | gp_Circ c; |
679 | Standard_Real deb,fin; |
680 | Sect(1,IndexSurf)->Value(IndexSec).Get(c,deb,fin); |
681 | Handle(Geom_Circle) Gc = new Geom_Circle(c); |
682 | Circ= new Geom_TrimmedCurve(Gc,deb,fin); |
683 | } |
684 | |
685 | |
686 | |
687 | |
688 | |
689 | |
690 | |
691 | |
692 | |
693 | |
694 | |
695 | |
696 | |
697 | |
698 | |