From: jfa Date: Thu, 7 Jun 2007 08:08:54 +0000 (+0000) Subject: NPAL16173: EDF454: Result of revolving a shell should be a compound. X-Git-Tag: V3_2_7~18 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=97fc7b1c06941ef8846e03286db167d99c2f9db0;p=modules%2Fgeom.git NPAL16173: EDF454: Result of revolving a shell should be a compound. --- diff --git a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx index de70f1259..8d39e8826 100644 --- a/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_I3DPrimOperations.cxx @@ -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); diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index 529c6cdec..02af581ec 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -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 #include +#include #include #include #include @@ -78,6 +78,7 @@ #include #include #include +#include #include #include #include @@ -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; } diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx index 42d2ed991..228aa8862 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx @@ -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 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 diff --git a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx index ea9d3acbb..89fcf6163 100644 --- a/src/GEOMImpl/GEOMImpl_PipeDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PipeDriver.cxx @@ -21,16 +21,28 @@ #include #include + +#include +#include +#include #include #include #include +#include +#include + #include +#include +#include +#include #include #include -#include +#include #include +#include +#include #include #include #include @@ -38,32 +50,24 @@ #include #include #include -#include -#include -#include -#include - -#include -#include -#include -#include "utilities.h" -#include -#include -#include #include -#include -#include -#include +#include #include #include -#include #include + #include -#include #include -#include -//#include +#include +#include + +#include +#include +#include +#include + +#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; diff --git a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx index 87157a5fc..8d049aa56 100644 --- a/src/GEOMImpl/GEOMImpl_PrismDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_PrismDriver.cxx @@ -21,6 +21,8 @@ #include #include + +#include #include #include #include @@ -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()); diff --git a/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx b/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx index beec64f3c..2f790ca3e 100644 --- a/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx +++ b/src/GEOMImpl/GEOMImpl_RevolutionDriver.cxx @@ -21,6 +21,8 @@ #include #include + +#include #include #include #include @@ -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; }