1 // VISU OBJECT : interactive object for VISU entities implementation
3 // Copyright (C) 2003 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 // File : VISU_Result_i.cc
24 // Author : Alexey PETROV
27 #include "VISU_Result_i.hh"
29 #include "VISU_Convertor_impl.hxx"
30 #include "VISU_CorbaMedConvertor.hxx"
31 #include "VISU_ConvertorUtils.hxx"
32 #include "VISU_PipeLine.hxx"
34 #include "SUIT_ResourceMgr.h"
36 #include "SALOMEDS_Tool.hxx"
37 #include "HDFascii.hxx"
39 #include "SUIT_Session.h"
40 #include "SALOME_Event.hxx"
41 #include "SalomeApp_Study.h"
42 #include "SalomeApp_Application.h"
44 #include <boost/thread/recursive_mutex.hpp>
45 #include <boost/thread/thread.hpp>
47 #include <boost/thread/mutex.hpp>
48 #include <boost/bind.hpp>
52 #include <qfileinfo.h>
53 #include <qsemaphore.h>
58 #include <vtkUnstructuredGrid.h>
61 #include <Bnd_Box.hxx>
67 static int MYDEBUG = 0;
68 static int MYTIMEDEBUG = 0;
70 static int MYDEBUG = 0;
71 static int MYTIMEDEBUG = 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 //---------------------------------------------------------------
100 typedef boost::recursive_mutex TMutex;
101 typedef TMutex::scoped_lock TLock;
103 static TMutex myMutex;
105 //---------------------------------------------------------------
106 struct TGetStudy: public SALOME_Event
108 typedef _PTR(Study) TResult;
112 TGetStudy(const int theStudyId):
113 myStudyId(theStudyId)
120 SUIT_Session* aSession = SUIT_Session::session();
121 QPtrList<SUIT_Application> anApplications = aSession->applications();
122 QPtrListIterator<SUIT_Application> anIter (anApplications);
123 while (SUIT_Application* aSApp = anIter.current()) {
124 if(SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSApp)){
125 if(SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy())) {
126 if(_PTR(Study) aStudyDS = aStudy->studyDS()){
127 if(aStudyDS->StudyId() == myStudyId){
128 myResult = aStudy->studyDS();
140 //---------------------------------------------------------------
142 GenerateName (const char* theName)
144 TLock aLock(myMutex);
146 typedef map<string,int> TNameMap;
147 static TNameMap aMap;
149 TNameMap::const_iterator i = aMap.find(theName);
151 if (i == aMap.end()) {
155 tmp = GenerateName(theName,++aMap[theName]);
157 if(MYDEBUG) MESSAGE("GenerateName - "<<tmp<<" from - "<<theName<<"; " <<aMap[theName]);
162 //---------------------------------------------------------------
164 GenerateFieldName (const string& theName, const string& theUnits)
167 const string tmp (theUnits.size(),' ');
168 if (theUnits == "" || theUnits == tmp)
169 aName.sprintf("%s, -",theName.c_str());
171 aName.sprintf("%s, %s",theName.c_str(),theUnits.c_str());
172 aName = aName.simplifyWhiteSpace();
173 return aName.latin1();
177 //---------------------------------------------------------------
179 GetComponentDataType (SALOMEDS::SObject_ptr theSObject)
181 SALOMEDS::SComponent_var aCompRefSObj = theSObject->GetFatherComponent();
182 CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
183 return aDataType.in();
187 //---------------------------------------------------------------
189 CreateReference (SALOMEDS::Study_ptr theStudyDocument,
190 const string& theFatherEntry,
191 const string& theRefEntry)
193 SALOMEDS::StudyBuilder_var aStudyBuilder = theStudyDocument->NewBuilder();
194 SALOMEDS::SObject_var aFather = theStudyDocument->FindObjectID(theFatherEntry.c_str());
195 SALOMEDS::SObject_var newObj = aStudyBuilder->NewObject(aFather);
196 SALOMEDS::SObject_var aRefSObj = theStudyDocument->FindObjectID(theRefEntry.c_str());
197 aStudyBuilder->Addreference(newObj,aRefSObj);
201 //---------------------------------------------------------------
203 CreateReference (_PTR(Study) theStudyDocument,
204 const string& theFatherEntry,
205 const string& theRefEntry)
207 TLock aLock(myMutex);
209 _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
210 _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry);
211 _PTR(SObject) aNewObj = aStudyBuilder->NewObject(aFather);
212 _PTR(SObject) aRefSObj = theStudyDocument->FindObjectID(theRefEntry);
213 aStudyBuilder->Addreference(aNewObj,aRefSObj);
217 //---------------------------------------------------------------
220 CreateAttributes(_PTR(Study) theStudyDocument,
221 const string& theFatherEntry,
222 const string& theIOR,
223 const string& theName,
224 const string& theComment,
225 CORBA::Boolean theCreateNew)
227 TLock aLock(myMutex);
229 _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
230 _PTR(SObject) aFather = theStudyDocument->FindObjectID(theFatherEntry);
232 _PTR(SObject) aNewObj;
234 aNewObj = aStudyBuilder->NewObject(aFather);
238 _PTR(GenericAttribute) anAttr;
240 anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeIOR");
241 _PTR(AttributeIOR) anIOR (anAttr);
242 anIOR->SetValue(theIOR);
245 anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeName");
246 _PTR(AttributeName) aName (anAttr);
247 aName->SetValue(theName);
249 if (theComment != "") {
250 anAttr = aStudyBuilder->FindOrCreateAttribute(aNewObj, "AttributeComment");
251 _PTR(AttributeComment) aCmnt (anAttr);
252 aCmnt->SetValue(theComment);
254 return aNewObj->GetID();
258 //---------------------------------------------------------------
261 UpdateAttributes(_PTR(Study) theStudyDocument,
262 const string& theEntry,
263 const string& theIOR,
264 const string& theName,
265 const string& theComment)
267 TLock aLock(myMutex);
269 _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
270 _PTR(SObject) aSObject = theStudyDocument->FindObjectID(theEntry);
272 _PTR(GenericAttribute) anAttr;
274 anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeIOR");
275 _PTR(AttributeIOR) anIOR (anAttr);
276 anIOR->SetValue(theIOR);
279 anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeName");
280 _PTR(AttributeName) aName (anAttr);
281 aName->SetValue(theName);
283 if (theComment != "") {
284 anAttr = aStudyBuilder->FindOrCreateAttribute(aSObject, "AttributeComment");
285 _PTR(AttributeComment) aCmnt (anAttr);
286 aCmnt->SetValue(theComment);
291 //---------------------------------------------------------------
294 RemoveSObject(_PTR(Study) theStudyDocument,
295 const string& theEntry)
297 TLock aLock(myMutex);
299 _PTR(StudyBuilder) aStudyBuilder = theStudyDocument->NewBuilder();
300 _PTR(SObject) aSObject = theStudyDocument->FindObjectID(theEntry);
301 aStudyBuilder->RemoveObject(aSObject);
305 //---------------------------------------------------------------
306 struct TResultManager
310 TResultManager(Result_i* theResult):
313 myResult->Register();
323 //---------------------------------------------------------------
324 struct TTransactionManager
326 _PTR(StudyBuilder) myStudyBuilder;
328 TTransactionManager(_PTR(Study) theStudyDocument):
329 myStudyBuilder(theStudyDocument->NewBuilder())
331 TLock aLock(myMutex);
332 myStudyBuilder->NewCommand();
335 ~TTransactionManager()
337 TLock aLock(myMutex);
338 myStudyBuilder->CommitCommand();
343 //---------------------------------------------------------------
344 struct TUpdateObjBrowser: public SALOME_Event
347 CORBA::Boolean* myIsDone;
348 TUpdateObjBrowser(const int theStudyId,
349 CORBA::Boolean* theIsDone):
350 myStudyId(theStudyId),
358 TLock aLock(myMutex);
359 SUIT_Session* aSession = SUIT_Session::session();
360 QPtrList<SUIT_Application> anApplications = aSession->applications();
361 QPtrListIterator<SUIT_Application> anIter (anApplications);
362 while (SUIT_Application* aSApp = anIter.current()) {
363 if(SalomeApp_Application* anApp = dynamic_cast<SalomeApp_Application*>(aSApp)){
364 if (SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(anApp->activeStudy())) {
365 if (_PTR(Study) aCStudy = aStudy->studyDS()) {
366 if (myStudyId == aCStudy->StudyId()) {
367 TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::updateObjectBrowser");
368 anApp->updateObjectBrowser();
381 //---------------------------------------------------------------
383 BuildEntities(Result_i* theResult,
384 VISU_Convertor* theInput,
385 CORBA::Boolean* theIsDone,
386 std::string theResultEntry,
387 CORBA::Boolean theIsAtOnce,
388 CORBA::Boolean theIsBuildGroups,
389 CORBA::Boolean theIsBuildFields,
390 _PTR(Study) theStudy)
395 TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildEntities");
396 TResultManager aResultManager(theResult);
397 TTransactionManager aTransactionManager(theStudy);
400 TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildEntities");
401 theInput->BuildEntities();
405 const TMeshMap& aMeshMap = theInput->GetMeshMap();
406 TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
407 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
408 const string& aMeshName = aMeshMapIter->first;
409 const PMesh& aMesh = aMeshMapIter->second;
410 const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
411 if(aMeshOnEntityMap.empty())
414 aComment.sprintf("myComment=MESH;myName=%s;myDim=%d",
418 CreateAttributes(theStudy,
425 aComment.sprintf("myComment=FAMILIES;myMeshName=%s",
427 string aSubMeshesEntry =
428 CreateAttributes(theStudy,
435 if(theIsBuildGroups){
436 aMesh->myGroupsEntry =
437 CreateAttributes(theStudy,
445 if(theIsBuildFields){
446 aMesh->myFieldsEntry =
447 CreateAttributes(theStudy,
456 TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
457 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
458 const TEntity& anEntity = aMeshOnEntityMapIter->first;
459 const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
464 anEntityName = "onNodes";
467 anEntityName = "onEdges";
470 anEntityName = "onFaces";
473 anEntityName = "onCells";
479 aComment.sprintf("myComment=ENTITY;myType=%d;myMeshName=%s;myId=%d",
484 aMeshOnEntity->myEntry =
485 CreateAttributes(theStudy,
488 anEntityName.c_str(),
494 ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
497 //---------------------------------------------------------------
499 BuildGroups(Result_i* theResult,
500 VISU_Convertor* theInput,
501 CORBA::Boolean* theIsDone,
502 CORBA::Boolean theIsBuild,
503 CORBA::Boolean theIsAtOnce,
504 _PTR(Study) theStudy)
506 if(!theIsBuild || *theIsDone)
509 TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildGroups");
510 TResultManager aResultManager(theResult);
511 TTransactionManager aTransactionManager(theStudy);
514 TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildGroups");
515 theInput->BuildGroups();
519 const TMeshMap& aMeshMap = theInput->GetMeshMap();
520 TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
521 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
522 const string& aMeshName = aMeshMapIter->first;
523 const PMesh& aMesh = aMeshMapIter->second;
525 const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
526 if(aMeshOnEntityMap.empty())
529 TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
530 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
531 const TEntity& anEntity = aMeshOnEntityMapIter->first;
532 const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
534 const TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
535 TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
536 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
537 const string& aFamilyName = aFamilyMapIter->first;
538 const PFamily& aFamily = aFamilyMapIter->second;
539 aComment.sprintf("myComment=FAMILY;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s",
543 aFamilyName.c_str());
545 CreateAttributes(theStudy,
546 aMeshOnEntity->myEntry,
554 const TGroupMap& aGroupMap = aMesh->myGroupMap;
555 if(!aGroupMap.empty()){
556 aComment.sprintf("myComment=GROUPS;myMeshName=%s",
559 UpdateAttributes(theStudy,
560 aMesh->myGroupsEntry,
565 TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
566 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
567 const string& aGroupName = aGroupMapIter->first;
568 const PGroup& aGroup = aGroupMapIter->second;
569 aComment.sprintf("myComment=GROUP;myType=%d;myMeshName=%s;myName=%s",
570 TGROUP,aMeshName.c_str(),aGroupName.c_str());
572 CreateAttributes(theStudy,
573 aMesh->myGroupsEntry,
578 const TFamilySet& aFamilySet = aGroup->myFamilySet;
579 TFamilySet::const_iterator aFamilyIter = aFamilySet.begin();
580 for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){
581 const PFamily& aFamily = *aFamilyIter;
582 CreateReference(theStudy,
587 }else if(!theIsAtOnce)
588 RemoveSObject(theStudy,
589 aMesh->myGroupsEntry);
592 ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
596 //---------------------------------------------------------------
598 BuildFields(Result_i* theResult,
599 VISU_Convertor* theInput,
600 CORBA::Boolean* theIsDone,
601 CORBA::Boolean theIsBuild,
602 CORBA::Boolean theIsAtOnce,
603 _PTR(Study) theStudy)
605 if(!theIsBuild || *theIsDone)
608 TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildFields");
609 TResultManager aResultManager(theResult);
610 TTransactionManager aTransactionManager(theStudy);
613 TTimerLog aTimerLog(MYTIMEDEBUG,"theInput->BuildFields");
614 theInput->BuildFields();
618 const TMeshMap& aMeshMap = theInput->GetMeshMap();
619 TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
620 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
621 const string& aMeshName = aMeshMapIter->first;
622 const PMesh& aMesh = aMeshMapIter->second;
624 const TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
625 if(aMeshOnEntityMap.empty())
629 bool anIsFieldsEntryUpdated = false;
630 TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
631 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
632 const TEntity& anEntity = aMeshOnEntityMapIter->first;
633 const PMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
634 const TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
635 TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
636 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
637 if(!anIsFieldsEntryUpdated){
638 aComment.sprintf("myComment=FIELDS;myMeshName=%s",
641 UpdateAttributes(theStudy,
642 aMesh->myFieldsEntry,
647 anIsFieldsEntryUpdated = true;
649 const string& aFieldName = aFieldMapIter->first;
650 const PField& aField = aFieldMapIter->second;
651 const TValField& aValField = aField->myValField;
652 QString aFieldNameWithUnit = GenerateFieldName(aFieldName,aField->myUnitNames[0]);
653 aComment.sprintf("myComment=FIELD;myType=%d;myMeshName=%s;myEntityId=%d;myName=%s;myNbTimeStamps=%d;myNumComponent=%d",
661 CreateAttributes(theStudy,
662 aMesh->myFieldsEntry,
664 aFieldNameWithUnit.latin1(),
667 CreateReference(theStudy,
669 aMeshOnEntity->myEntry);
670 TValField::const_iterator aValFieldIter = aValField.begin();
671 for(; aValFieldIter != aValField.end(); aValFieldIter++){
672 int aTimeStamp = aValFieldIter->first;
673 const PValForTime& aValForTime = aValFieldIter->second;
674 aComment.sprintf("myComment=TIMESTAMP;myType=%d;myMeshName=%s;myEntityId=%d;myFieldName=%s;myTimeStampId=%d;myNumComponent=%d",
681 string aTimeStampId = VISU_Convertor::GenerateName(aValForTime->myTime);
682 aValForTime->myEntry =
683 CreateAttributes(theStudy,
693 if(!anIsFieldsEntryUpdated && !theIsAtOnce)
694 RemoveSObject(theStudy,
695 aMesh->myFieldsEntry);
698 ProcessVoidEvent(new TUpdateObjBrowser(theStudy->StudyId(),theIsDone));
702 //---------------------------------------------------------------
704 BuildMinMax(Result_i* theResult,
705 VISU_Convertor* theInput,
706 CORBA::Boolean* theIsDone,
707 CORBA::Boolean theIsBuild,
708 Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal)
710 if(!theIsBuild || *theIsDone)
713 TTimerLog aTimerLog(MYTIMEDEBUG,"Result_i::BuildMinMax");
714 TResultManager aResultManager(theResult);
716 theInput->BuildMinMax();
720 (*theUpdateMinMaxSignal)();
724 //---------------------------------------------------------------
726 BuildFieldDataTree(Result_i* theResult,
727 VISU_Convertor* theInput,
728 CORBA::Boolean* theIsFieldsDone,
729 CORBA::Boolean theIsBuildFields,
730 CORBA::Boolean* theIsMinMaxDone,
731 CORBA::Boolean theIsBuildMinMax,
732 Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal,
733 _PTR(Study) theStudy)
735 BuildFields(theResult,
742 BuildMinMax(theResult,
746 theUpdateMinMaxSignal);
750 //---------------------------------------------------------------
754 VISU_Convertor* myInput;
755 CORBA::Boolean* myIsEntitiesDone;
756 std::string myResultEntry;
757 CORBA::Boolean* myIsFieldsDone;
758 CORBA::Boolean myIsBuildFields;
759 CORBA::Boolean* myIsMinMaxDone;
760 CORBA::Boolean myIsBuildMinMax;
761 Result_i::TUpdateMinMaxSignal* myUpdateMinMaxSignal;
762 CORBA::Boolean* myIsGroupsDone;
763 CORBA::Boolean myIsBuildGroups;
766 TBuildArgs(Result_i* theResult,
767 VISU_Convertor* theInput,
768 CORBA::Boolean* theIsEntitiesDone,
769 std::string theResultEntry,
770 CORBA::Boolean* theIsFieldsDone,
771 CORBA::Boolean theIsBuildFields,
772 CORBA::Boolean* theIsMinMaxDone,
773 CORBA::Boolean theIsBuildMinMax,
774 Result_i::TUpdateMinMaxSignal* theUpdateMinMaxSignal,
775 CORBA::Boolean* theIsGroupsDone,
776 CORBA::Boolean theIsBuildGroups,
777 _PTR(Study) theStudy):
780 myIsEntitiesDone(theIsEntitiesDone),
781 myResultEntry(theResultEntry),
782 myIsFieldsDone(theIsFieldsDone),
783 myIsBuildFields(theIsBuildFields),
784 myIsMinMaxDone(theIsMinMaxDone),
785 myIsBuildMinMax(theIsBuildMinMax),
786 myUpdateMinMaxSignal(theUpdateMinMaxSignal),
787 myIsGroupsDone(theIsGroupsDone),
788 myIsBuildGroups(theIsBuildGroups),
794 //---------------------------------------------------------------
796 BuildDataTree(TBuildArgs theBuildArgs)
798 BuildEntities(theBuildArgs.myResult,
799 theBuildArgs.myInput,
800 theBuildArgs.myIsEntitiesDone,
801 theBuildArgs.myResultEntry,
803 theBuildArgs.myIsBuildGroups,
804 theBuildArgs.myIsBuildFields,
805 theBuildArgs.myStudy);
807 boost::thread aThread(boost::bind(&BuildGroups,
808 theBuildArgs.myResult,
809 theBuildArgs.myInput,
810 theBuildArgs.myIsGroupsDone,
811 theBuildArgs.myIsBuildGroups,
813 theBuildArgs.myStudy));
816 boost::thread aThread(boost::bind(&BuildFieldDataTree,
817 theBuildArgs.myResult,
818 theBuildArgs.myInput,
819 theBuildArgs.myIsFieldsDone,
820 theBuildArgs.myIsBuildFields,
821 theBuildArgs.myIsMinMaxDone,
822 theBuildArgs.myIsBuildMinMax,
823 theBuildArgs.myUpdateMinMaxSignal,
824 theBuildArgs.myStudy));
831 //---------------------------------------------------------------
834 myMinMaxIsInitilized(false)
839 ::IsMinMaxInitilized()
841 return myMinMaxIsInitilized;
848 myMinMaxIsInitilized = true;
852 //---------------------------------------------------------------
853 const string VISU::Result_i::myComment = "RESULT";
854 const char* VISU::Result_i::GetComment() const { return myComment.c_str();}
856 //---------------------------------------------------------------
858 ::Result_i (SALOMEDS::Study_ptr theStudy,
859 const ESourceId& theSourceId,
860 const ECreationId& theCreationId,
861 CORBA::Boolean theIsBuildImmediately,
862 CORBA::Boolean theIsBuildFields,
863 CORBA::Boolean theIsBuildMinMax,
864 CORBA::Boolean theIsBuildGroups):
865 myStudyDocument(SALOMEDS::Study::_duplicate(theStudy)),
866 myCreationId(theCreationId),
867 mySourceId(theSourceId),
868 myIsBuildImmediately(theIsBuildImmediately),
869 myIsBuildFields(theIsBuildFields),
870 myIsBuildMinMax(theIsBuildMinMax),
871 myIsBuildGroups(theIsBuildGroups),
872 myIsEntitiesDone(false),
873 myIsFieldsDone(false),
874 myIsGroupsDone(false),
875 myIsMinMaxDone(false),
879 myStudy = ProcessEvent(new TGetStudy(myStudyDocument->StudyId()));
883 //---------------------------------------------------------------
888 struct TRemoveFromStudy: public SALOME_Event
890 VISU::Result_i* myRemovable;
891 TRemoveFromStudy(VISU::Result_i* theRemovable):
892 myRemovable(theRemovable)
899 VISU::RemoveFromStudy(myRemovable->GetSObject(),false);
900 myRemovable->Destroy();
904 // Remove the result with all presentations and other possible sub-objects
905 ProcessVoidEvent(new TRemoveFromStudy(this));
909 //---------------------------------------------------------------
912 ::MinMaxConnect(VISU::MinMaxCunsomer* theMinMaxCunsomer)
914 myUpdateMinMaxSignal.connect(boost::bind(&MinMaxCunsomer::UpdateMinMax,theMinMaxCunsomer));
918 //---------------------------------------------------------------
924 float aSize = myInput->GetSize();
925 bool aResult = VISU_PipeLine::CheckAvailableMemory(aSize);
926 MESSAGE("Result_i::IsPossible - CheckAvailableMemory = "<<float(aSize)<<"; aResult = "<<float(aResult));
928 }catch(std::exception& exc){
929 INFOS("Follow exception was occured :\n"<<exc.what());
931 INFOS("Unknown exception was occured!");
937 //---------------------------------------------------------------
942 if(MYDEBUG) MESSAGE("Result_i::Build - myIsAllDone = "<<myIsAllDone);
948 const VISU::TMeshMap& aMeshMap = myInput->GetMeshMap();
949 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
950 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
951 const string& aMeshName = aMeshMapIter->first;
952 const VISU::PMesh aMesh = aMeshMapIter->second;
953 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
954 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
956 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
957 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
958 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
959 const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
960 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
961 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
962 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
963 const string& aFieldName = aFieldMapIter->first;
964 const VISU::PField aField = aFieldMapIter->second;
965 const VISU::TValField& aValField = aField->myValField;
966 VISU::TValField::const_iterator aValFieldIter = aValField.begin();
967 for(; aValFieldIter != aValField.end(); aValFieldIter++){
968 int aTimeStamp = aValFieldIter->first;
970 myInput->GetTimeStampOnMesh(aMeshName,anEntity,aFieldName,aTimeStamp);
971 }catch(std::exception& exc){
972 INFOS("Follow exception was occured :\n"<<exc.what());
974 INFOS("Unknown exception was occured!!!");
979 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
980 VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
981 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
982 const string& aGroupName = aGroupMapIter->first;
984 myInput->GetMeshOnGroup(aMeshName,aGroupName);
985 }catch(std::exception& exc){
986 INFOS("Follow exception was occured :\n"<<exc.what());
988 INFOS("Unknown exception was occured!!!");
992 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
993 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
994 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
995 const string& aFamilyName = aFamilyMapIter->first;
997 myInput->GetFamilyOnEntity(aMeshName,anEntity,aFamilyName);
998 }catch(std::exception& exc){
999 INFOS("Follow exception was occured :\n"<<exc.what());
1001 INFOS("Unknown exception was occured!!!");
1004 //Import mesh on entity
1006 myInput->GetMeshOnEntity(aMeshName,anEntity);
1007 }catch(std::exception& exc){
1008 INFOS("Follow exception was occured :\n"<<exc.what());
1010 INFOS("Unknown exception was occured!!!");
1015 }catch(std::exception& exc){
1016 INFOS("Follow exception was occured :\n"<<exc.what());
1018 INFOS("Unknown exception was occured!!!");
1024 //---------------------------------------------------------------
1027 ::Build(CORBA::Boolean theIsBuildAll,
1028 CORBA::Boolean theIsAtOnce)
1033 if(Build(SALOMEDS::SObject::_nil(),theIsAtOnce)){
1043 //---------------------------------------------------------------
1046 ::Build(SALOMEDS::SObject_ptr theSObject,
1047 CORBA::Boolean theIsAtOnce)
1055 mySComponent = FindOrCreateVisuComponent(myStudyDocument);
1056 CORBA::String_var aSComponentEntry = mySComponent->GetID();
1057 CORBA::String_var anIOR(GetID());
1059 aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s",
1062 myFileInfo.filePath().latin1(),
1063 myInitFileName.c_str()); // Restoring of Python dump
1064 string aResultEntry =
1065 CreateAttributes(myStudy,
1066 aSComponentEntry.in(),
1071 mySObject = myStudyDocument->FindObjectID(aResultEntry.c_str());
1072 if(!CORBA::is_nil(theSObject)){
1073 CORBA::String_var aString = theSObject->GetID();
1074 CreateReference(myStudyDocument,aResultEntry,aString.in());
1105 &myUpdateMinMaxSignal);
1108 TBuildArgs aBuildArgs(this,
1116 &myUpdateMinMaxSignal,
1120 boost::thread aThread(boost::bind(&BuildDataTree,
1128 //---------------------------------------------------------------
1131 ::BuildAll(SALOMEDS::SObject_ptr theSObject)
1133 if(MYDEBUG) MESSAGE("Result_i::Build");
1137 }catch(std::exception& exc){
1138 INFOS("Follow exception was occured :\n"<<exc.what());
1141 INFOS("Unknown exception was occured!!!");
1149 //---------------------------------------------------------------
1152 Create(const char* theFileName)
1155 myFileInfo.setFile(theFileName);
1156 myInitFileName = myFileInfo.filePath().latin1();
1157 myName = ::GenerateName(myFileInfo.fileName()).latin1();
1158 if(mySourceId == eRestoredFile){
1159 std::string aTmpDir(SALOMEDS_Tool::GetTmpDir());
1160 static QString aCommand;
1161 aCommand.sprintf("cp %s %s",myFileInfo.absFilePath().latin1(),aTmpDir.c_str());
1162 if(system(aCommand) == -1){
1163 MESSAGE("Create - Can't execute the command :"<<aCommand);
1166 if(MYDEBUG) MESSAGE("Result_i::Create - aCommand = "<<aCommand);
1167 myFileInfo.setFile(QString(aTmpDir.c_str()) + myFileInfo.fileName());
1169 myInput = CreateConvertor(myFileInfo.absFilePath().latin1());
1171 if(myIsBuildImmediately)
1172 Build(SALOMEDS::SObject::_nil());
1175 }catch(std::exception& exc){
1176 INFOS("Follow exception was occured :\n"<<exc.what());
1178 INFOS("Unknown exception was occured!!!");
1184 //---------------------------------------------------------------
1187 Create(SALOMEDS::SObject_ptr theMedSObject)
1189 if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOMEDS::SObject_ptr");
1191 myInput = CreateMEDConvertor(theMedSObject);
1197 string aCompDataType = GetComponentDataType(theMedSObject);
1198 myFileInfo.setFile(aCompDataType.c_str());
1199 myInitFileName = aCompDataType;
1201 myName = ::GenerateName("aResult").latin1();
1203 return Build(theMedSObject);
1204 }catch(std::exception& exc){
1205 INFOS("Follow exception was occured :\n"<<exc.what());
1207 INFOS("Unknown exception was occured!!!");
1213 //---------------------------------------------------------------
1216 Create(SALOME_MED::FIELD_ptr theField)
1218 if(MYDEBUG) MESSAGE("Result_i::Create MedObject from SALOME_MED::FIELD_ptr");
1220 myInput = CreateMEDFieldConvertor(theField);
1226 string aCompDataType = "MED";
1227 myFileInfo.setFile(aCompDataType.c_str());
1228 myInitFileName = aCompDataType;
1230 myName = ::GenerateName("aResult").latin1();
1232 CORBA::String_var anIOR = myStudyDocument->ConvertObjectToIOR(theField);
1233 SALOMEDS::SObject_var aFieldSObject = myStudyDocument->FindObjectIOR(anIOR);
1235 return Build(aFieldSObject);
1236 }catch(std::exception& exc){
1237 INFOS("Follow exception was occured :\n"<<exc.what());
1239 INFOS("Unknown exception was occured!!!");
1245 //---------------------------------------------------------------
1248 Restore(SALOMEDS::SObject_ptr theSObject,
1249 const Storable::TRestoringMap& theMap,
1250 const string& thePrefix)
1252 if(MYDEBUG) MESSAGE("Result_i::Restore - " << thePrefix);
1254 mySObject = SALOMEDS::SObject::_duplicate(theSObject);
1255 myStudyDocument = mySObject->GetStudy();
1256 mySComponent = mySObject->GetFatherComponent();
1257 myName = VISU::Storable::FindValue(theMap, "myName").latin1();
1258 myInitFileName = VISU::Storable::FindValue(theMap, "myInitFileName").latin1();
1260 SALOMEDS::SObject_var aRefSObj, aTargetRefSObj;
1261 if (mySObject->FindSubObject(1, aRefSObj) &&
1262 aRefSObj->ReferencedObject(aTargetRefSObj))
1264 if(MYDEBUG) MESSAGE("Result_i::GetInput - There is some reference.");
1265 SALOMEDS::SComponent_var aCompRefSObj = aTargetRefSObj->GetFatherComponent();
1266 CORBA::String_var aDataType = aCompRefSObj->ComponentDataType();
1267 myFileInfo.setFile(aDataType.in());
1268 if(MYDEBUG) MESSAGE("Result_i::GetInput - aDataType = " << aDataType);
1269 Engines::Component_var aEngComp =
1270 Base_i::myEnginesLifeCycle->FindOrLoad_Component("FactoryServer", aDataType.in());
1271 if (CORBA::is_nil(aEngComp))
1272 throw std::runtime_error("Restore - There is no aEngComp for the aDataType !!!");
1273 SALOMEDS::StudyBuilder_var aStudyBuilder = myStudyDocument->NewBuilder();
1274 SALOMEDS::Driver_var aDriver = SALOMEDS::Driver::_narrow(aEngComp);
1275 aStudyBuilder->LoadWith(aCompRefSObj, aDriver);
1276 if (strcmp(aDataType, "MED") == 0){
1277 // create field or MED converter
1278 CORBA::Object_var aMedObject = VISU::SObjectToObject(aTargetRefSObj);
1279 SALOME_MED::FIELD_var aField = SALOME_MED::FIELD::_narrow(aMedObject);
1280 if(!CORBA::is_nil(aField))
1281 myInput = CreateMEDFieldConvertor(aField);
1283 myInput = CreateMEDConvertor(aTargetRefSObj);
1286 throw std::runtime_error("GetInput - There is no convertor for the aDataType !!!");
1288 myFileInfo.setFile(thePrefix.c_str());
1290 string aStudyPrefix ("");
1292 aStudyPrefix = SALOMEDS_Tool::GetNameFromPath(myStudyDocument->URL());
1293 if (!myFileInfo.isFile()) {
1294 string aFileName = thePrefix + aStudyPrefix + "_" + myName;
1295 myFileInfo.setFile(aFileName.c_str());
1298 MESSAGE("Result_i::Restore - aFileName = " << myFileInfo.filePath() << "; " << myFileInfo.isFile());
1300 const char* aPathLatin = myFileInfo.filePath().latin1();
1301 if (HDFascii::isASCII(aPathLatin)) {
1302 MESSAGE("ConvertFromASCIIToHDF(" << aPathLatin << ")");
1303 char* aResultPath = HDFascii::ConvertFromASCIIToHDF(aPathLatin);
1304 MESSAGE("ConvertFromASCIIToHDF() DONE : " << aResultPath);
1305 char* aHDFFileName = new char[strlen(aResultPath) + 19];
1306 sprintf(aHDFFileName, "%shdf_from_ascii.hdf", aResultPath);
1308 if (IsMultifile()) { // set this file as new - temporary
1309 static QString aCommand;
1310 aCommand.sprintf("mv %s %s%s",aHDFFileName, aResultPath, myFileInfo.baseName().latin1());
1311 if (system(aCommand) == -1) {
1312 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand);
1315 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand);
1317 myFileInfo.setFile(QString(aResultPath) + QString(myFileInfo.baseName().latin1()));
1318 } else { // change current temporary file to the new: with hdf-format
1319 static QString aCommand;
1320 aCommand.sprintf("mv %s %s\0",aHDFFileName, myFileInfo.filePath().latin1());
1321 if (system(aCommand.latin1()) == -1) {
1322 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - Can't execute the command :" << aCommand);
1325 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - " << aCommand);
1327 SALOMEDS::ListOfFileNames_var anEmptyList = new SALOMEDS::ListOfFileNames;
1328 SALOMEDS_Tool::RemoveTemporaryFiles(aResultPath, anEmptyList.in(), true);
1330 mySourceId = eRestoredFile;
1331 delete(aResultPath);
1332 delete(aHDFFileName);
1333 } else if (!IsMultifile()) {
1334 mySourceId = eRestoredFile;
1338 if(MYDEBUG) MESSAGE("VISU::Result_i::Restore - mySourceId = " << mySourceId);
1339 myInput = CreateConvertor(myFileInfo.filePath().latin1());
1341 myInput->BuildEntities();
1342 if(myIsBuildFields){
1343 myInput->BuildFields();
1344 myIsFieldsDone = true;
1345 if(myIsBuildMinMax){
1346 myInput->BuildMinMax();
1347 myIsMinMaxDone = true;
1350 if(myIsBuildGroups){
1351 myInput->BuildGroups();
1352 myIsGroupsDone = true;
1356 aComment.sprintf("myComment=%s;myType=%d;myFileName=%s;myInitFileName=%s",
1357 GetComment(), VISU::TRESULT, myFileInfo.filePath().latin1(),
1358 myInitFileName.c_str()); // Restoring of Python dump
1359 SALOMEDS::GenericAttribute_var anAttr;
1360 if (!theSObject->FindAttribute(anAttr, "AttributeComment"))
1361 throw std::runtime_error("Build - There is no AttributeComment for the SObject !!!");
1362 SALOMEDS::AttributeComment_var aCmnt = SALOMEDS::AttributeComment::_narrow(anAttr);
1363 aCmnt->SetValue(aComment.latin1());
1365 bool anIsBuildAll = VISU::GetResourceMgr()->booleanValue("VISU", "full_med_loading", false);
1369 } catch(std::exception& exc) {
1370 INFOS("Follow exception was occured :\n"<<exc.what());
1372 INFOS("Unknown exception was occured!!!");
1377 //---------------------------------------------------------------
1378 VISU::Result_i::TInput*
1385 //---------------------------------------------------------------
1392 (myIsBuildFields? myIsFieldsDone: true) &&
1393 (myIsBuildMinMax? myIsMinMaxDone: true) &&
1394 (myIsBuildGroups? myIsGroupsDone: true);
1401 return myIsEntitiesDone;
1406 ::SetBuildFields(CORBA::Boolean theIsBuildFields,
1407 CORBA::Boolean theIsCalculateMinMax)
1409 myIsBuildFields = theIsBuildFields;
1410 if(theIsBuildFields)
1411 myIsBuildMinMax = theIsCalculateMinMax;
1413 myIsBuildMinMax = false;
1418 ::SetBuildGroups(CORBA::Boolean theIsBuildGroups)
1420 myIsBuildGroups = theIsBuildGroups;
1427 return myIsFieldsDone;
1434 return myIsGroupsDone;
1441 return myIsMinMaxDone;
1444 //---------------------------------------------------------------
1447 ::ToStream(std::ostringstream& theStr)
1449 if(MYDEBUG) MESSAGE(GetComment());
1450 Storable::DataToStream(theStr,"myName",myName.c_str());
1451 Storable::DataToStream(theStr,"myInitFileName",myInitFileName.c_str());
1452 Storable::DataToStream(theStr,"myCreationId",myCreationId);
1453 Storable::DataToStream(theStr,"myIsBuildFields",myIsFieldsDone);
1454 Storable::DataToStream(theStr,"myIsBuildMinMax",myIsMinMaxDone);
1455 Storable::DataToStream(theStr,"myIsBuildGroups",myIsGroupsDone);
1459 //---------------------------------------------------------------
1462 ::Restore(SALOMEDS::SObject_ptr theSObject,
1463 const string& thePrefix,
1464 const Storable::TRestoringMap& theMap)
1466 SALOMEDS::Study_var aStudy = theSObject->GetStudy();
1468 ECreationId aCreationId = ECreationId(Storable::FindValue(theMap,"myCreationId").toInt());
1469 ESourceId aSourceId = eRestoredFile;
1470 if(aCreationId == eImportMed || aCreationId == eImportMedField)
1471 aSourceId = eRestoredComponent;
1473 CORBA::Boolean anIsBuildFields = Storable::FindValue(theMap,"myIsBuildFields","0").toInt();
1474 CORBA::Boolean anIsBuildMinMax = Storable::FindValue(theMap,"myIsBuildMinMax","0").toInt();
1475 CORBA::Boolean anIsBuildGroups = Storable::FindValue(theMap,"myIsBuildGroups","0").toInt();
1477 VISU::Result_i* aResult = new VISU::Result_i(aStudy,
1483 if (aResult == NULL)
1486 return aResult->Restore(theSObject,theMap,thePrefix);
1490 //---------------------------------------------------------------
1493 ::GetRefFatherEntry()
1502 CORBA::String_var anEntry = mySObject->GetID();
1503 return string(anEntry);
1506 const SALOMEDS::SObject_var&
1508 ::GetSObject() const
1513 const SALOMEDS::Study_var&
1515 ::GetStudyDocument() const
1517 return myStudyDocument;
1520 const SALOMEDS::SComponent_var&
1522 ::GetSComponent() const
1524 return mySComponent;
1529 ::GetEntry(const std::string& theComment)
1531 return FindEntryWithComment(myStudyDocument,GetEntry().c_str(),theComment.c_str());
1535 //---------------------------------------------------------------
1539 MESSAGE("Result_i::~Result_i() - this = "<<this);
1540 if (mySourceId == eRestoredFile) {
1541 static QString aCommand;
1542 aCommand.sprintf("rm %s",myFileInfo.filePath().latin1());
1543 MESSAGE("Result_i::~Result_i - system("<<aCommand<<") = "<<system(aCommand));
1544 aCommand.sprintf("rmdir --ignore-fail-on-non-empty %s",myFileInfo.dirPath().latin1());
1545 MESSAGE("Result_i::~Result_i - system("<<aCommand<<") = "<<system(aCommand));
1547 if(myInput) delete myInput;
1550 //=======================================================================
1551 //function : GetAxisInfo
1553 //=======================================================================
1554 const Result_i::TAxisInfo*
1556 ::GetAxisInfo(const string& theMeshName,
1558 gp_Dir& thePlaneNormal)
1560 const TAxisInfo* components = NULL;
1562 if ( theAxis < AXIS_X || theAxis > AXIS_Z ) {
1563 MESSAGE(" Bad axis index " << theAxis );
1567 map< string, TGridInfo >::iterator name_info;
1568 name_info = myMeshName2GridInfoMap.find( theMeshName );
1569 TGridInfo * gInfo = 0;
1571 if ( name_info != myMeshName2GridInfoMap.end() )
1573 gInfo = & name_info->second;
1575 else if ( myInput && IsPossible() && theAxis >= AXIS_X && theAxis <= AXIS_Z )
1577 // check presence of theMeshName
1578 const VISU::TMeshMap& meshMap = myInput->GetMeshMap();
1579 if ( meshMap.find( theMeshName ) == meshMap.end() ) {
1580 MESSAGE("No mesh named " << theMeshName );
1584 VISU::PIDMapper anIDMapper = myInput->GetMeshOnEntity(theMeshName,
1586 VISU::TVTKOutput* aMesh = anIDMapper->GetVTKOutput();
1588 if ( !aMesh || aMesh->GetNumberOfCells() == 0 ) {
1589 MESSAGE( "No cells in the mesh: " << theMeshName );
1593 // define axis directions and min cell size in each direction
1594 const int nbAxes = 3;
1596 gp_Vec axDirs[ nbAxes ];
1597 float minSize[3] = { FLT_MAX, FLT_MAX, FLT_MAX };
1598 bool axesComputed = false;
1599 for ( vtkIdType iCell = 0; iCell < aMesh->GetNumberOfCells(); ++iCell )
1601 vtkCell* cell = aMesh->GetCell( iCell );
1602 int nbPnt = cell->GetNumberOfPoints();
1605 vtkPoints * points = cell->GetPoints();
1606 vtkFloatingPointType* coords[ 4 ];
1607 coords[0] = points->GetPoint( 0 );
1608 coords[1] = points->GetPoint( 1 );
1609 coords[2] = points->GetPoint( 3 );
1610 coords[3] = points->GetPoint( 4 );
1611 gp_Pnt p0( coords[0][0], coords[0][1], coords[0][2] );
1612 for ( iAx = 0; iAx < nbAxes; ++iAx )
1614 vtkFloatingPointType* coo = coords[ iAx + 1 ];
1615 gp_Pnt p( coo[0], coo[1], coo[2] );
1617 vtkFloatingPointType size = p0.SquareDistance( p );
1618 if ( size > FLT_MIN && size < minSize[ iAx ] )
1619 minSize[ iAx ] = size;
1621 if ( !axesComputed ) {
1622 gp_Vec dir( p0, p );
1623 if ( dir.SquareMagnitude() <= DBL_MIN )
1625 axDirs[ iAx ] = dir;
1628 if ( iAx == nbAxes )
1629 axesComputed = true;
1631 if ( !axesComputed ) {
1632 MESSAGE("No good hexahedrons in the mesh: " << theMeshName );
1636 // compute axes dirs
1637 gInfo = & myMeshName2GridInfoMap[ theMeshName ];
1638 for ( iAx = 0; iAx < nbAxes; ++iAx )
1640 int iPrev = ( iAx == 0 ) ? 2 : iAx - 1;
1641 int iNext = ( iAx == 2 ) ? 0 : iAx + 1;
1642 gInfo->myAxis[ iAx ] = axDirs[ iPrev ] ^ axDirs[ iNext ];
1645 // get and sort intermediate component values - projections of nodes
1646 // on axis direction; define bnd box
1647 set< vtkFloatingPointType > comps[ 3 ];
1649 vtkPoints * points = aMesh->GetPoints();
1650 vtkIdType iP, nbP = aMesh->GetNumberOfPoints();
1651 for ( iP = 0; iP < nbP; ++iP )
1653 vtkFloatingPointType* coo = points->GetPoint( iP );
1654 gp_Pnt p( coo[0], coo[1], coo[2] );
1656 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1657 const gp_Dir& dir = gInfo->myAxis[ iAx ];
1658 vtkFloatingPointType dot = dir.XYZ() * p.XYZ();
1659 comps[ iAx ].insert( dot );
1663 // find a range of projections of bnd box corners on each axis
1664 vtkFloatingPointType range[3], firstValue[3];
1665 double x[2],y[2],z[2];
1666 box.Get(x[0],y[0],z[0],x[1],y[1],z[1]);
1667 for ( iAx = 0; iAx < nbAxes; ++iAx ) {
1668 set< vtkFloatingPointType > bndComps;
1669 const gp_Dir& dir = gInfo->myAxis[ iAx ];
1670 for ( int iX = 0; iX < 2; ++iX ) {
1671 for ( int iY = 0; iY < 2; ++iY ) {
1672 for ( int iZ = 0; iZ < 2; ++iZ ) {
1673 gp_Pnt p( x[ iX ], y[ iY ], z[ iZ ] );
1674 vtkFloatingPointType dot = dir.XYZ() * p.XYZ();
1675 bndComps.insert( dot );
1679 firstValue[ iAx ] = *bndComps.begin();
1680 range[ iAx ] = *bndComps.rbegin() - *bndComps.begin();
1683 // compute component values
1684 for ( iAx = 0; iAx < nbAxes; ++iAx )
1686 list< vtkFloatingPointType > values;
1688 set< vtkFloatingPointType >& comp = comps[ iAx ];
1689 set< vtkFloatingPointType >::iterator val = comp.begin();
1690 vtkFloatingPointType bnd = -1., rng = range[ iAx ], first = firstValue[ iAx ];
1691 vtkFloatingPointType tol = 0.1 * sqrt( minSize[ iAx ]) / rng;
1692 for ( ; val != comp.end(); ++val ) {
1693 vtkFloatingPointType value = ( *val - first ) / rng;
1694 if ( value > bnd ) {
1695 values.push_back( value );
1700 // store values in gInfo
1701 vector< vtkFloatingPointType >& myComp = gInfo->myComponets[ iAx ];
1702 myComp.resize( nbVals );
1703 list< vtkFloatingPointType >::iterator v = values.begin();
1704 for ( int i = 0; v != values.end(); ++v )
1709 // set return values
1712 thePlaneNormal = gInfo->myAxis[ theAxis ];
1713 components = & gInfo->myComponets[ theAxis ];