0026173: Wrong result of ChFi3d_ChBuilder algorithm: incorrect processing of G1 junct...
[occt.git] / src / ChFi3d / ChFi3d_Builder.cxx
index 0637465..eb7bba3 100644 (file)
@@ -5,8 +5,8 @@
 //
 // This file is part of Open CASCADE Technology software library.
 //
-// This library is free software; you can redistribute it and / or modify it
-// under the terms of the GNU Lesser General Public version 2.1 as published
+// 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.
 // Alternatively, this file may be used under the terms of Open CASCADE
 // commercial license or contractual agreement.
 
-#include <ChFi3d_Builder.ixx>
 
+#include <Adaptor2d_HCurve2d.hxx>
+#include <Adaptor3d_HSurface.hxx>
+#include <Adaptor3d_TopolTool.hxx>
+#include <AppBlend_Approx.hxx>
+#include <Blend_CurvPointFuncInv.hxx>
+#include <Blend_FuncInv.hxx>
+#include <Blend_Function.hxx>
+#include <Blend_RstRstFunction.hxx>
+#include <Blend_SurfCurvFuncInv.hxx>
+#include <Blend_SurfPointFuncInv.hxx>
+#include <Blend_SurfRstFunction.hxx>
+#include <BRep_Builder.hxx>
+#include <BRep_Tool.hxx>
+#include <BRepAdaptor_HCurve2d.hxx>
+#include <BRepAdaptor_HSurface.hxx>
+#include <BRepBlend_Line.hxx>
+#include <BRepLib.hxx>
+#include <BRepTopAdaptor_TopolTool.hxx>
+#include <ChFi3d.hxx>
+#include <ChFi3d_Builder.hxx>
+#include <ChFi3d_Builder_0.hxx>
+#include <ChFiDS_CommonPoint.hxx>
+#include <ChFiDS_HData.hxx>
+#include <ChFiDS_HElSpine.hxx>
+#include <ChFiDS_ListIteratorOfListOfStripe.hxx>
+#include <ChFiDS_SequenceOfSurfData.hxx>
+#include <ChFiDS_Spine.hxx>
+#include <ChFiDS_Stripe.hxx>
+#include <ChFiDS_SurfData.hxx>
+#include <Geom2d_Curve.hxx>
+#include <Geom_Surface.hxx>
+#include <gp_Pnt2d.hxx>
+#include <Precision.hxx>
+#include <ShapeFix.hxx>
+#include <Standard_ConstructionError.hxx>
+#include <Standard_ErrorHandler.hxx>
 #include <Standard_Failure.hxx>
 #include <Standard_NoSuchObject.hxx>
 #include <Standard_NotImplemented.hxx>
-#include <Standard_ErrorHandler.hxx>
+#include <Standard_OutOfRange.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
 #include <TColStd_MapIteratorOfMapOfInteger.hxx>
 #include <TColStd_MapOfInteger.hxx>
-#include <TColStd_ListIteratorOfListOfInteger.hxx>
-
-#include <TopoDS.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Vertex.hxx>
-
 #include <TopAbs.hxx>
-#include <TopAbs_ShapeEnum.hxx>
 #include <TopAbs_Orientation.hxx>
-#include <BRep_Builder.hxx>
-#include <BRep_Tool.hxx>
+#include <TopAbs_ShapeEnum.hxx>
 #include <TopExp.hxx>
 #include <TopExp_Explorer.hxx>
-#include <TopTools_ListOfShape.hxx>
-#include <TopTools_ListIteratorOfListOfShape.hxx>
-
+#include <TopoDS.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Vertex.hxx>
+#include <TopOpeBRepBuild_HBuilder.hxx>
+#include <TopOpeBRepDS_BuildTool.hxx>
+#include <TopOpeBRepDS_Curve.hxx>
 #include <TopOpeBRepDS_CurveExplorer.hxx>
 #include <TopOpeBRepDS_CurvePointInterference.hxx>
 #include <TopOpeBRepDS_DataStructure.hxx>
-#include <TopOpeBRepDS_BuildTool.hxx>
-#include <TopOpeBRepDS_Curve.hxx>
+#include <TopOpeBRepDS_HDataStructure.hxx>
+#include <TopOpeBRepDS_ListOfInterference.hxx>
 #include <TopOpeBRepDS_PointIterator.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
-
-#include <BRep_Tool.hxx>
-#include <ChFiDS_Stripe.hxx>
-#include <ChFiDS_ListIteratorOfListOfStripe.hxx>
-#include <ChFiDS_SequenceOfSurfData.hxx>
-#include <ChFiDS_HData.hxx>
-
-#include <ChFi3d.hxx>
-
-#include <ChFi3d_Builder_0.hxx>
-#include <TopOpeBRepDS_ListOfInterference.hxx>
-#include <BRepLib.hxx>
-#include <ShapeFix.hxx>
-#include <Precision.hxx>
+#include <TopTools_ListOfShape.hxx>
 
 #ifdef DRAW
 #include <TestTopOpeTools.hxx>
 #include <TestTopOpe.hxx>
 #endif
-#ifdef DEB
+#ifdef OCCT_DEBUG
 #include <OSD_Chronometer.hxx>
 
 
@@ -163,7 +181,8 @@ void ChFi3d_Builder::ExtentAnalyse ()
   for (Standard_Integer iv = 1; iv <= myVDataMap.Extent(); iv++) {
     nbs = myVDataMap(iv).Extent();
     const TopoDS_Vertex& Vtx = myVDataMap.FindKey(iv);
-    nbedges = ChFi3d_NumberOfEdges(Vtx, myVEMap); 
+    //nbedges = ChFi3d_NumberOfEdges(Vtx, myVEMap); 
+    nbedges = ChFi3d_NumberOfSharpEdges(Vtx, myVEMap, myEFMap); 
     switch (nbs) {
     case 1 :
       ExtentOneCorner(Vtx, myVDataMap.FindFromIndex(iv).First());
@@ -190,7 +209,7 @@ void ChFi3d_Builder::ExtentAnalyse ()
 void  ChFi3d_Builder::Compute()
 {
   
-#ifdef DEB   //perf 
+#ifdef OCCT_DEBUG   //perf 
   t_total=0;t_extent=0; t_perfsetofsurf=0;t_perffilletonvertex=0;
   t_filds=0;t_reconstruction=0;t_setregul=0;
   t_perfsetofkpart=0; t_perfsetofkgen=0;t_makextremities=0;
@@ -236,7 +255,7 @@ void  ChFi3d_Builder::Compute()
   ExtentAnalyse();
   
   
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
   ChFi3d_ResultChron(cl_extent,t_extent);
   ChFi3d_InitChron(cl_perfsetofsurf);
 #endif
@@ -250,7 +269,7 @@ void  ChFi3d_Builder::Compute()
     }
     catch(Standard_Failure) {
       Handle(Standard_Failure) exc = Standard_Failure::Caught();
-#ifdef DEB
+#ifdef OCCT_DEBUG
       cout <<"EXCEPTION Stripe compute " << exc << endl;
 #endif
       badstripes.Append(itel.Value());
@@ -263,7 +282,7 @@ void  ChFi3d_Builder::Compute()
   }
   done = (badstripes.IsEmpty());
   
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
   ChFi3d_ResultChron(cl_perfsetofsurf,t_perfsetofsurf);
   ChFi3d_InitChron(cl_perffilletonvertex);
 #endif 
@@ -281,7 +300,7 @@ void  ChFi3d_Builder::Compute()
       catch(Standard_Failure)
       {
         Handle(Standard_Failure) exc = Standard_Failure::Caught();
-#ifdef DEB
+#ifdef OCCT_DEBUG
         cout <<"EXCEPTION Corner compute " << exc << endl;
 #endif
         badvertices.Append(myVDataMap.FindKey(j));
@@ -295,7 +314,7 @@ void  ChFi3d_Builder::Compute()
   }
   
 
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
   ChFi3d_ResultChron(cl_perffilletonvertex,t_perffilletonvertex);
   ChFi3d_InitChron(cl_filds);
 #endif
@@ -336,7 +355,7 @@ void  ChFi3d_Builder::Compute()
        }
        catch(Standard_Failure) {
          Handle(Standard_Failure) exc = Standard_Failure::Caught();
-#ifdef DEB
+#ifdef OCCT_DEBUG
          cout <<"EXCEPTION Fillets compute " << exc << endl;
 #endif
          badstripes.Append(itel.Value());
@@ -351,7 +370,7 @@ void  ChFi3d_Builder::Compute()
       if (!done) break;
     }
     
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
     ChFi3d_ResultChron(cl_filds,t_filds);
     ChFi3d_InitChron(cl_reconstruction);
 #endif
@@ -466,7 +485,7 @@ void  ChFi3d_Builder::Compute()
        }
       }
       }
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
       ChFi3d_ResultChron(cl_reconstruction ,t_reconstruction);
       ChFi3d_InitChron(cl_setregul);
 #endif
@@ -475,29 +494,29 @@ void  ChFi3d_Builder::Compute()
       SetRegul();
       
       
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
  ChFi3d_ResultChron(cl_setregul ,t_setregul);
 #endif
     }
   }
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
   ChFi3d_ResultChron(cl_total,t_total);
 #endif
       
   
   // display of time for perfs 
   
-#ifdef DEB  
-  cout<<endl; 
-  cout<<"COMPUTE: temps total "<<t_total<<"s  dont :"<<endl;
-  cout<<"- Init + ExtentAnalyse "<<t_extent<<"s"<<endl;  
-  cout<<"- PerformSetOfSurf "<<t_perfsetofsurf<<"s"<<endl;
-  cout<<"- PerformFilletOnVertex "<<t_perffilletonvertex<<"s"<<endl; 
-  cout<<"- FilDS "<<t_filds<<"s"<<endl; 
-  cout<<"- Reconstruction "<<t_reconstruction<<"s"<<endl;
-  cout<<"- SetRegul "<<t_setregul<<"s"<<endl<<endl;
-  
+#ifdef OCCT_DEBUG
   if(ChFi3d_GettraceCHRON()){
+    cout<<endl; 
+    cout<<"COMPUTE: temps total "<<t_total<<"s  dont :"<<endl;
+    cout<<"- Init + ExtentAnalyse "<<t_extent<<"s"<<endl;  
+    cout<<"- PerformSetOfSurf "<<t_perfsetofsurf<<"s"<<endl;
+    cout<<"- PerformFilletOnVertex "<<t_perffilletonvertex<<"s"<<endl; 
+    cout<<"- FilDS "<<t_filds<<"s"<<endl; 
+    cout<<"- Reconstruction "<<t_reconstruction<<"s"<<endl;
+    cout<<"- SetRegul "<<t_setregul<<"s"<<endl<<endl;
+
     cout<<endl;
     cout <<"temps PERFORMSETOFSURF "<<t_perfsetofsurf <<"s  dont : "<<endl;
     cout <<"- SetofKPart "<<t_perfsetofkpart<<"s"<<endl;
@@ -692,7 +711,7 @@ void ChFi3d_Builder::PerformFilletOnVertex
     if (BRep_Tool::Degenerated(cur)) nba--;
   }
   nba=nba/2;*/
-  Standard_Integer nba = ChFi3d_NumberOfEdges(Vtx, myVEMap);
+  Standard_Integer nba = ChFi3d_NumberOfSharpEdges(Vtx, myVEMap, myEFMap);
 
   if (nondegenere) { // Normal processing
     switch (i) {
@@ -700,22 +719,22 @@ void ChFi3d_Builder::PerformFilletOnVertex
       {
        if(sp->Status(isfirst) == ChFiDS_FreeBoundary) return; 
        if(nba>3) {
-#ifdef DEB //perf    
+#ifdef OCCT_DEBUG //perf    
          ChFi3d_InitChron(cl_performatend);
 #endif
          PerformIntersectionAtEnd(Index);
-#ifdef DEB    
+#ifdef OCCT_DEBUG
          ChFi3d_ResultChron(cl_performatend,t_performatend);
 #endif 
        }
        else { 
-#ifdef DEB //perf    
+#ifdef OCCT_DEBUG //perf    
          ChFi3d_InitChron(cl_perform1corner);
 #endif
           if (MoreSurfdata(Index))
              PerformMoreSurfdata(Index);
          else PerformOneCorner(Index);
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
          ChFi3d_ResultChron(cl_perform1corner,t_perform1corner);
 #endif  
        }
@@ -724,20 +743,20 @@ void ChFi3d_Builder::PerformFilletOnVertex
     case 2 : 
       {
        if(nba>3){
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
          ChFi3d_InitChron(cl_performmore3corner);
 #endif
          PerformMoreThreeCorner(Index, i);
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
          ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
 #endif
        }
        else { 
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
          ChFi3d_InitChron(cl_perform2corner);
 #endif
          PerformTwoCorner(Index);
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
          ChFi3d_ResultChron(cl_perform2corner,t_perform2corner);
 #endif
        }
@@ -746,31 +765,31 @@ void ChFi3d_Builder::PerformFilletOnVertex
     case 3 : 
       {
        if(nba>3){
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
          ChFi3d_InitChron(cl_performmore3corner);
 #endif
          PerformMoreThreeCorner(Index, i);
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
          ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
 #endif
        }
        else {
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
          ChFi3d_InitChron(cl_perform3corner);
 #endif
          PerformThreeCorner(Index);
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
          ChFi3d_ResultChron(cl_perform3corner,t_perform3corner);
 #endif
        }
       }
       break;
       default : {
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
        ChFi3d_InitChron(cl_performmore3corner);
 #endif
        PerformMoreThreeCorner(Index, i);
-#ifdef DEB //perf 
+#ifdef OCCT_DEBUG //perf 
        ChFi3d_ResultChron(cl_performmore3corner,t_performmore3corner);
 #endif
       }