From: fkl Date: Wed, 11 Feb 2004 14:55:55 +0000 (+0000) Subject: Optimization : get direct TopoDS_Shape when GEOMClient and GEOM server are colocated X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=refs%2Fheads%2FFKL_1_4_0;p=modules%2Fgeom.git Optimization : get direct TopoDS_Shape when GEOMClient and GEOM server are colocated --- diff --git a/src/GEOM/GEOM_Shape_i.cc b/src/GEOM/GEOM_Shape_i.cc index bf7cdf062..60db998b4 100644 --- a/src/GEOM/GEOM_Shape_i.cc +++ b/src/GEOM/GEOM_Shape_i.cc @@ -246,3 +246,12 @@ GEOM::GEOM_Gen_ptr GEOM_Shape_i::Engine() { return _engine; } + +//======================================================================= +//function : getShape +//purpose : return the TopoDS_Shape when client and servant are colocated, be careful +//======================================================================= + +long GEOM_Shape_i::getShape() { + return((long)(&_geom)); +} diff --git a/src/GEOM/GEOM_Shape_i.hh b/src/GEOM/GEOM_Shape_i.hh index a976b31c4..bf114b937 100644 --- a/src/GEOM/GEOM_Shape_i.hh +++ b/src/GEOM/GEOM_Shape_i.hh @@ -112,6 +112,8 @@ public: GEOM::GEOM_Shape::TMPFile* GetShapeStream(); GEOM::GEOM_Gen_ptr Engine(); + + long getShape(); }; #endif diff --git a/src/GEOMClient/GEOM_Client.cxx b/src/GEOMClient/GEOM_Client.cxx index e3fb21cb3..b5ee8f58e 100644 --- a/src/GEOMClient/GEOM_Client.cxx +++ b/src/GEOMClient/GEOM_Client.cxx @@ -47,34 +47,58 @@ using namespace std; #include +#include + +#define HST_CLIENT_LEN 256 + //======================================================================= // function : Load() // purpose : //======================================================================= -static TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape ) +TopoDS_Shape GEOM_Client::Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape ) { - TopoDS_Shape S; - /* get sequence of bytes of resulting brep shape from GEOM server */ - GEOM::GEOM_Shape::TMPFile_var SeqFile = aShape->GetShapeStream(); - int sizebuf = SeqFile->length(); - char* buf; - buf = (char*) &SeqFile[0]; - istrstream streamBrep(buf,sizebuf); - BRep_Builder aBuilder; - BRepTools::Read(S, streamBrep, aBuilder); - return S; + char hst_client[HST_CLIENT_LEN]; + gethostname(hst_client, HST_CLIENT_LEN); + + Engines::Container_var ctn_server = geom->GetContainerRef(); + long pid_server = ctn_server->getPID(); + + if ( (pid_client==pid_server) && (strcmp(hst_client, ctn_server->getHostName())==0) ) { + TopoDS_Shape* S = (TopoDS_Shape*)(aShape->getShape()); + return(*S); + } else { + /* get sequence of bytes of resulting brep shape from GEOM server */ + TopoDS_Shape S; + GEOM::GEOM_Shape::TMPFile_var SeqFile = aShape->GetShapeStream(); + int sizebuf = SeqFile->length(); + char* buf; + buf = (char*) &SeqFile[0]; + istrstream streamBrep(buf,sizebuf); + BRep_Builder aBuilder; + BRepTools::Read(S, streamBrep, aBuilder); + return(S); + }; } //======================================================================= // function : Create() -// purpose : +// purpose : Create in client not in a container //======================================================================= GEOM_Client::GEOM_Client() { + pid_client = (-1); } +//======================================================================= +// function : Create() +// purpose : +//======================================================================= +GEOM_Client::GEOM_Client(Engines::Container_ptr client) +{ + pid_client = client->getPID(); +} //======================================================================= // function : Find() diff --git a/src/GEOMClient/GEOM_Client.hxx b/src/GEOMClient/GEOM_Client.hxx index 09d4351b7..0dbaddd63 100644 --- a/src/GEOMClient/GEOM_Client.hxx +++ b/src/GEOMClient/GEOM_Client.hxx @@ -75,18 +75,21 @@ public: // Methods PUBLIC // Standard_EXPORT GEOM_Client(); + Standard_EXPORT GEOM_Client(Engines::Container_ptr client); Standard_EXPORT Standard_Integer Find( const TCollection_AsciiString& ShapeIOR, TopoDS_Shape& S ) ; Standard_EXPORT void Bind( const TCollection_AsciiString& ShapeIOR, const TopoDS_Shape& S ) ; Standard_EXPORT TopoDS_Shape GetShape( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape ); Standard_EXPORT void RemoveShapeFromBuffer( const TCollection_AsciiString& shapeIOR ) ; Standard_EXPORT void ClearClientBuffer() ; Standard_EXPORT unsigned int BufferLength() ; + TopoDS_Shape Load( GEOM::GEOM_Gen_ptr geom, GEOM::GEOM_Shape_ptr aShape); private: // Fields PRIVATE // TColStd_SequenceOfAsciiString myIORs ; TopTools_SequenceOfShape myShapes ; + long pid_client; };