continue;
if (geomObj->GetType() == GEOM_MARKER) {
ComboBox1->addItem(geomObj->GetName());
- TopoDS_Shape aShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
+ TopoDS_Shape aShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), geomObj);
gp_Ax3 aLCS;
aLCS.Transform(aShape.Location().Transformation());
UIC_FILES = \
ui_EntityGUI_1Sel_QTD.h \
- ui_EntityGUI_2Sel1Check_QTD.h \
+ ui_EntityGUI_2Sel1Check_QTD.h \
ui_EntityGUI_1Sel1Spin1Check_QTD.h \
ui_EntityGUI_1Spin_QTD.h \
ui_EntityGUI_2Spin_QTD.h \
if (GeomObject->_is_nil())
return result;
- result = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), GeomObject);
+ result = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), GeomObject);
return result;
}
{
if ( !CORBA::is_nil( theObject ) )
{
- TopoDS_Shape aTopoDSShape = GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), theObject );
+ TopoDS_Shape aTopoDSShape = GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObject );
if ( !aTopoDSShape.IsNull() && ( theType == TopAbs_SHAPE || theType == aTopoDSShape.ShapeType() ) )
{
theShape = aTopoDSShape;
CORBA::String_var IOR = SalomeApp_Application::orb()->object_to_string( theObj );
TCollection_AsciiString asciiIOR( (char *)IOR.in() );
- GEOM_Client().RemoveShapeFromBuffer( asciiIOR );
+ GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
if ( !getStudy() || !getStudy()->studyDS() )
return;
if ( anIt->Value()->FindAttribute(anAttr, "AttributeIOR") ) {
_PTR(AttributeIOR) anIOR ( anAttr );
TCollection_AsciiString asciiIOR( (char*)anIOR->Value().c_str() );
- GEOM_Client().RemoveShapeFromBuffer( asciiIOR );
+ GEOM_Client::get_client().RemoveShapeFromBuffer( asciiIOR );
}
}
}
//=======================================================================
Standard_Integer GEOM_Client::Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S )
{
- for ( Standard_Integer i = 1; i<= myIORs.Length(); i++ ) {
- if (myIORs.Value(i).IsEqual(IOR)) {
+ if(_myIndexes.count(IOR) != 0)
+ {
+ Standard_Integer i =_myIndexes[IOR];
S = myShapes.Value(i);
return i;
}
- }
return 0;
}
{
myIORs.Append(IOR);
myShapes.Append(S);
+ _myIndexes[IOR]=myIORs.Length();
}
//=======================================================================
if( anIndex != 0 ) {
myIORs.Remove(anIndex);
myShapes.Remove(anIndex);
+ _myIndexes.erase(IOR);
+ _mySubShapes.erase(IOR);
}
return;
}
return;
myIORs.Clear();
myShapes.Clear();
+ _myIndexes.clear();
+ _mySubShapes.clear();
return;
}
GEOM::ListOfLong_var list = aShape->GetSubShapeIndices();
TopTools_IndexedMapOfShape anIndices;
- TopExp::MapShapes(aMainShape, anIndices);
+ CORBA::String_var aMainIOR = geom->GetStringFromIOR(aShape->GetMainShape());
+ TCollection_AsciiString mainIOR = (char*)aMainIOR.in();
+
+ //find subshapes only one time
+ if(_mySubShapes.count(mainIOR)==0)
+ {
+ TopExp::MapShapes(aMainShape, anIndices);
+ Standard_Integer ii = 1, nbSubSh = anIndices.Extent();
+ for (; ii <= nbSubSh; ii++)
+ {
+ _mySubShapes[mainIOR].push_back(anIndices.FindKey(ii));
+ }
+ }
/* Case of only one subshape */
if (list->length() == 1 && list[0] > 0) {
- S = anIndices.FindKey(list[0]);
+ S = _mySubShapes[mainIOR][list[0]-1];
}
else {
BRep_Builder B;
B.MakeCompound(aCompound);
for (int i = 0; i < list->length(); i++) {
if (0 < list[i] && list[i] <= anIndices.Extent()) {
- TopoDS_Shape aSubShape = anIndices.FindKey(list[i]);
+ TopoDS_Shape aSubShape = _mySubShapes[mainIOR][list[i]-1];
B.Add(aCompound, aSubShape);
}
}
#define GEOMCLIENT_EXPORT
#endif
+#include <TCollection_AsciiString.hxx>
+#include <TopoDS_Shape.hxx>
+#include <map>
+#include <vector>
+
+/*
+ * if define SINGLE_CLIENT is not commented, the method get_client always returns the same GEOM_Client object (singleton object)
+ * and the SHAPE_READER macro can be used to define an object that is always this singleton object
+ * if define SINGLE_CLIENT is commented, we get the old way to define the GEOM_Client objects : get_client returns a new object
+ * and the SHAPE_READER macro defines also a new object
+ */
+#define SINGLE_CLIENT
//=====================================================================
// GEOM_Client : class definition
//=====================================================================
//Standard_EXPORT
unsigned int BufferLength() ;
TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape);
+#ifdef SINGLE_CLIENT
+ static GEOM_Client& get_client() { static GEOM_Client a;return a; }
+#else
+ static GEOM_Client get_client() { return GEOM_Client(); }
+#endif
private:
// Fields PRIVATE
//
TColStd_SequenceOfAsciiString myIORs ;
TopTools_SequenceOfShape myShapes ;
+ std::map< TCollection_AsciiString , int > _myIndexes;
+ std::map< TCollection_AsciiString , std::vector<TopoDS_Shape> > _mySubShapes;
long pid_client;
};
+#ifdef SINGLE_CLIENT
+#define SHAPE_READER(obj) GEOM_Client& obj=GEOM_Client::get_client()
+#else
+#define SHAPE_READER(obj) GEOM_Client obj
+#endif
#endif
}
if ( !CORBA::is_nil( geomGen ) )
{
- TopoDS_Shape aTopoDSShape = GEOM_Client().GetShape( geomGen, theObject );
+ TopoDS_Shape aTopoDSShape = GEOM_Client::get_client().GetShape( geomGen, theObject );
if ( !aTopoDSShape.IsNull() )
{
return 0;
internalReset();
- setShape( GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), theObj ) );
+ setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), theObj ) );
myType = theObj->GetType();
// Update presentation
if ( !GeomObject->_is_nil() )
{
// finally set shape
- setShape( GEOM_Client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
+ setShape( GEOM_Client::get_client().GetShape( GeometryGUI::GetGeomGen(), GeomObject ) );
myType = GeomObject->GetType();
}
}
static void Modified( bool = true );
- GEOM_Client& GetShapeReader() { return myShapeReader; }
+ GEOM_Client& GetShapeReader() { static SHAPE_READER(myShapeReader);return myShapeReader; }
// Get active dialog box
QDialog* GetActiveDialogBox(){ return myActiveDialogBox; }
GUIMap myGUIMap; // GUI libraries map
QDialog* myActiveDialogBox; // active dialog box
- GEOM_Client myShapeReader; // geom shape reader
gp_Ax3 myWorkingPlane;
QMap<int,QString> myRules; // popup rules
static StudyTextureMap myTextureMap; // texture map
#include <vtkRenderer.h>
-static GEOM_Client ShapeReader;
+static SHAPE_READER(ShapeReader);
inline OCCViewer_Viewer* GetOCCViewer(SUIT_Application* theApp){
SUIT_ViewWindow* window = theApp->desktop()->activeWindow();
if (GEOMBase::GetShape(aGeomObj, aShape)) {
if (aGeomObj->GetType() == GEOM_GROUP || aShape.ShapeType() == getShapeType()) {
TopTools_IndexedMapOfShape aMainMap;
- TopoDS_Shape aMainShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
+ TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
TopExp::MapShapes(aMainShape, aMainMap);
TopExp_Explorer anExp (aShape, getShapeType());
SALOME_View* aView = dynamic_cast<SALOME_View*>(aViewModel);
if (aView == 0) return;
- TopoDS_Shape aMainShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
+ TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myMainObj);
TopoDS_Shape aRestrictionShape;
if (subSelectionWay() == ALL_SUBSHAPES)
aRestrictionShape = aMainShape;
else if (!myInPlaceObj->_is_nil())
- aRestrictionShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myInPlaceObj);
+ aRestrictionShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myInPlaceObj);
else ;
TopTools_IndexedMapOfShape aSubShapesMap;
_PTR(Study) aStudy = appStudy->studyDS();
TopTools_IndexedMapOfShape aMainMap;
- TopoDS_Shape aMainShape = GEOM_Client().GetShape(GeometryGUI::GetGeomGen(), myObject);
+ TopoDS_Shape aMainShape = GEOM_Client::get_client().GetShape(GeometryGUI::GetGeomGen(), myObject);
TopExp::MapShapes(aMainShape, aMainMap);
SALOME_ListIteratorOfListIO anIter (aSelList);