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->Destroy();
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,
509 boost::thread aThread(boost::bind(&BuildFieldDataTree,
520 //---------------------------------------------------------------
523 ::BuildAll(SALOMEDS::SObject_ptr theSObject)
525 if(MYDEBUG) MESSAGE("Result_i::Build");
529 }catch(std::exception& exc){
530 INFOS("Follow exception was occured :\n"<<exc.what());
533 INFOS("Unknown exception was occured!!!");
541 //---------------------------------------------------------------
544 ::Create(const char* theFileName)
547 myFileInfo.setFile(theFileName);
548 myFileName = myFileInfo.fileName().toLatin1().data();
551 SetInitFileName(myFileInfo.filePath().toLatin1().data());
552 SetName(VISU::GenerateName(myFileInfo.fileName().toLatin1().data()).toLatin1().data(), false);
555 if(mySourceId == eRestoredFile){
556 QString aTmpDir(SALOMEDS_Tool::GetTmpDir().c_str());
557 std::string aFileName = VISU::MakeFileName(myFileInfo.fileName().toLatin1().data(), this);
558 QString aPathToCopy(aTmpDir + aFileName.c_str());
559 if(!VISU::CopyFile(myFileInfo.absoluteFilePath().toLatin1().data(), aPathToCopy.toLatin1().data()))
562 myFileInfo.setFile(aPathToCopy);
563 myFileName = myFileInfo.fileName().toLatin1().data();
566 myInput.reset(CreateConvertor(myFileInfo.absoluteFilePath().toLatin1().data()));
569 if(myIsBuildImmediately)
570 Build(SALOMEDS::SObject::_nil());
573 }catch(std::exception& exc){
574 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
576 MSG(MYDEBUG,"Unknown exception !!!");
582 //---------------------------------------------------------------
585 ::Create(SALOMEDS::SObject_ptr theMedSObject)
587 if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOMEDS::SObject_ptr");
589 myInput.reset(CreateMEDConvertor(theMedSObject));
595 string aCompDataType = GetComponentDataType(theMedSObject);
596 myFileInfo.setFile(aCompDataType.c_str());
597 myFileName = VISU::GenerateName("aResult").toLatin1().data();
599 SetInitFileName(aCompDataType);
600 SetName(VISU::GenerateName(myFileInfo.fileName().toLatin1().data()).toLatin1().data(), false);
602 return Build(theMedSObject);
603 }catch(std::exception& exc){
604 INFOS("Follow exception was occured :\n"<<exc.what());
606 INFOS("Unknown exception was occured!!!");
612 //---------------------------------------------------------------
615 ::Create(SALOME_MED::FIELD_ptr theField)
617 if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOME_MED::FIELD_ptr");
619 myInput.reset(CreateMEDFieldConvertor(theField));
625 string aCompDataType = "MED";
626 myFileInfo.setFile(aCompDataType.c_str());
628 myFileName = VISU::GenerateName("aResult").toLatin1().data();
629 SetInitFileName(aCompDataType);
630 SetName(VISU::GenerateName(myFileInfo.fileName().toLatin1().data()).toLatin1().data(), false);
632 CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField);
633 SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR);
635 return Build(aFieldSObject);
636 }catch(std::exception& exc){
637 INFOS("Follow exception was occured :\n"<<exc.what());
639 INFOS("Unknown exception was occured!!!");
645 //---------------------------------------------------------------
648 ::Save(SALOMEDS::SComponent_ptr theComponent,
649 const std::string& theURL,
652 TFileNames& theFileNames,
653 TFileNames& theFiles)
655 switch(GetCreationId()){
656 case Result_i::eImportFile:
657 case Result_i::eCopyAndImportFile: {
658 INITMSG(MYDEBUG, "Result::Save - this = "<<this<<"\n");
659 INITMSGA(MYDEBUG, 0, "theIsMultiFile = "<<theIsMultiFile<<"; theIsASCII = "<<theIsASCII<<"\n");
662 if (theIsMultiFile) {
663 CORBA::String_var anURL = GetStudyDocument()->URL();
664 aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
667 std::string aFileName = aPrefix + "_" + GetFileName().c_str();
668 BEGMSG(MYDEBUG, "aFileName = '"<<aFileName<<"'\n");
670 std::string aFile = GetFileInfo().filePath().toLatin1().data();
671 BEGMSG(MYDEBUG, "aFile = '"<<aFile<<"'\n");
673 if(theIsMultiFile || theIsASCII){
674 std::string aPathToCopy(theURL + aFileName);
675 BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
677 if(!VISU::CopyFile(aFile, aPathToCopy))
681 HDFascii::ConvertFromHDFToASCII(const_cast<char*>(aPathToCopy.c_str()), true);
684 theFileNames.push_back(aFileName);
685 theFiles.push_back(aFile);
694 //---------------------------------------------------------------
697 ::CanCopy(SALOMEDS::SObject_ptr theObject)
699 switch(GetCreationId()){
700 case Result_i::eImportFile:
701 case Result_i::eCopyAndImportFile:
709 //---------------------------------------------------------------
712 ::CopyFrom(SALOMEDS::SObject_ptr theObject,
713 CORBA::Long& theObjectID,
714 const std::string& theTmpDir,
715 TFileNames& theFileNames)
717 if(!Storable::CopyFrom(theObject, theObjectID, theTmpDir, theFileNames))
720 SALOMEDS::Study_var aStudy = theObject->GetStudy();
721 CORBA::String_var anURL = aStudy->URL();
722 std::string aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
723 std::string aFileName = aPrefix + GetFileInfo().fileName().toLatin1().data();
725 static QString aCommand;
726 std::string aFilePath = theTmpDir + aFileName;
727 aCommand.sprintf(" %s %s", GetFileInfo().filePath().toLatin1().data(), aFilePath.c_str());
728 aCommand = QDir::convertSeparators( aCommand );
729 aCommand.prepend( COPY_COMMAND );
731 if(system(aCommand.toLatin1().data()) != 0) {
732 if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand.toLatin1().data());
736 SALOMEDS::SComponent_var aSComponent = aStudy->FindComponent("VISU");
738 theFileNames.push_back(aFileName);
744 //---------------------------------------------------------------
747 ::Restore(SALOMEDS::SObject_ptr theSObject,
748 const Storable::TRestoringMap& theMap,
749 const string& thePrefix,
750 CORBA::Boolean theIsMultiFile)
752 if(MYDEBUG) MESSAGE("Result_i::Restore - " << thePrefix);
753 mySObject = SALOMEDS::SObject::_duplicate(theSObject);
754 mySComponent = mySObject->GetFatherComponent();
755 myStudyDocument = theSObject->GetStudy();
756 myStudy = VISU::GetStudy(myStudyDocument);
758 myCreationId = ECreationId(Storable::FindValue(theMap, "myCreationId").toInt());
759 mySourceId = eRestoredFile;
760 if(myCreationId == eImportMed || myCreationId == eImportMedField)
761 mySourceId = eRestoredComponent;
763 myIsBuildFields = Storable::FindValue(theMap, "myIsBuildFields", "1").toInt();
764 myIsBuildMinMax = Storable::FindValue(theMap, "myIsBuildMinMax", "1").toInt();
765 myIsBuildGroups = Storable::FindValue(theMap, "myIsBuildGroups", "1").toInt();
767 myIsBuildImmediately = true;
770 myFileName = VISU::Storable::FindValue(theMap, "myName").toLatin1().data();
772 for (int i = 0; i < myFileName.length(); i++)
774 if (myFileName[i] == ':')
778 SetInitFileName(VISU::Storable::FindValue(theMap, "myInitFileName").toLatin1().data());
780 SALOMEDS::SObject_var aRefSObj, aTargetRefSObj;
781 if (theSObject->FindSubObject(1, aRefSObj) && aRefSObj->ReferencedObject(aTargetRefSObj)) {
782 if(MYDEBUG) MESSAGE("Result_i::GetInput - There is some reference.");
783 SALOMEDS::SComponent_var aCompRefSObj = aTargetRefSObj->GetFatherComponent();
784 CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
785 myFileInfo.setFile(aDataType.in());
786 if(MYDEBUG) MESSAGE("Result_i::GetInput - aDataType = " << aDataType);
787 Engines::EngineComponent_var aEngComp =
788 Base_i::myEnginesLifeCycle->FindOrLoad_Component("FactoryServer", aDataType.in());
789 if (CORBA::is_nil(aEngComp))
790 throw std::runtime_error("Restore - There is no aEngComp for the aDataType !!!");
791 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
792 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp);
793 aStudyBuilder->LoadWith(aCompRefSObj, aDriver);
794 // create field or MED converter
795 CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj);
796 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(aMedObject);
797 if (!CORBA::is_nil(aField)) {
798 // create field converter
799 myInput.reset(CreateMEDFieldConvertor(aField));
802 else if (strcmp(aDataType, "MED") == 0) {
803 // create MED converter
804 myInput.reset(CreateMEDConvertor(aTargetRefSObj));
808 throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!");
811 myFileInfo.setFile(thePrefix.c_str());
813 std::string aStudyPrefix ("");
814 if (theIsMultiFile) {
815 CORBA::String_var anURL(GetStudyDocument()->URL());
816 aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
818 if (!myFileInfo.isFile()) {
819 std::string aFileName = thePrefix + aStudyPrefix + "_" + myFileName;
820 myFileInfo.setFile(aFileName.c_str());
823 MESSAGE("Result_i::Restore - aFileName = " << myFileInfo.filePath().toLatin1().data() << "; " << myFileInfo.isFile());
825 if (HDFascii::isASCII(myFileInfo.filePath().toLatin1().data())) {
826 MESSAGE("ConvertFromASCIIToHDF(" << myFileInfo.filePath().toLatin1().data() << ")");
827 char* aResultPath = HDFascii::ConvertFromASCIIToHDF(myFileInfo.filePath().toLatin1().data());
828 MESSAGE("ConvertFromASCIIToHDF() DONE : " << aResultPath);
829 char* aHDFFileName = new char[strlen(aResultPath) + 19];
830 sprintf(aHDFFileName, "%shdf_from_ascii.hdf", aResultPath);
832 if (theIsMultiFile) { // set this file as new - temporary
833 static QString aCommand;
834 aCommand.sprintf(" %s %s%s",aHDFFileName, aResultPath, myFileInfo.baseName().toLatin1().data());
835 aCommand = QDir::convertSeparators( aCommand );
836 aCommand.prepend( MOVE_COMMAND );
838 if (system(aCommand.toLatin1().data()) == -1) {
839 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand.toLatin1().data());
842 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand.toLatin1().data());
844 myFileInfo.setFile(QString(aResultPath) + myFileInfo.baseName());
845 } else { // change current temporary file to the new: with hdf-format
846 static QString aCommand;
847 aCommand.sprintf(" %s %s\0",aHDFFileName, myFileInfo.filePath().toLatin1().data());
848 aCommand = QDir::convertSeparators( aCommand );
849 aCommand.prepend( MOVE_COMMAND );
851 if (system(aCommand.toLatin1().data()) == -1) {
852 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand.toLatin1().data());
855 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand.toLatin1().data());
857 SALOMEDS::ListOfFileNames_var anEmptyList = new SALOMEDS::ListOfFileNames;
858 SALOMEDS_Tool::RemoveTemporaryFiles(aResultPath, anEmptyList.in(), true);
860 mySourceId = eRestoredFile;
862 delete(aHDFFileName);
863 } else if (!theIsMultiFile) {
864 mySourceId = eRestoredFile;
866 mySourceId = eSavedFile;
868 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId);
869 myInput.reset(CreateConvertor(myFileInfo.filePath().toLatin1().data()));
871 myInput->BuildEntities();
873 myInput->BuildFields();
874 myIsFieldsDone = true;
876 myInput->BuildMinMax();
877 myIsMinMaxDone = true;
881 myInput->BuildGroups();
882 myIsGroupsDone = true;
886 aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s",
888 myFileInfo.filePath().toLatin1().data(),
889 GetInitFileName().c_str()); // Restoring of Python dump
890 SALOMEDS::GenericAttribute_var anAttr;
891 if (!theSObject->FindAttribute(anAttr, "AttributeString"))
892 throw std::runtime_error("Build - There is no AttributeString for the SObject !!!");
893 SALOMEDS::AttributeString_var aCmnt = SALOMEDS::AttributeString::_narrow(anAttr);
894 aCmnt->SetValue(aComment.toLatin1().data());
896 bool anIsBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
900 } catch(std::exception& exc) {
901 INFOS("Follow exception was occured :\n"<<exc.what());
903 INFOS("Unknown exception was occured!!!");
909 //---------------------------------------------------------------
910 VISU::Result_i::PInput
912 ::GetInput(const std::string& theMeshName,
913 VISU::Entity theEntity,
914 const std::string& theFieldName,
915 CORBA::Long theTimeStampNumber)
921 //---------------------------------------------------------------
928 (myIsBuildFields? myIsFieldsDone: true) &&
929 (myIsBuildMinMax? myIsMinMaxDone: true) &&
930 (myIsBuildGroups? myIsGroupsDone: true);
937 return myIsEntitiesDone;
942 ::SetBuildFields(CORBA::Boolean theIsBuildFields,
943 CORBA::Boolean theIsCalculateMinMax)
945 myIsBuildFields = theIsBuildFields;
947 myIsBuildMinMax = theIsCalculateMinMax;
949 myIsBuildMinMax = false;
954 ::SetBuildGroups(CORBA::Boolean theIsBuildGroups)
956 myIsBuildGroups = theIsBuildGroups;
963 return myIsFieldsDone;
970 return myIsGroupsDone;
977 return myIsMinMaxDone;
984 return myIsPartsDone;
988 //---------------------------------------------------------------
989 VISU::Result::EntityNames*
993 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
994 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
996 return aResult._retn();
998 aResult->length(aMeshMap.size());
999 VISU::TMeshMap::const_iterator anIter = aMeshMap.begin();
1000 for(size_t anId = 0; anIter != aMeshMap.end(); anIter++, anId++){
1001 const std::string& aName = anIter->first;
1002 aResult[anId] = aName.c_str();
1005 return aResult._retn();
1009 //---------------------------------------------------------------
1010 VISU::Result::Entities*
1012 ::GetEntities(const char* theMeshName)
1014 VISU::Result::Entities_var anEntities = new VISU::Result::Entities();
1015 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1016 if(aMeshMap.empty())
1017 return anEntities._retn();
1019 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1020 if(anIter == aMeshMap.end())
1021 return anEntities._retn();
1023 const VISU::PMesh& aMesh = anIter->second;
1024 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1025 if(aMeshOnEntityMap.empty())
1026 return anEntities._retn();
1029 anEntities->length(aMeshOnEntityMap.size());
1030 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.begin();
1031 for(size_t anId = 0; anIter != aMeshOnEntityMap.end(); anIter++, anId++){
1032 const VISU::TEntity& anEntity = anIter->first;
1033 anEntities[anId] = VISU::Entity(anEntity);
1037 return anEntities._retn();
1041 //---------------------------------------------------------------
1042 VISU::Result::EntityNames*
1044 ::GetFamilies(const char* theMeshName,
1045 VISU::Entity theEntity)
1047 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1048 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1049 if(aMeshMap.empty())
1050 return aResult._retn();
1052 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1053 if(anIter == aMeshMap.end())
1054 return aResult._retn();
1056 const VISU::PMesh& aMesh = anIter->second;
1057 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1058 if(aMeshOnEntityMap.empty())
1059 return aResult._retn();
1062 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1063 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1064 if(anIter == aMeshOnEntityMap.end())
1065 return aResult._retn();
1067 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1068 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1069 if(aFamilyMap.empty())
1070 return aResult._retn();
1073 aResult->length(aFamilyMap.size());
1074 VISU::TFamilyMap::const_iterator anIter = aFamilyMap.begin();
1075 for(size_t anId = 0; anIter != aFamilyMap.end(); anIter++, anId++){
1076 const std::string& aName = anIter->first;
1077 aResult[anId] = aName.c_str();
1082 return aResult._retn();
1086 //---------------------------------------------------------------
1087 VISU::Result::EntityNames*
1089 ::GetGroups(const char* theMeshName)
1091 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1092 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1093 if(aMeshMap.empty())
1094 return aResult._retn();
1096 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1097 if(anIter == aMeshMap.end())
1098 return aResult._retn();
1100 const VISU::PMesh& aMesh = anIter->second;
1101 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1102 if(aGroupMap.empty())
1103 return aResult._retn();
1106 aResult->length(aGroupMap.size());
1107 VISU::TGroupMap::const_iterator anIter = aGroupMap.begin();
1108 for(size_t anId = 0; anIter != aGroupMap.end(); anIter++, anId++){
1109 const std::string& aName = anIter->first;
1110 aResult[anId] = aName.c_str();
1114 return aResult._retn();
1118 //---------------------------------------------------------------
1119 VISU::Result::EntityNames*
1121 ::GetFields(const char* theMeshName,
1122 VISU::Entity theEntity)
1124 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1125 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1126 if(aMeshMap.empty())
1127 return aResult._retn();
1129 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1130 if(anIter == aMeshMap.end())
1131 return aResult._retn();
1133 const VISU::PMesh& aMesh = anIter->second;
1134 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1135 if(aMeshOnEntityMap.empty())
1136 return aResult._retn();
1139 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1140 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1141 if(anIter == aMeshOnEntityMap.end())
1142 return aResult._retn();
1144 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1145 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1146 if(aFieldMap.empty())
1147 return aResult._retn();
1150 aResult->length(aFieldMap.size());
1151 VISU::TFieldMap::const_iterator anIter = aFieldMap.begin();
1152 for(size_t anId = 0; anIter != aFieldMap.end(); anIter++, anId++){
1153 const std::string& aName = anIter->first;
1154 aResult[anId] = aName.c_str();
1159 return aResult._retn();
1163 //---------------------------------------------------------------
1164 VISU::Result::TimeStampNumbers*
1166 ::GetTimeStampNumbers(const char* theMeshName,
1167 VISU::Entity theEntity,
1168 const char* theFieldName)
1170 VISU::Result::TimeStampNumbers_var aResult = new VISU::Result::TimeStampNumbers();
1171 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1172 if(aMeshMap.empty())
1173 return aResult._retn();
1175 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1176 if(anIter == aMeshMap.end())
1177 return aResult._retn();
1179 const VISU::PMesh& aMesh = anIter->second;
1180 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1181 if(aMeshOnEntityMap.empty())
1182 return aResult._retn();
1185 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1186 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1187 if(anIter == aMeshOnEntityMap.end())
1188 return aResult._retn();
1190 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1191 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1192 if(aFieldMap.empty())
1193 return aResult._retn();
1196 VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName);
1197 if(anIter == aFieldMap.end())
1198 return aResult._retn();
1201 const VISU::PField& aField = anIter->second;
1202 const VISU::TValField& aValField = aField->myValField;
1203 if(aValField.empty())
1204 return aResult._retn();
1207 aResult->length(aValField.size());
1208 VISU::TValField::const_iterator anIter = aValField.begin();
1209 for(size_t anId = 0; anIter != aValField.end(); anIter++, anId++){
1210 const vtkIdType& aTimeStampNumber = anIter->first;
1211 aResult[anId] = aTimeStampNumber;
1218 return aResult._retn();
1222 //---------------------------------------------------------------
1225 ::GetTimeStampValues(const char* theMeshName,
1226 VISU::Entity theEntity,
1227 const char* theFieldName)
1229 VISU::double_array_var aResult = new VISU::double_array();
1230 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1231 if(aMeshMap.empty())
1232 return aResult._retn();
1234 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1235 if(anIter == aMeshMap.end())
1236 return aResult._retn();
1238 const VISU::PMesh& aMesh = anIter->second;
1239 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1240 if(aMeshOnEntityMap.empty())
1241 return aResult._retn();
1244 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1245 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1246 if(anIter == aMeshOnEntityMap.end())
1247 return aResult._retn();
1249 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1250 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1251 if(aFieldMap.empty())
1252 return aResult._retn();
1255 VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName);
1256 if(anIter == aFieldMap.end())
1257 return aResult._retn();
1260 const VISU::PField& aField = anIter->second;
1261 const VISU::TValField& aValField = aField->myValField;
1262 if(aValField.empty())
1263 return aResult._retn();
1266 aResult->length(aValField.size());
1267 VISU::TValField::const_iterator anIter = aValField.begin();
1268 for(size_t anId = 0; anIter != aValField.end(); anIter++, anId++){
1269 const PValForTime& aValForTime = anIter->second;
1270 aResult[anId] = aValForTime->myTime.first;
1277 return aResult._retn();
1281 //---------------------------------------------------------------
1284 ::GetNumberOfComponents(const char* theMeshName,
1285 VISU::Entity theEntity,
1286 const char* theFieldName)
1288 CORBA::Long aResult = 0;
1289 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1290 if(aMeshMap.empty())
1293 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1294 if(anIter == aMeshMap.end())
1297 const VISU::PMesh& aMesh = anIter->second;
1298 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1299 if(aMeshOnEntityMap.empty())
1303 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1304 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1305 if(anIter == aMeshOnEntityMap.end())
1308 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1309 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1310 if(aFieldMap.empty())
1314 VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName);
1315 if(anIter == aFieldMap.end())
1319 const VISU::PField& aField = anIter->second;
1320 aResult = aField->myNbComp;
1329 //---------------------------------------------------------------
1330 VISU::Result::EntityNames*
1332 ::GetPartNames(const char* theMeshName)
1334 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1335 return aResult._retn();
1339 //---------------------------------------------------------------
1340 VISU::Result::Resolutions*
1342 ::GetResolutions(const char* theMeshName,
1343 const char* thePartName)
1345 VISU::Result::Resolutions_var aResult = new VISU::Result::Resolutions();
1346 return aResult._retn();
1350 //---------------------------------------------------------------
1351 VISU::Result::Resolution
1353 ::GetResolution(const char* theMeshName,
1354 const char* thePartName)
1356 return VISU::Result::HIDDEN;
1360 //---------------------------------------------------------------
1363 ::SetResolution(const char* theMeshName,
1364 const char* thePartName,
1365 VISU::Result::Resolution theResolution)
1369 //---------------------------------------------------------------
1372 ::New(SALOMEDS::Study_ptr theStudy,
1373 const ESourceId& theSourceId,
1374 const ECreationId& theCreationId,
1375 CORBA::Boolean theIsBuildImmediately,
1376 CORBA::Boolean theIsBuildFields,
1377 CORBA::Boolean theIsBuildMinMax,
1378 CORBA::Boolean theIsBuildGroups)
1380 return new RESULT_CLASS_NAME(theStudy,
1383 theIsBuildImmediately,
1390 //---------------------------------------------------------------
1393 ::StorableEngine(SALOMEDS::SObject_ptr theSObject,
1394 const Storable::TRestoringMap& theMap,
1395 const std::string& thePrefix,
1396 CORBA::Boolean theIsMultiFile)
1398 VISU::Result_i* aResult = new RESULT_CLASS_NAME();
1399 return aResult->Restore(theSObject, theMap, thePrefix, theIsMultiFile);
1403 //---------------------------------------------------------------
1406 ::ToStream(std::ostringstream& theStr)
1408 Storable::DataToStream(theStr,"myName", GetFileName().c_str());
1409 Storable::DataToStream(theStr,"myInitFileName", GetInitFileName().c_str());
1410 Storable::DataToStream(theStr,"myCreationId", myCreationId);
1411 Storable::DataToStream(theStr,"myIsBuildFields", myIsFieldsDone);
1412 Storable::DataToStream(theStr,"myIsBuildMinMax", myIsMinMaxDone);
1413 Storable::DataToStream(theStr,"myIsBuildGroups", myIsGroupsDone);
1416 //---------------------------------------------------------------
1420 ::ExportMED(const char* theTargetFileName)
1422 static QString aCommand;
1423 const char* aTempFileName = myFileInfo.absoluteFilePath().toLatin1();
1424 aCommand.sprintf(" %s %s", aTempFileName, theTargetFileName);
1425 aCommand = QDir::convertSeparators( aCommand );
1426 aCommand.prepend( COPY_COMMAND );
1428 if(system(aCommand.toLatin1().data()) != 0) {
1429 if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand.toLatin1().data());
1436 //---------------------------------------------------------------
1439 ::GetInitFileName() const
1441 return myInitFileName;
1447 ::SetInitFileName(const std::string& theFileName)
1449 myInitFileName = theFileName;
1453 //---------------------------------------------------------------
1456 ::GetFileName() const
1458 if(GetSourceId() == eFile)
1459 return VISU::MakeFileName(myFileName, this);
1467 ::GetFileInfo() const
1472 VISU::Result_i::ECreationId
1474 ::GetCreationId() const
1476 return myCreationId;
1480 VISU::Result_i::ESourceId
1482 ::GetSourceId() const
1488 //---------------------------------------------------------------
1493 CORBA::String_var anEntry = mySObject->GetID();
1494 return anEntry.in();
1497 SALOMEDS::SObject_var
1499 ::GetSObject() const
1506 ::GetStudyDocument() const
1508 return myStudyDocument;
1518 SALOMEDS::SComponent_var
1520 ::GetSComponent() const
1522 return mySComponent;
1527 ::GetEntry(const Storable::TRestoringMap& theRestoringMap)
1529 return Storable::FindEntry(myStudyDocument,
1535 //=======================================================================
1536 //function : GetAxisInfo
1538 //=======================================================================
1539 const VISU::Result_i::TAxisInfo*
1541 ::GetAxisInfo(const string& theMeshName,
1543 gp_Dir& thePlaneNormal)
1545 const TAxisInfo* components = NULL;
1547 if ( theAxis < AXIS_X || theAxis > AXIS_Z ) {
1548 MESSAGE(" Bad axis index " << theAxis );
1552 map< string, TGridInfo >::iterator name_info;
1553 name_info = myMeshName2GridInfoMap.find( theMeshName );
1554 TGridInfo * gInfo = 0;
1556 if ( name_info != myMeshName2GridInfoMap.end() )
1558 gInfo = & name_info->second;
1560 else if ( myInput && IsPossible() && theAxis >= AXIS_X && theAxis <= AXIS_Z )
1562 // check presence of theMeshName
1563 const VISU::TMeshMap& meshMap = myInput->GetMeshMap();
1565 VISU::TMeshMap::const_iterator aIter = meshMap.find( theMeshName );
1566 if ( aIter == meshMap.end() ) {
1567 MESSAGE("No mesh named " << theMeshName );
1570 theMesh = aIter->second;
1572 VISU::PUnstructuredGridIDMapper anIDMapper = myInput->GetMeshOnEntity(theMeshName,
1574 vtkUnstructuredGrid* aMesh = anIDMapper->GetUnstructuredGridOutput();
1576 if ( !aMesh || aMesh->GetNumberOfCells() == 0 ) {
1577 MESSAGE( "No cells in the mesh: " << theMeshName );
1581 if ( !theMesh->IsStructured() || theMesh->myIsPolarType ) {
1582 // define axis directions and min cell size in each direction
1583 const int nbAxes = 3;
1585 gp_Vec axDirs[ nbAxes ];
1586 float minSize[3] = { FLT_MAX, FLT_MAX, FLT_MAX };
1587 bool axesComputed = false;
1588 for ( vtkIdType iCell = 0; iCell < aMesh->GetNumberOfCells(); ++iCell ) {
1589 vtkCell* cell = aMesh->GetCell( iCell );
1591 if (cell->GetCellType() != VTK_HEXAHEDRON &&
1592 cell->GetCellType() != VTK_QUADRATIC_HEXAHEDRON )
1594 vtkPoints * points = cell->GetPoints();
1595 vtkFloatingPointType coords[ 4 ][3];
1596 points->GetPoint( 0, coords[0] );
1597 points->GetPoint( 1, coords[1] );
1598 points->GetPoint( 3, coords[2] );
1599 points->GetPoint( 4, coords[3] );
1600 gp_Pnt p0( coords[0][0], coords[0][1], coords[0][2] );
1601 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1602 vtkFloatingPointType* coo = coords[ iAx + 1 ];
1603 gp_Pnt p( coo[0], coo[1], coo[2] );
1605 vtkFloatingPointType size = p0.SquareDistance( p );
1606 if ( size > FLT_MIN && size < minSize[ iAx ] )
1607 minSize[ iAx ] = size;
1609 if ( !axesComputed ) {
1610 gp_Vec dir( p0, p );
1611 if ( dir.SquareMagnitude() <= gp::Resolution() ) {
1614 axDirs[ iAx ] = dir;
1617 if ( iAx == nbAxes )
1618 axesComputed = true;
1620 if ( !axesComputed ) {
1621 MESSAGE("No good hexahedrons in the mesh: " << theMeshName );
1625 // compute axes dirs
1626 gInfo = & myMeshName2GridInfoMap[ theMeshName ];
1627 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1628 int iPrev = ( iAx == 0 ) ? 2 : iAx - 1;
1629 int iNext = ( iAx == 2 ) ? 0 : iAx + 1;
1630 gInfo->myAxis[ iAx ] = axDirs[ iPrev ] ^ axDirs[ iNext ];
1633 // get and sort intermediate component values - projections of nodes
1634 // on axis direction; define bnd box
1635 set< vtkFloatingPointType > comps[ 3 ];
1637 vtkPoints * points = aMesh->GetPoints();
1638 vtkIdType iP, nbP = aMesh->GetNumberOfPoints();
1639 for ( iP = 0; iP < nbP; ++iP ) {
1640 vtkFloatingPointType coo[3];
1641 points->GetPoint( iP, coo );
1642 gp_Pnt p( coo[0], coo[1], coo[2] );
1644 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1645 const gp_Dir& dir = gInfo->myAxis[ iAx ];
1646 vtkFloatingPointType dot = dir.XYZ() * p.XYZ();
1647 comps[ iAx ].insert( dot );
1651 // find a range of projections of bnd box corners on each axis
1652 vtkFloatingPointType range[3], firstValue[3];
1653 double x[2],y[2],z[2];
1654 box.Get(x[0],y[0],z[0],x[1],y[1],z[1]);
1655 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1656 set< vtkFloatingPointType > bndComps;
1657 const gp_Dir& dir = gInfo->myAxis[ iAx ];
1658 for ( int iX = 0; iX < 2; ++iX ) {
1659 for ( int iY = 0; iY < 2; ++iY ) {
1660 for ( int iZ = 0; iZ < 2; ++iZ ) {
1661 gp_Pnt p( x[ iX ], y[ iY ], z[ iZ ] );
1662 vtkFloatingPointType dot = dir.XYZ() * p.XYZ();
1663 bndComps.insert( dot );
1667 firstValue[ iAx ] = *bndComps.begin();
1668 range[ iAx ] = *bndComps.rbegin() - *bndComps.begin();
1671 // compute component values
1672 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1673 list< vtkFloatingPointType > values;
1675 set< vtkFloatingPointType >& comp = comps[ iAx ];
1676 set< vtkFloatingPointType >::iterator val = comp.begin();
1677 vtkFloatingPointType bnd = -1., rng = range[ iAx ], first = firstValue[ iAx ];
1678 vtkFloatingPointType tol = 0.1 * sqrt( minSize[ iAx ]) / rng;
1679 for ( ; val != comp.end(); ++val ) {
1680 vtkFloatingPointType value = ( *val - first ) / rng;
1681 if ( value > bnd ) {
1682 values.push_back( value );
1687 // store values in gInfo
1688 vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ iAx ];
1689 myComp.resize( nbVals );
1690 list< vtkFloatingPointType >::iterator v = values.begin();
1691 for ( int i = 0; v != values.end(); ++v ){
1697 vtkIdType aMeshDim = theMesh->myDim;
1698 gInfo = & myMeshName2GridInfoMap[ theMeshName ];
1699 switch ( aMeshDim ) {
1701 gp_Dir aDir(0.0,0.0,1.0);
1702 gInfo->myAxis[ 2 ] = aDir;
1705 gp_Dir aDir(0.0,1.0,0.0);
1706 gInfo->myAxis[ 1 ] = aDir;
1709 gp_Dir aDir(1.0,0.0,0.0);
1710 gInfo->myAxis[ 0 ] = aDir;
1713 TStructuredId aStructuredId = theMesh->GetStructure();
1714 vector<vtkFloatingPointType> PointsCoords[3];
1715 vtkPoints* aPoints = aMesh->GetPoints();
1716 switch ( aMeshDim ) {
1718 TStructuredId aCoordIJK;
1719 vtkIdType nbZ = aStructuredId[2];
1720 for ( int i = 0; i < nbZ; i++ ) {
1721 aCoordIJK[2] = i + 1;
1722 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1723 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1724 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1725 PointsCoords[2].push_back(aPCoord[2]);
1729 TStructuredId aCoordIJK;
1730 vtkIdType nbJ = aStructuredId[1];
1731 for ( int i = 0; i < nbJ; i++ ) {
1732 aCoordIJK[1] = i + 1;
1733 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1734 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1735 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1736 PointsCoords[1].push_back(aPCoord[1]);
1740 TStructuredId aCoordIJK;
1741 vtkIdType nbI = aStructuredId[0];
1742 for ( int i = 0; i < nbI; i++ ) {
1743 aCoordIJK[0] = i + 1;
1744 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1745 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1746 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1747 PointsCoords[0].push_back(aPCoord[0]);
1750 for ( int i = 0; i < aMeshDim; i++ ) {
1751 vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ i ];
1752 int aSize = PointsCoords[i].size();
1754 vtkFloatingPointType aLen = PointsCoords[i][aSize-1] - PointsCoords[i][0];
1755 myComp.resize(aSize);
1757 for ( int k = 1; k < aSize; k++ ) {
1758 myComp[k]=myComp[k-1] + (PointsCoords[i][k]-PointsCoords[i][k-1])/aLen;
1765 // set return values
1767 thePlaneNormal = gInfo->myAxis[ theAxis ];
1768 components = & gInfo->myComponets[ theAxis ];
1774 SALOME_MED::MedFileInfo* VISU::Result_i::GetMEDFileInfo()
1776 SALOME_MED::MedFileInfo_var res = new SALOME_MED::MedFileInfo();
1778 QString fpath = myFileInfo.absoluteFilePath();
1779 res->fileName = fpath.toLatin1().constData();
1780 res->fileSize = myFileInfo.size();
1781 int major, minor, release;
1782 if( !MED::getMEDVersion( fpath.toLatin1().constData(), major, minor, release ) )
1790 res->release = release;