From: jfa Date: Thu, 9 Dec 2010 07:17:59 +0000 (+0000) Subject: Fixed a problem with transformations without copy in optimized mode: static variable... X-Git-Tag: V6_2_0a2~13 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=acf36df326245615e81b50249a2438506772a8d9;p=modules%2Fgeom.git Fixed a problem with transformations without copy in optimized mode: static variable GEOM_Glient is declared and initialized in .cxx now. --- diff --git a/src/GEOMClient/GEOM_Client.cxx b/src/GEOMClient/GEOM_Client.cxx index 6a89e6893..7e01a7a6f 100644 --- a/src/GEOMClient/GEOM_Client.cxx +++ b/src/GEOMClient/GEOM_Client.cxx @@ -19,13 +19,11 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - // GEOM GEOMClient : tool to transfer BREP files from GEOM server to GEOM client // File : GEOM_Client.cxx // Author : Yves FRICAUD/Lucien PIGNOLONI // Module : GEOM -// $Header$ -// + #include #include @@ -100,6 +98,7 @@ GEOM_Client::GEOM_Client() #else (long)getpid(); #endif + cout << "$$$ GEOM_Client::GEOM_Client() pid_client = " << pid_client << endl; } //======================================================================= @@ -107,7 +106,7 @@ GEOM_Client::GEOM_Client() // purpose : Copy constructor //======================================================================= GEOM_Client::GEOM_Client(const GEOM_Client& client) -{ +{ myIORs = client.myIORs; myShapes = client.myShapes; _myIndexes = client._myIndexes; @@ -122,20 +121,41 @@ GEOM_Client::GEOM_Client(const GEOM_Client& client) GEOM_Client::GEOM_Client(Engines::Container_ptr client) { pid_client = client->getPID(); + cout << "$$$ GEOM_Client::GEOM_Client(client) pid_client = " << pid_client << endl; } +//======================================================================= +// function : get_client() +// purpose : Static method to have the only one instance of GEOM_Client +//======================================================================= +#ifdef SINGLE_CLIENT +GEOM_Client& GEOM_Client::get_client() +{ + static GEOM_Client a; + return a; +} +#else +GEOM_Client GEOM_Client::get_client() +{ + return GEOM_Client(); +} +#endif + //======================================================================= // function : Find() // purpose : //======================================================================= Standard_Integer GEOM_Client::Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S ) { - if(_myIndexes.count(IOR) != 0) - { - Standard_Integer i =_myIndexes[IOR]; - S = myShapes.Value(i); - return i; - } + cout << "$$$ GEOM_Client::Find BEGIN this = " << this << ", _myIndexes.size() = " << _myIndexes.size() << endl; + if (_myIndexes.count(IOR) != 0) + { + Standard_Integer i = _myIndexes[IOR]; + S = myShapes.Value(i); + cout << "$$$ GEOM_Client::Find i = " << i << endl; + return i; + } + cout << "$$$ GEOM_Client::Find END" << endl; return 0; } @@ -162,7 +182,9 @@ void GEOM_Client::Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& { myIORs.Append(IOR); myShapes.Append(S); - _myIndexes[IOR]=myIORs.Length(); + _myIndexes[IOR] = myIORs.Length(); + cout << "$$$ !!! GEOM_Client::Bind this = " << this << ", _myIndexes.size() = " << _myIndexes.size() << endl; + cout << "$$$ !!! GEOM_Client::Bind len = " << myIORs.Length() << ", IOR = " << IOR.ToCString() << endl; } //======================================================================= @@ -171,18 +193,22 @@ void GEOM_Client::Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& //======================================================================= void GEOM_Client::RemoveShapeFromBuffer( const TCollection_AsciiString& IOR) { + cout << "$$$ GEOM_Client::RemoveShapeFromBuffer BEGIN" << endl; + cout << "$$$ GEOM_Client::RemoveShapeFromBuffer myIORs.Length() = " << myIORs.Length() << ", _myIndexes.size() = " << _myIndexes.size() << endl; if( myIORs.IsEmpty() ) return; + cout << "$$$ GEOM_Client::RemoveShapeFromBuffer 1" << endl; TopoDS_Shape S; Standard_Integer anIndex = Find( IOR, S ); if( anIndex != 0 ) { + cout << "$$$ GEOM_Client::RemoveShapeFromBuffer anIndex = " << anIndex << endl; myIORs.Remove(anIndex); myShapes.Remove(anIndex); _myIndexes.erase(IOR); _mySubShapes.erase(IOR); } - return; + cout << "$$$ GEOM_Client::RemoveShapeFromBuffer END" << endl; } //======================================================================= @@ -243,7 +269,7 @@ TopoDS_Shape GEOM_Client::GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_p TopTools_IndexedMapOfShape anIndices; TopExp::MapShapes(aMainShape, anIndices); Standard_Integer ii = 1, nbSubSh = anIndices.Extent(); - for (; ii <= nbSubSh; ii++) + for (; ii <= nbSubSh; ii++) { _mySubShapes[mainIOR].push_back(anIndices.FindKey(ii)); } diff --git a/src/GEOMClient/GEOM_Client.hxx b/src/GEOMClient/GEOM_Client.hxx index 6b81488ee..796f6ec4d 100644 --- a/src/GEOMClient/GEOM_Client.hxx +++ b/src/GEOMClient/GEOM_Client.hxx @@ -19,19 +19,17 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - // GEOM GEOMClient : tool to transfer BREP files from GEOM server to GEOM client // File : GEOM_Client.hxx // Author : Yves FRICAUD // Module : GEOM -// $Header$ -// + #ifndef _GEOM_Client_HeaderFile #define _GEOM_Client_HeaderFile #include #include CORBA_SERVER_HEADER(GEOM_Gen) -# + #ifdef HAVE_FINITE #undef HAVE_FINITE // E.A. fix a warning about redefinition of HAVE_FINITE in re-inclusion of Standard_values.h #endif @@ -44,10 +42,10 @@ #ifndef _Standard_Integer_HeaderFile #include #endif + class TCollection_AsciiString; class TopoDS_Shape; - #ifndef _Standard_HeaderFile #include #endif @@ -85,55 +83,56 @@ class TopoDS_Shape; * and the SHAPE_READER macro defines also a new object */ #define SINGLE_CLIENT + //===================================================================== // GEOM_Client : class definition //===================================================================== class GEOMCLIENT_EXPORT GEOM_Client { -public: - - inline void* operator new(size_t,void* anAddress) + public: + + inline void* operator new(size_t,void* anAddress) { return anAddress; } - inline void* operator new(size_t size) - { - return Standard::Allocate(size); + inline void* operator new(size_t size) + { + return Standard::Allocate(size); } - inline void operator delete(void *anAddress) - { - if (anAddress) Standard::Free((Standard_Address&)anAddress); + inline void operator delete(void *anAddress) + { + if (anAddress) Standard::Free((Standard_Address&)anAddress); } // Methods PUBLIC - // - //Standard_EXPORT + // + //Standard_EXPORT GEOM_Client(); - //Standard_EXPORT + //Standard_EXPORT GEOM_Client(Engines::Container_ptr client); - //Standard_EXPORT + //Standard_EXPORT GEOM_Client(const GEOM_Client& client); - //Standard_EXPORT + //Standard_EXPORT Standard_Integer Find( const TCollection_AsciiString& IOR, TopoDS_Shape& S ) ; - //Standard_EXPORT + //Standard_EXPORT Standard_Integer Find( const TopoDS_Shape& S, TCollection_AsciiString& IOR ) ; - //Standard_EXPORT + //Standard_EXPORT void Bind( const TCollection_AsciiString& IOR, const TopoDS_Shape& S ) ; - //Standard_EXPORT + //Standard_EXPORT TopoDS_Shape GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Object_ptr aShape ); - //Standard_EXPORT + //Standard_EXPORT void RemoveShapeFromBuffer( const TCollection_AsciiString& IOR ) ; - //Standard_EXPORT + //Standard_EXPORT void ClearClientBuffer() ; - //Standard_EXPORT + //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; } + static GEOM_Client& get_client(); #else - static GEOM_Client get_client() { return GEOM_Client(); } + static GEOM_Client get_client(); #endif -private: + private: // Fields PRIVATE // TColStd_SequenceOfAsciiString myIORs ;