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