]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Usage of ShapeUpgrade_UnifySameDomain instead of BlockFix_UnionFaces and BlockFix_Uni...
authorjfa <jfa@opencascade.com>
Mon, 6 Sep 2021 12:03:21 +0000 (15:03 +0300)
committerjfa <jfa@opencascade.com>
Mon, 6 Sep 2021 12:03:21 +0000 (15:03 +0300)
src/BlockFix/BlockFix_BlockFixAPI.cxx
src/GEOMImpl/GEOMImpl_BlockDriver.cxx

index 1701aaef5b5905b74dbc280b86a6d05d548100d3..1990d3ad04cc133102d613a87cb0397aebe0250d 100644 (file)
@@ -31,6 +31,8 @@
 #include <BlockFix_UnionEdges.hxx>
 
 #include <ShapeUpgrade_RemoveLocations.hxx>
+#include <TopoDS_Edge.hxx>
+#include <ShapeUpgrade_UnifySameDomain.hxx>
 
 #include <Precision.hxx>
 
@@ -67,10 +69,31 @@ void BlockFix_BlockFixAPI::Perform()
   myShape = BlockFix::RefillProblemFaces(myShape);
 
   // faces unification
-  BlockFix_UnionFaces aFaceUnifier;
-  aFaceUnifier.GetTolerance() = myTolerance;
-  aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces;
-  TopoDS_Shape aResult = aFaceUnifier.Perform(myShape);
+  TopoDS_Shape aResult = myShape;
+  if (myOptimumNbFaces > 1) {
+    // use old algo BlockFix_UnionFaces for exactly given resulting number of faces
+    BlockFix_UnionFaces aFaceUnifier;
+    aFaceUnifier.GetTolerance() = myTolerance;
+    aFaceUnifier.GetOptimumNbFaces() = myOptimumNbFaces;
+    aResult = aFaceUnifier.Perform(aResult);
+  }
+  else if (myOptimumNbFaces != -1) {
+    // use OCCT algo ShapeUpgrade_UnifySameDomain
+    ShapeUpgrade_UnifySameDomain Unifier;
+    //only faces
+    Standard_Boolean isUnifyEdges = Standard_False;
+    Standard_Boolean isUnifyFaces = Standard_True;
+    Standard_Boolean isConcatBSplines = Standard_True;
+    Unifier.Initialize(myShape, isUnifyEdges, isUnifyFaces, isConcatBSplines);
+    //Unifier.SetLinearTolerance(myTolerance);
+    Unifier.SetLinearTolerance(Precision::Confusion());
+    Unifier.SetAngularTolerance(Precision::Confusion());
+    Unifier.Build();
+    aResult = Unifier.Shape();
+  }
+  else {
+    // myOptimumNbFaces == -1 means do not union faces
+  }
 
   // avoid problem with degenerated edges appearance
   // due to shape quality regress
@@ -79,8 +102,16 @@ void BlockFix_BlockFixAPI::Perform()
   aResult = RemLoc.GetResult();
 
   // edges unification
-  BlockFix_UnionEdges anEdgeUnifier;
-  myShape = anEdgeUnifier.Perform(aResult,myTolerance);
+  //BlockFix_UnionEdges anEdgeUnifier;
+  //myShape = anEdgeUnifier.Perform(aResult,myTolerance);
+  ShapeUpgrade_UnifySameDomain Unifier;
+  Standard_Boolean isUnifyEdges = Standard_True;
+  Standard_Boolean isUnifyFaces = Standard_False; //only edges
+  Standard_Boolean isConcatBSplines = Standard_True;
+  Unifier.Initialize(aResult, isUnifyEdges, isUnifyFaces, isConcatBSplines);
+  Unifier.SetLinearTolerance(myTolerance);
+  Unifier.Build();
+  myShape = Unifier.Shape();
 
   TopoDS_Shape aRes = BlockFix::FixRanges(myShape,myTolerance);
   myShape = aRes;
index 22d2b0b5200761a66b4ba325958cd84c7cb2b66f..92dbc1be252d438fb9db8f1399017d5b8de9bc01 100644 (file)
@@ -63,6 +63,8 @@
 #include <BRepExtrema_ExtPF.hxx>
 #include <BRepExtrema_DistShapeShape.hxx>
 
+#include <ShapeUpgrade_UnifySameDomain.hxx>
+
 #include <TopAbs.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Shape.hxx>
@@ -742,10 +744,19 @@ Standard_Integer GEOMImpl_BlockDriver::Execute(Handle(TFunction_Logbook)& log) c
         Standard_NullObject::Raise("Null Shape given");
       }
 
-      BlockFix_UnionFaces aFaceUnifier;
-  
-      aFaceUnifier.GetOptimumNbFaces() = 0; // To force union faces.
-      aShape = aFaceUnifier.Perform(aBlockOrComp);
+      //BlockFix_UnionFaces aFaceUnifier;
+      //aFaceUnifier.GetOptimumNbFaces() = 0; // To force union faces.
+      //aShape = aFaceUnifier.Perform(aBlockOrComp);
+      // Use OCCT algo ShapeUpgrade_UnifySameDomain instead of BlockFix_UnionFaces:
+      Standard_Boolean isUnifyEdges = Standard_False;
+      Standard_Boolean isUnifyFaces = Standard_True;
+      Standard_Boolean isConcatBSplines = Standard_True;
+      ShapeUpgrade_UnifySameDomain aUnifier (aBlockOrComp,
+                                             isUnifyEdges, isUnifyFaces, isConcatBSplines);
+      aUnifier.SetLinearTolerance(Precision::Confusion());
+      aUnifier.SetAngularTolerance(Precision::Confusion());
+      aUnifier.Build();
+      aShape = aUnifier.Shape();
     } else { // unknown function type
       return 0;
     }