2 // Created: Tue Sep 22 17:54:07 1992
3 // Author: Gilles DEBARBOUILLE
7 #include <MAT_Edge.hxx>
8 #include <MAT_ListOfEdge.hxx>
9 #include <MAT_Bisector.hxx>
10 #include <MAT_ListOfBisector.hxx>
11 #include <TColStd_DataMapOfIntegerInteger.hxx>
12 #include <TColStd_Array1OfInteger.hxx>
13 #include <MAT_DataMapOfIntegerBisector.hxx>
14 #include <Precision.hxx>
16 //========================================================================
19 //========================================================================
23 thenumberofbisectors = 0;
28 //========================================================================
29 // function : CreateMat
30 // purpose : Calcul des lieux Bisecteurs.
32 // Structure de la carte.
33 // ======================
34 // La carte des lieux bisecteurs se presente sous la forme d un ou plusieurs
35 // arbres de bisectrices.
36 // ( un arbre, si calcul a l interieur du contour, plusieurs sinon).
38 // Les branches de plus bas niveau de l arbre separent deux elements voisins
41 // Principe de l algorithme.
42 // -------------------------
43 // l arbre est construit des branches les plus basses vers les plus hautes.
45 // 0 . Calcul des bisectrices entre elements voisins du contour.
46 // 1 . Elimination de certains element du contour => nouveau contour
49 // Principales etapes de l algorithme.
50 // ===================================
52 // etape 1: Initialisation de l algorithme .
53 // -----------------------------------------
54 // Recuperation via le tool du nombre d'elements sur le contour
55 // Initialisation de <theedgelist>, un edge correspond a chaque
56 // element du contour.
58 // etape 2 : Boucle principale.
59 // ----------------------------
60 // 0 - Tant que Nombre d'edge > 1
62 // 1. Pour chaque edge: construction de la bissectrice entre l edge
63 // et l edge suivante.
64 // La bissectrice est semi_infinie, elle est soit trimmee par le
65 // point commun des deux edges, soit par l intersection de deux
66 // bissectrices antecedentes.
68 // 2. Intersection des Bisectrices issue du meme edge
69 // => une bisectrice est intersectee avec sa voisine a gauche
70 // et sa voisine a droite.
72 // 3. Analyse des intersections.
73 // Si pas d'intersection entre deux bisectrices B1 et B2
74 // - Recherche de l intersection la plus basse de B1 avec les
75 // Bisectrices antecedentes a B2 du cote de B1. Soit Bi la
76 // bissectrice intersectee. Toutes les bissectrices constituant la
77 // branche qui relie B2 a Bi sont marquees a effacer
80 // 4. Suppresion des bisectrices a effacer.
81 // une bisectrise est a effacer :
82 // - Anulation de l intersection dont la bissectrice est issue
83 // => Prolongement des deux bisectrices posterieures.
84 // - Reinsertion des edge correspondant dans <theedgelist>.
86 // 5. Pour chaque edge, analyse des distances entre les points d inter
88 // B1 B2 les bisectrices liee a l edge
89 // Soit P0 le point d intersection des bissectrices .
90 // Soit P1 le point d intersection de B1 avec son autre voisine .
91 // Soit P2 le point d intersection de B2 avec son autre voisine .
93 // si sur B1 le parametre de P0 < parametre de P1 et
94 // si sur B2 le parametre de P0 < parametre de P2
95 // alors suppression de l edge de la liste des edges <theedgelist>.
97 // rq: le parametre sur une bissectirce est croissant par rapport
98 // a la distance du point courant aux edges.
100 // 6. Si aucune edge est elimine alors sortie de la boucle principale.
104 // etape 3 : Creation des racines des arbres de bisectrices.
105 // ---------------------------------------------------------
106 // Recuperation des bissectrices calculees lors du dernier passage
109 //========================================================================
110 void MAT_Mat::CreateMat(Tool& atool)
114 Standard_Boolean Icontinue;
117 Standard_Boolean interrupt = Standard_False;
119 Handle(MAT_Edge) edgetoremove;
120 Handle(MAT_Edge) previousedge,currentedge;
122 Standard_Integer noofbisectorstoremove;
123 Handle(MAT_Bisector) firstbisector,secondbisector;
124 Handle(MAT_Edge) edge;
125 Standard_Integer intersectionpoint;
126 Standard_Integer beginbisector;
127 Standard_Integer noofbisectors;
129 Standard_Integer NbIterBis = 0;
130 Standard_Integer EvenNbIterBis = 10;
131 TColStd_Array1OfInteger EdgeNumbers(1, EvenNbIterBis+1);
132 EdgeNumbers.Init(-1);
133 Standard_Boolean ToNullifyNoofbisectorstoremove = Standard_False;
135 Handle(MAT_ListOfBisector) currentbisectorlist;
137 Handle(MAT_Bisector) bisectortoremove,lastbisector,currentbisector;
138 Handle(MAT_Bisector) previousbisector;
140 Standard_Integer i,j,k,narea,shift,compact,all;
141 Standard_Integer noofedges;
142 Standard_Integer NumberMaxOfIte;
143 Standard_Real toleranceofconfusion;
145 noofedges = atool.NumberOfItems();
146 toleranceofconfusion = atool.ToleranceOfConfusion();
147 NumberMaxOfIte = noofedges*noofedges;
149 Standard_Integer* firstarea = new Standard_Integer[noofedges];
150 Standard_Integer* lastarea = new Standard_Integer[noofedges];
151 Standard_Integer* noofarea = new Standard_Integer[noofedges];
154 cout <<" Erreur d allocation "<<endl;
158 Standard_Integer parama[2];
159 Standard_Integer paramb[2];
161 // -----------------------------------------
162 // Initialisation et remise a zero des maps.
163 // -----------------------------------------
164 bisectoronetoremove.Clear();
165 bisectortwotoremove.Clear();
166 typeofbisectortoremove.Clear();
169 isDone = Standard_True;
170 noofbisectors = noofedges;
173 // --------------------------------------------------------------------
174 // Construction de <theedgelist> un edge correspond a un element simple
176 // --------------------------------------------------------------------
177 theedgelist = new MAT_ListOfEdge();
179 for(i=0; i<noofedges; i++) {
180 edge = new MAT_Edge();
181 edge->EdgeNumber(i+1);
183 theedgelist->BackAdd(edge);
188 //---------------------------------------------------
189 // Initialisation des bissectrices issues du contour.
190 //---------------------------------------------------
192 theedgelist->First();
194 for(i=0; i<theedgelist->Number(); i++) {
195 bisectormap.Bind(i,new MAT_Bisector());
196 bisectormap(i)->IndexNumber(i);
197 bisectormap(i)->FirstEdge(theedgelist->Current());
198 bisectormap(i)->FirstVector
199 (atool.TangentBefore(theedgelist->Current()->EdgeNumber()));
201 bisectormap(i)->SecondEdge(theedgelist->Current());
202 bisectormap(i)->IssuePoint
203 (atool.FirstPoint(theedgelist->Current()->EdgeNumber(),Dist));
204 bisectormap(i)->DistIssuePoint(Dist);
205 bisectormap(i)->SecondVector
206 (atool.TangentAfter(theedgelist->Current()->EdgeNumber()));
209 //----------------------------------------------------
210 // Affectation a chaque edge de ses deux bissectrices.
211 //----------------------------------------------------
212 theedgelist->First();
214 for(i=0; i<theedgelist->Number(); i++) {
215 theedgelist->Current()->FirstBisector
216 (bisectormap((i-1+noofbisectors)%noofbisectors));
217 theedgelist->Current()->SecondBisector
222 //===========================================================================
223 // Boucle Principale (etape 2)
224 //===========================================================================
225 Standard_Integer NumberOfIte = 0;
227 while(theedgelist->Number()>1) {
230 // ------------------------------------------------------------------
231 // Creation des geometries des bissectrices via le tool. (etape 2.1)
232 // -------------------------------------------------------------------
234 for(i=beginbisector; i<noofbisectors; i++) {
236 atool.CreateBisector(bisectormap(i));
237 thenumberofbisectors++;
240 atool.Dump(bisectormap(i)->BisectorNumber(),1);
247 // ---------------------------------------------
248 // Condition de sortie de la boucle principale.
249 // ---------------------------------------------
251 // Modified by Sergey KHROMOV - Fri Nov 17 10:28:28 2000 Begin
252 if (theedgelist->Number() < 3)
254 // Modified by Sergey KHROMOV - Fri Nov 17 10:28:37 2000 End
256 //---------------------------------------------------
257 // boucle 2 Tant qu il y a des bisectrices a effacer.
258 //---------------------------------------------------
259 while(Standard_True) {
262 noofbisectorstoremove = 0;
263 theedgelist->First();
265 //--------------------------------------------------------------
266 // Calcul des intersections des bisectrices voisines.(etape 2.2)
267 //--------------------------------------------------------------
269 if (NbIterBis <= EvenNbIterBis+1)
270 EdgeNumbers(NbIterBis) = theedgelist->Number();
273 for (k = 1; k <= EvenNbIterBis; k++)
274 EdgeNumbers(k) = EdgeNumbers(k+1);
275 EdgeNumbers(EvenNbIterBis+1) = theedgelist->Number();
277 if (EdgeNumbers(EvenNbIterBis+1) == EdgeNumbers(1))
278 ToNullifyNoofbisectorstoremove = Standard_True;
280 for(i=0; i<theedgelist->Number(); i++) {
281 edge = theedgelist->Current();
282 if(edge->Distance() == -1.) {
283 firstbisector = edge->FirstBisector();
284 secondbisector = edge->SecondBisector();
285 edge->Distance(atool.IntersectBisector
286 (firstbisector,secondbisector,intersectionpoint));
287 edge->IntersectionPoint(intersectionpoint);
289 if(edge->Distance() == Precision::Infinite()) {
290 if(firstbisector->IndexNumber() >= beginbisector ||
291 secondbisector->IndexNumber() >= beginbisector)
292 Intersect(atool,0,noofbisectorstoremove,
293 firstbisector,secondbisector );
296 if(firstbisector->IndexNumber() >= beginbisector) {
297 Intersect(atool,1,noofbisectorstoremove,
298 firstbisector,secondbisector );
300 if(secondbisector->IndexNumber() >= beginbisector) {
301 Intersect(atool,2,noofbisectorstoremove,
302 firstbisector,secondbisector );
309 //-------------------------------
310 // Test de sortie de la boucle 2.
311 //-------------------------------
313 if (ToNullifyNoofbisectorstoremove)
314 noofbisectorstoremove = 0;
315 if(noofbisectorstoremove == 0) break;
317 //---------------------------------------------------
318 // Annulation des bissectrices a effacer. (etape 2.4)
319 //---------------------------------------------------
321 for(i=0; i<noofbisectorstoremove; i++) {
323 bisectortoremove = bisectoronetoremove(i);
325 //---------------------------------------------------------------
326 // Destruction des bisectrices descendantes de <bisectortoremove>
327 // On descend dans l arbre jusqu a ce qu on atteigne
328 // <bisectortwotoremove(i).
329 //---------------------------------------------------------------
331 while(Standard_True){
334 atool.Dump(bisectortoremove->BisectorNumber(),0);
336 // ----------------------------------
337 // Annulation de <bisectortoremove>.
338 // ----------------------------------
339 thenumberofbisectors--;
340 currentbisectorlist = bisectortoremove->List();
341 currentbisectorlist->First();
342 currentbisector = currentbisectorlist->FirstItem();
343 previousedge = currentbisector->FirstEdge();
344 theedgelist->Init(previousedge);
345 previousedge->Distance(-1.);
346 previousedge->FirstBisector()->SecondParameter(Precision::Infinite());
347 previousedge->SecondBisector()->FirstParameter(Precision::Infinite());
349 //------------------------------------------
350 // Annulation des fils de <currentbisector>.
351 //------------------------------------------
353 while(currentbisectorlist->More()) {
354 currentbisector = currentbisectorlist->Current();
355 currentedge = currentbisector->SecondEdge();
357 //---------------------------------------
358 // Reinsertion de l edge dans le contour.
359 //---------------------------------------
360 theedgelist->LinkAfter(currentedge);
363 currentedge->FirstBisector(currentbisector);
364 previousedge->SecondBisector(currentbisector);
366 atool.Dump(currentbisector->BisectorNumber(),0);
369 //------------------------------------------------------
370 // Annulation de l intersection ie les fils qui
371 // ont generes l intersection sont prolonges a l infini.
372 //------------------------------------------------------
374 currentbisector->FirstParameter (Precision::Infinite());
375 currentbisector->SecondParameter(Precision::Infinite());
377 atool.TrimBisector(currentbisector);
380 atool.Dump(currentbisector->BisectorNumber(),1);
382 currentedge->Distance(-1.);
383 currentedge->FirstBisector()->SecondParameter(Precision::Infinite());
384 currentedge->SecondBisector()->FirstParameter(Precision::Infinite());
386 previousedge = currentedge;
387 currentbisectorlist->Next();
390 theedgelist->Unlink();
392 //-----------------------------------------------------------
393 // Test de sortie de la boucle d annulation des bissectrices.
394 //-----------------------------------------------------------
396 if(bisectortoremove->BisectorNumber() ==
397 bisectortwotoremove(i)->BisectorNumber()) break;
399 //-----------------------
400 // Descente dans l arbre.
401 //-----------------------
403 if(typeofbisectortoremove(i) == 1)
404 bisectortoremove = bisectortoremove->FirstBisector();
406 bisectortoremove = bisectortoremove->LastBisector();
408 } //----------------------------------------------------
409 // Fin boucle d annulation des bissectrices issue de
410 // <bisectoronetoremove(i)>.
411 //----------------------------------------------------
413 } //------------------------------------------
414 // Fin boucle d annulation des bissectrices.
415 //-------------------------------------------
424 // ----------------------------------------------------------------------
425 // Analyse des parametres des intersections sur les bisectrices de chaque
426 // edge et determination des portions de contour a supprimees. (etape 2.5)
427 // ----------------------------------------------------------------------
429 theedgelist->First();
431 currentbisector = theedgelist->Current()->FirstBisector();
432 if (currentbisector->FirstParameter() == Precision::Infinite() &&
433 currentbisector->SecondParameter() == Precision::Infinite()) {
437 else if(currentbisector->FirstParameter() == Precision::Infinite()) {
441 else if(currentbisector->SecondParameter() == Precision::Infinite()) {
445 else if (atool.Distance(currentbisector,
446 currentbisector->FirstParameter(),
447 currentbisector->SecondParameter())
448 > toleranceofconfusion) {
449 if((currentbisector->FirstParameter() -
450 currentbisector->SecondParameter())
451 *currentbisector->Sense() > 0.) {
467 for(i=0; i<theedgelist->Number(); i++) {
468 currentbisector = theedgelist->Current()->SecondBisector();
469 if (currentbisector->FirstParameter() == Precision::Infinite() &&
470 currentbisector->SecondParameter() == Precision::Infinite()) {
474 else if(currentbisector->FirstParameter() == Precision::Infinite()) {
478 else if(currentbisector->SecondParameter() == Precision::Infinite()) {
482 else if (atool.Distance(currentbisector,
483 currentbisector->FirstParameter(),
484 currentbisector->SecondParameter())
485 > toleranceofconfusion) {
486 if((currentbisector->FirstParameter() -
487 currentbisector->SecondParameter())
488 *currentbisector->Sense() > 0.) {
502 //-----------------------------------------------------------------
503 // Test si l edge est a enlever du contour
504 // Construction des portions de contour a eliminer.
506 // narea : nombre de portions continues du contour a eliminer.
507 // firstarea[i] : indice premier edge de la portion i.
508 // lastarea[i] : indice dernier edge de la portion i.
509 //-----------------------------------------------------------------
512 cout <<" Test sur les parametres pour elimination"<<endl;
513 cout << " Edge number :"<<theedgelist->Current()->EdgeNumber()<<endl;
516 if(paramb[0] > 0 && parama[1] > 0) {
519 cout <<" A ELIMINER "<<endl;
522 firstarea[++narea] = theedgelist->Index();
523 lastarea[narea] = firstarea[narea];
527 if(theedgelist->Index() == lastarea[narea]+1) {
532 firstarea[++narea] = theedgelist->Index();
533 lastarea[narea] = firstarea[narea];
538 parama[0] = parama[1];
539 paramb[0] = paramb[1];
546 if(lastarea[narea] == theedgelist->Number() && firstarea[0] == 1) {
547 firstarea[0] = firstarea[narea];
548 noofarea[0] = noofarea[0]+noofarea[narea];
549 compact = noofarea[narea];
556 //------------------------------------------------------------------
557 // Sortie de la boucle principale si il n y a pas d edge a eliminer.
559 //------------------------------------------------------------------
561 interrupt = Standard_True;
566 //----------------------------------------------------------------
567 // Elimination des edges a enlever du contour
568 // => Mise a jour du nouveau contour.
569 // => Creation des bissectrices entre les nouvelles edges voisines.
570 //----------------------------------------------------------------
572 beginbisector = noofbisectors;
575 if(narea == 1 && noofarea[0] == theedgelist->Number()) all = 1;
577 for(i=0; i<narea; i++) {
578 if(i == 1)shift = shift-compact;
579 theedgelist->First();
580 edgetoremove = theedgelist->Brackets(firstarea[i]-shift);
582 edgetoremove->FirstBisector()->EndPoint(edgetoremove
583 ->IntersectionPoint());
586 atool.Dump(edgetoremove->FirstBisector()->BisectorNumber(),0);
589 edgetoremove->FirstBisector()->FirstParameter
590 (edgetoremove->FirstBisector()->SecondParameter());
593 if(atool.TrimBisector(edgetoremove->FirstBisector()))
594 atool.Dump(edgetoremove->FirstBisector()->BisectorNumber(),1);
596 atool.TrimBisector(edgetoremove->FirstBisector());
599 bisectormap.Bind(noofbisectors,new MAT_Bisector());
600 bisectormap(noofbisectors)->IndexNumber(noofbisectors);
601 bisectormap(noofbisectors)->DistIssuePoint(edgetoremove->Distance());
602 bisectormap(noofbisectors)->IssuePoint(edgetoremove
603 ->IntersectionPoint());
604 bisectormap(noofbisectors)->FirstEdge(theedgelist->PreviousItem());
605 bisectormap(noofbisectors)->AddBisector(edgetoremove
608 for(j=0; j<noofarea[i]; j++) {
609 theedgelist->Unlink();
614 cout<<" Suppression de l'arete : "<<edgetoremove->EdgeNumber()<<endl;
617 if(all == 0 || j+1 != noofarea[i]) {
618 bisectormap(noofbisectors)->AddBisector(edgetoremove
621 edgetoremove->SecondBisector()->EndPoint(edgetoremove
622 ->IntersectionPoint());
625 atool.Dump(edgetoremove->SecondBisector()->BisectorNumber(),0);
628 edgetoremove->SecondBisector()->SecondParameter
629 (edgetoremove->SecondBisector()->FirstParameter());
631 if(atool.TrimBisector(edgetoremove->SecondBisector()))
632 atool.Dump(edgetoremove->SecondBisector()->BisectorNumber(),1);
634 atool.TrimBisector(edgetoremove->SecondBisector());
636 edgetoremove = theedgelist->Current();
638 bisectormap(noofbisectors)->SecondEdge(theedgelist->Current());
640 theedgelist->PreviousItem()
641 ->SecondBisector(bisectormap(noofbisectors));
642 theedgelist->Current()->FirstBisector(bisectormap(noofbisectors));
644 bisectormap(noofbisectors)->FirstVector
646 (bisectormap(noofbisectors)->FirstBisector()
647 ->BisectorNumber()));
649 bisectormap(noofbisectors)->SecondVector
651 (bisectormap(noofbisectors)->LastBisector()
652 ->BisectorNumber()));
656 theedgelist->PreviousItem()->Distance(-1);
657 theedgelist->Current()->Distance(-1);
659 theedgelist->PreviousItem()->FirstBisector()
660 ->SecondParameter(Precision::Infinite());
661 theedgelist->Current()->SecondBisector()->FirstParameter(Precision::Infinite());
664 //-----------------------------------------------------------------------
665 // Test sur le nombre d iterations :
666 // A chaque iteration est elimine un element du contour qui ne sera plus
667 // reinsere par la suite => le nombre d iterartions doit etre < au nombre
669 // Le nombre d iteration maximum est fixe a numberofedges*numberofedges.
670 //-----------------------------------------------------------------------
671 if (NumberOfIte > NumberMaxOfIte) {
672 isDone = Standard_False; //Echec calcul de la carte.
677 } //===============================================
678 // Fin Boucle Principale.
679 //===============================================
686 //----------------------------------------------
687 // interupt = True => bissectrices semi_infinies.
688 //----------------------------------------------
691 semiInfinite = Standard_True;
693 semiInfinite = Standard_False;
695 //------------------------------------------------------------------
696 // Si le nombre d edge > 1 => le nombre d edge = 2
697 // (cf test sortie boucle principale)
698 // Les deux dernieres bisectrices separent les memes edges .
699 // Soit elles sont confondues si calcul a l interieur, soit elles
700 // sont semi-Infinies (exemple : contour compose seulement de deux
702 //------------------------------------------------------------------
704 if(theedgelist->Number() > 1) { //Now this branch is never reachable
705 //because the case edgenumber = 2 is processed in the main loop
706 theedgelist->First();
707 edge = theedgelist->Current();
708 if(edge->FirstBisector()->IndexNumber() == noofbisectors-1) {
709 // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM Begin
710 if (atool.TrimBisector(edge->SecondBisector(),
711 edge->FirstBisector()->IssuePoint())) {
712 if (edge->SecondBisector()->EndPoint() == 0)
713 edge->SecondBisector()->EndPoint(edge->FirstBisector()->IssuePoint());
714 bisectormap(noofbisectors-1)->AddBisector(edge->SecondBisector());
716 semiInfinite = Standard_True;
717 // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End
720 // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM Begin
721 if (atool.TrimBisector(edge->FirstBisector(),
722 edge->SecondBisector()->IssuePoint())) {
723 if (edge->FirstBisector()->EndPoint() == 0)
724 edge->FirstBisector()->EndPoint(edge->SecondBisector()->IssuePoint());
725 bisectormap(noofbisectors-1)->AddBisector(edge->FirstBisector());
727 semiInfinite = Standard_True;
728 // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End
731 thenumberofbisectors--;
732 bisectormap(noofbisectors-1)->SecondEdge(edge);
733 bisectormap(noofbisectors-1)->BisectorNumber(-1);
738 beginbisector = noofbisectors;
739 theedgelist->First();
740 for(i=0; i<theedgelist->Number(); i++) {
741 edge = theedgelist->Current();
742 bisectormap.Bind(noofbisectors,edge->SecondBisector());
749 //---------------------------
750 // Recuperations des racines.
751 //---------------------------
753 roots = new MAT_ListOfBisector;
755 if (bisectormap(noofbisectors-1)->BisectorNumber() == -1) {
756 roots = bisectormap(noofbisectors-1)->List();
758 roots->Current()->FirstEdge()
759 ->Distance(bisectormap(noofbisectors-1)->DistIssuePoint());
762 for (i=beginbisector;i<noofbisectors;i++) {
763 roots->BackAdd(bisectormap(i));
767 //-------------------------------------
768 // Destruction des tableaux dynamiques.
769 //-------------------------------------
775 //========================================================================
776 // function : LoadBisectorsToRemove
777 // purpose : Chargement des bisectrices a effacer.
778 //========================================================================
779 void MAT_Mat::LoadBisectorsToRemove
780 ( Standard_Integer& noofbisectorstoremove,
781 const Standard_Real distance1,
782 const Standard_Real distance2,
783 const Handle(MAT_Bisector)& firstbisectortoremove1,
784 const Handle(MAT_Bisector)& firstbisectortoremove2,
785 const Handle(MAT_Bisector)& lastbisectortoremove1,
786 const Handle(MAT_Bisector)& lastbisectortoremove2 )
789 Standard_Integer found,index;
790 Handle(MAT_Bisector) firstbisectortoremove[2];
791 Handle(MAT_Bisector) lastbisectortoremove[2];
793 firstbisectortoremove[0] = firstbisectortoremove1;
794 firstbisectortoremove[1] = firstbisectortoremove2;
795 lastbisectortoremove[0] = lastbisectortoremove1;
796 lastbisectortoremove[1] = lastbisectortoremove2;
798 if (distance1 < Precision::Infinite() &&
799 distance2 == Precision::Infinite() ) index = 0;
800 else if(distance2 < Precision::Infinite() &&
801 distance1 == Precision::Infinite() ) index = 1;
805 found = noofbisectorstoremove;
806 for(int j=0; j<noofbisectorstoremove; j++) {
807 if(bisectoronetoremove(j)->BisectorNumber() ==
808 firstbisectortoremove[index]->BisectorNumber()) {
810 if(bisectortwotoremove(j)->BisectorNumber() <
811 lastbisectortoremove[index]->BisectorNumber())found = -1;
818 cout<<" first last bisector to remove :"<<
819 firstbisectortoremove[index]->BisectorNumber()<<" "<<
820 lastbisectortoremove[index]->BisectorNumber()<<endl;
822 bisectoronetoremove.Bind(found,firstbisectortoremove[index]);
823 bisectortwotoremove.Bind(found,lastbisectortoremove[index]);
824 typeofbisectortoremove.Bind(found,index+1);
826 if(found == noofbisectorstoremove)noofbisectorstoremove++;
831 //========================================================================
832 // function : Intersect
833 // purpose : Si <aside=0> Intersection de <firstbisector> avec les
834 // descendants de <secondbisector> les plus a gauche
835 // (ie secondbisector->FirstBisector()->FirstBisector...)
836 // Intersection de <secondbisector> avec les
837 // descendants de <firstbisector> les plus a droite
838 // (ie firstbisector->LastBisector()->LastBisector...)
840 // Si <aside=1> Intersection de <firstbisector> avec ses
841 // descendants les plus a gauche et les plus a droite.
843 // Si <aside=2> Intersection de <secondbisector> avec ses
844 // descendants les plus a gauche et les plus a droite.
845 //========================================================================v
846 void MAT_Mat::Intersect( Tool& atool,
847 const Standard_Integer aside,
848 Standard_Integer& noofbisectortoremove,
849 const Handle(MAT_Bisector)& firstbisector,
850 const Handle(MAT_Bisector)& secondbisector)
852 Standard_Integer bisectornumber;
853 Standard_Real distant,saveparameter;
854 Standard_Real distance[2];
855 Standard_Integer intersectionpoint;
856 Handle(MAT_Bisector) lastbisector,previousbisector;
857 Handle(MAT_Bisector) firstbisectortoremove[2];
858 Handle(MAT_Bisector) lastbisectortoremove[2];
860 distance[0] = Precision::Infinite();
861 distance[1] = Precision::Infinite();
863 for(bisectornumber = 0; bisectornumber<2; bisectornumber++) {
865 if(bisectornumber == 0)
866 firstbisectortoremove[bisectornumber] = secondbisector;
868 firstbisectortoremove[bisectornumber] = firstbisector;
870 else if(aside == 1) {
871 firstbisectortoremove[bisectornumber] = firstbisector;
874 firstbisectortoremove[bisectornumber] = secondbisector;
877 lastbisector = firstbisectortoremove[bisectornumber];
880 previousbisector = firstbisectortoremove[bisectornumber];
883 if(firstbisectortoremove[bisectornumber]->List()->IsEmpty())continue;
885 if(bisectornumber == 0)
886 previousbisector = firstbisectortoremove[bisectornumber]
889 previousbisector = firstbisectortoremove[bisectornumber]
893 distant = distance[bisectornumber];
894 while(!previousbisector->List()->IsEmpty()) {
896 if(bisectornumber == 0)
897 previousbisector = previousbisector->FirstBisector();
899 previousbisector = previousbisector->LastBisector();
901 if(aside == 1 || (aside == 0 && bisectornumber == 0)) {
902 saveparameter = previousbisector->FirstParameter();
903 distant = atool.IntersectBisector
904 (firstbisector,previousbisector,intersectionpoint);
905 previousbisector->FirstParameter(saveparameter);
908 saveparameter = previousbisector->SecondParameter();
909 distant = atool.IntersectBisector
910 (previousbisector,secondbisector,intersectionpoint);
911 previousbisector->SecondParameter(saveparameter);
914 if(distant < Precision::Infinite()) {
915 distance[bisectornumber] = distant;
916 lastbisectortoremove[bisectornumber] = lastbisector;
919 lastbisector = previousbisector;
923 //---------------------------------------
924 // Chargement des bissectrices a effacer.
925 //---------------------------------------
927 LoadBisectorsToRemove(noofbisectortoremove,
928 distance[0],distance[1],
929 firstbisectortoremove[0],firstbisectortoremove[1],
930 lastbisectortoremove[0] ,lastbisectortoremove[1]);
933 //========================================================================
936 //========================================================================
942 //========================================================================
945 //========================================================================
946 Standard_Boolean MAT_Mat::More() const
948 return roots->More();
951 //========================================================================
954 //========================================================================
960 //========================================================================
961 // function : Bisector
963 //========================================================================
964 Handle(MAT_Bisector) MAT_Mat::Bisector() const
966 return roots->Current();
969 //========================================================================
970 // function : NumberOfBisectors
972 //========================================================================
973 Standard_Integer MAT_Mat::NumberOfBisectors() const
975 return thenumberofbisectors;
978 //========================================================================
979 // function : SemiInfinite
981 //========================================================================
982 Standard_Boolean MAT_Mat::SemiInfinite() const
987 //========================================================================
990 //========================================================================
991 Standard_Boolean MAT_Mat::IsDone() const