1 // Created on: 1992-09-22
2 // Created by: Gilles DEBARBOUILLE
3 // Copyright (c) 1992-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
18 #include <MAT2d_Mat2d.hxx>
19 #include <MAT2d_Tool2d.hxx>
20 #include <MAT_Bisector.hxx>
21 #include <MAT_DataMapOfIntegerBisector.hxx>
22 #include <MAT_Edge.hxx>
23 #include <MAT_ListOfBisector.hxx>
24 #include <MAT_ListOfEdge.hxx>
25 #include <Precision.hxx>
26 #include <TColStd_Array1OfInteger.hxx>
27 #include <TColStd_DataMapOfIntegerInteger.hxx>
29 //========================================================================
30 // function : MAT2d_Mat2d
32 //========================================================================
33 MAT2d_Mat2d::MAT2d_Mat2d(const Standard_Boolean IsOpenResult)
35 myIsOpenResult = IsOpenResult;
36 thenumberofbisectors = 0;
41 //========================================================================
42 // function : CreateMat
43 // purpose : Calcul des lieux Bisecteurs.
45 // Structure de la carte.
46 // ======================
47 // La carte des lieux bisecteurs se presente sous la forme d un ou plusieurs
48 // arbres de bisectrices.
49 // ( un arbre, si calcul a l interieur du contour, plusieurs sinon).
51 // Les branches de plus bas niveau de l arbre separent deux elements voisins
54 // Principe de l algorithme.
55 // -------------------------
56 // l arbre est construit des branches les plus basses vers les plus hautes.
58 // 0 . Calcul des bisectrices entre elements voisins du contour.
59 // 1 . Elimination de certains element du contour => nouveau contour
62 // Principales etapes de l algorithme.
63 // ===================================
65 // etape 1: Initialisation de l algorithme .
66 // -----------------------------------------
67 // Recuperation via le tool du nombre d'elements sur le contour
68 // Initialisation de <theedgelist>, un edge correspond a chaque
69 // element du contour.
71 // etape 2 : Boucle principale.
72 // ----------------------------
73 // 0 - Tant que Nombre d'edge > 1
75 // 1. Pour chaque edge: construction de la bissectrice entre l edge
76 // et l edge suivante.
77 // La bissectrice est semi_infinie, elle est soit trimmee par le
78 // point commun des deux edges, soit par l intersection de deux
79 // bissectrices antecedentes.
81 // 2. Intersection des Bisectrices issue du meme edge
82 // => une bisectrice est intersectee avec sa voisine a gauche
83 // et sa voisine a droite.
85 // 3. Analyse des intersections.
86 // Si pas d'intersection entre deux bisectrices B1 et B2
87 // - Recherche de l intersection la plus basse de B1 avec les
88 // Bisectrices antecedentes a B2 du cote de B1. Soit Bi la
89 // bissectrice intersectee. Toutes les bissectrices constituant la
90 // branche qui relie B2 a Bi sont marquees a effacer
93 // 4. Suppresion des bisectrices a effacer.
94 // une bisectrise est a effacer :
95 // - Anulation de l intersection dont la bissectrice est issue
96 // => Prolongement des deux bisectrices posterieures.
97 // - Reinsertion des edge correspondant dans <theedgelist>.
99 // 5. Pour chaque edge, analyse des distances entre les points d inter
100 // section et l edge.
101 // B1 B2 les bisectrices liee a l edge
102 // Soit P0 le point d intersection des bissectrices .
103 // Soit P1 le point d intersection de B1 avec son autre voisine .
104 // Soit P2 le point d intersection de B2 avec son autre voisine .
106 // si sur B1 le parametre de P0 < parametre de P1 et
107 // si sur B2 le parametre de P0 < parametre de P2
108 // alors suppression de l edge de la liste des edges <theedgelist>.
110 // rq: le parametre sur une bissectirce est croissant par rapport
111 // a la distance du point courant aux edges.
113 // 6. Si aucune edge est elimine alors sortie de la boucle principale.
117 // etape 3 : Creation des racines des arbres de bisectrices.
118 // ---------------------------------------------------------
119 // Recuperation des bissectrices calculees lors du dernier passage
122 //========================================================================
123 void MAT2d_Mat2d::CreateMatOpen(MAT2d_Tool2d& atool)
127 Standard_Boolean Icontinue;
130 Standard_Boolean interrupt = Standard_False;
132 Handle(MAT_Edge) edgetoremove;
133 Handle(MAT_Edge) previousedge,currentedge;
135 Standard_Integer noofbisectorstoremove;
136 Handle(MAT_Bisector) firstbisector,secondbisector;
137 Handle(MAT_Edge) edge;
138 Standard_Integer intersectionpoint;
139 Standard_Integer beginbisector;
140 Standard_Integer noofbisectors;
142 Standard_Integer NbIterBis = 0;
143 Standard_Integer EvenNbIterBis = 10;
144 TColStd_Array1OfInteger EdgeNumbers(1, EvenNbIterBis+1);
145 EdgeNumbers.Init(-1);
146 Standard_Boolean ToNullifyNoofbisectorstoremove = Standard_False;
148 Handle(MAT_ListOfBisector) currentbisectorlist;
150 Handle(MAT_Bisector) bisectortoremove,lastbisector,currentbisector;
151 Handle(MAT_Bisector) previousbisector;
153 Standard_Integer i,j,k,narea,shift,compact,all;
154 Standard_Integer noofedges;
155 Standard_Integer NumberMaxOfIte;
156 Standard_Real toleranceofconfusion;
158 noofedges = atool.NumberOfItems();
159 toleranceofconfusion = atool.ToleranceOfConfusion();
160 NumberMaxOfIte = noofedges*noofedges;
162 TColStd_Array1OfInteger firstarea(0, noofedges);
163 TColStd_Array1OfInteger lastarea(0, noofedges);
164 TColStd_Array1OfInteger noofarea(0, noofedges);
166 Standard_Integer parama[2];
167 Standard_Integer paramb[2];
169 // -----------------------------------------
170 // Initialisation et remise a zero des maps.
171 // -----------------------------------------
172 bisectoronetoremove.Clear();
173 bisectortwotoremove.Clear();
174 typeofbisectortoremove.Clear();
177 isDone = Standard_True;
178 noofbisectors = noofedges-1;
181 // --------------------------------------------------------------------
182 // Construction de <theedgelist> un edge correspond a un element simple
184 // --------------------------------------------------------------------
185 theedgelist = new MAT_ListOfEdge();
187 for(i=0; i<noofedges; i++) {
188 edge = new MAT_Edge();
189 edge->EdgeNumber(i+1);
191 theedgelist->BackAdd(edge);
196 //---------------------------------------------------
197 // Initialisation des bissectrices issues du contour.
198 //---------------------------------------------------
200 theedgelist->First();
202 for(i=0; i<theedgelist->Number()-1; i++) {
203 bisectormap.Bind(i,new MAT_Bisector());
204 bisectormap(i)->IndexNumber(i);
205 bisectormap(i)->FirstEdge(theedgelist->Current());
206 bisectormap(i)->FirstVector
207 (atool.TangentBefore(theedgelist->Current()->EdgeNumber(), myIsOpenResult));
209 bisectormap(i)->SecondEdge(theedgelist->Current());
210 bisectormap(i)->IssuePoint
211 (atool.FirstPoint(theedgelist->Current()->EdgeNumber(),Dist));
212 bisectormap(i)->DistIssuePoint(Dist);
213 bisectormap(i)->SecondVector
214 (atool.TangentAfter(theedgelist->Current()->EdgeNumber(), myIsOpenResult));
217 //----------------------------------------------------
218 // Affectation a chaque edge de ses deux bissectrices.
219 //----------------------------------------------------
220 theedgelist->First();
221 theedgelist->Current()->FirstBisector(bisectormap(0));
222 theedgelist->Current()->SecondBisector(bisectormap(0));
225 for(i=1; i<theedgelist->Number()-1; i++) {
226 theedgelist->Current()->FirstBisector
228 theedgelist->Current()->SecondBisector
233 theedgelist->Current()->FirstBisector(bisectormap(theedgelist->Number()-2));
234 theedgelist->Current()->SecondBisector(bisectormap(theedgelist->Number()-2));
236 //===========================================================================
237 // Boucle Principale (etape 2)
238 //===========================================================================
239 Standard_Integer NumberOfIte = 0;
241 while(theedgelist->Number()>1) {
244 // ------------------------------------------------------------------
245 // Creation des geometries des bissectrices via le tool. (etape 2.1)
246 // -------------------------------------------------------------------
248 for(i=beginbisector; i<noofbisectors; i++) {
250 atool.CreateBisector(bisectormap(i));
251 thenumberofbisectors++;
253 #ifdef OCCT_DEBUG_Mat
254 atool.Dump(bisectormap(i)->BisectorNumber(),1);
261 // ---------------------------------------------
262 // Condition de sortie de la boucle principale.
263 // ---------------------------------------------
265 // Modified by Sergey KHROMOV - Fri Nov 17 10:28:28 2000 Begin
266 if (theedgelist->Number() < 3)
268 // Modified by Sergey KHROMOV - Fri Nov 17 10:28:37 2000 End
270 //---------------------------------------------------
271 // boucle 2 Tant qu il y a des bisectrices a effacer.
272 //---------------------------------------------------
276 noofbisectorstoremove = 0;
277 theedgelist->First();
280 //--------------------------------------------------------------
281 // Calcul des intersections des bisectrices voisines.(etape 2.2)
282 //--------------------------------------------------------------
284 if (NbIterBis <= EvenNbIterBis+1)
285 EdgeNumbers(NbIterBis) = theedgelist->Number();
288 for (k = 1; k <= EvenNbIterBis; k++)
289 EdgeNumbers(k) = EdgeNumbers(k+1);
290 EdgeNumbers(EvenNbIterBis+1) = theedgelist->Number();
292 if (EdgeNumbers(EvenNbIterBis+1) == EdgeNumbers(1))
293 ToNullifyNoofbisectorstoremove = Standard_True;
295 for(i=1; i<theedgelist->Number()-1; i++) {
296 edge = theedgelist->Current();
297 if(edge->Distance() == -1.) {
298 firstbisector = edge->FirstBisector();
299 secondbisector = edge->SecondBisector();
300 edge->Distance(atool.IntersectBisector
301 (firstbisector,secondbisector,intersectionpoint));
302 edge->IntersectionPoint(intersectionpoint);
304 if(edge->Distance() == Precision::Infinite()) {
305 if(firstbisector->IndexNumber() >= beginbisector ||
306 secondbisector->IndexNumber() >= beginbisector)
307 Intersect(atool,0,noofbisectorstoremove,
308 firstbisector,secondbisector );
311 if(firstbisector->IndexNumber() >= beginbisector) {
312 Intersect(atool,1,noofbisectorstoremove,
313 firstbisector,secondbisector );
315 if(secondbisector->IndexNumber() >= beginbisector) {
316 Intersect(atool,2,noofbisectorstoremove,
317 firstbisector,secondbisector );
324 //-------------------------------
325 // Test de sortie de la boucle 2.
326 //-------------------------------
328 if (ToNullifyNoofbisectorstoremove)
329 noofbisectorstoremove = 0;
330 if(noofbisectorstoremove == 0) break;
332 //---------------------------------------------------
333 // Annulation des bissectrices a effacer. (etape 2.4)
334 //---------------------------------------------------
336 for(i=0; i<noofbisectorstoremove; i++) {
338 bisectortoremove = bisectoronetoremove(i);
340 //---------------------------------------------------------------
341 // Destruction des bisectrices descendantes de <bisectortoremove>
342 // On descend dans l arbre jusqu a ce qu on atteigne
343 // <bisectortwotoremove(i).
344 //---------------------------------------------------------------
348 #ifdef OCCT_DEBUG_Mat
349 atool.Dump(bisectortoremove->BisectorNumber(),0);
351 // ----------------------------------
352 // Annulation de <bisectortoremove>.
353 // ----------------------------------
354 thenumberofbisectors--;
355 currentbisectorlist = bisectortoremove->List();
356 currentbisectorlist->First();
357 currentbisector = currentbisectorlist->FirstItem();
358 previousedge = currentbisector->FirstEdge();
359 theedgelist->Init(previousedge);
360 previousedge->Distance(-1.);
361 previousedge->FirstBisector()->SecondParameter(Precision::Infinite());
362 previousedge->SecondBisector()->FirstParameter(Precision::Infinite());
364 //------------------------------------------
365 // Annulation des fils de <currentbisector>.
366 //------------------------------------------
368 while(currentbisectorlist->More()) {
369 currentbisector = currentbisectorlist->Current();
370 currentedge = currentbisector->SecondEdge();
372 //---------------------------------------
373 // Reinsertion de l edge dans le contour.
374 //---------------------------------------
375 theedgelist->LinkAfter(currentedge);
378 currentedge->FirstBisector(currentbisector);
379 previousedge->SecondBisector(currentbisector);
380 #ifdef OCCT_DEBUG_Mat
381 atool.Dump(currentbisector->BisectorNumber(),0);
384 //------------------------------------------------------
385 // Annulation de l intersection ie les fils qui
386 // ont generes l intersection sont prolonges a l infini.
387 //------------------------------------------------------
389 currentbisector->FirstParameter (Precision::Infinite());
390 currentbisector->SecondParameter(Precision::Infinite());
392 atool.TrimBisector(currentbisector);
394 #ifdef OCCT_DEBUG_Mat
395 atool.Dump(currentbisector->BisectorNumber(),1);
397 currentedge->Distance(-1.);
398 currentedge->FirstBisector()->SecondParameter(Precision::Infinite());
399 currentedge->SecondBisector()->FirstParameter(Precision::Infinite());
401 previousedge = currentedge;
402 currentbisectorlist->Next();
405 theedgelist->Unlink();
407 //-----------------------------------------------------------
408 // Test de sortie de la boucle d annulation des bissectrices.
409 //-----------------------------------------------------------
411 if(bisectortoremove->BisectorNumber() ==
412 bisectortwotoremove(i)->BisectorNumber()) break;
414 //-----------------------
415 // Descente dans l arbre.
416 //-----------------------
418 if(typeofbisectortoremove(i) == 1)
419 bisectortoremove = bisectortoremove->FirstBisector();
421 bisectortoremove = bisectortoremove->LastBisector();
423 } //----------------------------------------------------
424 // Fin boucle d annulation des bissectrices issue de
425 // <bisectoronetoremove(i)>.
426 //----------------------------------------------------
428 } //------------------------------------------
429 // Fin boucle d annulation des bissectrices.
430 //-------------------------------------------
439 // ----------------------------------------------------------------------
440 // Analyse des parametres des intersections sur les bisectrices de chaque
441 // edge et determination des portions de contour a supprimees. (etape 2.5)
442 // ----------------------------------------------------------------------
444 theedgelist->First();
447 currentbisector = theedgelist->Current()->FirstBisector();
448 if (currentbisector->FirstParameter() == Precision::Infinite() &&
449 currentbisector->SecondParameter() == Precision::Infinite()) {
453 else if(currentbisector->FirstParameter() == Precision::Infinite()) {
457 else if(currentbisector->SecondParameter() == Precision::Infinite()) {
461 else if (atool.Distance(currentbisector,
462 currentbisector->FirstParameter(),
463 currentbisector->SecondParameter())
464 > toleranceofconfusion) {
465 if((currentbisector->FirstParameter() -
466 currentbisector->SecondParameter())
467 *currentbisector->Sense() > 0.) {
483 for(i=1; i<theedgelist->Number()-1; i++) {
484 currentbisector = theedgelist->Current()->SecondBisector();
485 if (currentbisector->FirstParameter() == Precision::Infinite() &&
486 currentbisector->SecondParameter() == Precision::Infinite()) {
490 else if(currentbisector->FirstParameter() == Precision::Infinite()) {
494 else if(currentbisector->SecondParameter() == Precision::Infinite()) {
498 else if (atool.Distance(currentbisector,
499 currentbisector->FirstParameter(),
500 currentbisector->SecondParameter())
501 > toleranceofconfusion) {
502 if((currentbisector->FirstParameter() -
503 currentbisector->SecondParameter())
504 *currentbisector->Sense() > 0.) {
518 //-----------------------------------------------------------------
519 // Test si l edge est a enlever du contour
520 // Construction des portions de contour a eliminer.
522 // narea : nombre de portions continues du contour a eliminer.
523 // firstarea[i] : indice premier edge de la portion i.
524 // lastarea[i] : indice dernier edge de la portion i.
525 //-----------------------------------------------------------------
527 #ifdef OCCT_DEBUG_Mat
528 std::cout <<" Test sur les parametres pour elimination"<<std::endl;
529 std::cout << " Edge number :"<<theedgelist->Current()->EdgeNumber()<<std::endl;
532 if(paramb[0] > 0 && parama[1] > 0) {
534 #ifdef OCCT_DEBUG_Mat
535 std::cout <<" A ELIMINER "<<std::endl;
538 firstarea(++narea) = theedgelist->Index();
539 lastarea(narea) = firstarea(narea);
543 if(theedgelist->Index() == lastarea(narea)+1) {
548 firstarea(++narea) = theedgelist->Index();
549 lastarea(narea) = firstarea(narea);
554 parama[0] = parama[1];
555 paramb[0] = paramb[1];
562 if(lastarea(narea) == theedgelist->Number() && firstarea(0) == 1) {
563 firstarea(0) = firstarea(narea);
564 noofarea(0) = noofarea(0)+noofarea(narea);
565 compact = noofarea(narea);
572 //------------------------------------------------------------------
573 // Sortie de la boucle principale si il n y a pas d edge a eliminer.
575 //------------------------------------------------------------------
577 interrupt = Standard_True;
582 //----------------------------------------------------------------
583 // Elimination des edges a enlever du contour
584 // => Mise a jour du nouveau contour.
585 // => Creation des bissectrices entre les nouvelles edges voisines.
586 //----------------------------------------------------------------
588 beginbisector = noofbisectors;
591 if(narea == 1 && noofarea(0) == theedgelist->Number()) all = 1;
593 for(i=0; i<narea; i++) {
594 if(i == 1)shift = shift-compact;
595 theedgelist->First();
597 edgetoremove = theedgelist->Brackets(firstarea(i)-shift);
599 edgetoremove->FirstBisector()->EndPoint(edgetoremove
600 ->IntersectionPoint());
602 #ifdef OCCT_DEBUG_Mat
603 atool.Dump(edgetoremove->FirstBisector()->BisectorNumber(),0);
606 edgetoremove->FirstBisector()->FirstParameter
607 (edgetoremove->FirstBisector()->SecondParameter());
609 #ifdef OCCT_DEBUG_Mat
610 if(atool.TrimBisector(edgetoremove->FirstBisector()))
611 atool.Dump(edgetoremove->FirstBisector()->BisectorNumber(),1);
613 atool.TrimBisector(edgetoremove->FirstBisector());
616 bisectormap.Bind(noofbisectors,new MAT_Bisector());
617 bisectormap(noofbisectors)->IndexNumber(noofbisectors);
618 bisectormap(noofbisectors)->DistIssuePoint(edgetoremove->Distance());
619 bisectormap(noofbisectors)->IssuePoint(edgetoremove
620 ->IntersectionPoint());
621 bisectormap(noofbisectors)->FirstEdge(theedgelist->PreviousItem());
622 bisectormap(noofbisectors)->AddBisector(edgetoremove
625 for(j=0; j<noofarea(i); j++) {
626 theedgelist->Unlink();
630 #ifdef OCCT_DEBUG_Mat
631 std::cout<<" Suppression de l'arete : "<<edgetoremove->EdgeNumber()<<std::endl;
634 if(all == 0 || j+1 != noofarea(i)) {
635 bisectormap(noofbisectors)->AddBisector(edgetoremove
638 edgetoremove->SecondBisector()->EndPoint(edgetoremove
639 ->IntersectionPoint());
641 #ifdef OCCT_DEBUG_Mat
642 atool.Dump(edgetoremove->SecondBisector()->BisectorNumber(),0);
645 edgetoremove->SecondBisector()->SecondParameter
646 (edgetoremove->SecondBisector()->FirstParameter());
647 #ifdef OCCT_DEBUG_Mat
648 if(atool.TrimBisector(edgetoremove->SecondBisector()))
649 atool.Dump(edgetoremove->SecondBisector()->BisectorNumber(),1);
651 atool.TrimBisector(edgetoremove->SecondBisector());
653 edgetoremove = theedgelist->Current();
655 bisectormap(noofbisectors)->SecondEdge(theedgelist->Current());
657 theedgelist->PreviousItem()
658 ->SecondBisector(bisectormap(noofbisectors));
659 theedgelist->Current()->FirstBisector(bisectormap(noofbisectors));
661 bisectormap(noofbisectors)->FirstVector
663 (bisectormap(noofbisectors)->FirstBisector()
664 ->BisectorNumber()));
666 bisectormap(noofbisectors)->SecondVector
668 (bisectormap(noofbisectors)->LastBisector()
669 ->BisectorNumber()));
673 theedgelist->PreviousItem()->Distance(-1);
674 theedgelist->Current()->Distance(-1);
676 theedgelist->PreviousItem()->FirstBisector()
677 ->SecondParameter(Precision::Infinite());
678 theedgelist->Current()->SecondBisector()->FirstParameter(Precision::Infinite());
681 //-----------------------------------------------------------------------
682 // Test sur le nombre d iterations :
683 // A chaque iteration est elimine un element du contour qui ne sera plus
684 // reinsere par la suite => le nombre d iterartions doit etre < au nombre
686 // Le nombre d iteration maximum est fixe a numberofedges*numberofedges.
687 //-----------------------------------------------------------------------
688 if (NumberOfIte > NumberMaxOfIte) {
689 isDone = Standard_False; //Echec calcul de la carte.
694 } //===============================================
695 // Fin Boucle Principale.
696 //===============================================
703 //----------------------------------------------
704 // interupt = True => bissectrices semi_infinies.
705 //----------------------------------------------
708 semiInfinite = Standard_True;
710 semiInfinite = Standard_False;
712 //------------------------------------------------------------------
713 // Si le nombre d edge > 1 => le nombre d edge = 2
714 // (cf test sortie boucle principale)
715 // Les deux dernieres bisectrices separent les memes edges .
716 // Soit elles sont confondues si calcul a l interieur, soit elles
717 // sont semi-Infinies (exemple : contour compose seulement de deux
719 //------------------------------------------------------------------
721 if(theedgelist->Number() > 1) { //Now this branch is never reachable
722 //because the case edgenumber = 2 is processed in the main loop
723 theedgelist->First();
724 edge = theedgelist->Current();
725 if(edge->FirstBisector()->IndexNumber() == noofbisectors-1) {
726 // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM Begin
727 if (atool.TrimBisector(edge->SecondBisector(),
728 edge->FirstBisector()->IssuePoint())) {
729 if (edge->SecondBisector()->EndPoint() == 0)
730 edge->SecondBisector()->EndPoint(edge->FirstBisector()->IssuePoint());
731 bisectormap(noofbisectors-1)->AddBisector(edge->SecondBisector());
733 semiInfinite = Standard_True;
734 // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End
737 // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM Begin
738 if (atool.TrimBisector(edge->FirstBisector(),
739 edge->SecondBisector()->IssuePoint())) {
740 if (edge->FirstBisector()->EndPoint() == 0)
741 edge->FirstBisector()->EndPoint(edge->SecondBisector()->IssuePoint());
742 bisectormap(noofbisectors-1)->AddBisector(edge->FirstBisector());
744 semiInfinite = Standard_True;
745 // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End
748 thenumberofbisectors--;
749 bisectormap(noofbisectors-1)->SecondEdge(edge);
750 bisectormap(noofbisectors-1)->BisectorNumber(-1);
756 beginbisector = noofbisectors;
757 theedgelist->First();
758 for(i=1; i<theedgelist->Number(); i++) {
759 edge = theedgelist->Current();
760 bisectormap.Bind(noofbisectors,edge->SecondBisector());
767 //---------------------------
768 // Recuperations des racines.
769 //---------------------------
771 roots = new MAT_ListOfBisector;
773 if (bisectormap(noofbisectors-1)->BisectorNumber() == -1) {
774 roots = bisectormap(noofbisectors-1)->List();
776 roots->Current()->FirstEdge()
777 ->Distance(bisectormap(noofbisectors-1)->DistIssuePoint());
780 for (i=beginbisector;i<noofbisectors;i++) {
781 roots->BackAdd(bisectormap(i));
787 void MAT2d_Mat2d::CreateMat(MAT2d_Tool2d& atool)
791 Standard_Boolean Icontinue;
794 Standard_Boolean interrupt = Standard_False;
796 Handle(MAT_Edge) edgetoremove;
797 Handle(MAT_Edge) previousedge,currentedge;
799 Standard_Integer noofbisectorstoremove;
800 Handle(MAT_Bisector) firstbisector,secondbisector;
801 Handle(MAT_Edge) edge;
802 Standard_Integer intersectionpoint;
803 Standard_Integer beginbisector;
804 Standard_Integer noofbisectors;
806 Standard_Integer NbIterBis = 0;
807 Standard_Integer EvenNbIterBis = 10;
808 TColStd_Array1OfInteger EdgeNumbers(1, EvenNbIterBis+1);
809 EdgeNumbers.Init(-1);
810 Standard_Boolean ToNullifyNoofbisectorstoremove = Standard_False;
812 Handle(MAT_ListOfBisector) currentbisectorlist;
814 Handle(MAT_Bisector) bisectortoremove,lastbisector,currentbisector;
815 Handle(MAT_Bisector) previousbisector;
817 Standard_Integer i,j,k,narea,shift,compact,all;
818 Standard_Integer noofedges;
819 Standard_Integer NumberMaxOfIte;
820 Standard_Real toleranceofconfusion;
822 noofedges = atool.NumberOfItems();
823 toleranceofconfusion = atool.ToleranceOfConfusion();
824 NumberMaxOfIte = noofedges*noofedges;
826 TColStd_Array1OfInteger firstarea(0, noofedges);
827 TColStd_Array1OfInteger lastarea(0, noofedges);
828 TColStd_Array1OfInteger noofarea(0, noofedges);
830 Standard_Integer parama[2];
831 Standard_Integer paramb[2];
833 Standard_Integer aNbOfNarea1 = 0, aPrefNarea = 0, aNbMaxNarea1 = 10;
834 Standard_Integer aNbElts[2] = {0, 0}, aCountElts[2] = {0, 0};
835 Standard_Boolean isBreak = Standard_False;
837 // -----------------------------------------
838 // Initialisation et remise a zero des maps.
839 // -----------------------------------------
840 bisectoronetoremove.Clear();
841 bisectortwotoremove.Clear();
842 typeofbisectortoremove.Clear();
845 isDone = Standard_True;
846 noofbisectors = noofedges;
849 // --------------------------------------------------------------------
850 // Construction de <theedgelist> un edge correspond a un element simple
852 // --------------------------------------------------------------------
853 theedgelist = new MAT_ListOfEdge();
855 for(i=0; i<noofedges; i++) {
856 edge = new MAT_Edge();
857 edge->EdgeNumber(i+1);
859 theedgelist->BackAdd(edge);
864 //---------------------------------------------------
865 // Initialisation des bissectrices issues du contour.
866 //---------------------------------------------------
868 theedgelist->First();
870 for(i=0; i<theedgelist->Number(); i++) {
871 bisectormap.Bind(i,new MAT_Bisector());
872 bisectormap(i)->IndexNumber(i);
873 bisectormap(i)->FirstEdge(theedgelist->Current());
874 bisectormap(i)->FirstVector
875 (atool.TangentBefore(theedgelist->Current()->EdgeNumber(), myIsOpenResult));
877 bisectormap(i)->SecondEdge(theedgelist->Current());
878 bisectormap(i)->IssuePoint
879 (atool.FirstPoint(theedgelist->Current()->EdgeNumber(),Dist));
880 bisectormap(i)->DistIssuePoint(Dist);
881 bisectormap(i)->SecondVector
882 (atool.TangentAfter(theedgelist->Current()->EdgeNumber(), myIsOpenResult));
885 //----------------------------------------------------
886 // Affectation a chaque edge de ses deux bissectrices.
887 //----------------------------------------------------
888 theedgelist->First();
890 for(i=0; i<theedgelist->Number(); i++) {
891 theedgelist->Current()->FirstBisector
892 (bisectormap((i-1+noofbisectors)%noofbisectors));
893 theedgelist->Current()->SecondBisector
898 //===========================================================================
899 // Boucle Principale (etape 2)
900 //===========================================================================
901 Standard_Integer NumberOfIte = 0;
903 while(theedgelist->Number()>1) {
906 // ------------------------------------------------------------------
907 // Creation des geometries des bissectrices via le tool. (etape 2.1)
908 // -------------------------------------------------------------------
909 Standard_Integer aNbBis = noofbisectors - beginbisector;
910 for(i=beginbisector; i<noofbisectors; i++) {
912 atool.CreateBisector(bisectormap(i));
913 thenumberofbisectors++;
915 #ifdef OCCT_DEBUG_Mat
916 atool.Dump(bisectormap(i)->BisectorNumber(),1);
923 //Patch to prevent infinit loop because of
930 Standard_Integer edge1number = bisectormap(beginbisector)->FirstEdge()->EdgeNumber();
931 Standard_Integer edge2number = bisectormap(beginbisector)->SecondEdge()->EdgeNumber();
932 if(aNbElts[0] == edge1number)
939 aNbElts[0] = edge1number;
941 if(aNbElts[1] == edge2number)
948 aNbElts[1] = edge2number;
950 if(aNbOfNarea1 >= aNbMaxNarea1 && (aCountElts[0] >= aNbMaxNarea1 || aCountElts[1] >= aNbMaxNarea1))
952 isBreak = Standard_True;
963 // ---------------------------------------------
964 // Condition de sortie de la boucle principale.
965 // ---------------------------------------------
967 // Modified by Sergey KHROMOV - Fri Nov 17 10:28:28 2000 Begin
968 if (theedgelist->Number() < 3)
970 // Modified by Sergey KHROMOV - Fri Nov 17 10:28:37 2000 End
972 //---------------------------------------------------
973 // boucle 2 Tant qu il y a des bisectrices a effacer.
974 //---------------------------------------------------
978 noofbisectorstoremove = 0;
979 theedgelist->First();
981 //--------------------------------------------------------------
982 // Calcul des intersections des bisectrices voisines.(etape 2.2)
983 //--------------------------------------------------------------
985 if (NbIterBis <= EvenNbIterBis+1)
986 EdgeNumbers(NbIterBis) = theedgelist->Number();
989 for (k = 1; k <= EvenNbIterBis; k++)
990 EdgeNumbers(k) = EdgeNumbers(k+1);
991 EdgeNumbers(EvenNbIterBis+1) = theedgelist->Number();
993 if (EdgeNumbers(EvenNbIterBis+1) == EdgeNumbers(1))
994 ToNullifyNoofbisectorstoremove = Standard_True;
996 for(i=0; i<theedgelist->Number(); i++) {
997 edge = theedgelist->Current();
998 if(edge->Distance() == -1.) {
999 firstbisector = edge->FirstBisector();
1000 secondbisector = edge->SecondBisector();
1001 edge->Distance(atool.IntersectBisector
1002 (firstbisector,secondbisector,intersectionpoint));
1003 edge->IntersectionPoint(intersectionpoint);
1005 if(edge->Distance() == Precision::Infinite()) {
1006 if(firstbisector->IndexNumber() >= beginbisector ||
1007 secondbisector->IndexNumber() >= beginbisector)
1008 Intersect(atool,0,noofbisectorstoremove,
1009 firstbisector,secondbisector );
1012 if(firstbisector->IndexNumber() >= beginbisector) {
1013 Intersect(atool,1,noofbisectorstoremove,
1014 firstbisector,secondbisector );
1016 if(secondbisector->IndexNumber() >= beginbisector) {
1017 Intersect(atool,2,noofbisectorstoremove,
1018 firstbisector,secondbisector );
1022 theedgelist->Next();
1025 //-------------------------------
1026 // Test de sortie de la boucle 2.
1027 //-------------------------------
1029 if (ToNullifyNoofbisectorstoremove)
1030 noofbisectorstoremove = 0;
1031 if(noofbisectorstoremove == 0) break;
1033 //---------------------------------------------------
1034 // Annulation des bissectrices a effacer. (etape 2.4)
1035 //---------------------------------------------------
1037 for(i=0; i<noofbisectorstoremove; i++) {
1039 bisectortoremove = bisectoronetoremove(i);
1041 //---------------------------------------------------------------
1042 // Destruction des bisectrices descendantes de <bisectortoremove>
1043 // On descend dans l arbre jusqu a ce qu on atteigne
1044 // <bisectortwotoremove(i).
1045 //---------------------------------------------------------------
1049 #ifdef OCCT_DEBUG_Mat
1050 atool.Dump(bisectortoremove->BisectorNumber(),0);
1052 // ----------------------------------
1053 // Annulation de <bisectortoremove>.
1054 // ----------------------------------
1055 thenumberofbisectors--;
1056 currentbisectorlist = bisectortoremove->List();
1057 currentbisectorlist->First();
1058 currentbisector = currentbisectorlist->FirstItem();
1059 previousedge = currentbisector->FirstEdge();
1060 theedgelist->Init(previousedge);
1061 previousedge->Distance(-1.);
1062 previousedge->FirstBisector()->SecondParameter(Precision::Infinite());
1063 previousedge->SecondBisector()->FirstParameter(Precision::Infinite());
1065 //------------------------------------------
1066 // Annulation des fils de <currentbisector>.
1067 //------------------------------------------
1069 while(currentbisectorlist->More()) {
1070 currentbisector = currentbisectorlist->Current();
1071 currentedge = currentbisector->SecondEdge();
1073 //---------------------------------------
1074 // Reinsertion de l edge dans le contour.
1075 //---------------------------------------
1076 theedgelist->LinkAfter(currentedge);
1077 theedgelist->Next();
1079 currentedge->FirstBisector(currentbisector);
1080 previousedge->SecondBisector(currentbisector);
1081 #ifdef OCCT_DEBUG_Mat
1082 atool.Dump(currentbisector->BisectorNumber(),0);
1085 //------------------------------------------------------
1086 // Annulation de l intersection ie les fils qui
1087 // ont generes l intersection sont prolonges a l infini.
1088 //------------------------------------------------------
1090 currentbisector->FirstParameter (Precision::Infinite());
1091 currentbisector->SecondParameter(Precision::Infinite());
1093 atool.TrimBisector(currentbisector);
1095 #ifdef OCCT_DEBUG_Mat
1096 atool.Dump(currentbisector->BisectorNumber(),1);
1098 currentedge->Distance(-1.);
1099 currentedge->FirstBisector()->SecondParameter(Precision::Infinite());
1100 currentedge->SecondBisector()->FirstParameter(Precision::Infinite());
1102 previousedge = currentedge;
1103 currentbisectorlist->Next();
1106 theedgelist->Unlink();
1108 //-----------------------------------------------------------
1109 // Test de sortie de la boucle d annulation des bissectrices.
1110 //-----------------------------------------------------------
1112 if(bisectortoremove->BisectorNumber() ==
1113 bisectortwotoremove(i)->BisectorNumber()) break;
1115 //-----------------------
1116 // Descente dans l arbre.
1117 //-----------------------
1119 if(typeofbisectortoremove(i) == 1)
1120 bisectortoremove = bisectortoremove->FirstBisector();
1122 bisectortoremove = bisectortoremove->LastBisector();
1124 } //----------------------------------------------------
1125 // Fin boucle d annulation des bissectrices issue de
1126 // <bisectoronetoremove(i)>.
1127 //----------------------------------------------------
1129 } //------------------------------------------
1130 // Fin boucle d annulation des bissectrices.
1131 //-------------------------------------------
1134 std::cin>>Icontinue;
1140 // ----------------------------------------------------------------------
1141 // Analyse des parametres des intersections sur les bisectrices de chaque
1142 // edge et determination des portions de contour a supprimees. (etape 2.5)
1143 // ----------------------------------------------------------------------
1145 theedgelist->First();
1147 currentbisector = theedgelist->Current()->FirstBisector();
1148 if (currentbisector->FirstParameter() == Precision::Infinite() &&
1149 currentbisector->SecondParameter() == Precision::Infinite()) {
1153 else if(currentbisector->FirstParameter() == Precision::Infinite()) {
1157 else if(currentbisector->SecondParameter() == Precision::Infinite()) {
1161 else if (atool.Distance(currentbisector,
1162 currentbisector->FirstParameter(),
1163 currentbisector->SecondParameter())
1164 > toleranceofconfusion) {
1165 if((currentbisector->FirstParameter() -
1166 currentbisector->SecondParameter())
1167 *currentbisector->Sense() > 0.) {
1183 for(i=0; i<theedgelist->Number(); i++) {
1184 currentbisector = theedgelist->Current()->SecondBisector();
1185 if (currentbisector->FirstParameter() == Precision::Infinite() &&
1186 currentbisector->SecondParameter() == Precision::Infinite()) {
1190 else if(currentbisector->FirstParameter() == Precision::Infinite()) {
1194 else if(currentbisector->SecondParameter() == Precision::Infinite()) {
1198 else if (atool.Distance(currentbisector,
1199 currentbisector->FirstParameter(),
1200 currentbisector->SecondParameter())
1201 > toleranceofconfusion) {
1202 if((currentbisector->FirstParameter() -
1203 currentbisector->SecondParameter())
1204 *currentbisector->Sense() > 0.) {
1218 //-----------------------------------------------------------------
1219 // Test si l edge est a enlever du contour
1220 // Construction des portions de contour a eliminer.
1222 // narea : nombre de portions continues du contour a eliminer.
1223 // firstarea[i] : indice premier edge de la portion i.
1224 // lastarea[i] : indice dernier edge de la portion i.
1225 //-----------------------------------------------------------------
1227 #ifdef OCCT_DEBUG_Mat
1228 std::cout <<" Test sur les parametres pour elimination"<<std::endl;
1229 std::cout << " Edge number :"<<theedgelist->Current()->EdgeNumber()<<std::endl;
1232 if(paramb[0] > 0 && parama[1] > 0) {
1234 #ifdef OCCT_DEBUG_Mat
1235 std::cout <<" A ELIMINER "<<std::endl;
1238 firstarea(++narea) = theedgelist->Index();
1239 lastarea(narea) = firstarea(narea);
1240 noofarea(narea) = 1;
1243 if(theedgelist->Index() == lastarea(narea)+1) {
1248 firstarea(++narea) = theedgelist->Index();
1249 lastarea(narea) = firstarea(narea);
1250 noofarea(narea) = 1;
1254 parama[0] = parama[1];
1255 paramb[0] = paramb[1];
1256 theedgelist->Next();
1262 if(lastarea(narea) == theedgelist->Number() && firstarea(0) == 1) {
1263 firstarea(0) = firstarea(narea);
1264 noofarea(0) = noofarea(0)+noofarea(narea);
1265 compact = noofarea(narea);
1272 //------------------------------------------------------------------
1273 // Sortie de la boucle principale si il n y a pas d edge a eliminer.
1275 //------------------------------------------------------------------
1277 //Patch to break infinite loop.
1278 if(narea == 1 && isBreak)
1284 interrupt = Standard_True;
1289 //----------------------------------------------------------------
1290 // Elimination des edges a enlever du contour
1291 // => Mise a jour du nouveau contour.
1292 // => Creation des bissectrices entre les nouvelles edges voisines.
1293 //----------------------------------------------------------------
1295 beginbisector = noofbisectors;
1298 if(narea == 1 && noofarea(0) == theedgelist->Number()) all = 1;
1300 for(i=0; i<narea; i++) {
1301 if(i == 1)shift = shift-compact;
1302 theedgelist->First();
1303 edgetoremove = theedgelist->Brackets(firstarea(i)-shift);
1305 edgetoremove->FirstBisector()->EndPoint(edgetoremove
1306 ->IntersectionPoint());
1308 #ifdef OCCT_DEBUG_Mat
1309 atool.Dump(edgetoremove->FirstBisector()->BisectorNumber(),0);
1312 edgetoremove->FirstBisector()->FirstParameter
1313 (edgetoremove->FirstBisector()->SecondParameter());
1315 #ifdef OCCT_DEBUG_Mat
1316 if(atool.TrimBisector(edgetoremove->FirstBisector()))
1317 atool.Dump(edgetoremove->FirstBisector()->BisectorNumber(),1);
1319 atool.TrimBisector(edgetoremove->FirstBisector());
1322 bisectormap.Bind(noofbisectors,new MAT_Bisector());
1323 bisectormap(noofbisectors)->IndexNumber(noofbisectors);
1324 bisectormap(noofbisectors)->DistIssuePoint(edgetoremove->Distance());
1325 bisectormap(noofbisectors)->IssuePoint(edgetoremove
1326 ->IntersectionPoint());
1327 bisectormap(noofbisectors)->FirstEdge(theedgelist->PreviousItem());
1328 bisectormap(noofbisectors)->AddBisector(edgetoremove
1331 for(j=0; j<noofarea(i); j++) {
1332 theedgelist->Unlink();
1333 theedgelist->Next();
1336 #ifdef OCCT_DEBUG_Mat
1337 std::cout<<" Suppression de l'arete : "<<edgetoremove->EdgeNumber()<<std::endl;
1340 if(all == 0 || j+1 != noofarea(i)) {
1341 bisectormap(noofbisectors)->AddBisector(edgetoremove
1342 ->SecondBisector());
1344 edgetoremove->SecondBisector()->EndPoint(edgetoremove
1345 ->IntersectionPoint());
1347 #ifdef OCCT_DEBUG_Mat
1348 atool.Dump(edgetoremove->SecondBisector()->BisectorNumber(),0);
1351 edgetoremove->SecondBisector()->SecondParameter
1352 (edgetoremove->SecondBisector()->FirstParameter());
1353 #ifdef OCCT_DEBUG_Mat
1354 if(atool.TrimBisector(edgetoremove->SecondBisector()))
1355 atool.Dump(edgetoremove->SecondBisector()->BisectorNumber(),1);
1357 atool.TrimBisector(edgetoremove->SecondBisector());
1359 edgetoremove = theedgelist->Current();
1361 bisectormap(noofbisectors)->SecondEdge(theedgelist->Current());
1363 theedgelist->PreviousItem()
1364 ->SecondBisector(bisectormap(noofbisectors));
1365 theedgelist->Current()->FirstBisector(bisectormap(noofbisectors));
1367 bisectormap(noofbisectors)->FirstVector
1369 (bisectormap(noofbisectors)->FirstBisector()
1370 ->BisectorNumber()));
1372 bisectormap(noofbisectors)->SecondVector
1374 (bisectormap(noofbisectors)->LastBisector()
1375 ->BisectorNumber()));
1379 theedgelist->PreviousItem()->Distance(-1);
1380 theedgelist->Current()->Distance(-1);
1382 theedgelist->PreviousItem()->FirstBisector()
1383 ->SecondParameter(Precision::Infinite());
1384 theedgelist->Current()->SecondBisector()->FirstParameter(Precision::Infinite());
1387 //-----------------------------------------------------------------------
1388 // Test sur le nombre d iterations :
1389 // A chaque iteration est elimine un element du contour qui ne sera plus
1390 // reinsere par la suite => le nombre d iterartions doit etre < au nombre
1392 // Le nombre d iteration maximum est fixe a numberofedges*numberofedges.
1393 //-----------------------------------------------------------------------
1394 if (NumberOfIte > NumberMaxOfIte) {
1395 isDone = Standard_False; //Echec calcul de la carte.
1400 } //===============================================
1401 // Fin Boucle Principale.
1402 //===============================================
1409 //----------------------------------------------
1410 // interupt = True => bissectrices semi_infinies.
1411 //----------------------------------------------
1414 semiInfinite = Standard_True;
1416 semiInfinite = Standard_False;
1418 //------------------------------------------------------------------
1419 // Si le nombre d edge > 1 => le nombre d edge = 2
1420 // (cf test sortie boucle principale)
1421 // Les deux dernieres bisectrices separent les memes edges .
1422 // Soit elles sont confondues si calcul a l interieur, soit elles
1423 // sont semi-Infinies (exemple : contour compose seulement de deux
1424 // arcs de cercles).
1425 //------------------------------------------------------------------
1427 if(theedgelist->Number() > 1) { //Now this branch is never reachable
1428 //because the case edgenumber = 2 is processed in the main loop
1429 theedgelist->First();
1430 edge = theedgelist->Current();
1431 if(edge->FirstBisector()->IndexNumber() == noofbisectors-1) {
1432 // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM Begin
1433 if (atool.TrimBisector(edge->SecondBisector(),
1434 edge->FirstBisector()->IssuePoint())) {
1435 if (edge->SecondBisector()->EndPoint() == 0)
1436 edge->SecondBisector()->EndPoint(edge->FirstBisector()->IssuePoint());
1437 bisectormap(noofbisectors-1)->AddBisector(edge->SecondBisector());
1439 semiInfinite = Standard_True;
1440 // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End
1443 // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM Begin
1444 if (atool.TrimBisector(edge->FirstBisector(),
1445 edge->SecondBisector()->IssuePoint())) {
1446 if (edge->FirstBisector()->EndPoint() == 0)
1447 edge->FirstBisector()->EndPoint(edge->SecondBisector()->IssuePoint());
1448 bisectormap(noofbisectors-1)->AddBisector(edge->FirstBisector());
1450 semiInfinite = Standard_True;
1451 // Modified by skv - Tue Sep 13 12:13:28 2005 IDEM End
1453 if (!semiInfinite) {
1454 thenumberofbisectors--;
1455 bisectormap(noofbisectors-1)->SecondEdge(edge);
1456 bisectormap(noofbisectors-1)->BisectorNumber(-1);
1461 beginbisector = noofbisectors;
1462 theedgelist->First();
1463 for(i=0; i<theedgelist->Number(); i++) {
1464 edge = theedgelist->Current();
1465 bisectormap.Bind(noofbisectors,edge->SecondBisector());
1467 theedgelist->Next();
1472 //---------------------------
1473 // Recuperations des racines.
1474 //---------------------------
1476 roots = new MAT_ListOfBisector;
1478 if (bisectormap(noofbisectors-1)->BisectorNumber() == -1) {
1479 roots = bisectormap(noofbisectors-1)->List();
1481 roots->Current()->FirstEdge()
1482 ->Distance(bisectormap(noofbisectors-1)->DistIssuePoint());
1485 for (i=beginbisector;i<noofbisectors;i++) {
1486 roots->BackAdd(bisectormap(i));
1492 //========================================================================
1493 // function : LoadBisectorsToRemove
1494 // purpose : Chargement des bisectrices a effacer.
1495 //========================================================================
1496 void MAT2d_Mat2d::LoadBisectorsToRemove
1497 ( Standard_Integer& noofbisectorstoremove,
1498 const Standard_Real distance1,
1499 const Standard_Real distance2,
1500 const Handle(MAT_Bisector)& firstbisectortoremove1,
1501 const Handle(MAT_Bisector)& firstbisectortoremove2,
1502 const Handle(MAT_Bisector)& lastbisectortoremove1,
1503 const Handle(MAT_Bisector)& lastbisectortoremove2 )
1506 Standard_Integer found,index;
1507 Handle(MAT_Bisector) firstbisectortoremove[2];
1508 Handle(MAT_Bisector) lastbisectortoremove[2];
1510 firstbisectortoremove[0] = firstbisectortoremove1;
1511 firstbisectortoremove[1] = firstbisectortoremove2;
1512 lastbisectortoremove[0] = lastbisectortoremove1;
1513 lastbisectortoremove[1] = lastbisectortoremove2;
1515 if (distance1 < Precision::Infinite() &&
1516 distance2 == Precision::Infinite() ) index = 0;
1517 else if(distance2 < Precision::Infinite() &&
1518 distance1 == Precision::Infinite() ) index = 1;
1522 found = noofbisectorstoremove;
1523 for(int j=0; j<noofbisectorstoremove; j++) {
1524 if(bisectoronetoremove(j)->BisectorNumber() ==
1525 firstbisectortoremove[index]->BisectorNumber()) {
1527 if(bisectortwotoremove(j)->BisectorNumber() <
1528 lastbisectortoremove[index]->BisectorNumber())found = -1;
1534 #ifdef OCCT_DEBUG_Mat
1535 std::cout<<" first last bisector to remove :"<<
1536 firstbisectortoremove[index]->BisectorNumber()<<" "<<
1537 lastbisectortoremove[index]->BisectorNumber()<<std::endl;
1539 bisectoronetoremove.Bind(found,firstbisectortoremove[index]);
1540 bisectortwotoremove.Bind(found,lastbisectortoremove[index]);
1541 typeofbisectortoremove.Bind(found,index+1);
1543 if(found == noofbisectorstoremove)noofbisectorstoremove++;
1548 //========================================================================
1549 // function : Intersect
1550 // purpose : Si <aside=0> Intersection de <firstbisector> avec les
1551 // descendants de <secondbisector> les plus a gauche
1552 // (ie secondbisector->FirstBisector()->FirstBisector...)
1553 // Intersection de <secondbisector> avec les
1554 // descendants de <firstbisector> les plus a droite
1555 // (ie firstbisector->LastBisector()->LastBisector...)
1557 // Si <aside=1> Intersection de <firstbisector> avec ses
1558 // descendants les plus a gauche et les plus a droite.
1560 // Si <aside=2> Intersection de <secondbisector> avec ses
1561 // descendants les plus a gauche et les plus a droite.
1562 //========================================================================v
1563 void MAT2d_Mat2d::Intersect( MAT2d_Tool2d& atool,
1564 const Standard_Integer aside,
1565 Standard_Integer& noofbisectortoremove,
1566 const Handle(MAT_Bisector)& firstbisector,
1567 const Handle(MAT_Bisector)& secondbisector)
1569 Standard_Integer bisectornumber;
1570 Standard_Real distant,saveparameter;
1571 Standard_Real distance[2];
1572 Standard_Integer intersectionpoint;
1573 Handle(MAT_Bisector) lastbisector,previousbisector;
1574 Handle(MAT_Bisector) firstbisectortoremove[2];
1575 Handle(MAT_Bisector) lastbisectortoremove[2];
1577 distance[0] = Precision::Infinite();
1578 distance[1] = Precision::Infinite();
1580 for(bisectornumber = 0; bisectornumber<2; bisectornumber++) {
1582 if(bisectornumber == 0)
1583 firstbisectortoremove[bisectornumber] = secondbisector;
1585 firstbisectortoremove[bisectornumber] = firstbisector;
1587 else if(aside == 1) {
1588 firstbisectortoremove[bisectornumber] = firstbisector;
1591 firstbisectortoremove[bisectornumber] = secondbisector;
1594 lastbisector = firstbisectortoremove[bisectornumber];
1597 previousbisector = firstbisectortoremove[bisectornumber];
1600 if(firstbisectortoremove[bisectornumber]->List()->IsEmpty())continue;
1602 if(bisectornumber == 0)
1603 previousbisector = firstbisectortoremove[bisectornumber]
1606 previousbisector = firstbisectortoremove[bisectornumber]
1610 distant = distance[bisectornumber];
1611 while(!previousbisector->List()->IsEmpty()) {
1613 if(bisectornumber == 0)
1614 previousbisector = previousbisector->FirstBisector();
1616 previousbisector = previousbisector->LastBisector();
1618 if(aside == 1 || (aside == 0 && bisectornumber == 0)) {
1619 saveparameter = previousbisector->FirstParameter();
1620 distant = atool.IntersectBisector
1621 (firstbisector,previousbisector,intersectionpoint);
1622 previousbisector->FirstParameter(saveparameter);
1625 saveparameter = previousbisector->SecondParameter();
1626 distant = atool.IntersectBisector
1627 (previousbisector,secondbisector,intersectionpoint);
1628 previousbisector->SecondParameter(saveparameter);
1631 if(distant < Precision::Infinite()) {
1632 distance[bisectornumber] = distant;
1633 lastbisectortoremove[bisectornumber] = lastbisector;
1636 lastbisector = previousbisector;
1640 //---------------------------------------
1641 // Chargement des bissectrices a effacer.
1642 //---------------------------------------
1644 LoadBisectorsToRemove(noofbisectortoremove,
1645 distance[0],distance[1],
1646 firstbisectortoremove[0],firstbisectortoremove[1],
1647 lastbisectortoremove[0] ,lastbisectortoremove[1]);
1650 //========================================================================
1653 //========================================================================
1654 void MAT2d_Mat2d::Init()
1659 //========================================================================
1662 //========================================================================
1663 Standard_Boolean MAT2d_Mat2d::More() const
1665 return roots->More();
1668 //========================================================================
1671 //========================================================================
1672 void MAT2d_Mat2d::Next()
1677 //========================================================================
1678 // function : Bisector
1680 //========================================================================
1681 Handle(MAT_Bisector) MAT2d_Mat2d::Bisector() const
1683 return roots->Current();
1686 //========================================================================
1687 // function : NumberOfBisectors
1689 //========================================================================
1690 Standard_Integer MAT2d_Mat2d::NumberOfBisectors() const
1692 return thenumberofbisectors;
1695 //========================================================================
1696 // function : SemiInfinite
1698 //========================================================================
1699 Standard_Boolean MAT2d_Mat2d::SemiInfinite() const
1701 return semiInfinite;
1704 //========================================================================
1705 // function : IsDone
1707 //========================================================================
1708 Standard_Boolean MAT2d_Mat2d::IsDone() const