Salome HOME
DCQ : Co-localisation V1_4_1
authordcq <dcq@opencascade.com>
Fri, 26 Mar 2004 15:09:49 +0000 (15:09 +0000)
committerdcq <dcq@opencascade.com>
Fri, 26 Mar 2004 15:09:49 +0000 (15:09 +0000)
idl/GEOM_Shape.idl
src/GEOM/GEOM_Shape_i.cc
src/GEOM/GEOM_Shape_i.hh
src/GEOMClient/GEOM_Client.cxx
src/GEOMClient/GEOM_Client.hxx

index b9091a0ed936185a414de3db717efdb636012add..a75c3486c38384b73e71cbc3776b97ed2444f1cf 100644 (file)
@@ -78,6 +78,8 @@ module GEOM
     // the generator engine
     GEOM_Gen Engine();
    
+    // Get the TopoDS_Shape, for colocated case only
+    long getShape();
   };
 };
 #endif
index bf7cdf062ded3df548390effb5ce62b5784b8049..60db998b4c1dc28f64c317740f5e7768afbd06b3 100644 (file)
@@ -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));
+}
index a976b31c415c3d72c5f9ac34c04d67b0af56a4a3..bf114b937a2a60e8a3deb23e5132fd592e3b9876 100644 (file)
@@ -112,6 +112,8 @@ public:
   GEOM::GEOM_Shape::TMPFile* GetShapeStream();
 
   GEOM::GEOM_Gen_ptr Engine();
+
+  long getShape();
 };
   
 #endif
index e3fb21cb3e40323358987072ae22f8660b65b426..b5ee8f58e84bbedff4fc74dbba4e00caf7c6ee89 100644 (file)
@@ -47,34 +47,58 @@ using namespace std;
 #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()
index 09d4351b7d4782709bef7eae208dfd7103009bd4..0dbaddd6362459e75748c6082bdbb0b4d9679417 100644 (file)
@@ -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;
 };