Provide idl methods for automatic shapes naming to allow geompy.py leaving without GUI.

This commit is contained in:
jfa 2006-03-28 13:50:38 +00:00
parent 42e3c3a45a
commit 2f738ba9cd
10 changed files with 352 additions and 139 deletions

View File

@ -893,6 +893,35 @@ module GEOM
GEOM_Object GetSubShape (in GEOM_Object theMainShape, GEOM_Object GetSubShape (in GEOM_Object theMainShape,
in long theID); 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 <VAR>GetShapeTypeString()</VAR> 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 <VAR>GetTopologyIndex()</VAR> 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. * Count number of faces in the given shape.
* \param theShape Shape to count faces in. * \param theShape Shape to count faces in.
@ -1378,7 +1407,7 @@ module GEOM
* \param theDirFace2 Second direction face global index. * \param theDirFace2 Second direction face global index.
* \param theNbTimes Quantity of transformations to be done. * \param theNbTimes Quantity of transformations to be done.
* \note Global index of sub-shape can be obtained, using method * \note Global index of sub-shape can be obtained, using method
* <VAR>GEOM_ILocalOperations.GetSubShapeIndex()</VAR>. * <VAR>GEOM_IShapesOperations.GetSubShapeIndex()</VAR>.
* \return New GEOM_Object, containing the result shape. * \return New GEOM_Object, containing the result shape.
*/ */
GEOM_Object MakeMultiTransformation1D (in GEOM_Object theBlock, GEOM_Object MakeMultiTransformation1D (in GEOM_Object theBlock,
@ -1602,7 +1631,8 @@ module GEOM
* \param theShape Shape, to perform fillet on. * \param theShape Shape, to perform fillet on.
* \param theR Fillet radius. * \param theR Fillet radius.
* \param theEdges Global indices of edges to perform fillet on. * \param theEdges Global indices of edges to perform fillet on.
* \note Global index of sub-shape can be obtained, using method <VAR>GetSubShapeIndex()</VAR>. * \note Global index of sub-shape can be obtained, using method
* <VAR>GEOM_IShapesOperations.GetSubShapeIndex()</VAR>.
* \return New GEOM_Object, containing the result shape. * \return New GEOM_Object, containing the result shape.
*/ */
GEOM_Object MakeFilletEdges (in GEOM_Object theShape, GEOM_Object MakeFilletEdges (in GEOM_Object theShape,
@ -1614,7 +1644,8 @@ module GEOM
* \param theShape Shape, to perform fillet on. * \param theShape Shape, to perform fillet on.
* \param theR Fillet radius. * \param theR Fillet radius.
* \param theFaces Global indices of faces to perform fillet on. * \param theFaces Global indices of faces to perform fillet on.
* \note Global index of sub-shape can be obtained, using method <VAR>GetSubShapeIndex()</VAR>. * \note Global index of sub-shape can be obtained, using method
* <VAR>GEOM_IShapesOperations.GetSubShapeIndex()</VAR>.
* \return New GEOM_Object, containing the result shape. * \return New GEOM_Object, containing the result shape.
*/ */
GEOM_Object MakeFilletFaces (in GEOM_Object theShape, GEOM_Object MakeFilletFaces (in GEOM_Object theShape,
@ -1637,7 +1668,8 @@ module GEOM
* \param theD1 Chamfer size along \a theFace1. * \param theD1 Chamfer size along \a theFace1.
* \param theD2 Chamfer size along \a theFace2. * \param theD2 Chamfer size along \a theFace2.
* \param theFace1,theFace2 Global indices of two faces of \a theShape. * \param theFace1,theFace2 Global indices of two faces of \a theShape.
* \note Global index of sub-shape can be obtained, using method <VAR>GetSubShapeIndex()</VAR>. * \note Global index of sub-shape can be obtained, using method
* <VAR>GEOM_IShapesOperations.GetSubShapeIndex()</VAR>.
* \return New GEOM_Object, containing the result shape. * \return New GEOM_Object, containing the result shape.
*/ */
GEOM_Object MakeChamferEdge (in GEOM_Object theShape, 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. * 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 theD2 Chamfer size along another of two faces, connected to the edge.
* \param theFaces Sequence of global indices of faces of \a theShape. * \param theFaces Sequence of global indices of faces of \a theShape.
* \note Global index of sub-shape can be obtained, using method <VAR>GetSubShapeIndex()</VAR>. * \note Global index of sub-shape can be obtained, using method
* <VAR>GEOM_IShapesOperations.GetSubShapeIndex()</VAR>.
* \return New GEOM_Object, containing the result shape. * \return New GEOM_Object, containing the result shape.
*/ */
GEOM_Object MakeChamferFaces (in GEOM_Object theShape, GEOM_Object MakeChamferFaces (in GEOM_Object theShape,
@ -1676,10 +1709,8 @@ module GEOM
in double theMeshDeflection); in double theMeshDeflection);
/*! /*!
* Get global index of \a theSubShape in \a theShape. * Duplicates <VAR>GEOM_IShapesOperations.GetSubShapeIndex()</VAR>.
* \param theShape Main shape. * Present here only for compatibility.
* \param theSubShape Sub-shape of the main shape.
* \return global index of \a theSubShape in \a theShape.
*/ */
long GetSubShapeIndex (in GEOM_Object theShape, in GEOM_Object theSubShape); 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 * 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 theGroup is a GEOM group to which the new sub shape is added
* \param theSubShapeId is a sub shape ID in the main object. * \param theSubShapeId is a sub shape ID in the main object.
* \note Use method <VAR>ILocalOperations.GetSubShapeIndex()</VAR> to get an ID by the sub shape * \note Use method <VAR>GEOM_IShapesOperations.GetSubShapeIndex()</VAR> to get an ID by the sub shape
*/ */
void AddObject (in GEOM_Object theGroup, in long theSubShapeId); 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 * 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 theGroup is a GEOM group from which the sub shape is removed.
* \param theSubShapeId is a sub shape ID in the main object. * \param theSubShapeId is a sub shape ID in the main object.
* \note Use method <VAR>ILocalOperations.GetSubShapeIndex()</VAR> to get an ID by the sub shape * \note Use method <VAR>GEOM_IShapesOperations.GetSubShapeIndex()</VAR> to get an ID by the sub shape
*/ */
void RemoveObject (in GEOM_Object theGroup, in long theSubShapeId); void RemoveObject (in GEOM_Object theGroup, in long theSubShapeId);

View File

@ -59,21 +59,25 @@
#include "SALOMEDSClient.hxx" #include "SALOMEDSClient.hxx"
// OCCT Includes // OCCT Includes
#include <TopExp_Explorer.hxx> //#include <TopExp_Explorer.hxx>
#include <TopTools_MapOfShape.hxx> //#include <TopTools_MapOfShape.hxx>
#include <TopTools_ListOfShape.hxx> //#include <TopTools_ListOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx> //#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <BRepAdaptor_Surface.hxx> //#include <GeomAbs_CurveType.hxx>
#include <BRepAdaptor_Curve.hxx> //#include <GeomAbs_SurfaceType.hxx>
#include <GeomAbs_CurveType.hxx> //#include <TopoDS.hxx>
#include <GeomAbs_SurfaceType.hxx> #include <TopAbs.hxx>
#include <TopoDS.hxx> #include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx> //#include <TopoDS_Edge.hxx>
#include <TopoDS_Face.hxx> //#include <TopoDS_Face.hxx>
#include <TopoDS_Iterator.hxx> //#include <TopoDS_Iterator.hxx>
#include <AIS_ListOfInteractive.hxx> #include <AIS_ListOfInteractive.hxx>
#include <AIS_ListIteratorOfListOfInteractive.hxx> #include <AIS_ListIteratorOfListOfInteractive.hxx>
#include <V3d_Viewer.hxx> //#include <V3d_Viewer.hxx>
// IDL Headers
#include <SALOMEconfig.h>
#include CORBA_SERVER_HEADER(GEOM_Gen)
using namespace std; using namespace std;
@ -224,7 +228,8 @@ void GEOM_Swig::createAndDisplayGO (const char* Entry)
public: public:
TEventUpdateBrowser() {} TEventUpdateBrowser() {}
virtual void Execute() { virtual void Execute() {
SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication()); SalomeApp_Application* app =
dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
if (app) { if (app) {
CAM_Module* module = app->module("Geometry"); CAM_Module* module = app->module("Geometry");
SalomeApp_Module* appMod = dynamic_cast<SalomeApp_Module*>(module); SalomeApp_Module* appMod = dynamic_cast<SalomeApp_Module*>(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(); GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen();
if ( CORBA::is_nil( Geom ) ) if (CORBA::is_nil(aGeomGen))
return -1; return -1;
GEOM::GEOM_Object_var aMainShape = Geom->GetIORFromString(IOR); GEOM::GEOM_Object_var aMainShape = aGeomGen->GetIORFromString(IOR);
TopoDS_Shape shape = ShapeReader.GetShape(Geom, aMainShape); GEOM::GEOM_Object_var aSubShape = aGeomGen->GetIORFromString(SubIOR);
if (CORBA::is_nil(aMainShape) || CORBA::is_nil(aSubShape))
return -1;
GEOM::GEOM_Object_var aSubShape = Geom->GetIORFromString(SubIOR); GEOM::GEOM_IShapesOperations_var anIShapesOperations =
TopoDS_Shape subshape = ShapeReader.GetShape(Geom, aSubShape); aGeomGen->GetIShapesOperations(aMainShape->GetStudyID());
if (CORBA::is_nil(anIShapesOperations))
return -1;
int index = 1; return anIShapesOperations->GetTopologyIndex(aMainShape, aSubShape);
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();
}
}
return -1;
} }
const char* GEOM_Swig::getShapeTypeString(const char* IOR) const char* GEOM_Swig::getShapeTypeString(const char* IOR)
{ {
GEOM::GEOM_Gen_var Geom = GeometryGUI::GetGeomGen(); TCollection_AsciiString aTypeName ("Shape of unknown type");
if ( CORBA::is_nil( Geom ) )
return 0;
GEOM::GEOM_Object_var aShape = Geom->GetIORFromString(IOR); GEOM::GEOM_Gen_var aGeomGen = GeometryGUI::GetGeomGen();
TopoDS_Shape shape = ShapeReader.GetShape(Geom, aShape); if (!CORBA::is_nil(aGeomGen))
if( shape.IsNull() ) {
return "Null Shape" ;
}
switch (shape.ShapeType() )
{ {
case TopAbs_COMPOUND: GEOM::GEOM_Object_var aShape = aGeomGen->GetIORFromString(IOR);
{ return "Compound" ;} if (!CORBA::is_nil(aShape))
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)); GEOM::GEOM_IShapesOperations_var anIShapesOperations =
if ( surf.GetType() == GeomAbs_Plane ) { aGeomGen->GetIShapesOperations(aShape->GetStudyID());
return "Plane" ; if (!CORBA::is_nil(anIShapesOperations))
} else if ( surf.GetType() == GeomAbs_Cylinder ) { {
return "Cylindrical Face" ; aTypeName = anIShapesOperations->GetShapeTypeString(aShape);
} 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:
{
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" ;
}
}
case TopAbs_VERTEX:
{ return "Vertex" ;}
case TopAbs_SHAPE:
{ return "Shape" ;}
} }
return 0;
return CORBA::string_dup(aTypeName.ToCString());
} }

View File

@ -64,7 +64,8 @@ LIB_CLIENT_IDL = SALOME_Exception.idl \
SALOMEDS.idl \ SALOMEDS.idl \
SALOMEDS_Attributes.idl \ SALOMEDS_Attributes.idl \
SALOME_GenericObj.idl \ SALOME_GenericObj.idl \
SALOME_Component.idl SALOME_Component.idl \
GEOM_Gen.idl
LIB_SERVER_IDL = LIB_SERVER_IDL =

View File

@ -35,6 +35,9 @@
#include <GEOMImpl_IArchimede.hxx> #include <GEOMImpl_IArchimede.hxx>
#include <GEOMImpl_ArchimedeDriver.hxx> #include <GEOMImpl_ArchimedeDriver.hxx>
#include <GEOMImpl_Gen.hxx>
#include <GEOMImpl_IShapesOperations.hxx>
#include "utilities.h" #include "utilities.h"
#include <OpUtil.hxx> #include <OpUtil.hxx>
#include <Utils_ExceptHandlers.hxx> #include <Utils_ExceptHandlers.hxx>
@ -509,17 +512,17 @@ Standard_Integer GEOMImpl_ILocalOperations::GetSubShapeIndex (Handle(GEOM_Object
{ {
SetErrorCode(KO); SetErrorCode(KO);
TopoDS_Shape aShape = theShape->GetValue(); Standard_Integer anInd = -1;
TopoDS_Shape aSubShape = theSubShape->GetValue(); GEOM_Engine* anEngine = GetEngine();
//GEOMImpl_Gen* aGen = dynamic_cast<GEOMImpl_Gen*>(anEngine);
GEOMImpl_Gen* aGen = (GEOMImpl_Gen*)anEngine;
if (aShape.IsNull() || aSubShape.IsNull()) return -1; if (aGen) {
GEOMImpl_IShapesOperations* anIShapesOperations =
TopTools_IndexedMapOfShape anIndices; aGen->GetIShapesOperations(GetDocID());
TopExp::MapShapes(aShape, anIndices); anInd = anIShapesOperations->GetSubShapeIndex(theShape, theSubShape);
if (anIndices.Contains(aSubShape)) { SetErrorCode(anIShapesOperations->GetErrorCode());
SetErrorCode(OK);
return anIndices.FindIndex(aSubShape);
} }
return -1; return anInd;
} }

View File

@ -56,6 +56,7 @@
#include <BRep_Tool.hxx> #include <BRep_Tool.hxx>
#include <BRepGProp.hxx> #include <BRepGProp.hxx>
#include <BRepAdaptor_Curve.hxx> #include <BRepAdaptor_Curve.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRepBndLib.hxx> #include <BRepBndLib.hxx>
#include <BRepBuilderAPI_MakeFace.hxx> #include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepMesh_IncrementalMesh.hxx> #include <BRepMesh_IncrementalMesh.hxx>
@ -705,6 +706,163 @@ Handle(GEOM_Object) GEOMImpl_IShapesOperations::GetSubShape
return anObj; 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;
}
//============================================================================= //=============================================================================
/*! /*!

View File

@ -71,7 +71,15 @@ class GEOMImpl_IShapesOperations : public GEOM_IOperations {
const Standard_Boolean isSorted); const Standard_Boolean isSorted);
Standard_EXPORT Handle(GEOM_Object) GetSubShape (Handle(GEOM_Object) theMainShape, 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 NumberOfFaces (Handle(GEOM_Object) theShape);
Standard_EXPORT Standard_Integer NumberOfEdges (Handle(GEOM_Object) theShape); Standard_EXPORT Standard_Integer NumberOfEdges (Handle(GEOM_Object) theShape);

View File

@ -248,7 +248,7 @@ char* GEOM_IMeasureOperations_i::WhatIs (GEOM::GEOM_Object_ptr theShape)
// Get shape parameters // Get shape parameters
TCollection_AsciiString aDescription = GetOperations()->WhatIs(aShape); TCollection_AsciiString aDescription = GetOperations()->WhatIs(aShape);
return strdup(aDescription.ToCString()); return CORBA::string_dup(aDescription.ToCString());
} }
//============================================================================= //=============================================================================

View File

@ -438,6 +438,76 @@ GEOM::GEOM_Object_ptr GEOM_IShapesOperations_i::GetSubShape
return GetObject(anObject); 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 <theSubShape> inside <theMainShape>
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 <theSubShape>, unique among all sub-shapes of <theMainShape> 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 * NumberOfFaces

View File

@ -73,6 +73,14 @@ class GEOM_IShapesOperations_i :
GEOM::GEOM_Object_ptr GetSubShape (GEOM::GEOM_Object_ptr theMainShape, GEOM::GEOM_Object_ptr GetSubShape (GEOM::GEOM_Object_ptr theMainShape,
CORBA::Long theID); 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 NumberOfFaces (GEOM::GEOM_Object_ptr theShape);
CORBA::Long NumberOfEdges (GEOM::GEOM_Object_ptr theShape); CORBA::Long NumberOfEdges (GEOM::GEOM_Object_ptr theShape);

View File

@ -106,10 +106,12 @@ def SubShapeName(aSubObj, aMainObj):
* Example: see GEOM_TestAll.py * Example: see GEOM_TestAll.py
""" """
aSubId = orb.object_to_string(aSubObj) #aSubId = orb.object_to_string(aSubObj)
aMainId = orb.object_to_string(aMainObj) #aMainId = orb.object_to_string(aMainObj)
index = gg.getIndexTopology(aSubId, aMainId) #index = gg.getIndexTopology(aSubId, aMainId)
name = gg.getShapeTypeString(aSubId) + "_%d"%(index) #name = gg.getShapeTypeString(aSubId) + "_%d"%(index)
index = ShapesOp.GetTopologyIndex(aMainObj, aSubObj)
name = ShapesOp.GetShapeTypeString(aSubObj) + "_%d"%(index)
return name return name
def addToStudy(aShape, aName): def addToStudy(aShape, aName):