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_Result_i.cc
24 // Author : Alexey PETROV
27 #include "VISU_MultiResult_i.hh"
28 #include "VISU_ResultUtils.hh"
29 #include "VISU_Prs3d_i.hh"
31 #include "VISU_Convertor_impl.hxx"
32 #include "VISU_CorbaMedConvertor.hxx"
33 #include "VISU_ConvertorUtils.hxx"
34 #include "VISU_PipeLine.hxx"
36 #include "SUIT_ResourceMgr.h"
38 #include "SALOMEDS_Tool.hxx"
39 #include "HDFascii.hxx"
41 #include "SUIT_Session.h"
42 #include "SALOME_Event.h"
43 #include "SalomeApp_Study.h"
44 #include "SalomeApp_Application.h"
46 #include "MED_Factory.hxx"
48 #include <boost/thread/thread.hpp>
49 #include <boost/bind.hpp>
61 #include <vtkUnstructuredGrid.h>
64 #include <Bnd_Box.hxx>
67 static int MYDEBUG = 1;
69 static int MYDEBUG = 0;
76 //---------------------------------------------------------------
78 FindResult(SALOMEDS::SObject_ptr theSObject)
80 SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent();
81 SALOMEDS::SObject_var aFather = theSObject->GetFather();
82 CORBA::String_var aComponentID (aSComponent->GetID());
83 CORBA::String_var aFatherID (aFather->GetID());
85 while (strcmp(aComponentID, aFatherID) != 0) {
86 CORBA::Object_var anObject = SObjectToObject(aFather);
87 if (!CORBA::is_nil(anObject)) {
88 aResult = Result::_narrow(anObject);
89 if (!aResult->_is_nil()) return aResult;
91 aFather = aFather->GetFather();
92 aFatherID = aFather->GetID();
98 //---------------------------------------------------------------
100 GetResult(SALOMEDS::Study_ptr theStudy,
101 const std::string& theResultEntry)
103 if(CORBA::is_nil(theStudy))
106 SALOMEDS::SObject_var aSObject = theStudy->FindObjectID(theResultEntry.c_str());
107 CORBA::Object_var anObject = SObjectToObject(aSObject);
108 return dynamic_cast<VISU::Result_i*>(GetServant(anObject).in());
112 //---------------------------------------------------------------
114 GetComponentDataType (SALOMEDS::SObject_ptr theSObject)
116 SALOMEDS::SComponent_var aCompRefSObj = theSObject->GetFatherComponent();
117 CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
118 return aDataType.in();
122 //---------------------------------------------------------------
124 CreateReference (SALOMEDS::Study_ptr theStudyDocument,
125 const string& theFatherEntry,
126 const string& theRefEntry)
128 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
129 SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry.c_str());
130 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(aFather);
131 SALOMEDS::SObject_var aRefSObj = theStudyDocument->FindObjectID(theRefEntry.c_str());
132 aStudyBuilder->Addreference(newObj,aRefSObj);
136 //---------------------------------------------------------------
140 //---------------------------------------------------------------
141 const string VISU::Result_i::myComment = "RESULT";
142 const char* VISU::Result_i::GetComment() const { return myComment.c_str();}
144 //---------------------------------------------------------------
146 ::Result_i(SALOMEDS::Study_ptr theStudy,
147 const ESourceId& theSourceId,
148 const ECreationId& theCreationId,
149 CORBA::Boolean theIsBuildImmediately,
150 CORBA::Boolean theIsBuildFields,
151 CORBA::Boolean theIsBuildMinMax,
152 CORBA::Boolean theIsBuildGroups):
153 myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)),
154 myCreationId(theCreationId),
155 mySourceId(theSourceId),
156 myIsBuildImmediately(theIsBuildImmediately),
157 myIsBuildFields(theIsBuildFields),
158 myIsBuildMinMax(theIsBuildMinMax),
159 myIsBuildGroups(theIsBuildGroups),
160 myIsEntitiesDone(false),
161 myIsFieldsDone(false),
162 myIsGroupsDone(false),
163 myIsMinMaxDone(false),
165 myIsBuildParts(false),
168 if(MYDEBUG) MESSAGE("Result_i::Result_i - this = "<<this);
169 myStudy = VISU::GetStudy(myStudyDocument);
173 //---------------------------------------------------------------
176 myIsEntitiesDone(false),
177 myIsFieldsDone(false),
178 myIsGroupsDone(false),
179 myIsMinMaxDone(false),
181 myIsBuildParts(false),
184 if(MYDEBUG) MESSAGE("Result_i::Result_i - this = "<<this);
188 //---------------------------------------------------------------
192 MESSAGE("Result_i::~Result_i() - this = "<<this);
193 if (GetSourceId() == eRestoredFile)
194 VISU::RemoveFile(myFileInfo.filePath().toLatin1().data());
198 //---------------------------------------------------------------
203 struct TRemoveFromStudy: public SALOME_Event
205 VISU::Result_i* myRemovable;
206 TRemoveFromStudy(VISU::Result_i* theRemovable):
207 myRemovable(theRemovable)
214 VISU::RemoveFromStudy(myRemovable->GetSObject(),false);
215 myRemovable->Destroy();
219 // Remove the result with all presentations and other possible sub-objects
220 ProcessVoidEvent(new TRemoveFromStudy(this));
224 //---------------------------------------------------------------
227 ::ConnectObserver(TResultObserver* theObserver,
228 boost::signalslib::connection& theConnection)
230 if(theConnection.connected())
231 theConnection.disconnect();
234 myUpdateObserverSignal.connect(boost::bind(boost::bind(&TResultObserver::UpdateFromResult,
241 //---------------------------------------------------------------
246 struct TEvent: public SALOME_Event
248 VISU::Result_i::TUpdateObserverSignal& myUpdateObserverSignal;
250 TEvent(VISU::Result_i::TUpdateObserverSignal& theUpdateObserverSignal):
251 myUpdateObserverSignal(theUpdateObserverSignal)
258 myUpdateObserverSignal();
262 ProcessVoidEvent(new TEvent(myUpdateObserverSignal));
266 //---------------------------------------------------------------
272 size_t aSize = myInput->GetSize();
273 size_t aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
274 MESSAGE("Result_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<float(aResult));
276 }catch(std::exception& exc){
277 INFOS("Follow exception was occured :\n"<<exc.what());
279 INFOS("Unknown exception was occured!");
285 //---------------------------------------------------------------
290 if(MYDEBUG) MESSAGE("Result_i::Build - myIsAllDone = "<<myIsAllDone);
296 const VISU::TMeshMap& aMeshMap = myInput->GetMeshMap();
297 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
298 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
299 const string& aMeshName = aMeshMapIter->first;
300 const VISU::PMesh aMesh = aMeshMapIter->second;
301 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
302 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
304 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
305 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
306 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
307 const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
308 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
309 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
310 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
311 const string& aFieldName = aFieldMapIter->first;
312 const VISU::PField aField = aFieldMapIter->second;
313 const VISU::TValField& aValField = aField->myValField;
314 VISU::TValField::const_iterator aValFieldIter = aValField.begin();
315 for(; aValFieldIter != aValField.end(); aValFieldIter++){
316 int aTimeStamp = aValFieldIter->first;
318 myInput->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
319 }catch(std::exception& exc){
320 INFOS("Follow exception was occured :\n"<<exc.what());
322 INFOS("Unknown exception was occured!!!");
327 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
328 VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
329 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
330 const string& aGroupName = aGroupMapIter->first;
332 myInput->GetMeshOnGroup(aMeshName,aGroupName);
333 }catch(std::exception& exc){
334 INFOS("Follow exception was occured :\n"<<exc.what());
336 INFOS("Unknown exception was occured!!!");
340 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
341 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
342 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
343 const string& aFamilyName = aFamilyMapIter->first;
345 myInput->GetFamilyOnEntity(aMeshName,anEntity,aFamilyName);
346 }catch(std::exception& exc){
347 INFOS("Follow exception was occured :\n"<<exc.what());
349 INFOS("Unknown exception was occured!!!");
352 //Import mesh on entity
354 myInput->GetMeshOnEntity(aMeshName,anEntity);
355 }catch(std::exception& exc){
356 INFOS("Follow exception was occured :\n"<<exc.what());
358 INFOS("Unknown exception was occured!!!");
363 }catch(std::exception& exc){
364 INFOS("Follow exception was occured :\n"<<exc.what());
366 INFOS("Unknown exception was occured!!!");
372 //---------------------------------------------------------------
375 ::Build(CORBA::Boolean theIsBuildAll,
376 CORBA::Boolean theIsAtOnce)
381 if(Build(SALOMEDS::SObject::_nil(), theIsAtOnce)){
384 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
386 SALOMEDS::GenericAttribute_var anAttr;
387 SALOMEDS::AttributePixMap_var aPixmap;
389 anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, "AttributePixMap" );
390 aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
391 aPixmap ->SetPixMap("ICON_TREE_RESULT");
402 //---------------------------------------------------------------
403 VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject,
404 CORBA::Boolean theIsAtOnce)
412 mySComponent = FindOrCreateVisuComponent(myStudyDocument);
413 CORBA::String_var aSComponentEntry = mySComponent->GetID();
414 CORBA::String_var anIOR(GetID());
416 aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s",
418 myFileInfo.filePath().toLatin1().data(),
419 GetInitFileName().c_str()); // Restoring of Python dump
420 std::string aResultEntry =
421 CreateAttributes(myStudy,
422 aSComponentEntry.in(),
427 aComment.toLatin1().data(),
429 mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str());
430 if(!CORBA::is_nil(theSObject)){
431 CORBA::String_var aString = theSObject->GetID();
432 CreateReference(myStudyDocument, aResultEntry, aString.in());
453 BuildFieldDataTree(this,
461 boost::thread aThread(boost::bind(boost::bind(&Result_i::BuildDataTree, this, _1),
469 //---------------------------------------------------------------
472 ::BuildDataTree(const std::string& theResultEntry)
485 boost::thread aThread(boost::bind(&BuildGroups,
494 boost::thread aThread(boost::bind(&BuildFieldDataTree,
505 //---------------------------------------------------------------
508 ::BuildAll(SALOMEDS::SObject_ptr theSObject)
510 if(MYDEBUG) MESSAGE("Result_i::Build");
514 }catch(std::exception& exc){
515 INFOS("Follow exception was occured :\n"<<exc.what());
518 INFOS("Unknown exception was occured!!!");
526 //---------------------------------------------------------------
529 ::Create(const char* theFileName)
532 myFileInfo.setFile(theFileName);
533 myFileName = myFileInfo.fileName().toLatin1().data();
536 SetInitFileName(myFileInfo.filePath().toLatin1().data());
537 SetName(VISU::GenerateName(myFileInfo.fileName().toLatin1().data()).toLatin1().data(), false);
540 if(mySourceId == eRestoredFile){
541 QString aTmpDir(SALOMEDS_Tool::GetTmpDir().c_str());
542 std::string aFileName = VISU::MakeFileName(myFileInfo.fileName().toLatin1().data(), this);
543 QString aPathToCopy(aTmpDir + aFileName.c_str());
544 if(!VISU::CopyFile(myFileInfo.absoluteFilePath().toLatin1().data(), aPathToCopy.toLatin1().data()))
547 myFileInfo.setFile(aPathToCopy);
548 myFileName = myFileInfo.fileName().toLatin1().data();
551 myInput.reset(CreateConvertor(myFileInfo.absoluteFilePath().toLatin1().data()));
554 if(myIsBuildImmediately)
555 Build(SALOMEDS::SObject::_nil());
558 }catch(std::exception& exc){
559 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
561 MSG(MYDEBUG,"Unknown exception !!!");
567 //---------------------------------------------------------------
570 ::Create(SALOMEDS::SObject_ptr theMedSObject)
572 if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOMEDS::SObject_ptr");
574 myInput.reset(CreateMEDConvertor(theMedSObject));
580 string aCompDataType = GetComponentDataType(theMedSObject);
581 myFileInfo.setFile(aCompDataType.c_str());
582 myFileName = VISU::GenerateName("aResult").toLatin1().data();
584 SetInitFileName(aCompDataType);
585 SetName(VISU::GenerateName(myFileInfo.fileName().toLatin1().data()).toLatin1().data(), false);
587 return Build(theMedSObject);
588 }catch(std::exception& exc){
589 INFOS("Follow exception was occured :\n"<<exc.what());
591 INFOS("Unknown exception was occured!!!");
597 //---------------------------------------------------------------
600 ::Create(SALOME_MED::FIELD_ptr theField)
602 if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOME_MED::FIELD_ptr");
604 myInput.reset(CreateMEDFieldConvertor(theField));
610 string aCompDataType = "MED";
611 myFileInfo.setFile(aCompDataType.c_str());
613 myFileName = VISU::GenerateName("aResult").toLatin1().data();
614 SetInitFileName(aCompDataType);
615 SetName(VISU::GenerateName(myFileInfo.fileName().toLatin1().data()).toLatin1().data(), false);
617 CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField);
618 SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR);
620 return Build(aFieldSObject);
621 }catch(std::exception& exc){
622 INFOS("Follow exception was occured :\n"<<exc.what());
624 INFOS("Unknown exception was occured!!!");
630 //---------------------------------------------------------------
633 ::Save(SALOMEDS::SComponent_ptr theComponent,
634 const std::string& theURL,
637 TFileNames& theFileNames,
638 TFileNames& theFiles)
640 switch(GetCreationId()){
641 case Result_i::eImportFile:
642 case Result_i::eCopyAndImportFile: {
643 INITMSG(MYDEBUG, "Result::Save - this = "<<this<<"\n");
644 INITMSGA(MYDEBUG, 0, "theIsMultiFile = "<<theIsMultiFile<<"; theIsASCII = "<<theIsASCII<<"\n");
647 if (theIsMultiFile) {
648 CORBA::String_var anURL = GetStudyDocument()->URL();
649 aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
652 std::string aFileName = aPrefix + "_" + GetFileName().c_str();
653 BEGMSG(MYDEBUG, "aFileName = '"<<aFileName<<"'\n");
655 std::string aFile = GetFileInfo().filePath().toLatin1().data();
656 BEGMSG(MYDEBUG, "aFile = '"<<aFile<<"'\n");
658 if(theIsMultiFile || theIsASCII){
659 std::string aPathToCopy(theURL + aFileName);
660 BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
662 if(!VISU::CopyFile(aFile, aPathToCopy))
666 HDFascii::ConvertFromHDFToASCII(const_cast<char*>(aPathToCopy.c_str()), true);
669 theFileNames.push_back(aFileName);
670 theFiles.push_back(aFile);
679 //---------------------------------------------------------------
682 ::CanCopy(SALOMEDS::SObject_ptr theObject)
684 switch(GetCreationId()){
685 case Result_i::eImportFile:
686 case Result_i::eCopyAndImportFile:
694 //---------------------------------------------------------------
697 ::CopyFrom(SALOMEDS::SObject_ptr theObject,
698 CORBA::Long& theObjectID,
699 const std::string& theTmpDir,
700 TFileNames& theFileNames)
702 if(!Storable::CopyFrom(theObject, theObjectID, theTmpDir, theFileNames))
705 SALOMEDS::Study_var aStudy = theObject->GetStudy();
706 CORBA::String_var anURL = aStudy->URL();
707 std::string aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
708 std::string aFileName = aPrefix + GetFileInfo().fileName().toLatin1().data();
710 static QString aCommand;
711 std::string aFilePath = theTmpDir + aFileName;
712 aCommand.sprintf(" %s %s", GetFileInfo().filePath().toLatin1().data(), aFilePath.c_str());
713 aCommand = QDir::convertSeparators( aCommand );
714 aCommand.prepend( COPY_COMMAND );
716 if(system(aCommand.toLatin1().data()) != 0) {
717 if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand.toLatin1().data());
721 SALOMEDS::SComponent_var aSComponent = aStudy->FindComponent("VISU");
723 theFileNames.push_back(aFileName);
729 //---------------------------------------------------------------
732 ::Restore(SALOMEDS::SObject_ptr theSObject,
733 const Storable::TRestoringMap& theMap,
734 const string& thePrefix,
735 CORBA::Boolean theIsMultiFile)
737 if(MYDEBUG) MESSAGE("Result_i::Restore - " << thePrefix);
738 mySObject = SALOMEDS::SObject::_duplicate(theSObject);
739 mySComponent = mySObject->GetFatherComponent();
740 myStudyDocument = theSObject->GetStudy();
741 myStudy = VISU::GetStudy(myStudyDocument);
743 myCreationId = ECreationId(Storable::FindValue(theMap, "myCreationId").toInt());
744 mySourceId = eRestoredFile;
745 if(myCreationId == eImportMed || myCreationId == eImportMedField)
746 mySourceId = eRestoredComponent;
748 myIsBuildFields = Storable::FindValue(theMap, "myIsBuildFields", "1").toInt();
749 myIsBuildMinMax = Storable::FindValue(theMap, "myIsBuildMinMax", "1").toInt();
750 myIsBuildGroups = Storable::FindValue(theMap, "myIsBuildGroups", "1").toInt();
752 myIsBuildImmediately = true;
755 myFileName = VISU::Storable::FindValue(theMap, "myName").toLatin1().data();
756 SetInitFileName(VISU::Storable::FindValue(theMap, "myInitFileName").toLatin1().data());
758 SALOMEDS::SObject_var aRefSObj, aTargetRefSObj;
759 if (theSObject->FindSubObject(1, aRefSObj) && aRefSObj->ReferencedObject(aTargetRefSObj)) {
760 if(MYDEBUG) MESSAGE("Result_i::GetInput - There is some reference.");
761 SALOMEDS::SComponent_var aCompRefSObj = aTargetRefSObj->GetFatherComponent();
762 CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
763 myFileInfo.setFile(aDataType.in());
764 if(MYDEBUG) MESSAGE("Result_i::GetInput - aDataType = " << aDataType);
765 Engines::Component_var aEngComp =
766 Base_i::myEnginesLifeCycle->FindOrLoad_Component("FactoryServer", aDataType.in());
767 if (CORBA::is_nil(aEngComp))
768 throw std::runtime_error("Restore - There is no aEngComp for the aDataType !!!");
769 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
770 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp);
771 aStudyBuilder->LoadWith(aCompRefSObj, aDriver);
772 // create field or MED converter
773 CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj);
774 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(aMedObject);
775 if (!CORBA::is_nil(aField)) {
776 // create field converter
777 myInput.reset(CreateMEDFieldConvertor(aField));
780 else if (strcmp(aDataType, "MED") == 0) {
781 // create MED converter
782 myInput.reset(CreateMEDConvertor(aTargetRefSObj));
786 throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!");
789 myFileInfo.setFile(thePrefix.c_str());
791 std::string aStudyPrefix ("");
792 if (theIsMultiFile) {
793 CORBA::String_var anURL(GetStudyDocument()->URL());
794 aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
796 if (!myFileInfo.isFile()) {
797 std::string aFileName = thePrefix + aStudyPrefix + "_" + myFileName;
798 myFileInfo.setFile(aFileName.c_str());
801 MESSAGE("Result_i::Restore - aFileName = " << myFileInfo.filePath().toLatin1().data() << "; " << myFileInfo.isFile());
803 if (HDFascii::isASCII(myFileInfo.filePath().toLatin1().data())) {
804 MESSAGE("ConvertFromASCIIToHDF(" << myFileInfo.filePath().toLatin1().data() << ")");
805 char* aResultPath = HDFascii::ConvertFromASCIIToHDF(myFileInfo.filePath().toLatin1().data());
806 MESSAGE("ConvertFromASCIIToHDF() DONE : " << aResultPath);
807 char* aHDFFileName = new char[strlen(aResultPath) + 19];
808 sprintf(aHDFFileName, "%shdf_from_ascii.hdf", aResultPath);
810 if (theIsMultiFile) { // set this file as new - temporary
811 static QString aCommand;
812 aCommand.sprintf(" %s %s%s",aHDFFileName, aResultPath, myFileInfo.baseName().toLatin1().data());
813 aCommand = QDir::convertSeparators( aCommand );
814 aCommand.prepend( MOVE_COMMAND );
816 if (system(aCommand.toLatin1().data()) == -1) {
817 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand.toLatin1().data());
820 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand.toLatin1().data());
822 myFileInfo.setFile(QString(aResultPath) + myFileInfo.baseName());
823 } else { // change current temporary file to the new: with hdf-format
824 static QString aCommand;
825 aCommand.sprintf(" %s %s\0",aHDFFileName, myFileInfo.filePath().toLatin1().data());
826 aCommand = QDir::convertSeparators( aCommand );
827 aCommand.prepend( MOVE_COMMAND );
829 if (system(aCommand.toLatin1().data()) == -1) {
830 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand.toLatin1().data());
833 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand.toLatin1().data());
835 SALOMEDS::ListOfFileNames_var anEmptyList = new SALOMEDS::ListOfFileNames;
836 SALOMEDS_Tool::RemoveTemporaryFiles(aResultPath, anEmptyList.in(), true);
838 mySourceId = eRestoredFile;
840 delete(aHDFFileName);
841 } else if (!theIsMultiFile) {
842 mySourceId = eRestoredFile;
844 mySourceId = eSavedFile;
846 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId);
847 myInput.reset(CreateConvertor(myFileInfo.filePath().toLatin1().data()));
849 myInput->BuildEntities();
851 myInput->BuildFields();
852 myIsFieldsDone = true;
854 myInput->BuildMinMax();
855 myIsMinMaxDone = true;
859 myInput->BuildGroups();
860 myIsGroupsDone = true;
864 aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s",
866 myFileInfo.filePath().toLatin1().data(),
867 GetInitFileName().c_str()); // Restoring of Python dump
868 SALOMEDS::GenericAttribute_var anAttr;
869 if (!theSObject->FindAttribute(anAttr, "AttributeString"))
870 throw std::runtime_error("Build - There is no AttributeString for the SObject !!!");
871 SALOMEDS::AttributeString_var aCmnt = SALOMEDS::AttributeString::_narrow(anAttr);
872 aCmnt->SetValue(aComment.toLatin1().data());
874 bool anIsBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
878 } catch(std::exception& exc) {
879 INFOS("Follow exception was occured :\n"<<exc.what());
881 INFOS("Unknown exception was occured!!!");
887 //---------------------------------------------------------------
888 VISU::Result_i::PInput
890 ::GetInput(const std::string& theMeshName,
891 VISU::Entity theEntity,
892 const std::string& theFieldName,
893 CORBA::Long theTimeStampNumber)
899 //---------------------------------------------------------------
906 (myIsBuildFields? myIsFieldsDone: true) &&
907 (myIsBuildMinMax? myIsMinMaxDone: true) &&
908 (myIsBuildGroups? myIsGroupsDone: true);
915 return myIsEntitiesDone;
920 ::SetBuildFields(CORBA::Boolean theIsBuildFields,
921 CORBA::Boolean theIsCalculateMinMax)
923 myIsBuildFields = theIsBuildFields;
925 myIsBuildMinMax = theIsCalculateMinMax;
927 myIsBuildMinMax = false;
932 ::SetBuildGroups(CORBA::Boolean theIsBuildGroups)
934 myIsBuildGroups = theIsBuildGroups;
941 return myIsFieldsDone;
948 return myIsGroupsDone;
955 return myIsMinMaxDone;
962 return myIsPartsDone;
966 //---------------------------------------------------------------
967 VISU::Result::EntityNames*
971 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
972 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
974 return aResult._retn();
976 aResult->length(aMeshMap.size());
977 VISU::TMeshMap::const_iterator anIter = aMeshMap.begin();
978 for(size_t anId = 0; anIter != aMeshMap.end(); anIter++, anId++){
979 const std::string& aName = anIter->first;
980 aResult[anId] = aName.c_str();
983 return aResult._retn();
987 //---------------------------------------------------------------
988 VISU::Result::Entities*
990 ::GetEntities(const char* theMeshName)
992 VISU::Result::Entities_var anEntities = new VISU::Result::Entities();
993 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
995 return anEntities._retn();
997 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
998 if(anIter == aMeshMap.end())
999 return anEntities._retn();
1001 const VISU::PMesh& aMesh = anIter->second;
1002 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1003 if(aMeshOnEntityMap.empty())
1004 return anEntities._retn();
1007 anEntities->length(aMeshOnEntityMap.size());
1008 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.begin();
1009 for(size_t anId = 0; anIter != aMeshOnEntityMap.end(); anIter++, anId++){
1010 const VISU::TEntity& anEntity = anIter->first;
1011 anEntities[anId] = VISU::Entity(anEntity);
1015 return anEntities._retn();
1019 //---------------------------------------------------------------
1020 VISU::Result::EntityNames*
1022 ::GetFamilies(const char* theMeshName,
1023 VISU::Entity theEntity)
1025 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1026 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1027 if(aMeshMap.empty())
1028 return aResult._retn();
1030 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1031 if(anIter == aMeshMap.end())
1032 return aResult._retn();
1034 const VISU::PMesh& aMesh = anIter->second;
1035 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1036 if(aMeshOnEntityMap.empty())
1037 return aResult._retn();
1040 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1041 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1042 if(anIter == aMeshOnEntityMap.end())
1043 return aResult._retn();
1045 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1046 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1047 if(aFamilyMap.empty())
1048 return aResult._retn();
1051 aResult->length(aFamilyMap.size());
1052 VISU::TFamilyMap::const_iterator anIter = aFamilyMap.begin();
1053 for(size_t anId = 0; anIter != aFamilyMap.end(); anIter++, anId++){
1054 const std::string& aName = anIter->first;
1055 aResult[anId] = aName.c_str();
1060 return aResult._retn();
1064 //---------------------------------------------------------------
1065 VISU::Result::EntityNames*
1067 ::GetGroups(const char* theMeshName)
1069 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1070 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1071 if(aMeshMap.empty())
1072 return aResult._retn();
1074 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1075 if(anIter == aMeshMap.end())
1076 return aResult._retn();
1078 const VISU::PMesh& aMesh = anIter->second;
1079 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1080 if(aGroupMap.empty())
1081 return aResult._retn();
1084 aResult->length(aGroupMap.size());
1085 VISU::TGroupMap::const_iterator anIter = aGroupMap.begin();
1086 for(size_t anId = 0; anIter != aGroupMap.end(); anIter++, anId++){
1087 const std::string& aName = anIter->first;
1088 aResult[anId] = aName.c_str();
1092 return aResult._retn();
1096 //---------------------------------------------------------------
1097 VISU::Result::EntityNames*
1099 ::GetFields(const char* theMeshName,
1100 VISU::Entity theEntity)
1102 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1103 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1104 if(aMeshMap.empty())
1105 return aResult._retn();
1107 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1108 if(anIter == aMeshMap.end())
1109 return aResult._retn();
1111 const VISU::PMesh& aMesh = anIter->second;
1112 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1113 if(aMeshOnEntityMap.empty())
1114 return aResult._retn();
1117 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1118 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1119 if(anIter == aMeshOnEntityMap.end())
1120 return aResult._retn();
1122 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1123 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1124 if(aFieldMap.empty())
1125 return aResult._retn();
1128 aResult->length(aFieldMap.size());
1129 VISU::TFieldMap::const_iterator anIter = aFieldMap.begin();
1130 for(size_t anId = 0; anIter != aFieldMap.end(); anIter++, anId++){
1131 const std::string& aName = anIter->first;
1132 aResult[anId] = aName.c_str();
1137 return aResult._retn();
1141 //---------------------------------------------------------------
1142 VISU::Result::TimeStampNumbers*
1144 ::GetTimeStampNumbers(const char* theMeshName,
1145 VISU::Entity theEntity,
1146 const char* theFieldName)
1148 VISU::Result::TimeStampNumbers_var aResult = new VISU::Result::TimeStampNumbers();
1149 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1150 if(aMeshMap.empty())
1151 return aResult._retn();
1153 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1154 if(anIter == aMeshMap.end())
1155 return aResult._retn();
1157 const VISU::PMesh& aMesh = anIter->second;
1158 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1159 if(aMeshOnEntityMap.empty())
1160 return aResult._retn();
1163 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1164 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1165 if(anIter == aMeshOnEntityMap.end())
1166 return aResult._retn();
1168 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1169 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1170 if(aFieldMap.empty())
1171 return aResult._retn();
1174 VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName);
1175 if(anIter == aFieldMap.end())
1176 return aResult._retn();
1179 const VISU::PField& aField = anIter->second;
1180 const VISU::TValField& aValField = aField->myValField;
1181 if(aValField.empty())
1182 return aResult._retn();
1185 aResult->length(aValField.size());
1186 VISU::TValField::const_iterator anIter = aValField.begin();
1187 for(size_t anId = 0; anIter != aValField.end(); anIter++, anId++){
1188 const vtkIdType& aTimeStampNumber = anIter->first;
1189 aResult[anId] = aTimeStampNumber;
1196 return aResult._retn();
1200 //---------------------------------------------------------------
1203 ::GetNumberOfComponents(const char* theMeshName,
1204 VISU::Entity theEntity,
1205 const char* theFieldName)
1207 CORBA::Long aResult = 0;
1208 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1209 if(aMeshMap.empty())
1212 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1213 if(anIter == aMeshMap.end())
1216 const VISU::PMesh& aMesh = anIter->second;
1217 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1218 if(aMeshOnEntityMap.empty())
1222 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1223 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1224 if(anIter == aMeshOnEntityMap.end())
1227 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1228 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1229 if(aFieldMap.empty())
1233 VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName);
1234 if(anIter == aFieldMap.end())
1238 const VISU::PField& aField = anIter->second;
1239 aResult = aField->myNbComp;
1248 //---------------------------------------------------------------
1249 VISU::Result::EntityNames*
1251 ::GetPartNames(const char* theMeshName)
1253 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1254 return aResult._retn();
1258 //---------------------------------------------------------------
1259 VISU::Result::Resolutions*
1261 ::GetResolutions(const char* theMeshName,
1262 const char* thePartName)
1264 VISU::Result::Resolutions_var aResult = new VISU::Result::Resolutions();
1265 return aResult._retn();
1269 //---------------------------------------------------------------
1270 VISU::Result::Resolution
1272 ::GetResolution(const char* theMeshName,
1273 const char* thePartName)
1275 return VISU::Result::HIDDEN;
1279 //---------------------------------------------------------------
1282 ::SetResolution(const char* theMeshName,
1283 const char* thePartName,
1284 VISU::Result::Resolution theResolution)
1288 //---------------------------------------------------------------
1291 ::New(SALOMEDS::Study_ptr theStudy,
1292 const ESourceId& theSourceId,
1293 const ECreationId& theCreationId,
1294 CORBA::Boolean theIsBuildImmediately,
1295 CORBA::Boolean theIsBuildFields,
1296 CORBA::Boolean theIsBuildMinMax,
1297 CORBA::Boolean theIsBuildGroups)
1299 return new RESULT_CLASS_NAME(theStudy,
1302 theIsBuildImmediately,
1309 //---------------------------------------------------------------
1312 ::StorableEngine(SALOMEDS::SObject_ptr theSObject,
1313 const Storable::TRestoringMap& theMap,
1314 const std::string& thePrefix,
1315 CORBA::Boolean theIsMultiFile)
1317 VISU::Result_i* aResult = new RESULT_CLASS_NAME();
1318 return aResult->Restore(theSObject, theMap, thePrefix, theIsMultiFile);
1322 //---------------------------------------------------------------
1325 ::ToStream(std::ostringstream& theStr)
1327 Storable::DataToStream(theStr,"myName", GetFileName().c_str());
1328 Storable::DataToStream(theStr,"myInitFileName", GetInitFileName().c_str());
1329 Storable::DataToStream(theStr,"myCreationId", myCreationId);
1330 Storable::DataToStream(theStr,"myIsBuildFields", myIsFieldsDone);
1331 Storable::DataToStream(theStr,"myIsBuildMinMax", myIsMinMaxDone);
1332 Storable::DataToStream(theStr,"myIsBuildGroups", myIsGroupsDone);
1335 //---------------------------------------------------------------
1339 ::ExportMED(const char* theTargetFileName)
1341 static QString aCommand;
1342 const char* aTempFileName = myFileInfo.absoluteFilePath().toLatin1();
1343 aCommand.sprintf(" %s %s", aTempFileName, theTargetFileName);
1344 aCommand = QDir::convertSeparators( aCommand );
1345 aCommand.prepend( COPY_COMMAND );
1347 if(system(aCommand.toLatin1().data()) != 0) {
1348 if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand.toLatin1().data());
1355 //---------------------------------------------------------------
1358 ::GetInitFileName() const
1360 return myInitFileName;
1366 ::SetInitFileName(const std::string& theFileName)
1368 myInitFileName = theFileName;
1372 //---------------------------------------------------------------
1375 ::GetFileName() const
1377 if(GetSourceId() == eFile)
1378 return VISU::MakeFileName(myFileName, this);
1386 ::GetFileInfo() const
1391 VISU::Result_i::ECreationId
1393 ::GetCreationId() const
1395 return myCreationId;
1399 VISU::Result_i::ESourceId
1401 ::GetSourceId() const
1407 //---------------------------------------------------------------
1412 CORBA::String_var anEntry = mySObject->GetID();
1413 return anEntry.in();
1416 SALOMEDS::SObject_var
1418 ::GetSObject() const
1425 ::GetStudyDocument() const
1427 return myStudyDocument;
1437 SALOMEDS::SComponent_var
1439 ::GetSComponent() const
1441 return mySComponent;
1446 ::GetEntry(const Storable::TRestoringMap& theRestoringMap)
1448 return Storable::FindEntry(myStudyDocument,
1454 //=======================================================================
1455 //function : GetAxisInfo
1457 //=======================================================================
1458 const VISU::Result_i::TAxisInfo*
1460 ::GetAxisInfo(const string& theMeshName,
1462 gp_Dir& thePlaneNormal)
1464 const TAxisInfo* components = NULL;
1466 if ( theAxis < AXIS_X || theAxis > AXIS_Z ) {
1467 MESSAGE(" Bad axis index " << theAxis );
1471 map< string, TGridInfo >::iterator name_info;
1472 name_info = myMeshName2GridInfoMap.find( theMeshName );
1473 TGridInfo * gInfo = 0;
1475 if ( name_info != myMeshName2GridInfoMap.end() )
1477 gInfo = & name_info->second;
1479 else if ( myInput && IsPossible() && theAxis >= AXIS_X && theAxis <= AXIS_Z )
1481 // check presence of theMeshName
1482 const VISU::TMeshMap& meshMap = myInput->GetMeshMap();
1484 VISU::TMeshMap::const_iterator aIter = meshMap.find( theMeshName );
1485 if ( aIter == meshMap.end() ) {
1486 MESSAGE("No mesh named " << theMeshName );
1489 theMesh = aIter->second;
1491 VISU::PUnstructuredGridIDMapper anIDMapper = myInput->GetMeshOnEntity(theMeshName,
1493 vtkUnstructuredGrid* aMesh = anIDMapper->GetUnstructuredGridOutput();
1495 if ( !aMesh || aMesh->GetNumberOfCells() == 0 ) {
1496 MESSAGE( "No cells in the mesh: " << theMeshName );
1500 if ( !theMesh->IsStructured() || theMesh->myIsPolarType ) {
1501 // define axis directions and min cell size in each direction
1502 const int nbAxes = 3;
1504 gp_Vec axDirs[ nbAxes ];
1505 float minSize[3] = { FLT_MAX, FLT_MAX, FLT_MAX };
1506 bool axesComputed = false;
1507 for ( vtkIdType iCell = 0; iCell < aMesh->GetNumberOfCells(); ++iCell ) {
1508 vtkCell* cell = aMesh->GetCell( iCell );
1510 if (cell->GetCellType() != VTK_HEXAHEDRON &&
1511 cell->GetCellType() != VTK_QUADRATIC_HEXAHEDRON )
1513 vtkPoints * points = cell->GetPoints();
1514 vtkFloatingPointType coords[ 4 ][3];
1515 points->GetPoint( 0, coords[0] );
1516 points->GetPoint( 1, coords[1] );
1517 points->GetPoint( 3, coords[2] );
1518 points->GetPoint( 4, coords[3] );
1519 gp_Pnt p0( coords[0][0], coords[0][1], coords[0][2] );
1520 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1521 vtkFloatingPointType* coo = coords[ iAx + 1 ];
1522 gp_Pnt p( coo[0], coo[1], coo[2] );
1524 vtkFloatingPointType size = p0.SquareDistance( p );
1525 if ( size > FLT_MIN && size < minSize[ iAx ] )
1526 minSize[ iAx ] = size;
1528 if ( !axesComputed ) {
1529 gp_Vec dir( p0, p );
1530 if ( dir.SquareMagnitude() <= gp::Resolution() ) {
1533 axDirs[ iAx ] = dir;
1536 if ( iAx == nbAxes )
1537 axesComputed = true;
1539 if ( !axesComputed ) {
1540 MESSAGE("No good hexahedrons in the mesh: " << theMeshName );
1544 // compute axes dirs
1545 gInfo = & myMeshName2GridInfoMap[ theMeshName ];
1546 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1547 int iPrev = ( iAx == 0 ) ? 2 : iAx - 1;
1548 int iNext = ( iAx == 2 ) ? 0 : iAx + 1;
1549 gInfo->myAxis[ iAx ] = axDirs[ iPrev ] ^ axDirs[ iNext ];
1552 // get and sort intermediate component values - projections of nodes
1553 // on axis direction; define bnd box
1554 set< vtkFloatingPointType > comps[ 3 ];
1556 vtkPoints * points = aMesh->GetPoints();
1557 vtkIdType iP, nbP = aMesh->GetNumberOfPoints();
1558 for ( iP = 0; iP < nbP; ++iP ) {
1559 vtkFloatingPointType coo[3];
1560 points->GetPoint( iP, coo );
1561 gp_Pnt p( coo[0], coo[1], coo[2] );
1563 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1564 const gp_Dir& dir = gInfo->myAxis[ iAx ];
1565 vtkFloatingPointType dot = dir.XYZ() * p.XYZ();
1566 comps[ iAx ].insert( dot );
1570 // find a range of projections of bnd box corners on each axis
1571 vtkFloatingPointType range[3], firstValue[3];
1572 double x[2],y[2],z[2];
1573 box.Get(x[0],y[0],z[0],x[1],y[1],z[1]);
1574 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1575 set< vtkFloatingPointType > bndComps;
1576 const gp_Dir& dir = gInfo->myAxis[ iAx ];
1577 for ( int iX = 0; iX < 2; ++iX ) {
1578 for ( int iY = 0; iY < 2; ++iY ) {
1579 for ( int iZ = 0; iZ < 2; ++iZ ) {
1580 gp_Pnt p( x[ iX ], y[ iY ], z[ iZ ] );
1581 vtkFloatingPointType dot = dir.XYZ() * p.XYZ();
1582 bndComps.insert( dot );
1586 firstValue[ iAx ] = *bndComps.begin();
1587 range[ iAx ] = *bndComps.rbegin() - *bndComps.begin();
1590 // compute component values
1591 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1592 list< vtkFloatingPointType > values;
1594 set< vtkFloatingPointType >& comp = comps[ iAx ];
1595 set< vtkFloatingPointType >::iterator val = comp.begin();
1596 vtkFloatingPointType bnd = -1., rng = range[ iAx ], first = firstValue[ iAx ];
1597 vtkFloatingPointType tol = 0.1 * sqrt( minSize[ iAx ]) / rng;
1598 for ( ; val != comp.end(); ++val ) {
1599 vtkFloatingPointType value = ( *val - first ) / rng;
1600 if ( value > bnd ) {
1601 values.push_back( value );
1606 // store values in gInfo
1607 vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ iAx ];
1608 myComp.resize( nbVals );
1609 list< vtkFloatingPointType >::iterator v = values.begin();
1610 for ( int i = 0; v != values.end(); ++v ){
1616 vtkIdType aMeshDim = theMesh->myDim;
1617 gInfo = & myMeshName2GridInfoMap[ theMeshName ];
1618 switch ( aMeshDim ) {
1620 gp_Dir aDir(0.0,0.0,1.0);
1621 gInfo->myAxis[ 2 ] = aDir;
1624 gp_Dir aDir(0.0,1.0,0.0);
1625 gInfo->myAxis[ 1 ] = aDir;
1628 gp_Dir aDir(1.0,0.0,0.0);
1629 gInfo->myAxis[ 0 ] = aDir;
1632 TStructuredId aStructuredId = theMesh->GetStructure();
1633 vector<vtkFloatingPointType> PointsCoords[3];
1634 vtkPoints* aPoints = aMesh->GetPoints();
1635 switch ( aMeshDim ) {
1637 TStructuredId aCoordIJK;
1638 vtkIdType nbZ = aStructuredId[2];
1639 for ( int i = 0; i < nbZ; i++ ) {
1640 aCoordIJK[2] = i + 1;
1641 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1642 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1643 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1644 PointsCoords[2].push_back(aPCoord[2]);
1648 TStructuredId aCoordIJK;
1649 vtkIdType nbJ = aStructuredId[1];
1650 for ( int i = 0; i < nbJ; i++ ) {
1651 aCoordIJK[1] = i + 1;
1652 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1653 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1654 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1655 PointsCoords[1].push_back(aPCoord[1]);
1659 TStructuredId aCoordIJK;
1660 vtkIdType nbI = aStructuredId[0];
1661 for ( int i = 0; i < nbI; i++ ) {
1662 aCoordIJK[0] = i + 1;
1663 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1664 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1665 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1666 PointsCoords[0].push_back(aPCoord[0]);
1669 for ( int i = 0; i < aMeshDim; i++ ) {
1670 vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ i ];
1671 int aSize = PointsCoords[i].size();
1673 vtkFloatingPointType aLen = PointsCoords[i][aSize-1] - PointsCoords[i][0];
1674 myComp.resize(aSize);
1676 for ( int k = 1; k < aSize; k++ ) {
1677 myComp[k]=myComp[k-1] + (PointsCoords[i][k]-PointsCoords[i][k-1])/aLen;
1684 // set return values
1686 thePlaneNormal = gInfo->myAxis[ theAxis ];
1687 components = & gInfo->myComponets[ theAxis ];
1693 SALOME_MED::MedFileInfo* VISU::Result_i::GetMEDFileInfo()
1695 SALOME_MED::MedFileInfo_var res = new SALOME_MED::MedFileInfo();
1697 QString fpath = myFileInfo.absoluteFilePath();
1698 res->fileName = fpath.toLatin1().constData();
1699 res->fileSize = myFileInfo.size();
1700 int major, minor, release;
1701 if( !MED::getMEDVersion( fpath.toLatin1().constData(), major, minor, release ) )
1709 res->release = release;