0027341: Incorrect exact HLR results
[occt.git] / src / HLRBRep / HLRBRep_Data.cxx
index 8b26212..4f6ac72 100644 (file)
 
 //#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;
@@ -186,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;
@@ -233,7 +243,7 @@ public:
   } 
   //-- ============================================================
   void Destroy() {
-#ifdef DEB
+#ifdef OCCT_DEBUG
     if(N) { 
       Standard_Integer nnn=0;
       StNbMoy=StNbMoyNonNul=0;
@@ -267,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;
@@ -347,7 +361,7 @@ public:
   //-- ============================================================
   Standard_Real Get(Standard_Integer i0,Standard_Integer j0) { 
     i0--; j0--;
-#ifdef DEB
+#ifdef OCCT_DEBUG
     StNbLect++;
 #endif
 
@@ -760,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;
@@ -794,7 +808,7 @@ void HLRBRep_Data::Update (const HLRAlgo_Projector& P)
     fd->Side(FS.IsSide(tol,myToler*10));
     Standard_Boolean inverted = Standard_False;
     if (fd->WithOutL() && !fd->Side()) {
-      //inverted = OrientOutLine(face,*fd);
+      inverted = OrientOutLine(face,*fd);
       OrientOthEdge(face,*fd);
     }
     if (fd->Side()) {
@@ -814,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);
@@ -880,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())
@@ -1211,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();
        //-- -----------------------------------------------------------------------
@@ -1353,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 
@@ -1519,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
     }
@@ -1527,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
   }
@@ -1592,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
@@ -1621,12 +1633,10 @@ TopAbs_State HLRBRep_Data::Compare (const Standard_Integer E,
 //=======================================================================
 
 
-#ifdef DEB
 Standard_Boolean HLRBRep_Data::OrientOutLine (const Standard_Integer I, HLRBRep_FaceData& FD)
-#else
-Standard_Boolean HLRBRep_Data::OrientOutLine (const Standard_Integer, HLRBRep_FaceData& FD)
-#endif
 {
+  (void)I; // avoid compiler warning
+
   const Handle(HLRAlgo_WiresBlock)& wb = FD.Wires();
   Standard_Integer nw = wb->NbWires();
   Standard_Integer iw1,ie1,ne1;
@@ -1678,7 +1688,7 @@ Standard_Boolean HLRBRep_Data::OrientOutLine (const Standard_Integer, HLRBRep_Fa
            (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;
@@ -1691,7 +1701,7 @@ Standard_Boolean HLRBRep_Data::OrientOutLine (const Standard_Integer, HLRBRep_Fa
          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;
@@ -1713,7 +1723,7 @@ Standard_Boolean HLRBRep_Data::OrientOutLine (const Standard_Integer, HLRBRep_Fa
          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;
@@ -1773,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
       }
     }
   }
@@ -1823,12 +1837,14 @@ void HLRBRep_Data::OrientOthEdge (const Standard_Integer I,
     VertMax[15] = (Standard_Integer)((myDeca[15]+TotMax[15])*mySurD[15]); 
 
 TopAbs_State 
-HLRBRep_Data::Classify (const Standard_Integer /*E*/,
+HLRBRep_Data::Classify (const Standard_Integer E,
                        const HLRBRep_EdgeData& ED,
                        const Standard_Boolean LevelFlag,
                        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];
@@ -1972,9 +1988,7 @@ HLRBRep_Data::Classify (const Standard_Integer /*E*/,
                          (Standard_Address)VertMax,
                          (Standard_Address)MinMaxVert);
 
-
-
-#if 0 
+#ifdef OCCT_DEBUG
        {
          Standard_Integer qwe,qwep8,q,q1,q2;
          printf("\n E:%d -------\n",E);
@@ -2014,9 +2028,6 @@ HLRBRep_Data::Classify (const Standard_Integer /*E*/,
        }
  #endif
 
-
-
-
     if (((MaxFace1 - MinVert1) & 0x80008000) != 0 ||
        ((MaxVert1 - MinFace1) & 0x80008000) != 0 ||
        ((MaxFace2 - MinVert2) & 0x80008000) != 0 ||