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
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_Result_i.cc
25 // Author : Alexey PETROV
28 #include "VISU_MultiResult_i.hh"
29 #include "VISU_ResultUtils.hh"
30 #include "VISU_Prs3d_i.hh"
32 #include "VISU_Convertor_impl.hxx"
33 #include "VISU_CorbaMedConvertor.hxx"
34 #include "VISU_ConvertorUtils.hxx"
35 #include "VISU_PipeLine.hxx"
37 #include "SUIT_ResourceMgr.h"
39 #include "SALOMEDS_Tool.hxx"
40 #include "HDFascii.hxx"
41 #include "Basics_Utils.hxx"
43 #include "SUIT_Session.h"
44 #include "SALOME_Event.h"
45 #include "SalomeApp_Study.h"
46 #include "SalomeApp_Application.h"
48 #include "MED_Factory.hxx"
50 #include <boost/thread/thread.hpp>
51 #include <boost/bind.hpp>
63 #include <vtkUnstructuredGrid.h>
66 #include <Bnd_Box.hxx>
69 static int MYDEBUG = 1;
71 static int MYDEBUG = 0;
78 //---------------------------------------------------------------
80 FindResult(SALOMEDS::SObject_ptr theSObject)
82 SALOMEDS::SComponent_var aSComponent = theSObject->GetFatherComponent();
83 SALOMEDS::SObject_var aFather = theSObject->GetFather();
84 CORBA::String_var aComponentID (aSComponent->GetID());
85 CORBA::String_var aFatherID (aFather->GetID());
87 while (strcmp(aComponentID, aFatherID) != 0) {
88 CORBA::Object_var anObject = SObjectToObject(aFather);
89 if (!CORBA::is_nil(anObject)) {
90 aResult = Result::_narrow(anObject);
91 if (!aResult->_is_nil()) return aResult;
93 aFather = aFather->GetFather();
94 aFatherID = aFather->GetID();
100 //---------------------------------------------------------------
102 GetResult(SALOMEDS::Study_ptr theStudy,
103 const std::string& theResultEntry)
105 Result_i* result = NULL;
106 if (!CORBA::is_nil(theStudy)) {
107 SALOMEDS::SComponent_var aSComponent = theStudy->FindComponent("VISU");
108 if (!CORBA::is_nil(aSComponent)) {
109 std::string compid = aSComponent->GetID();
110 std::string aResultEntry = theResultEntry;
111 if (theResultEntry.substr(0, compid.length()) != compid) aResultEntry = compid + theResultEntry.substr(compid.length());
112 SALOMEDS::SObject_var aSObject = theStudy->FindObjectID(aResultEntry.c_str());
113 CORBA::Object_var anObject = SObjectToObject(aSObject);
114 result = dynamic_cast<VISU::Result_i*>(GetServant(anObject).in());
121 //---------------------------------------------------------------
123 GetComponentDataType (SALOMEDS::SObject_ptr theSObject)
125 SALOMEDS::SComponent_var aCompRefSObj = theSObject->GetFatherComponent();
126 CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
127 return aDataType.in();
131 //---------------------------------------------------------------
133 CreateReference (SALOMEDS::Study_ptr theStudyDocument,
134 const string& theFatherEntry,
135 const string& theRefEntry)
137 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
138 SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry.c_str());
139 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(aFather);
140 SALOMEDS::SObject_var aRefSObj = theStudyDocument->FindObjectID(theRefEntry.c_str());
141 aStudyBuilder->Addreference(newObj,aRefSObj);
145 //---------------------------------------------------------------
149 //---------------------------------------------------------------
150 const string VISU::Result_i::myComment = "RESULT";
151 const char* VISU::Result_i::GetComment() const { return myComment.c_str();}
153 //---------------------------------------------------------------
155 ::Result_i(SALOMEDS::Study_ptr theStudy,
156 const ESourceId& theSourceId,
157 const ECreationId& theCreationId,
158 CORBA::Boolean theIsBuildImmediately,
159 CORBA::Boolean theIsBuildFields,
160 CORBA::Boolean theIsBuildMinMax,
161 CORBA::Boolean theIsBuildGroups):
162 myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)),
163 myCreationId(theCreationId),
164 mySourceId(theSourceId),
165 myIsBuildImmediately(theIsBuildImmediately),
166 myIsBuildFields(theIsBuildFields),
167 myIsBuildMinMax(theIsBuildMinMax),
168 myIsBuildGroups(theIsBuildGroups),
169 myIsEntitiesDone(false),
170 myIsFieldsDone(false),
171 myIsGroupsDone(false),
172 myIsMinMaxDone(false),
174 myIsBuildParts(false),
177 if(MYDEBUG) MESSAGE("Result_i::Result_i - this = "<<this);
178 myStudy = VISU::GetStudy(myStudyDocument);
182 //---------------------------------------------------------------
185 myIsEntitiesDone(false),
186 myIsFieldsDone(false),
187 myIsGroupsDone(false),
188 myIsMinMaxDone(false),
190 myIsBuildParts(false),
193 if(MYDEBUG) MESSAGE("Result_i::Result_i - this = "<<this);
197 //---------------------------------------------------------------
201 MESSAGE("Result_i::~Result_i() - this = "<<this);
202 if (GetSourceId() == eRestoredFile)
203 VISU::RemoveFile(myFileInfo.filePath().toLatin1().data());
207 //---------------------------------------------------------------
212 struct TRemoveFromStudy: public SALOME_Event
214 VISU::Result_i* myRemovable;
215 TRemoveFromStudy(VISU::Result_i* theRemovable):
216 myRemovable(theRemovable)
223 VISU::RemoveFromStudy(myRemovable->GetSObject(),false);
224 myRemovable->Destroy();
228 // Remove the result with all presentations and other possible sub-objects
229 ProcessVoidEvent(new TRemoveFromStudy(this));
233 //---------------------------------------------------------------
236 ::ConnectObserver(TResultObserver* theObserver,
237 boost::signalslib::connection& theConnection)
239 if(theConnection.connected())
240 theConnection.disconnect();
243 myUpdateObserverSignal.connect(boost::bind(boost::bind(&TResultObserver::UpdateFromResult,
250 //---------------------------------------------------------------
255 struct TEvent: public SALOME_Event
257 VISU::Result_i::TUpdateObserverSignal& myUpdateObserverSignal;
259 TEvent(VISU::Result_i::TUpdateObserverSignal& theUpdateObserverSignal):
260 myUpdateObserverSignal(theUpdateObserverSignal)
267 myUpdateObserverSignal();
271 ProcessVoidEvent(new TEvent(myUpdateObserverSignal));
275 //---------------------------------------------------------------
281 size_t aSize = myInput->GetSize();
282 size_t aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
283 MESSAGE("Result_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<float(aResult));
285 }catch(std::exception& exc){
286 INFOS("Follow exception was occured :\n"<<exc.what());
288 INFOS("Unknown exception was occured!");
294 //---------------------------------------------------------------
299 if(MYDEBUG) MESSAGE("Result_i::Build - myIsAllDone = "<<myIsAllDone);
305 const VISU::TMeshMap& aMeshMap = myInput->GetMeshMap();
306 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
307 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
308 const string& aMeshName = aMeshMapIter->first;
309 const VISU::PMesh aMesh = aMeshMapIter->second;
310 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
311 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
313 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
314 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
315 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
316 const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
317 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
318 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
319 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
320 const string& aFieldName = aFieldMapIter->first;
321 const VISU::PField aField = aFieldMapIter->second;
322 const VISU::TValField& aValField = aField->myValField;
323 VISU::TValField::const_iterator aValFieldIter = aValField.begin();
324 for(; aValFieldIter != aValField.end(); aValFieldIter++){
325 int aTimeStamp = aValFieldIter->first;
327 myInput->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
328 }catch(std::exception& exc){
329 INFOS("Follow exception was occured :\n"<<exc.what());
331 INFOS("Unknown exception was occured!!!");
336 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
337 VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
338 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
339 const string& aGroupName = aGroupMapIter->first;
341 myInput->GetMeshOnGroup(aMeshName,aGroupName);
342 }catch(std::exception& exc){
343 INFOS("Follow exception was occured :\n"<<exc.what());
345 INFOS("Unknown exception was occured!!!");
349 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
350 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
351 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
352 const string& aFamilyName = aFamilyMapIter->first;
354 myInput->GetFamilyOnEntity(aMeshName,anEntity,aFamilyName);
355 }catch(std::exception& exc){
356 INFOS("Follow exception was occured :\n"<<exc.what());
358 INFOS("Unknown exception was occured!!!");
361 //Import mesh on entity
363 myInput->GetMeshOnEntity(aMeshName,anEntity);
364 }catch(std::exception& exc){
365 INFOS("Follow exception was occured :\n"<<exc.what());
367 INFOS("Unknown exception was occured!!!");
372 }catch(std::exception& exc){
373 INFOS("Follow exception was occured :\n"<<exc.what());
375 INFOS("Unknown exception was occured!!!");
381 //---------------------------------------------------------------
384 ::Build(CORBA::Boolean theIsBuildAll,
385 CORBA::Boolean theIsAtOnce)
390 if(Build(SALOMEDS::SObject::_nil(), theIsAtOnce)){
393 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
395 SALOMEDS::GenericAttribute_var anAttr;
396 SALOMEDS::AttributePixMap_var aPixmap;
397 SALOMEDS::AttributeUserID_var aId;
399 anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, "AttributePixMap" );
400 aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
401 aPixmap ->SetPixMap("ICON_TREE_RESULT");
403 std::string auid = "AttributeUserID";
404 auid += Kernel_Utils::GetGUID(Kernel_Utils::ObjectdID);
405 anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, auid.c_str() );
406 aId = SALOMEDS::AttributeUserID::_narrow( anAttr );
407 aId ->SetValue("VISU.RESULT");
418 //---------------------------------------------------------------
419 VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject,
420 CORBA::Boolean theIsAtOnce)
428 mySComponent = FindOrCreateVisuComponent(myStudyDocument);
429 CORBA::String_var aSComponentEntry = mySComponent->GetID();
430 CORBA::String_var anIOR(GetID());
432 aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s",
434 myFileInfo.filePath().toLatin1().data(),
435 GetInitFileName().c_str()); // Restoring of Python dump
436 std::string aResultEntry =
437 CreateAttributes(myStudy,
438 aSComponentEntry.in(),
443 aComment.toLatin1().data(),
445 mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str());
446 if(!CORBA::is_nil(theSObject)){
447 CORBA::String_var aString = theSObject->GetID();
448 CreateReference(myStudyDocument, aResultEntry, aString.in());
469 BuildFieldDataTree(this,
477 boost::thread aThread(boost::bind(boost::bind(&Result_i::BuildDataTree, this, _1),
485 //---------------------------------------------------------------
488 ::BuildDataTree(const std::string& theResultEntry)
501 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();
772 SetInitFileName(VISU::Storable::FindValue(theMap, "myInitFileName").toLatin1().data());
774 SALOMEDS::SObject_var aRefSObj, aTargetRefSObj;
775 if (theSObject->FindSubObject(1, aRefSObj) && aRefSObj->ReferencedObject(aTargetRefSObj)) {
776 if(MYDEBUG) MESSAGE("Result_i::GetInput - There is some reference.");
777 SALOMEDS::SComponent_var aCompRefSObj = aTargetRefSObj->GetFatherComponent();
778 CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
779 myFileInfo.setFile(aDataType.in());
780 if(MYDEBUG) MESSAGE("Result_i::GetInput - aDataType = " << aDataType);
781 Engines::Component_var aEngComp =
782 Base_i::myEnginesLifeCycle->FindOrLoad_Component("FactoryServer", aDataType.in());
783 if (CORBA::is_nil(aEngComp))
784 throw std::runtime_error("Restore - There is no aEngComp for the aDataType !!!");
785 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
786 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp);
787 aStudyBuilder->LoadWith(aCompRefSObj, aDriver);
788 // create field or MED converter
789 CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj);
790 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(aMedObject);
791 if (!CORBA::is_nil(aField)) {
792 // create field converter
793 myInput.reset(CreateMEDFieldConvertor(aField));
796 else if (strcmp(aDataType, "MED") == 0) {
797 // create MED converter
798 myInput.reset(CreateMEDConvertor(aTargetRefSObj));
802 throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!");
805 myFileInfo.setFile(thePrefix.c_str());
807 std::string aStudyPrefix ("");
808 if (theIsMultiFile) {
809 CORBA::String_var anURL(GetStudyDocument()->URL());
810 aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
812 if (!myFileInfo.isFile()) {
813 std::string aFileName = thePrefix + aStudyPrefix + "_" + myFileName;
814 myFileInfo.setFile(aFileName.c_str());
817 MESSAGE("Result_i::Restore - aFileName = " << myFileInfo.filePath().toLatin1().data() << "; " << myFileInfo.isFile());
819 if (HDFascii::isASCII(myFileInfo.filePath().toLatin1().data())) {
820 MESSAGE("ConvertFromASCIIToHDF(" << myFileInfo.filePath().toLatin1().data() << ")");
821 char* aResultPath = HDFascii::ConvertFromASCIIToHDF(myFileInfo.filePath().toLatin1().data());
822 MESSAGE("ConvertFromASCIIToHDF() DONE : " << aResultPath);
823 char* aHDFFileName = new char[strlen(aResultPath) + 19];
824 sprintf(aHDFFileName, "%shdf_from_ascii.hdf", aResultPath);
826 if (theIsMultiFile) { // set this file as new - temporary
827 static QString aCommand;
828 aCommand.sprintf(" %s %s%s",aHDFFileName, aResultPath, myFileInfo.baseName().toLatin1().data());
829 aCommand = QDir::convertSeparators( aCommand );
830 aCommand.prepend( MOVE_COMMAND );
832 if (system(aCommand.toLatin1().data()) == -1) {
833 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand.toLatin1().data());
836 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand.toLatin1().data());
838 myFileInfo.setFile(QString(aResultPath) + myFileInfo.baseName());
839 } else { // change current temporary file to the new: with hdf-format
840 static QString aCommand;
841 aCommand.sprintf(" %s %s\0",aHDFFileName, myFileInfo.filePath().toLatin1().data());
842 aCommand = QDir::convertSeparators( aCommand );
843 aCommand.prepend( MOVE_COMMAND );
845 if (system(aCommand.toLatin1().data()) == -1) {
846 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand.toLatin1().data());
849 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand.toLatin1().data());
851 SALOMEDS::ListOfFileNames_var anEmptyList = new SALOMEDS::ListOfFileNames;
852 SALOMEDS_Tool::RemoveTemporaryFiles(aResultPath, anEmptyList.in(), true);
854 mySourceId = eRestoredFile;
856 delete(aHDFFileName);
857 } else if (!theIsMultiFile) {
858 mySourceId = eRestoredFile;
860 mySourceId = eSavedFile;
862 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId);
863 myInput.reset(CreateConvertor(myFileInfo.filePath().toLatin1().data()));
865 myInput->BuildEntities();
867 myInput->BuildFields();
868 myIsFieldsDone = true;
870 myInput->BuildMinMax();
871 myIsMinMaxDone = true;
875 myInput->BuildGroups();
876 myIsGroupsDone = true;
880 aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s",
882 myFileInfo.filePath().toLatin1().data(),
883 GetInitFileName().c_str()); // Restoring of Python dump
884 SALOMEDS::GenericAttribute_var anAttr;
885 if (!theSObject->FindAttribute(anAttr, "AttributeString"))
886 throw std::runtime_error("Build - There is no AttributeString for the SObject !!!");
887 SALOMEDS::AttributeString_var aCmnt = SALOMEDS::AttributeString::_narrow(anAttr);
888 aCmnt->SetValue(aComment.toLatin1().data());
890 bool anIsBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
894 } catch(std::exception& exc) {
895 INFOS("Follow exception was occured :\n"<<exc.what());
897 INFOS("Unknown exception was occured!!!");
903 //---------------------------------------------------------------
904 VISU::Result_i::PInput
906 ::GetInput(const std::string& theMeshName,
907 VISU::Entity theEntity,
908 const std::string& theFieldName,
909 CORBA::Long theTimeStampNumber)
915 //---------------------------------------------------------------
922 (myIsBuildFields? myIsFieldsDone: true) &&
923 (myIsBuildMinMax? myIsMinMaxDone: true) &&
924 (myIsBuildGroups? myIsGroupsDone: true);
931 return myIsEntitiesDone;
936 ::SetBuildFields(CORBA::Boolean theIsBuildFields,
937 CORBA::Boolean theIsCalculateMinMax)
939 myIsBuildFields = theIsBuildFields;
941 myIsBuildMinMax = theIsCalculateMinMax;
943 myIsBuildMinMax = false;
948 ::SetBuildGroups(CORBA::Boolean theIsBuildGroups)
950 myIsBuildGroups = theIsBuildGroups;
957 return myIsFieldsDone;
964 return myIsGroupsDone;
971 return myIsMinMaxDone;
978 return myIsPartsDone;
982 //---------------------------------------------------------------
983 VISU::Result::EntityNames*
987 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
988 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
990 return aResult._retn();
992 aResult->length(aMeshMap.size());
993 VISU::TMeshMap::const_iterator anIter = aMeshMap.begin();
994 for(size_t anId = 0; anIter != aMeshMap.end(); anIter++, anId++){
995 const std::string& aName = anIter->first;
996 aResult[anId] = aName.c_str();
999 return aResult._retn();
1003 //---------------------------------------------------------------
1004 VISU::Result::Entities*
1006 ::GetEntities(const char* theMeshName)
1008 VISU::Result::Entities_var anEntities = new VISU::Result::Entities();
1009 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1010 if(aMeshMap.empty())
1011 return anEntities._retn();
1013 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1014 if(anIter == aMeshMap.end())
1015 return anEntities._retn();
1017 const VISU::PMesh& aMesh = anIter->second;
1018 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1019 if(aMeshOnEntityMap.empty())
1020 return anEntities._retn();
1023 anEntities->length(aMeshOnEntityMap.size());
1024 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.begin();
1025 for(size_t anId = 0; anIter != aMeshOnEntityMap.end(); anIter++, anId++){
1026 const VISU::TEntity& anEntity = anIter->first;
1027 anEntities[anId] = VISU::Entity(anEntity);
1031 return anEntities._retn();
1035 //---------------------------------------------------------------
1036 VISU::Result::EntityNames*
1038 ::GetFamilies(const char* theMeshName,
1039 VISU::Entity theEntity)
1041 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1042 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1043 if(aMeshMap.empty())
1044 return aResult._retn();
1046 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1047 if(anIter == aMeshMap.end())
1048 return aResult._retn();
1050 const VISU::PMesh& aMesh = anIter->second;
1051 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1052 if(aMeshOnEntityMap.empty())
1053 return aResult._retn();
1056 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1057 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1058 if(anIter == aMeshOnEntityMap.end())
1059 return aResult._retn();
1061 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1062 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1063 if(aFamilyMap.empty())
1064 return aResult._retn();
1067 aResult->length(aFamilyMap.size());
1068 VISU::TFamilyMap::const_iterator anIter = aFamilyMap.begin();
1069 for(size_t anId = 0; anIter != aFamilyMap.end(); anIter++, anId++){
1070 const std::string& aName = anIter->first;
1071 aResult[anId] = aName.c_str();
1076 return aResult._retn();
1080 //---------------------------------------------------------------
1081 VISU::Result::EntityNames*
1083 ::GetGroups(const char* theMeshName)
1085 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1086 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1087 if(aMeshMap.empty())
1088 return aResult._retn();
1090 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1091 if(anIter == aMeshMap.end())
1092 return aResult._retn();
1094 const VISU::PMesh& aMesh = anIter->second;
1095 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1096 if(aGroupMap.empty())
1097 return aResult._retn();
1100 aResult->length(aGroupMap.size());
1101 VISU::TGroupMap::const_iterator anIter = aGroupMap.begin();
1102 for(size_t anId = 0; anIter != aGroupMap.end(); anIter++, anId++){
1103 const std::string& aName = anIter->first;
1104 aResult[anId] = aName.c_str();
1108 return aResult._retn();
1112 //---------------------------------------------------------------
1113 VISU::Result::EntityNames*
1115 ::GetFields(const char* theMeshName,
1116 VISU::Entity theEntity)
1118 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1119 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1120 if(aMeshMap.empty())
1121 return aResult._retn();
1123 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1124 if(anIter == aMeshMap.end())
1125 return aResult._retn();
1127 const VISU::PMesh& aMesh = anIter->second;
1128 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1129 if(aMeshOnEntityMap.empty())
1130 return aResult._retn();
1133 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1134 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1135 if(anIter == aMeshOnEntityMap.end())
1136 return aResult._retn();
1138 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1139 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1140 if(aFieldMap.empty())
1141 return aResult._retn();
1144 aResult->length(aFieldMap.size());
1145 VISU::TFieldMap::const_iterator anIter = aFieldMap.begin();
1146 for(size_t anId = 0; anIter != aFieldMap.end(); anIter++, anId++){
1147 const std::string& aName = anIter->first;
1148 aResult[anId] = aName.c_str();
1153 return aResult._retn();
1157 //---------------------------------------------------------------
1158 VISU::Result::TimeStampNumbers*
1160 ::GetTimeStampNumbers(const char* theMeshName,
1161 VISU::Entity theEntity,
1162 const char* theFieldName)
1164 VISU::Result::TimeStampNumbers_var aResult = new VISU::Result::TimeStampNumbers();
1165 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1166 if(aMeshMap.empty())
1167 return aResult._retn();
1169 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1170 if(anIter == aMeshMap.end())
1171 return aResult._retn();
1173 const VISU::PMesh& aMesh = anIter->second;
1174 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1175 if(aMeshOnEntityMap.empty())
1176 return aResult._retn();
1179 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1180 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1181 if(anIter == aMeshOnEntityMap.end())
1182 return aResult._retn();
1184 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1185 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1186 if(aFieldMap.empty())
1187 return aResult._retn();
1190 VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName);
1191 if(anIter == aFieldMap.end())
1192 return aResult._retn();
1195 const VISU::PField& aField = anIter->second;
1196 const VISU::TValField& aValField = aField->myValField;
1197 if(aValField.empty())
1198 return aResult._retn();
1201 aResult->length(aValField.size());
1202 VISU::TValField::const_iterator anIter = aValField.begin();
1203 for(size_t anId = 0; anIter != aValField.end(); anIter++, anId++){
1204 const vtkIdType& aTimeStampNumber = anIter->first;
1205 aResult[anId] = aTimeStampNumber;
1212 return aResult._retn();
1216 //---------------------------------------------------------------
1219 ::GetNumberOfComponents(const char* theMeshName,
1220 VISU::Entity theEntity,
1221 const char* theFieldName)
1223 CORBA::Long aResult = 0;
1224 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1225 if(aMeshMap.empty())
1228 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1229 if(anIter == aMeshMap.end())
1232 const VISU::PMesh& aMesh = anIter->second;
1233 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1234 if(aMeshOnEntityMap.empty())
1238 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1239 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1240 if(anIter == aMeshOnEntityMap.end())
1243 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1244 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1245 if(aFieldMap.empty())
1249 VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName);
1250 if(anIter == aFieldMap.end())
1254 const VISU::PField& aField = anIter->second;
1255 aResult = aField->myNbComp;
1264 //---------------------------------------------------------------
1265 VISU::Result::EntityNames*
1267 ::GetPartNames(const char* theMeshName)
1269 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1270 return aResult._retn();
1274 //---------------------------------------------------------------
1275 VISU::Result::Resolutions*
1277 ::GetResolutions(const char* theMeshName,
1278 const char* thePartName)
1280 VISU::Result::Resolutions_var aResult = new VISU::Result::Resolutions();
1281 return aResult._retn();
1285 //---------------------------------------------------------------
1286 VISU::Result::Resolution
1288 ::GetResolution(const char* theMeshName,
1289 const char* thePartName)
1291 return VISU::Result::HIDDEN;
1295 //---------------------------------------------------------------
1298 ::SetResolution(const char* theMeshName,
1299 const char* thePartName,
1300 VISU::Result::Resolution theResolution)
1304 //---------------------------------------------------------------
1307 ::New(SALOMEDS::Study_ptr theStudy,
1308 const ESourceId& theSourceId,
1309 const ECreationId& theCreationId,
1310 CORBA::Boolean theIsBuildImmediately,
1311 CORBA::Boolean theIsBuildFields,
1312 CORBA::Boolean theIsBuildMinMax,
1313 CORBA::Boolean theIsBuildGroups)
1315 return new RESULT_CLASS_NAME(theStudy,
1318 theIsBuildImmediately,
1325 //---------------------------------------------------------------
1328 ::StorableEngine(SALOMEDS::SObject_ptr theSObject,
1329 const Storable::TRestoringMap& theMap,
1330 const std::string& thePrefix,
1331 CORBA::Boolean theIsMultiFile)
1333 VISU::Result_i* aResult = new RESULT_CLASS_NAME();
1334 return aResult->Restore(theSObject, theMap, thePrefix, theIsMultiFile);
1338 //---------------------------------------------------------------
1341 ::ToStream(std::ostringstream& theStr)
1343 Storable::DataToStream(theStr,"myName", GetFileName().c_str());
1344 Storable::DataToStream(theStr,"myInitFileName", GetInitFileName().c_str());
1345 Storable::DataToStream(theStr,"myCreationId", myCreationId);
1346 Storable::DataToStream(theStr,"myIsBuildFields", myIsFieldsDone);
1347 Storable::DataToStream(theStr,"myIsBuildMinMax", myIsMinMaxDone);
1348 Storable::DataToStream(theStr,"myIsBuildGroups", myIsGroupsDone);
1351 //---------------------------------------------------------------
1355 ::ExportMED(const char* theTargetFileName)
1357 static QString aCommand;
1358 const char* aTempFileName = myFileInfo.absoluteFilePath().toLatin1();
1359 aCommand.sprintf(" %s %s", aTempFileName, theTargetFileName);
1360 aCommand = QDir::convertSeparators( aCommand );
1361 aCommand.prepend( COPY_COMMAND );
1363 if(system(aCommand.toLatin1().data()) != 0) {
1364 if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand.toLatin1().data());
1371 //---------------------------------------------------------------
1374 ::GetInitFileName() const
1376 return myInitFileName;
1382 ::SetInitFileName(const std::string& theFileName)
1384 myInitFileName = theFileName;
1388 //---------------------------------------------------------------
1391 ::GetFileName() const
1393 if(GetSourceId() == eFile)
1394 return VISU::MakeFileName(myFileName, this);
1402 ::GetFileInfo() const
1407 VISU::Result_i::ECreationId
1409 ::GetCreationId() const
1411 return myCreationId;
1415 VISU::Result_i::ESourceId
1417 ::GetSourceId() const
1423 //---------------------------------------------------------------
1428 CORBA::String_var anEntry = mySObject->GetID();
1429 return anEntry.in();
1432 SALOMEDS::SObject_var
1434 ::GetSObject() const
1441 ::GetStudyDocument() const
1443 return myStudyDocument;
1453 SALOMEDS::SComponent_var
1455 ::GetSComponent() const
1457 return mySComponent;
1462 ::GetEntry(const Storable::TRestoringMap& theRestoringMap)
1464 return Storable::FindEntry(myStudyDocument,
1470 //=======================================================================
1471 //function : GetAxisInfo
1473 //=======================================================================
1474 const VISU::Result_i::TAxisInfo*
1476 ::GetAxisInfo(const string& theMeshName,
1478 gp_Dir& thePlaneNormal)
1480 const TAxisInfo* components = NULL;
1482 if ( theAxis < AXIS_X || theAxis > AXIS_Z ) {
1483 MESSAGE(" Bad axis index " << theAxis );
1487 map< string, TGridInfo >::iterator name_info;
1488 name_info = myMeshName2GridInfoMap.find( theMeshName );
1489 TGridInfo * gInfo = 0;
1491 if ( name_info != myMeshName2GridInfoMap.end() )
1493 gInfo = & name_info->second;
1495 else if ( myInput && IsPossible() && theAxis >= AXIS_X && theAxis <= AXIS_Z )
1497 // check presence of theMeshName
1498 const VISU::TMeshMap& meshMap = myInput->GetMeshMap();
1500 VISU::TMeshMap::const_iterator aIter = meshMap.find( theMeshName );
1501 if ( aIter == meshMap.end() ) {
1502 MESSAGE("No mesh named " << theMeshName );
1505 theMesh = aIter->second;
1507 VISU::PUnstructuredGridIDMapper anIDMapper = myInput->GetMeshOnEntity(theMeshName,
1509 vtkUnstructuredGrid* aMesh = anIDMapper->GetUnstructuredGridOutput();
1511 if ( !aMesh || aMesh->GetNumberOfCells() == 0 ) {
1512 MESSAGE( "No cells in the mesh: " << theMeshName );
1516 if ( !theMesh->IsStructured() || theMesh->myIsPolarType ) {
1517 // define axis directions and min cell size in each direction
1518 const int nbAxes = 3;
1520 gp_Vec axDirs[ nbAxes ];
1521 float minSize[3] = { FLT_MAX, FLT_MAX, FLT_MAX };
1522 bool axesComputed = false;
1523 for ( vtkIdType iCell = 0; iCell < aMesh->GetNumberOfCells(); ++iCell ) {
1524 vtkCell* cell = aMesh->GetCell( iCell );
1526 if (cell->GetCellType() != VTK_HEXAHEDRON &&
1527 cell->GetCellType() != VTK_QUADRATIC_HEXAHEDRON )
1529 vtkPoints * points = cell->GetPoints();
1530 vtkFloatingPointType coords[ 4 ][3];
1531 points->GetPoint( 0, coords[0] );
1532 points->GetPoint( 1, coords[1] );
1533 points->GetPoint( 3, coords[2] );
1534 points->GetPoint( 4, coords[3] );
1535 gp_Pnt p0( coords[0][0], coords[0][1], coords[0][2] );
1536 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1537 vtkFloatingPointType* coo = coords[ iAx + 1 ];
1538 gp_Pnt p( coo[0], coo[1], coo[2] );
1540 vtkFloatingPointType size = p0.SquareDistance( p );
1541 if ( size > FLT_MIN && size < minSize[ iAx ] )
1542 minSize[ iAx ] = size;
1544 if ( !axesComputed ) {
1545 gp_Vec dir( p0, p );
1546 if ( dir.SquareMagnitude() <= gp::Resolution() ) {
1549 axDirs[ iAx ] = dir;
1552 if ( iAx == nbAxes )
1553 axesComputed = true;
1555 if ( !axesComputed ) {
1556 MESSAGE("No good hexahedrons in the mesh: " << theMeshName );
1560 // compute axes dirs
1561 gInfo = & myMeshName2GridInfoMap[ theMeshName ];
1562 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1563 int iPrev = ( iAx == 0 ) ? 2 : iAx - 1;
1564 int iNext = ( iAx == 2 ) ? 0 : iAx + 1;
1565 gInfo->myAxis[ iAx ] = axDirs[ iPrev ] ^ axDirs[ iNext ];
1568 // get and sort intermediate component values - projections of nodes
1569 // on axis direction; define bnd box
1570 set< vtkFloatingPointType > comps[ 3 ];
1572 vtkPoints * points = aMesh->GetPoints();
1573 vtkIdType iP, nbP = aMesh->GetNumberOfPoints();
1574 for ( iP = 0; iP < nbP; ++iP ) {
1575 vtkFloatingPointType coo[3];
1576 points->GetPoint( iP, coo );
1577 gp_Pnt p( coo[0], coo[1], coo[2] );
1579 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1580 const gp_Dir& dir = gInfo->myAxis[ iAx ];
1581 vtkFloatingPointType dot = dir.XYZ() * p.XYZ();
1582 comps[ iAx ].insert( dot );
1586 // find a range of projections of bnd box corners on each axis
1587 vtkFloatingPointType range[3], firstValue[3];
1588 double x[2],y[2],z[2];
1589 box.Get(x[0],y[0],z[0],x[1],y[1],z[1]);
1590 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1591 set< vtkFloatingPointType > bndComps;
1592 const gp_Dir& dir = gInfo->myAxis[ iAx ];
1593 for ( int iX = 0; iX < 2; ++iX ) {
1594 for ( int iY = 0; iY < 2; ++iY ) {
1595 for ( int iZ = 0; iZ < 2; ++iZ ) {
1596 gp_Pnt p( x[ iX ], y[ iY ], z[ iZ ] );
1597 vtkFloatingPointType dot = dir.XYZ() * p.XYZ();
1598 bndComps.insert( dot );
1602 firstValue[ iAx ] = *bndComps.begin();
1603 range[ iAx ] = *bndComps.rbegin() - *bndComps.begin();
1606 // compute component values
1607 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1608 list< vtkFloatingPointType > values;
1610 set< vtkFloatingPointType >& comp = comps[ iAx ];
1611 set< vtkFloatingPointType >::iterator val = comp.begin();
1612 vtkFloatingPointType bnd = -1., rng = range[ iAx ], first = firstValue[ iAx ];
1613 vtkFloatingPointType tol = 0.1 * sqrt( minSize[ iAx ]) / rng;
1614 for ( ; val != comp.end(); ++val ) {
1615 vtkFloatingPointType value = ( *val - first ) / rng;
1616 if ( value > bnd ) {
1617 values.push_back( value );
1622 // store values in gInfo
1623 vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ iAx ];
1624 myComp.resize( nbVals );
1625 list< vtkFloatingPointType >::iterator v = values.begin();
1626 for ( int i = 0; v != values.end(); ++v ){
1632 vtkIdType aMeshDim = theMesh->myDim;
1633 gInfo = & myMeshName2GridInfoMap[ theMeshName ];
1634 switch ( aMeshDim ) {
1636 gp_Dir aDir(0.0,0.0,1.0);
1637 gInfo->myAxis[ 2 ] = aDir;
1640 gp_Dir aDir(0.0,1.0,0.0);
1641 gInfo->myAxis[ 1 ] = aDir;
1644 gp_Dir aDir(1.0,0.0,0.0);
1645 gInfo->myAxis[ 0 ] = aDir;
1648 TStructuredId aStructuredId = theMesh->GetStructure();
1649 vector<vtkFloatingPointType> PointsCoords[3];
1650 vtkPoints* aPoints = aMesh->GetPoints();
1651 switch ( aMeshDim ) {
1653 TStructuredId aCoordIJK;
1654 vtkIdType nbZ = aStructuredId[2];
1655 for ( int i = 0; i < nbZ; i++ ) {
1656 aCoordIJK[2] = i + 1;
1657 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1658 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1659 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1660 PointsCoords[2].push_back(aPCoord[2]);
1664 TStructuredId aCoordIJK;
1665 vtkIdType nbJ = aStructuredId[1];
1666 for ( int i = 0; i < nbJ; i++ ) {
1667 aCoordIJK[1] = i + 1;
1668 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1669 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1670 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1671 PointsCoords[1].push_back(aPCoord[1]);
1675 TStructuredId aCoordIJK;
1676 vtkIdType nbI = aStructuredId[0];
1677 for ( int i = 0; i < nbI; i++ ) {
1678 aCoordIJK[0] = i + 1;
1679 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1680 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1681 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1682 PointsCoords[0].push_back(aPCoord[0]);
1685 for ( int i = 0; i < aMeshDim; i++ ) {
1686 vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ i ];
1687 int aSize = PointsCoords[i].size();
1689 vtkFloatingPointType aLen = PointsCoords[i][aSize-1] - PointsCoords[i][0];
1690 myComp.resize(aSize);
1692 for ( int k = 1; k < aSize; k++ ) {
1693 myComp[k]=myComp[k-1] + (PointsCoords[i][k]-PointsCoords[i][k-1])/aLen;
1700 // set return values
1702 thePlaneNormal = gInfo->myAxis[ theAxis ];
1703 components = & gInfo->myComponets[ theAxis ];
1709 SALOME_MED::MedFileInfo* VISU::Result_i::GetMEDFileInfo()
1711 SALOME_MED::MedFileInfo_var res = new SALOME_MED::MedFileInfo();
1713 QString fpath = myFileInfo.absoluteFilePath();
1714 res->fileName = fpath.toLatin1().constData();
1715 res->fileSize = myFileInfo.size();
1716 int major, minor, release;
1717 if( !MED::getMEDVersion( fpath.toLatin1().constData(), major, minor, release ) )
1725 res->release = release;