1 // Copyright (C) 2009-2012 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 static bool db = false;
26 // #include <Basics_Utils.hxx>
28 // #include <TDF_Tool.hxx>
29 // #include <TDF_Data.hxx>
30 // #include <TDF_Reference.hxx>
31 // #include <TDF_LabelSequence.hxx>
32 // #include <TDataStd_Integer.hxx>
33 // #include <TDataStd_ChildNodeIterator.hxx>
34 // #include <TFunction_Driver.hxx>
35 // #include <TFunction_DriverTable.hxx>
36 // #include <TDataStd_HArray1OfByte.hxx>
37 // #include <TDataStd_ByteArray.hxx>
38 // #include <TDataStd_UAttribute.hxx>
39 // #include <TDF_ChildIterator.hxx>
40 // #include <TDataStd_Comment.hxx>
41 // #include <Resource_DataMapIteratorOfDataMapOfAsciiStringAsciiString.hxx>
50 #include <TCollection_AsciiString.hxx>
51 #include <TopAbs_ShapeEnum.hxx>
53 #include <TopoDS_Vertex.hxx>
54 #include <TopoDS_Edge.hxx>
55 #include <TopoDS_Face.hxx>
58 #include <Geom_Curve.hxx>
61 #include <BRep_Builder.hxx>
62 #include <BRep_Tool.hxx>
63 #include <BRepTools.hxx>
65 #include "SALOME_NamingService.hxx"
66 #include "SALOME_LifeCycleCORBA.hxx"
67 #include "Utils_SINGLETON.hxx"
68 #include "Utils_ExceptHandlers.hxx"
69 #include "HexElements_grid.cxx"
72 #include "HEXABLOCK.hxx"
73 #include "utilities.h"
75 #include "HexDocument_impl.hxx"
78 // #include "SALOMEDS_Tool.hxx"
79 // #include "SALOMEDSImpl_TMPFile.hxx"
81 using namespace HEXABLOCK_ORB;
84 // Static variables definition
85 PortableServer::POA_var HEXABLOCK_Gen_i::_poa;
86 HEXABLOCK_Gen_i* HEXABLOCK_Gen_i::_HEXABLOCKGen = NULL;
87 SALOME_LifeCycleCORBA* HEXABLOCK_Gen_i::_lcc = NULL;
88 GEOM::GEOM_Gen_var HEXABLOCK_Gen_i::_geomGen = GEOM::GEOM_Gen::_nil();
89 // GEOM_Client* HEXABLOCK_Gen_i::_geomClient = NULL;
90 CORBA::ORB_var HEXABLOCK_Gen_i::_orb;
91 SALOME_NamingService* HEXABLOCK_Gen_i::_ns = NULL;
93 //=============================================================================
95 * standard constructor
97 //=============================================================================
99 HEXABLOCK_Gen_i::HEXABLOCK_Gen_i(CORBA::ORB_ptr orb,
100 PortableServer::POA_ptr poa,
101 PortableServer::ObjectId * contId,
102 const char *instanceName,
103 const char *interfaceName) :
104 Engines_Component_i(orb, poa, contId, instanceName, interfaceName)
106 MESSAGE("activate object");
108 _poa = PortableServer::POA::_duplicate(poa);
109 _orb = CORBA::ORB::_duplicate(orb);
110 _id = _poa->activate_object(_thisObj);
111 _engine_cpp = new HEXA_NS::Hex;
113 _HEXABLOCKGen = this;
114 MESSAGE("ALRRRRRIGHTTTTT");
117 //=============================================================================
119 * GetServant [ static ]
121 * Get servant of the CORBA object
123 //=============================================================================
125 PortableServer::ServantBase_var HEXABLOCK_Gen_i::GetServant( CORBA::Object_ptr theObject )
127 if( CORBA::is_nil( theObject ) || CORBA::is_nil( GetPOA() ) )
130 PortableServer::Servant aServant = GetPOA()->reference_to_servant( theObject );
134 INFOS( "GetServant - Unknown exception was caught!!!" );
141 //=============================================================================
143 //=============================================================================
144 HEXABLOCK_Gen_i::~HEXABLOCK_Gen_i()
151 //=============================================================================
155 //=============================================================================
156 Engines::TMPFile* HEXABLOCK_Gen_i::DumpPython(CORBA::Object_ptr theStudy,
157 CORBA::Boolean /*isPublished*/,
158 CORBA::Boolean /*isMultiFile*/,
159 CORBA::Boolean& isValidScript)
161 MESSAGE("DumpPython DumpPython DumpPython DumpPython");
162 std::cout << "DumpPython DumpPython DumpPython DumpPython" << std::endl;
163 isValidScript = true; // to avoid dump python operation failing
164 Engines::TMPFile_var aStreamFile = new Engines::TMPFile(0);
165 return aStreamFile._retn();
167 // SALOMEDS::Study_var aStudy = SALOMEDS::Study::_narrow(theStudy);
168 // if(CORBA::is_nil(aStudy))
169 // return new Engines::TMPFile(0);
171 // SALOMEDS::SObject_var aSO = aStudy->FindComponent(ComponentDataType());
172 // if(CORBA::is_nil(aSO))
173 // return new Engines::TMPFile(0);
175 // TObjectData objData;
176 // std::vector<TObjectData> objectDataVec;
178 // TVariablesList aVariableMap;
180 // SALOMEDS::ChildIterator_var Itr = aStudy->NewChildIterator(aSO);
181 // for(Itr->InitEx(true); Itr->More(); Itr->Next()) {
182 // SALOMEDS::SObject_var aValue = Itr->Value();
183 // CORBA::String_var IOR = aValue->GetIOR();
184 // if(strlen(IOR.in()) > 0) {
185 // CORBA::Object_var obj = _orb->string_to_object(IOR);
186 // GEOM::GEOM_Object_var GO = GEOM::GEOM_Object::_narrow(obj);
187 // if(!CORBA::is_nil(GO)) {
188 // CORBA::String_var aName = aValue->GetName();
189 // CORBA::String_var anEntry = GO->GetEntry();
190 // CORBA::String_var aStudyEntry = aValue->GetID();
191 // objData._name = aName.in();
192 // objData._entry = anEntry.in();
193 // objData._studyEntry = aStudyEntry.in();
194 // objectDataVec.push_back( objData );
196 // //Find attribute with list of used notebook variables
197 // SALOMEDS::GenericAttribute_var anAttr;
198 // SALOMEDS::AttributeString_var anAttrStr;
199 // if(aValue->FindAttribute(anAttr,"AttributeString")){
200 // anAttrStr = SALOMEDS::AttributeString::_narrow(anAttr);
201 // SALOMEDS::ListOfListOfStrings_var aSections = aStudy->ParseVariables(anAttrStr->Value());
202 // ObjectStates* aStates = new ObjectStates();
203 // for(int i = 0; i < aSections->length(); i++) {
205 // SALOMEDS::ListOfStrings aListOfVars = aSections[i];
206 // for(int j = 0; j < aListOfVars.length(); j++) {
207 // bool isVar = aStudy->IsVariable(aListOfVars[j].in());
208 // TVariable aVar = TVariable( (char*)aListOfVars[j].in(), isVar );
209 // aState.push_back(aVar);
211 // aStates->AddState(aState);
213 // aVariableMap.insert(std::make_pair(TCollection_AsciiString(anEntry),aStates));
219 // TCollection_AsciiString aScript;
220 // aScript += _impl->DumpPython(aStudy->StudyId(), objectDataVec, aVariableMap, isPublished, isValidScript);
224 // //Output the script that sets up the visual parameters.
225 // char* script = aStudy->GetDefaultScript(ComponentDataType(), "\t");
226 // if (script && strlen(script) > 0) {
227 // aScript += "\n\t### Store presentation parameters of displayed objects\n";
228 // aScript += script;
229 // CORBA::string_free(script);
233 // aScript += "\n\tpass\n";
235 // int aLen = aScript.Length();
236 // unsigned char* aBuffer = new unsigned char[aLen+1];
237 // strcpy((char*)aBuffer, aScript.ToCString());
239 // CORBA::Octet* anOctetBuf = (CORBA::Octet*)aBuffer;
240 // Engines::TMPFile_var aStreamFile = new Engines::TMPFile(aLen+1, aLen+1, anOctetBuf, 1);
242 // return aStreamFile._retn();
248 void HEXABLOCK_Gen_i::test()
250 MESSAGE("HEEEEEEEEEEEEEEYYYYYYYYYYY");
253 CORBA::Long HEXABLOCK_Gen_i::countDocument()
255 CORBA::Long nbDocument = _engine_cpp->countDocument();
256 // CORBA::Long nbDocument = 333;
260 Document_ptr HEXABLOCK_Gen_i::getDocument(CORBA::Long i)
262 HEXA_NS::Document *doc=_engine_cpp->getDocument(i);
263 if ( doc == NULL ) return Document::_nil();
264 Document_impl *servantCorba = new Document_impl( GetPOA(), doc );
265 return servantCorba->_this();
268 void HEXABLOCK_Gen_i::removeDocument(HEXABLOCK_ORB::Document_ptr docIn)
270 Document_impl* docServant = ::DownCast<Document_impl*>( docIn );
271 ASSERT( docServant );
273 HEXA_NS::Document* doc = docServant->GetImpl();
274 _engine_cpp->removeDocument( doc );
279 Document_ptr HEXABLOCK_Gen_i::addDocument(const char* name)
281 // HEXA_NS::Document *doc=_engine_cpp->addDocument (name);
282 // Document_impl *servantCorba=new Document_impl( GetPOA(), doc);
283 // return servantCorba->_this();
285 return createDocInStudy(name);
290 Document_ptr HEXABLOCK_Gen_i::loadDocument(const char* xmlFilename)
292 HEXA_NS::Document *doc=_engine_cpp->loadDocument(xmlFilename);
293 Document_impl *servantCorba=new Document_impl( GetPOA(), doc );
294 return servantCorba->_this();
297 GEOM_Client* HEXABLOCK_Gen_i::getGeomClient()
299 // create shape reader if necessary
300 if ( _geomClient == NULL )
301 _geomClient = new GEOM_Client(GetContainerRef());
302 ASSERT( _geomClient);
307 TopoDS_Shape HEXABLOCK_Gen_i::geomObjectToShape(GEOM::GEOM_Object_ptr theGeomObject)
310 if ( !theGeomObject->_is_nil() ){
311 _geomClient = getGeomClient();
313 if(CORBA::is_nil(_geomGen)) {
314 Engines::EngineComponent_ptr temp=GetLCC()->FindOrLoad_Component("FactoryServer","GEOM");
315 _geomGen=GEOM::GEOM_Gen::_narrow(temp);
317 if ( _geomClient != NULL && !_geomGen->_is_nil () )
318 S = _geomClient->GetShape( _geomGen, theGeomObject );
327 // HEXABLOCK_ORB::GEOM_Object_ptr HEXABLOCK_Gen_i::shapeToGeomObject (const TopoDS_Shape& theShape )
329 // HEXABLOCK_ORB::GEOM_Object_var aShapeObj;
330 // if ( !theShape.IsNull() ) {
331 // _geomClient = getGeomClient();//new GEOM_Client(GetContainerRef());
332 // TCollection_AsciiString IOR;
333 // bool found = _geomClient->Find(theShape, IOR);
335 // CORBA::Object_var obj = _orb->string_to_object( IOR.ToCString() );
336 // aShapeObj = HEXABLOCK_ORB::GEOM_Object::_narrow ( obj );
339 // return aShapeObj._retn();
344 // GEOM::GEOM_Object_ptr HEXABLOCK_Gen_i::_makeFace( const TopoDS_Shape& theShape )
346 // ASSERT ( theShape.ShapeType() == TopAbs_FACE );
348 // int theStudyID = 0;
349 // GEOM::GEOM_Object_var result;
351 // // PrimOp = self.GetI3DPrimOperations
352 // // GEOM_IShapesOperations
353 // return result._retn();
356 // GEOM::GEOM_Object_ptr HEXABLOCK_Gen_i::_makeEdge( const TopoDS_Shape& theShape )
358 // ASSERT ( theShape.ShapeType() == TopAbs_EDGE );
359 // int theStudyID = 0;
360 // GEOM::GEOM_Object_var result;
361 // GEOM::GEOM_Object_var p1;
362 // GEOM::GEOM_Object_var p2;
364 // if ( CORBA::is_nil(_geomGen) ) { //_geomGen->_is_nil()
365 // Engines::EngineComponent_ptr temp=GetLCC()->FindOrLoad_Component("FactoryServer","GEOM");
366 // _geomGen=GEOM::GEOM_Gen::_narrow(temp);
368 // GEOM::GEOM_IBasicOperations_var aBasicOp = _geomGen->GetIBasicOperations(theStudyID);
369 // GEOM::GEOM_IShapesOperations_var aShapesOp = _geomGen->GetIShapesOperations(theStudyID);
371 // TopoDS_Edge anEdge = TopoDS::Edge( theShape );
373 // Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge, f, l);
375 // gp_Pnt aCurveStart = aCurve->Value( f );
376 // gp_Pnt aCurveEnd = aCurve->Value( l );
378 // double x1, y1, z1;
379 // double x2, y2, z2;
381 // x1 = aCurveStart.X(); y1 = aCurveStart.Y(); z1 = aCurveStart.Z();
382 // x2 = aCurveEnd.X(); y2 = aCurveEnd.Y(); z2 = aCurveEnd.Z();
383 // p1= aBasicOp->MakePointXYZ(x1, y1, z1);
384 // p2= aBasicOp->MakePointXYZ(x2, y2, z2);
385 // result = aShapesOp->MakeEdge(p1, p2);
387 // return result._retn();
390 // GEOM::GEOM_Object_ptr HEXABLOCK_Gen_i::_makeVertex( const TopoDS_Shape& theShape )
392 // ASSERT ( theShape.ShapeType() == TopAbs_VERTEX );
394 // int theStudyID = 0;
395 // GEOM::GEOM_Object_var result;
397 // TopoDS_Vertex aPoint;
398 // aPoint = TopoDS::Vertex( theShape );
399 // gp_Pnt aPnt = BRep_Tool::Pnt( aPoint );
400 // double x = aPnt.X();
401 // double y = aPnt.Y();
402 // double z = aPnt.Z();
404 // GEOM::GEOM_IBasicOperations_var aBasicOp = _geomGen->GetIBasicOperations(theStudyID);
405 // result = aBasicOp->MakePointXYZ(x, y, z);
407 // return result._retn();
411 // GEOM::GEOM_Object_ptr HEXABLOCK_Gen_i::shapeToGeomObject (const TopoDS_Shape& theShape )
413 // std::cout << "XXXXXXXX shapeToGeomObject "<< std::endl;
414 // GEOM::GEOM_Object_var aShapeObj;
415 // if ( !theShape.IsNull() ) {
416 // switch ( theShape.ShapeType() ){
417 // case TopAbs_VERTEX: aShapeObj = _makeVertex( theShape ); break;
418 // // case TopAbs_FACE: aShapeObj = _makeFace( theShape ); break; //CS_TODO
419 // case TopAbs_EDGE: aShapeObj = _makeEdge( theShape ); break;
420 // default: throw (SALOME_Exception(LOCALIZED("shapeToGeomObject : shape type not supported")));
423 // return aShapeObj._retn();
429 GEOM::GEOM_Object_ptr HEXABLOCK_Gen_i::brepToGeomObject(const std::string& theBrep)
431 int theStudyID = 0; //CS_TODO
432 GEOM::GEOM_Object_var aShapeObj;
434 if ( CORBA::is_nil(_geomGen) ){
435 Engines::EngineComponent_ptr temp=GetLCC()->FindOrLoad_Component("FactoryServer","GEOM");
436 _geomGen=GEOM::GEOM_Gen::_narrow(temp);
438 GEOM::GEOM_IInsertOperations_var aInsOp = _geomGen->GetIInsertOperations(theStudyID);
440 // char *tmpname = strdup("HexaAssocXXXXXX"); // killed by Abu
441 char tmpname [32]; // Abu 11/07
442 sprintf (tmpname, "/tmp/tmpHexaAsso%dXXXXXX", getpid()); // Abu 11/07
443 // strcpy (tmpname, "HexaAssocXXXXXX"); // killed by Abu
445 int fd = mkstemp( tmpname );
448 ofstream tmpfile( tmpname );
451 aShapeObj = aInsOp->ImportFile( tmpname, "BREP" );
456 return aShapeObj._retn();
464 // GEOM::GEOM_Object_ptr HEXABLOCK_Gen_i::shapeToGeomObject (const TopoDS_Shape& theShape )
466 // GEOM::GEOM_Object_var aShapeObj;
467 // std::cout<<"shapeToGeomObject "<<std::endl;
468 // if ( !theShape.IsNull() ) {
469 // std::cout<<"shapeToGeomObject !theShape.IsNull()"<<std::endl;
470 // _geomClient = getGeomClient();//new GEOM_Client(GetContainerRef());
471 // TCollection_AsciiString IOR;
472 // bool found = _geomClient->Find(theShape, IOR);
473 // std::cout<<"shapeToGeomObject found"<<found<<std::endl;
475 // CORBA::Object_var obj = _orb->string_to_object( IOR.ToCString() );
476 // aShapeObj = GEOM::GEOM_Object::_narrow ( obj );
479 // return aShapeObj._retn();
483 StudyContext* HEXABLOCK_Gen_i::GetCurrentStudyContext()
485 if ( !CORBA::is_nil( myCurrentStudy ) &&
486 myStudyContextMap.find( GetCurrentStudyID() ) != myStudyContextMap.end() )
487 return myStudyContextMap[ myCurrentStudy->StudyId() ];
492 int HEXABLOCK_Gen_i::RegisterObject(CORBA::Object_ptr theObject)
494 StudyContext* myStudyContext = GetCurrentStudyContext();
495 if ( myStudyContext && !CORBA::is_nil( theObject )) {
496 CORBA::String_var iorString = GetORB()->object_to_string( theObject );
497 return myStudyContext->addObject( string( iorString.in() ) );
503 // SMESH::SMESH_Mesh_ptr SMESH_Gen_i::createMesh()
504 // throw ( SALOME::SALOME_Exception )
507 char* HEXABLOCK_Gen_i::ComponentDataType()
509 // if(MYDEBUG) MESSAGE( "HEXABLOCK_Gen_i::ComponentDataType" );
510 return CORBA::string_dup( "HEXABLOCK" );
515 // SMESH_Mesh* SMESH_Gen::CreateMesh(int theStudyId, bool theIsEmbeddedMode)
516 // throw(SALOME_Exception)
518 // Unexpect aCatch(SalomeException);
519 // MESSAGE("SMESH_Gen::CreateMesh");
521 // // Get studyContext, create it if it does'nt exist, with a SMESHDS_Document
522 // StudyContextStruct *aStudyContext = GetStudyContext(theStudyId);
524 // // create a new SMESH_mesh object
525 // SMESH_Mesh *aMesh = new SMESH_Mesh(_localId++,
528 // theIsEmbeddedMode,
529 // aStudyContext->myDocument);
530 // aStudyContext->mapMesh[_localId] = aMesh;
538 Document_ptr HEXABLOCK_Gen_i::createDoc (const char* name)
539 throw ( SALOME::SALOME_Exception )
541 Unexpect aCatch(SALOME_SalomeException);
542 // if(MYDEBUG) MESSAGE( "SMESH_Gen_i::createMesh" );
544 // Get or create the GEOM_Client instance
546 HEXA_NS::Document *d = _engine_cpp->addDocument (name);
547 Document_impl *docImpl = new Document_impl( GetPOA(), d );
549 // activate the CORBA servant of Mesh
550 Document_var docServant = Document::_narrow( docImpl->_this() );
551 /* int nextId = */ RegisterObject( docServant );
552 // if(MYDEBUG) MESSAGE( "Add mesh to map with id = "<< nextId);
553 return docServant._retn();
555 catch (SALOME_Exception& S_ex) {
556 // THROW_SALOME_CORBA_EXCEPTION( S_ex.what(), SALOME::BAD_PARAM );
558 return Document::_nil();
561 Document_ptr HEXABLOCK_Gen_i::createDocInStudy (const char* name)
562 throw ( SALOME::SALOME_Exception )
564 Unexpect aCatch(SALOME_SalomeException);
565 // if(MYDEBUG) MESSAGE( "SMESH_Gen_i::CreateMesh" );
567 Document_var doc = this->createDoc (name);
569 // publish mesh in the study
570 if ( CanPublishInStudy( doc ) ) {
571 SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
572 aStudyBuilder->NewCommand(); // There is a transaction
573 SALOMEDS::SObject_var aSO = PublishDoc( myCurrentStudy, doc.in() );
574 aStudyBuilder->CommitCommand();
575 // if ( !aSO->_is_nil() ) {
576 // // Update Python script
577 // TPythonDump() << aSO << " = " << this << ".CreateEmptyMesh()";
587 SALOME_LifeCycleCORBA* HEXABLOCK_Gen_i::GetLCC() {
588 if ( _lcc == NULL ) {
589 _lcc = new SALOME_LifeCycleCORBA( GetNS() );
594 SALOME_NamingService* HEXABLOCK_Gen_i::GetNS()
597 _ns = SINGLETON_<SALOME_NamingService>::Instance();
598 ASSERT(SINGLETON_<SALOME_NamingService>::IsAlreadyExisting());
599 _ns->init_orb( _orb );
606 int HEXABLOCK_Gen_i::GetCurrentStudyID()
608 return myCurrentStudy->_is_nil() || myCurrentStudy->_non_existent() ? -1 : myCurrentStudy->StudyId();
612 void HEXABLOCK_Gen_i::SetCurrentStudy( SALOMEDS::Study_ptr theStudy )
614 /*int curStudyId = */ GetCurrentStudyID();
615 myCurrentStudy = SALOMEDS::Study::_duplicate( theStudy );
616 // create study context, if it doesn't exist and set current study
617 int studyId = GetCurrentStudyID();
618 if ( myStudyContextMap.find( studyId ) == myStudyContextMap.end() ) {
619 myStudyContextMap[ studyId ] = new StudyContext;
622 // // myCurrentStudy may be nil
623 // if ( !CORBA::is_nil( myCurrentStudy ) ) {
624 // SALOMEDS::StudyBuilder_var aStudyBuilder = myCurrentStudy->NewBuilder();
625 // if( !myCurrentStudy->FindComponent( "GEOM" )->_is_nil() )
626 // aStudyBuilder->LoadWith( myCurrentStudy->FindComponent( "GEOM" ), GetGeomEngine() );
628 // // NPAL16168, issue 0020210
629 // // Let meshes update their data depending on GEOM groups that could change
630 // if ( curStudyId != studyId )
632 // //SALOMEDS::SComponent_var me = PublishComponent( myCurrentStudy );
633 // SALOMEDS::SComponent_var me = SALOMEDS::SComponent::_narrow
634 // ( myCurrentStudy->FindComponent( ComponentDataType() ) );
635 // if ( !me->_is_nil() ) {
636 // SALOMEDS::ChildIterator_var anIter = myCurrentStudy->NewChildIterator( me );
637 // for ( ; anIter->More(); anIter->Next() ) {
638 // SALOMEDS::SObject_var so = anIter->Value();
639 // CORBA::Object_var ior = SObjectToObject( so );
640 // if ( SMESH_Mesh_i* mesh = SMESH::DownCast<SMESH_Mesh_i*>( ior ))
641 // mesh->CheckGeomGroupModif();
653 TopoDS_Shape string2shape( const string& brep )
657 // istringstream streamBrep(brep.c_str());
658 istringstream streamBrep(brep);
659 // char* chaine = new char[brep.size()];
660 // strcpy(chaine, brep.c_str());
661 // istringstream streamBrep( chaine );
663 BRep_Builder aBuilder;
664 BRepTools::Read(shape, streamBrep, aBuilder);
665 // BRepTools::Read(shape, brep, aBuilder);
669 // TopoDS_Shape STRING_TO_SHAPE( char* buf, int sizebuf )
671 // TopoDS_Shape shape;
672 // std::istrstream streamBrep(buf,sizebuf);
673 // BRep_Builder aBuilder;
674 // BRepTools::Read(shape, streamBrep, aBuilder);
678 // ===================================================== shape2string
679 string shape2string( const TopoDS_Shape& aShape )
681 ostringstream streamShape;
683 BRepTools::Write(aShape, streamShape);
684 // BRepTools::Write(aShape, strShape);
686 return streamShape.str();
688 // ===================================================== HEXABLOCKEngine_factory
691 PortableServer::ObjectId * HEXABLOCKEngine_factory(
693 PortableServer::POA_ptr poa,
694 PortableServer::ObjectId * contId,
695 const char *instanceName,
696 const char *interfaceName)
698 MESSAGE("PortableServer::ObjectId * HEXABLOCKEngine_factory()");
699 SCRUTE(interfaceName);
700 HEXABLOCK_Gen_i *myHEXABLOCK
701 = new HEXABLOCK_Gen_i(orb, poa, contId, instanceName, interfaceName);
702 return myHEXABLOCK->getId() ;
705 // ------------------------------------------------------------------------
707 // Heritage de SALOMEDSImpl_Driver
709 // ------------------------------------------------------------------------
711 /* ***********************************************************************
712 // ========================================================= GetIOR
713 std::string HEXABLOCK_Gen_i::GetIOR()
717 *********************************************************************** */
718 // =========================================================== SaveASCII
719 SALOMEDS::TMPFile* HEXABLOCK_Gen_i::SaveASCII (
720 const SALOMEDS::SComponent_ptr compo,
724 SALOMEDS::TMPFile* fic = Save (compo, theURL, isMultiFile);
727 // =========================================================== LoadASCII
728 CORBA::Boolean HEXABLOCK_Gen_i::LoadASCII(SALOMEDS::SComponent_ptr compo,
729 const SALOMEDS::TMPFile& theStream,
733 bool rep = Load (compo, theStream, theURL, isMultiFile);
736 // =========================================================== Close
737 void HEXABLOCK_Gen_i::Close(SALOMEDS::SComponent_ptr theComponent)
739 if (db) cout << " +++++++ Je suis passe par HEXABLOCK_Gen_i::"
742 // =================================================== IORToLocalPersistentID
743 char* HEXABLOCK_Gen_i::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
744 const char* IORString,
745 CORBA::Boolean isMultiFile,
746 CORBA::Boolean isASCII)
748 if (db) cout << " +++++++ Je suis passe par HEXABLOCK_Gen_i::"
749 << "IORToLocalPersistentID" << endl;
750 static char empty [8] = "";
753 // =================================================== LocalPersistentIDToIOR
754 char* HEXABLOCK_Gen_i::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
755 const char* aLocalPersistentID,
756 CORBA::Boolean isMultiFile,
757 CORBA::Boolean isASCII)
759 if (db) cout << " +++++++ Je suis passe par HEXABLOCK_Gen_i::"
760 << "LocalPersistentIDToIOR" << endl;
761 static char empty [8] = "";
765 // =========================================================== CanCopy
766 CORBA::Boolean HEXABLOCK_Gen_i::CanCopy (SALOMEDS::SObject_ptr theObject)
768 if (db) cout << " +++++++ Je suis passe par HEXABLOCK_Gen_i::"
769 << "CanCopy" << endl;
772 // =========================================================== CopyFrom
773 SALOMEDS::TMPFile* HEXABLOCK_Gen_i::CopyFrom(SALOMEDS::SObject_ptr theObject,
774 CORBA::Long& theObjectID)
776 if (db) cout << " +++++++ Je suis passe par HEXABLOCK_Gen_i::"
777 << "CopyFrom" << endl;
780 // =========================================================== CanPaste
781 CORBA::Boolean HEXABLOCK_Gen_i:: CanPaste (const char* theComponentName,
782 CORBA::Long theObjectID)
784 if (db) cout << " +++++++ Je suis passe par HEXABLOCK_Gen_i::"
785 << "CanPaste" << endl;
788 // =========================================================== PasteInto
789 SALOMEDS::SObject_ptr HEXABLOCK_Gen_i::PasteInto(const SALOMEDS::TMPFile& fic,
790 CORBA::Long theObjectID,
791 SALOMEDS::SObject_ptr theObject)
793 if (db) cout << " +++++++ Je suis passe par HEXABLOCK_Gen_i::"
794 << "PasteInto" << endl;
797 // ======================================================== CanPublishInStudy
798 // bool HEXABLOCK_Gen_i::CanPublishInStudy(CORBA::Object_ptr theIOR)
802 // =========================================================== CanPaste
803 SALOMEDS::SObject_ptr HEXABLOCK_Gen_i::PublishInStudy (SALOMEDS::Study_ptr stud,
804 SALOMEDS::SObject_ptr theSObject,
805 CORBA::Object_ptr theObject,
807 throw (SALOME::SALOME_Exception)
809 if (db) cout << " +++++++ Je suis passe par HEXABLOCK_Gen_i::"
810 << "PublishInStudy" << endl;
813 // =========================================================== Save
814 SALOMEDS::TMPFile* HEXABLOCK_Gen_i::Save(
815 const SALOMEDS::SComponent_ptr compo,
819 if (db) cout << " +++++++ Je suis passe par HEXABLOCK_Gen_i::"
823 // =========================================================== Load
824 CORBA::Boolean HEXABLOCK_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
825 const SALOMEDS::TMPFile& theStream,
829 if (db) cout << " +++++++ Je suis passe par HEXABLOCK_Gen_i::"