1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISU_Gen_i.cc
24 // Author : Alexey PETROV
27 #include "VISU_Gen_i.hh"
28 #include "VISU_Result_i.hh"
29 #include "VISU_PrsObject_i.hh"
30 #include "VISU_ViewManager_i.hh"
32 #include "VISU_Prs3d_i.hh"
33 #include "VISU_Mesh_i.hh"
34 #include "VISU_Table_i.hh"
35 #include "VISU_PointMap3d_i.hh"
36 #include "VISU_TimeAnimation.h"
38 #include "VISU_ColoredPrs3dFactory.hh"
39 #include "VISU_ColoredPrs3dCache_i.hh"
40 #include "VISU_ColoredPrs3dHolder_i.hh"
42 #include <VISU_Vtk2MedConvertor.hxx>
44 #include "VISU_Actor.h"
46 #include "HDFascii.hxx"
47 #include "SALOMEDS_Tool.hxx"
49 #include "SALOMEDSClient_AttributeName.hxx"
50 #include "SALOMEDSClient_AttributePixMap.hxx"
52 #include "SUIT_Session.h"
53 #include "SalomeApp_Study.h"
54 #include "SalomeApp_Application.h"
55 #include "LightApp_SelectionMgr.h"
56 #include "SVTK_ViewModel.h"
57 #include "SVTK_ViewWindow.h"
58 #include "SALOME_Event.h"
59 #include "SALOME_ListIO.hxx"
60 #include "SALOME_ListIteratorOfListIO.hxx"
62 #include "utilities.h"
65 #include <omnithread.h>
66 #include CORBA_SERVER_HEADER(SALOME_Session)
67 #include CORBA_SERVER_HEADER(SALOME_ModuleCatalog)
68 #include CORBA_SERVER_HEADER(MED_Gen)
75 #include <vtkRenderer.h>
76 #include <vtkActorCollection.h>
79 #include <TCollection_AsciiString.hxx>
80 #include <TColStd_SequenceOfAsciiString.hxx>
82 #include "Utils_ExceptHandlers.hxx"
83 UNEXPECT_CATCH(SalomeException, SALOME::SALOME_Exception);
88 #include <boost/filesystem/path.hpp>
89 #include <boost/filesystem/operations.hpp>
90 namespace filesystem = boost::filesystem;
94 static int MYDEBUG = 0;
96 static int MYDEBUG = 0;
102 VISU_I_EXPORT VISU::VISU_Gen_ptr
103 GetImpl(CORBA::ORB_ptr theORB,
104 PortableServer::POA_ptr thePOA,
105 SALOME_NamingService* theNamingService,
108 if(MYDEBUG) MESSAGE("extern 'C' GetImpl");
109 VISU::VISU_Gen_i *aVISU_Gen = new VISU::VISU_Gen_i(theORB,thePOA,theNamingService,theMutex);
110 //return VISU::VISU_Gen::_duplicate(aVISU_Gen->_this());
111 return aVISU_Gen->_this();
116 //----------------------------------------------------------------------------
117 static std::string VISU_TMP_DIR;
119 static CORBA::Boolean myIsMultiFile;
120 const CORBA::Boolean IsMultiFile()
122 return myIsMultiFile;
125 //----------------------------------------------------------------------------
127 ClientFindOrCreateVisuComponent (_PTR(Study) theStudyDocument)
129 _PTR(SComponent) aSComponent = theStudyDocument->FindComponent("VISU");
131 _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
132 aStudyBuilder->NewCommand();
133 int aLocked = theStudyDocument->GetProperties()->IsLocked();
134 if (aLocked) theStudyDocument->GetProperties()->SetLocked(false);
135 aSComponent = aStudyBuilder->NewComponent("VISU");
136 _PTR(GenericAttribute) anAttr =
137 aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
138 _PTR(AttributeName) aName (anAttr);
140 CORBA::ORB_var anORB = Base_i::GetORB();
141 SALOME_NamingService *NamingService = new SALOME_NamingService( anORB );
142 CORBA::Object_var objVarN = NamingService->Resolve("/Kernel/ModulCatalog");
143 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue =
144 SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
145 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "VISU" );
146 if (!Comp->_is_nil()) {
147 aName->SetValue(Comp->componentusername());
150 anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributePixMap");
151 _PTR(AttributePixMap) aPixmap (anAttr);
152 aPixmap->SetPixMap( "ICON_OBJBROWSER_Visu" );
154 VISU_Gen_var aVisuGen = Base_i::GetVisuGenImpl()->_this();
155 aStudyBuilder->DefineComponentInstance(aSComponent, aVisuGen->GetID());
156 if (aLocked) theStudyDocument->GetProperties()->SetLocked(true);
157 aStudyBuilder->CommitCommand();
163 //----------------------------------------------------------------------------
164 SALOMEDS::SComponent_var
165 FindOrCreateVisuComponent(SALOMEDS::Study_ptr theStudyDocument)
167 SALOMEDS::SComponent_var aSComponent = theStudyDocument->FindComponent("VISU");
168 if (aSComponent->_is_nil()) {
169 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
170 aStudyBuilder->NewCommand();
171 int aLocked = theStudyDocument->GetProperties()->IsLocked();
172 if (aLocked) theStudyDocument->GetProperties()->SetLocked(false);
173 aSComponent = aStudyBuilder->NewComponent("VISU");
174 SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributeName");
175 SALOMEDS::AttributeName_var aName = SALOMEDS::AttributeName::_narrow(anAttr);
177 //NRI aName->SetValue("Visu");
178 CORBA::ORB_var anORB = Base_i::GetORB();
179 SALOME_NamingService *NamingService = new SALOME_NamingService( anORB );
180 CORBA::Object_var objVarN = NamingService->Resolve("/Kernel/ModulCatalog");
181 SALOME_ModuleCatalog::ModuleCatalog_var Catalogue = SALOME_ModuleCatalog::ModuleCatalog::_narrow(objVarN);
182 SALOME_ModuleCatalog::Acomponent_var Comp = Catalogue->GetComponent( "VISU" );
183 if ( !Comp->_is_nil() ) {
184 aName->SetValue( Comp->componentusername() );
187 anAttr = aStudyBuilder->FindOrCreateAttribute(aSComponent, "AttributePixMap");
188 SALOMEDS::AttributePixMap_var aPixmap = SALOMEDS::AttributePixMap::_narrow(anAttr);
189 aPixmap->SetPixMap( "ICON_OBJBROWSER_Visu" );
191 VISU_Gen_var aVisuGen = Base_i::GetVisuGenImpl()->_this();
192 aStudyBuilder->DefineComponentInstance(aSComponent,aVisuGen);
193 if (aLocked) theStudyDocument->GetProperties()->SetLocked(true);
194 aStudyBuilder->CommitCommand();
200 //----------------------------------------------------------------------------
204 Storable::RegistryStorableEngine(Result_i::myComment.c_str(),&(Result_i::StorableEngine));
206 Storable::RegistryStorableEngine(Mesh_i::myComment.c_str(),&(Mesh_i::StorableEngine));
208 Storable::RegistryStorableEngine(ScalarMap_i::myComment.c_str(),&(StorableEngine<ScalarMap_i>));
209 Storable::RegistryStorableEngine(GaussPoints_i::myComment.c_str(),&(StorableEngine<GaussPoints_i>));
210 Storable::RegistryStorableEngine(DeformedShape_i::myComment.c_str(),&(StorableEngine<DeformedShape_i>));
211 Storable::RegistryStorableEngine(CutPlanes_i::myComment.c_str(),&(StorableEngine<CutPlanes_i>));
212 Storable::RegistryStorableEngine(CutLines_i::myComment.c_str(),&(StorableEngine<CutLines_i>));
213 Storable::RegistryStorableEngine(IsoSurfaces_i::myComment.c_str(),&(StorableEngine<IsoSurfaces_i>));
214 Storable::RegistryStorableEngine(StreamLines_i::myComment.c_str(),&(StorableEngine<StreamLines_i>));
215 Storable::RegistryStorableEngine(Plot3D_i::myComment.c_str(),&(StorableEngine<Plot3D_i>));
216 Storable::RegistryStorableEngine(Vectors_i::myComment.c_str(),&(StorableEngine<Vectors_i>));
217 Storable::RegistryStorableEngine(DeformedShapeAndScalarMap_i::myComment.c_str(),&(StorableEngine<DeformedShapeAndScalarMap_i>));
219 Storable::RegistryStorableEngine(ColoredPrs3dHolder_i::myComment.c_str(),&(ColoredPrs3dHolder_i::StorableEngine));
220 Storable::RegistryStorableEngine(ColoredPrs3dCache_i::myComment.c_str(),&(ColoredPrs3dCache_i::StorableEngine));
222 Storable::RegistryStorableEngine(PointMap3d_i::myComment.c_str(),&(PointMap3d_i::StorableEngine));
223 Storable::RegistryStorableEngine(Table_i::myComment.c_str(),&(Table_i::StorableEngine));
224 Storable::RegistryStorableEngine(Curve_i::myComment.c_str(),&(Curve_i::StorableEngine));
225 Storable::RegistryStorableEngine(Container_i::myComment.c_str(),&(Container_i::StorableEngine));
229 //----------------------------------------------------------------------------
230 SALOMEDS::ListOfFileNames*
231 GetListOfFileNames(const Result_i::TFileNames& theFileNames)
233 SALOMEDS::ListOfFileNames_var aListOfFileNames = new SALOMEDS::ListOfFileNames;
234 if(!theFileNames.empty()){
235 aListOfFileNames->length(theFileNames.size());
236 for(int aCounter = theFileNames.size(); aCounter > 0; aCounter--)
237 aListOfFileNames[aCounter-1] = theFileNames[aCounter-1].c_str();
239 return aListOfFileNames._retn();
243 //----------------------------------------------------------------------------
245 ::VISU_Gen_i(CORBA::ORB_ptr theORB, PortableServer::POA_ptr thePOA,
246 SALOME_NamingService* theNamingService, QMutex* theMutex) :
247 Engines_Component_i()
249 if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : "<<theMutex);
250 Base_i::myMutex = theMutex; //apo
251 Base_i::myOrb = CORBA::ORB::_duplicate(theORB);
252 Base_i::myPoa = PortableServer::POA::_duplicate(thePOA);
253 Base_i::myNamingService = theNamingService;
254 static SALOME_LifeCycleCORBA aEnginesLifeCycle(theNamingService);
255 Base_i::myEnginesLifeCycle = &aEnginesLifeCycle;
256 Base_i::myVisuGenImpl = this;
259 CORBA::Object_var anObj = myNamingService->Resolve("/myStudyManager");
260 SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(anObj);
261 SALOMEDS::ListOfOpenStudies_var aListOfOpenStudies = aStudyManager->GetOpenStudies();
262 if(aListOfOpenStudies->length() > 0) {
263 CORBA::String_var aStudyName = aListOfOpenStudies[0];
264 //aFileInfo.setFile(aStudyName.in());
265 myStudyDocument = aStudyManager->GetStudyByName(aStudyName/*aFileInfo.baseName()*/);
266 myClippingPlaneMgr.SetStudy(GetStudy(myStudyDocument));
268 if(MYDEBUG) MESSAGE("VISU_Gen_i::VISU_Gen_i : there is no opened study in StudyManager !!!");
272 //----------------------------------------------------------------------------
275 ::CreatePrs3d(VISUType theType,
276 SALOMEDS::Study_ptr theStudy)
278 if(ColoredPrs3d_i* aPrs3d = CreatePrs3d_i(theType, theStudy, ColoredPrs3d_i::EPublishIndependently))
279 return aPrs3d->_this();
280 return Prs3d::_nil();
284 //----------------------------------------------------------------------------
288 if(MYDEBUG) MESSAGE("VISU_Gen_i::~VISU_Gen_i");
292 //----------------------------------------------------------------------------
294 CorrectSObjectType(SALOMEDS::SObject_ptr theSObject,
295 SALOMEDS::StudyBuilder_ptr theBuilder)
297 SALOMEDS::GenericAttribute_var anAttr;
298 bool isAttrStringFound = false;
300 if( theSObject->FindAttribute(anAttr, "AttributeComment") ) {
301 //SRN: Replace an AttributeComment with AttributeString
302 SALOMEDS::AttributeComment_var aComment = SALOMEDS::AttributeComment::_narrow(anAttr);
303 string aValue = aComment->Value();
304 theBuilder->RemoveAttribute(theSObject, "AttributeComment");
305 anAttr = theBuilder->FindOrCreateAttribute(theSObject, "AttributeString");
306 SALOMEDS::AttributeString_var aStringAttr = SALOMEDS::AttributeString::_narrow(anAttr);
307 aStringAttr->SetValue(aValue.c_str());
308 isAttrStringFound = true;
311 if ( isAttrStringFound || theSObject->FindAttribute(anAttr, "AttributeString") ) {
312 SALOMEDS::AttributeString_var aAttComment = SALOMEDS::AttributeString::_narrow(anAttr);
314 CORBA::String_var aValue = aAttComment->Value();
315 std::string aString = Storable::CorrectPersistentString(aValue.in());
316 aAttComment->SetValue( aString.c_str() );
322 //----------------------------------------------------------------------------
325 ::Load(SALOMEDS::SComponent_ptr theComponent,
326 const SALOMEDS::TMPFile & theStream,
328 CORBA::Boolean theIsMultiFile)
331 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
333 SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
334 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
336 for (anIter->InitEx(true); anIter->More(); anIter->Next()) {
337 SALOMEDS::SObject_var aSObject = anIter->Value();
338 CorrectSObjectType(aSObject, aStudyBuilder);
342 VISU_TMP_DIR = theIsMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
343 SALOMEDS::ListOfFileNames_var aSeq =
344 SALOMEDS_Tool::PutStreamToFiles(theStream, VISU_TMP_DIR, theIsMultiFile);
345 myIsMultiFile = theIsMultiFile;
350 //----------------------------------------------------------------------------
353 ::LoadASCII(SALOMEDS::SComponent_ptr theComponent,
354 const SALOMEDS::TMPFile & theStream,
358 return Load(theComponent, theStream, theURL, theIsMultiFile);
362 //----------------------------------------------------------------------------
365 ::LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject,
366 const char* theLocalPersistentID,
367 CORBA::Boolean theIsMultiFile,
368 CORBA::Boolean theIsASCII)
370 CORBA::String_var aString("");
371 if(strcmp(theLocalPersistentID,"") != 0) {
372 Storable* aStorable = Storable::Create(theSObject,
373 theLocalPersistentID,
376 if(aStorable != NULL)
377 aString = aStorable->GetID();
379 return aString._retn();
383 //----------------------------------------------------------------------------
386 ::Save(SALOMEDS::SComponent_ptr theComponent,
390 if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - theURL = '"<<theURL<<"'");
392 Result_i::TFileNames aFileNames;
393 Result_i::TFileNames aFiles;
395 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
396 SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
397 for (; anIter->More(); anIter->Next()) {
398 SALOMEDS::SObject_var aSObject = anIter->Value();
399 CORBA::Object_var anObj = SObjectToObject(aSObject);
400 if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
401 aResult->Save(theComponent,
409 if(MYDEBUG) MESSAGE("VISU_Gen_i::Save - aFileNames.size() - "<<aFileNames.size());
411 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
412 if(aFileNames.empty())
413 return aStreamFile._retn();
415 SALOMEDS::ListOfFileNames_var aListOfFileNames = GetListOfFileNames(aFileNames);
416 SALOMEDS::ListOfFileNames_var aListOfFiles = GetListOfFileNames(aFiles);
419 aStreamFile = SALOMEDS_Tool::PutFilesToStream(theURL, aListOfFiles.in(), theIsMultiFile);
421 aStreamFile = SALOMEDS_Tool::PutFilesToStream(aListOfFiles.in(), aListOfFileNames.in());
423 return aStreamFile._retn();
427 //----------------------------------------------------------------------------
430 ::SaveASCII(SALOMEDS::SComponent_ptr theComponent,
434 std::string anURL = theIsMultiFile ? theURL : SALOMEDS_Tool::GetTmpDir();
435 if(MYDEBUG) MESSAGE("VISU_Gen_i::SaveASCII - "<<anURL);
437 Result_i::TFileNames aFileNames;
438 Result_i::TFileNames aFiles;
440 SALOMEDS::Study_var aStudy = theComponent->GetStudy();
441 SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(theComponent);
442 for (; anIter->More(); anIter->Next()) {
443 SALOMEDS::SObject_var aSObject = anIter->Value();
444 CORBA::Object_var anObj = SObjectToObject(aSObject);
445 if(Result_i* aResult = dynamic_cast<Result_i*>(GetServant(anObj).in())){
446 aResult->Save(theComponent,
454 if(MYDEBUG) MESSAGE("VISU_Gen_i::SaveASCII - aFileNames.size() - "<<aFileNames.size());
456 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile(0);
457 if(aFileNames.empty())
458 return aStreamFile._retn();
460 SALOMEDS::ListOfFileNames_var aListOfFileNames = GetListOfFileNames(aFileNames);
461 aStreamFile = SALOMEDS_Tool::PutFilesToStream(anURL, aListOfFileNames.in(), theIsMultiFile);
464 SALOMEDS_Tool::RemoveTemporaryFiles(anURL, aListOfFileNames, true);
466 return aStreamFile._retn();
470 //----------------------------------------------------------------------------
473 ::IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject,
474 const char* theIORString,
475 CORBA::Boolean theIsMultiFile,
476 CORBA::Boolean theIsASCII)
478 CORBA::String_var aString("");
479 if(strcmp(theIORString, "") != 0){
480 CORBA::Object_var anObj = GetORB()->string_to_object(theIORString);
481 if(Storable* aStorable = dynamic_cast<Storable*>(GetServant(anObj).in())){
482 aString = aStorable->ToString().c_str();
483 return aString._retn();
486 return aString._retn();
490 //----------------------------------------------------------------------------
495 return Base_i::GetID();
499 //----------------------------------------------------------------------------
502 ::SetCurrentStudy(SALOMEDS::Study_ptr theStudy)
504 class TEvent: public SALOME_Event {
505 std::string myStudyName;
507 TEvent(const std::string theStudyName):myStudyName(theStudyName)
509 virtual void Execute()
511 bool isActive = false;
512 SUIT_Session* aSession = SUIT_Session::session();
513 QList<SUIT_Application*> anApplications = aSession->applications();
514 QList<SUIT_Application*>::Iterator anIter = anApplications.begin();
515 SUIT_Application* aFirstApp = *anIter;
516 while (anIter != anApplications.end()) {
517 SUIT_Application* anApp = *anIter;
518 if (SUIT_Study* aSStudy = anApp->activeStudy()) {
519 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy)) {
520 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
521 if(MYDEBUG) MESSAGE("There is an application with active study : StudyId = "
522 << aCStudy->StudyId() << "; Name = '" << aCStudy->Name() << "'");
523 if (myStudyName == aCStudy->Name()) {
533 MESSAGE("!!! anApp->onLoadDoc(myStudyName) !!!");
534 // Has to be loaded in an empty or in a new application
535 SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aFirstApp);
536 anApp->onLoadDoc(myStudyName.c_str());
541 if (!CORBA::is_nil(theStudy))
543 CORBA::String_var aName = theStudy->Name();
544 std::string aStudyName (aName.in());
545 if(MYDEBUG) MESSAGE("StudyId = " << theStudy->StudyId() << "; Name = '" << aName.in() << "'");
546 myStudyDocument = SALOMEDS::Study::_duplicate(theStudy);
547 myClippingPlaneMgr.SetStudy(GetStudy(myStudyDocument));
549 ProcessVoidEvent(new TEvent(aStudyName));
551 // Load MED component if necessary
552 if(!myStudyDocument->FindComponent("MED")->_is_nil())
554 SALOME_LifeCycleCORBA aLCC(SalomeApp_Application::namingService());
555 Engines::Component_var aComponent = aLCC.FindOrLoad_Component("FactoryServer","MED");
556 SALOME_MED::MED_Gen_var aMedEngine = SALOME_MED::MED_Gen::_narrow(aComponent);
558 if(!CORBA::is_nil(aMedEngine))
560 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
562 aStudyBuilder->LoadWith( myStudyDocument->FindComponent( "MED" ), aMedEngine );
564 catch( const SALOME::SALOME_Exception& ) {
565 // Oops, something went wrong while loading
566 // See also SalomeApp_Study::openDataModel()
571 INFOS("CORBA::is_nil(theStudy)");
576 //----------------------------------------------------------------------------
581 return SALOMEDS::Study::_duplicate(myStudyDocument);
585 //----------------------------------------------------------------------------
591 ViewManager_i * aViewManager = new ViewManager_i(myStudyDocument);
592 return ViewManager::_duplicate(aViewManager->_this());
596 //----------------------------------------------------------------------------
597 SALOMEDS::SObject_ptr
599 ::ImportTables(const char* theFileName)
601 if(myStudyDocument->GetProperties()->IsLocked())
602 return SALOMEDS::SObject::_nil();
604 SALOMEDS::SObject_var aRes = VISU::ImportTables(theFileName,myStudyDocument);
606 SALOMEDS::Study_var aStudy = aRes->GetStudy();
607 SALOMEDS::ChildIterator_var anIter = aStudy->NewChildIterator(aRes);
608 for (; anIter->More(); anIter->Next()) {
609 SALOMEDS::SObject_var SO = anIter->Value();
610 CreateTable( SO->GetID() );
617 //----------------------------------------------------------------------------
620 ::ExportTableToFile(SALOMEDS::SObject_ptr theTable,
621 const char* theFileName)
623 return VISU::ExportTableToFile(theTable, theFileName);
627 //----------------------------------------------------------------------------
630 ::ImportFile(const char* theFileName)
632 if(myStudyDocument->GetProperties()->IsLocked())
633 return Result::_nil();
635 Result_i* aResult = Result_i::New(myStudyDocument,
637 Result_i::eImportFile,
643 if(aResult->Create(theFileName) != NULL)
644 return aResult->_this();
646 aResult->_remove_ref();
648 return VISU::Result::_nil();
652 //----------------------------------------------------------------------------
655 ::CreateResult(const char* theFileName)
657 if(myStudyDocument->GetProperties()->IsLocked())
658 return Result::_nil();
660 Result_i* aResult = Result_i::New(myStudyDocument,
662 Result_i::eImportFile,
668 if(aResult->Create(theFileName) != NULL)
669 return aResult->_this();
671 aResult->_remove_ref();
673 return VISU::Result::_nil();
677 //----------------------------------------------------------------------------
680 ::CopyAndImportFile(const char* theFileName)
682 if(myStudyDocument->GetProperties()->IsLocked())
683 return Result::_nil();
685 Result_i* aResult = Result_i::New(myStudyDocument,
686 Result_i::eRestoredFile,
687 Result_i::eCopyAndImportFile,
692 if(aResult->Create(theFileName) != NULL)
693 return aResult->_this();
695 aResult->_remove_ref();
697 return VISU::Result::_nil();
701 //----------------------------------------------------------------------------
702 Result_ptr VISU_Gen_i::ImportMed(SALOMEDS::SObject_ptr theMedSObject)
704 if (myStudyDocument->GetProperties()->IsLocked())
705 return Result::_nil();
707 Result_i* aResult = Result_i::New(myStudyDocument,
708 Result_i::eComponent,
709 Result_i::eImportMed,
714 if (aResult->Create(theMedSObject) != NULL)
716 return aResult->_this();
719 aResult->_remove_ref();
721 return VISU::Result::_nil();
725 //----------------------------------------------------------------------------
728 ::ImportMedField (SALOME_MED::FIELD_ptr theField)
730 if (myStudyDocument->GetProperties()->IsLocked())
731 return Result::_nil();
733 Result_i* aResult = Result_i::New(myStudyDocument,
734 Result_i::eComponent,
735 Result_i::eImportMedField,
741 if (aResult->Create(theField) != NULL)
742 return aResult->_this();
744 aResult->_remove_ref();
746 return VISU::Result::_nil();
751 ::RenameMeshInStudy(Result_ptr theResult,
752 const std::string& theMeshName,
753 int theEntity, // -1 for group indication
754 const std::string& theSubMeshName, // Family or Group name
755 const std::string& theNewName)
757 Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in());
761 SALOMEDS::Study_var aStudyDocument = aResult->GetStudyDocument();
762 if (aStudyDocument->GetProperties()->IsLocked())
767 VISU::VISUType aType;
769 if (theSubMeshName == "")
770 aType = VISU::TENTITY;
772 aType = VISU::TFAMILY;
774 aType = VISU::TGROUP;
776 VISU::Storable::TRestoringMap aRestoringMap;
777 aRestoringMap["myMeshName"] = theMeshName.c_str();
781 aRestoringMap["myComment"] = "ENTITY";
782 aRestoringMap["myId"] = QString::number(theEntity);
785 aRestoringMap["myComment"] = "FAMILY";
786 aRestoringMap["myEntityId"] = QString::number(theEntity);
787 aRestoringMap["myName"] = theSubMeshName.c_str();
790 aRestoringMap["myComment"] = "GROUP";
791 aRestoringMap["myName"] = theSubMeshName.c_str();
795 string anEntry = aResult->GetEntry(aRestoringMap);
799 SALOMEDS::SObject_ptr aSObject = aStudyDocument->FindObjectID(anEntry.c_str());
801 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudyDocument->NewBuilder();
802 aStudyBuilder->NewCommand(); // There is a transaction
804 SALOMEDS::GenericAttribute_var anAttr =
805 aStudyBuilder->FindOrCreateAttribute(aSObject,"AttributeName");
806 SALOMEDS::AttributeName_var aNameAttr = SALOMEDS::AttributeName::_narrow(anAttr);
807 aNameAttr->SetValue(theNewName.c_str());
809 aStudyBuilder->CommitCommand();
813 //----------------------------------------------------------------------------
816 ::RenameEntityInStudy(Result_ptr theResult,
817 const char* theMeshName,
818 VISU::Entity theEntity,
819 const char* theNewName)
821 RenameMeshInStudy(theResult, theMeshName, (int)theEntity, "", theNewName);
825 //----------------------------------------------------------------------------
828 ::RenameFamilyInStudy(Result_ptr theResult,
829 const char* theMeshName,
830 VISU::Entity theEntity,
831 const char* theFamilyName,
832 const char* theNewName)
834 RenameMeshInStudy(theResult, theMeshName, (int)theEntity, theFamilyName, theNewName);
838 //----------------------------------------------------------------------------
841 ::RenameGroupInStudy(Result_ptr theResult,
842 const char* theMeshName,
843 const char* theGroupName,
844 const char* theNewName)
846 RenameMeshInStudy(theResult, theMeshName, -1, theGroupName, theNewName);
850 //----------------------------------------------------------------------------
853 ::MeshOnEntity(Result_ptr theResult,
854 const char* theMeshName,
855 VISU::Entity theEntity)
857 Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in());
859 return VISU::Mesh::_nil();
861 SALOMEDS::Study_var aStudyDocument = aResult->GetStudyDocument();
862 if (aStudyDocument->GetProperties()->IsLocked())
863 return VISU::Mesh::_nil();
865 Mesh_i* aPresent = new Mesh_i();
866 if(aPresent->Create(aResult, theMeshName, theEntity))
867 return aPresent->_this();
869 aPresent->_remove_ref();
871 return VISU::Mesh::_nil();
875 //----------------------------------------------------------------------------
878 ::FamilyMeshOnEntity(Result_ptr theResult,
879 const char* theMeshName,
880 VISU::Entity theEntity,
881 const char* theFamilyName)
883 Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in());
885 return VISU::Mesh::_nil();
887 SALOMEDS::Study_var aStudyDocument = aResult->GetStudyDocument();
888 if (aStudyDocument->GetProperties()->IsLocked())
889 return VISU::Mesh::_nil();
891 Mesh_i* aPresent = new Mesh_i();
892 if(aPresent->Create(aResult, theMeshName, theEntity, theFamilyName))
893 return aPresent->_this();
895 aPresent->_remove_ref();
897 return VISU::Mesh::_nil();
901 //----------------------------------------------------------------------------
904 ::GroupMesh(Result_ptr theResult,
905 const char* theMeshName,
906 const char* theGroupName)
908 Result_i* aResult = dynamic_cast<Result_i*>(GetServant(theResult).in());
910 return VISU::Mesh::_nil();
912 SALOMEDS::Study_var aStudyDocument = aResult->GetStudyDocument();
913 if (aStudyDocument->GetProperties()->IsLocked())
914 return VISU::Mesh::_nil();
916 Mesh_i* aPresent = new Mesh_i();
917 if(aPresent->Create(aResult, theMeshName, theGroupName))
918 return aPresent->_this();
920 aPresent->_remove_ref();
922 return VISU::Mesh::_nil();
926 //----------------------------------------------------------------------------
929 ::ScalarMapOnField(Result_ptr theResult,
930 const char* theMeshName,
931 VISU::Entity theEntity,
932 const char* theFieldName,
933 CORBA::Long theIteration)
935 return Prs3dOnField<VISU::ScalarMap_i>(theResult,
939 theIteration)._retn();
943 //----------------------------------------------------------------------------
946 ::GaussPointsOnField(Result_ptr theResult,
947 const char* theMeshName,
948 VISU::Entity theEntity,
949 const char* theFieldName,
950 CORBA::Long theIteration)
952 return Prs3dOnField<VISU::GaussPoints_i>(theResult,
956 theIteration)._retn();
960 //---------------------------------------------------------------
963 ::DeformedShapeOnField(Result_ptr theResult,
964 const char* theMeshName,
965 VISU::Entity theEntity,
966 const char* theFieldName,
967 CORBA::Long theIteration)
969 return Prs3dOnField<VISU::DeformedShape_i>(theResult,
973 theIteration)._retn();
977 //---------------------------------------------------------------
978 DeformedShapeAndScalarMap_ptr
980 ::ScalarMapOnDeformedShapeOnField(Result_ptr theResult,
981 const char* theMeshName,
982 VISU::Entity theEntity,
983 const char* theFieldName,
984 CORBA::Long theIteration)
986 return DeformedShapeAndScalarMapOnField(theResult,
994 //---------------------------------------------------------------
995 DeformedShapeAndScalarMap_ptr
997 ::DeformedShapeAndScalarMapOnField(Result_ptr theResult,
998 const char* theMeshName,
999 VISU::Entity theEntity,
1000 const char* theFieldName,
1001 CORBA::Long theIteration)
1003 return Prs3dOnField<VISU::DeformedShapeAndScalarMap_i>(theResult,
1007 theIteration)._retn();
1011 //---------------------------------------------------------------
1014 ::VectorsOnField(Result_ptr theResult,
1015 const char* theMeshName,
1016 VISU::Entity theEntity,
1017 const char* theFieldName,
1018 CORBA::Long theIteration)
1020 return Prs3dOnField<VISU::Vectors_i>(theResult,
1024 theIteration)._retn();
1028 //---------------------------------------------------------------
1031 ::IsoSurfacesOnField(Result_ptr theResult,
1032 const char* theMeshName,
1033 VISU::Entity theEntity,
1034 const char* theFieldName,
1035 CORBA::Long theIteration)
1037 return Prs3dOnField<VISU::IsoSurfaces_i>(theResult,
1041 theIteration)._retn();
1045 //---------------------------------------------------------------
1048 ::StreamLinesOnField(Result_ptr theResult,
1049 const char* theMeshName,
1050 VISU::Entity theEntity,
1051 const char* theFieldName,
1052 CORBA::Long theIteration)
1054 return Prs3dOnField<VISU::StreamLines_i>(theResult,
1058 theIteration)._retn();
1062 //---------------------------------------------------------------
1065 ::Plot3DOnField(Result_ptr theResult,
1066 const char* theMeshName,
1067 VISU::Entity theEntity,
1068 const char* theFieldName,
1069 CORBA::Long theIteration)
1071 return Prs3dOnField<VISU::Plot3D_i>(theResult,
1075 theIteration)._retn();
1079 //---------------------------------------------------------------
1082 ::CutPlanesOnField(Result_ptr theResult,
1083 const char* theMeshName,
1084 VISU::Entity theEntity,
1085 const char* theFieldName,
1086 CORBA::Long theIteration)
1088 return Prs3dOnField<VISU::CutPlanes_i>(theResult,
1092 theIteration)._retn();
1096 //---------------------------------------------------------------
1099 ::CutLinesOnField(Result_ptr theResult,
1100 const char* theMeshName,
1101 VISU::Entity theEntity,
1102 const char* theFieldName,
1103 CORBA::Long theIteration)
1105 return Prs3dOnField<VISU::CutLines_i>(theResult,
1109 theIteration)._retn();
1112 //---------------------------------------------------------------
1113 struct CreateTableEvent: public SALOME_Event
1115 SALOMEDS::Study_var myStudyDocument;
1116 const char* myTableEntry;
1117 typedef Table_ptr TResult;
1120 CreateTableEvent(SALOMEDS::Study_var theStudy, const char* theTableEntry)
1122 myStudyDocument = theStudy;
1123 myTableEntry = theTableEntry;
1124 myResult = Table::_nil();
1131 SALOMEDS::SObject_var SO = myStudyDocument->FindObjectID(myTableEntry);
1132 SALOMEDS::GenericAttribute_var anAttr;
1133 if ( SO->FindAttribute(anAttr, "AttributeTableOfReal") ) {
1134 SALOMEDS::AttributeTableOfReal_var aTableOfReal = SALOMEDS::AttributeTableOfReal::_narrow(anAttr);
1135 if ( isSparseMatrix( aTableOfReal ) ) {
1136 PointMap3d_i* pPresent = new PointMap3d_i(myStudyDocument,myTableEntry);
1137 if(pPresent->Create() != NULL)
1138 myResult = pPresent->_this();
1140 pPresent->_remove_ref();
1141 myResult = VISU::Table::_nil();
1146 Table_i* pPresent = new Table_i(myStudyDocument,myTableEntry);
1147 if(pPresent->Create() != NULL)
1148 myResult = pPresent->_this();
1150 pPresent->_remove_ref();
1151 myResult = VISU::Table::_nil();
1157 isSparseMatrix(SALOMEDS::AttributeTableOfReal_var theTableOfReal)
1159 int aCols = theTableOfReal->GetNbColumns();
1160 int aRows = theTableOfReal->GetNbRows();
1162 for (int i=1; i<=aCols; i++) {
1163 for (int j=1; j<=aRows; j++) {
1164 if ( !(theTableOfReal->HasValue(j, i)) )
1172 //---------------------------------------------------------------
1175 ::CreateTable(const char* theTableEntry)
1177 TCollection_AsciiString tmp( (char*)theTableEntry ); // 11.06.2008 IPAL18844
1178 if( myStudyDocument->GetProperties()->IsLocked() ||
1180 return Table::_nil();
1182 return ProcessEvent(new CreateTableEvent(myStudyDocument, theTableEntry));
1185 //---------------------------------------------------------------
1188 ::CreateCurve(Table_ptr theTable,
1189 CORBA::Long theHRow,
1190 CORBA::Long theVRow)
1192 return CreateCurveWithZ( theTable, theHRow, theVRow, 0 );
1196 //---------------------------------------------------------------
1199 ::CreateCurveWithZ(Table_ptr theTable,
1200 CORBA::Long theHRow,
1201 CORBA::Long theVRow,
1202 CORBA::Long theZRow)
1204 if(myStudyDocument->GetProperties()->IsLocked())
1205 return Curve::_nil();
1207 PortableServer::POA_ptr aPOA = GetPOA();
1208 Table_i* pTable = dynamic_cast<Table_i*>(aPOA->reference_to_servant(theTable));
1209 Curve_i* pPresent = new Curve_i(myStudyDocument,pTable,theHRow,theVRow,theZRow);
1210 if(pPresent->Create() != NULL)
1211 return pPresent->_this();
1213 pPresent->_remove_ref();
1214 return VISU::Curve::_nil();
1220 //---------------------------------------------------------------
1225 if(myStudyDocument->GetProperties()->IsLocked())
1226 return Container::_nil();
1228 Container_i* pPresent = new Container_i(myStudyDocument);
1229 if(pPresent->Create() != NULL)
1230 return pPresent->_this();
1232 pPresent->_remove_ref();
1233 return VISU::Container::_nil();
1238 //---------------------------------------------------------------
1241 ::CreateAnimation(View3D_ptr theView3D)
1243 if(myStudyDocument->GetProperties()->IsLocked())
1244 return Animation::_nil();
1246 if(VISU_TimeAnimation_i* anAnim = new VISU_TimeAnimation_i(myStudyDocument,theView3D)){
1247 return anAnim->_this();
1249 return VISU::Animation::_nil();
1253 //---------------------------------------------------------------
1256 ::DeleteResult (Result_ptr theResult)
1258 theResult->RemoveFromStudy();
1262 //---------------------------------------------------------------
1265 ::DeletePrs3d(Prs3d_ptr thePrs3d)
1267 thePrs3d->RemoveFromStudy();
1271 //---------------------------------------------------------------
1274 ::Close(SALOMEDS::SComponent_ptr theComponent)
1278 //---------------------------------------------------------------
1281 ::ComponentDataType()
1283 return CORBA::string_dup("VISU");
1287 //---------------------------------------------------------------
1290 ::CanPublishInStudy(CORBA::Object_ptr theIOR)
1292 Result_var aResultObj = Result::_narrow(theIOR);
1293 return !(aResultObj->_is_nil());
1297 //---------------------------------------------------------------
1298 SALOMEDS::SObject_ptr
1300 ::PublishInStudy(SALOMEDS::Study_ptr theStudy,
1301 SALOMEDS::SObject_ptr theSObject,
1302 CORBA::Object_ptr theObject,
1303 const char* theName)
1304 throw (SALOME::SALOME_Exception)
1306 Unexpect aCatch(SalomeException);
1307 if(MYDEBUG) MESSAGE("VISU_Gen_i::PublishInStudy : "<<myMutex);
1309 SALOMEDS::SObject_var aResultSO;
1310 Result_i* aResultObj = dynamic_cast<Result_i*>(GetServant(theObject).in());
1312 return aResultSO._retn();
1313 const QFileInfo& aFileInfo = aResultObj->GetFileInfo();
1314 CORBA::String_var anEntry = aResultObj->Create((const char*)aFileInfo.absoluteFilePath().toLatin1())->GetID();
1315 aResultSO = theStudy->FindObjectID(anEntry);
1316 return aResultSO._retn();
1320 //---------------------------------------------------------------
1323 ::CanCopy(SALOMEDS::SObject_ptr theObject)
1325 CORBA::Object_var anObj = SObjectToObject(theObject);
1326 if (Storable* aStorable = dynamic_cast<Storable*>(GetServant(anObj).in()))
1327 return aStorable->CanCopy(theObject);
1333 //---------------------------------------------------------------
1336 ::CopyFrom(SALOMEDS::SObject_ptr theObject,
1337 CORBA::Long& theObjectID)
1340 SALOMEDS::TMPFile_var aStreamFile = new SALOMEDS::TMPFile;
1342 CORBA::Object_var anObj = SObjectToObject(theObject);
1343 if (CORBA::is_nil(anObj)) {
1344 aStreamFile->length(1);
1345 aStreamFile[0] = CORBA::string_dup("E")[0];
1346 } else if (Storable* aStorable = dynamic_cast<Storable*>(GetServant(anObj).in())) {
1347 std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();
1348 Storable::TFileNames aFileNames;
1349 bool anIsDone = aStorable->CopyFrom(theObject, theObjectID, aTmpDir, aFileNames);
1351 SALOMEDS::ListOfFileNames_var aListOfFileNames = new SALOMEDS::ListOfFileNames;
1352 aListOfFileNames->length(aFileNames.size());
1353 for(size_t anId = 0; anId < aFileNames.size(); anId++)
1354 aListOfFileNames[anId] = aFileNames[anId].c_str();
1357 aStreamFile = SALOMEDS_Tool::PutFilesToStream(aTmpDir, aListOfFileNames.in(), false);
1359 SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir.c_str(), aListOfFileNames.in(), true);
1361 return aStreamFile._retn();
1365 //---------------------------------------------------------------
1368 ::CanPaste(const char* theComponentName, CORBA::Long theObjectID) {
1369 // The VISU component can paste only objects copied by VISU component
1370 CORBA::String_var aString = ComponentDataType();
1371 if (strcmp(theComponentName, aString.in()) == 0 && theObjectID == 1)
1377 //---------------------------------------------------------------
1378 SALOMEDS::SObject_ptr
1380 ::PasteInto(const SALOMEDS::TMPFile& theStream,
1381 CORBA::Long theObjectID,
1382 SALOMEDS::SObject_ptr theSObject)
1384 if (theObjectID != 1)
1385 return SALOMEDS::SObject::_nil();
1387 SALOMEDS::SComponent_var aComponent = theSObject->GetFatherComponent();
1388 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
1389 SALOMEDS::StudyBuilder_var aStudyBuilder = aStudy->NewBuilder();
1390 CORBA::String_var aComponentID(aComponent->GetID());
1391 CORBA::String_var aSObjectID(theSObject->GetID());
1393 SALOMEDS::SObject_var aSObject;
1394 if (strcmp(aComponentID, aSObjectID) == 0) //create the new result SObject
1395 aSObject = aStudyBuilder->NewObject(aComponent);
1397 aSObject = SALOMEDS::SObject::_duplicate(theSObject);
1399 std::string aTmpDir = SALOMEDS_Tool::GetTmpDir();
1400 SALOMEDS::ListOfFileNames_var aListOfFileNames =
1401 SALOMEDS_Tool::PutStreamToFiles(theStream, aTmpDir, false);
1402 if(MYDEBUG) MESSAGE("Result_i::PasteInto - aListOfFileNames->length() = "<<aListOfFileNames->length());
1404 std::ostrstream aLocalPersistentID;
1406 std::string aCopyPersist = aTmpDir + "copy_persistent";
1407 std::ifstream anInputFileStream( aCopyPersist.c_str() );
1408 anInputFileStream >> aLocalPersistentID.rdbuf();
1411 //Just for Result::Restore to find the Comment attribute :(
1412 SALOMEDS::GenericAttribute_var anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeString");
1414 std::string aFileName(aTmpDir);
1415 if(aListOfFileNames->length() > 1)
1416 aFileName += aListOfFileNames[1].in();
1417 Storable* aStorable = Storable::Create(aSObject, aLocalPersistentID.str(), aFileName, false);
1419 SALOMEDS::ListOfFileNames_var aFilesToRemove = new SALOMEDS::ListOfFileNames;
1420 aFilesToRemove->length(1);
1421 aFilesToRemove[0] = aListOfFileNames[0];
1422 SALOMEDS_Tool::RemoveTemporaryFiles(aTmpDir, aFilesToRemove.in(), true);
1424 anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeIOR");
1425 SALOMEDS::AttributeIOR_var anIOR = SALOMEDS::AttributeIOR::_narrow(anAttr);
1426 CORBA::String_var anIORValue(aStorable->GetID());
1427 anIOR->SetValue(anIORValue);
1429 return aSObject._retn();
1433 //---------------------------------------------------------------
1434 VISU::ColoredPrs3dCache_ptr
1436 ::GetColoredPrs3dCache(SALOMEDS::Study_ptr theStudy)
1438 return ColoredPrs3dCache_i::GetInstance(theStudy);
1442 CORBA::Long VISU_Gen_i::CreateClippingPlane(CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
1443 CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
1444 CORBA::Boolean isAuto, const char* name)
1446 return myClippingPlaneMgr.CreateClippingPlane(X, Y, Z, dX, dY, dZ, isAuto, name);
1450 void VISU_Gen_i::EditClippingPlane(CORBA::Long id, CORBA::Double X,CORBA::Double Y, CORBA::Double Z,
1451 CORBA::Double dX, CORBA::Double dY, CORBA::Double dZ,
1452 CORBA::Boolean isAuto, const char* name)
1454 myClippingPlaneMgr.EditClippingPlane(id, X, Y, Z, dX, dY, dZ, isAuto, name);
1457 /* Returns clipping plane by its Id */
1458 VISU::ClippingPlane* VISU_Gen_i::GetClippingPlane(CORBA::Long id)
1460 VISU_CutPlaneFunction* aPlane = myClippingPlaneMgr.GetClippingPlane(id);
1462 if (aPlane != NULL) {
1465 aPlane->GetOrigin(aOrigin);
1466 aPlane->GetNormal(aDir);
1468 VISU::ClippingPlane* aRetPlane = new VISU::ClippingPlane;
1469 aRetPlane->X = aOrigin[0];
1470 aRetPlane->Y = aOrigin[1];
1471 aRetPlane->Z = aOrigin[2];
1472 aRetPlane->dX = aDir[0];
1473 aRetPlane->dY = aDir[1];
1474 aRetPlane->dZ = aDir[2];
1475 aRetPlane->isAuto = aPlane->isAuto();
1477 aRetPlane->name = aPlane->getName().c_str();
1483 /* Deletes clipping plane by its Id */
1484 CORBA::Boolean VISU_Gen_i::DeleteClippingPlane(CORBA::Long id)
1486 return myClippingPlaneMgr.DeleteClippingPlane(id);
1489 /* Applyes a clipping plane with Id to presentation thePrs */
1490 CORBA::Boolean VISU_Gen_i::ApplyClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
1492 VISU::Prs3d_i* aPrs = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(thePrs).in());
1493 return myClippingPlaneMgr.ApplyClippingPlane(aPrs, id);
1496 /* Detaches a clipping plane with Id from presentation thePrs */
1497 CORBA::Boolean VISU_Gen_i::DetachClippingPlane(Prs3d_ptr thePrs, CORBA::Long id)
1499 VISU::Prs3d_i* aPrs = dynamic_cast<VISU::Prs3d_i*>(VISU::GetServant(thePrs).in());
1500 return myClippingPlaneMgr.DetachClippingPlane(aPrs, id);
1503 /* Get number of clipping planes */
1504 CORBA::Long VISU_Gen_i::GetClippingPlanesNb()
1506 return myClippingPlaneMgr.GetClippingPlanesNb();
1510 \brief Converts set of VTK files to the one MED-file
1511 \param theVTKFiles sequence of VTK files
1512 \param theMEDFile MED-file
1513 \param theMeshName mesh name. This parameter can be empty. In this case name
1514 of mesh is equal vtk2med
1515 \param theTStamps values of time stamps. This array can be empty, in
1516 this case values of time stamps will be generated automatically ( 0, 1, 2 ... )
1517 \return TRUE if operation has been completed successfully, FALSE otherwise
1521 ::VTK2MED( const VISU::string_array& theVTKFiles,
1522 const char* theMEDFile,
1523 const char* theMeshName,
1524 const VISU::double_array& theTStamps )
1526 if ( !theMEDFile || !theVTKFiles.length() )
1529 VISU_Vtk2MedConvertor aConvertor;
1530 aConvertor.setMEDFileName( theMEDFile );
1531 // std::string aFirstFile = theVTKFiles[ 0 ];
1532 char* aFirstFile = CORBA::string_dup( theVTKFiles[ 0 ] );
1533 aConvertor.setFirstVTKFileName( aFirstFile );
1534 if ( theVTKFiles.length() > 1 )
1536 VISU_Vtk2MedConvertor::TVectorString aFiles( theVTKFiles.length() - 1 );
1537 for ( int i = 1, n = theVTKFiles.length(); i < n; i++ )
1538 aFiles[ i - 1 ] = theVTKFiles[ i ];
1539 aConvertor.setDataVTKFileNames( aFiles );
1541 if ( theTStamps.length() > 0 )
1543 VISU_Vtk2MedConvertor::TVectorDouble aTStamps( theTStamps.length() );
1544 for ( int i = 0, n = theTStamps.length(); i < n; i++ )
1545 aTStamps[ i ] = theTStamps[ i ];
1546 aConvertor.setTimeStamps( aTStamps );
1549 if ( theMeshName && strlen( theMeshName ) > 0 )
1550 aConvertor.setMeshName( theMeshName );
1552 aConvertor.addToIgnoringFieldList("cellID");
1553 aConvertor.setCellDataFieldNameIDS("cellID");
1555 int res = aConvertor.Execute();