]> OCCT Git - occt-copy.git/commitdiff
Debug CR29523_v720
authornbv <nbv@opencascade.com>
Tue, 24 Apr 2018 14:15:21 +0000 (17:15 +0300)
committernbv <nbv@opencascade.com>
Sat, 28 Apr 2018 07:29:31 +0000 (10:29 +0300)
src/BRepFill/BRepFill_Voluved.cxx
src/QABugs/QABugs_20.cxx

index 12efc6f416e8dd5589bc75df560e8df1107d28e8..df425dcbe7fc20ed293363223fa49f2862ba29e0 100644 (file)
 #include <ShapeFix_Shape.hxx>
 #include <BRepClass_FaceClassifier.hxx>
 #include <BRepGProp_Face.hxx>
+#include <BinTools.hxx>
 
 static const Standard_Real aPipeLinearTolerance = 1.0e-4;
 static const Standard_Real aPipeAngularTolerance = 1.0e-2;
 
+static const Standard_Boolean isParallelComputation = Standard_False;
+const char aDirPatch[] = "D:\\nbv-29523\\shapes\\my\\";
+
 static Standard_Boolean CheckSingularityAndAdd(const TopoDS_Face& theF,
                                                const Standard_Real theFuzzyToler,
                                                TopTools_ListOfShape& theListOfFaces,
                                                TopTools_ListOfShape& theListOfSplits);
 
+#define BREPFILL_VOLUVED_DEBUG
+
 //=======================================================================
 //function : GetSpineAndProfile
 //purpose  : 
@@ -332,15 +338,50 @@ void BRepFill_Voluved::Perform(const TopoDS_Wire& theSpine,
     myFuzzyValue = theTolerance;
   }
 
+#ifdef BREPFILL_VOLUVED_DEBUG
+  char aBuff[10000];
+  Sprintf(aBuff, "%s%s", aDirPatch, "spine.nbv");
+  BinTools::Write(theSpine, aBuff);
+  Sprintf(aBuff, "%s%s", aDirPatch, "profile.nbv");
+  BinTools::Write(theProfile, aBuff);
+
+  std::streamsize aPrecVal = std::cout.precision();
+
+  std::cout.precision(15);
+
+  std::cout << "++++ Dump of Spine" << std::endl;
+  BRepTools::Dump(theSpine, std::cout);
+  std::cout << "---- Dump of Spine" << std::endl;
+
+  std::cout << "++++ Dump of Profile" << std::endl;
+  BRepTools::Dump(theProfile, std::cout);
+  std::cout << "---- Dump of Profile" << std::endl;
+
+  std::cout.precision(aPrecVal);
+#endif
+
   GetSpineAndProfile(theSpine, theProfile);
 
   myPipeShell.Nullify();
   myTopBottom.Nullify();
   myResult.Nullify();
 
+#ifdef BREPFILL_VOLUVED_DEBUG
+  std::cout << "Start Evolved. Toler = " << myFuzzyValue << std::endl;
+#endif
+
   PerformSweep();
+
+#ifdef BREPFILL_VOLUVED_DEBUG
+  std::cout << "PerformSweep complete. Status = " << myErrorStatus << std::endl;
+#endif
+  
   GetLids();
 
+#ifdef BREPFILL_VOLUVED_DEBUG
+  std::cout << "GetLids complete. Status = " << myErrorStatus << std::endl;
+#endif
+
   if ((myErrorStatus != BRepFill_Voluved_NotSolid) && !theSolidReq)
   {
     myResult = myPipeShell;
@@ -457,7 +498,7 @@ void BRepFill_Voluved::GetLids()
   // Split interfered edges
   BOPAlgo_PaveFiller aPF;
   aPF.SetArguments(aLE);
-  aPF.SetRunParallel(Standard_True);
+  aPF.SetRunParallel(isParallelComputation);
 
   aPF.Perform();
   if (aPF.HasErrors())
@@ -474,7 +515,7 @@ void BRepFill_Voluved::GetLids()
     aBuilder.AddArgument(aS);
   }
 
-  aBuilder.SetRunParallel(Standard_True);
+  aBuilder.SetRunParallel(isParallelComputation);
   aBuilder.PerformWithFiller(aPF);
   if (aBuilder.HasErrors())
   {
@@ -689,9 +730,22 @@ void BRepFill_Voluved::BuildSolid()
 
   Handle(ShapeFix_Shape) aSFix = new ShapeFix_Shape;
   aSFix->Init(myPipeShell);
+
+#ifdef BREPFILL_VOLUVED_DEBUG
+  char aBuff[10000];
+  Sprintf(aBuff, "%s%s", aDirPatch, "shape1.nbv");
+  BinTools::Write(myPipeShell, aBuff);
+#endif
+
+
   aSFix->Perform();
   myPipeShell = aSFix->Shape();
 
+#ifdef BREPFILL_VOLUVED_DEBUG
+  Sprintf(aBuff, "%s%s", aDirPatch, "shape2.nbv");
+  BinTools::Write(myPipeShell, aBuff);
+#endif
+
   for (anExpF.Init(myPipeShell, TopAbs_FACE);
        anExpF.More(); anExpF.Next())
   {
@@ -716,10 +770,25 @@ void BRepFill_Voluved::BuildSolid()
       aLF.Append(aF);
     }
 
+#ifdef BREPFILL_VOLUVED_DEBUG
+    BRep_Builder aBB;
+    TopoDS_Compound aDebComp;
+    aBB.MakeCompound(aDebComp);
+    TopTools_ListIteratorOfListOfShape anItrDeb(aLF);
+    for (; anItrDeb.More(); anItrDeb.Next())
+    {
+      const TopoDS_Face &aF = TopoDS::Face(anItrDeb.Value());
+      aBB.Add(aDebComp, aF);
+    }
+
+    Sprintf(aBuff, "%s%s", aDirPatch, "shape3.nbv");
+    BinTools::Write(aDebComp, aBuff);
+#endif
+
     // Split interfered faces
     BOPAlgo_PaveFiller aPF;
     aPF.SetArguments(aLF);
-    aPF.SetRunParallel(Standard_True);
+    aPF.SetRunParallel(isParallelComputation);
     aPF.SetFuzzyValue(myFuzzyValue);
 
     aPF.Perform();
@@ -733,12 +802,17 @@ void BRepFill_Voluved::BuildSolid()
         aBuilder.AddArgument(aS);
       }
 
-      aBuilder.SetRunParallel(Standard_True);
+      aBuilder.SetRunParallel(isParallelComputation);
       aBuilder.PerformWithFiller(aPF);
       myPipeShell = aBuilder.Shape();
     }
   }
 
+#ifdef BREPFILL_VOLUVED_DEBUG
+  Sprintf(aBuff, "%s%s", aDirPatch, "shape4.nbv");
+  BinTools::Write(myPipeShell, aBuff);
+#endif
+
   aLF.Clear();
   aMapF.Clear();
   for (anExpF.Init(myPipeShell, TopAbs_FACE);
@@ -761,11 +835,26 @@ void BRepFill_Voluved::BuildSolid()
     }
   }
   
+#ifdef BREPFILL_VOLUVED_DEBUG
+  BRep_Builder aBB;
+  TopoDS_Compound aDebComp;
+  aBB.MakeCompound(aDebComp);
+  TopTools_ListIteratorOfListOfShape anItrDeb(aLF);
+  for (; anItrDeb.More(); anItrDeb.Next())
+  {
+    const TopoDS_Face &aF = TopoDS::Face(anItrDeb.Value());
+    aBB.Add(aDebComp, aF);
+  }
+
+  Sprintf(aBuff, "%s%s", aDirPatch, "shape5.nbv");
+  BinTools::Write(aDebComp, aBuff);
+#endif
+
   BOPAlgo_MakerVolume aMV;
   aMV.SetArguments(aLF);
   aMV.SetFuzzyValue(myFuzzyValue);
   aMV.SetIntersect(Standard_True);
-  aMV.SetRunParallel(Standard_True);
+  aMV.SetRunParallel(isParallelComputation);
   aMV.SetAvoidInternalShapes(Standard_True);
   aMV.Perform();
 
@@ -775,6 +864,11 @@ void BRepFill_Voluved::BuildSolid()
   }
   
   myResult = aMV.Shape();
+
+#ifdef BREPFILL_VOLUVED_DEBUG
+  std::cout << "BuildSolid After VM." << std::endl;
+#endif
+
   RemoveExcessSolids(aLSplits, myResult, aLF, aMV);
 
   myErrorStatus = BRepFill_Voluved_OK;
@@ -812,7 +906,7 @@ void BRepFill_Voluved::ExtractOuterSolid(TopoDS_Shape& theShape,
   BOPAlgo_MakerVolume aMV;
   aMV.SetArguments(theArgsList);
   aMV.SetIntersect(Standard_True);
-  aMV.SetRunParallel(Standard_True);
+  aMV.SetRunParallel(isParallelComputation);
   aMV.SetAvoidInternalShapes(Standard_True);
   aMV.Perform();
 
@@ -1525,7 +1619,7 @@ Standard_Boolean CheckSingularityAndAdd(const TopoDS_Face& theF,
     // Split interfered edges
     BOPAlgo_PaveFiller aPF;
     aPF.SetArguments(aLE);
-    aPF.SetRunParallel(Standard_True);
+    aPF.SetRunParallel(isParallelComputation);
 
     aPF.Perform();
     if (aPF.HasErrors())
@@ -1550,7 +1644,7 @@ Standard_Boolean CheckSingularityAndAdd(const TopoDS_Face& theF,
       aBuilder.AddArgument(aS);
     }
 
-    aBuilder.SetRunParallel(Standard_True);
+    aBuilder.SetRunParallel(isParallelComputation);
     aBuilder.PerformWithFiller(aPF);
     if (aBuilder.HasErrors())
     {
@@ -1635,7 +1729,7 @@ Standard_Boolean CheckSingularityAndAdd(const TopoDS_Face& theF,
       aBAB.AddArgument(aSh);
     }
 
-    aBAB.SetRunParallel(Standard_True);
+    aBAB.SetRunParallel(isParallelComputation);
     aBAB.SetNonDestructive(Standard_True);
     aBAB.PerformWithFiller(aPF);
     if (aBAB.HasErrors())
index 4b7a1160d0bd42290bd3700ff6f980554a92e2e9..5a18f2cca202a40fc6319520023d1776197d42f4 100644 (file)
@@ -2531,6 +2531,136 @@ static Standard_Integer OCC28131 (Draw_Interpretor&, Standard_Integer theNbArgs,
   return 0;
 }
 
+#include <BRepOffsetAPI_MakeEvolved.hxx>
+#include <ShapeFix_Wireframe.hxx>
+static Standard_Integer myCall(Draw_Interpretor&, Standard_Integer theNbArgs, const char** theArgVec)
+{
+  TopoDS_Wire extrudeWire = TopoDS::Wire(DBRep::Get(theArgVec[2]));
+  TopoDS_Wire toolWire = TopoDS::Wire(DBRep::Get(theArgVec[3]));
+
+  // ################################ Check and Fix Wire Gaps #########################################
+  if (1)
+  {
+    ShapeFix_Wireframe fix_tool(extrudeWire);
+    fix_tool.ModeDropSmallEdges() = Standard_True;
+    fix_tool.SetPrecision(Precision::Confusion()); //yes!
+    fix_tool.FixSmallEdges();
+    fix_tool.FixWireGaps();
+    extrudeWire = TopoDS::Wire(fix_tool.Shape());
+  }
+
+  // ################################ Extrude tool #########################################
+  BRepOffsetAPI_MakeEvolved mkEvolved = BRepOffsetAPI_MakeEvolved(extrudeWire, toolWire, GeomAbs_Arc, Standard_False, Standard_True, Standard_False, Standard_True, 0);
+
+  DBRep::Set(theArgVec[1], mkEvolved.Shape());
+
+  return 0;
+}
+
+//=======================================================================
+//function : FindGaps
+//purpose  : 
+//=======================================================================
+static Standard_Integer FindGaps(Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgV)
+{
+  if (theNArg < 3)
+  {
+    theDI << "Use: " << theArgV[0] << " result wire\n";
+    return 1;
+  }
+
+  const TopoDS_Wire aWir = TopoDS::Wire(DBRep::Get(theArgV[2]));
+
+  TopTools_IndexedDataMapOfShapeListOfShape aMapVE;
+  TopExp::MapShapesAndAncestors(aWir, TopAbs_VERTEX, TopAbs_EDGE, aMapVE);
+
+  Standard_Real aMaxDist = RealFirst();
+
+  for (Standard_Integer i = 1; i <= aMapVE.Extent(); i++)
+  {
+    const TopoDS_Vertex &aV = TopoDS::Vertex(aMapVE.FindKey(i));
+
+    TopTools_ListOfShape aLE = aMapVE.FindFromIndex(i);
+
+    const TopoDS_Edge anE1 = TopoDS::Edge(aLE.First());
+    const TopoDS_Edge anE2 = TopoDS::Edge(aLE.Last());
+
+    const BRepAdaptor_Curve anAC1(anE1), anAC2(anE2);
+
+    const Standard_Real aPrm1 = BRep_Tool::Parameter(aV, anE1);
+    const Standard_Real aPrm2 = BRep_Tool::Parameter(aV, anE2);
+
+    gp_Pnt aP1, aP2;
+    anAC1.D0(aPrm1, aP1);
+    anAC2.D0(aPrm2, aP2);
+
+    char aBuff[100];
+    Sprintf(aBuff, "%sv%d", theArgV[1], i);
+    DBRep::Set(aBuff, aV);
+
+    const Standard_Real aDist = aP1.Distance(aP2);
+    aMaxDist = Max(aMaxDist, aDist);
+
+    theDI << aBuff << ": Dist = " << aDist << "\n";
+  }
+
+  theDI << "Max. gap is " << aMaxDist << "\n";
+
+  return 0;
+}
+
+//=======================================================================
+//function : VEProcess
+//purpose  : 
+//=======================================================================
+static Standard_Integer VEProcess(Draw_Interpretor& theDI, Standard_Integer theNArg, const char** theArgV)
+{
+  if (theNArg < 3)
+  {
+    theDI << "Use: " << theArgV[0] << " result wire\n";
+    return 1;
+  }
+
+  const TopoDS_Wire aWir = TopoDS::Wire(DBRep::Get(theArgV[2]));
+
+  TopTools_IndexedDataMapOfShapeListOfShape aMapVE;
+  TopExp::MapShapesAndAncestors(aWir, TopAbs_VERTEX, TopAbs_EDGE, aMapVE);
+
+  for (Standard_Integer i = 1; i <= aMapVE.Extent(); i++)
+  {
+    const TopoDS_Vertex &aV = TopoDS::Vertex(aMapVE.FindKey(i));
+
+    TopTools_ListOfShape aLE = aMapVE.FindFromIndex(i);
+
+    const TopoDS_Edge anE1 = TopoDS::Edge(aLE.First());
+    const TopoDS_Edge anE2 = TopoDS::Edge(aLE.Last());
+
+    const BRepAdaptor_Curve anAC1(anE1), anAC2(anE2);
+
+    const Standard_Real aPrm1 = BRep_Tool::Parameter(aV, anE1);
+    const Standard_Real aPrm2 = BRep_Tool::Parameter(aV, anE2);
+
+    gp_Pnt aP;
+    gp_Vec aT1, aT2;
+    anAC1.D1(aPrm1, aP, aT1);
+    anAC2.D1(aPrm2, aP, aT2);
+
+    Standard_Real anAngle = aT1.Angle(aT2);
+
+    if (anAngle > M_PI_2)
+      anAngle = M_PI - anAngle;
+
+    char aBuff[100];
+    Sprintf(aBuff, "%sv%d", theArgV[1], i);
+    DBRep::Set(aBuff, aV);
+
+    theDI << aBuff << " (" << BRep_Tool::Tolerance(aV) << "): A = " << anAngle << "\n";
+  }
+
+  return 0;
+}
+
+
 void QABugs::Commands_20(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -2560,5 +2690,10 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
                   __FILE__, OCC28887, group);
   theCommands.Add("OCC28131", "OCC28131 name: creates face problematic for offset", __FILE__, OCC28131, group);
 
+  theCommands.Add("myCall", "myCall result spine profile", __FILE__, myCall, group);
+
+  theCommands.Add("findgaps", "findgaps result wire", __FILE__, FindGaps, group);
+  theCommands.Add("veproc", "veproc result wire", __FILE__, VEProcess, group);
+
   return;
 }