1 #ifndef _HEXABLOCK_HXX_
2 #define _HEXABLOCK_HXX_
4 #include <SALOMEconfig.h>
5 #include CORBA_SERVER_HEADER(HEXABLOCK_Gen)
6 #include "SALOME_Component_i.hxx"
10 // #include <strstream.h>
11 // #include <iostream.h>
14 #include <TopoDS_Shape.hxx>
15 #include "GEOM_Client.hxx"
17 #include "hexa_base.hxx"
20 using namespace HEXABLOCK_ORB;
22 class SALOME_LifeCycleCORBA;
23 class SALOME_NamingService;
27 public POA_HEXABLOCK_ORB::HEXABLOCK_Gen,
28 public Engines_Component_i
32 HEXABLOCK( CORBA::ORB_ptr orb,
33 PortableServer::POA_ptr poa,
34 PortableServer::ObjectId * contId,
35 const char *instanceName,
36 const char *interfaceName);
37 // Get object of the CORBA reference
38 static PortableServer::POA_var GetPOA() { return _poa;}
39 static PortableServer::ServantBase_var GetServant( CORBA::Object_ptr theObject );
44 ::CORBA::Long countDocument();
45 Document_ptr getDocument(::CORBA::Long i);
46 void removeDocument(Document_ptr d); //CS_TODO
47 Document_ptr addDocument();
48 Document_ptr loadDocument(const char* xmlFilename);
50 GEOM_Client* getGeomClient();
51 TopoDS_Shape geomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject);
52 GEOM::GEOM_Object_ptr shapeToGeomObject(const TopoDS_Shape& theShape );
53 static SALOME_LifeCycleCORBA* GetLCC();
54 static SALOME_NamingService* GetNS();
55 static HEXABLOCK* GetHEXABLOCKGen() { return _HEXABLOCKGen;}
58 HEXA_NS::Hex* _engine_cpp;
59 GEOM_Client* _geomClient;
62 static PortableServer::POA_var _poa;// POA reference
63 static GEOM::GEOM_Gen_var _geomGen;
64 static SALOME_LifeCycleCORBA* _lcc;
65 static CORBA::ORB_var _orb;
66 static SALOME_NamingService* _ns;
67 static HEXABLOCK* _HEXABLOCKGen;
69 GEOM::GEOM_Object_ptr _makeVertex( const TopoDS_Shape& theShape );
74 PortableServer::ObjectId * HEXABLOCKEngine_factory(
76 PortableServer::POA_ptr poa,
77 PortableServer::ObjectId * contId,
78 const char *instanceName,
79 const char *interfaceName
85 DownCast(CORBA::Object_ptr theArg)
87 return dynamic_cast<T>(HEXABLOCK::GetServant(theArg).in());
94 TopoDS_Shape string2shape( const string& brep );
97 string shape2string( const TopoDS_Shape& aShape );
105 // 1) Séquence de code convertissant une chaîne au format BREP vers un TopoDS_Shape
107 // TopoDS_Shape STRING_TO_SHAPE( char* buf, int sizebuf )
109 // TopoDS_Shape shape;
110 // std::istrstream streamBrep(buf,sizebuf);
111 // BRep_Builder aBuilder;
112 // BRepTools::Read(shape, streamBrep, aBuilder);
116 // 2) Séquence de code convertissant un TopoDS_Shape en une chaîne au format BREP
118 // char* SHAPE_TO_STRING( TopoDS_Shape aShape, int& sizebuf )
120 // ostrstream streamShape;
121 // BRepTools::Write(aShape, streamShape);
122 // sizebuf = streamShape.pcount();
123 // char* buf = new char [sizebuf];
124 // char* valueOfStream = streamShape.str();
125 // memcpy(buf, valueOfStream, size);
129 // 3) Séquence de code accédant aux coordonnées d'un TopoDS_Shape qui est un Vertex
131 // bool SHAPE_TO_COORD(TopoDS_Shape aShape, double& x, double& y, double& z)
133 // if ( aShape.ShapeType() == TopAbs_VERTEX ) {
134 // TopoDS_Vertex aPoint;
135 // aPoint = TopoDS::Vertex( aShape );
136 // gp_Pnt aPnt = BRep_Tool::Pnt( aPoint );
146 // 4) Séquence de code créant un TopoDS_Shape à partir de coordonnées
148 // TopoDS_Shape COORD_TO_SHAPE(double x, double y, double z)
150 // gp_Pnt aPnt(x, y, z);
151 // BRepBuilderAPI_MakeVertex mkVertex (aPnt);
152 // TopoDS_Vertex aVertex = TopoDS::Vertex(mkVertex.Shape());