#include <TopTools_ListOfShape.hxx>
+#include <unistd.h>
+
+#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()
// 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;
};