1 // Copyright (C) 2007-2010 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"
40 #include "Basics_Utils.hxx"
42 #include "SUIT_Session.h"
43 #include "SALOME_Event.h"
44 #include "SalomeApp_Study.h"
45 #include "SalomeApp_Application.h"
47 #include "MED_Factory.hxx"
49 #include <boost/thread/thread.hpp>
50 #include <boost/bind.hpp>
62 #include <vtkUnstructuredGrid.h>
65 #include <Bnd_Box.hxx>
68 static int MYDEBUG = 1;
70 static int MYDEBUG = 0;
77 //---------------------------------------------------------------
79 FindResult(SALOMEDS::SObject_ptr theSObject)
81 SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent();
82 SALOMEDS::SObject_var aFather = theSObject->GetFather();
83 CORBA::String_var aComponentID (aSComponent->GetID());
84 CORBA::String_var aFatherID (aFather->GetID());
86 while (strcmp(aComponentID, aFatherID) != 0) {
87 CORBA::Object_var anObject = SObjectToObject(aFather);
88 if (!CORBA::is_nil(anObject)) {
89 aResult = Result::_narrow(anObject);
90 if (!aResult->_is_nil()) return aResult;
92 aFather = aFather->GetFather();
93 aFatherID = aFather->GetID();
99 //---------------------------------------------------------------
101 GetResult(SALOMEDS::Study_ptr theStudy,
102 const std::string& theResultEntry)
104 Result_i* result = NULL;
105 if (!CORBA::is_nil(theStudy)) {
106 SALOMEDS::SComponent_var aSComponent = theStudy->FindComponent("VISU");
107 if (!CORBA::is_nil(aSComponent)) {
108 std::string compid = aSComponent->GetID();
109 std::string aResultEntry = theResultEntry;
110 if (theResultEntry.substr(0, compid.length()) != compid) aResultEntry = compid + theResultEntry.substr(compid.length());
111 SALOMEDS::SObject_var aSObject = theStudy->FindObjectID(aResultEntry.c_str());
112 CORBA::Object_var anObject = SObjectToObject(aSObject);
113 result = dynamic_cast<VISU::Result_i*>(GetServant(anObject).in());
120 //---------------------------------------------------------------
122 GetComponentDataType (SALOMEDS::SObject_ptr theSObject)
124 SALOMEDS::SComponent_var aCompRefSObj = theSObject->GetFatherComponent();
125 CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
126 return aDataType.in();
130 //---------------------------------------------------------------
132 CreateReference (SALOMEDS::Study_ptr theStudyDocument,
133 const string& theFatherEntry,
134 const string& theRefEntry)
136 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
137 SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry.c_str());
138 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(aFather);
139 SALOMEDS::SObject_var aRefSObj = theStudyDocument->FindObjectID(theRefEntry.c_str());
140 aStudyBuilder->Addreference(newObj,aRefSObj);
144 //---------------------------------------------------------------
148 //---------------------------------------------------------------
149 const string VISU::Result_i::myComment = "RESULT";
150 const char* VISU::Result_i::GetComment() const { return myComment.c_str();}
152 //---------------------------------------------------------------
154 ::Result_i(SALOMEDS::Study_ptr theStudy,
155 const ESourceId& theSourceId,
156 const ECreationId& theCreationId,
157 CORBA::Boolean theIsBuildImmediately,
158 CORBA::Boolean theIsBuildFields,
159 CORBA::Boolean theIsBuildMinMax,
160 CORBA::Boolean theIsBuildGroups):
161 myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)),
162 myCreationId(theCreationId),
163 mySourceId(theSourceId),
164 myIsBuildImmediately(theIsBuildImmediately),
165 myIsBuildFields(theIsBuildFields),
166 myIsBuildMinMax(theIsBuildMinMax),
167 myIsBuildGroups(theIsBuildGroups),
168 myIsEntitiesDone(false),
169 myIsFieldsDone(false),
170 myIsGroupsDone(false),
171 myIsMinMaxDone(false),
173 myIsBuildParts(false),
176 if(MYDEBUG) MESSAGE("Result_i::Result_i - this = "<<this);
177 myStudy = VISU::GetStudy(myStudyDocument);
181 //---------------------------------------------------------------
184 myIsEntitiesDone(false),
185 myIsFieldsDone(false),
186 myIsGroupsDone(false),
187 myIsMinMaxDone(false),
189 myIsBuildParts(false),
192 if(MYDEBUG) MESSAGE("Result_i::Result_i - this = "<<this);
196 //---------------------------------------------------------------
200 MESSAGE("Result_i::~Result_i() - this = "<<this);
201 if (GetSourceId() == eRestoredFile)
202 VISU::RemoveFile(myFileInfo.filePath().toLatin1().data());
206 //---------------------------------------------------------------
211 struct TRemoveFromStudy: public SALOME_Event
213 VISU::Result_i* myRemovable;
214 TRemoveFromStudy(VISU::Result_i* theRemovable):
215 myRemovable(theRemovable)
222 VISU::RemoveFromStudy(myRemovable->GetSObject(),false);
223 myRemovable->UnRegister();
227 // Remove the result with all presentations and other possible sub-objects
228 ProcessVoidEvent(new TRemoveFromStudy(this));
232 //---------------------------------------------------------------
235 ::ConnectObserver(TResultObserver* theObserver,
236 boost::signalslib::connection& theConnection)
238 if(theConnection.connected())
239 theConnection.disconnect();
242 myUpdateObserverSignal.connect(boost::bind(boost::bind(&TResultObserver::UpdateFromResult,
249 //---------------------------------------------------------------
254 struct TEvent: public SALOME_Event
256 VISU::Result_i::TUpdateObserverSignal& myUpdateObserverSignal;
258 TEvent(VISU::Result_i::TUpdateObserverSignal& theUpdateObserverSignal):
259 myUpdateObserverSignal(theUpdateObserverSignal)
266 myUpdateObserverSignal();
270 ProcessVoidEvent(new TEvent(myUpdateObserverSignal));
274 //---------------------------------------------------------------
280 size_t aSize = myInput->GetSize();
281 size_t aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
282 MESSAGE("Result_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<float(aResult));
284 }catch(std::exception& exc){
285 INFOS("Follow exception was occured :\n"<<exc.what());
287 INFOS("Unknown exception was occured!");
293 //---------------------------------------------------------------
298 if(MYDEBUG) MESSAGE("Result_i::Build - myIsAllDone = "<<myIsAllDone);
304 const VISU::TMeshMap& aMeshMap = myInput->GetMeshMap();
305 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
306 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
307 const string& aMeshName = aMeshMapIter->first;
308 const VISU::PMesh aMesh = aMeshMapIter->second;
309 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
310 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
312 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
313 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
314 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
315 const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
316 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
317 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
318 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
319 const string& aFieldName = aFieldMapIter->first;
320 const VISU::PField aField = aFieldMapIter->second;
321 const VISU::TValField& aValField = aField->myValField;
322 VISU::TValField::const_iterator aValFieldIter = aValField.begin();
323 for(; aValFieldIter != aValField.end(); aValFieldIter++){
324 int aTimeStamp = aValFieldIter->first;
326 myInput->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
327 }catch(std::exception& exc){
328 INFOS("Follow exception was occured :\n"<<exc.what());
330 INFOS("Unknown exception was occured!!!");
335 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
336 VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
337 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
338 const string& aGroupName = aGroupMapIter->first;
340 myInput->GetMeshOnGroup(aMeshName,aGroupName);
341 }catch(std::exception& exc){
342 INFOS("Follow exception was occured :\n"<<exc.what());
344 INFOS("Unknown exception was occured!!!");
348 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
349 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
350 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
351 const string& aFamilyName = aFamilyMapIter->first;
353 myInput->GetFamilyOnEntity(aMeshName,anEntity,aFamilyName);
354 }catch(std::exception& exc){
355 INFOS("Follow exception was occured :\n"<<exc.what());
357 INFOS("Unknown exception was occured!!!");
360 //Import mesh on entity
362 myInput->GetMeshOnEntity(aMeshName,anEntity);
363 }catch(std::exception& exc){
364 INFOS("Follow exception was occured :\n"<<exc.what());
366 INFOS("Unknown exception was occured!!!");
371 }catch(std::exception& exc){
372 INFOS("Follow exception was occured :\n"<<exc.what());
374 INFOS("Unknown exception was occured!!!");
380 //---------------------------------------------------------------
383 ::Build(CORBA::Boolean theIsBuildAll,
384 CORBA::Boolean theIsAtOnce)
389 if(Build(SALOMEDS::SObject::_nil(), theIsAtOnce)){
392 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
394 SALOMEDS::GenericAttribute_var anAttr;
395 SALOMEDS::AttributePixMap_var aPixmap;
396 SALOMEDS::AttributeUserID_var aId;
398 anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, "AttributePixMap" );
399 aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
400 aPixmap ->SetPixMap("ICON_TREE_RESULT");
402 std::string auid = "AttributeUserID";
403 auid += Kernel_Utils::GetGUID(Kernel_Utils::ObjectdID);
404 anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, auid.c_str() );
405 aId = SALOMEDS::AttributeUserID::_narrow( anAttr );
406 aId ->SetValue("VISU.RESULT");
417 //---------------------------------------------------------------
418 VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject,
419 CORBA::Boolean theIsAtOnce)
427 mySComponent = FindOrCreateVisuComponent(myStudyDocument);
428 CORBA::String_var aSComponentEntry = mySComponent->GetID();
429 CORBA::String_var anIOR(GetID());
431 aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s",
433 myFileInfo.filePath().toLatin1().data(),
434 GetInitFileName().c_str()); // Restoring of Python dump
435 std::string aResultEntry =
436 CreateAttributes(myStudy,
437 aSComponentEntry.in(),
442 aComment.toLatin1().data(),
444 mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str());
445 if(!CORBA::is_nil(theSObject)){
446 CORBA::String_var aString = theSObject->GetID();
447 CreateReference(myStudyDocument, aResultEntry, aString.in());
468 BuildFieldDataTree(this,
476 boost::thread aThread(boost::bind(boost::bind(&Result_i::BuildDataTree, this, _1),
484 //---------------------------------------------------------------
487 ::BuildDataTree(const std::string& theResultEntry)
500 boost::thread aThread(boost::bind(&BuildGroups,
510 boost::thread aThread(boost::bind(&BuildFieldDataTree,
521 //---------------------------------------------------------------
524 ::BuildAll(SALOMEDS::SObject_ptr theSObject)
526 if(MYDEBUG) MESSAGE("Result_i::Build");
530 }catch(std::exception& exc){
531 INFOS("Follow exception was occured :\n"<<exc.what());
534 INFOS("Unknown exception was occured!!!");
542 //---------------------------------------------------------------
545 ::Create(const char* theFileName)
548 myFileInfo.setFile(theFileName);
549 myFileName = myFileInfo.fileName().toLatin1().data();
552 SetInitFileName(myFileInfo.filePath().toLatin1().data());
553 SetName(VISU::GenerateName(myFileInfo.fileName().toLatin1().data()).toLatin1().data(), false);
556 if(mySourceId == eRestoredFile){
557 QString aTmpDir(SALOMEDS_Tool::GetTmpDir().c_str());
558 std::string aFileName = VISU::MakeFileName(myFileInfo.fileName().toLatin1().data(), this);
559 QString aPathToCopy(aTmpDir + aFileName.c_str());
560 if(!VISU::CopyFile(myFileInfo.absoluteFilePath().toLatin1().data(), aPathToCopy.toLatin1().data()))
563 myFileInfo.setFile(aPathToCopy);
564 myFileName = myFileInfo.fileName().toLatin1().data();
567 myInput.reset(CreateConvertor(myFileInfo.absoluteFilePath().toLatin1().data()));
570 if(myIsBuildImmediately)
571 Build(SALOMEDS::SObject::_nil());
574 }catch(std::exception& exc){
575 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
577 MSG(MYDEBUG,"Unknown exception !!!");
583 //---------------------------------------------------------------
586 ::Create(SALOMEDS::SObject_ptr theMedSObject)
588 if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOMEDS::SObject_ptr");
590 myInput.reset(CreateMEDConvertor(theMedSObject));
596 string aCompDataType = GetComponentDataType(theMedSObject);
597 myFileInfo.setFile(aCompDataType.c_str());
598 myFileName = VISU::GenerateName("aResult").toLatin1().data();
600 SetInitFileName(aCompDataType);
601 SetName(VISU::GenerateName(myFileInfo.fileName().toLatin1().data()).toLatin1().data(), false);
603 return Build(theMedSObject);
604 }catch(std::exception& exc){
605 INFOS("Follow exception was occured :\n"<<exc.what());
607 INFOS("Unknown exception was occured!!!");
613 //---------------------------------------------------------------
616 ::Create(SALOME_MED::FIELD_ptr theField)
618 if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOME_MED::FIELD_ptr");
620 myInput.reset(CreateMEDFieldConvertor(theField));
626 string aCompDataType = "MED";
627 myFileInfo.setFile(aCompDataType.c_str());
629 myFileName = VISU::GenerateName("aResult").toLatin1().data();
630 SetInitFileName(aCompDataType);
631 SetName(VISU::GenerateName(myFileInfo.fileName().toLatin1().data()).toLatin1().data(), false);
633 CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField);
634 SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR);
636 return Build(aFieldSObject);
637 }catch(std::exception& exc){
638 INFOS("Follow exception was occured :\n"<<exc.what());
640 INFOS("Unknown exception was occured!!!");
646 //---------------------------------------------------------------
649 ::Save(SALOMEDS::SComponent_ptr theComponent,
650 const std::string& theURL,
653 TFileNames& theFileNames,
654 TFileNames& theFiles)
656 switch(GetCreationId()){
657 case Result_i::eImportFile:
658 case Result_i::eCopyAndImportFile: {
659 INITMSG(MYDEBUG, "Result::Save - this = "<<this<<"\n");
660 INITMSGA(MYDEBUG, 0, "theIsMultiFile = "<<theIsMultiFile<<"; theIsASCII = "<<theIsASCII<<"\n");
663 if (theIsMultiFile) {
664 CORBA::String_var anURL = GetStudyDocument()->URL();
665 aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
668 std::string aFileName = aPrefix + "_" + GetFileName().c_str();
669 BEGMSG(MYDEBUG, "aFileName = '"<<aFileName<<"'\n");
671 std::string aFile = GetFileInfo().filePath().toLatin1().data();
672 BEGMSG(MYDEBUG, "aFile = '"<<aFile<<"'\n");
674 if(theIsMultiFile || theIsASCII){
675 std::string aPathToCopy(theURL + aFileName);
676 BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
678 if(!VISU::CopyFile(aFile, aPathToCopy))
682 HDFascii::ConvertFromHDFToASCII(const_cast<char*>(aPathToCopy.c_str()), true);
685 theFileNames.push_back(aFileName);
686 theFiles.push_back(aFile);
695 //---------------------------------------------------------------
698 ::CanCopy(SALOMEDS::SObject_ptr theObject)
700 switch(GetCreationId()){
701 case Result_i::eImportFile:
702 case Result_i::eCopyAndImportFile:
710 //---------------------------------------------------------------
713 ::CopyFrom(SALOMEDS::SObject_ptr theObject,
714 CORBA::Long& theObjectID,
715 const std::string& theTmpDir,
716 TFileNames& theFileNames)
718 if(!Storable::CopyFrom(theObject, theObjectID, theTmpDir, theFileNames))
721 SALOMEDS::Study_var aStudy = theObject->GetStudy();
722 CORBA::String_var anURL = aStudy->URL();
723 std::string aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
724 std::string aFileName = aPrefix + GetFileInfo().fileName().toLatin1().data();
726 static QString aCommand;
727 std::string aFilePath = theTmpDir + aFileName;
728 aCommand.sprintf(" %s %s", GetFileInfo().filePath().toLatin1().data(), aFilePath.c_str());
729 aCommand = QDir::convertSeparators( aCommand );
730 aCommand.prepend( COPY_COMMAND );
732 if(system(aCommand.toLatin1().data()) != 0) {
733 if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand.toLatin1().data());
737 SALOMEDS::SComponent_var aSComponent = aStudy->FindComponent("VISU");
739 theFileNames.push_back(aFileName);
745 //---------------------------------------------------------------
748 ::Restore(SALOMEDS::SObject_ptr theSObject,
749 const Storable::TRestoringMap& theMap,
750 const string& thePrefix,
751 CORBA::Boolean theIsMultiFile)
753 if(MYDEBUG) MESSAGE("Result_i::Restore - " << thePrefix);
754 mySObject = SALOMEDS::SObject::_duplicate(theSObject);
755 mySComponent = mySObject->GetFatherComponent();
756 myStudyDocument = theSObject->GetStudy();
757 myStudy = VISU::GetStudy(myStudyDocument);
759 myCreationId = ECreationId(Storable::FindValue(theMap, "myCreationId").toInt());
760 mySourceId = eRestoredFile;
761 if(myCreationId == eImportMed || myCreationId == eImportMedField)
762 mySourceId = eRestoredComponent;
764 myIsBuildFields = Storable::FindValue(theMap, "myIsBuildFields", "1").toInt();
765 myIsBuildMinMax = Storable::FindValue(theMap, "myIsBuildMinMax", "1").toInt();
766 myIsBuildGroups = Storable::FindValue(theMap, "myIsBuildGroups", "1").toInt();
768 myIsBuildImmediately = true;
771 myFileName = VISU::Storable::FindValue(theMap, "myName").toLatin1().data();
773 for (int i = 0; i < myFileName.length(); i++)
775 if (myFileName[i] == ':')
779 SetInitFileName(VISU::Storable::FindValue(theMap, "myInitFileName").toLatin1().data());
781 SALOMEDS::SObject_var aRefSObj, aTargetRefSObj;
782 if (theSObject->FindSubObject(1, aRefSObj) && aRefSObj->ReferencedObject(aTargetRefSObj)) {
783 if(MYDEBUG) MESSAGE("Result_i::GetInput - There is some reference.");
784 SALOMEDS::SComponent_var aCompRefSObj = aTargetRefSObj->GetFatherComponent();
785 CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
786 myFileInfo.setFile(aDataType.in());
787 if(MYDEBUG) MESSAGE("Result_i::GetInput - aDataType = " << aDataType);
788 Engines::EngineComponent_var aEngComp =
789 Base_i::myEnginesLifeCycle->FindOrLoad_Component("FactoryServer", aDataType.in());
790 if (CORBA::is_nil(aEngComp))
791 throw std::runtime_error("Restore - There is no aEngComp for the aDataType !!!");
792 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
793 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp);
794 aStudyBuilder->LoadWith(aCompRefSObj, aDriver);
795 // create field or MED converter
796 CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj);
797 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(aMedObject);
798 if (!CORBA::is_nil(aField)) {
799 // create field converter
800 myInput.reset(CreateMEDFieldConvertor(aField));
803 else if (strcmp(aDataType, "MED") == 0) {
804 // create MED converter
805 myInput.reset(CreateMEDConvertor(aTargetRefSObj));
809 throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!");
812 myFileInfo.setFile(thePrefix.c_str());
814 std::string aStudyPrefix ("");
815 if (theIsMultiFile) {
816 CORBA::String_var anURL(GetStudyDocument()->URL());
817 aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
819 if (!myFileInfo.isFile()) {
820 std::string aFileName = thePrefix + aStudyPrefix + "_" + myFileName;
821 myFileInfo.setFile(aFileName.c_str());
824 MESSAGE("Result_i::Restore - aFileName = " << myFileInfo.filePath().toLatin1().data() << "; " << myFileInfo.isFile());
826 if (HDFascii::isASCII(myFileInfo.filePath().toLatin1().data())) {
827 MESSAGE("ConvertFromASCIIToHDF(" << myFileInfo.filePath().toLatin1().data() << ")");
828 char* aResultPath = HDFascii::ConvertFromASCIIToHDF(myFileInfo.filePath().toLatin1().data());
829 MESSAGE("ConvertFromASCIIToHDF() DONE : " << aResultPath);
830 char* aHDFFileName = new char[strlen(aResultPath) + 19];
831 sprintf(aHDFFileName, "%shdf_from_ascii.hdf", aResultPath);
833 if (theIsMultiFile) { // set this file as new - temporary
834 static QString aCommand;
835 aCommand.sprintf(" %s %s%s",aHDFFileName, aResultPath, myFileInfo.baseName().toLatin1().data());
836 aCommand = QDir::convertSeparators( aCommand );
837 aCommand.prepend( MOVE_COMMAND );
839 if (system(aCommand.toLatin1().data()) == -1) {
840 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand.toLatin1().data());
843 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand.toLatin1().data());
845 myFileInfo.setFile(QString(aResultPath) + myFileInfo.baseName());
846 } else { // change current temporary file to the new: with hdf-format
847 static QString aCommand;
848 aCommand.sprintf(" %s %s\0",aHDFFileName, myFileInfo.filePath().toLatin1().data());
849 aCommand = QDir::convertSeparators( aCommand );
850 aCommand.prepend( MOVE_COMMAND );
852 if (system(aCommand.toLatin1().data()) == -1) {
853 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand.toLatin1().data());
856 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand.toLatin1().data());
858 SALOMEDS::ListOfFileNames_var anEmptyList = new SALOMEDS::ListOfFileNames;
859 SALOMEDS_Tool::RemoveTemporaryFiles(aResultPath, anEmptyList.in(), true);
861 mySourceId = eRestoredFile;
863 delete(aHDFFileName);
864 } else if (!theIsMultiFile) {
865 mySourceId = eRestoredFile;
867 mySourceId = eSavedFile;
869 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId);
870 myInput.reset(CreateConvertor(myFileInfo.filePath().toLatin1().data()));
872 myInput->BuildEntities();
874 myInput->BuildFields();
875 myIsFieldsDone = true;
877 myInput->BuildMinMax();
878 myIsMinMaxDone = true;
882 myInput->BuildGroups();
883 myIsGroupsDone = true;
887 aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s",
889 myFileInfo.filePath().toLatin1().data(),
890 GetInitFileName().c_str()); // Restoring of Python dump
891 SALOMEDS::GenericAttribute_var anAttr;
892 if (!theSObject->FindAttribute(anAttr, "AttributeString"))
893 throw std::runtime_error("Build - There is no AttributeString for the SObject !!!");
894 SALOMEDS::AttributeString_var aCmnt = SALOMEDS::AttributeString::_narrow(anAttr);
895 aCmnt->SetValue(aComment.toLatin1().data());
897 bool anIsBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
901 } catch(std::exception& exc) {
902 INFOS("Follow exception was occured :\n"<<exc.what());
904 INFOS("Unknown exception was occured!!!");
910 //---------------------------------------------------------------
911 VISU::Result_i::PInput
913 ::GetInput(const std::string& theMeshName,
914 VISU::Entity theEntity,
915 const std::string& theFieldName,
916 CORBA::Long theTimeStampNumber)
922 //---------------------------------------------------------------
929 (myIsBuildFields? myIsFieldsDone: true) &&
930 (myIsBuildMinMax? myIsMinMaxDone: true) &&
931 (myIsBuildGroups? myIsGroupsDone: true);
938 return myIsEntitiesDone;
943 ::SetBuildFields(CORBA::Boolean theIsBuildFields,
944 CORBA::Boolean theIsCalculateMinMax)
946 myIsBuildFields = theIsBuildFields;
948 myIsBuildMinMax = theIsCalculateMinMax;
950 myIsBuildMinMax = false;
955 ::SetBuildGroups(CORBA::Boolean theIsBuildGroups)
957 myIsBuildGroups = theIsBuildGroups;
964 return myIsFieldsDone;
971 return myIsGroupsDone;
978 return myIsMinMaxDone;
985 return myIsPartsDone;
989 //---------------------------------------------------------------
990 VISU::Result::EntityNames*
994 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
995 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
997 return aResult._retn();
999 aResult->length(aMeshMap.size());
1000 VISU::TMeshMap::const_iterator anIter = aMeshMap.begin();
1001 for(size_t anId = 0; anIter != aMeshMap.end(); anIter++, anId++){
1002 const std::string& aName = anIter->first;
1003 aResult[anId] = aName.c_str();
1006 return aResult._retn();
1010 //---------------------------------------------------------------
1011 VISU::Result::Entities*
1013 ::GetEntities(const char* theMeshName)
1015 VISU::Result::Entities_var anEntities = new VISU::Result::Entities();
1016 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1017 if(aMeshMap.empty())
1018 return anEntities._retn();
1020 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1021 if(anIter == aMeshMap.end())
1022 return anEntities._retn();
1024 const VISU::PMesh& aMesh = anIter->second;
1025 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1026 if(aMeshOnEntityMap.empty())
1027 return anEntities._retn();
1030 anEntities->length(aMeshOnEntityMap.size());
1031 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.begin();
1032 for(size_t anId = 0; anIter != aMeshOnEntityMap.end(); anIter++, anId++){
1033 const VISU::TEntity& anEntity = anIter->first;
1034 anEntities[anId] = VISU::Entity(anEntity);
1038 return anEntities._retn();
1042 //---------------------------------------------------------------
1043 VISU::Result::EntityNames*
1045 ::GetFamilies(const char* theMeshName,
1046 VISU::Entity theEntity)
1048 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1049 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1050 if(aMeshMap.empty())
1051 return aResult._retn();
1053 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1054 if(anIter == aMeshMap.end())
1055 return aResult._retn();
1057 const VISU::PMesh& aMesh = anIter->second;
1058 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1059 if(aMeshOnEntityMap.empty())
1060 return aResult._retn();
1063 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1064 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1065 if(anIter == aMeshOnEntityMap.end())
1066 return aResult._retn();
1068 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1069 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1070 if(aFamilyMap.empty())
1071 return aResult._retn();
1074 aResult->length(aFamilyMap.size());
1075 VISU::TFamilyMap::const_iterator anIter = aFamilyMap.begin();
1076 for(size_t anId = 0; anIter != aFamilyMap.end(); anIter++, anId++){
1077 const std::string& aName = anIter->first;
1078 aResult[anId] = aName.c_str();
1083 return aResult._retn();
1087 //---------------------------------------------------------------
1088 VISU::Result::EntityNames*
1090 ::GetGroups(const char* theMeshName)
1092 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1093 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1094 if(aMeshMap.empty())
1095 return aResult._retn();
1097 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1098 if(anIter == aMeshMap.end())
1099 return aResult._retn();
1101 const VISU::PMesh& aMesh = anIter->second;
1102 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1103 if(aGroupMap.empty())
1104 return aResult._retn();
1107 aResult->length(aGroupMap.size());
1108 VISU::TGroupMap::const_iterator anIter = aGroupMap.begin();
1109 for(size_t anId = 0; anIter != aGroupMap.end(); anIter++, anId++){
1110 const std::string& aName = anIter->first;
1111 aResult[anId] = aName.c_str();
1115 return aResult._retn();
1119 //---------------------------------------------------------------
1120 VISU::Result::EntityNames*
1122 ::GetFields(const char* theMeshName,
1123 VISU::Entity theEntity)
1125 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1126 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1127 if(aMeshMap.empty())
1128 return aResult._retn();
1130 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1131 if(anIter == aMeshMap.end())
1132 return aResult._retn();
1134 const VISU::PMesh& aMesh = anIter->second;
1135 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1136 if(aMeshOnEntityMap.empty())
1137 return aResult._retn();
1140 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1141 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1142 if(anIter == aMeshOnEntityMap.end())
1143 return aResult._retn();
1145 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1146 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1147 if(aFieldMap.empty())
1148 return aResult._retn();
1151 aResult->length(aFieldMap.size());
1152 VISU::TFieldMap::const_iterator anIter = aFieldMap.begin();
1153 for(size_t anId = 0; anIter != aFieldMap.end(); anIter++, anId++){
1154 const std::string& aName = anIter->first;
1155 aResult[anId] = aName.c_str();
1160 return aResult._retn();
1164 //---------------------------------------------------------------
1165 VISU::Result::TimeStampNumbers*
1167 ::GetTimeStampNumbers(const char* theMeshName,
1168 VISU::Entity theEntity,
1169 const char* theFieldName)
1171 VISU::Result::TimeStampNumbers_var aResult = new VISU::Result::TimeStampNumbers();
1172 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1173 if(aMeshMap.empty())
1174 return aResult._retn();
1176 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1177 if(anIter == aMeshMap.end())
1178 return aResult._retn();
1180 const VISU::PMesh& aMesh = anIter->second;
1181 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1182 if(aMeshOnEntityMap.empty())
1183 return aResult._retn();
1186 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1187 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1188 if(anIter == aMeshOnEntityMap.end())
1189 return aResult._retn();
1191 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1192 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1193 if(aFieldMap.empty())
1194 return aResult._retn();
1197 VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName);
1198 if(anIter == aFieldMap.end())
1199 return aResult._retn();
1202 const VISU::PField& aField = anIter->second;
1203 const VISU::TValField& aValField = aField->myValField;
1204 if(aValField.empty())
1205 return aResult._retn();
1208 aResult->length(aValField.size());
1209 VISU::TValField::const_iterator anIter = aValField.begin();
1210 for(size_t anId = 0; anIter != aValField.end(); anIter++, anId++){
1211 const vtkIdType& aTimeStampNumber = anIter->first;
1212 aResult[anId] = aTimeStampNumber;
1219 return aResult._retn();
1223 //---------------------------------------------------------------
1226 ::GetTimeStampValues(const char* theMeshName,
1227 VISU::Entity theEntity,
1228 const char* theFieldName)
1230 VISU::double_array_var aResult = new VISU::double_array();
1231 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1232 if(aMeshMap.empty())
1233 return aResult._retn();
1235 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1236 if(anIter == aMeshMap.end())
1237 return aResult._retn();
1239 const VISU::PMesh& aMesh = anIter->second;
1240 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1241 if(aMeshOnEntityMap.empty())
1242 return aResult._retn();
1245 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1246 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1247 if(anIter == aMeshOnEntityMap.end())
1248 return aResult._retn();
1250 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1251 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1252 if(aFieldMap.empty())
1253 return aResult._retn();
1256 VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName);
1257 if(anIter == aFieldMap.end())
1258 return aResult._retn();
1261 const VISU::PField& aField = anIter->second;
1262 const VISU::TValField& aValField = aField->myValField;
1263 if(aValField.empty())
1264 return aResult._retn();
1267 aResult->length(aValField.size());
1268 VISU::TValField::const_iterator anIter = aValField.begin();
1269 for(size_t anId = 0; anIter != aValField.end(); anIter++, anId++){
1270 const PValForTime& aValForTime = anIter->second;
1271 aResult[anId] = aValForTime->myTime.first;
1278 return aResult._retn();
1282 //---------------------------------------------------------------
1285 ::GetNumberOfComponents(const char* theMeshName,
1286 VISU::Entity theEntity,
1287 const char* theFieldName)
1289 CORBA::Long aResult = 0;
1290 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1291 if(aMeshMap.empty())
1294 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1295 if(anIter == aMeshMap.end())
1298 const VISU::PMesh& aMesh = anIter->second;
1299 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1300 if(aMeshOnEntityMap.empty())
1304 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1305 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1306 if(anIter == aMeshOnEntityMap.end())
1309 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1310 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1311 if(aFieldMap.empty())
1315 VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName);
1316 if(anIter == aFieldMap.end())
1320 const VISU::PField& aField = anIter->second;
1321 aResult = aField->myNbComp;
1330 //---------------------------------------------------------------
1331 VISU::Result::EntityNames*
1333 ::GetPartNames(const char* theMeshName)
1335 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1336 return aResult._retn();
1340 //---------------------------------------------------------------
1341 VISU::Result::Resolutions*
1343 ::GetResolutions(const char* theMeshName,
1344 const char* thePartName)
1346 VISU::Result::Resolutions_var aResult = new VISU::Result::Resolutions();
1347 return aResult._retn();
1351 //---------------------------------------------------------------
1352 VISU::Result::Resolution
1354 ::GetResolution(const char* theMeshName,
1355 const char* thePartName)
1357 return VISU::Result::HIDDEN;
1361 //---------------------------------------------------------------
1364 ::SetResolution(const char* theMeshName,
1365 const char* thePartName,
1366 VISU::Result::Resolution theResolution)
1370 //---------------------------------------------------------------
1373 ::New(SALOMEDS::Study_ptr theStudy,
1374 const ESourceId& theSourceId,
1375 const ECreationId& theCreationId,
1376 CORBA::Boolean theIsBuildImmediately,
1377 CORBA::Boolean theIsBuildFields,
1378 CORBA::Boolean theIsBuildMinMax,
1379 CORBA::Boolean theIsBuildGroups)
1381 return new RESULT_CLASS_NAME(theStudy,
1384 theIsBuildImmediately,
1391 //---------------------------------------------------------------
1394 ::StorableEngine(SALOMEDS::SObject_ptr theSObject,
1395 const Storable::TRestoringMap& theMap,
1396 const std::string& thePrefix,
1397 CORBA::Boolean theIsMultiFile)
1399 VISU::Result_i* aResult = new RESULT_CLASS_NAME();
1400 return aResult->Restore(theSObject, theMap, thePrefix, theIsMultiFile);
1404 //---------------------------------------------------------------
1407 ::ToStream(std::ostringstream& theStr)
1409 Storable::DataToStream(theStr,"myName", GetFileName().c_str());
1410 Storable::DataToStream(theStr,"myInitFileName", GetInitFileName().c_str());
1411 Storable::DataToStream(theStr,"myCreationId", myCreationId);
1412 Storable::DataToStream(theStr,"myIsBuildFields", myIsFieldsDone);
1413 Storable::DataToStream(theStr,"myIsBuildMinMax", myIsMinMaxDone);
1414 Storable::DataToStream(theStr,"myIsBuildGroups", myIsGroupsDone);
1417 //---------------------------------------------------------------
1421 ::ExportMED(const char* theTargetFileName)
1423 static QString aCommand;
1424 const char* aTempFileName = myFileInfo.absoluteFilePath().toLatin1();
1425 aCommand.sprintf(" %s %s", aTempFileName, theTargetFileName);
1426 aCommand = QDir::convertSeparators( aCommand );
1427 aCommand.prepend( COPY_COMMAND );
1429 if(system(aCommand.toLatin1().data()) != 0) {
1430 if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand.toLatin1().data());
1437 //---------------------------------------------------------------
1440 ::GetInitFileName() const
1442 return myInitFileName;
1448 ::SetInitFileName(const std::string& theFileName)
1450 myInitFileName = theFileName;
1454 //---------------------------------------------------------------
1457 ::GetFileName() const
1459 if(GetSourceId() == eFile)
1460 return VISU::MakeFileName(myFileName, this);
1468 ::GetFileInfo() const
1473 VISU::Result_i::ECreationId
1475 ::GetCreationId() const
1477 return myCreationId;
1481 VISU::Result_i::ESourceId
1483 ::GetSourceId() const
1489 //---------------------------------------------------------------
1494 CORBA::String_var anEntry = mySObject->GetID();
1495 return anEntry.in();
1498 SALOMEDS::SObject_var
1500 ::GetSObject() const
1507 ::GetStudyDocument() const
1509 return myStudyDocument;
1519 SALOMEDS::SComponent_var
1521 ::GetSComponent() const
1523 return mySComponent;
1528 ::GetEntry(const Storable::TRestoringMap& theRestoringMap)
1530 return Storable::FindEntry(myStudyDocument,
1536 //=======================================================================
1537 //function : GetAxisInfo
1539 //=======================================================================
1540 const VISU::Result_i::TAxisInfo*
1542 ::GetAxisInfo(const string& theMeshName,
1544 gp_Dir& thePlaneNormal)
1546 const TAxisInfo* components = NULL;
1548 if ( theAxis < AXIS_X || theAxis > AXIS_Z ) {
1549 MESSAGE(" Bad axis index " << theAxis );
1553 map< string, TGridInfo >::iterator name_info;
1554 name_info = myMeshName2GridInfoMap.find( theMeshName );
1555 TGridInfo * gInfo = 0;
1557 if ( name_info != myMeshName2GridInfoMap.end() )
1559 gInfo = & name_info->second;
1561 else if ( myInput && IsPossible() && theAxis >= AXIS_X && theAxis <= AXIS_Z )
1563 // check presence of theMeshName
1564 const VISU::TMeshMap& meshMap = myInput->GetMeshMap();
1566 VISU::TMeshMap::const_iterator aIter = meshMap.find( theMeshName );
1567 if ( aIter == meshMap.end() ) {
1568 MESSAGE("No mesh named " << theMeshName );
1571 theMesh = aIter->second;
1573 VISU::PUnstructuredGridIDMapper anIDMapper = myInput->GetMeshOnEntity(theMeshName,
1575 vtkUnstructuredGrid* aMesh = anIDMapper->GetUnstructuredGridOutput();
1577 if ( !aMesh || aMesh->GetNumberOfCells() == 0 ) {
1578 MESSAGE( "No cells in the mesh: " << theMeshName );
1582 if ( !theMesh->IsStructured() || theMesh->myIsPolarType ) {
1583 // define axis directions and min cell size in each direction
1584 const int nbAxes = 3;
1586 gp_Vec axDirs[ nbAxes ];
1587 float minSize[3] = { FLT_MAX, FLT_MAX, FLT_MAX };
1588 bool axesComputed = false;
1589 for ( vtkIdType iCell = 0; iCell < aMesh->GetNumberOfCells(); ++iCell ) {
1590 vtkCell* cell = aMesh->GetCell( iCell );
1592 if (cell->GetCellType() != VTK_HEXAHEDRON &&
1593 cell->GetCellType() != VTK_QUADRATIC_HEXAHEDRON )
1595 vtkPoints * points = cell->GetPoints();
1596 vtkFloatingPointType coords[ 4 ][3];
1597 points->GetPoint( 0, coords[0] );
1598 points->GetPoint( 1, coords[1] );
1599 points->GetPoint( 3, coords[2] );
1600 points->GetPoint( 4, coords[3] );
1601 gp_Pnt p0( coords[0][0], coords[0][1], coords[0][2] );
1602 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1603 vtkFloatingPointType* coo = coords[ iAx + 1 ];
1604 gp_Pnt p( coo[0], coo[1], coo[2] );
1606 vtkFloatingPointType size = p0.SquareDistance( p );
1607 if ( size > FLT_MIN && size < minSize[ iAx ] )
1608 minSize[ iAx ] = size;
1610 if ( !axesComputed ) {
1611 gp_Vec dir( p0, p );
1612 if ( dir.SquareMagnitude() <= gp::Resolution() ) {
1615 axDirs[ iAx ] = dir;
1618 if ( iAx == nbAxes )
1619 axesComputed = true;
1621 if ( !axesComputed ) {
1622 MESSAGE("No good hexahedrons in the mesh: " << theMeshName );
1626 // compute axes dirs
1627 gInfo = & myMeshName2GridInfoMap[ theMeshName ];
1628 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1629 int iPrev = ( iAx == 0 ) ? 2 : iAx - 1;
1630 int iNext = ( iAx == 2 ) ? 0 : iAx + 1;
1631 gInfo->myAxis[ iAx ] = axDirs[ iPrev ] ^ axDirs[ iNext ];
1634 // get and sort intermediate component values - projections of nodes
1635 // on axis direction; define bnd box
1636 set< vtkFloatingPointType > comps[ 3 ];
1638 vtkPoints * points = aMesh->GetPoints();
1639 vtkIdType iP, nbP = aMesh->GetNumberOfPoints();
1640 for ( iP = 0; iP < nbP; ++iP ) {
1641 vtkFloatingPointType coo[3];
1642 points->GetPoint( iP, coo );
1643 gp_Pnt p( coo[0], coo[1], coo[2] );
1645 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1646 const gp_Dir& dir = gInfo->myAxis[ iAx ];
1647 vtkFloatingPointType dot = dir.XYZ() * p.XYZ();
1648 comps[ iAx ].insert( dot );
1652 // find a range of projections of bnd box corners on each axis
1653 vtkFloatingPointType range[3], firstValue[3];
1654 double x[2],y[2],z[2];
1655 box.Get(x[0],y[0],z[0],x[1],y[1],z[1]);
1656 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1657 set< vtkFloatingPointType > bndComps;
1658 const gp_Dir& dir = gInfo->myAxis[ iAx ];
1659 for ( int iX = 0; iX < 2; ++iX ) {
1660 for ( int iY = 0; iY < 2; ++iY ) {
1661 for ( int iZ = 0; iZ < 2; ++iZ ) {
1662 gp_Pnt p( x[ iX ], y[ iY ], z[ iZ ] );
1663 vtkFloatingPointType dot = dir.XYZ() * p.XYZ();
1664 bndComps.insert( dot );
1668 firstValue[ iAx ] = *bndComps.begin();
1669 range[ iAx ] = *bndComps.rbegin() - *bndComps.begin();
1672 // compute component values
1673 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1674 list< vtkFloatingPointType > values;
1676 set< vtkFloatingPointType >& comp = comps[ iAx ];
1677 set< vtkFloatingPointType >::iterator val = comp.begin();
1678 vtkFloatingPointType bnd = -1., rng = range[ iAx ], first = firstValue[ iAx ];
1679 vtkFloatingPointType tol = 0.1 * sqrt( minSize[ iAx ]) / rng;
1680 for ( ; val != comp.end(); ++val ) {
1681 vtkFloatingPointType value = ( *val - first ) / rng;
1682 if ( value > bnd ) {
1683 values.push_back( value );
1688 // store values in gInfo
1689 vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ iAx ];
1690 myComp.resize( nbVals );
1691 list< vtkFloatingPointType >::iterator v = values.begin();
1692 for ( int i = 0; v != values.end(); ++v ){
1698 vtkIdType aMeshDim = theMesh->myDim;
1699 gInfo = & myMeshName2GridInfoMap[ theMeshName ];
1700 switch ( aMeshDim ) {
1702 gp_Dir aDir(0.0,0.0,1.0);
1703 gInfo->myAxis[ 2 ] = aDir;
1706 gp_Dir aDir(0.0,1.0,0.0);
1707 gInfo->myAxis[ 1 ] = aDir;
1710 gp_Dir aDir(1.0,0.0,0.0);
1711 gInfo->myAxis[ 0 ] = aDir;
1714 TStructuredId aStructuredId = theMesh->GetStructure();
1715 vector<vtkFloatingPointType> PointsCoords[3];
1716 vtkPoints* aPoints = aMesh->GetPoints();
1717 switch ( aMeshDim ) {
1719 TStructuredId aCoordIJK;
1720 vtkIdType nbZ = aStructuredId[2];
1721 for ( int i = 0; i < nbZ; i++ ) {
1722 aCoordIJK[2] = i + 1;
1723 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1724 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1725 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1726 PointsCoords[2].push_back(aPCoord[2]);
1730 TStructuredId aCoordIJK;
1731 vtkIdType nbJ = aStructuredId[1];
1732 for ( int i = 0; i < nbJ; i++ ) {
1733 aCoordIJK[1] = i + 1;
1734 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1735 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1736 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1737 PointsCoords[1].push_back(aPCoord[1]);
1741 TStructuredId aCoordIJK;
1742 vtkIdType nbI = aStructuredId[0];
1743 for ( int i = 0; i < nbI; i++ ) {
1744 aCoordIJK[0] = i + 1;
1745 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1746 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1747 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1748 PointsCoords[0].push_back(aPCoord[0]);
1751 for ( int i = 0; i < aMeshDim; i++ ) {
1752 vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ i ];
1753 int aSize = PointsCoords[i].size();
1755 vtkFloatingPointType aLen = PointsCoords[i][aSize-1] - PointsCoords[i][0];
1756 myComp.resize(aSize);
1758 for ( int k = 1; k < aSize; k++ ) {
1759 myComp[k]=myComp[k-1] + (PointsCoords[i][k]-PointsCoords[i][k-1])/aLen;
1766 // set return values
1768 thePlaneNormal = gInfo->myAxis[ theAxis ];
1769 components = & gInfo->myComponets[ theAxis ];
1775 SALOME_MED::MedFileInfo* VISU::Result_i::GetMEDFileInfo()
1777 SALOME_MED::MedFileInfo_var res = new SALOME_MED::MedFileInfo();
1779 QString fpath = myFileInfo.absoluteFilePath();
1780 res->fileName = fpath.toLatin1().constData();
1781 res->fileSize = myFileInfo.size();
1782 int major, minor, release;
1783 if( !MED::getMEDVersion( fpath.toLatin1().constData(), major, minor, release ) )
1791 res->release = release;