1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISU_Result_i.cc
24 // Author : Alexey PETROV
27 #include "VISU_MultiResult_i.hh"
28 #include "VISU_ResultUtils.hh"
29 #include "VISU_Prs3d_i.hh"
31 #include "VISU_Convertor_impl.hxx"
32 #include "VISU_CorbaMedConvertor.hxx"
33 #include "VISU_ConvertorUtils.hxx"
34 #include "VISU_PipeLine.hxx"
36 #include "SUIT_ResourceMgr.h"
38 #include "SALOMEDS_Tool.hxx"
39 #include "HDFascii.hxx"
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 if(CORBA::is_nil(theStudy))
107 SALOMEDS::SObject_var aSObject = theStudy->FindObjectID(theResultEntry.c_str());
108 CORBA::Object_var anObject = SObjectToObject(aSObject);
109 return dynamic_cast<VISU::Result_i*>(GetServant(anObject).in());
113 //---------------------------------------------------------------
115 GetComponentDataType (SALOMEDS::SObject_ptr theSObject)
117 SALOMEDS::SComponent_var aCompRefSObj = theSObject->GetFatherComponent();
118 CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
119 return aDataType.in();
123 //---------------------------------------------------------------
125 CreateReference (SALOMEDS::Study_ptr theStudyDocument,
126 const string& theFatherEntry,
127 const string& theRefEntry)
129 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
130 SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry.c_str());
131 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(aFather);
132 SALOMEDS::SObject_var aRefSObj = theStudyDocument->FindObjectID(theRefEntry.c_str());
133 aStudyBuilder->Addreference(newObj,aRefSObj);
137 //---------------------------------------------------------------
141 //---------------------------------------------------------------
142 const string VISU::Result_i::myComment = "RESULT";
143 const char* VISU::Result_i::GetComment() const { return myComment.c_str();}
145 //---------------------------------------------------------------
147 ::Result_i(SALOMEDS::Study_ptr theStudy,
148 const ESourceId& theSourceId,
149 const ECreationId& theCreationId,
150 CORBA::Boolean theIsBuildImmediately,
151 CORBA::Boolean theIsBuildFields,
152 CORBA::Boolean theIsBuildMinMax,
153 CORBA::Boolean theIsBuildGroups):
154 myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)),
155 myCreationId(theCreationId),
156 mySourceId(theSourceId),
157 myIsBuildImmediately(theIsBuildImmediately),
158 myIsBuildFields(theIsBuildFields),
159 myIsBuildMinMax(theIsBuildMinMax),
160 myIsBuildGroups(theIsBuildGroups),
161 myIsEntitiesDone(false),
162 myIsFieldsDone(false),
163 myIsGroupsDone(false),
164 myIsMinMaxDone(false),
166 myIsBuildParts(false),
169 if(MYDEBUG) MESSAGE("Result_i::Result_i - this = "<<this);
170 myStudy = VISU::GetStudy(myStudyDocument);
174 //---------------------------------------------------------------
177 myIsEntitiesDone(false),
178 myIsFieldsDone(false),
179 myIsGroupsDone(false),
180 myIsMinMaxDone(false),
182 myIsBuildParts(false),
185 if(MYDEBUG) MESSAGE("Result_i::Result_i - this = "<<this);
189 //---------------------------------------------------------------
193 MESSAGE("Result_i::~Result_i() - this = "<<this);
194 if (GetSourceId() == eRestoredFile)
195 VISU::RemoveFile(myFileInfo.filePath().toLatin1().data());
199 //---------------------------------------------------------------
204 struct TRemoveFromStudy: public SALOME_Event
206 VISU::Result_i* myRemovable;
207 TRemoveFromStudy(VISU::Result_i* theRemovable):
208 myRemovable(theRemovable)
215 VISU::RemoveFromStudy(myRemovable->GetSObject(),false);
216 myRemovable->Destroy();
220 // Remove the result with all presentations and other possible sub-objects
221 ProcessVoidEvent(new TRemoveFromStudy(this));
225 //---------------------------------------------------------------
228 ::ConnectObserver(TResultObserver* theObserver,
229 boost::signalslib::connection& theConnection)
231 if(theConnection.connected())
232 theConnection.disconnect();
235 myUpdateObserverSignal.connect(boost::bind(boost::bind(&TResultObserver::UpdateFromResult,
242 //---------------------------------------------------------------
247 struct TEvent: public SALOME_Event
249 VISU::Result_i::TUpdateObserverSignal& myUpdateObserverSignal;
251 TEvent(VISU::Result_i::TUpdateObserverSignal& theUpdateObserverSignal):
252 myUpdateObserverSignal(theUpdateObserverSignal)
259 myUpdateObserverSignal();
263 ProcessVoidEvent(new TEvent(myUpdateObserverSignal));
267 //---------------------------------------------------------------
273 size_t aSize = myInput->GetSize();
274 size_t aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
275 MESSAGE("Result_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<float(aResult));
277 }catch(std::exception& exc){
278 INFOS("Follow exception was occured :\n"<<exc.what());
280 INFOS("Unknown exception was occured!");
286 //---------------------------------------------------------------
291 if(MYDEBUG) MESSAGE("Result_i::Build - myIsAllDone = "<<myIsAllDone);
297 const VISU::TMeshMap& aMeshMap = myInput->GetMeshMap();
298 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
299 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
300 const string& aMeshName = aMeshMapIter->first;
301 const VISU::PMesh aMesh = aMeshMapIter->second;
302 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
303 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
305 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
306 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
307 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
308 const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
309 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
310 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
311 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
312 const string& aFieldName = aFieldMapIter->first;
313 const VISU::PField aField = aFieldMapIter->second;
314 const VISU::TValField& aValField = aField->myValField;
315 VISU::TValField::const_iterator aValFieldIter = aValField.begin();
316 for(; aValFieldIter != aValField.end(); aValFieldIter++){
317 int aTimeStamp = aValFieldIter->first;
319 myInput->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
320 }catch(std::exception& exc){
321 INFOS("Follow exception was occured :\n"<<exc.what());
323 INFOS("Unknown exception was occured!!!");
328 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
329 VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
330 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
331 const string& aGroupName = aGroupMapIter->first;
333 myInput->GetMeshOnGroup(aMeshName,aGroupName);
334 }catch(std::exception& exc){
335 INFOS("Follow exception was occured :\n"<<exc.what());
337 INFOS("Unknown exception was occured!!!");
341 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
342 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
343 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
344 const string& aFamilyName = aFamilyMapIter->first;
346 myInput->GetFamilyOnEntity(aMeshName,anEntity,aFamilyName);
347 }catch(std::exception& exc){
348 INFOS("Follow exception was occured :\n"<<exc.what());
350 INFOS("Unknown exception was occured!!!");
353 //Import mesh on entity
355 myInput->GetMeshOnEntity(aMeshName,anEntity);
356 }catch(std::exception& exc){
357 INFOS("Follow exception was occured :\n"<<exc.what());
359 INFOS("Unknown exception was occured!!!");
364 }catch(std::exception& exc){
365 INFOS("Follow exception was occured :\n"<<exc.what());
367 INFOS("Unknown exception was occured!!!");
373 //---------------------------------------------------------------
376 ::Build(CORBA::Boolean theIsBuildAll,
377 CORBA::Boolean theIsAtOnce)
382 if(Build(SALOMEDS::SObject::_nil(), theIsAtOnce)){
385 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
387 SALOMEDS::GenericAttribute_var anAttr;
388 SALOMEDS::AttributePixMap_var aPixmap;
389 SALOMEDS::AttributeUserID_var aId;
391 anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, "AttributePixMap" );
392 aPixmap = SALOMEDS::AttributePixMap::_narrow( anAttr );
393 aPixmap ->SetPixMap("ICON_TREE_RESULT");
395 std::string auid = "AttributeUserID";
396 auid += Kernel_Utils::GetGUID(Kernel_Utils::ObjectdID);
397 anAttr = aStudyBuilder->FindOrCreateAttribute( mySObject, auid.c_str() );
398 aId = SALOMEDS::AttributeUserID::_narrow( anAttr );
399 aId ->SetValue("VISU.RESULT");
410 //---------------------------------------------------------------
411 VISU::Storable* VISU::Result_i::Build(SALOMEDS::SObject_ptr theSObject,
412 CORBA::Boolean theIsAtOnce)
420 mySComponent = FindOrCreateVisuComponent(myStudyDocument);
421 CORBA::String_var aSComponentEntry = mySComponent->GetID();
422 CORBA::String_var anIOR(GetID());
424 aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s",
426 myFileInfo.filePath().toLatin1().data(),
427 GetInitFileName().c_str()); // Restoring of Python dump
428 std::string aResultEntry =
429 CreateAttributes(myStudy,
430 aSComponentEntry.in(),
435 aComment.toLatin1().data(),
437 mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str());
438 if(!CORBA::is_nil(theSObject)){
439 CORBA::String_var aString = theSObject->GetID();
440 CreateReference(myStudyDocument, aResultEntry, aString.in());
461 BuildFieldDataTree(this,
469 boost::thread aThread(boost::bind(boost::bind(&Result_i::BuildDataTree, this, _1),
477 //---------------------------------------------------------------
480 ::BuildDataTree(const std::string& theResultEntry)
493 boost::thread aThread(boost::bind(&BuildGroups,
502 boost::thread aThread(boost::bind(&BuildFieldDataTree,
513 //---------------------------------------------------------------
516 ::BuildAll(SALOMEDS::SObject_ptr theSObject)
518 if(MYDEBUG) MESSAGE("Result_i::Build");
522 }catch(std::exception& exc){
523 INFOS("Follow exception was occured :\n"<<exc.what());
526 INFOS("Unknown exception was occured!!!");
534 //---------------------------------------------------------------
537 ::Create(const char* theFileName)
540 myFileInfo.setFile(theFileName);
541 myFileName = myFileInfo.fileName().toLatin1().data();
544 SetInitFileName(myFileInfo.filePath().toLatin1().data());
545 SetName(VISU::GenerateName(myFileInfo.fileName().toLatin1().data()).toLatin1().data(), false);
548 if(mySourceId == eRestoredFile){
549 QString aTmpDir(SALOMEDS_Tool::GetTmpDir().c_str());
550 std::string aFileName = VISU::MakeFileName(myFileInfo.fileName().toLatin1().data(), this);
551 QString aPathToCopy(aTmpDir + aFileName.c_str());
552 if(!VISU::CopyFile(myFileInfo.absoluteFilePath().toLatin1().data(), aPathToCopy.toLatin1().data()))
555 myFileInfo.setFile(aPathToCopy);
556 myFileName = myFileInfo.fileName().toLatin1().data();
559 myInput.reset(CreateConvertor(myFileInfo.absoluteFilePath().toLatin1().data()));
562 if(myIsBuildImmediately)
563 Build(SALOMEDS::SObject::_nil());
566 }catch(std::exception& exc){
567 MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
569 MSG(MYDEBUG,"Unknown exception !!!");
575 //---------------------------------------------------------------
578 ::Create(SALOMEDS::SObject_ptr theMedSObject)
580 if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOMEDS::SObject_ptr");
582 myInput.reset(CreateMEDConvertor(theMedSObject));
588 string aCompDataType = GetComponentDataType(theMedSObject);
589 myFileInfo.setFile(aCompDataType.c_str());
590 myFileName = VISU::GenerateName("aResult").toLatin1().data();
592 SetInitFileName(aCompDataType);
593 SetName(VISU::GenerateName(myFileInfo.fileName().toLatin1().data()).toLatin1().data(), false);
595 return Build(theMedSObject);
596 }catch(std::exception& exc){
597 INFOS("Follow exception was occured :\n"<<exc.what());
599 INFOS("Unknown exception was occured!!!");
605 //---------------------------------------------------------------
608 ::Create(SALOME_MED::FIELD_ptr theField)
610 if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOME_MED::FIELD_ptr");
612 myInput.reset(CreateMEDFieldConvertor(theField));
618 string aCompDataType = "MED";
619 myFileInfo.setFile(aCompDataType.c_str());
621 myFileName = VISU::GenerateName("aResult").toLatin1().data();
622 SetInitFileName(aCompDataType);
623 SetName(VISU::GenerateName(myFileInfo.fileName().toLatin1().data()).toLatin1().data(), false);
625 CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField);
626 SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR);
628 return Build(aFieldSObject);
629 }catch(std::exception& exc){
630 INFOS("Follow exception was occured :\n"<<exc.what());
632 INFOS("Unknown exception was occured!!!");
638 //---------------------------------------------------------------
641 ::Save(SALOMEDS::SComponent_ptr theComponent,
642 const std::string& theURL,
645 TFileNames& theFileNames,
646 TFileNames& theFiles)
648 switch(GetCreationId()){
649 case Result_i::eImportFile:
650 case Result_i::eCopyAndImportFile: {
651 INITMSG(MYDEBUG, "Result::Save - this = "<<this<<"\n");
652 INITMSGA(MYDEBUG, 0, "theIsMultiFile = "<<theIsMultiFile<<"; theIsASCII = "<<theIsASCII<<"\n");
655 if (theIsMultiFile) {
656 CORBA::String_var anURL = GetStudyDocument()->URL();
657 aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
660 std::string aFileName = aPrefix + "_" + GetFileName().c_str();
661 BEGMSG(MYDEBUG, "aFileName = '"<<aFileName<<"'\n");
663 std::string aFile = GetFileInfo().filePath().toLatin1().data();
664 BEGMSG(MYDEBUG, "aFile = '"<<aFile<<"'\n");
666 if(theIsMultiFile || theIsASCII){
667 std::string aPathToCopy(theURL + aFileName);
668 BEGMSG(MYDEBUG, "aPathToCopy = '"<<aPathToCopy<<"'\n");
670 if(!VISU::CopyFile(aFile, aPathToCopy))
674 HDFascii::ConvertFromHDFToASCII(const_cast<char*>(aPathToCopy.c_str()), true);
677 theFileNames.push_back(aFileName);
678 theFiles.push_back(aFile);
687 //---------------------------------------------------------------
690 ::CanCopy(SALOMEDS::SObject_ptr theObject)
692 switch(GetCreationId()){
693 case Result_i::eImportFile:
694 case Result_i::eCopyAndImportFile:
702 //---------------------------------------------------------------
705 ::CopyFrom(SALOMEDS::SObject_ptr theObject,
706 CORBA::Long& theObjectID,
707 const std::string& theTmpDir,
708 TFileNames& theFileNames)
710 if(!Storable::CopyFrom(theObject, theObjectID, theTmpDir, theFileNames))
713 SALOMEDS::Study_var aStudy = theObject->GetStudy();
714 CORBA::String_var anURL = aStudy->URL();
715 std::string aPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
716 std::string aFileName = aPrefix + GetFileInfo().fileName().toLatin1().data();
718 static QString aCommand;
719 std::string aFilePath = theTmpDir + aFileName;
720 aCommand.sprintf(" %s %s", GetFileInfo().filePath().toLatin1().data(), aFilePath.c_str());
721 aCommand = QDir::convertSeparators( aCommand );
722 aCommand.prepend( COPY_COMMAND );
724 if(system(aCommand.toLatin1().data()) != 0) {
725 if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand.toLatin1().data());
729 SALOMEDS::SComponent_var aSComponent = aStudy->FindComponent("VISU");
731 theFileNames.push_back(aFileName);
737 //---------------------------------------------------------------
740 ::Restore(SALOMEDS::SObject_ptr theSObject,
741 const Storable::TRestoringMap& theMap,
742 const string& thePrefix,
743 CORBA::Boolean theIsMultiFile)
745 if(MYDEBUG) MESSAGE("Result_i::Restore - " << thePrefix);
746 mySObject = SALOMEDS::SObject::_duplicate(theSObject);
747 mySComponent = mySObject->GetFatherComponent();
748 myStudyDocument = theSObject->GetStudy();
749 myStudy = VISU::GetStudy(myStudyDocument);
751 myCreationId = ECreationId(Storable::FindValue(theMap, "myCreationId").toInt());
752 mySourceId = eRestoredFile;
753 if(myCreationId == eImportMed || myCreationId == eImportMedField)
754 mySourceId = eRestoredComponent;
756 myIsBuildFields = Storable::FindValue(theMap, "myIsBuildFields", "1").toInt();
757 myIsBuildMinMax = Storable::FindValue(theMap, "myIsBuildMinMax", "1").toInt();
758 myIsBuildGroups = Storable::FindValue(theMap, "myIsBuildGroups", "1").toInt();
760 myIsBuildImmediately = true;
763 myFileName = VISU::Storable::FindValue(theMap, "myName").toLatin1().data();
764 SetInitFileName(VISU::Storable::FindValue(theMap, "myInitFileName").toLatin1().data());
766 SALOMEDS::SObject_var aRefSObj, aTargetRefSObj;
767 if (theSObject->FindSubObject(1, aRefSObj) && aRefSObj->ReferencedObject(aTargetRefSObj)) {
768 if(MYDEBUG) MESSAGE("Result_i::GetInput - There is some reference.");
769 SALOMEDS::SComponent_var aCompRefSObj = aTargetRefSObj->GetFatherComponent();
770 CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
771 myFileInfo.setFile(aDataType.in());
772 if(MYDEBUG) MESSAGE("Result_i::GetInput - aDataType = " << aDataType);
773 Engines::Component_var aEngComp =
774 Base_i::myEnginesLifeCycle->FindOrLoad_Component("FactoryServer", aDataType.in());
775 if (CORBA::is_nil(aEngComp))
776 throw std::runtime_error("Restore - There is no aEngComp for the aDataType !!!");
777 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
778 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp);
779 aStudyBuilder->LoadWith(aCompRefSObj, aDriver);
780 // create field or MED converter
781 CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj);
782 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(aMedObject);
783 if (!CORBA::is_nil(aField)) {
784 // create field converter
785 myInput.reset(CreateMEDFieldConvertor(aField));
788 else if (strcmp(aDataType, "MED") == 0) {
789 // create MED converter
790 myInput.reset(CreateMEDConvertor(aTargetRefSObj));
794 throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!");
797 myFileInfo.setFile(thePrefix.c_str());
799 std::string aStudyPrefix ("");
800 if (theIsMultiFile) {
801 CORBA::String_var anURL(GetStudyDocument()->URL());
802 aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(anURL.in());
804 if (!myFileInfo.isFile()) {
805 std::string aFileName = thePrefix + aStudyPrefix + "_" + myFileName;
806 myFileInfo.setFile(aFileName.c_str());
809 MESSAGE("Result_i::Restore - aFileName = " << myFileInfo.filePath().toLatin1().data() << "; " << myFileInfo.isFile());
811 if (HDFascii::isASCII(myFileInfo.filePath().toLatin1().data())) {
812 MESSAGE("ConvertFromASCIIToHDF(" << myFileInfo.filePath().toLatin1().data() << ")");
813 char* aResultPath = HDFascii::ConvertFromASCIIToHDF(myFileInfo.filePath().toLatin1().data());
814 MESSAGE("ConvertFromASCIIToHDF() DONE : " << aResultPath);
815 char* aHDFFileName = new char[strlen(aResultPath) + 19];
816 sprintf(aHDFFileName, "%shdf_from_ascii.hdf", aResultPath);
818 if (theIsMultiFile) { // set this file as new - temporary
819 static QString aCommand;
820 aCommand.sprintf(" %s %s%s",aHDFFileName, aResultPath, myFileInfo.baseName().toLatin1().data());
821 aCommand = QDir::convertSeparators( aCommand );
822 aCommand.prepend( MOVE_COMMAND );
824 if (system(aCommand.toLatin1().data()) == -1) {
825 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand.toLatin1().data());
828 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand.toLatin1().data());
830 myFileInfo.setFile(QString(aResultPath) + myFileInfo.baseName());
831 } else { // change current temporary file to the new: with hdf-format
832 static QString aCommand;
833 aCommand.sprintf(" %s %s\0",aHDFFileName, myFileInfo.filePath().toLatin1().data());
834 aCommand = QDir::convertSeparators( aCommand );
835 aCommand.prepend( MOVE_COMMAND );
837 if (system(aCommand.toLatin1().data()) == -1) {
838 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand.toLatin1().data());
841 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand.toLatin1().data());
843 SALOMEDS::ListOfFileNames_var anEmptyList = new SALOMEDS::ListOfFileNames;
844 SALOMEDS_Tool::RemoveTemporaryFiles(aResultPath, anEmptyList.in(), true);
846 mySourceId = eRestoredFile;
848 delete(aHDFFileName);
849 } else if (!theIsMultiFile) {
850 mySourceId = eRestoredFile;
852 mySourceId = eSavedFile;
854 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId);
855 myInput.reset(CreateConvertor(myFileInfo.filePath().toLatin1().data()));
857 myInput->BuildEntities();
859 myInput->BuildFields();
860 myIsFieldsDone = true;
862 myInput->BuildMinMax();
863 myIsMinMaxDone = true;
867 myInput->BuildGroups();
868 myIsGroupsDone = true;
872 aComment.sprintf("myComment=%s;myFileName=%s;myInitFileName=%s",
874 myFileInfo.filePath().toLatin1().data(),
875 GetInitFileName().c_str()); // Restoring of Python dump
876 SALOMEDS::GenericAttribute_var anAttr;
877 if (!theSObject->FindAttribute(anAttr, "AttributeString"))
878 throw std::runtime_error("Build - There is no AttributeString for the SObject !!!");
879 SALOMEDS::AttributeString_var aCmnt = SALOMEDS::AttributeString::_narrow(anAttr);
880 aCmnt->SetValue(aComment.toLatin1().data());
882 bool anIsBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
886 } catch(std::exception& exc) {
887 INFOS("Follow exception was occured :\n"<<exc.what());
889 INFOS("Unknown exception was occured!!!");
895 //---------------------------------------------------------------
896 VISU::Result_i::PInput
898 ::GetInput(const std::string& theMeshName,
899 VISU::Entity theEntity,
900 const std::string& theFieldName,
901 CORBA::Long theTimeStampNumber)
907 //---------------------------------------------------------------
914 (myIsBuildFields? myIsFieldsDone: true) &&
915 (myIsBuildMinMax? myIsMinMaxDone: true) &&
916 (myIsBuildGroups? myIsGroupsDone: true);
923 return myIsEntitiesDone;
928 ::SetBuildFields(CORBA::Boolean theIsBuildFields,
929 CORBA::Boolean theIsCalculateMinMax)
931 myIsBuildFields = theIsBuildFields;
933 myIsBuildMinMax = theIsCalculateMinMax;
935 myIsBuildMinMax = false;
940 ::SetBuildGroups(CORBA::Boolean theIsBuildGroups)
942 myIsBuildGroups = theIsBuildGroups;
949 return myIsFieldsDone;
956 return myIsGroupsDone;
963 return myIsMinMaxDone;
970 return myIsPartsDone;
974 //---------------------------------------------------------------
975 VISU::Result::EntityNames*
979 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
980 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
982 return aResult._retn();
984 aResult->length(aMeshMap.size());
985 VISU::TMeshMap::const_iterator anIter = aMeshMap.begin();
986 for(size_t anId = 0; anIter != aMeshMap.end(); anIter++, anId++){
987 const std::string& aName = anIter->first;
988 aResult[anId] = aName.c_str();
991 return aResult._retn();
995 //---------------------------------------------------------------
996 VISU::Result::Entities*
998 ::GetEntities(const char* theMeshName)
1000 VISU::Result::Entities_var anEntities = new VISU::Result::Entities();
1001 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1002 if(aMeshMap.empty())
1003 return anEntities._retn();
1005 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1006 if(anIter == aMeshMap.end())
1007 return anEntities._retn();
1009 const VISU::PMesh& aMesh = anIter->second;
1010 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1011 if(aMeshOnEntityMap.empty())
1012 return anEntities._retn();
1015 anEntities->length(aMeshOnEntityMap.size());
1016 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.begin();
1017 for(size_t anId = 0; anIter != aMeshOnEntityMap.end(); anIter++, anId++){
1018 const VISU::TEntity& anEntity = anIter->first;
1019 anEntities[anId] = VISU::Entity(anEntity);
1023 return anEntities._retn();
1027 //---------------------------------------------------------------
1028 VISU::Result::EntityNames*
1030 ::GetFamilies(const char* theMeshName,
1031 VISU::Entity theEntity)
1033 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1034 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1035 if(aMeshMap.empty())
1036 return aResult._retn();
1038 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1039 if(anIter == aMeshMap.end())
1040 return aResult._retn();
1042 const VISU::PMesh& aMesh = anIter->second;
1043 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1044 if(aMeshOnEntityMap.empty())
1045 return aResult._retn();
1048 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1049 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1050 if(anIter == aMeshOnEntityMap.end())
1051 return aResult._retn();
1053 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1054 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1055 if(aFamilyMap.empty())
1056 return aResult._retn();
1059 aResult->length(aFamilyMap.size());
1060 VISU::TFamilyMap::const_iterator anIter = aFamilyMap.begin();
1061 for(size_t anId = 0; anIter != aFamilyMap.end(); anIter++, anId++){
1062 const std::string& aName = anIter->first;
1063 aResult[anId] = aName.c_str();
1068 return aResult._retn();
1072 //---------------------------------------------------------------
1073 VISU::Result::EntityNames*
1075 ::GetGroups(const char* theMeshName)
1077 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1078 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1079 if(aMeshMap.empty())
1080 return aResult._retn();
1082 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1083 if(anIter == aMeshMap.end())
1084 return aResult._retn();
1086 const VISU::PMesh& aMesh = anIter->second;
1087 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1088 if(aGroupMap.empty())
1089 return aResult._retn();
1092 aResult->length(aGroupMap.size());
1093 VISU::TGroupMap::const_iterator anIter = aGroupMap.begin();
1094 for(size_t anId = 0; anIter != aGroupMap.end(); anIter++, anId++){
1095 const std::string& aName = anIter->first;
1096 aResult[anId] = aName.c_str();
1100 return aResult._retn();
1104 //---------------------------------------------------------------
1105 VISU::Result::EntityNames*
1107 ::GetFields(const char* theMeshName,
1108 VISU::Entity theEntity)
1110 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1111 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1112 if(aMeshMap.empty())
1113 return aResult._retn();
1115 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1116 if(anIter == aMeshMap.end())
1117 return aResult._retn();
1119 const VISU::PMesh& aMesh = anIter->second;
1120 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1121 if(aMeshOnEntityMap.empty())
1122 return aResult._retn();
1125 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1126 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1127 if(anIter == aMeshOnEntityMap.end())
1128 return aResult._retn();
1130 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1131 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1132 if(aFieldMap.empty())
1133 return aResult._retn();
1136 aResult->length(aFieldMap.size());
1137 VISU::TFieldMap::const_iterator anIter = aFieldMap.begin();
1138 for(size_t anId = 0; anIter != aFieldMap.end(); anIter++, anId++){
1139 const std::string& aName = anIter->first;
1140 aResult[anId] = aName.c_str();
1145 return aResult._retn();
1149 //---------------------------------------------------------------
1150 VISU::Result::TimeStampNumbers*
1152 ::GetTimeStampNumbers(const char* theMeshName,
1153 VISU::Entity theEntity,
1154 const char* theFieldName)
1156 VISU::Result::TimeStampNumbers_var aResult = new VISU::Result::TimeStampNumbers();
1157 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1158 if(aMeshMap.empty())
1159 return aResult._retn();
1161 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1162 if(anIter == aMeshMap.end())
1163 return aResult._retn();
1165 const VISU::PMesh& aMesh = anIter->second;
1166 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1167 if(aMeshOnEntityMap.empty())
1168 return aResult._retn();
1171 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1172 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1173 if(anIter == aMeshOnEntityMap.end())
1174 return aResult._retn();
1176 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1177 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1178 if(aFieldMap.empty())
1179 return aResult._retn();
1182 VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName);
1183 if(anIter == aFieldMap.end())
1184 return aResult._retn();
1187 const VISU::PField& aField = anIter->second;
1188 const VISU::TValField& aValField = aField->myValField;
1189 if(aValField.empty())
1190 return aResult._retn();
1193 aResult->length(aValField.size());
1194 VISU::TValField::const_iterator anIter = aValField.begin();
1195 for(size_t anId = 0; anIter != aValField.end(); anIter++, anId++){
1196 const vtkIdType& aTimeStampNumber = anIter->first;
1197 aResult[anId] = aTimeStampNumber;
1204 return aResult._retn();
1208 //---------------------------------------------------------------
1211 ::GetNumberOfComponents(const char* theMeshName,
1212 VISU::Entity theEntity,
1213 const char* theFieldName)
1215 CORBA::Long aResult = 0;
1216 const VISU::TMeshMap& aMeshMap = GetInput()->GetMeshMap();
1217 if(aMeshMap.empty())
1220 VISU::TMeshMap::const_iterator anIter = aMeshMap.find(theMeshName);
1221 if(anIter == aMeshMap.end())
1224 const VISU::PMesh& aMesh = anIter->second;
1225 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1226 if(aMeshOnEntityMap.empty())
1230 VISU::TEntity anEntity = VISU::TEntity(theEntity);
1231 VISU::TMeshOnEntityMap::const_iterator anIter = aMeshOnEntityMap.find(anEntity);
1232 if(anIter == aMeshOnEntityMap.end())
1235 const VISU::PMeshOnEntity& aMeshOnEntity = anIter->second;
1236 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1237 if(aFieldMap.empty())
1241 VISU::TFieldMap::const_iterator anIter = aFieldMap.find(theFieldName);
1242 if(anIter == aFieldMap.end())
1246 const VISU::PField& aField = anIter->second;
1247 aResult = aField->myNbComp;
1256 //---------------------------------------------------------------
1257 VISU::Result::EntityNames*
1259 ::GetPartNames(const char* theMeshName)
1261 VISU::Result::EntityNames_var aResult = new VISU::Result::EntityNames();
1262 return aResult._retn();
1266 //---------------------------------------------------------------
1267 VISU::Result::Resolutions*
1269 ::GetResolutions(const char* theMeshName,
1270 const char* thePartName)
1272 VISU::Result::Resolutions_var aResult = new VISU::Result::Resolutions();
1273 return aResult._retn();
1277 //---------------------------------------------------------------
1278 VISU::Result::Resolution
1280 ::GetResolution(const char* theMeshName,
1281 const char* thePartName)
1283 return VISU::Result::HIDDEN;
1287 //---------------------------------------------------------------
1290 ::SetResolution(const char* theMeshName,
1291 const char* thePartName,
1292 VISU::Result::Resolution theResolution)
1296 //---------------------------------------------------------------
1299 ::New(SALOMEDS::Study_ptr theStudy,
1300 const ESourceId& theSourceId,
1301 const ECreationId& theCreationId,
1302 CORBA::Boolean theIsBuildImmediately,
1303 CORBA::Boolean theIsBuildFields,
1304 CORBA::Boolean theIsBuildMinMax,
1305 CORBA::Boolean theIsBuildGroups)
1307 return new RESULT_CLASS_NAME(theStudy,
1310 theIsBuildImmediately,
1317 //---------------------------------------------------------------
1320 ::StorableEngine(SALOMEDS::SObject_ptr theSObject,
1321 const Storable::TRestoringMap& theMap,
1322 const std::string& thePrefix,
1323 CORBA::Boolean theIsMultiFile)
1325 VISU::Result_i* aResult = new RESULT_CLASS_NAME();
1326 return aResult->Restore(theSObject, theMap, thePrefix, theIsMultiFile);
1330 //---------------------------------------------------------------
1333 ::ToStream(std::ostringstream& theStr)
1335 Storable::DataToStream(theStr,"myName", GetFileName().c_str());
1336 Storable::DataToStream(theStr,"myInitFileName", GetInitFileName().c_str());
1337 Storable::DataToStream(theStr,"myCreationId", myCreationId);
1338 Storable::DataToStream(theStr,"myIsBuildFields", myIsFieldsDone);
1339 Storable::DataToStream(theStr,"myIsBuildMinMax", myIsMinMaxDone);
1340 Storable::DataToStream(theStr,"myIsBuildGroups", myIsGroupsDone);
1343 //---------------------------------------------------------------
1347 ::ExportMED(const char* theTargetFileName)
1349 static QString aCommand;
1350 const char* aTempFileName = myFileInfo.absoluteFilePath().toLatin1();
1351 aCommand.sprintf(" %s %s", aTempFileName, theTargetFileName);
1352 aCommand = QDir::convertSeparators( aCommand );
1353 aCommand.prepend( COPY_COMMAND );
1355 if(system(aCommand.toLatin1().data()) != 0) {
1356 if(MYDEBUG) MESSAGE("VISU_Gen_i::Copy - Cann't execute the command :"<<aCommand.toLatin1().data());
1363 //---------------------------------------------------------------
1366 ::GetInitFileName() const
1368 return myInitFileName;
1374 ::SetInitFileName(const std::string& theFileName)
1376 myInitFileName = theFileName;
1380 //---------------------------------------------------------------
1383 ::GetFileName() const
1385 if(GetSourceId() == eFile)
1386 return VISU::MakeFileName(myFileName, this);
1394 ::GetFileInfo() const
1399 VISU::Result_i::ECreationId
1401 ::GetCreationId() const
1403 return myCreationId;
1407 VISU::Result_i::ESourceId
1409 ::GetSourceId() const
1415 //---------------------------------------------------------------
1420 CORBA::String_var anEntry = mySObject->GetID();
1421 return anEntry.in();
1424 SALOMEDS::SObject_var
1426 ::GetSObject() const
1433 ::GetStudyDocument() const
1435 return myStudyDocument;
1445 SALOMEDS::SComponent_var
1447 ::GetSComponent() const
1449 return mySComponent;
1454 ::GetEntry(const Storable::TRestoringMap& theRestoringMap)
1456 return Storable::FindEntry(myStudyDocument,
1462 //=======================================================================
1463 //function : GetAxisInfo
1465 //=======================================================================
1466 const VISU::Result_i::TAxisInfo*
1468 ::GetAxisInfo(const string& theMeshName,
1470 gp_Dir& thePlaneNormal)
1472 const TAxisInfo* components = NULL;
1474 if ( theAxis < AXIS_X || theAxis > AXIS_Z ) {
1475 MESSAGE(" Bad axis index " << theAxis );
1479 map< string, TGridInfo >::iterator name_info;
1480 name_info = myMeshName2GridInfoMap.find( theMeshName );
1481 TGridInfo * gInfo = 0;
1483 if ( name_info != myMeshName2GridInfoMap.end() )
1485 gInfo = & name_info->second;
1487 else if ( myInput && IsPossible() && theAxis >= AXIS_X && theAxis <= AXIS_Z )
1489 // check presence of theMeshName
1490 const VISU::TMeshMap& meshMap = myInput->GetMeshMap();
1492 VISU::TMeshMap::const_iterator aIter = meshMap.find( theMeshName );
1493 if ( aIter == meshMap.end() ) {
1494 MESSAGE("No mesh named " << theMeshName );
1497 theMesh = aIter->second;
1499 VISU::PUnstructuredGridIDMapper anIDMapper = myInput->GetMeshOnEntity(theMeshName,
1501 vtkUnstructuredGrid* aMesh = anIDMapper->GetUnstructuredGridOutput();
1503 if ( !aMesh || aMesh->GetNumberOfCells() == 0 ) {
1504 MESSAGE( "No cells in the mesh: " << theMeshName );
1508 if ( !theMesh->IsStructured() || theMesh->myIsPolarType ) {
1509 // define axis directions and min cell size in each direction
1510 const int nbAxes = 3;
1512 gp_Vec axDirs[ nbAxes ];
1513 float minSize[3] = { FLT_MAX, FLT_MAX, FLT_MAX };
1514 bool axesComputed = false;
1515 for ( vtkIdType iCell = 0; iCell < aMesh->GetNumberOfCells(); ++iCell ) {
1516 vtkCell* cell = aMesh->GetCell( iCell );
1518 if (cell->GetCellType() != VTK_HEXAHEDRON &&
1519 cell->GetCellType() != VTK_QUADRATIC_HEXAHEDRON )
1521 vtkPoints * points = cell->GetPoints();
1522 vtkFloatingPointType coords[ 4 ][3];
1523 points->GetPoint( 0, coords[0] );
1524 points->GetPoint( 1, coords[1] );
1525 points->GetPoint( 3, coords[2] );
1526 points->GetPoint( 4, coords[3] );
1527 gp_Pnt p0( coords[0][0], coords[0][1], coords[0][2] );
1528 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1529 vtkFloatingPointType* coo = coords[ iAx + 1 ];
1530 gp_Pnt p( coo[0], coo[1], coo[2] );
1532 vtkFloatingPointType size = p0.SquareDistance( p );
1533 if ( size > FLT_MIN && size < minSize[ iAx ] )
1534 minSize[ iAx ] = size;
1536 if ( !axesComputed ) {
1537 gp_Vec dir( p0, p );
1538 if ( dir.SquareMagnitude() <= gp::Resolution() ) {
1541 axDirs[ iAx ] = dir;
1544 if ( iAx == nbAxes )
1545 axesComputed = true;
1547 if ( !axesComputed ) {
1548 MESSAGE("No good hexahedrons in the mesh: " << theMeshName );
1552 // compute axes dirs
1553 gInfo = & myMeshName2GridInfoMap[ theMeshName ];
1554 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1555 int iPrev = ( iAx == 0 ) ? 2 : iAx - 1;
1556 int iNext = ( iAx == 2 ) ? 0 : iAx + 1;
1557 gInfo->myAxis[ iAx ] = axDirs[ iPrev ] ^ axDirs[ iNext ];
1560 // get and sort intermediate component values - projections of nodes
1561 // on axis direction; define bnd box
1562 set< vtkFloatingPointType > comps[ 3 ];
1564 vtkPoints * points = aMesh->GetPoints();
1565 vtkIdType iP, nbP = aMesh->GetNumberOfPoints();
1566 for ( iP = 0; iP < nbP; ++iP ) {
1567 vtkFloatingPointType coo[3];
1568 points->GetPoint( iP, coo );
1569 gp_Pnt p( coo[0], coo[1], coo[2] );
1571 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1572 const gp_Dir& dir = gInfo->myAxis[ iAx ];
1573 vtkFloatingPointType dot = dir.XYZ() * p.XYZ();
1574 comps[ iAx ].insert( dot );
1578 // find a range of projections of bnd box corners on each axis
1579 vtkFloatingPointType range[3], firstValue[3];
1580 double x[2],y[2],z[2];
1581 box.Get(x[0],y[0],z[0],x[1],y[1],z[1]);
1582 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1583 set< vtkFloatingPointType > bndComps;
1584 const gp_Dir& dir = gInfo->myAxis[ iAx ];
1585 for ( int iX = 0; iX < 2; ++iX ) {
1586 for ( int iY = 0; iY < 2; ++iY ) {
1587 for ( int iZ = 0; iZ < 2; ++iZ ) {
1588 gp_Pnt p( x[ iX ], y[ iY ], z[ iZ ] );
1589 vtkFloatingPointType dot = dir.XYZ() * p.XYZ();
1590 bndComps.insert( dot );
1594 firstValue[ iAx ] = *bndComps.begin();
1595 range[ iAx ] = *bndComps.rbegin() - *bndComps.begin();
1598 // compute component values
1599 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1600 list< vtkFloatingPointType > values;
1602 set< vtkFloatingPointType >& comp = comps[ iAx ];
1603 set< vtkFloatingPointType >::iterator val = comp.begin();
1604 vtkFloatingPointType bnd = -1., rng = range[ iAx ], first = firstValue[ iAx ];
1605 vtkFloatingPointType tol = 0.1 * sqrt( minSize[ iAx ]) / rng;
1606 for ( ; val != comp.end(); ++val ) {
1607 vtkFloatingPointType value = ( *val - first ) / rng;
1608 if ( value > bnd ) {
1609 values.push_back( value );
1614 // store values in gInfo
1615 vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ iAx ];
1616 myComp.resize( nbVals );
1617 list< vtkFloatingPointType >::iterator v = values.begin();
1618 for ( int i = 0; v != values.end(); ++v ){
1624 vtkIdType aMeshDim = theMesh->myDim;
1625 gInfo = & myMeshName2GridInfoMap[ theMeshName ];
1626 switch ( aMeshDim ) {
1628 gp_Dir aDir(0.0,0.0,1.0);
1629 gInfo->myAxis[ 2 ] = aDir;
1632 gp_Dir aDir(0.0,1.0,0.0);
1633 gInfo->myAxis[ 1 ] = aDir;
1636 gp_Dir aDir(1.0,0.0,0.0);
1637 gInfo->myAxis[ 0 ] = aDir;
1640 TStructuredId aStructuredId = theMesh->GetStructure();
1641 vector<vtkFloatingPointType> PointsCoords[3];
1642 vtkPoints* aPoints = aMesh->GetPoints();
1643 switch ( aMeshDim ) {
1645 TStructuredId aCoordIJK;
1646 vtkIdType nbZ = aStructuredId[2];
1647 for ( int i = 0; i < nbZ; i++ ) {
1648 aCoordIJK[2] = i + 1;
1649 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1650 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1651 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1652 PointsCoords[2].push_back(aPCoord[2]);
1656 TStructuredId aCoordIJK;
1657 vtkIdType nbJ = aStructuredId[1];
1658 for ( int i = 0; i < nbJ; i++ ) {
1659 aCoordIJK[1] = i + 1;
1660 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1661 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1662 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1663 PointsCoords[1].push_back(aPCoord[1]);
1667 TStructuredId aCoordIJK;
1668 vtkIdType nbI = aStructuredId[0];
1669 for ( int i = 0; i < nbI; i++ ) {
1670 aCoordIJK[0] = i + 1;
1671 vtkIdType aObjID = anIDMapper->GetObjectIDByIndexes(aCoordIJK);
1672 vtkIdType aVTKID = anIDMapper->GetNodeVTKID(aObjID);
1673 vtkFloatingPointType* aPCoord = aPoints->GetPoint(aVTKID);
1674 PointsCoords[0].push_back(aPCoord[0]);
1677 for ( int i = 0; i < aMeshDim; i++ ) {
1678 vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ i ];
1679 int aSize = PointsCoords[i].size();
1681 vtkFloatingPointType aLen = PointsCoords[i][aSize-1] - PointsCoords[i][0];
1682 myComp.resize(aSize);
1684 for ( int k = 1; k < aSize; k++ ) {
1685 myComp[k]=myComp[k-1] + (PointsCoords[i][k]-PointsCoords[i][k-1])/aLen;
1692 // set return values
1694 thePlaneNormal = gInfo->myAxis[ theAxis ];
1695 components = & gInfo->myComponets[ theAxis ];
1701 SALOME_MED::MedFileInfo* VISU::Result_i::GetMEDFileInfo()
1703 SALOME_MED::MedFileInfo_var res = new SALOME_MED::MedFileInfo();
1705 QString fpath = myFileInfo.absoluteFilePath();
1706 res->fileName = fpath.toLatin1().constData();
1707 res->fileSize = myFileInfo.size();
1708 int major, minor, release;
1709 if( !MED::getMEDVersion( fpath.toLatin1().constData(), major, minor, release ) )
1717 res->release = release;