]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
Add Partition result to output
authorjfa <jfa@opencascade.com>
Tue, 19 Nov 2024 21:50:50 +0000 (21:50 +0000)
committerjfa <jfa@opencascade.com>
Fri, 22 Nov 2024 12:24:24 +0000 (12:24 +0000)
idl/GEOM_Gen.idl
src/GEOMImpl/GEOMImpl_IMeasureOperations.cxx
src/GEOMImpl/GEOMImpl_IMeasureOperations.hxx
src/GEOMImpl/GEOMImpl_PartitionDriver.cxx
src/GEOMImpl/GEOMImpl_Types.hxx
src/GEOM_I/GEOM_IMeasureOperations_i.cc
src/GEOM_I/GEOM_IMeasureOperations_i.hh
src/GEOM_SWIG/geomBuilder.py

index d4d2eed32fd08c9aa5fe2e931957093beb3a99bd..d5ca6c227bc3cadbb94cc63cd085e1038d28e169 100644 (file)
@@ -4805,7 +4805,8 @@ module GEOM
     //  *  \param theShortReport Whether to display the error report in short format
     //  *  \param theRunParallel Whether to run the computations in parallel
     //  *  \param theDoExact Whether to perform exact checking
-    //  *  \param theErrors Structure, containing discovered errors and incriminated sub-shapes.
+    //  *  \param theResultShape Output parameter. The result of BOP General Fuse. Indices of its sub-shapes are reported in theErrors structure.
+    //  *  \param theErrors Output parameter. Structure, containing discovered errors and incriminated sub-shapes.
     //  *  \return TRUE, if the input shapes "seem to be valid" for BOP.
     //  */
     boolean ExtractBOPFailure (in ListOfGO     theShapes,
@@ -4814,6 +4815,7 @@ module GEOM
                                in boolean      theShortReport,
                                in boolean      theRunParallel,
                                in boolean      theDoExact,
+                               out GEOM_Object theResultShape,
                                out ShapeErrors theErrors);
 
     /*!
index 11c27b5346f9c00fd38f697f015292986c147ef7..2e8274b20c14c8a6ae1bc4dd074d8f7f7f87429a 100644 (file)
@@ -34,6 +34,9 @@
 #include <GEOMImpl_IConformity.hxx>
 #include <GEOMImpl_ConformityDriver.hxx>
 
+#include <GEOMImpl_IPartition.hxx>
+#include <GEOMImpl_PartitionDriver.hxx>
+
 #include <GEOMUtils.hxx>
 
 #include <GEOMAlgo_AlgoTools.hxx>
@@ -1724,13 +1727,14 @@ TCollection_AsciiString GEOMImpl_IMeasureOperations::PrintShapeErrors
  */
 //=============================================================================
 bool GEOMImpl_IMeasureOperations::ExtractBOPFailure
-                          (const Handle(TColStd_HSequenceOfTransient)&  theShapes,
-                           const bool                                   theUseTimer,
-                           const bool                                   theTopoOnly,
-                           const bool                                   theShortReport,
-                           const bool                                   theRunParallel,
-                           const bool                                   theDoExact,
-                           std::list<ShapeError>&                       theErrors)
+                       (const Handle(TColStd_HSequenceOfTransient)& theShapes,
+                        const bool                                  theUseTimer,
+                        const bool                                  theTopoOnly,
+                        const bool                                  theShortReport,
+                        const bool                                  theRunParallel,
+                        const bool                                  theDoExact,
+                        Handle(GEOM_Object)&                        theResultShape,
+                        std::list<ShapeError>&                      theErrors)
 {
   SetErrorCode(KO);
   theErrors.clear();
@@ -1740,8 +1744,16 @@ bool GEOMImpl_IMeasureOperations::ExtractBOPFailure
   Standard_Integer aNbShapes = theShapes->Length();
   if (!aNbShapes) return false;
 
+  // Create Partition object
+  theResultShape = GetEngine()->AddObject(GEOM_PARTITION);
+  Handle(GEOM_Function) aFunction = theResultShape->AddFunction
+    (GEOMImpl_PartitionDriver::GetID(), PARTITION_GENERAL_FUSE);
+  // For creation information filling
+  GEOMImpl_IPartition aCI (aFunction);
+  Handle(TColStd_HSequenceOfTransient) aShapesSeq = new TColStd_HSequenceOfTransient;
+
   TopTools_ListOfShape aList;
-  for (int i=1; i<=aNbShapes; i++) {
+  for (int i = 1; i <= aNbShapes; i++) {
     Handle(GEOM_Object) aGeomObj = Handle(GEOM_Object)::DownCast(theShapes->Value(i));
     if (aGeomObj.IsNull())
       continue;
@@ -1754,9 +1766,12 @@ bool GEOMImpl_IMeasureOperations::ExtractBOPFailure
     if (aShape.IsNull())
       continue;
 
+    aShapesSeq->Append(aRefShape);
     aList.Append(aShape);
   }
 
+  aCI.SetShapes(aShapesSeq);
+
   // Call the GeomAnaTool API to extract BOP failures
   // TopTools_ListOfShape aFailuresList = GeomAnaTool::ExtractBOPFailure(aList, theUseTimer, theTopoOnly, theShortReport, theRunParallel, theDoExact);
   // std::cout << "ExtractBOPFailure: " << aFailuresList.Extent() << " failures" << std::endl;
@@ -1773,6 +1788,12 @@ bool GEOMImpl_IMeasureOperations::ExtractBOPFailure
     aTool.SetRunParallel(theRunParallel);
     aTool.SetExactCheck(theDoExact);
     aTool.Perform();
+
+    // Set General Fuse result right here
+    // (without driver execution, as we already have the result shape)
+    TopoDS_Shape aShapeRes = aTool.Result();
+    aFunction->SetValue(aShapeRes);
+
     if (aTool.HasFailures())
     {
       std::cout << "--- The operation has failures ---" << std::endl;
@@ -1793,6 +1814,17 @@ bool GEOMImpl_IMeasureOperations::ExtractBOPFailure
       std::cout << "+++ The operation has no failures +++" << std::endl;
       isValid = true;
     }
+
+    //Make a Python command
+    GEOM::TPythonDump aPD (aFunction);
+    aPD << "(isBOPFailure, " << theResultShape
+        << ", anErrors) = geompy.ExtractBOPFailure([";
+    for (int i = 1; i <= aNbShapes; i++) {
+      aPD << Handle(GEOM_Object)::DownCast(theShapes->Value(i));
+      if (i < aNbShapes) aPD << ", ";
+    }
+    aPD << "], " << theUseTimer << ", " << theTopoOnly << ", " << theShortReport
+        << ", " << theRunParallel << ", " << theDoExact << ")";
   }
   catch(Standard_Failure& aFail)
   {
index 8b677de56091617eb7c848e98a633ba1faf61a64..d6eea1e277eecc1b2fd4489597e1773a5d660af6 100644 (file)
@@ -163,13 +163,14 @@ class GEOMImpl_IMeasureOperations : public GEOM_IOperations {
                                    const std::list<ShapeError> &theErrors);
 
   Standard_EXPORT bool ExtractBOPFailure
-                                  (const Handle(TColStd_HSequenceOfTransient)&  theShapes,
-                                   const bool                                   theUseTimer,
-                                   const bool                                   theTopoOnly,
-                                   const bool                                   theShortReport,
-                                   const bool                                   theRunParallel,
-                                   const bool                                   theDoExact,
-                                   std::list<ShapeError>&                       theErrors);
+                       (const Handle(TColStd_HSequenceOfTransient)& theShapes,
+                        const bool                                  theUseTimer,
+                        const bool                                  theTopoOnly,
+                        const bool                                  theShortReport,
+                        const bool                                  theRunParallel,
+                        const bool                                  theDoExact,
+                        Handle(GEOM_Object)&                        theResultShape,
+                        std::list<ShapeError>&                      theErrors);
 
   Standard_EXPORT bool CheckSelfIntersections (Handle(GEOM_Object) theShape,
                                                const SICheckLevel  theCheckLevel,
index 9bee2250fd3975c5c7a013dc1e29fa1b50b4ae6f..b90dae0c5f090167b784fd39526769fc90afcaa9 100644 (file)
@@ -564,6 +564,9 @@ GetCreationInformation(std::string&             theOperationName,
     AddParam( theParams, "Object", aCI.GetShape() );
     AddParam( theParams, "Plane", aCI.GetPlane() );
     break;
+  case PARTITION_GENERAL_FUSE:
+    AddParam( theParams, "Objects", aCI.GetShapes() );
+    break;
   default:
     return false;
   }
index 9a0c75e65b9c5477ba678420f45b0e1236907ae5..044abaf853be1b047e1bdd65d6915beab881f43e 100644 (file)
 #define PARTITION_PARTITION 1
 #define PARTITION_HALF      2
 #define PARTITION_NO_SELF_INTERSECTIONS 3
+#define PARTITION_GENERAL_FUSE 4
 
 #define POLYLINE_POINTS       1
 #define POLYLINE2D_PLN_COORDS 2
index 1feb907c88763f0728725703c70eceda71510596..1eedcf6997b1ed0100287ad7a6e9617421e8fa7c 100644 (file)
@@ -722,8 +722,12 @@ CORBA::Boolean GEOM_IMeasureOperations_i::ExtractBOPFailure
                     CORBA::Boolean                                 theShortReport,
                     CORBA::Boolean                                 theRunParallel,
                     CORBA::Boolean                                 theDoExact,
+                    GEOM::GEOM_Object_out                          theResultShape,
                     GEOM::GEOM_IMeasureOperations::ShapeErrors_out theErrors)
 {
+  GEOM::GEOM_Object_var aNullRes;
+  theResultShape = aNullRes._retn();
+
   // Set the not done flag
   GetOperations()->SetNotDone();
 
@@ -752,10 +756,16 @@ CORBA::Boolean GEOM_IMeasureOperations_i::ExtractBOPFailure
   }
 
   // Perform partition operation and check for failures
+  Handle(::GEOM_Object) aResultShape;
   std::list<GEOMImpl_IMeasureOperations::ShapeError> anErrList;
-  bool isOk = GetOperations()->ExtractBOPFailure(aSeqShapes, theUseTimer, theTopoOnly,
-                                                 theShortReport, theRunParallel, theDoExact,
-                                                 anErrList);
+  bool isOk = GetOperations()->ExtractBOPFailure
+    (aSeqShapes, theUseTimer, theTopoOnly,
+     theShortReport, theRunParallel, theDoExact,
+     aResultShape, anErrList);
+
+  if (!aResultShape.IsNull()) {
+    theResultShape = GetObject(aResultShape);
+  }
 
   ConvertShapeError(anErrList, theErrors);
 
index 3b346e7960d8d0779b8575809af8bff163e4421d..ed6911efdb3dbb3d8128bde4b809c58d99b418ea 100644 (file)
@@ -105,6 +105,7 @@ class GEOM_I_EXPORT GEOM_IMeasureOperations_i :
                     CORBA::Boolean                                 theShortReport,
                     CORBA::Boolean                                 theRunParallel,
                     CORBA::Boolean                                 theDoExact,
+                    GEOM::GEOM_Object_out                          theResultShape,
                     GEOM::GEOM_IMeasureOperations::ShapeErrors_out theErrors);
 
   CORBA::Boolean CheckSelfIntersections (GEOM::GEOM_Object_ptr theShape,
index 04cad8817eadb1487f1ed2bf120e1088980beaca..a553547cdb9700be59e0fc53fa632774056ea5fd 100644 (file)
@@ -11983,10 +11983,21 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
             return self.MeasuOp.CheckBOPArguments(theShape)
 
 
+        ## Extracts the BOP failure information from the given list of faces.
+        #  @param lFaces - list of faces to extract the BOP failure information from.
+        #  @param timer - if True, the time of the operation is measured.
+        #  @param topo - if True, only the topological entities will be checked.
+        #  @param short - if True, the error report will be in short format.
+        #  @param parallel - if True, the operation will be executed in parallel.
+        #  @param exact - if True, an exact check will be performed.
+        #  @return (isValid, shapeResult, listOfErrors), where
+        #          isValid - a boolean value (if result shape is valid or not),
+        #          shapeResult - the result shape itself as GEOM::Object,
+        #          listOfErrors - the list of GEOM.GEOM_IMeasureOperations.ShapeError.
         def ExtractBOPFailure(self, lFaces, timer=None, topo=None, short=None, parallel=None, exact=None):
             """
             Extracts the BOP failure information from the given list of faces.
-        
+
             Parameters:
                 lFaces - list of faces to extract the BOP failure information from.
                 timer - if True, the time of the operation is measured.
@@ -11994,9 +12005,11 @@ class geomBuilder(GEOM._objref_GEOM_Gen):
                 short - if True, the error report will be in short format.
                 parallel - if True, the operation will be executed in parallel.
                 exact - if True, an exact check will be performed.
-        
+
             Returns:
-                the list of failed shapes.
+                a boolean value (if result shape is valid or not),
+                the result shape itself,
+                the list of GEOM.GEOM_IMeasureOperations.ShapeError.
             """
             # Check for default parameter values
             if timer is None: