]> SALOME platform Git repositories - modules/geom.git/commitdiff
Salome HOME
NPAL16173: EDF454: Result of revolving a shell should be a compound.
authorjfa <jfa@opencascade.com>
Thu, 7 Jun 2007 08:08:54 +0000 (08:08 +0000)
committerjfa <jfa@opencascade.com>
Thu, 7 Jun 2007 08:08:54 +0000 (08:08 +0000)
src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx
src/GEOMImpl/GEOMImpl_IShapesOperations.cxx
src/GEOMImpl/GEOMImpl_IShapesOperations.hxx
src/GEOMImpl/GEOMImpl_PipeDriver.cxx
src/GEOMImpl/GEOMImpl_PrismDriver.cxx
src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx

index de70f12593474c28353968098390da78e7401a07..8d39e8826315bc24d06d4d58bd4bc6945f441ca5 100644 (file)
@@ -864,7 +864,7 @@ Handle(GEOM_Object) GEOMImpl_I3DPrimOperations::MakeRevolutionAxisAngle (Handle(
   }
 
   //Make a Python command
-  GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolution("
+  GEOM::TPythonDump(aFunction) << aRevolution << " = geompy.MakeRevolutionAxisAngle("
     << theBase << ", " << theAxis << ", " << theAngle * 180.0 / PI << "*math.pi/180.0)";
 
   SetErrorCode(OK);
index 529c6cdec5416a1f85ff5c30685ba66c89d231d3..02af581eccfb6e38d18ea27ef6cfa1d1a2ea9c5b 100644 (file)
@@ -42,7 +42,6 @@
 #include "GEOMAlgo_FinderShapeOnQuad.hxx"
 #include "GEOMAlgo_FinderShapeOn2.hxx"
 #include "GEOMAlgo_ClsfBox.hxx"
-//#include "GEOMAlgo_ClsfSurf.hxx"
 #include "GEOMAlgo_Gluer1.hxx"
 #include "GEOMAlgo_ListIteratorOfListOfCoupleOfShapes.hxx"
 #include "GEOMAlgo_CoupleOfShapes.hxx"
@@ -62,6 +61,7 @@
 #include <BRepExtrema_ExtCF.hxx>
 
 #include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
 #include <BRepTools.hxx>
 #include <BRepGProp.hxx>
 #include <BRepAdaptor_Curve.hxx>
@@ -78,6 +78,7 @@
 #include <TopoDS_Face.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Vertex.hxx>
+#include <TopoDS_Compound.hxx>
 #include <TopoDS_Iterator.hxx>
 #include <TopExp_Explorer.hxx>
 #include <TopLoc_Location.hxx>
@@ -1587,8 +1588,10 @@ Handle(TColStd_HSequenceOfInteger)
   Handle(TColStd_HSequenceOfInteger) aSeqOfIDs;
 
   // Check presence of triangulation, build if need
-  if (!CheckTriangulation(theShape))
+  if (!CheckTriangulation(theShape)) {
+    SetErrorCode("Cannot build triangulation on the shape");
     return aSeqOfIDs;
+  }
 
   // Call algo
   GEOMAlgo_FinderShapeOn1 aFinder;
@@ -2207,8 +2210,10 @@ Handle(TColStd_HSequenceOfInteger)
   Handle(TColStd_HSequenceOfInteger) aSeqOfIDs;
 
   // Check presence of triangulation, build if need
-  if (!CheckTriangulation(aShape))
+  if (!CheckTriangulation(aShape)) {
+    SetErrorCode("Cannot build triangulation on the shape");
     return aSeqOfIDs;
+  }
 
   // Call algo
   gp_Pnt aPntTL = BRep_Tool::Pnt(TopoDS::Vertex(aTL));
@@ -2651,6 +2656,33 @@ void GEOMImpl_IShapesOperations::SortShapes(TopTools_ListOfShape& SL)
     SL.Append( aShapes( OrderInd(Index) ));
 }
 
+//=======================================================================
+//function : CompsolidToCompound
+//purpose  :
+//=======================================================================
+TopoDS_Shape GEOMImpl_IShapesOperations::CompsolidToCompound (const TopoDS_Shape& theCompsolid)
+{
+  if (theCompsolid.ShapeType() != TopAbs_COMPSOLID) {
+    return theCompsolid;
+  }
+
+  TopoDS_Compound aCompound;
+  BRep_Builder B;
+  B.MakeCompound(aCompound);
+
+  TopTools_MapOfShape mapShape;
+  TopoDS_Iterator It (theCompsolid, Standard_True, Standard_True);
+
+  for (; It.More(); It.Next()) {
+    TopoDS_Shape aShape_i = It.Value();
+    if (mapShape.Add(aShape_i)) {
+      B.Add(aCompound, aShape_i);
+    }
+  }
+
+  return aCompound;
+}
+
 //=======================================================================
 //function : CheckTriangulation
 //purpose  :
@@ -2659,7 +2691,6 @@ bool GEOMImpl_IShapesOperations::CheckTriangulation (const TopoDS_Shape& aShape)
 {
   TopExp_Explorer exp (aShape, TopAbs_FACE);
   if (!exp.More()) {
-    SetErrorCode("Shape without faces given");
     return false;
   }
 
index 42d2ed991e3dde04f7e455508074fbb4b6def0f2..228aa8862c5d626a75c2ab03d956279e84013e57 100644 (file)
@@ -36,7 +36,8 @@ class GEOM_Engine;
 class Handle(GEOM_Object);
 class Handle(TColStd_HArray1OfInteger);
 
-class GEOMImpl_IShapesOperations : public GEOM_IOperations {
+class GEOMImpl_IShapesOperations : public GEOM_IOperations
+{
  public:
   Standard_EXPORT GEOMImpl_IShapesOperations(GEOM_Engine* theEngine, int theDocID);
   Standard_EXPORT ~GEOMImpl_IShapesOperations();
@@ -112,22 +113,25 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations {
                                   const GEOMAlgo_State       theState);
 
 
-  Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
-                                                            const Standard_Integer     theShapeType,
-                                                            const Handle(GEOM_Object)& theAxis,
-                                                            const Standard_Real        theRadius,
-                                                            const GEOMAlgo_State       theState);
+  Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
+    GetShapesOnCylinder (const Handle(GEOM_Object)& theShape,
+                         const Standard_Integer     theShapeType,
+                         const Handle(GEOM_Object)& theAxis,
+                         const Standard_Real        theRadius,
+                         const GEOMAlgo_State       theState);
 
-  Standard_EXPORT Handle(TColStd_HSequenceOfTransient) GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
-                                                          const Standard_Integer     theShapeType,
-                                                          const Handle(GEOM_Object)& theCenter,
-                                                          const Standard_Real        theRadius,
-                                                          const GEOMAlgo_State       theState);
+  Standard_EXPORT Handle(TColStd_HSequenceOfTransient)
+    GetShapesOnSphere (const Handle(GEOM_Object)& theShape,
+                       const Standard_Integer     theShapeType,
+                       const Handle(GEOM_Object)& theCenter,
+                       const Standard_Real        theRadius,
+                       const GEOMAlgo_State       theState);
 
-  Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
-                                                          const Standard_Integer     theShapeType,
-                                                          const Handle(GEOM_Object)& theAx1,
-                                                          const GEOMAlgo_State       theState);
+  Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
+    GetShapesOnPlaneIDs (const Handle(GEOM_Object)& theShape,
+                         const Standard_Integer     theShapeType,
+                         const Handle(GEOM_Object)& theAx1,
+                         const GEOMAlgo_State       theState);
 
   Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
     GetShapesOnPlaneWithLocationIDs (const Handle(GEOM_Object)& theShape,
@@ -136,17 +140,19 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations {
                                      const Handle(GEOM_Object)& thePnt,
                                      const GEOMAlgo_State       theState);
 
-  Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
-                                                             const Standard_Integer     theShapeType,
-                                                             const Handle(GEOM_Object)& theAxis,
-                                                             const Standard_Real        theRadius,
-                                                             const GEOMAlgo_State       theState);
+  Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
+    GetShapesOnCylinderIDs (const Handle(GEOM_Object)& theShape,
+                            const Standard_Integer     theShapeType,
+                            const Handle(GEOM_Object)& theAxis,
+                            const Standard_Real        theRadius,
+                            const GEOMAlgo_State       theState);
 
-  Standard_EXPORT Handle(TColStd_HSequenceOfInteger) GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
-                                                           const Standard_Integer     theShapeType,
-                                                           const Handle(GEOM_Object)& theCenter,
-                                                           const Standard_Real        theRadius,
-                                                           const GEOMAlgo_State       theState);
+  Standard_EXPORT Handle(TColStd_HSequenceOfInteger)
+    GetShapesOnSphereIDs (const Handle(GEOM_Object)& theShape,
+                          const Standard_Integer     theShapeType,
+                          const Handle(GEOM_Object)& theCenter,
+                          const Standard_Real        theRadius,
+                          const GEOMAlgo_State       theState);
 
   /*!
    * \brief Find subshapes complying with given status about quadrangle
@@ -201,8 +207,6 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations {
   Standard_EXPORT Handle(GEOM_Object) GetInPlace (Handle(GEOM_Object) theShapeWhere,
                                                   Handle(GEOM_Object) theShapeWhat);
 
-  Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
-
   /*!
    * \brief Searches a shape equal to theWhat in the context of theWhere
    * \param theShapeWhere - a context shap
@@ -240,6 +244,30 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations {
                                                const Standard_Integer theShapeType,
                                                GEOMAlgo_State theState);
 
+ public:
+  /*!
+   * \brief Sort shapes in the list by their coordinates.
+   * \param SL The list of shapes to sort.
+   */
+  Standard_EXPORT static void SortShapes (TopTools_ListOfShape& SL);
+
+  /*!
+   * \brief Convert TopoDS_COMPSOLID to TopoDS_COMPOUND.
+   *
+   * If the argument shape is not of type TopoDS_COMPSOLID, this method returns it as is.
+   *
+   * \param theCompsolid The compsolid to be converted.
+   * \retval TopoDS_Shape Returns the resulting compound.
+   */
+  Standard_EXPORT static TopoDS_Shape CompsolidToCompound (const TopoDS_Shape& theCompsolid);
+
+  /*!
+   * \brief Build a triangulation on \a theShape if it is absent.
+   * \param theShape The shape to check/build triangulation on.
+   * \retval bool Returns false if the shape has no faces, i.e. impossible to build triangulation.
+   */
+  Standard_EXPORT static bool CheckTriangulation (const TopoDS_Shape& theShape);
+
  private:
   Handle(GEOM_Object) MakeShape (list<Handle(GEOM_Object)>      theShapes,
                                  const Standard_Integer         theObjectType,
@@ -247,11 +275,9 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations {
                                  const TCollection_AsciiString& theMethodName);
 
 // ----------------------------------------------------
-  // methods common for all GetShapesOnXXX() functions
+// methods common for all GetShapesOnXXX() functions
 // ----------------------------------------------------
 
-  bool CheckTriangulation (const TopoDS_Shape& aShape);
-
   /*!
    * \brief Checks if theShapeType parameter of GetShapesOnXXX() is OK
     * \param theShapeType - the shape type to check
index ea9d3acbb2ced4892fe354820a3b55f1c8a02ebe..89fcf61636d564bd8d42a7a378711363856c6f93 100644 (file)
 #include <Standard_Stream.hxx>
 
 #include <GEOMImpl_PipeDriver.hxx>
+
+#include <GEOMImpl_IShapesOperations.hxx>
+#include <GEOMImpl_IPipeDiffSect.hxx>
+#include <GEOMImpl_IPipeShellSect.hxx>
 #include <GEOMImpl_IPipe.hxx>
 #include <GEOMImpl_Types.hxx>
 #include <GEOM_Function.hxx>
 
+#include <ShapeAnalysis_FreeBounds.hxx>
+#include <ShapeAnalysis_Edge.hxx>
+
 #include <BRep_Tool.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepBuilderAPI_Sewing.hxx>
 #include <BRepCheck_Analyzer.hxx>
 #include <BRepOffsetAPI_MakePipe.hxx>
-#include <BRepBuilderAPI_MakeWire.hxx>
+#include <BRepOffsetAPI_MakePipeShell.hxx>
 
 #include <TopAbs.hxx>
+#include <TopExp.hxx>
+#include <TopExp_Explorer.hxx>
 #include <TopoDS.hxx>
 #include <TopoDS_Wire.hxx>
 #include <TopoDS_Edge.hxx>
 #include <TopoDS_Solid.hxx>
 #include <TopoDS_Shell.hxx>
 #include <TopoDS_Face.hxx>
-#include <BRepOffsetAPI_MakePipeShell.hxx>
-#include <TColStd_HSequenceOfTransient.hxx>
-#include <GEOMImpl_IPipeDiffSect.hxx>
-#include <GEOMImpl_IPipeShellSect.hxx>
-
-#include <Standard_NullObject.hxx>
-#include <Standard_TypeMismatch.hxx>
-#include <Standard_ConstructionError.hxx>
-#include "utilities.h"
-#include <TopExp_Explorer.hxx>
-#include <TopTools_SequenceOfShape.hxx>
-#include <BRep_Builder.hxx>
 #include <TopoDS_Compound.hxx>
-#include <ShapeAnalysis_FreeBounds.hxx>
-#include <TColgp_SequenceOfPnt.hxx>
-#include <ShapeAnalysis_Edge.hxx>
+#include <TopTools_SequenceOfShape.hxx>
 #include <TopTools_IndexedDataMapOfShapeShape.hxx>
 #include <TopTools_IndexedDataMapOfShapeListOfShape.hxx>
-#include <TopExp.hxx>
 #include <TopTools_ListIteratorOfListOfShape.hxx>
+
 #include <GeomAPI_ProjectPointOnCurve.hxx>
-#include <Precision.hxx>
 #include <Geom_TrimmedCurve.hxx>
-#include <BRepBuilderAPI_Sewing.hxx>
 
-//#include <BRepTools.hxx>
+#include <TColgp_SequenceOfPnt.hxx>
+#include <TColStd_HSequenceOfTransient.hxx>
+
+#include <Precision.hxx>
+#include <Standard_NullObject.hxx>
+#include <Standard_TypeMismatch.hxx>
+#include <Standard_ConstructionError.hxx>
+
+#include "utilities.h"
 
 
 //=======================================================================
@@ -345,7 +349,6 @@ static void FindNextPairOfFaces(const TopoDS_Shape& aCurFace,
     }
 
     FindNextPairOfFaces(F1other, aMapEdgeFaces1, aMapEdgeFaces2, FF, aCI);
-    
   }
 }
 
@@ -1250,7 +1253,8 @@ Standard_Integer GEOMImpl_PipeDriver::Execute(TFunction_Logbook& log) const
     Standard_ConstructionError::Raise("Algorithm have produced an invalid shape result");
   }
 
-  aFunction->SetValue(aShape);
+  TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape);
+  aFunction->SetValue(aRes);
 
   log.SetTouched(Label());
   if(aCI) delete aCI;
index 87157a5fcfada5d38e32adc67477dffa3e14ea21..8d049aa56b23fbbe1f044e4f521ecfaa1424b375 100644 (file)
@@ -21,6 +21,8 @@
 #include <Standard_Stream.hxx>
 
 #include <GEOMImpl_PrismDriver.hxx>
+
+#include <GEOMImpl_IShapesOperations.hxx>
 #include <GEOMImpl_IPrism.hxx>
 #include <GEOMImpl_Types.hxx>
 #include <GEOM_Function.hxx>
@@ -114,7 +116,8 @@ Standard_Integer GEOMImpl_PrismDriver::Execute(TFunction_Logbook& log) const
 
   if (aShape.IsNull()) return 0;
 
-  aFunction->SetValue(aShape);
+  TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape);
+  aFunction->SetValue(aRes);
 
   log.SetTouched(Label()); 
 
index beec64f3c3387041c585ace91401777cc74d91f3..2f790ca3ee055a4435d3a86da8324f7dcf52a7e7 100644 (file)
@@ -21,6 +21,8 @@
 #include <Standard_Stream.hxx>
 
 #include <GEOMImpl_RevolutionDriver.hxx>
+
+#include <GEOMImpl_IShapesOperations.hxx>
 #include <GEOMImpl_IRevolution.hxx>
 #include <GEOMImpl_Types.hxx>
 #include <GEOM_Function.hxx>
@@ -114,11 +116,13 @@ Standard_Integer GEOMImpl_RevolutionDriver::Execute(TFunction_Logbook& log) cons
   }
 
   if (aShape.IsNull()) return 0;
-  aFunction->SetValue(aShape);
 
-  log.SetTouched(Label()); 
+  TopoDS_Shape aRes = GEOMImpl_IShapesOperations::CompsolidToCompound(aShape);
+  aFunction->SetValue(aRes);
+
+  log.SetTouched(Label());
 
-  return 1;    
+  return 1;
 }