0027772: Foundation Classes - define Standard_Boolean using C++ type "bool" instead...
[occt.git] / src / ChFi3d / ChFi3d_ChBuilder.cxx
CommitLineData
b311480e 1// Created on: 1995-04-26
2// Created by: Flore Lantheaume
3// Copyright (c) 1995-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
7fd59977 17
42cf5bc1 18#include <Adaptor3d_TopolTool.hxx>
7fd59977 19#include <Blend_Point.hxx>
42cf5bc1 20#include <BlendFunc_SectionShape.hxx>
21#include <BRepAdaptor_Curve2d.hxx>
22#include <BRepAdaptor_HCurve2d.hxx>
23#include <BRepAdaptor_HSurface.hxx>
24#include <BRepAdaptor_Surface.hxx>
7fd59977 25#include <BRepBlend_Chamfer.hxx>
26#include <BRepBlend_ChamfInv.hxx>
27#include <BRepBlend_ChAsym.hxx>
28#include <BRepBlend_ChAsymInv.hxx>
42cf5bc1 29#include <BRepBlend_Line.hxx>
7fd59977 30#include <BRepBlend_Walking.hxx>
7fd59977 31#include <BRepTools.hxx>
42cf5bc1 32#include <ChFi3d.hxx>
33#include <ChFi3d_Builder_0.hxx>
34#include <ChFi3d_ChBuilder.hxx>
35#include <ChFiDS_ChamfSpine.hxx>
36#include <ChFiDS_CircSection.hxx>
37#include <ChFiDS_HData.hxx>
38#include <ChFiDS_HElSpine.hxx>
39#include <ChFiDS_ListIteratorOfListOfStripe.hxx>
40#include <ChFiDS_ListIteratorOfRegularities.hxx>
41#include <ChFiDS_ListOfStripe.hxx>
42#include <ChFiDS_Regul.hxx>
43#include <ChFiDS_SecHArray1.hxx>
44#include <ChFiDS_Spine.hxx>
45#include <ChFiDS_Stripe.hxx>
46#include <ChFiDS_SurfData.hxx>
47#include <ElSLib.hxx>
48#include <Extrema_GenLocateExtPS.hxx>
49#include <GeomAdaptor_HCurve.hxx>
50#include <Standard_ConstructionError.hxx>
7fd59977 51#include <Standard_DomainError.hxx>
42cf5bc1 52#include <Standard_NotImplemented.hxx>
53#include <TopAbs.hxx>
54#include <TopoDS_Edge.hxx>
55#include <TopoDS_Face.hxx>
56#include <TopoDS_Shape.hxx>
57#include <TopoDS_Vertex.hxx>
58#include <TopOpeBRepBuild_HBuilder.hxx>
59#include <TopOpeBRepDS_HDataStructure.hxx>
60#include <TopTools_ListIteratorOfListOfShape.hxx>
7fd59977 61
0797d9d3 62#ifdef OCCT_DEBUG
7fd59977 63extern Standard_Boolean ChFi3d_GettraceCHRON();
64#endif
65
66//=======================================================================
67//function : SearchCommonFaces
68//purpose : search the 2 common faces <F1> and <F2> of the edge <E>
69// uses the EFMap and take the 2 first good faces
70//=======================================================================
71
72void SearchCommonFaces(const ChFiDS_Map& EFMap,
73 const TopoDS_Edge& E,
74 TopoDS_Face& F1,
75 TopoDS_Face& F2)
76{
77 TopoDS_Face Fc;
78 TopTools_ListIteratorOfListOfShape It;
79
80 F1.Nullify();
81 F2.Nullify();
82 for ( It.Initialize(EFMap(E)); It.More(); It.Next() ) {
83 Fc = TopoDS::Face(It.Value());
84 if ( F1.IsNull() )
85 F1 = Fc;
86 else if ( !Fc.IsSame(F1) ) {
87 F2 = Fc;
88 break;
89 }
90 }
91
92 if (!F1.IsNull() && F2.IsNull() && BRepTools::IsReallyClosed( E, F1 ))
93 F2 = F1;
94}
95
96//=======================================================================
97//function : ExtentSpinesOnCommonFace
81bba717 98//purpose : Extend spines of two chamfers by distance dis1,dis2
99// on their common face
100// Two guide lines Spine1 and Spine2 cross in V
101// isfirst(i) = False if Spine(i) is oriented to V (i = 1,2)
7fd59977 102//=======================================================================
103
104void ExtentSpineOnCommonFace(Handle(ChFiDS_Spine)& Spine1,
105 Handle(ChFiDS_Spine)& Spine2,
106 const TopoDS_Vertex& V,
107 const Standard_Real dis1,
108 const Standard_Real dis2,
109 const Standard_Boolean isfirst1,
110 const Standard_Boolean isfirst2)
111{
112 Standard_Real tolesp = 1.e-7;
113
81bba717 114 // alpha, the opening angle between two
115 // tangents of two guidelines in V is found
7fd59977 116 Standard_Real tga1,tga2;
117 Standard_Real d1plus = 0., d2plus = 0.;
118
119 gp_Pnt tmp;
120 gp_Vec tg1, tg2;
121 Spine1->D1(Spine1->Absc(V),tmp,tg1);
122 Spine2->D1(Spine2->Absc(V),tmp,tg2);
123 tg1.Normalize();
124 tg2.Normalize();
125 if (isfirst1)
126 tg1.Reverse();
127 if (isfirst2)
128 tg2.Reverse();
129
130 Standard_Real cosalpha,sinalpha;
131 cosalpha = tg1.Dot(tg2);
132 sinalpha = sqrt(1-cosalpha*cosalpha);
133
134 //a1+a2 = alpha
135 Standard_Real temp;
136 temp = cosalpha+dis2/dis1;
137 if( Abs(temp) > tolesp ){
138 tga1 = sinalpha/temp;
139 d1plus = dis1/tga1;
140 }
141 temp = cosalpha+dis1/dis2;
142 if( Abs(temp) > tolesp ){
143 tga2 = sinalpha/temp;
144 d2plus = dis2/tga2;
145 }
146
81bba717 147 //extension by the calculated distance
7fd59977 148 if (d1plus > 0.) {
149 d1plus *= 3.;
150 if (isfirst1){
151 Spine1->SetFirstParameter(-d1plus);
152 Spine1->SetFirstTgt(0.);
153 }
154 else{
155 Standard_Real param = Spine1->LastParameter(Spine1->NbEdges());
156 Spine1->SetLastParameter(d1plus+param);
157 Spine1->SetLastTgt(param);
158 }
159 }
160 if (d2plus > 0.) {
161 d2plus *= 1.5;
162 if (isfirst2){
163 Spine2->SetFirstParameter(-d2plus);
164 Spine2->SetFirstTgt(0.);
165 }
166 else{
167 Standard_Real param = Spine2->LastParameter(Spine2->NbEdges());
168 Spine2->SetLastParameter(d2plus+param);
169 Spine2->SetLastTgt(param);
170 }
171 }
172}
173
174//=======================================================================
175//function : ChFi3d_ChBuilder
176//purpose :
177//=======================================================================
178
179ChFi3d_ChBuilder::ChFi3d_ChBuilder(const TopoDS_Shape& S,
180 const Standard_Real Ta) :
181 ChFi3d_Builder(S, Ta)
182{
183}
184
185
186//=======================================================================
187//function : Add
188//purpose : create a new stripe with a spine containing the edge <E>
189// add on the spine the tangential edges to <E>
190//=======================================================================
191
192void ChFi3d_ChBuilder::Add(const TopoDS_Edge& E)
193{
194
195 if(!Contains(E) && myEFMap.Contains(E)){
196 Handle(ChFiDS_Stripe) Stripe = new ChFiDS_Stripe();
197 Handle(ChFiDS_Spine)& Sp = Stripe->ChangeSpine();
198 Sp = new ChFiDS_ChamfSpine(tolesp);
199 Handle(ChFiDS_ChamfSpine) Spine = Handle(ChFiDS_ChamfSpine)::DownCast(Sp);
200
201 TopoDS_Edge E_wnt = E;
202 E_wnt.Orientation(TopAbs_FORWARD);
203 Spine->SetEdges(E_wnt);
204 if(PerformElement(Spine)){
205 PerformExtremity(Spine);
206 Spine->Load();
207 myListStripe.Append(Stripe);
208 }
209 }
210}
211
212
213//=======================================================================
214//function : Add
215//purpose : create a new stripe with a ChamfSpine containing the edge <E>
216// with the distance <Dis> on the face <F>
217// . Add the tangential edges continuous to E in the spine
218//
219//=======================================================================
220
221void ChFi3d_ChBuilder::Add(const Standard_Real Dis,
222 const TopoDS_Edge& E,
223 const TopoDS_Face& F)
224{
225 if (!Contains(E) && myEFMap.Contains(E)) {
226
227 // Take the 2 common faces of the egde <E>
228 TopoDS_Face F1,F2;
229 SearchCommonFaces(myEFMap,E,F1,F2);
230
231 if (! F1.IsSame(F) && F2.IsSame(F) ) {
232 F2 = F1;
233 F1 = F;
234 }
235
236 if ( F1.IsSame(F)) {
237 TopoDS_Edge E_wnt = E;
238 E_wnt.Orientation(TopAbs_FORWARD);
239 BRepAdaptor_Surface Sb1,Sb2;
240 Sb1.Initialize(F1);
241 Sb2.Initialize(F2);
242 TopAbs_Orientation Or1,Or2;
243 ChFi3d::ConcaveSide(Sb1,Sb2,E_wnt,Or1,Or2);
244 Handle(ChFiDS_Stripe) Stripe = new ChFiDS_Stripe();
245 Handle(ChFiDS_Spine)& Sp = Stripe->ChangeSpine();
246 Sp = new ChFiDS_ChamfSpine(tolesp);
247 Handle(ChFiDS_ChamfSpine)
248 Spine = Handle(ChFiDS_ChamfSpine)::DownCast(Sp);
249
250 Spine->SetEdges(E_wnt);
251 if(PerformElement(Spine)){
252 Spine->Load();
253 myListStripe.Append(Stripe);
254
255 Spine->SetDist(Dis);
256
257 PerformExtremity(Spine);
258 }
259 }
260 }
261}
262
263
264//=======================================================================
265//function : SetDist
266//purpose : set the distances <Dis>of the contour of
267// index IC
268//=======================================================================
269
270void ChFi3d_ChBuilder::SetDist(const Standard_Real Dis,
271 const Standard_Integer IC,
272 const TopoDS_Face& F)
273{
274
275 if(IC <= NbElements()) {
276 Handle(ChFiDS_ChamfSpine) csp = Handle(ChFiDS_ChamfSpine)::DownCast(Value(IC));
277
278 // Search the first edge which has a common face equal to F
279 TopoDS_Face F1,F2,FirstF1,FirstF2;
280 //TopAbs_Orientation Or1,Or2;
281 //Standard_Integer Choix, ChoixConge;
282 BRepAdaptor_Surface Sb1,Sb2;
283 Standard_Integer i = 1;
284 Standard_Boolean Found = Standard_False;
285 while ( (i <= csp->NbEdges()) && (!Found) ) {
286 SearchCommonFaces(myEFMap,csp->Edges(i),F1,F2);
287 if ( i == 1) {
288 FirstF1 = F1;
289 FirstF2 = F2;
290 }
291 Found = ( F1.IsSame(F) || F2.IsSame(F) );
292 i++;
293 }
294
295 if (Found) {
296 if ( F2.IsSame(F) ) {
297 F2 = F1;
298 F1 = F;
299 }
300 csp->SetDist(Dis);
301
302 }
303 else
81bba717 304 Standard_DomainError::Raise("the face is not common to any of edges of the contour");
7fd59977 305
306 }
307}
308
309
310//=======================================================================
311//function : GetDist
312//purpose :
313//=======================================================================
314
315void ChFi3d_ChBuilder::GetDist(const Standard_Integer IC,
316 Standard_Real& Dis) const
317{
318 Handle(ChFiDS_ChamfSpine) chsp = Handle(ChFiDS_ChamfSpine)::DownCast(Value(IC));
319 chsp->GetDist(Dis);
320
321}
322
323
324//=======================================================================
325//function : Add
326//purpose : create a new stripe with a ChAsymSpine containing the edge <E>
327// with the distance <Dis> and the angle Angle on the face <F>
328// . Add the tangential edges continuous to E in the spine
329//
330//=======================================================================
331
332void ChFi3d_ChBuilder::Add(const Standard_Real Dis1,
333 const Standard_Real Dis2,
334 const TopoDS_Edge& E,
335 const TopoDS_Face& F)
336{
337 if (!Contains(E) && myEFMap.Contains(E)) {
338
339 // Take the 2 common faces of the egde <E>
340 TopoDS_Face F1,F2;
341 SearchCommonFaces(myEFMap,E,F1,F2);
342
343 if (! F1.IsSame(F) && F2.IsSame(F) ) {
344 F2 = F1;
345 F1 = F;
346 }
347
348 if ( F1.IsSame(F)) {
349 TopoDS_Edge E_wnt = E;
350 E_wnt.Orientation(TopAbs_FORWARD);
351 BRepAdaptor_Surface Sb1,Sb2;
352 Sb1.Initialize(F1);
353 Sb2.Initialize(F2);
354 TopAbs_Orientation Or1,Or2;
355 Standard_Integer Choix = ChFi3d::ConcaveSide(Sb1,Sb2,E_wnt,Or1,Or2);
356
357 Handle(ChFiDS_Stripe) Stripe = new ChFiDS_Stripe();
358 Handle(ChFiDS_Spine)& Sp = Stripe->ChangeSpine();
359 Sp = new ChFiDS_ChamfSpine(tolesp);
360 Handle(ChFiDS_ChamfSpine)
361 Spine = Handle(ChFiDS_ChamfSpine)::DownCast(Sp);
362
363 Spine->SetEdges(E_wnt);
364 if(PerformElement(Spine)){
365 Spine->Load();
366 myListStripe.Append(Stripe);
367
368 Standard_Integer ChoixConge;
369 SearchCommonFaces(myEFMap,Spine->Edges(1),F1,F2);
370 Sb1.Initialize(F1);
371 Sb2.Initialize(F2);
372 ChoixConge = ChFi3d::ConcaveSide(Sb1,Sb2,
373 Spine->Edges(1),
374 Or1,Or2);
375
376
377 // compare the 2 computed choices to know how to set the
378 // distances of the Spine according to the choice done
379 // on the added edge <e>
380 if ( ChoixConge%2 != Choix%2 )
381 Spine->SetDists(Dis2, Dis1);
382 else Spine->SetDists(Dis1, Dis2);
383
384 PerformExtremity(Spine);
385 }
386 }
387 }
388}
389
390
391//=======================================================================
392//function : SetDists
393//purpose : set the distances <Dis1> and <Dis2> of the contour of
394// index IC
395//=======================================================================
396
397void ChFi3d_ChBuilder::SetDists(const Standard_Real Dis1,
398 const Standard_Real Dis2,
399 const Standard_Integer IC,
400 const TopoDS_Face& F)
401{
402
403 if(IC <= NbElements()) {
404 Handle(ChFiDS_ChamfSpine) csp = Handle(ChFiDS_ChamfSpine)::DownCast(Value(IC));
405
406 // Search the first edge which has a common face equal to F
407 TopoDS_Face F1,F2,FirstF1,FirstF2;
408 TopAbs_Orientation Or1,Or2;
409 Standard_Integer Choix, ChoixConge;
410 BRepAdaptor_Surface Sb1,Sb2;
411 Standard_Integer i = 1;
412 Standard_Boolean Found = Standard_False;
413 while ( (i <= csp->NbEdges()) && (!Found) ) {
414 SearchCommonFaces(myEFMap,csp->Edges(i),F1,F2);
415 if ( i == 1) {
416 FirstF1 = F1;
417 FirstF2 = F2;
418 }
419 Found = ( F1.IsSame(F) || F2.IsSame(F) );
420 i++;
421 }
422
423 if (Found) {
424 if ( F2.IsSame(F) ) {
425 F2 = F1;
426 F1 = F;
427 }
428 Sb1.Initialize(F1);
429 Sb2.Initialize(F2);
430 Choix = ChFi3d::ConcaveSide(Sb1,Sb2,
431 csp->Edges(i-1),
432 Or1,Or2);
433 Sb1.Initialize(FirstF1);
434 Sb2.Initialize(FirstF2);
435 ChoixConge = ChFi3d::ConcaveSide(Sb1,Sb2,
436 csp->Edges(1),
437 Or1,Or2);
438 if ( ChoixConge%2 != Choix%2 )
439 csp->SetDists(Dis2,Dis1);
440 else csp->SetDists(Dis1,Dis2);
441 }
442 else
81bba717 443 Standard_DomainError::Raise("the face is not common to any of edges of the contour");
7fd59977 444
445 }
446}
447
448
449//=======================================================================
450//function : Dists
451//purpose :
452//=======================================================================
453
454void ChFi3d_ChBuilder::Dists(const Standard_Integer IC,
455 Standard_Real& dis1,
456 Standard_Real& dis2) const
457{
458 Handle(ChFiDS_ChamfSpine) chsp = Handle(ChFiDS_ChamfSpine)::DownCast(Value(IC));
459 Standard_Real temp1, temp2;
460 chsp->Dists(temp1,temp2);
461 dis1 = temp1;
462 dis2 = temp2;
463}
464
465
466//=======================================================================
467//function : Add
468//purpose : create a new stripe with a ChAsymSpine containing the edge <E>
469// with the distance <Dis> and the angle Angle on the face <F>
470// . Add the tangential edges continuous to E in the spine
471//
472//=======================================================================
473
474void ChFi3d_ChBuilder::AddDA(const Standard_Real Dis1,
475 const Standard_Real Angle,
476 const TopoDS_Edge& E,
477 const TopoDS_Face& F)
478{
479 if (!Contains(E) && myEFMap.Contains(E)) {
480
481 // Take the 2 common faces of the egde <E>
482 TopoDS_Face F1,F2;
483 SearchCommonFaces(myEFMap,E,F1,F2);
484
485 if (! F1.IsSame(F) && F2.IsSame(F) ) {
486 F2 = F1;
487 F1 = F;
488 }
489
490 if ( F1.IsSame(F)) {
491 TopoDS_Edge E_wnt = E;
492 E_wnt.Orientation(TopAbs_FORWARD);
493 BRepAdaptor_Surface Sb1,Sb2;
494 Sb1.Initialize(F1);
495 Sb2.Initialize(F2);
496 TopAbs_Orientation Or1,Or2;
497 Standard_Integer Choix = ChFi3d::ConcaveSide(Sb1,Sb2,E_wnt,Or1,Or2);
498
499 Handle(ChFiDS_Stripe) Stripe = new ChFiDS_Stripe();
500 Handle(ChFiDS_Spine)& Sp = Stripe->ChangeSpine();
501 Sp = new ChFiDS_ChamfSpine(tolesp);
502 Handle(ChFiDS_ChamfSpine)
503 Spine = Handle(ChFiDS_ChamfSpine)::DownCast(Sp);
504
505 Spine->SetEdges(E_wnt);
506 if(PerformElement(Spine)){
507 Spine->Load();
508 myListStripe.Append(Stripe);
509
510 Standard_Integer ChoixConge;
511 SearchCommonFaces(myEFMap,Spine->Edges(1),F1,F2);
512 Sb1.Initialize(F1);
513 Sb2.Initialize(F2);
514 ChoixConge = ChFi3d::ConcaveSide(Sb1,Sb2,
515 Spine->Edges(1),
516 Or1,Or2);
517
518 // compare the 2 computed choices to know how to set the
519 // distances of the Spine according to the choice done
520 // on the added edge <e>
521 if ( ChoixConge%2 != Choix%2 ) {
522 Spine->SetDistAngle(Dis1, Angle, Standard_False);
523 }
524 else {
525 Spine->SetDistAngle(Dis1, Angle, Standard_True);
526 }
527
528 PerformExtremity(Spine);
529 }
530 }
531 }
532}
533
534
535//=======================================================================
536//function : SetDistAngle
537//purpose : set the distances <Dis> and <Angle> of the contour of
538// index IC
539//=======================================================================
540
541void ChFi3d_ChBuilder::SetDistAngle(const Standard_Real Dis,
542 const Standard_Real Angle,
543 const Standard_Integer IC,
544 const TopoDS_Face& F)
545{
546
547 if(IC <= NbElements()) {
548 Handle(ChFiDS_ChamfSpine) csp = Handle(ChFiDS_ChamfSpine)::DownCast(Value(IC));
549
550 // Search the first edge which has a common face equal to F
551 TopoDS_Face F1,F2,FirstF1,FirstF2;
552 TopAbs_Orientation Or1,Or2;
553 Standard_Integer Choix, ChoixConge;
554 BRepAdaptor_Surface Sb1,Sb2;
555 Standard_Integer i = 1;
556 Standard_Boolean Found = Standard_False;
557// Standard_Boolean DisOnF1 = Standard_True;
558
559 while ( (i <= csp->NbEdges()) && (!Found) ) {
560 SearchCommonFaces(myEFMap,csp->Edges(i),F1,F2);
561 if ( i == 1) {
562 FirstF1 = F1;
563 FirstF2 = F2;
564 }
565 Found = ( F1.IsSame(F) || F2.IsSame(F) );
566 i++;
567 }
568
569 if (Found) {
570 if ( F2.IsSame(F) ) {
571 F2 = F1;
572 F1 = F;
573 }
574 Sb1.Initialize(F1);
575 Sb2.Initialize(F2);
576 Choix = ChFi3d::ConcaveSide(Sb1,Sb2,
577 csp->Edges(i-1),
578 Or1,Or2);
579 Sb1.Initialize(FirstF1);
580 Sb2.Initialize(FirstF2);
581 ChoixConge = ChFi3d::ConcaveSide(Sb1,Sb2,
582 csp->Edges(1),
583 Or1,Or2);
584 if ( ChoixConge%2 != Choix%2 ) {
585 csp->SetDistAngle(Dis, Angle, Standard_False);
586 }
587 else {
588 csp->SetDistAngle(Dis, Angle, Standard_True);
589 }
590 }
591 else
81bba717 592 Standard_DomainError::Raise("the face is not common to any edges of the contour");
7fd59977 593
594 }
595}
596
597
598//=======================================================================
599//function : GetDistAngle
600//purpose :
601//=======================================================================
602
603void ChFi3d_ChBuilder::GetDistAngle(const Standard_Integer IC,
604 Standard_Real& Dis,
605 Standard_Real& Angle,
606 Standard_Boolean& DisOnFace1) const
607{
608 Handle(ChFiDS_ChamfSpine) chsp = Handle(ChFiDS_ChamfSpine)::DownCast(Value(IC));
609
610 chsp->GetDistAngle(Dis, Angle, DisOnFace1);
611}
612
613//=======================================================================
614//function : IsChamfer
615//purpose :
616//=======================================================================
617ChFiDS_ChamfMethod ChFi3d_ChBuilder::IsChamfer(const Standard_Integer IC) const
618{
619 Handle(ChFiDS_ChamfSpine) chsp = Handle(ChFiDS_ChamfSpine)::DownCast(Value(IC));
620
621 ChFiDS_ChamfMethod ret = chsp->IsChamfer();
622
623 return ret;
624
625}
626
627//=======================================================================
628//function : ResetContour
629//purpose :
630//=======================================================================
631
632void ChFi3d_ChBuilder::ResetContour(const Standard_Integer IC)
633{
634 if(IC <= NbElements()) {
635 Handle(ChFiDS_ChamfSpine) chsp = Handle(ChFiDS_ChamfSpine)::DownCast(Value(IC));
636 chsp->Reset(Standard_True);
637 }
638}
639
640//--------------------------------AJOUT----------------------------------
641//=======================================================================
642//function : Simulate
643//purpose :
644//=======================================================================
645
646void ChFi3d_ChBuilder::Simulate (const Standard_Integer IC)
647{
0797d9d3 648#ifdef OCCT_DEBUG
7fd59977 649 if(ChFi3d_GettraceCHRON()){
650 simul.Reset();elspine.Reset();chemine.Reset();
651 simul.Start();
652 }
653#endif
654 ChFiDS_ListIteratorOfListOfStripe itel;
655 Standard_Integer i = 1;
656 for (itel.Initialize(myListStripe);itel.More(); itel.Next(), i++) {
657 if(i == IC){
658 PerformSetOfSurf(itel.Value(), Standard_True);
659 break;
660 }
661 }
0797d9d3 662#ifdef OCCT_DEBUG
7fd59977 663 if(ChFi3d_GettraceCHRON()){
664 simul.Stop();
81bba717 665 cout<<"Total simulation time : ";
7fd59977 666 simul.Show();
81bba717 667 cout<<"Spine construction time : ";
7fd59977 668 elspine.Show();
81bba717 669 cout<<"and progression time : ";
7fd59977 670 chemine.Show();
671 }
672#endif
673}
674
675//---------------------------AJOUT---------------------------------------
676//=======================================================================
677//function : NbSurf
678//purpose :
679//=======================================================================
680
681Standard_Integer ChFi3d_ChBuilder::NbSurf (const Standard_Integer IC) const
682{
683 ChFiDS_ListIteratorOfListOfStripe itel;
684 Standard_Integer i = 1;
685 for (itel.Initialize(myListStripe);itel.More(); itel.Next(), i++) {
686 if(i == IC){
687 return itel.Value()->SetOfSurfData()->Length();
688 }
689 }
690 return 0;
691}
692
693
694//--------------------------AJOUT---------------------------------------
695//=======================================================================
696//function : Sect
697//purpose :
698//=======================================================================
699
700Handle(ChFiDS_SecHArray1) ChFi3d_ChBuilder::Sect (const Standard_Integer IC,
701 const Standard_Integer IS) const
702{
703 ChFiDS_ListIteratorOfListOfStripe itel;
704 Standard_Integer i = 1;
705 Handle(ChFiDS_SecHArray1) res;
706 for (itel.Initialize(myListStripe);itel.More(); itel.Next(), i++) {
707 if(i == IC){
708 Handle(MMgt_TShared) bid = itel.Value()->SetOfSurfData()->Value(IS)->Simul();
709 res = Handle(ChFiDS_SecHArray1)::DownCast(bid);
710 return res;
711 }
712 }
713 return Handle(ChFiDS_SecHArray1)();
714}
715
716
717//-------------------MODIFS---------------------------------------------
718//=======================================================================
719//function : SimulKPart
720//purpose : Stores simulating sections in simul
721//=======================================================================
722
723void ChFi3d_ChBuilder::SimulKPart(const Handle(ChFiDS_SurfData)& SD ) const
724{
725 TopOpeBRepDS_DataStructure& DStr = myDS->ChangeDS();
726 Handle(Geom_Surface) S = DStr.Surface(SD->Surf()).Surface();
727 gp_Pnt2d p1f = SD->InterferenceOnS1().PCurveOnSurf()->
728 Value(SD->InterferenceOnS1().FirstParameter());
729 gp_Pnt2d p1l = SD->InterferenceOnS1().PCurveOnSurf()->
730 Value(SD->InterferenceOnS1().LastParameter());
731 gp_Pnt2d p2f = SD->InterferenceOnS2().PCurveOnSurf()->
732 Value(SD->InterferenceOnS2().FirstParameter());
733 gp_Pnt2d p2l = SD->InterferenceOnS2().PCurveOnSurf()->
734 Value(SD->InterferenceOnS2().LastParameter());
735 GeomAdaptor_Surface AS(S);
736 Handle(ChFiDS_SecHArray1) sec;
737 Standard_Real u1,v1,u2,v2;
738 GeomAbs_SurfaceType typ = AS.GetType();
739 switch (typ){
740 case GeomAbs_Plane:
741 {
742 v1 = p1f.Y();
743 v2 = p2f.Y();
744 u1 = Max(p1f.X(),p2f.X());
745 u2 = Min(p1l.X(),p2l.X());
746 sec = new ChFiDS_SecHArray1(1,2);
747 gp_Pln Pl = AS.Plane();
748 ChFiDS_CircSection& sec1 = sec->ChangeValue(1);
749 ChFiDS_CircSection& sec2 = sec->ChangeValue(2);
750 sec1.Set(ElSLib::PlaneUIso(Pl.Position(),u1),v1,v2);
751 sec2.Set(ElSLib::PlaneUIso(Pl.Position(),u2),v1,v2);
752 }
753 break;
754 case GeomAbs_Cone:
755 {
756 v1 = p1f.Y();
757 v2 = p2f.Y();
758 u1 = Max(p1f.X(),p2f.X());
759 u2 = Min(p1l.X(),p2l.X());
760 Standard_Real ang = (u2-u1);
761 gp_Cone Co = AS.Cone();
762 Standard_Real rad = Co.RefRadius(), sang = Co.SemiAngle();
c6541a0c 763 Standard_Integer n = (Standard_Integer) (36.*ang/M_PI + 1);
7fd59977 764 if(n<2) n = 2;
765 sec = new ChFiDS_SecHArray1(1, n);
766 for (Standard_Integer i = 1; i <= n; i++) {
767 ChFiDS_CircSection& isec = sec->ChangeValue(i);
768 Standard_Real u = u1 + (i - 1)*(u2 - u1)/(n-1);
769 isec.Set(ElSLib::ConeUIso(Co.Position(), rad, sang, u), v1, v2);
770 }
771 }
772 break;
773 default:
774 break;
775 }
776 SD->SetSimul(sec);
777}
778
779//------------------------MODIFS---------------------------------------
780//=======================================================================
781//function : SimulSurf
782//purpose :
783//=======================================================================
784
785Standard_Boolean
786ChFi3d_ChBuilder::SimulSurf(Handle(ChFiDS_SurfData)& Data,
787 const Handle(ChFiDS_HElSpine)& HGuide,
788 const Handle(ChFiDS_Spine)& Spine,
789 const Standard_Integer Choix,
790 const Handle(BRepAdaptor_HSurface)& S1,
791 const Handle(Adaptor3d_TopolTool)& I1,
792 const Handle(BRepAdaptor_HSurface)& S2,
793 const Handle(Adaptor3d_TopolTool)& I2,
794 const Standard_Real TolGuide,
795 Standard_Real& First,
796 Standard_Real& Last,
797 const Standard_Boolean Inside,
798 const Standard_Boolean Appro,
799 const Standard_Boolean Forward,
800 const Standard_Boolean RecOnS1,
801 const Standard_Boolean RecOnS2,
802 const math_Vector& Soldep,
dde68833 803 Standard_Integer& intf,
804 Standard_Integer& intl)
7fd59977 805
806{
807 Handle(ChFiDS_ChamfSpine)
808 chsp = Handle(ChFiDS_ChamfSpine)::DownCast(Spine);
809
810 if (chsp.IsNull())
811 Standard_ConstructionError::Raise
81bba717 812 ("SimulSurf : this is not the spine of a chamfer");
7fd59977 813
814
815 Standard_Real radius;
81bba717 816 // Flexible parameters!
7fd59977 817 Standard_Real la = HGuide->LastParameter(), fi = HGuide->FirstParameter();
818 Standard_Real longueur = la - fi;
819 Standard_Real MaxStep = longueur * 0.05;
820 Standard_Real radiusspine = 0, locfleche, w;
821 gp_Pnt Pbid;
822 gp_Vec d1,d2;
81bba717 823 // As ElSpine is parameterized by a curvilinear quasi-abscissa,
824 // the min radius is estimated as 1/D2 max;
7fd59977 825 //for(Standard_Integer i = 0; i <= 20; i++){
826 Standard_Integer i;
827 for( i = 0; i <= 20; i++){
828 w = fi + i*MaxStep;
829 HGuide->D2(w,Pbid,d1,d2);
830 Standard_Real temp = d2.SquareMagnitude();
831 if(temp>radiusspine) radiusspine = temp;
832 }
833
834 Handle(BRepBlend_Line) lin;
835 Standard_Real PFirst = First;
836 if(intf) First = chsp->FirstParameter(1);
837 if(intl) Last = chsp->LastParameter(chsp->NbEdges());
838
839
840
841 if (chsp->IsChamfer() == ChFiDS_Sym) {
842 Standard_Real dis;
843 chsp->GetDist(dis);
844 radius = Max(dis, radiusspine);
81bba717 845 locfleche = radius*1.e-2; //graphic criterion
7fd59977 846
847 BRepBlend_Chamfer Func(S1,S2,HGuide);
848 BRepBlend_ChamfInv FInv(S1,S2,HGuide);
849 Func.Set(dis, dis, Choix);
850 FInv.Set(dis, dis, Choix);
851
852 done = SimulData(Data,HGuide,lin,S1,I1,S2,I2,
853 Func,FInv,PFirst,MaxStep,locfleche,
854 TolGuide,First,Last,Inside,Appro,Forward,
855 Soldep,4,RecOnS1,RecOnS2);
856
857 if ( !done ) return Standard_False;
858 Handle(ChFiDS_SecHArray1) sec;
859 gp_Pnt2d pf1,pl1,pf2,pl2;
860
861 Standard_Integer nbp = lin->NbPoints();
862 sec = new ChFiDS_SecHArray1(1,nbp);
863 for( i = 1; i <= nbp; i++ ){
864 ChFiDS_CircSection& isec = sec->ChangeValue(i);
865 Standard_Real u1,v1,u2,v2,ww,p1,p2;
866 gp_Lin line;
867 const Blend_Point& p = lin->Point(i);
868 p.ParametersOnS1(u1,v1);
869 p.ParametersOnS2(u2,v2);
870 ww = p.Parameter();
871 Func.Section(ww,u1,v1,u2,v2,p1,p2,line);
872 isec.Set(line,p1,p2);
873 if(i == 1) {pf1.SetCoord(u1,v1); pf2.SetCoord(u2,v2);}
874 if(i == nbp) {pl1.SetCoord(u1,v1); pl2.SetCoord(u2,v2);}
875 }
876
877 Data->SetSimul(sec);
878 Data->Set2dPoints(pf1,pl1,pf2,pl2);
879 ChFi3d_FilCommonPoint(lin->StartPointOnFirst(),lin->TransitionOnS1(),
880 Standard_True, Data->ChangeVertexFirstOnS1(),tolesp);
881 ChFi3d_FilCommonPoint(lin->EndPointOnFirst(),lin->TransitionOnS1(),
882 Standard_False,Data->ChangeVertexLastOnS1(),tolesp);
883 ChFi3d_FilCommonPoint(lin->StartPointOnSecond(),lin->TransitionOnS2(),
884 Standard_True, Data->ChangeVertexFirstOnS2(),tolesp);
885 ChFi3d_FilCommonPoint(lin->EndPointOnSecond(),lin->TransitionOnS2(),
886 Standard_False, Data->ChangeVertexLastOnS2(),tolesp);
887
888 Standard_Boolean reverse = (!Forward || Inside);
889 if(intf && reverse){
dde68833 890 Standard_Boolean ok = Standard_False;
7fd59977 891 const ChFiDS_CommonPoint& cp1 = Data->VertexFirstOnS1();
892 if(cp1.IsOnArc()){
893 TopoDS_Face F1 = S1->ChangeSurface().Face();
894 TopoDS_Face bid;
dde68833 895 intf = !SearchFace(Spine,cp1,F1,bid);
896 ok = intf != 0;
7fd59977 897 }
898 const ChFiDS_CommonPoint& cp2 = Data->VertexFirstOnS2();
899 if(cp2.IsOnArc() && !ok){
900 TopoDS_Face F2 = S2->ChangeSurface().Face();
901 TopoDS_Face bid;
902 intf = !SearchFace(Spine,cp2,F2,bid);
903 }
904 }
905 if(intl){
dde68833 906 Standard_Boolean ok = Standard_False;
7fd59977 907 const ChFiDS_CommonPoint& cp1 = Data->VertexLastOnS1();
908 if(cp1.IsOnArc()){
909 TopoDS_Face F1 = S1->ChangeSurface().Face();
910 TopoDS_Face bid;
dde68833 911 intl = !SearchFace(Spine,cp1,F1,bid);
912 ok = intl != 0;
7fd59977 913 }
914 const ChFiDS_CommonPoint& cp2 = Data->VertexLastOnS2();
915 if(cp2.IsOnArc() && !ok){
916 TopoDS_Face F2 = S2->ChangeSurface().Face();
917 TopoDS_Face bid;
918 intl = !SearchFace(Spine,cp2,F2,bid);
919 }
920 }
921 }
922 else if (chsp->IsChamfer() == ChFiDS_TwoDist) {
923 Standard_Real dis1, dis2;
924 chsp->Dists(dis1, dis2);
925 radius = Max(dis1, dis2);
926 radius = Max(radius, radiusspine);
81bba717 927 locfleche = radius*1.e-2; //graphic criterion
7fd59977 928
929 BRepBlend_Chamfer Func(S1,S2,HGuide);
930 BRepBlend_ChamfInv FInv(S1,S2,HGuide);
931 Func.Set(dis1,dis2,Choix);
932 FInv.Set(dis1,dis2,Choix);
933
934 done = SimulData(Data,HGuide,lin,S1,I1,S2,I2,
935 Func,FInv,PFirst,MaxStep,locfleche,
936 TolGuide,First,Last,Inside,Appro,Forward,
937 Soldep,4,RecOnS1,RecOnS2);
938
939 if ( !done ) return Standard_False;
940 Handle(ChFiDS_SecHArray1) sec;
941 gp_Pnt2d pf1,pl1,pf2,pl2;
942
943 Standard_Integer nbp = lin->NbPoints();
944 sec = new ChFiDS_SecHArray1(1,nbp);
945 for( i = 1; i <= nbp; i++ ){
946 ChFiDS_CircSection& isec = sec->ChangeValue(i);
947 Standard_Real u1,v1,u2,v2,ww,p1,p2;
948 gp_Lin line;
949 const Blend_Point& p = lin->Point(i);
950 p.ParametersOnS1(u1,v1);
951 p.ParametersOnS2(u2,v2);
952 ww = p.Parameter();
953 Func.Section(ww,u1,v1,u2,v2,p1,p2,line);
954 isec.Set(line,p1,p2);
955 if(i == 1) {pf1.SetCoord(u1,v1); pf2.SetCoord(u2,v2);}
956 if(i == nbp) {pl1.SetCoord(u1,v1); pl2.SetCoord(u2,v2);}
957 }
958
959 Data->SetSimul(sec);
960 Data->Set2dPoints(pf1,pl1,pf2,pl2);
961 ChFi3d_FilCommonPoint(lin->StartPointOnFirst(),lin->TransitionOnS1(),
962 Standard_True, Data->ChangeVertexFirstOnS1(),tolesp);
963 ChFi3d_FilCommonPoint(lin->EndPointOnFirst(),lin->TransitionOnS1(),
964 Standard_False,Data->ChangeVertexLastOnS1(),tolesp);
965 ChFi3d_FilCommonPoint(lin->StartPointOnSecond(),lin->TransitionOnS2(),
966 Standard_True, Data->ChangeVertexFirstOnS2(),tolesp);
967 ChFi3d_FilCommonPoint(lin->EndPointOnSecond(),lin->TransitionOnS2(),
968 Standard_False, Data->ChangeVertexLastOnS2(),tolesp);
969
970 Standard_Boolean reverse = (!Forward || Inside);
971 if(intf && reverse){
dde68833 972 Standard_Boolean ok = Standard_False;
7fd59977 973 const ChFiDS_CommonPoint& cp1 = Data->VertexFirstOnS1();
974 if(cp1.IsOnArc()){
975 TopoDS_Face F1 = S1->ChangeSurface().Face();
976 TopoDS_Face bid;
dde68833 977 intf = !SearchFace(Spine,cp1,F1,bid);
978 ok = intf != 0;
7fd59977 979 }
980 const ChFiDS_CommonPoint& cp2 = Data->VertexFirstOnS2();
981 if(cp2.IsOnArc() && !ok){
982 TopoDS_Face F2 = S2->ChangeSurface().Face();
983 TopoDS_Face bid;
984 intf = !SearchFace(Spine,cp2,F2,bid);
985 }
986 }
987 if(intl){
dde68833 988 Standard_Boolean ok = Standard_False;
7fd59977 989 const ChFiDS_CommonPoint& cp1 = Data->VertexLastOnS1();
990 if(cp1.IsOnArc()){
991 TopoDS_Face F1 = S1->ChangeSurface().Face();
992 TopoDS_Face bid;
dde68833 993 intl = !SearchFace(Spine,cp1,F1,bid);
994 ok = intl != 0;
7fd59977 995 }
996 const ChFiDS_CommonPoint& cp2 = Data->VertexLastOnS2();
997 if(cp2.IsOnArc() && !ok){
998 TopoDS_Face F2 = S2->ChangeSurface().Face();
999 TopoDS_Face bid;
1000 intl = !SearchFace(Spine,cp2,F2,bid);
1001 }
1002 }
1003 }
1004 else {
1005 Standard_Real dis, angle;
1006 Standard_Boolean disonF1;
1007 chsp->GetDistAngle(dis, angle, disonF1);
1008 radius = Max(dis, dis * tan(angle));
1009 radius = Max(radius, radiusspine);
81bba717 1010 locfleche = radius*1.e-2; //graphic criterion
7fd59977 1011
1012 Standard_Integer Ch = FindChoiceDistAngle(Choix, disonF1);
1013
1014 if (disonF1) {
1015 BRepBlend_ChAsym Func(S1,S2,HGuide);
1016 BRepBlend_ChAsymInv FInv(S1,S2,HGuide);
1017
1018 Func.Set(dis, angle, Ch);
1019 FInv.Set(dis, angle, Ch);
1020
1021 done = SimulData(Data,HGuide,lin,S1,I1,S2,I2,
1022 Func,FInv,PFirst,MaxStep,locfleche,
1023 TolGuide,First,Last,Inside,Appro,Forward,
1024 Soldep,4,RecOnS1,RecOnS2);
1025
1026 if ( !done ) return Standard_False;
1027 Handle(ChFiDS_SecHArray1) sec;
1028 gp_Pnt2d pf1,pl1,pf2,pl2;
1029
1030 Standard_Integer nbp = lin->NbPoints();
1031 sec = new ChFiDS_SecHArray1(1,nbp);
1032 for( i = 1; i <= nbp; i++ ){
1033 ChFiDS_CircSection& isec = sec->ChangeValue(i);
1034 Standard_Real u1,v1,u2,v2,ww,p1,p2;
1035 gp_Lin line;
1036 const Blend_Point& p = lin->Point(i);
1037 p.ParametersOnS1(u1,v1);
1038 p.ParametersOnS2(u2,v2);
1039 ww = p.Parameter();
1040 Func.Section(ww,u1,v1,u2,v2,p1,p2,line);
1041 isec.Set(line,p1,p2);
1042 if(i == 1) {pf1.SetCoord(u1,v1); pf2.SetCoord(u2,v2);}
1043 if(i == nbp) {pl1.SetCoord(u1,v1); pl2.SetCoord(u2,v2);}
1044 }
1045
1046 Data->SetSimul(sec);
1047 Data->Set2dPoints(pf1,pl1,pf2,pl2);
1048 ChFi3d_FilCommonPoint(lin->StartPointOnFirst(),lin->TransitionOnS1(),
1049 Standard_True, Data->ChangeVertexFirstOnS1(),tolesp);
1050 ChFi3d_FilCommonPoint(lin->EndPointOnFirst(),lin->TransitionOnS1(),
1051 Standard_False,Data->ChangeVertexLastOnS1(),tolesp);
1052 ChFi3d_FilCommonPoint(lin->StartPointOnSecond(),lin->TransitionOnS2(),
1053 Standard_True, Data->ChangeVertexFirstOnS2(),tolesp);
1054 ChFi3d_FilCommonPoint(lin->EndPointOnSecond(),lin->TransitionOnS2(),
1055 Standard_False, Data->ChangeVertexLastOnS2(),tolesp);
1056
1057 Standard_Boolean reverse = (!Forward || Inside);
1058 if(intf && reverse){
dde68833 1059 Standard_Boolean ok = Standard_False;
7fd59977 1060 const ChFiDS_CommonPoint& cp1 = Data->VertexFirstOnS1();
1061 if(cp1.IsOnArc()){
1062 TopoDS_Face F1 = S1->ChangeSurface().Face();
1063 TopoDS_Face bid;
dde68833 1064 intf = !SearchFace(Spine,cp1,F1,bid);
1065 ok = intf != 0;
7fd59977 1066 }
1067 const ChFiDS_CommonPoint& cp2 = Data->VertexFirstOnS2();
1068 if(cp2.IsOnArc() && !ok){
1069 TopoDS_Face F2 = S2->ChangeSurface().Face();
1070 TopoDS_Face bid;
1071 intf = !SearchFace(Spine,cp2,F2,bid);
1072 }
1073 }
1074
1075 if(intl){
dde68833 1076 Standard_Boolean ok = Standard_False;
7fd59977 1077 const ChFiDS_CommonPoint& cp1 = Data->VertexLastOnS1();
1078 if(cp1.IsOnArc()){
1079 TopoDS_Face F1 = S1->ChangeSurface().Face();
1080 TopoDS_Face bid;
dde68833 1081 intl = !SearchFace(Spine,cp1,F1,bid);
1082 ok = intl != 0;
7fd59977 1083 }
1084 const ChFiDS_CommonPoint& cp2 = Data->VertexLastOnS2();
1085 if(cp2.IsOnArc() && !ok){
1086 TopoDS_Face F2 = S2->ChangeSurface().Face();
1087 TopoDS_Face bid;
1088 intl = !SearchFace(Spine,cp2,F2,bid);
1089 }
1090 }
1091 }
1092 else {
1093 BRepBlend_ChAsym Func(S2,S1,HGuide);
1094 BRepBlend_ChAsymInv FInv(S2,S1,HGuide);
1095
1096 Func.Set(dis, angle, Ch);
1097 FInv.Set(dis, angle, Ch);
1098
1099 Standard_Real Rtemp;
1100 Rtemp = Soldep(1);
1101 Soldep(1) = Soldep(3);
1102 Soldep(3) = Rtemp;
1103 Rtemp = Soldep(2);
1104 Soldep(2) = Soldep(4);
1105 Soldep(4) = Rtemp;
1106
1107 done = SimulData(Data,HGuide,lin,S2,I2,S1,I1,
1108 Func,FInv,PFirst,MaxStep,locfleche,
1109 TolGuide,First,Last,Inside,Appro,Forward,
1110 Soldep,4,RecOnS2,RecOnS1);
1111
1112 if ( !done ) return Standard_False;
1113 Handle(ChFiDS_SecHArray1) sec;
1114 gp_Pnt2d pf1,pl1,pf2,pl2;
1115
1116 Standard_Integer nbp = lin->NbPoints();
1117 sec = new ChFiDS_SecHArray1(1,nbp);
1118 for( i = 1; i <= nbp; i++ ){
1119 ChFiDS_CircSection& isec = sec->ChangeValue(i);
1120 Standard_Real u1,v1,u2,v2,ww,p1,p2;
1121 gp_Lin line;
1122 const Blend_Point& p = lin->Point(i);
1123 p.ParametersOnS1(u1,v1);
1124 p.ParametersOnS2(u2,v2);
1125 ww = p.Parameter();
1126 Func.Section(ww,u1,v1,u2,v2,p1,p2,line);
1127 isec.Set(line,p1,p2);
1128 if(i == 1) {pf1.SetCoord(u1,v1); pf2.SetCoord(u2,v2);}
1129 if(i == nbp) {pl1.SetCoord(u1,v1); pl2.SetCoord(u2,v2);}
1130 }
1131
1132 Data->SetSimul(sec);
1133 Data->Set2dPoints(pf1,pl1,pf2,pl2);
1134 ChFi3d_FilCommonPoint(lin->StartPointOnFirst(),lin->TransitionOnS1(),
1135 Standard_True, Data->ChangeVertexFirstOnS1(),tolesp);
1136 ChFi3d_FilCommonPoint(lin->EndPointOnFirst(),lin->TransitionOnS1(),
1137 Standard_False,Data->ChangeVertexLastOnS1(),tolesp);
1138 ChFi3d_FilCommonPoint(lin->StartPointOnSecond(),lin->TransitionOnS2(),
1139 Standard_True, Data->ChangeVertexFirstOnS2(),tolesp);
1140 ChFi3d_FilCommonPoint(lin->EndPointOnSecond(),lin->TransitionOnS2(),
1141 Standard_False, Data->ChangeVertexLastOnS2(),tolesp);
1142
1143 Standard_Boolean reverse = (!Forward || Inside);
1144 if(intf && reverse){
dde68833 1145 Standard_Boolean ok = Standard_False;
7fd59977 1146 const ChFiDS_CommonPoint& cp1 = Data->VertexFirstOnS1();
1147 if(cp1.IsOnArc()){
1148 TopoDS_Face F1 = S1->ChangeSurface().Face();
1149 TopoDS_Face bid;
dde68833 1150 intf = !SearchFace(Spine,cp1,F1,bid);
1151 ok = intf != 0;
7fd59977 1152 }
1153 const ChFiDS_CommonPoint& cp2 = Data->VertexFirstOnS2();
1154 if(cp2.IsOnArc() && !ok){
1155 TopoDS_Face F2 = S2->ChangeSurface().Face();
1156 TopoDS_Face bid;
1157 intf = !SearchFace(Spine,cp2,F2,bid);
1158 }
1159 }
1160
1161 if(intl){
dde68833 1162 Standard_Boolean ok = Standard_False;
7fd59977 1163 const ChFiDS_CommonPoint& cp1 = Data->VertexLastOnS1();
1164 if(cp1.IsOnArc()){
1165 TopoDS_Face F1 = S1->ChangeSurface().Face();
1166 TopoDS_Face bid;
dde68833 1167 intl = !SearchFace(Spine,cp1,F1,bid);
1168 ok = intl != 0;
7fd59977 1169 }
1170 const ChFiDS_CommonPoint& cp2 = Data->VertexLastOnS2();
1171 if(cp2.IsOnArc() && !ok){
1172 TopoDS_Face F2 = S2->ChangeSurface().Face();
1173 TopoDS_Face bid;
1174 intl = !SearchFace(Spine,cp2,F2,bid);
1175 }
1176 }
1177 }
1178 }
1179 return Standard_True;
1180}
1181
1182void ChFi3d_ChBuilder::SimulSurf(Handle(ChFiDS_SurfData)& ,
1183 const Handle(ChFiDS_HElSpine)& ,
1184 const Handle(ChFiDS_Spine)& ,
1185 const Standard_Integer ,
1186 const Handle(BRepAdaptor_HSurface)& ,
1187 const Handle(Adaptor3d_TopolTool)& ,
1188 const Handle(BRepAdaptor_HCurve2d)& ,
1189 const Handle(BRepAdaptor_HSurface)& ,
1190 const Handle(BRepAdaptor_HCurve2d)& ,
1191 Standard_Boolean& ,
1192 const Handle(BRepAdaptor_HSurface)& ,
1193 const Handle(Adaptor3d_TopolTool)& ,
1194 const TopAbs_Orientation ,
1195 const Standard_Real ,
1196 const Standard_Real ,
1197 Standard_Real& ,
1198 Standard_Real& ,
1199 const Standard_Boolean ,
1200 const Standard_Boolean ,
1201 const Standard_Boolean ,
1202 const Standard_Boolean ,
1203 const Standard_Boolean ,
1204 const Standard_Boolean ,
1205 const math_Vector& )
1206{
1207 Standard_Failure::Raise("SimulSurf Not Implemented");
1208}
1209void ChFi3d_ChBuilder::SimulSurf(Handle(ChFiDS_SurfData)& ,
1210 const Handle(ChFiDS_HElSpine)& ,
1211 const Handle(ChFiDS_Spine)& ,
1212 const Standard_Integer ,
1213 const Handle(BRepAdaptor_HSurface)& ,
1214 const Handle(Adaptor3d_TopolTool)& ,
1215 const TopAbs_Orientation ,
1216 const Handle(BRepAdaptor_HSurface)& ,
1217 const Handle(Adaptor3d_TopolTool)& ,
1218 const Handle(BRepAdaptor_HCurve2d)& ,
1219 const Handle(BRepAdaptor_HSurface)& ,
1220 const Handle(BRepAdaptor_HCurve2d)& ,
1221 Standard_Boolean& ,
1222 const Standard_Real ,
1223 const Standard_Real ,
1224 Standard_Real& ,
1225 Standard_Real& ,
1226 const Standard_Boolean ,
1227 const Standard_Boolean ,
1228 const Standard_Boolean ,
1229 const Standard_Boolean ,
1230 const Standard_Boolean ,
1231 const Standard_Boolean ,
1232 const math_Vector& )
1233{
1234 Standard_Failure::Raise("SimulSurf Not Implemented");
1235}
1236void ChFi3d_ChBuilder::SimulSurf(Handle(ChFiDS_SurfData)& ,
1237 const Handle(ChFiDS_HElSpine)& ,
1238 const Handle(ChFiDS_Spine)& ,
1239 const Standard_Integer ,
1240 const Handle(BRepAdaptor_HSurface)& ,
1241 const Handle(Adaptor3d_TopolTool)& ,
1242 const Handle(BRepAdaptor_HCurve2d)& ,
1243 const Handle(BRepAdaptor_HSurface)& ,
1244 const Handle(BRepAdaptor_HCurve2d)& ,
1245 Standard_Boolean& ,
1246 const TopAbs_Orientation ,
1247 const Handle(BRepAdaptor_HSurface)& ,
1248 const Handle(Adaptor3d_TopolTool)& ,
1249 const Handle(BRepAdaptor_HCurve2d)& ,
1250 const Handle(BRepAdaptor_HSurface)& ,
1251 const Handle(BRepAdaptor_HCurve2d)& ,
1252 Standard_Boolean& ,
1253 const TopAbs_Orientation ,
1254 const Standard_Real ,
1255 const Standard_Real ,
1256 Standard_Real& ,
1257 Standard_Real& ,
1258 const Standard_Boolean ,
1259 const Standard_Boolean ,
1260 const Standard_Boolean ,
1261 const Standard_Boolean ,
1262 const Standard_Boolean ,
1263 const Standard_Boolean ,
1264 const Standard_Boolean ,
1265 const math_Vector& )
1266{
1267 Standard_Failure::Raise("SimulSurf Not Implemented");
1268}
1269//------------------------MODIFS---------------------------------------
1270//=======================================================================
1271//function : PerformFirstSection
1272//purpose : to implement the first section if there is no KPart
1273//=======================================================================
1274
1275Standard_Boolean ChFi3d_ChBuilder::PerformFirstSection
1276(const Handle(ChFiDS_Spine)& Spine,
1277 const Handle(ChFiDS_HElSpine)& HGuide,
1278 const Standard_Integer Choix,
1279 Handle(BRepAdaptor_HSurface)& S1,
1280 Handle(BRepAdaptor_HSurface)& S2,
1281 const Handle(Adaptor3d_TopolTool)& I1,
1282 const Handle(Adaptor3d_TopolTool)& I2,
1283 const Standard_Real Par,
1284 math_Vector& SolDep,
1285 TopAbs_State& Pos1,
1286 TopAbs_State& Pos2) const
1287{
1288 Handle(ChFiDS_ChamfSpine)
1289 chsp = Handle(ChFiDS_ChamfSpine)::DownCast(Spine);
1290
1291 if (chsp.IsNull())
1292 Standard_ConstructionError::Raise
81bba717 1293 ("PerformSurf : this is not the spine of a chamfer");
7fd59977 1294
1295 Standard_Real TolGuide = HGuide->Resolution(tolesp) ;
1296
1297
1298 if (chsp->IsChamfer() == ChFiDS_Sym) {
1299 Standard_Real dis;
1300 chsp->GetDist(dis);
1301
1302 BRepBlend_Chamfer Func(S1,S2,HGuide);
1303 Func.Set(dis,dis,Choix);
af99433e 1304 BRepBlend_Walking TheWalk(S1,S2,I1,I2,HGuide);
7fd59977 1305
81bba717 1306 //calculate an approximate starting solution
7fd59977 1307 gp_Vec TgF, TgL, tmp1, tmp2, d1gui;
1308 gp_Pnt pt1, pt2, ptgui;
1309 gp_XYZ temp;
1310
1311 ( HGuide->Curve() ).D1(Par,ptgui,d1gui);
1312 // ptgui = (S1->Surface()).Value(SolDep(1),SolDep(2));
1313
1314 Func.Set(Par);
1315 Func.Tangent(SolDep(1),SolDep(2),SolDep(3),SolDep(4),TgF,TgL,tmp1,tmp2);
1316
1317 Standard_Boolean rev1 = Standard_False;
1318 Standard_Boolean rev2 = Standard_False;
1319 Standard_Real sign = (TgF.Crossed(d1gui)).Dot(TgL);
1320
1321 if( Choix%2 == 1 )
1322 rev1 = Standard_True;
1323 else
1324 rev2 = Standard_True;
1325
1326 if( sign < 0. ){
1327 rev1 = !rev1;
1328 rev2 = !rev2;
1329 }
1330
1331 if( rev1 )
1332 TgF.Reverse();
1333 if( rev2 )
1334 TgL.Reverse();
1335
1336 temp = (TgF.XYZ()).Multiplied(dis);
1337 pt1.SetXYZ( (ptgui.XYZ()).Added(temp) );
1338 temp = (TgL.XYZ()).Multiplied(dis);
1339 pt2.SetXYZ( (ptgui.XYZ()).Added(temp) );
1340
1341 Standard_Real tol = tolesp*1.e2;
1342// Standard_Real u,v;
e5260e1d 1343 Extrema_GenLocateExtPS proj1(S1->Surface(), tol, tol);
1344 proj1.Perform(pt1, SolDep(1), SolDep(2));
1345 Extrema_GenLocateExtPS proj2(S2->Surface(), tol, tol);
1346 proj2.Perform(pt2, SolDep(3), SolDep(4));
1347
7fd59977 1348 if( proj1.IsDone() ){
1349 (proj1.Point()).Parameter(SolDep(1),SolDep(2));
1350 }
1351 if( proj2.IsDone() ){
1352 (proj2.Point()).Parameter(SolDep(3),SolDep(4));
1353 }
1354
1355 return TheWalk.PerformFirstSection(Func,Par,SolDep,
1356 tolesp,TolGuide,Pos1,Pos2);
1357 }
1358 else if (chsp->IsChamfer() == ChFiDS_TwoDist) {
1359 Standard_Real dis1, dis2;
1360 chsp->Dists(dis1, dis2);
1361
1362 BRepBlend_Chamfer Func(S1,S2,HGuide);
1363 Func.Set(dis1,dis2,Choix);
af99433e 1364 BRepBlend_Walking TheWalk(S1,S2,I1,I2,HGuide);
7fd59977 1365
81bba717 1366 //calculate an approximate starting solution
7fd59977 1367 gp_Vec TgF, TgL, tmp1, tmp2, d1gui;
1368 gp_Pnt pt1, pt2, ptgui;
1369 gp_XYZ temp;
1370
1371 ( HGuide->Curve() ).D1(Par,ptgui,d1gui);
1372 // ptgui = (S1->Surface()).Value(SolDep(1),SolDep(2));
1373
1374 Func.Set(Par);
1375 Func.Tangent(SolDep(1),SolDep(2),SolDep(3),SolDep(4),TgF,TgL,tmp1,tmp2);
1376
1377 Standard_Boolean rev1 = Standard_False;
1378 Standard_Boolean rev2 = Standard_False;
1379 Standard_Real sign = (TgF.Crossed(d1gui)).Dot(TgL);
1380
1381 if( Choix%2 == 1 )
1382 rev1 = Standard_True;
1383 else
1384 rev2 = Standard_True;
1385
1386 if( sign < 0. ){
1387 rev1 = !rev1;
1388 rev2 = !rev2;
1389 }
1390
1391 if( rev1 )
1392 TgF.Reverse();
1393 if( rev2 )
1394 TgL.Reverse();
1395
1396 temp = (TgF.XYZ()).Multiplied(dis1);
1397 pt1.SetXYZ( (ptgui.XYZ()).Added(temp) );
1398 temp = (TgL.XYZ()).Multiplied(dis2);
1399 pt2.SetXYZ( (ptgui.XYZ()).Added(temp) );
1400
1401 Standard_Real tol = tolesp*1.e2;
1402// Standard_Real u,v;
e5260e1d 1403
1404 Extrema_GenLocateExtPS proj1(S1->Surface(), tol, tol);
1405 proj1.Perform(pt1, SolDep(1), SolDep(2));
1406 Extrema_GenLocateExtPS proj2(S2->Surface(), tol, tol);
1407 proj2.Perform(pt2, SolDep(3), SolDep(4));
1408
7fd59977 1409 if( proj1.IsDone() ){
1410 (proj1.Point()).Parameter(SolDep(1),SolDep(2));
1411 }
1412 if( proj2.IsDone() ){
1413 (proj2.Point()).Parameter(SolDep(3),SolDep(4));
1414 }
1415
1416 return TheWalk.PerformFirstSection(Func,Par,SolDep,
1417 tolesp,TolGuide,Pos1,Pos2);
1418 }
1419 else {
1420 Standard_Real dis1, angle;
1421 Standard_Boolean disonF1;
1422 chsp->GetDistAngle(dis1, angle, disonF1);
1423
1424 Standard_Integer Ch = FindChoiceDistAngle(Choix, disonF1);
1425
1426 if (disonF1) {
1427 BRepBlend_ChAsym Func(S1,S2,HGuide);
1428 Func.Set(dis1, angle, Ch);
af99433e 1429 BRepBlend_Walking TheWalk(S1,S2,I1,I2,HGuide);
7fd59977 1430
81bba717 1431 //calculate an approximate starting solution
7fd59977 1432 gp_Vec TgF, TgL, tmp1, tmp2, d1gui;
1433 gp_Pnt pt1, pt2, ptgui;
1434 gp_XYZ temp;
1435
1436 ( HGuide->Curve() ).D1(Par,ptgui,d1gui);
1437 // ptgui = (S1->Surface()).Value(SolDep(1),SolDep(2));
1438
1439 Func.Set(Par);
1440 Func.Tangent(SolDep(1),SolDep(2),SolDep(3),SolDep(4),TgF,TgL,tmp1,tmp2);
1441
1442 Standard_Boolean rev1 = Standard_False;
1443 Standard_Boolean rev2 = Standard_False;
1444 Standard_Real sign = (TgF.Crossed(d1gui)).Dot(TgL);
1445
1446 if( Ch%2 == 1 )
1447 rev1 = Standard_True;
1448 else
1449 rev2 = Standard_True;
1450
1451 if( sign < 0. ){
1452 rev1 = !rev1;
1453 rev2 = !rev2;
1454 }
1455
1456 if( rev1 )
1457 TgF.Reverse();
1458 if( rev2 )
1459 TgL.Reverse();
1460
1461 temp = (TgF.XYZ()).Multiplied(dis1);
1462 pt1.SetXYZ( (ptgui.XYZ()).Added(temp) );
1463
1464 Standard_Real dis2, tmpcos, tmpsin;
1465 tmpcos = TgF.Dot(TgL);
1466 tmpsin = sqrt(1. - tmpcos * tmpcos);
1467
1468 dis2 = dis1 / (tmpcos + tmpsin / tan(angle));
1469
1470 temp = (TgL.XYZ()).Multiplied(dis2);
1471 pt2.SetXYZ( (ptgui.XYZ()).Added(temp) );
1472
1473 Standard_Real tol = tolesp*1.e2;
1474// Standard_Real u,v;
e5260e1d 1475 Extrema_GenLocateExtPS proj1(S1->Surface(), tol, tol);
1476 proj1.Perform(pt1, SolDep(1), SolDep(2));
1477 Extrema_GenLocateExtPS proj2(S2->Surface(), tol, tol);
1478 proj2.Perform(pt2, SolDep(3), SolDep(4));
7fd59977 1479 if( proj1.IsDone() ){
1480 (proj1.Point()).Parameter(SolDep(1),SolDep(2));
1481 }
1482 if( proj2.IsDone() ){
1483 (proj2.Point()).Parameter(SolDep(3),SolDep(4));
1484 }
1485
1486 return TheWalk.PerformFirstSection(Func,Par,SolDep,
1487 tolesp,TolGuide,Pos1,Pos2);
1488 }
1489 else {
1490 Standard_Real Rtemp;
1491 BRepBlend_ChAsym Func(S2,S1,HGuide);
1492 Func.Set(dis1, angle, Ch);
af99433e 1493 BRepBlend_Walking TheWalk(S2,S1,I2,I1,HGuide);
7fd59977 1494
81bba717 1495 //calculate an approximate starting solution
7fd59977 1496 gp_Vec TgF, TgL, tmp1, tmp2, d1gui;
1497 gp_Pnt pt1, pt2, ptgui;
1498 gp_XYZ temp;
1499
1500 ( HGuide->Curve() ).D1(Par,ptgui,d1gui);
1501 // ptgui = (S1->Surface()).Value(SolDep(1),SolDep(2));
1502 Rtemp = SolDep(1);
1503 SolDep(1) = SolDep(3);
1504 SolDep(3) = Rtemp;
1505 Rtemp = SolDep(2);
1506 SolDep(2) = SolDep(4);
1507 SolDep(4) = Rtemp;
1508 Func.Set(Par);
1509
1510 Func.Tangent(SolDep(1),SolDep(2),SolDep(3),SolDep(4),TgF,TgL,tmp1,tmp2);
1511
1512 Standard_Boolean rev1 = Standard_False;
1513 Standard_Boolean rev2 = Standard_False;
1514 Standard_Real sign = (TgF.Crossed(d1gui)).Dot(TgL);
1515
1516 if( Ch%2 == 1 )
1517 rev1 = Standard_True;
1518 else
1519 rev2 = Standard_True;
1520
1521 if( sign < 0. ){
1522 rev1 = !rev1;
1523 rev2 = !rev2;
1524 }
1525
1526 if( rev1 )
1527 TgF.Reverse();
1528 if( rev2 )
1529 TgL.Reverse();
1530
1531 temp = (TgF.XYZ()).Multiplied(dis1);
1532 pt1.SetXYZ( (ptgui.XYZ()).Added(temp) );
1533
1534 Standard_Real dis2, tmpcos, tmpsin;
1535 tmpcos = TgF.Dot(TgL);
1536 tmpsin = sqrt(1. - tmpcos * tmpcos);
1537
1538 dis2 = dis1 / (tmpcos + tmpsin / tan(angle));
1539
1540 temp = (TgL.XYZ()).Multiplied(dis2);
1541 pt2.SetXYZ( (ptgui.XYZ()).Added(temp) );
1542
1543 Standard_Real tol = tolesp*1.e2;
1544// Standard_Real u,v;
e5260e1d 1545 Extrema_GenLocateExtPS proj1(S2->Surface(), tol, tol);
1546 proj1.Perform(pt1, SolDep(1), SolDep(2));
1547 Extrema_GenLocateExtPS proj2(S1->Surface(), tol, tol);
1548 proj2.Perform(pt2, SolDep(3), SolDep(4));
7fd59977 1549 if( proj1.IsDone() ) {
1550 (proj1.Point()).Parameter(SolDep(1),SolDep(2));
1551 }
1552 if( proj2.IsDone() ){
1553 (proj2.Point()).Parameter(SolDep(3),SolDep(4));
1554 }
1555
1556 Standard_Boolean RetWalk = TheWalk.PerformFirstSection(Func,Par,SolDep,
1557 tolesp,TolGuide,Pos2,Pos1);
1558 Rtemp = SolDep(1);
1559 SolDep(1) = SolDep(3);
1560 SolDep(3) = Rtemp;
1561 Rtemp = SolDep(2);
1562 SolDep(2) = SolDep(4);
1563 SolDep(4) = Rtemp;
1564
1565 return RetWalk;
1566 }
1567 }
1568}
1569
1570
1571//=======================================================================
1572//function : PerformSurf
1573//purpose :
1574//=======================================================================
1575
1576Standard_Boolean
1577ChFi3d_ChBuilder::PerformSurf(ChFiDS_SequenceOfSurfData& SeqData,
1578 const Handle(ChFiDS_HElSpine)& HGuide,
1579 const Handle(ChFiDS_Spine)& Spine,
1580 const Standard_Integer Choix,
1581 const Handle(BRepAdaptor_HSurface)& S1,
1582 const Handle(Adaptor3d_TopolTool)& I1,
1583 const Handle(BRepAdaptor_HSurface)& S2,
1584 const Handle(Adaptor3d_TopolTool)& I2,
1585 const Standard_Real MaxStep,
1586 const Standard_Real Fleche,
1587 const Standard_Real TolGuide,
1588 Standard_Real& First,
1589 Standard_Real& Last,
1590 const Standard_Boolean Inside,
1591 const Standard_Boolean Appro,
1592 const Standard_Boolean Forward,
1593 const Standard_Boolean RecOnS1,
1594 const Standard_Boolean RecOnS2,
1595 const math_Vector& Soldep,
dde68833 1596 Standard_Integer& intf,
1597 Standard_Integer& intl)
7fd59977 1598
1599{
1600 Handle(ChFiDS_SurfData) Data = SeqData(1);
1601 Handle(ChFiDS_ChamfSpine)
1602 chsp = Handle(ChFiDS_ChamfSpine)::DownCast(Spine);
1603
1604 if (chsp.IsNull())
1605 Standard_ConstructionError::Raise
81bba717 1606 ("PerformSurf : this is not the spine of a chamfer");
7fd59977 1607
1608 Standard_Boolean gd1,gd2,gf1,gf2;
1609 Handle(BRepBlend_Line) lin;
1610 TopAbs_Orientation Or = S1->ChangeSurface().Face().Orientation();
1611 Standard_Real PFirst = First;
1612 if(intf) First = chsp->FirstParameter(1);
1613 if(intl) Last = chsp->LastParameter(chsp->NbEdges());
1614
1615 if (chsp->IsChamfer() == ChFiDS_Sym) {
1616 BRepBlend_Chamfer Func(S1,S2,HGuide);
1617 BRepBlend_ChamfInv FInv(S1,S2,HGuide);
1618 Standard_Real dis;
1619 chsp->GetDist(dis);
1620 Func.Set(dis, dis, Choix);
1621 FInv.Set(dis, dis, Choix);
1622
1623 done = ComputeData(Data,HGuide,Spine,lin,S1,I1,S2,I2,Func,FInv,
1624 PFirst,MaxStep,Fleche,TolGuide,First,Last,
1625 Inside,Appro,Forward,Soldep,intf,intl,
1626 gd1,gd2,gf1,gf2,RecOnS1,RecOnS2);
1627 if(!done) return Standard_False; // ratrappage possible PMN 14/05/1998
1628 done = CompleteData(Data,Func,lin,S1,S2,Or,gd1,gd2,gf1,gf2);
81bba717 1629 if(!done) Standard_Failure::Raise("PerformSurf : Fail of approximation!");
7fd59977 1630 }
1631 else if (chsp->IsChamfer() == ChFiDS_TwoDist) {
1632 BRepBlend_Chamfer Func(S1,S2,HGuide);
1633 BRepBlend_ChamfInv FInv(S1,S2,HGuide);
1634 Standard_Real d1, d2;
1635 chsp->Dists(d1,d2);
1636 Func.Set(d1,d2,Choix);
1637 FInv.Set(d1,d2,Choix);
1638
1639 done = ComputeData(Data,HGuide,Spine,lin,S1,I1,S2,I2,Func,FInv,
1640 PFirst,MaxStep,Fleche,TolGuide,First,Last,
1641 Inside,Appro,Forward,Soldep,intf,intl,
1642 gd1,gd2,gf1,gf2,RecOnS1,RecOnS2);
1643 if(!done) return Standard_False; // ratrappage possible PMN 14/05/1998
1644 done = CompleteData(Data,Func,lin,S1,S2,Or,gd1,gd2,gf1,gf2);
81bba717 1645 if(!done) Standard_Failure::Raise("PerformSurf : Fail of approximation!");
7fd59977 1646 }
1647 else {
1648 Standard_Real d1, angle;
1649 Standard_Boolean disonF1;
1650 chsp->GetDistAngle(d1, angle, disonF1);
1651
1652 Standard_Integer Ch = FindChoiceDistAngle(Choix, disonF1);
1653
1654 if (disonF1) {
1655 BRepBlend_ChAsym Func(S1,S2,HGuide);
1656 BRepBlend_ChAsymInv FInv(S1,S2,HGuide);
1657 Func.Set(d1, angle, Ch);
1658 FInv.Set(d1, angle, Ch);
1659
1660 done = ComputeData(Data,HGuide,Spine,lin,S1,I1,S2,I2,Func,FInv,
1661 PFirst,MaxStep,Fleche,TolGuide,First,Last,
1662 Inside,Appro,Forward,Soldep,intf,intl,
1663 gd1,gd2,gf1,gf2,RecOnS1,RecOnS2);
1664
1665 if(!done) return Standard_False; // ratrappage possible PMN 14/05/1998
1666 done = CompleteData(Data,Func,lin,S1,S2,Or,gd1,gd2,gf1,gf2);
81bba717 1667 if(!done) Standard_Failure::Raise("PerformSurf : Fail of approximation!");
7fd59977 1668 }
1669 else {
1670 Standard_Real Rtemp;
1671 BRepBlend_ChAsym Func(S2, S1, HGuide);
1672 BRepBlend_ChAsymInv FInv(S2, S1,HGuide);
1673 Func.Set(d1, angle, Ch);
1674 FInv.Set(d1, angle, Ch);
1675
1676 Rtemp = Soldep(1);
1677 Soldep(1) = Soldep(3);
1678 Soldep(3) = Rtemp;
1679 Rtemp = Soldep(2);
1680 Soldep(2) = Soldep(4);
1681 Soldep(4) = Rtemp;
1682
1683 TopAbs_Orientation Or2 = S2->ChangeSurface().Face().Orientation();
1684
1685 done = ComputeData(Data,HGuide,Spine,lin,S2,I2,S1,I1,Func,FInv,
1686 PFirst,MaxStep,Fleche,TolGuide,First,Last,
1687 Inside,Appro,Forward,Soldep,intf,intl,
1688 gd2,gd1,gf2,gf1,RecOnS2,RecOnS1);
1689
1690 ChFiDS_CommonPoint tmp = Data->VertexFirstOnS1();
1691 Data->ChangeVertexFirstOnS1() = Data->VertexFirstOnS2();
1692 Data->ChangeVertexFirstOnS2() = tmp;
1693 tmp = Data->VertexLastOnS1();
1694 Data->ChangeVertexLastOnS1() = Data->VertexLastOnS2();
1695 Data->ChangeVertexLastOnS2() = tmp;
1696 if(!done) return Standard_False; // ratrappage possible PMN 14/05/1998
1697 done = CompleteData(Data,Func,lin,S1,S2,Or2,gd1,gd2,gf1,gf2, Standard_True);
81bba717 1698 if(!done) Standard_Failure::Raise("PerformSurf : Fail of approximation!");
7fd59977 1699 }
1700
1701 }
1702 return Standard_True;
1703}
1704void ChFi3d_ChBuilder::PerformSurf(ChFiDS_SequenceOfSurfData& ,
1705 const Handle(ChFiDS_HElSpine)& ,
1706 const Handle(ChFiDS_Spine)& ,
1707 const Standard_Integer ,
1708 const Handle(BRepAdaptor_HSurface)& ,
1709 const Handle(Adaptor3d_TopolTool)& ,
1710 const Handle(BRepAdaptor_HCurve2d)& ,
1711 const Handle(BRepAdaptor_HSurface)& ,
1712 const Handle(BRepAdaptor_HCurve2d)& ,
1713 Standard_Boolean& ,
1714 const Handle(BRepAdaptor_HSurface)& ,
1715 const Handle(Adaptor3d_TopolTool)& ,
1716 const TopAbs_Orientation ,
1717 const Standard_Real ,
1718 const Standard_Real ,
1719 const Standard_Real ,
1720 Standard_Real& ,
1721 Standard_Real& ,
1722 const Standard_Boolean ,
1723 const Standard_Boolean ,
1724 const Standard_Boolean ,
1725 const Standard_Boolean ,
1726 const Standard_Boolean ,
1727 const Standard_Boolean ,
1728 const math_Vector& )
1729{
1730 Standard_Failure::Raise("PerformSurf Not Implemented");
1731}
1732void ChFi3d_ChBuilder::PerformSurf(ChFiDS_SequenceOfSurfData& ,
1733 const Handle(ChFiDS_HElSpine)& ,
1734 const Handle(ChFiDS_Spine)& ,
1735 const Standard_Integer ,
1736 const Handle(BRepAdaptor_HSurface)& ,
1737 const Handle(Adaptor3d_TopolTool)& ,
1738 const TopAbs_Orientation ,
1739 const Handle(BRepAdaptor_HSurface)& ,
1740 const Handle(Adaptor3d_TopolTool)& ,
1741 const Handle(BRepAdaptor_HCurve2d)& ,
1742 const Handle(BRepAdaptor_HSurface)& ,
1743 const Handle(BRepAdaptor_HCurve2d)& ,
1744 Standard_Boolean& ,
1745 const Standard_Real ,
1746 const Standard_Real ,
1747 const Standard_Real ,
1748 Standard_Real& ,
1749 Standard_Real& ,
1750 const Standard_Boolean ,
1751 const Standard_Boolean ,
1752 const Standard_Boolean ,
1753 const Standard_Boolean ,
1754 const Standard_Boolean ,
1755 const Standard_Boolean ,
1756 const math_Vector& )
1757{
1758 Standard_Failure::Raise("PerformSurf Not Implemented");
1759
1760}
1761void ChFi3d_ChBuilder::PerformSurf(ChFiDS_SequenceOfSurfData& ,
1762 const Handle(ChFiDS_HElSpine)& ,
1763 const Handle(ChFiDS_Spine)& ,
1764 const Standard_Integer ,
1765 const Handle(BRepAdaptor_HSurface)& ,
1766 const Handle(Adaptor3d_TopolTool)& ,
1767 const Handle(BRepAdaptor_HCurve2d)& ,
1768 const Handle(BRepAdaptor_HSurface)& ,
1769 const Handle(BRepAdaptor_HCurve2d)& ,
1770 Standard_Boolean& ,
1771 const TopAbs_Orientation ,
1772 const Handle(BRepAdaptor_HSurface)& ,
1773 const Handle(Adaptor3d_TopolTool)& ,
1774 const Handle(BRepAdaptor_HCurve2d)& ,
1775 const Handle(BRepAdaptor_HSurface)& ,
1776 const Handle(BRepAdaptor_HCurve2d)& ,
1777 Standard_Boolean& ,
1778 const TopAbs_Orientation ,
1779 const Standard_Real ,
1780 const Standard_Real ,
1781 const Standard_Real ,
1782 Standard_Real& ,
1783 Standard_Real& ,
1784 const Standard_Boolean ,
1785 const Standard_Boolean ,
1786 const Standard_Boolean ,
1787 const Standard_Boolean ,
1788 const Standard_Boolean ,
1789 const Standard_Boolean ,
1790 const Standard_Boolean ,
1791 const math_Vector& )
1792{
1793 Standard_Failure::Raise("PerformSurf Not Implemented");
1794
1795}
1796//=======================================================================
1797//function : ExtentOneCorner
1798//purpose : extends the spine of the stripe S on the side of the vertex V
81bba717 1799// PMN : 28/11/97 : Reproduces the code of fillets, and it seems to work better...
7fd59977 1800//=======================================================================
1801
1802void ChFi3d_ChBuilder::ExtentOneCorner(const TopoDS_Vertex& V,
1803 const Handle(ChFiDS_Stripe)& S)
1804{
1805 Standard_Integer Sens = 0;
1806 Standard_Real Coeff = 0.5;
1807 Handle(ChFiDS_Spine) Spine = S->Spine();
1808 ChFi3d_IndexOfSurfData(V,S,Sens);
81bba717 1809 if (Spine->IsTangencyExtremity((Sens == 1))) return; //No extension on queue
7fd59977 1810 Standard_Real dU = Spine->LastParameter(Spine->NbEdges());
1811 if (Sens == 1) {
1812 Spine->SetFirstParameter(-dU*Coeff);
1813 Spine->SetFirstTgt(0.);
1814 }
1815 else {
1816 Spine->SetLastParameter(dU*(1.+Coeff));
1817 Spine->SetLastTgt(dU);
1818 }
1819/*
1820 Standard_Integer Sens;
1821 Standard_Boolean isfirst;
1822 Standard_Integer Iedge = 1;
1823 Standard_Real d1, d2;
1824
1825 Handle(ChFiDS_Spine) Spine = S->Spine();
1826 Handle(ChFiDS_ChamfSpine)
1827 chsp = Handle(ChFiDS_ChamfSpine)::DownCast(Spine);
1828 chsp->Dists(d1,d2);
1829 Standard_Integer IE = ChFi3d_IndexOfSurfData(V,S,Sens);
1830 isfirst = (Sens == 1);
1831 if (!isfirst)
1832 Iedge = Spine->NbEdges();
1833
1834 TopTools_ListIteratorOfListOfShape It, Jt;
1835 TopoDS_Edge E1, E2, Ec;
1836 TopoDS_Face F1, F2, Fc;
1837 TopoDS_Edge EdgeSp = Spine->Edges(Iedge);
1838
1839 ConexFaces(Spine,Iedge,F1,F2);
1840
1841 for (Jt.Initialize(myVEMap(V));Jt.More();Jt.Next()) {
1842 Ec = TopoDS::Edge(Jt.Value());
1843 if (!Ec.IsSame(EdgeSp)){
1844 for (It.Initialize(myEFMap(Ec));It.More();It.Next()) {
1845 Fc = TopoDS::Face(It.Value());
1846 if (Fc.IsSame(F1))
1847 E1 = Ec;
1848 else if (Fc.IsSame(F2))
1849 E2 = Ec;
1850 }
1851 }
1852 }
1853
1854 gp_Vec tg1, tg2, tgsp;
1855 gp_Pnt tmp, ptgui;
1856 Spine->D1(Spine->Absc(V),ptgui,tgsp);
1857 if (isfirst)
1858 tgsp.Reverse();
1859
1860 // tg1
1861 BRepAdaptor_Curve curv;
1862 curv.Initialize(E1);
1863 curv.D1(curv.FirstParameter(),tmp,tg1); //pour eviter les projections
1864 tg1.Reverse();
1865 // pbm d'erreurs d'approx : baisser la tolerance
1866 if( !tmp.IsEqual(ptgui,tolesp*1.e2) )
1867 curv.D1(curv.LastParameter(),tmp,tg1);
1868
1869 // tg2
1870 curv.Initialize(E2);
1871 curv.D1(curv.FirstParameter(),tmp,tg2);
1872 tg2.Reverse();
1873 if( !tmp.IsEqual(ptgui,tolesp*1.e2) )
1874 curv.D1(curv.LastParameter(),tmp,tg2);
1875
1876 // calcul de dspine
1877 Standard_Real dspine;
1878 Standard_Real d1plus = 0.;
1879 Standard_Real d2plus = 0.;
1880
1881 Standard_Real sinalpha = tg1.Dot(tgsp);
1882 if (sinalpha < 0.){
1883 Standard_Real cosalpha = Sqrt(1 - sinalpha*sinalpha);
1884 d1plus = -d1*sinalpha/cosalpha;
1885 }
1886 sinalpha = tg2.Dot(tgsp);
1887 if (sinalpha < 0.){
1888 Standard_Real cosalpha = Sqrt(1 - sinalpha*sinalpha);
1889 d2plus = -d2*sinalpha/cosalpha;
1890 }
1891 dspine = d1plus;
1892 if (d2plus > d1plus)
1893 dspine = d2plus;
1894
1895 dspine *=1.5;
1896
1897 // ExtentOneCorner
1898 if (isfirst) {
1899 Spine->SetFirstParameter(-dspine);
1900 Spine->SetFirstTgt(0.);
1901 }
1902 else{
1903 Standard_Real param = Spine->LastParameter(Spine->NbEdges());
1904 Spine->SetLastParameter(param+dspine);
1905 Spine->SetLastTgt(param);
1906 } */
1907}
1908
1909
1910
1911//=======================================================================
1912//function : ExtentTwoCorner
1913//purpose : extends the spines of the stripes contained in the list LS,
1914// on the side of the vertex V
1915//=======================================================================
1916
1917
1918void ChFi3d_ChBuilder::ExtentTwoCorner(const TopoDS_Vertex& V,
1919 const ChFiDS_ListOfStripe& LS)
1920{
7fd59977 1921 Standard_Integer Sens = 0;
7fd59977 1922 ChFiDS_ListIteratorOfListOfStripe itel(LS);
1923 Standard_Boolean FF = Standard_True;
1924 Standard_Boolean isfirst[2];
1925 Standard_Integer Iedge[2];
1926 Iedge[0] = 1;
1927 Iedge[1] = 1;
1928 Handle(ChFiDS_Stripe) Stripe[2];
1929 Handle(ChFiDS_Spine) Spine[2];
1930
1931 Standard_Integer i = 0;
1932 for (; itel.More(); itel.Next(),i++) {
1933 ChFi3d_IndexOfSurfData(V,itel.Value(),Sens);
1934 if (!FF)
1935 if ( Stripe[1] == itel.Value())
1936 Sens = -Sens;
1937
1938 Stripe[i] = itel.Value();
1939 isfirst[i] = (Sens == 1);
1940 Spine[i] = Stripe[i]->Spine();
1941 if( !isfirst[i] )
1942 Iedge[i] = Spine[i]->NbEdges();
1943 FF = Standard_False;
1944 }
1945
1946
1947 Handle(ChFiDS_ChamfSpine) chsp[2];
d20d815b 1948 Standard_Real d[4], dis[2] = { 0.0, 0.0 };
7fd59977 1949 Standard_Integer j;
1950 TopoDS_Face F[4];
1951 Standard_Real tmpang, tmd;
1952 Standard_Boolean disonF1;
1953
1954
1955 for (i=0, j=0; i<2; i++, j += 2) {
1956 chsp[i] = Handle(ChFiDS_ChamfSpine)::DownCast(Spine[i]);
1957 ConexFaces(Spine[i],Iedge[i],F[j],F[j+1]);
1958
1959 if (chsp[i]->IsChamfer() == ChFiDS_Sym) {
1960 chsp[i]->GetDist(d[j]);
1961 d[j+1] = d[j];
1962 }
1963 else if (chsp[i]->IsChamfer() == ChFiDS_TwoDist) {
1964 chsp[i]->Dists(d[j],d[j+1]);
1965 }
1966 else {
1967 chsp[i]->GetDistAngle(tmd, tmpang, disonF1);
81bba717 1968 // an approximate calculation of distance 2 is done
7fd59977 1969 if (disonF1) {
1970 d[j] = tmd;
1971 d[j+1] = tmd * tan(tmpang);
1972 }
1973 else
1974 {
1975 d[j] = tmd * tan(tmpang);
1976 d[j+1] = tmd;
1977 }
1978 }
1979
1980 }
1981
1982 Standard_Boolean notfound = Standard_True;
1983 i = 0;
1984 while (notfound && (i<2)) {
1985 j = 0;
1986 while (notfound && (j<2)) {
1987 if (F[i].IsSame(F[j+2])) {
1988 dis[0] = d[i];
1989// dOnArc[0] = d[(i+1)%2];
1990
1991 dis[1] = d[j + 2];
1992// dOnArc[1] = d[(j+1)%2 + 2];
1993 notfound = Standard_False;
1994 }
1995 j++;
1996 }
1997 i++;
1998 }
1999 // ExtentTwoCorner
2000
2001 ChFiDS_State State[2];
2002
2003 for (i=0; i<2; i++) {
2004 if (isfirst[i])
2005 State[i] = Spine[i]->FirstStatus();
2006 else
2007 State[i] = Spine[i]->LastStatus();
2008 }
2009
2010 if (State[0] == ChFiDS_AllSame ){
2011/*
81bba717 2012 // The greatest intersection of the chamfer is found (on the incident edge)
2013 // with the face at end
7fd59977 2014 i = 0;
2015 j = 1;
2016 if(dOnArc[j] > dOnArc[i]) {
2017 Standard_Integer temp = i;
2018 i = j;
2019 j = temp;
2020 }
2021 ExtentOneCorner( V, Stripe[i] ); */
2022
81bba717 2023 // it is necessary that two chamfers touch the face at end
7fd59977 2024 for (j=0; j<2; j++)
2025 ExtentOneCorner( V, Stripe[j] );
2026 }
2027 else if ((State[0] == ChFiDS_OnSame) && (State[1] == ChFiDS_OnSame)) {
2028
2029 ExtentSpineOnCommonFace(Spine[0],Spine[1],V,dis[0],dis[1],
2030 isfirst[0],isfirst[1]);
2031 }
2032
2033}
2034
2035//=======================================================================
2036//function : ExtentThreeCorner
2037//purpose :
2038//=======================================================================
2039
2040void ChFi3d_ChBuilder::ExtentThreeCorner(const TopoDS_Vertex& V,
2041 const ChFiDS_ListOfStripe& LS)
2042{
7fd59977 2043 Standard_Integer Sens = 0;
7fd59977 2044 ChFiDS_ListOfStripe check;
2045 Standard_Boolean isfirst[3];
2046 Standard_Integer Iedge[3];
2047 Iedge[0] = 1;
2048 Iedge[1] = 1;
2049 Iedge[2] = 1;
2050 Handle(ChFiDS_Spine) Spine[3];
2051
2052 Standard_Integer i = 0;
2053 for(ChFiDS_ListIteratorOfListOfStripe itel(LS); itel.More(); itel.Next(), i++) {
2054 Handle(ChFiDS_Stripe) Stripe = itel.Value();
2055 ChFi3d_IndexOfSurfData(V,Stripe,Sens);
2056 for(ChFiDS_ListIteratorOfListOfStripe ich(check); ich.More(); ich.Next()){
2057 if(Stripe == ich.Value()){
2058 Sens = -Sens;
2059 break;
2060 }
2061 }
2062
2063 isfirst[i] = (Sens == 1);
2064 Spine[i] = Stripe->Spine();
2065 if( !isfirst[i] )
2066 Iedge[i] = Spine[i]->NbEdges();
2067
2068 check.Append(Stripe);
2069 }
2070
2071 Standard_Real d[3][2], tmd, tmpangle;
2072 Standard_Boolean disonF1;
2073 Standard_Integer j;
2074 TopoDS_Face F[3][2];
2075
2076 Handle(ChFiDS_ChamfSpine) chsp[3];
2077
2078 for (i=0; i<3; i++) {
2079 chsp[i] = Handle(ChFiDS_ChamfSpine)::DownCast(Spine[i]);
2080 ConexFaces(Spine[i],Iedge[i],F[i][0],F[i][1]);
2081
2082 if (chsp[i]->IsChamfer() == ChFiDS_Sym) {
2083 chsp[i]->GetDist(d[i][0]);
2084 d[i][1] = d[i][0];
2085 }
2086 else if (chsp[i]->IsChamfer() == ChFiDS_TwoDist) {
2087 chsp[i]->Dists(d[i][0],d[i][1]);
2088 }
2089 else {
2090 chsp[i]->GetDistAngle(tmd, tmpangle, disonF1);
81bba717 2091 // an approximate calculation of distance 2 is done
7fd59977 2092
2093 if (disonF1) {
2094 d[i][0] = tmd;
2095 d[i][1] = tmd * tan(tmpangle);
2096 }
2097 else {
2098 d[i][0] = tmd * tan(tmpangle);
2099 d[i][1] = tmd;
2100 }
2101 }
2102 }
2103
2104
81bba717 2105 // dis[i][j] distance from chamfer i on the common face with
2106 // chamfer j
7fd59977 2107 Standard_Real dis[3][3];
2108
2109 for (i=0; i<3; i++) {
2110// for (Standard_Integer ii=0; ii<3; ii++) {
2111// j = (i+ii)%3;
2112 j = (i+1)%3;
2113 Standard_Boolean notfound = Standard_True;
2114 Standard_Integer k, l;
2115 k = 0;
2116 while (notfound && (k<2)) {
2117 l = 0;
2118 while (notfound && (l<2)) {
2119 if (F[i][k].IsSame(F[j][l])) {
2120 dis[i][j] = d[i][k];
2121 dis[j][i] = d[j][l];
2122 notfound = Standard_False;
2123 }
2124 l++;
2125 }
2126 k++;
2127 }
2128// }
2129 }
2130
2131 //ExtentThreeCorner
2132 for (i=0; i<3; i++) {
2133 j = (i+1)%3;
2134 ExtentSpineOnCommonFace(Spine[i],Spine[j],V,dis[i][j],dis[j][i],
2135 isfirst[i],isfirst[j]);
2136 }
2137
2138}
2139
2140//=======================================================================
2141//function : SetRegul
2142//purpose :
2143//=======================================================================
2144
2145void ChFi3d_ChBuilder::SetRegul()
2146
2147{
2148 ChFiDS_ListIteratorOfRegularities it;
2149 TopTools_ListIteratorOfListOfShape itc;
2150 TopTools_ListIteratorOfListOfShape its1;
2151 TopTools_ListIteratorOfListOfShape its2;
2152 BRepAdaptor_Surface S;
2153 BRepAdaptor_Curve2d PC;
2154 Standard_Real u,v,t;
2155 gp_Pnt p;
2156 gp_Vec n1,n2,du,dv;
2157 BRep_Builder B;
c6541a0c 2158 Standard_Real Seuil = M_PI/360.;
7fd59977 2159 Standard_Real Seuil2 = Seuil * Seuil;
2160 for (it.Initialize(myRegul); it.More(); it.Next()){
2161 const ChFiDS_Regul& reg = it.Value();
2162 itc.Initialize(myCoup->NewEdges(reg.Curve()));
2163 if(itc.More()){
2164 TopoDS_Edge E = TopoDS::Edge(itc.Value());
2165 if(reg.IsSurface1() && reg.IsSurface2()){
2166 its1.Initialize(myCoup->NewFaces(reg.S1()));
2167 its2.Initialize(myCoup->NewFaces(reg.S2()));
2168 if(its1.More() && its2.More()){
2169 TopoDS_Face F1 = TopoDS::Face(its1.Value());
2170 TopoDS_Face F2 = TopoDS::Face(its2.Value());
2171 S.Initialize(F1,Standard_False);
2172 PC.Initialize(E,F1);
2173 t = 0.5*(PC.FirstParameter() + PC.LastParameter());
2174 PC.Value(t).Coord(u,v);
2175 S.D1(u,v,p,du,dv);
2176 n1 = du.Crossed(dv);
2177
2178 S.Initialize(F2,Standard_False);
2179 PC.Initialize(E,F2);
2180 PC.Value(t).Coord(u,v);
2181 S.D1(u,v,p,du,dv);
2182 n2 = du.Crossed(dv);
2183
2184 if(n1.SquareMagnitude() > 1.e-14 && n2.SquareMagnitude() > 1.e-14){
2185 n1.Normalize();
2186 n2.Normalize();
2187 Standard_Real sina2 = n1.Crossed(n2).SquareMagnitude();
2188 if(sina2 < Seuil2) {
2189 GeomAbs_Shape cont = ChFi3d_evalconti(E,F1,F2);
2190 B.Continuity(E,F1,F2,cont);
2191 }
2192 }
2193 }
2194 }
2195 }
2196 }
2197}
2198
2199//=======================================================================
2200//function : ConexFaces
81bba717 2201//purpose : F1, F2 are connected to edge so that F1 corresponds to distance
7fd59977 2202//=======================================================================
2203
2204void ChFi3d_ChBuilder::ConexFaces (const Handle(ChFiDS_Spine)& Spine,
2205 const Standard_Integer IEdge,
2206 TopoDS_Face& F1,
2207 TopoDS_Face& F2) const
2208{
2209 BRepAdaptor_Surface Sb1,Sb2;
2210 TopAbs_Orientation tmp1,tmp2;
2211 Standard_Integer RC,Choix;
2212 TopoDS_Face f1,f2,ff1,ff2;
2213
81bba717 2214 //calculate the reference orientation
7fd59977 2215 // ChFi3d_Builder::StripeOrientations is private
2216 SearchCommonFaces(myEFMap,Spine->Edges(1),ff1,ff2);
2217 ff1.Orientation(TopAbs_FORWARD);
2218 Sb1.Initialize(ff1);
2219 ff2.Orientation(TopAbs_FORWARD);
2220 Sb2.Initialize(ff2);
2221 RC = ChFi3d::ConcaveSide(Sb1,Sb2,Spine->Edges(1),tmp1,tmp2);
2222
81bba717 2223 //calculate the connected faces
7fd59977 2224 SearchCommonFaces(myEFMap,Spine->Edges(IEdge),f1,f2);
2225 Sb1.Initialize(f1);
2226 Sb2.Initialize(f2);
2227 Choix = ChFi3d::ConcaveSide(Sb1,Sb2,Spine->Edges(IEdge),tmp1,tmp2);
2228
2229 if (RC%2 != Choix%2) {
2230 F1 = f2;
2231 F2 = f1;
2232 }
2233 else {
2234 F1 = f1;
2235 F2 = f2;
2236 }
2237}
2238
2239
2240//=======================================================================
2241//function : FindChoiceDistAngle
81bba717 2242//purpose : F1, F2 connected to the edge so that F1 corresponds to distance
7fd59977 2243//=======================================================================
2244
2245Standard_Integer ChFi3d_ChBuilder::FindChoiceDistAngle(const Standard_Integer Choice,
2246 const Standard_Boolean DisOnF1) const
2247{
7fd59977 2248 Standard_Integer ch = 0;
7fd59977 2249 if (!DisOnF1) {
2250
2251 switch (Choice) {
2252 case 1 : ch = 2;
2253 break;
2254 case 2 : ch = 1;
2255 break;
2256 case 3 : ch = 8;
2257 break;
2258 case 4 : ch = 7;
2259 break;
2260 case 5 : ch = 6;
2261 break;
2262 case 6 : ch = 5;
2263 break;
2264 case 7 : ch = 4;
2265 break;
2266 case 8 : ch = 3;
2267 break;
2268 }
2269
2270 }
2271 else
2272 ch = Choice;
2273
2274 return ch;
2275}