0022923: The command 'intersect' throws an exception.
[occt.git] / src / IntPolyh / IntPolyh_Triangle.cxx
index e22490f..85130b0 100755 (executable)
 #define MyConfusionPrecision 10.0e-12
 #define SquareMyConfusionPrecision 10.0e-24
 
-//# ifdef DEB
-  //#define MYDEBUG DEB
-//# else
-  //#define MYDEBUG 0
-//# endif
-
-IntPolyh_Triangle::IntPolyh_Triangle() : p1(-1),p2(-1),p3(-1),
+static
+  void GetInfoTA(const Standard_Integer numP1,
+                const Standard_Integer numP2,
+                const Standard_Integer numTA,
+                const IntPolyh_ArrayOfTriangles & TTriangles,
+                Standard_Integer & numP3b,
+                Standard_Integer & P3bIndex,
+                Standard_Integer & Edge2b,
+                Standard_Integer & Edge3b);
+static
+  void NewTriangle(const Standard_Integer P1,
+                  const Standard_Integer P2,
+                  const Standard_Integer P3,
+                  IntPolyh_ArrayOfTriangles &TTriangles,
+                  const Handle(Adaptor3d_HSurface)& MySurface,
+                  IntPolyh_ArrayOfPoints &TPoints);
+static
+  void NewEdge(const Standard_Integer P1,
+              const Standard_Integer P2,
+              const Standard_Integer T1,
+              const Standard_Integer T2,
+            IntPolyh_ArrayOfEdges & TEdges); 
+static
+  void OldEdge(const Standard_Integer EdgeN,
+              const Standard_Integer NumTri,
+              const Standard_Integer NewTriNum,
+              IntPolyh_ArrayOfEdges & TEdges) ;
+static
+  void TestOldEdgeB(const Standard_Integer NumTA,
+                   const Standard_Integer numPtT1,
+                   const Standard_Integer numPtT2,
+                   const Standard_Integer T1,
+                   const Standard_Integer T2,
+                   const IntPolyh_ArrayOfTriangles & TTriangles,
+                   const Standard_Integer Edge1,
+                   const Standard_Integer Edge3,
+                   IntPolyh_ArrayOfEdges & TEdges );
+
+//=======================================================================
+//function : IntPolyh_Triangle
+//purpose  : 
+//=======================================================================
+IntPolyh_Triangle::IntPolyh_Triangle() 
+: 
+  p1(-1),p2(-1),p3(-1),
+  e1(-1),oe1(0),e2(-1),oe2(0),e3(-1),oe3(0),
+  II(0),IP(1),Fleche(0.0) 
+{
+} 
+//=======================================================================
+//function : IntPolyh_Triangle
+//purpose  : 
+//=======================================================================
+IntPolyh_Triangle::IntPolyh_Triangle(const Standard_Integer a,
+                                    const Standard_Integer b,
+                                    const Standard_Integer c) 
+:
+  p1(a),p2(b),p3(c),
   e1(-1),oe1(0),e2(-1),oe2(0),e3(-1),oe3(0),
-  II(0),IP(1),Fleche(0.0) { } 
-
-IntPolyh_Triangle::IntPolyh_Triangle(const Standard_Integer a,const Standard_Integer b,
-                                    const Standard_Integer c) : p1(a),p2(b),p3(c),
-                                    e1(-1),oe1(0),e2(-1),oe2(0),e3(-1),oe3(0),II(0),IP(1),Fleche(0.0) { }
-
-Standard_Integer IntPolyh_Triangle::FirstPoint() const { return(p1); } 
-Standard_Integer IntPolyh_Triangle::SecondPoint() const { return(p2); }
-Standard_Integer IntPolyh_Triangle::ThirdPoint() const { return(p3); }
-Standard_Integer IntPolyh_Triangle::FirstEdge() const { return(e1); }
-Standard_Integer IntPolyh_Triangle::FirstEdgeOrientation() const { return(oe1); }
-Standard_Integer IntPolyh_Triangle::SecondEdge() const { return(e2); }
-Standard_Integer IntPolyh_Triangle::SecondEdgeOrientation() const { return(oe2); }
-Standard_Integer IntPolyh_Triangle::ThirdEdge() const { return(e3); }
-Standard_Integer IntPolyh_Triangle::ThirdEdgeOrientation() const { return(oe3); }
-Standard_Real IntPolyh_Triangle::GetFleche() const { return(Fleche); }
-Standard_Integer IntPolyh_Triangle::IndiceIntersectionPossible() const { return(IP); }
-Standard_Integer IntPolyh_Triangle::IndiceIntersection() const { return(II); }
-
-void IntPolyh_Triangle::SetFirstPoint(const Standard_Integer a) { p1=a; } 
-void IntPolyh_Triangle::SetSecondPoint(const Standard_Integer b) { p2=b; }    
-void IntPolyh_Triangle::SetThirdPoint(const Standard_Integer c) { p3=c; }
-void IntPolyh_Triangle::SetFirstEdge(const Standard_Integer e, const Standard_Integer oe) { e1=e; oe1=oe;}
-void IntPolyh_Triangle::SetSecondEdge(const Standard_Integer f, const Standard_Integer of) { e2=f; oe2=of; }
-void IntPolyh_Triangle::SetThirdEdge(const Standard_Integer g, const Standard_Integer og) { e3=g; oe3=og; }
-void IntPolyh_Triangle::SetFleche(const Standard_Real A) { Fleche=A;}
-void IntPolyh_Triangle::SetIndiceIntersectionPossible(const Standard_Integer I) { IP=I; }
-void IntPolyh_Triangle::SetIndiceIntersection(const Standard_Integer I) { II=I; }
-
-
-Standard_Integer IntPolyh_Triangle::GetEdgeNumber(const Standard_Integer EdgeIndex) const { 
+  II(0),IP(1),Fleche(0.0) 
+{ 
+}
+//=======================================================================
+//function : FirstPoint
+//purpose  : 
+//=======================================================================
+Standard_Integer IntPolyh_Triangle::FirstPoint() const 
+{ 
+  return(p1); 
+} 
+//=======================================================================
+//function : SecondPoint
+//purpose  : 
+//=======================================================================
+Standard_Integer IntPolyh_Triangle::SecondPoint() const 
+{ 
+  return(p2); 
+}
+//=======================================================================
+//function : ThirdPoint
+//purpose  : 
+//=======================================================================
+Standard_Integer IntPolyh_Triangle::ThirdPoint() const 
+{
+  return(p3); 
+}
+//=======================================================================
+//function : FirstEdge
+//purpose  : 
+//=======================================================================
+Standard_Integer IntPolyh_Triangle::FirstEdge() const
+{
+  return(e1); 
+}
+//=======================================================================
+//function : FirstEdgeOrientation
+//purpose  : 
+//=======================================================================
+Standard_Integer IntPolyh_Triangle::FirstEdgeOrientation() const 
+{
+  return(oe1); 
+}
+//=======================================================================
+//function : SecondEdge
+//purpose  : 
+//=======================================================================
+Standard_Integer IntPolyh_Triangle::SecondEdge() const 
+{
+  return(e2); 
+}
+//=======================================================================
+//function : SecondEdgeOrientation
+//purpose  : 
+//=======================================================================
+Standard_Integer IntPolyh_Triangle::SecondEdgeOrientation() const 
+{ 
+  return(oe2); 
+}
+//=======================================================================
+//function : ThirdEdge
+//purpose  : 
+//=======================================================================
+Standard_Integer IntPolyh_Triangle::ThirdEdge() const 
+{
+  return(e3); 
+}
+//=======================================================================
+//function : ThirdEdgeOrientation
+//purpose  : 
+//=======================================================================
+Standard_Integer IntPolyh_Triangle::ThirdEdgeOrientation() const
+{
+  return(oe3); 
+}
+//=======================================================================
+//function : GetFleche
+//purpose  : 
+//=======================================================================
+Standard_Real IntPolyh_Triangle::GetFleche() const 
+{
+  return(Fleche); 
+}
+//=======================================================================
+//function : IndiceIntersectionPossible
+//purpose  : 
+//=======================================================================
+Standard_Integer IntPolyh_Triangle::IndiceIntersectionPossible() const 
+{
+  return(IP); 
+}
+//=======================================================================
+//function : IndiceIntersection
+//purpose  : 
+//=======================================================================
+Standard_Integer IntPolyh_Triangle::IndiceIntersection() const 
+{
+  return(II); 
+}
+//=======================================================================
+//function : SetFirstPoint
+//purpose  : 
+//=======================================================================
+void IntPolyh_Triangle::SetFirstPoint(const Standard_Integer a) 
+{
+  p1=a; 
+} 
+//=======================================================================
+//function : SetSecondPoint
+//purpose  : 
+//=======================================================================
+void IntPolyh_Triangle::SetSecondPoint(const Standard_Integer b)
+{
+  p2=b; 
+}    
+//=======================================================================
+//function : SetThirdPoint
+//purpose  : 
+//=======================================================================
+void IntPolyh_Triangle::SetThirdPoint(const Standard_Integer c) 
+{ 
+  p3=c;
+}
+//=======================================================================
+//function : SetFirstEdge
+//purpose  : 
+//=======================================================================
+void IntPolyh_Triangle::SetFirstEdge(const Standard_Integer e, 
+                                    const Standard_Integer oe) 
+{
+  e1=e; 
+  oe1=oe;
+}
+//=======================================================================
+//function : SetSecondEdge
+//purpose  : 
+//=======================================================================
+void IntPolyh_Triangle::SetSecondEdge(const Standard_Integer f, 
+                                     const Standard_Integer of) 
+{
+  e2=f; 
+  oe2=of; 
+}
+//=======================================================================
+//function : SetThirdEdge
+//purpose  : 
+//=======================================================================
+void IntPolyh_Triangle::SetThirdEdge(const Standard_Integer g, 
+                                    const Standard_Integer og) 
+{
+  e3=g; 
+  oe3=og; 
+}
+//=======================================================================
+//function : SetFleche
+//purpose  : 
+//=======================================================================
+void IntPolyh_Triangle::SetFleche(const Standard_Real A) 
+{
+  Fleche=A;
+}
+//=======================================================================
+//function : SetIndiceIntersectionPossible
+//purpose  : 
+//=======================================================================
+void IntPolyh_Triangle::SetIndiceIntersectionPossible(const Standard_Integer I) 
+{
+  IP=I; 
+}
+//=======================================================================
+//function : SetIndiceIntersection
+//purpose  : 
+//=======================================================================
+void IntPolyh_Triangle::SetIndiceIntersection(const Standard_Integer I)
+{
+  II=I; 
+}
+//=======================================================================
+//function : GetEdgeNumber
+//purpose  : 
+//=======================================================================
+Standard_Integer 
+  IntPolyh_Triangle::GetEdgeNumber(const Standard_Integer EdgeIndex) const 
+{ 
   if(EdgeIndex==1)
     return(e1);
   if(EdgeIndex==2)
@@ -62,11 +266,14 @@ Standard_Integer IntPolyh_Triangle::GetEdgeNumber(const Standard_Integer EdgeInd
     return(e3);
 
   return 0;
-
 }  
-
+//=======================================================================
+//function : SetEdge
+//purpose  : 
+//=======================================================================
 void IntPolyh_Triangle::SetEdge(const Standard_Integer EdgeIndex,
-                               const Standard_Integer EdgeNumber) {
+                               const Standard_Integer EdgeNumber) 
+{
   if(EdgeIndex==1)
     e1=EdgeNumber;
   if(EdgeIndex==2)
@@ -74,8 +281,13 @@ void IntPolyh_Triangle::SetEdge(const Standard_Integer EdgeIndex,
   if(EdgeIndex==3)
     e3=EdgeNumber;
 }  
-
-Standard_Integer IntPolyh_Triangle::GetEdgeOrientation(const Standard_Integer EdgeIndex) const {
+//=======================================================================
+//function : GetEdgeOrientation
+//purpose  : 
+//=======================================================================
+Standard_Integer 
+  IntPolyh_Triangle::GetEdgeOrientation(const Standard_Integer EdgeIndex) const 
+{
   if(EdgeIndex==1)
     return(oe1);
   if(EdgeIndex==2)
@@ -86,9 +298,13 @@ Standard_Integer IntPolyh_Triangle::GetEdgeOrientation(const Standard_Integer Ed
   return 0;
 
 }  
-
+//=======================================================================
+//function : SetEdgeOrientation
+//purpose  : 
+//=======================================================================
 void IntPolyh_Triangle::SetEdgeOrientation(const Standard_Integer EdgeIndex,
-                                          const Standard_Integer OrEd) {
+                                          const Standard_Integer OrEd) 
+{
   if(EdgeIndex==1)
     oe1=OrEd;
   if(EdgeIndex==2)
@@ -97,26 +313,47 @@ void IntPolyh_Triangle::SetEdgeOrientation(const Standard_Integer EdgeIndex,
     oe3=OrEd;
 }  
 
-      /*Calcul de la fleche pour un triangle**************
-       Distance entre le plan forme par le triangle et
-       le barycentre situe sur la surface calcule avec les coordonnees Gu,Gv
-       (coordonnees du barycentre du triangle dans l'espace UV)*/
-
+      
+//=======================================================================
+//function : TriangleDeflection
+//purpose  : 
+/*Calcul de la fleche pour un triangle**************
+  Distance entre le plan forme par le triangle et
+  le barycentre situe sur la surface calcule avec les coordonnees Gu,Gv
+  (coordonnees du barycentre du triangle dans l'espace UV)*/
+//=======================================================================
 void IntPolyh_Triangle::TriangleDeflection(const Handle(Adaptor3d_HSurface)& MySurface,
-                                          const IntPolyh_ArrayOfPoints& TPoints){
-
+                                          const IntPolyh_ArrayOfPoints& TPoints)
+{
   const IntPolyh_Point & P1 = TPoints[p1];
   const IntPolyh_Point & P2 = TPoints[p2];
   const IntPolyh_Point & P3 = TPoints[p3];
-  Standard_Real Gu=(P1.U()+P2.U()+P3.U())/3.0;
-  Standard_Real Gv=(P1.V()+P2.V()+P3.V())/3.0;
-
-  gp_Pnt PtXYZ = (MySurface)->Value( Gu, Gv);
+  //
+  //modified by NIZNHY-PKV Fri Jan 20 14:25:11 2012f
+  {
+    Standard_Integer iDeg1, iDeg2, iDeg3, iDeg;
+    //
+    iDeg1=(P1.Degenerated()) ? 1 : 0;
+    iDeg2=(P2.Degenerated()) ? 1 : 0;
+    iDeg3=(P3.Degenerated()) ? 1 : 0;
+    iDeg=iDeg1+iDeg2+iDeg3;
+    if (iDeg>1) {
+      Fleche=0.;
+      return;
+    }
+  }
+  //modified by NIZNHY-PKV Fri Jan 20 14:25:13 2012t
+  Standard_Real Gu, Gv, SqNorme;
+  gp_Pnt PtXYZ;
+  //
+  Gu=(P1.U()+P2.U()+P3.U())/3.0;
+  Gv=(P1.V()+P2.V()+P3.V())/3.0;
+
+  PtXYZ = (MySurface)->Value( Gu, Gv);
   IntPolyh_Point BarycentreReel(PtXYZ.X(), PtXYZ.Y(), PtXYZ.Z(), Gu, Gv);
   IntPolyh_Point NormaleTri;
   NormaleTri.Cross(P2-P1,P3-P1);
-  Standard_Real SqNorme=NormaleTri.SquareModulus();
+  SqNorme=NormaleTri.SquareModulus();
   
   if (SqNorme > SquareMyConfusionPrecision) {
     NormaleTri=NormaleTri/sqrt(SqNorme);
@@ -125,33 +362,10 @@ void IntPolyh_Triangle::TriangleDeflection(const Handle(Adaptor3d_HSurface)& MyS
   else {
     // On calcule la fleche sur le plus grand des edges
     // calcul des longueurs des cotes au carre
-       
       Standard_Real L12 = P1.SquareDistance(P2);
       Standard_Real L23 = P2.SquareDistance(P3);
       Standard_Real L31 = P3.SquareDistance(P1);
 
-      if (L12<SquareMyConfusionPrecision) {
-# if MYDEBUG
-       printf("\nTriangleDeflection() from IntPolyh_Triangle : L12=0\n");
-       P1.Dump();
-       P2.Dump();
-# endif
-      }
-      if (L23<SquareMyConfusionPrecision) {
-# if MYDEBUG
-       printf("\nTriangleDeflection() from IntPolyh_Triangle : L23=0\n");
-       P2.Dump();
-       P3.Dump();
-# endif
-      }
-      if (L31<SquareMyConfusionPrecision) {
-# if MYDEBUG
-       printf("\nTriangleDeflection() from IntPolyh_Triangle : L31=0\n");
-       P3.Dump();
-       P1.Dump();
-# endif
-      }
-
       IntPolyh_Point Milieu; // milieu du plus grand des edges
 
       if ((L12>L23) && (L12>L31))
@@ -168,11 +382,17 @@ void IntPolyh_Triangle::TriangleDeflection(const Handle(Adaptor3d_HSurface)& MyS
     }
 }
 
-Standard_Integer IntPolyh_Triangle::CheckCommonEdge(const Standard_Integer PT1,
-                                                   const Standard_Integer PT2,
-                                                   const Standard_Integer PT3,
-                                                   const Standard_Integer Index,
-                                                   const IntPolyh_ArrayOfTriangles &TTriangles) const {
+//=======================================================================
+//function : CheckCommonEdge
+//purpose  : 
+//=======================================================================
+Standard_Integer 
+  IntPolyh_Triangle::CheckCommonEdge(const Standard_Integer PT1,
+                                    const Standard_Integer PT2,
+                                    const Standard_Integer PT3,
+                                    const Standard_Integer Index,
+                                    const IntPolyh_ArrayOfTriangles &TTriangles)  const 
+{
   Standard_Integer P1,P2,P3,res=-1;
   P1=TTriangles[Index].FirstPoint();
   P2=TTriangles[Index].SecondPoint();
@@ -188,10 +408,15 @@ Standard_Integer IntPolyh_Triangle::CheckCommonEdge(const Standard_Integer PT1,
   else res=-1;
   return(res);
 }
-
-Standard_Integer IntPolyh_Triangle::GetNextTriangle2(const Standard_Integer NumTri,
-                                                    const Standard_Integer NumEdge,
-                                                    const IntPolyh_ArrayOfEdges &TEdges) const {
+//=======================================================================
+//function : GetNextTriangle2
+//purpose  : 
+//=======================================================================
+Standard_Integer 
+  IntPolyh_Triangle::GetNextTriangle2(const Standard_Integer NumTri,
+                                     const Standard_Integer NumEdge,
+                                     const IntPolyh_ArrayOfEdges &TEdges) const 
+{
   Standard_Integer NumNextTri=-1;
   if (NumEdge==1) {
     const IntPolyh_Edge & Edge1=TEdges[e1];
@@ -214,26 +439,20 @@ Standard_Integer IntPolyh_Triangle::GetNextTriangle2(const Standard_Integer NumT
     else
       NumNextTri=Edge3.FirstTriangle();
   }
-  else {
-# if MYDEBUG
-    printf("\nTriangleDeflection() from IntPolyh_Triangle :\n");
-    printf("Edge index != {1,2,3}, Edge Number=%d\n",NumEdge);
-# endif
-  }
   return (NumNextTri);
 }
 
 
+//=======================================================================
+//function : LinkEdges2Triangle
+//purpose  : 
+//=======================================================================
 void IntPolyh_Triangle::LinkEdges2Triangle(const IntPolyh_ArrayOfEdges & TEdges,
                                           const Standard_Integer edge1,
                                           const Standard_Integer edge2,
                                           const Standard_Integer edge3) {
   if( (edge1<0)||(edge2<0)||(edge3<0) ) {
-# if MYDEBUG
-    printf("LinkEdges2Triangle() from IntPolyh_Triangle.cxx :/n");
-    printf("Some edges are unknown LinkEdges2Triangle impossible\n");
-    printf("edge1=%d edge2=%d edge3=%d\n",edge1,edge2,edge3);
-# endif
+
   }
   else {
     e1=edge1;  
@@ -249,6 +468,10 @@ void IntPolyh_Triangle::LinkEdges2Triangle(const IntPolyh_ArrayOfEdges & TEdges,
   }
 }
 
+//=======================================================================
+//function : GetInfoTA
+//purpose  : 
+//=======================================================================
 void GetInfoTA(const Standard_Integer numP1,
               const Standard_Integer numP2,
               const Standard_Integer numTA,
@@ -256,7 +479,8 @@ void GetInfoTA(const Standard_Integer numP1,
               Standard_Integer & numP3b,
               Standard_Integer & P3bIndex,
               Standard_Integer & Edge2b,
-              Standard_Integer & Edge3b) {
+              Standard_Integer & Edge3b)
+{
   /// On veut savoir quel est le troisieme point du triangle
   /// adjacent (TriAdj) et quel sont les edges partant de ce point
   const IntPolyh_Triangle & TriAdj=TTriangles[numTA];
@@ -306,13 +530,12 @@ void GetInfoTA(const Standard_Integer numP1,
      Edge3b=TriAdj.ThirdEdge();
     }
   }      
-  if(numP3b<0) {
-# if MYDEBUG
-    printf("ERROR1 refinement with null Point\n");
-# endif
-  }
 }
 
+//=======================================================================
+//function : NewTriangle
+//purpose  : 
+//=======================================================================
 void NewTriangle(const Standard_Integer P1,
                 const Standard_Integer P2,
                 const Standard_Integer P3,
@@ -327,16 +550,19 @@ void NewTriangle(const Standard_Integer P1,
   TTriangles.IncNbTriangles();
 }
 
+//=======================================================================
+//function : NewEdge
+//purpose  : 
+//=======================================================================
 void NewEdge(const Standard_Integer P1,
             const Standard_Integer P2,
             const Standard_Integer T1,
             const Standard_Integer T2,
-            IntPolyh_ArrayOfEdges & TEdges) {
-//#ifndef DEB
+            IntPolyh_ArrayOfEdges & TEdges)
+{
+
   const Standard_Integer FinTE = TEdges.NbEdges();
-//#else
-//  const FinTE = TEdges.NbEdges();
-//#endif
+
   TEdges[FinTE].SetFirstPoint(P1);
   TEdges[FinTE].SetSecondPoint(P2);
   TEdges[FinTE].SetFirstTriangle(T1);
@@ -344,14 +570,27 @@ void NewEdge(const Standard_Integer P1,
   TEdges.IncNbEdges();
 }
 
+//=======================================================================
+//function : OldEdge
+//purpose  : 
+//=======================================================================
 void OldEdge(const Standard_Integer EdgeN,
             const Standard_Integer NumTri,
             const Standard_Integer NewTriNum,
-            IntPolyh_ArrayOfEdges & TEdges) {
-  if(TEdges[EdgeN].FirstTriangle()==NumTri) TEdges[EdgeN].SetFirstTriangle(NewTriNum);
-  else TEdges[EdgeN].SetSecondTriangle(NewTriNum);
+            IntPolyh_ArrayOfEdges & TEdges) 
+{
+  if(TEdges[EdgeN].FirstTriangle()==NumTri){
+    TEdges[EdgeN].SetFirstTriangle(NewTriNum);
+  }
+  else{
+    TEdges[EdgeN].SetSecondTriangle(NewTriNum);
+  }
 }
 
+//=======================================================================
+//function : TestOldEdgeB
+//purpose  : 
+//=======================================================================
 void TestOldEdgeB(const Standard_Integer NumTA,
                  const Standard_Integer numPtT1,
                  const Standard_Integer numPtT2,
@@ -360,7 +599,8 @@ void TestOldEdgeB(const Standard_Integer NumTA,
                  const IntPolyh_ArrayOfTriangles & TTriangles,
                  const Standard_Integer Edge1,
                  const Standard_Integer Edge3,
-                 IntPolyh_ArrayOfEdges & TEdges ) {
+                 IntPolyh_ArrayOfEdges & TEdges )
+{
 
   if( (TEdges[Edge1].FirstPoint() == numPtT1)
      ||(TEdges[Edge1].SecondPoint()== numPtT1) ) {
@@ -383,8 +623,10 @@ void TestOldEdgeB(const Standard_Integer NumTA,
     else TEdges[Edge1].SetSecondTriangle(T2);
   }
 }
-
-
+//=======================================================================
+//function : MiddleRefinement
+//purpose  : 
+//=======================================================================
 void IntPolyh_Triangle::MiddleRefinement(const Standard_Integer NumTri,
                                         const Handle(Adaptor3d_HSurface)& MySurface,
                                         IntPolyh_ArrayOfPoints &TPoints,
@@ -679,6 +921,10 @@ void IntPolyh_Triangle::MiddleRefinement(const Standard_Integer NumTri,
   TPoints.IncNbPoints();
 }
 
+//=======================================================================
+//function : MultipleMiddleRefinement
+//purpose  : 
+//=======================================================================
 void IntPolyh_Triangle::MultipleMiddleRefinement(const Standard_Integer NbAffinages,
                                                 const Standard_Integer NumTri,
                                                 const Handle(Adaptor3d_HSurface)& MySurface,
@@ -720,6 +966,10 @@ void IntPolyh_Triangle::MultipleMiddleRefinement(const Standard_Integer NbAffina
   }
 }
 
+//=======================================================================
+//function : CompareBoxTriangle
+//purpose  : 
+//=======================================================================
 Standard_Integer IntPolyh_Triangle::CompareBoxTriangle(const Bnd_Box &b,
                                                       const IntPolyh_ArrayOfPoints &TPoints) const{
   Standard_Integer Test=0;
@@ -742,6 +992,10 @@ Standard_Integer IntPolyh_Triangle::CompareBoxTriangle(const Bnd_Box &b,
   //Pour gagner du temps on pourrait envisager de garder la boite englobante dans la structure du triangle
 }
 
+//=======================================================================
+//function : MultipleMiddleRefinement2
+//purpose  : 
+//=======================================================================
 void IntPolyh_Triangle::MultipleMiddleRefinement2(const Standard_Real CritereAffinage,
                                                  const Bnd_Box &b,//boite englobante de l'autre surface
                                                  const Standard_Integer NumTri,
@@ -773,23 +1027,22 @@ void IntPolyh_Triangle::MultipleMiddleRefinement2(const Standard_Real CritereAff
   }
 }
 
+//=======================================================================
+//function : SetEdgeandOrientation
+//purpose  : 
+//=======================================================================
 void IntPolyh_Triangle::SetEdgeandOrientation(const Standard_Integer EdgeIndex,
                                              const IntPolyh_ArrayOfEdges &TEdges) {
   const Standard_Integer FinTE = TEdges.NbEdges();
-#ifndef DEB
+
   Standard_Integer PE1 =0,PE2 =0;
-#else
-  Standard_Integer PE1,PE2;
-#endif
+
   Standard_Integer Test=1;
 
   if (EdgeIndex==1) { PE1=p1; PE2=p2; }
   else if (EdgeIndex==2) { PE1=p2; PE2=p3; }
   else if (EdgeIndex==3) { PE1=p3; PE2=p1; }
   else { 
-# if MYDEBUG
-    printf("SetEdgeandOrientation() from IntPolyh_Triangle.cxx : No edge, No Edge\n");
-# endif
     Test=0;
   }
   if (Test!=0) {
@@ -805,9 +1058,7 @@ void IntPolyh_Triangle::SetEdgeandOrientation(const Standard_Integer EdgeIndex,
          }
        }
        else {
-# if MYDEBUG
-         printf("SetEdgeandOrientation() from IntPolyh_Triangle.cxx : WARNING NULL EDGE\n");
-# endif
+
          Test=0;
        }
       }
@@ -821,9 +1072,7 @@ void IntPolyh_Triangle::SetEdgeandOrientation(const Standard_Integer EdgeIndex,
          }
        }
        else {
-# if MYDEBUG
-         printf("SetEdgeandOrientation() from IntPolyh_Triangle.cxx : WARNING NULL EDGE\n");
-# endif
+
        }   
       }
     }
@@ -831,72 +1080,22 @@ void IntPolyh_Triangle::SetEdgeandOrientation(const Standard_Integer EdgeIndex,
 }
 
 
-void IntPolyh_Triangle::Dump (const Standard_Integer i) const { 
+//=======================================================================
+//function : Dump
+//purpose  : 
+//=======================================================================
+void IntPolyh_Triangle::Dump (const Standard_Integer i) const
+{ 
   printf("\nTriangle(%3d) : Points %5d %5d %5d Edges %5d %5d %5d fleche: %8f  intersection possible %8d  intersection: %5d\n"
         ,i,p1,p2,p3,e1,e2,e3,Fleche,IP,II);
 }
 
 
+//=======================================================================
+//function : DumpFleche
+//purpose  : 
+//=======================================================================
 void IntPolyh_Triangle::DumpFleche (const Standard_Integer i) const { 
   printf("\nTriangle(%3d) fleche: %5f\n",i,Fleche);
 }
 
-
-
-/* Affinage par le barycentre
-      calcul du barycentre
-      remaillage
-
-  void IntPolyh_MaillageAffinage::RefinementG(const Standard_Integer SurfID,
-  IntPolyh_Triangle& MonTriangle){
-  
-  Handle(Adaptor3d_HSurface) MaSurface=(SurfID==1)? MaSurface1:MaSurface2;
-  IntPolyh_ArrayOfPoints &TPoints=(SurfID==1)? TPoints1:TPoints2;
-  IntPolyh_ArrayOfTriangles &TTriangles=(SurfID==1)? TTriangles1:TTriangles2;
-  Standard_Integer NbSamplesU=(SurfID==1)? NbSamplesU1:NbSamplesU2;
-  Standard_Integer NbSamplesV=(SurfID==1)? NbSamplesV1:NbSamplesV2;
-  
-  Standard_Integer FinTP = TPoints.NbPoints();
-  Standard_Integer FinTT = TTriangles.NbTriangles();
-
-
-  Standard_Integer P1 = MonTriangle.FirstPoint();
-  Standard_Integer P2 = MonTriangle.SecondPoint();
-  Standard_Integer P3 = MonTriangle.ThirdPoint();
-  
-  
-  Standard_Real U,V,x,y,z;
-  U = (TPoints[P1].U()+TPoints[P2].U()+TPoints[P3].U())/3.0;
-  V = (TPoints[P1].V()+TPoints[P2].V()+TPoints[P3].V())/3.0;
-  
-  gp_Pnt PtXYZ = (MaSurface)->Value(U, V);
-  IntPolyh_Point BarycentreTriangleReel(PtXYZ.X(), PtXYZ.Y(), PtXYZ.Z(), U, V);
-  TPoints[FinTP]=BarycentreTriangleReel;
-  
-  TTriangles[FinTT].SetFirstPoint(P1);
-  TTriangles[FinTT].SetSecondPoint(P2);
-  TTriangles[FinTT].SetThirdPoint(FinTP);
-  (TTriangles[FinTT]).TriangleDeflection(MaSurface, TPoints);
-  FinTT++;
-  
-  TTriangles[FinTT].SetFirstPoint(P2);
-  TTriangles[FinTT].SetSecondPoint(P3);
-  TTriangles[FinTT].SetThirdPoint(FinTP);
-  (TTriangles[FinTT]).TriangleDeflection(MaSurface, TPoints);
-  FinTT++;
-  
-  TTriangles[FinTT].SetFirstPoint(P3);
-  TTriangles[FinTT].SetSecondPoint(P1);
-  TTriangles[FinTT].SetThirdPoint(FinTP);
-  (TTriangles[FinTT]).TriangleDeflection(MaSurface, TPoints);
-  FinTT++;
-  
-  //  FinTP++;
-  TPoints.IncNbPoints();
-  TTriangles.SetNbTriangles(FinTT);
-  //   Le triangle traite est maintenant obsolete 
-  MonTriangle.SetFleche(-1.0);
-  }*/
-
-
-