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