0027557: Unstable HLR tests
[occt.git] / src / HLRBRep / HLRBRep_Data.cxx
old mode 100755 (executable)
new mode 100644 (file)
index 3ef3b7e..63e7ee0
@@ -1,46 +1,47 @@
 // Created on: 1997-04-17
 // Created by: Christophe MARION
 // Copyright (c) 1997-1999 Matra Datavision
-// Copyright (c) 1999-2012 OPEN CASCADE SAS
+// Copyright (c) 1999-2014 OPEN CASCADE SAS
 //
-// The content of this file is subject to the Open CASCADE Technology Public
-// License Version 6.5 (the "License"). You may not use the content of this file
-// except in compliance with the License. Please obtain a copy of the License
-// at http://www.opencascade.org and read it completely before using this file.
+// This file is part of Open CASCADE Technology software library.
 //
-// The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
-// main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
+// This library is free software; you can redistribute it and/or modify it under
+// the terms of the GNU Lesser General Public License version 2.1 as published
+// by the Free Software Foundation, with special exception defined in the file
+// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
+// distribution for complete text of the license and disclaimer of any warranty.
 //
-// The Original Code and all software distributed under the License is
-// distributed on an "AS IS" basis, without warranty of any kind, and the
-// Initial Developer hereby disclaims all such warranties, including without
-// limitation, any warranties of merchantability, fitness for a particular
-// purpose or non-infringement. Please see the License for the specific terms
-// and conditions governing the rights and limitations under the License.
-
+// Alternatively, this file may be used under the terms of Open CASCADE
+// commercial license or contractual agreement.
 
 //#define No_Standard_OutOfRange
 
-#define OCC191 // jfa 26/02/2002 Bug of cone display
-
-#include <HLRBRep_Data.ixx>
-
-#include <StdFail_UndefinedDerivative.hxx>
-#include <Precision.hxx>
-#include <gp_Dir.hxx>
+#include <BRepTopAdaptor_Tool.hxx>
+#include <BRepTopAdaptor_TopolTool.hxx>
+#include <ElCLib.hxx>
 #include <Geom2d_Curve.hxx>
-#include <IntRes2d_IntersectionPoint.hxx>
-#include <IntRes2d_IntersectionSegment.hxx>
-#include <IntCurveSurface_IntersectionPoint.hxx>
-#include <IntCurveSurface_TransitionOnCurve.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <gp.hxx>
+#include <gp_Dir.hxx>
+#include <gp_Dir2d.hxx>
 #include <HLRAlgo.hxx>
+#include <HLRAlgo_Interference.hxx>
 #include <HLRAlgo_ListIteratorOfInterferenceList.hxx>
+#include <HLRAlgo_Projector.hxx>
+#include <HLRBRep_Data.hxx>
+#include <HLRBRep_EdgeData.hxx>
 #include <HLRBRep_EdgeFaceTool.hxx>
-#include <ElCLib.hxx>
-#include <gp.hxx>
+#include <HLRBRep_FaceData.hxx>
+#include <IntCurveSurface_IntersectionPoint.hxx>
+#include <IntCurveSurface_TransitionOnCurve.hxx>
+#include <IntRes2d_IntersectionPoint.hxx>
+#include <IntRes2d_IntersectionSegment.hxx>
+#include <Precision.hxx>
+#include <Standard_Type.hxx>
+#include <StdFail_UndefinedDerivative.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+
 #include <stdio.h>
-#include <BRepTopAdaptor_Tool.hxx>
+IMPLEMENT_STANDARD_RTTIEXT(HLRBRep_Data,MMgt_TShared)
 
 Standard_Integer nbOkIntersection;
 Standard_Integer nbPtIntersection;
@@ -191,26 +192,30 @@ public:
   long unsigned **TabBit;
   Standard_Integer nTabBit;
 
-#ifdef DEB  
+#ifdef OCCT_DEBUG
   Standard_Integer StNbLect,StNbEcr,StNbMax,StNbMoy,StNbMoyNonNul; //-- STAT
 #endif
 
+private:
+  TableauRejection(const TableauRejection&);
+  TableauRejection& operator=(const TableauRejection&);
+
 public:
   //-- ============================================================
   TableauRejection() { 
     N=0; nTabBit=0;  UV=NULL;  nbUV=NULL;  IndUV=NULL; TabBit=NULL;
-#ifdef DEB
+#ifdef OCCT_DEBUG
     StNbLect=StNbEcr=StNbMax=StNbMoy=StNbMoyNonNul=0;
 #endif
   }
   //-- ============================================================
   void SetDim(const Standard_Integer n) {
-#ifdef DEB
+#ifdef OCCT_DEBUG
     cout<<"\n@#@#@#@#@# SetDim "<<n<<endl;
 #endif
     if(UV) 
       Destroy();
-#ifdef DEB
+#ifdef OCCT_DEBUG
     StNbLect=StNbEcr=StNbMax=StNbMoy=0;
 #endif
     N=n;
@@ -238,7 +243,7 @@ public:
   } 
   //-- ============================================================
   void Destroy() {
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if(N) { 
       Standard_Integer nnn=0;
       StNbMoy=StNbMoyNonNul=0;
@@ -272,27 +277,31 @@ public:
          free(IndUV[i]);
          IndUV[i]=NULL;
        }
-       else { cout<<" IndUV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; } 
-              
+#ifdef OCCT_DEBUG
+       else
+          cout<<" IndUV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl;
+#endif
       }
       for(i=0;i<N;i++) { 
        if(UV[i]) { 
          free(UV[i]);
          UV[i]=NULL;
        }
+#ifdef OCCT_DEBUG
        else { cout<<" UV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; } 
+#endif
       }
       
-      if(nbUV)  { free(nbUV);  nbUV=NULL; } else { cout<<" nbUV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; } 
-      if(IndUV) { free(IndUV); IndUV=NULL;} else { cout<<" IndUV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; } 
-      if(UV)    { free(UV);    UV=NULL; }  else { cout<<" UV ~~~~~~~~~~~~~~~~~~~~~~~~~~~~"<<endl; } 
+      if(nbUV)  { free(nbUV);  nbUV=NULL; } 
+      if(IndUV) { free(IndUV); IndUV=NULL;}
+      if(UV) { free(UV);    UV=NULL; }
       N=0;
     }
   }
   //-- ============================================================
   void Set(Standard_Integer i0,Standard_Integer j0,const Standard_Real u) { 
     i0--; j0--;
-#ifdef DEB
+#ifdef OCCT_DEBUG
     StNbEcr++;
 #endif
     Standard_Integer k=-1;
@@ -352,7 +361,7 @@ public:
   //-- ============================================================
   Standard_Real Get(Standard_Integer i0,Standard_Integer j0) { 
     i0--; j0--;
-#ifdef DEB
+#ifdef OCCT_DEBUG
     StNbLect++;
 #endif
 
@@ -464,31 +473,10 @@ public:
     }
   }
 };
-
-
-
 //-- ================================================================================
 
 
-//=======================================================================
-//function : FindInList
-//purpose  : 
-//=======================================================================
-// Unused :
-#ifdef DEB
-static Standard_Boolean FindInList (const TColStd_ListOfInteger& L,
-                                   const Standard_Integer V)
-{
-  for (TColStd_ListIteratorOfListOfInteger ILV(L);
-       ILV.More();
-       ILV.Next()) {
-    if (V == ILV.Value())
-      return Standard_True;
-  }
-  return Standard_False;
-}
-#endif
-
 //=======================================================================
 //function : AdjustParameter
 //purpose  : 
@@ -786,7 +774,7 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P)
     Standard_Boolean withOutL = Standard_False;
     
     for (myFaceItr1.InitEdge(*fd);
-        myFaceItr1.MoreEdge() && !cut && !withOutL;
+        myFaceItr1.MoreEdge();
         myFaceItr1.NextEdge()) {
       if (myFaceItr1.Internal()) {
        withOutL = Standard_True;
@@ -840,21 +828,19 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P)
        myFEOutLine  = myFaceItr1.OutLine    ();
        myFEInternal = myFaceItr1.Internal   ();
        myFEDouble   = myFaceItr1.Double     ();
-       HLRBRep_EdgeData* ed = &(myEData(myFE));
+       HLRBRep_EdgeData* EDataFE1 = &(myEData(myFE));
        if (!myFEDouble &&
            (myFEOri == TopAbs_FORWARD ||
             myFEOri == TopAbs_REVERSED)) {
-         myFEGeom = &(ed->ChangeGeometry());
-         const HLRBRep_Curve& EC = ed->Geometry();
+         myFEGeom = &(EDataFE1->ChangeGeometry());
+         const HLRBRep_Curve& EC = EDataFE1->Geometry();
          p = EC.Parameter3d((EC.LastParameter () +
                              EC.FirstParameter()) / 2);
          if (HLRBRep_EdgeFaceTool::UVPoint(p,myFEGeom,iFaceGeom,pu,pv)) {
            mySLProps.SetParameters(pu,pv);
            gp_Pnt Pt;
            Pt = EC.Value3D(p);
-#ifdef OCC191
             if (mySLProps.IsNormalDefined())
-#endif
             {
               gp_Vec Nm = mySLProps.Normal();
               Pt.Transform(T);
@@ -906,9 +892,9 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P)
         myFaceItr1.MoreEdge();
         myFaceItr1.NextEdge()) {
       myFE = myFaceItr1.Edge();
-      HLRBRep_EdgeData* ed = &(myEData(myFE));
-      if (!fd->Simple()) ed->AutoIntersectionDone(Standard_False);
-      HLRAlgo::DecodeMinMax(ed->MinMax(),
+      HLRBRep_EdgeData* EDataFE2 = &(myEData(myFE));
+      if (!fd->Simple()) EDataFE2->AutoIntersectionDone(Standard_False);
+      HLRAlgo::DecodeMinMax(EDataFE2->MinMax(),
                            (Standard_Address)EdgeMin,
                            (Standard_Address)EdgeMax);
       if (myFaceItr1.BeginningOfWire())
@@ -1237,7 +1223,7 @@ void HLRBRep_Data::NextInterference ()
     if (myFEOri == TopAbs_FORWARD ||
        myFEOri == TopAbs_REVERSED) {
       // Edge from the boundary
-      if (!((HLRBRep_EdgeData*)myFEData)->Vertical() && !myFEDouble) {
+      if (!((HLRBRep_EdgeData*)myFEData)->Vertical() && !(myFEDouble && !myFEOutLine)) {
        // not a vertical edge and not a double Edge
        Standard_Address MinMaxFEdg = ((HLRBRep_EdgeData*)myFEData)->MinMax();
        //-- -----------------------------------------------------------------------
@@ -1379,7 +1365,7 @@ void HLRBRep_Data::NextInterference ()
                  }
                  else {
                    myNbPoints = myNbSegments = 0;
-#ifdef DEB
+#ifdef OCCT_DEBUG
                    cout << "HLRBRep_Data::NextInterference : "; 
                    if (myLE == myFE) 
                      cout << "Edge " << myLE 
@@ -1545,7 +1531,7 @@ void HLRBRep_Data::EdgeState (const Standard_Real p1,
     else {
       stbef = TopAbs_OUT;
       staft = TopAbs_OUT;
-#ifdef DEB
+#ifdef OCCT_DEBUG
     cout << "HLRBRep_Data::EdgeState : undefined" << endl;
 #endif
     }
@@ -1553,7 +1539,7 @@ void HLRBRep_Data::EdgeState (const Standard_Real p1,
   else {
     stbef = TopAbs_OUT;
     staft = TopAbs_OUT; 
-#ifdef DEB
+#ifdef OCCT_DEBUG
     cout << "HLRBRep_Data::EdgeState : undefined" << endl;
 #endif
   }
@@ -1618,7 +1604,7 @@ HLRBRep_Data::HidingStartLevel (const Standard_Integer E,
     else if (p > param + tolpar)
       Loop = Standard_False;
     else {
-#ifdef DEB  
+#ifdef OCCT_DEBUG
       cout << "HLRBRep_Data::HidingStartLevel : ";
       cout << "Bad Parameter." << endl;
 #endif
@@ -1646,10 +1632,11 @@ TopAbs_State HLRBRep_Data::Compare (const Standard_Integer E,
 //purpose  : 
 //=======================================================================
 
-Standard_Boolean
-HLRBRep_Data::OrientOutLine (const Standard_Integer I,
-                            HLRBRep_FaceData& FD)
+
+Standard_Boolean HLRBRep_Data::OrientOutLine (const Standard_Integer I, HLRBRep_FaceData& FD)
 {
+  (void)I; // avoid compiler warning
+
   const Handle(HLRAlgo_WiresBlock)& wb = FD.Wires();
   Standard_Integer nw = wb->NbWires();
   Standard_Integer iw1,ie1,ne1;
@@ -1701,7 +1688,7 @@ HLRBRep_Data::OrientOutLine (const Standard_Integer I,
            (iFaceGeom,pu,pv,V);
          gp_Vec Nm = mySLProps.Normal();
          if (curv == 0) {
-#ifdef DEB  
+#ifdef OCCT_DEBUG
            cout << "HLRBRep_Data::OrientOutLine " << I;
            cout << " Edge " << myFE << " : ";
            cout << "CurvatureValue == 0." << endl;
@@ -1714,7 +1701,7 @@ HLRBRep_Data::OrientOutLine (const Standard_Integer I,
          Nm.Transform(T);
          Nm.Cross(Tg);
          if (Tg.Magnitude() < gp::Resolution()) {
-#ifdef DEB  
+#ifdef OCCT_DEBUG
            cout << "HLRBRep_Data::OrientOutLine " << I;
            cout << " Edge " << myFE << " : ";
            cout << "Tg.Magnitude() == 0." << endl;
@@ -1736,7 +1723,7 @@ HLRBRep_Data::OrientOutLine (const Standard_Integer I,
          eb1->Orientation(ie1,myFEOri);
        }
        else {
-#ifdef DEB  
+#ifdef OCCT_DEBUG
          cout << "HLRBRep_Data::OrientOutLine " << I;
          cout << " Edge " << myFE << " : ";
          cout << "UVPoint not found, OutLine not Oriented" << endl;
@@ -1796,11 +1783,15 @@ void HLRBRep_Data::OrientOthEdge (const Standard_Integer I,
            eb1->Orientation(ie1,myFEOri);
          }
        }
+#ifdef OCCT_DEBUG
        else {
          cout << "HLRBRep_Data::OrientOthEdge " << I;
          cout << " Edge " << myFE << " : ";
          cout << "UVPoint not found, Edge not Oriented" << endl;
        }
+#else
+        (void)I; // avoid compiler warning
+#endif
       }
     }
   }
@@ -1852,6 +1843,8 @@ HLRBRep_Data::Classify (const Standard_Integer E,
                        Standard_Integer& Level,
                        const Standard_Real param)
 {
+  (void)E; // avoid compiler warning
+
   nbClassification++;
   Standard_Integer VertMin[16],VertMax[16],MinMaxVert[16];
   Standard_Real TotMin[16],TotMax[16];
@@ -1994,10 +1987,8 @@ HLRBRep_Data::Classify (const Standard_Integer E,
     HLRAlgo::EncodeMinMax((Standard_Address)VertMin,
                          (Standard_Address)VertMax,
                          (Standard_Address)MinMaxVert);
-
-
-
-#if 0 
+    /*
+#ifdef OCCT_DEBUG
        {
          Standard_Integer qwe,qwep8,q,q1,q2;
          printf("\n E:%d -------\n",E);
@@ -2036,9 +2027,7 @@ HLRBRep_Data::Classify (const Standard_Integer E,
          cout<<endl;
        }
  #endif
-
-
-
+    */
 
     if (((MaxFace1 - MinVert1) & 0x80008000) != 0 ||
        ((MaxVert1 - MinFace1) & 0x80008000) != 0 ||
@@ -2121,7 +2110,9 @@ HLRBRep_Data::Classify (const Standard_Integer E,
            
            do {
              gp_Pnt2d pnt2d(u,v);
-             if (myClassifier->Classify(pnt2d,0.0)!=TopAbs_OUT) {
+             if (myClassifier->Classify(pnt2d,Precision::PConfusion())
+                  != TopAbs_OUT)
+              {
                InsideRestriction = Standard_True;
                state = TopAbs_IN;
                Level++;
@@ -2148,7 +2139,7 @@ HLRBRep_Data::Classify (const Standard_Integer E,
 //purpose  : 
 //=======================================================================
 
-TopAbs_State HLRBRep_Data::SimplClassify (const Standard_Integer E,
+TopAbs_State HLRBRep_Data::SimplClassify (const Standard_Integer /*E*/,
                                          const HLRBRep_EdgeData& ED,
                                          const Standard_Integer Nbp,
                                          const Standard_Real p1,