From: jfa Date: Tue, 28 Mar 2006 13:50:38 +0000 (+0000) Subject: Provide idl methods for automatic shapes naming to allow geompy.py leaving without... X-Git-Tag: T3_2_0b1_pre1~21 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=2f738ba9cdf691ff57f2edef2907c78d9778d4ac;p=modules%2Fgeom.git Provide idl methods for automatic shapes naming to allow geompy.py leaving without GUI. --- diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 28c2ad4ae..24023fa50 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -893,6 +893,35 @@ module GEOM GEOM_Object GetSubShape (in GEOM_Object theMainShape, in long theID); + /*! + * Get global index of \a theSubShape in \a theMainShape. + * \param theMainShape Main shape. + * \param theSubShape Sub-shape of the main shape. + * \return global index of \a theSubShape in \a theMainShape. + */ + long GetSubShapeIndex (in GEOM_Object theMainShape, in GEOM_Object theSubShape); + + /*! + * Get index of \a theSubShape in \a theMainShape, unique among sub-shapes of the same type. + * Together with method GetShapeTypeString() it can be used + * to generate automatic names for sub-shapes, when publishing them in a study. + * \param theMainShape Main shape. + * \param theSubShape Sub-shape of the main shape. + * \return index of \a theSubShape in a list of all sub-shapes of \a theMainShape of the same type. + */ + long GetTopologyIndex (in GEOM_Object theMainShape, in GEOM_Object theSubShape); + + /*! + * \brief Get name of type of \a theShape. + * + * Use wide type notation, taking into consideration both topology and geometry of the shape. + * Together with method GetTopologyIndex() it can be used + * to generate automatic names for sub-shapes, when publishing them in a study. + * \param theShape The shape to get a type of. + * \return String, containing a type name of \a theShape. + */ + string GetShapeTypeString (in GEOM_Object theShape); + /*! * Count number of faces in the given shape. * \param theShape Shape to count faces in. @@ -1378,7 +1407,7 @@ module GEOM * \param theDirFace2 Second direction face global index. * \param theNbTimes Quantity of transformations to be done. * \note Global index of sub-shape can be obtained, using method - * GEOM_ILocalOperations.GetSubShapeIndex(). + * GEOM_IShapesOperations.GetSubShapeIndex(). * \return New GEOM_Object, containing the result shape. */ GEOM_Object MakeMultiTransformation1D (in GEOM_Object theBlock, @@ -1602,7 +1631,8 @@ module GEOM * \param theShape Shape, to perform fillet on. * \param theR Fillet radius. * \param theEdges Global indices of edges to perform fillet on. - * \note Global index of sub-shape can be obtained, using method GetSubShapeIndex(). + * \note Global index of sub-shape can be obtained, using method + * GEOM_IShapesOperations.GetSubShapeIndex(). * \return New GEOM_Object, containing the result shape. */ GEOM_Object MakeFilletEdges (in GEOM_Object theShape, @@ -1614,7 +1644,8 @@ module GEOM * \param theShape Shape, to perform fillet on. * \param theR Fillet radius. * \param theFaces Global indices of faces to perform fillet on. - * \note Global index of sub-shape can be obtained, using method GetSubShapeIndex(). + * \note Global index of sub-shape can be obtained, using method + * GEOM_IShapesOperations.GetSubShapeIndex(). * \return New GEOM_Object, containing the result shape. */ GEOM_Object MakeFilletFaces (in GEOM_Object theShape, @@ -1637,7 +1668,8 @@ module GEOM * \param theD1 Chamfer size along \a theFace1. * \param theD2 Chamfer size along \a theFace2. * \param theFace1,theFace2 Global indices of two faces of \a theShape. - * \note Global index of sub-shape can be obtained, using method GetSubShapeIndex(). + * \note Global index of sub-shape can be obtained, using method + * GEOM_IShapesOperations.GetSubShapeIndex(). * \return New GEOM_Object, containing the result shape. */ GEOM_Object MakeChamferEdge (in GEOM_Object theShape, @@ -1653,7 +1685,8 @@ module GEOM * will be get along face, which is nearer to \a theFaces beginning. * \param theD2 Chamfer size along another of two faces, connected to the edge. * \param theFaces Sequence of global indices of faces of \a theShape. - * \note Global index of sub-shape can be obtained, using method GetSubShapeIndex(). + * \note Global index of sub-shape can be obtained, using method + * GEOM_IShapesOperations.GetSubShapeIndex(). * \return New GEOM_Object, containing the result shape. */ GEOM_Object MakeChamferFaces (in GEOM_Object theShape, @@ -1676,10 +1709,8 @@ module GEOM in double theMeshDeflection); /*! - * Get global index of \a theSubShape in \a theShape. - * \param theShape Main shape. - * \param theSubShape Sub-shape of the main shape. - * \return global index of \a theSubShape in \a theShape. + * Duplicates GEOM_IShapesOperations.GetSubShapeIndex(). + * Present here only for compatibility. */ long GetSubShapeIndex (in GEOM_Object theShape, in GEOM_Object theSubShape); }; @@ -1972,7 +2003,7 @@ module GEOM * Adds a sub object with ID theSubShapeId to the group * \param theGroup is a GEOM group to which the new sub shape is added * \param theSubShapeId is a sub shape ID in the main object. - * \note Use method ILocalOperations.GetSubShapeIndex() to get an ID by the sub shape + * \note Use method GEOM_IShapesOperations.GetSubShapeIndex() to get an ID by the sub shape */ void AddObject (in GEOM_Object theGroup, in long theSubShapeId); @@ -1980,7 +2011,7 @@ module GEOM * Removes a sub object with ID \a theSubShapeId from the group * \param theGroup is a GEOM group from which the sub shape is removed. * \param theSubShapeId is a sub shape ID in the main object. - * \note Use method ILocalOperations.GetSubShapeIndex() to get an ID by the sub shape + * \note Use method GEOM_IShapesOperations.GetSubShapeIndex() to get an ID by the sub shape */ void RemoveObject (in GEOM_Object theGroup, in long theSubShapeId); diff --git a/src/GEOMGUI/GeometryGUI_Swig.cxx b/src/GEOMGUI/GeometryGUI_Swig.cxx index 9a10ef6df..9cfc90129 100644 --- a/src/GEOMGUI/GeometryGUI_Swig.cxx +++ b/src/GEOMGUI/GeometryGUI_Swig.cxx @@ -59,21 +59,25 @@ #include "SALOMEDSClient.hxx" // OCCT Includes -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +//#include +//#include +//#include +//#include +//#include +//#include +//#include +#include +#include +//#include +//#include +//#include #include #include -#include +//#include + +// IDL Headers +#include +#include CORBA_SERVER_HEADER(GEOM_Gen) using namespace std; @@ -224,7 +228,8 @@ void GEOM_Swig::createAndDisplayGO (const char* Entry) public: TEventUpdateBrowser() {} virtual void Execute() { - SalomeApp_Application* app = dynamic_cast(SUIT_Session::session()->activeApplication()); + SalomeApp_Application* app = + dynamic_cast(SUIT_Session::session()->activeApplication()); if (app) { CAM_Module* module = app->module("Geometry"); SalomeApp_Module* appMod = dynamic_cast(module); @@ -237,118 +242,45 @@ void GEOM_Swig::createAndDisplayGO (const char* Entry) } -int GEOM_Swig::getIndexTopology(const char* SubIOR, const char* IOR) +int GEOM_Swig::getIndexTopology(const char* SubIOR, const char* IOR) { - GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen(); - if ( CORBA::is_nil( Geom ) ) + GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen(); + if (CORBA::is_nil(aGeomGen)) return -1; - GEOM::GEOM_Object_var aMainShape = Geom->GetIORFromString(IOR); - TopoDS_Shape shape = ShapeReader.GetShape(Geom, aMainShape); - - GEOM::GEOM_Object_var aSubShape = Geom->GetIORFromString(SubIOR); - TopoDS_Shape subshape = ShapeReader.GetShape(Geom, aSubShape); - - int index = 1; - if(subshape.ShapeType() == TopAbs_COMPOUND) { - TopoDS_Iterator it; - TopTools_ListOfShape CL; - CL.Append(shape); - TopTools_ListIteratorOfListOfShape itC; - for(itC.Initialize(CL); itC.More(); itC.Next()) { - for(it.Initialize(itC.Value()); it.More(); it.Next()) { - if (it.Value().ShapeType() == TopAbs_COMPOUND) { - if (it.Value().IsSame(subshape)) - return index; - else - index++; - CL.Append(it.Value()); - } - } - } - } - else { - TopExp_Explorer Exp(shape, subshape.ShapeType()); - TopTools_MapOfShape M; - while(Exp.More()) { - if(M.Add(Exp.Current())) { - if(Exp.Current().IsSame(subshape)) - return index; - index++; - } - Exp.Next(); - } - } + GEOM::GEOM_Object_var aMainShape = aGeomGen->GetIORFromString(IOR); + GEOM::GEOM_Object_var aSubShape = aGeomGen->GetIORFromString(SubIOR); + if (CORBA::is_nil(aMainShape) || CORBA::is_nil(aSubShape)) + return -1; + + GEOM::GEOM_IShapesOperations_var anIShapesOperations = + aGeomGen->GetIShapesOperations(aMainShape->GetStudyID()); + if (CORBA::is_nil(anIShapesOperations)) + return -1; - return -1; + return anIShapesOperations->GetTopologyIndex(aMainShape, aSubShape); } const char* GEOM_Swig::getShapeTypeString(const char* IOR) { - GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen(); - if ( CORBA::is_nil( Geom ) ) - return 0; - - GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(IOR); - TopoDS_Shape shape = ShapeReader.GetShape(Geom, aShape); - - if( shape.IsNull() ) { - return "Null Shape" ; - } + TCollection_AsciiString aTypeName ("Shape of unknown type"); - switch (shape.ShapeType() ) + GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen(); + if (!CORBA::is_nil(aGeomGen)) { - case TopAbs_COMPOUND: - { return "Compound" ;} - case TopAbs_COMPSOLID: - { return "Compound Solid" ;} - case TopAbs_SOLID: - { return "Solid" ;} - case TopAbs_SHELL: - { return "Shell" ;} - case TopAbs_FACE: - { - BRepAdaptor_Surface surf(TopoDS::Face(shape)); - if ( surf.GetType() == GeomAbs_Plane ) { - return "Plane" ; - } else if ( surf.GetType() == GeomAbs_Cylinder ) { - return "Cylindrical Face" ; - } else if ( surf.GetType() == GeomAbs_Sphere ) { - return "Spherical Face" ; - } else if ( surf.GetType() == GeomAbs_Torus ) { - return "Toroidal Face" ; - } else if ( surf.GetType() == GeomAbs_Cone ) { - return "Conical Face" ; - } else { - return "GEOM::FACE" ; - } - } - case TopAbs_WIRE: - { return "Wire" ;} - case TopAbs_EDGE: + GEOM::GEOM_Object_var aShape = aGeomGen->GetIORFromString(IOR); + if (!CORBA::is_nil(aShape)) { - BRepAdaptor_Curve curv(TopoDS::Edge(shape)); - if ( curv.GetType() == GeomAbs_Line ) { - if ( (Abs(curv.FirstParameter()) >= 1E6 ) || - (Abs(curv.LastParameter()) >= 1E6 )) { - return "Line" ; - } else - return "Edge" ; - } else if ( curv.GetType() == GeomAbs_Circle ) { - if ( curv.IsClosed() ) - return "Circle" ; - else - return "Arc" ; - } else { - return "Edge" ; + GEOM::GEOM_IShapesOperations_var anIShapesOperations = + aGeomGen->GetIShapesOperations(aShape->GetStudyID()); + if (!CORBA::is_nil(anIShapesOperations)) + { + aTypeName = anIShapesOperations->GetShapeTypeString(aShape); } } - case TopAbs_VERTEX: - { return "Vertex" ;} - case TopAbs_SHAPE: - { return "Shape" ;} } - return 0; + + return CORBA::string_dup(aTypeName.ToCString()); } diff --git a/src/GEOMGUI/Makefile.in b/src/GEOMGUI/Makefile.in index a14ea4cb1..ecfc9c433 100644 --- a/src/GEOMGUI/Makefile.in +++ b/src/GEOMGUI/Makefile.in @@ -64,7 +64,8 @@ LIB_CLIENT_IDL = SALOME_Exception.idl \ SALOMEDS.idl \ SALOMEDS_Attributes.idl \ SALOME_GenericObj.idl \ - SALOME_Component.idl + SALOME_Component.idl \ + GEOM_Gen.idl LIB_SERVER_IDL = diff --git a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx index c6f85f04a..483979d7e 100644 --- a/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_ILocalOperations.cxx @@ -35,6 +35,9 @@ #include #include +#include +#include + #include "utilities.h" #include #include @@ -509,17 +512,17 @@ Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object { SetErrorCode(KO); - TopoDS_Shape aShape = theShape->GetValue(); - TopoDS_Shape aSubShape = theSubShape->GetValue(); - - if (aShape.IsNull() || aSubShape.IsNull()) return -1; + Standard_Integer anInd = -1; + GEOM_Engine* anEngine = GetEngine(); + //GEOMImpl_Gen* aGen = dynamic_cast(anEngine); + GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine; - TopTools_IndexedMapOfShape anIndices; - TopExp::MapShapes(aShape, anIndices); - if (anIndices.Contains(aSubShape)) { - SetErrorCode(OK); - return anIndices.FindIndex(aSubShape); + if (aGen) { + GEOMImpl_IShapesOperations* anIShapesOperations = + aGen->GetIShapesOperations(GetDocID()); + anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape); + SetErrorCode(anIShapesOperations->GetErrorCode()); } - return -1; + return anInd; } diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx index 7c41f7342..5095ba2b2 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.cxx @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -705,6 +706,163 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetSubShape return anObj; } +//============================================================================= +/*! + * GetSubShapeIndex + */ +//============================================================================= +Standard_Integer GEOMImpl_IShapesOperations::GetSubShapeIndex (Handle(GEOM_Object) theMainShape, + Handle(GEOM_Object) theSubShape) +{ + SetErrorCode(KO); + + TopoDS_Shape aMainShape = theMainShape->GetValue(); + TopoDS_Shape aSubShape = theSubShape->GetValue(); + + if (aMainShape.IsNull() || aSubShape.IsNull()) return -1; + + TopTools_IndexedMapOfShape anIndices; + TopExp::MapShapes(aMainShape, anIndices); + if (anIndices.Contains(aSubShape)) { + SetErrorCode(OK); + return anIndices.FindIndex(aSubShape); + } + + return -1; +} + +//============================================================================= +/*! + * GetTopologyIndex + */ +//============================================================================= +Standard_Integer GEOMImpl_IShapesOperations::GetTopologyIndex (Handle(GEOM_Object) theMainShape, + Handle(GEOM_Object) theSubShape) +{ + SetErrorCode(OK); + + TopoDS_Shape aMainShape = theMainShape->GetValue(); + TopoDS_Shape aSubShape = theSubShape->GetValue(); + + if (aMainShape.IsNull() || aSubShape.IsNull()) { + SetErrorCode("Null argument shape given"); + return -1; + } + + int index = 1; + if (aSubShape.ShapeType() == TopAbs_COMPOUND) { + TopoDS_Iterator it; + TopTools_ListOfShape CL; + CL.Append(aMainShape); + TopTools_ListIteratorOfListOfShape itC; + for (itC.Initialize(CL); itC.More(); itC.Next()) { + for (it.Initialize(itC.Value()); it.More(); it.Next()) { + if (it.Value().ShapeType() == TopAbs_COMPOUND) { + if (it.Value().IsSame(aSubShape)) + return index; + else + index++; + CL.Append(it.Value()); + } + } + } + } else { + TopExp_Explorer anExp (aMainShape, aSubShape.ShapeType()); + TopTools_MapOfShape M; + for (; anExp.More(); anExp.Next()) { + if (M.Add(anExp.Current())) { + if (anExp.Current().IsSame(aSubShape)) + return index; + index++; + } + } + } + + SetErrorCode("The sub-shape does not belong to the main shape"); + return -1; +} + +//============================================================================= +/*! + * GetShapeTypeString + */ +//============================================================================= +TCollection_AsciiString GEOMImpl_IShapesOperations::GetShapeTypeString (Handle(GEOM_Object) theShape) +{ + SetErrorCode(KO); + + TCollection_AsciiString aTypeName ("Null Shape"); + + TopoDS_Shape aShape = theShape->GetValue(); + if (aShape.IsNull()) + return aTypeName; + + switch (aShape.ShapeType() ) + { + case TopAbs_COMPOUND: + aTypeName = "Compound"; + break; + case TopAbs_COMPSOLID: + aTypeName = "Compound Solid"; + break; + case TopAbs_SOLID: + aTypeName = "Solid"; + break; + case TopAbs_SHELL: + aTypeName = "Shell"; + break; + case TopAbs_FACE: + { + BRepAdaptor_Surface surf (TopoDS::Face(aShape)); + if (surf.GetType() == GeomAbs_Plane) + aTypeName = "Plane"; + else if (surf.GetType() == GeomAbs_Cylinder) + aTypeName = "Cylindrical Face"; + else if (surf.GetType() == GeomAbs_Sphere) + aTypeName = "Spherical Face"; + else if (surf.GetType() == GeomAbs_Torus) + aTypeName = "Toroidal Face"; + else if (surf.GetType() == GeomAbs_Cone) + aTypeName = "Conical Face"; + else + aTypeName = "GEOM::FACE"; + } + break; + case TopAbs_WIRE: + aTypeName = "Wire"; + break; + case TopAbs_EDGE: + { + BRepAdaptor_Curve curv (TopoDS::Edge(aShape)); + if (curv.GetType() == GeomAbs_Line) { + if ((Abs(curv.FirstParameter()) >= 1E6) || + (Abs(curv.LastParameter()) >= 1E6)) + aTypeName = "Line"; + else + aTypeName = "Edge" ; + } else if (curv.GetType() == GeomAbs_Circle) { + if (curv.IsClosed()) + aTypeName = "Circle"; + else + aTypeName = "Arc"; + } else { + aTypeName = "Edge"; + } + } + break; + case TopAbs_VERTEX: + aTypeName = "Vertex"; + break; + case TopAbs_SHAPE: + aTypeName = "Shape"; + break; + default: + aTypeName = "Shape of unknown type"; + } + + return aTypeName; +} + //============================================================================= /*! diff --git a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx index 82a7d37e0..28882a0d1 100644 --- a/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IShapesOperations.hxx @@ -71,7 +71,15 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations { const Standard_Boolean isSorted); Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape, - const Standard_Integer theID); + const Standard_Integer theID); + + Standard_EXPORT Standard_Integer GetSubShapeIndex (Handle(GEOM_Object) theMainShape, + Handle(GEOM_Object) theSubShape); + + Standard_EXPORT Standard_Integer GetTopologyIndex (Handle(GEOM_Object) theMainShape, + Handle(GEOM_Object) theSubShape); + + Standard_EXPORT TCollection_AsciiString GetShapeTypeString (Handle(GEOM_Object) theShape); Standard_EXPORT Standard_Integer NumberOfFaces (Handle(GEOM_Object) theShape); Standard_EXPORT Standard_Integer NumberOfEdges (Handle(GEOM_Object) theShape); diff --git a/src/GEOM_I/GEOM_IMeasureOperations_i.cc b/src/GEOM_I/GEOM_IMeasureOperations_i.cc index 1564bd5b7..8fd387a2c 100644 --- a/src/GEOM_I/GEOM_IMeasureOperations_i.cc +++ b/src/GEOM_I/GEOM_IMeasureOperations_i.cc @@ -248,7 +248,7 @@ char* GEOM_IMeasureOperations_i::WhatIs (GEOM::GEOM_Object_ptr theShape) // Get shape parameters TCollection_AsciiString aDescription = GetOperations()->WhatIs(aShape); - return strdup(aDescription.ToCString()); + return CORBA::string_dup(aDescription.ToCString()); } //============================================================================= diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.cc b/src/GEOM_I/GEOM_IShapesOperations_i.cc index 4c452deae..d41f919b7 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.cc +++ b/src/GEOM_I/GEOM_IShapesOperations_i.cc @@ -438,6 +438,76 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape return GetObject(anObject); } +//============================================================================= +/*! + * GetSubShapeIndex + */ +//============================================================================= +CORBA::Long GEOM_IShapesOperations_i::GetSubShapeIndex + (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape) +{ + if (theMainShape == NULL || theSubShape == NULL) return -1; + + //Get the reference shapes + Handle(GEOM_Object) aMainShapeRef = GetOperations()->GetEngine()->GetObject + (theMainShape->GetStudyID(), theMainShape->GetEntry()); + Handle(GEOM_Object) aSubShapeRef = GetOperations()->GetEngine()->GetObject + (theSubShape->GetStudyID(), theSubShape->GetEntry()); + if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1; + + //Get the unique ID of inside + CORBA::Long anID = GetOperations()->GetSubShapeIndex(aMainShapeRef, aSubShapeRef); + if (!GetOperations()->IsDone()) + return -1; + + return anID; +} + +//============================================================================= +/*! + * GetTopologyIndex + */ +//============================================================================= +CORBA::Long GEOM_IShapesOperations_i::GetTopologyIndex + (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr theSubShape) +{ + if (theMainShape == NULL || theSubShape == NULL) return -1; + + //Get the reference shapes + Handle(GEOM_Object) aMainShapeRef = GetOperations()->GetEngine()->GetObject + (theMainShape->GetStudyID(), theMainShape->GetEntry()); + Handle(GEOM_Object) aSubShapeRef = GetOperations()->GetEngine()->GetObject + (theSubShape->GetStudyID(), theSubShape->GetEntry()); + if (aMainShapeRef.IsNull() || aSubShapeRef.IsNull()) return -1; + + //Get an ID of , unique among all sub-shapes of of the same type + CORBA::Long anID = GetOperations()->GetTopologyIndex(aMainShapeRef, aSubShapeRef); + if (!GetOperations()->IsDone()) + return -1; + + return anID; +} + +//============================================================================= +/*! + * GetShapeTypeString + */ +//============================================================================= +char* GEOM_IShapesOperations_i::GetShapeTypeString (GEOM::GEOM_Object_ptr theShape) +{ + if (theShape == NULL) return NULL; + + //Get the reference shape + Handle(GEOM_Object) aShape = GetOperations()->GetEngine()->GetObject + (theShape->GetStudyID(), theShape->GetEntry()); + + if (aShape.IsNull()) return NULL; + + // Get shape parameters + TCollection_AsciiString aDescription = GetOperations()->GetShapeTypeString(aShape); + return CORBA::string_dup(aDescription.ToCString()); +} + //============================================================================= /*! * NumberOfFaces diff --git a/src/GEOM_I/GEOM_IShapesOperations_i.hh b/src/GEOM_I/GEOM_IShapesOperations_i.hh index eb48a0f74..c09d16e3c 100644 --- a/src/GEOM_I/GEOM_IShapesOperations_i.hh +++ b/src/GEOM_I/GEOM_IShapesOperations_i.hh @@ -73,6 +73,14 @@ class GEOM_IShapesOperations_i : GEOM::GEOM_Object_ptr GetSubShape (GEOM::GEOM_Object_ptr theMainShape, CORBA::Long theID); + CORBA::Long GetSubShapeIndex (GEOM::GEOM_Object_ptr theMainShape, + GEOM::GEOM_Object_ptr theSubShape); + + CORBA::Long GetTopologyIndex (GEOM::GEOM_Object_ptr theMainShape, + GEOM::GEOM_Object_ptr theSubShape); + + char* GetShapeTypeString (GEOM::GEOM_Object_ptr theShape); + CORBA::Long NumberOfFaces (GEOM::GEOM_Object_ptr theShape); CORBA::Long NumberOfEdges (GEOM::GEOM_Object_ptr theShape); diff --git a/src/GEOM_SWIG/geompy.py b/src/GEOM_SWIG/geompy.py index fcd4a139b..e34d3163e 100644 --- a/src/GEOM_SWIG/geompy.py +++ b/src/GEOM_SWIG/geompy.py @@ -106,10 +106,12 @@ def SubShapeName(aSubObj, aMainObj): * Example: see GEOM_TestAll.py """ - aSubId = orb.object_to_string(aSubObj) - aMainId = orb.object_to_string(aMainObj) - index = gg.getIndexTopology(aSubId, aMainId) - name = gg.getShapeTypeString(aSubId) + "_%d"%(index) + #aSubId = orb.object_to_string(aSubObj) + #aMainId = orb.object_to_string(aMainObj) + #index = gg.getIndexTopology(aSubId, aMainId) + #name = gg.getShapeTypeString(aSubId) + "_%d"%(index) + index = ShapesOp.GetTopologyIndex(aMainObj, aSubObj) + name = ShapesOp.GetShapeTypeString(aSubObj) + "_%d"%(index) return name def addToStudy(aShape, aName):