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_Convertor_impl.cxx
24 // Author : Alexey PETROV
27 #include "VISU_Convertor_impl.hxx"
28 #include "VISU_ConvertorUtils.hxx"
29 #include "VTKViewer_AppendFilter.h"
30 #include "VISU_MergeFilter.hxx"
31 #include "VTKViewer_CellLocationsArray.h"
33 #include <vtkPoints.h>
34 #include <vtkUnstructuredGrid.h>
36 #include <vtkIdList.h>
37 #include <vtkCellType.h>
38 #include <vtkCellArray.h>
39 #include <vtkFloatArray.h>
40 #include <vtkUnsignedCharArray.h>
41 #include <vtkPointData.h>
42 #include <vtkCellData.h>
43 #include <vtkCellLinks.h>
47 #include <qfileinfo.h>
55 static vtkFloatingPointType ERR_SIZE_CALC = 1.00;
57 static int MYVTKDEBUG = 0;
60 static int MYDEBUG = 0;
61 static int MYDEBUGWITHFILES = 0;
64 static int MYDEBUG = 0;
65 static int MYDEBUGWITHFILES = 0;
70 //---------------------------------------------------------------
71 TIsVTKDone::TIsVTKDone():
77 //---------------------------------------------------------------
78 TSizeCounter::TSizeCounter():
84 //---------------------------------------------------------------
92 if(!mySource.GetPointer()){
93 mySource = vtkUnstructuredGrid::New();
103 return GetSource().GetPointer();
107 //---------------------------------------------------------------
108 TAppendFilter::TAppendFilter()
111 const TVTKAppendFilter&
115 if(!myFilter.GetPointer()){
116 myFilter = VTKViewer_AppendFilter::New();
118 myFilter->SetDoMappingFlag(true);
127 GetFilter()->Update();
128 return GetFilter()->GetOutput();
132 //---------------------------------------------------------------
133 TMergeFilter::TMergeFilter()
136 const TVTKMergeFilter&
140 if(!myFilter.GetPointer()){
141 myFilter = VISU_MergeFilter::New();
151 GetFilter()->Update();
152 return GetFilter()->GetUnstructuredGridOutput();
156 //---------------------------------------------------------------
159 myPoints(vtkPoints::New())
166 ::Init(vtkIdType theNbPoints,
170 myNbPoints = theNbPoints;
171 myCoord.resize(theNbPoints*theDim);
172 myPoints->SetNumberOfPoints(theNbPoints);
177 ::GetCoordSlice(vtkIdType theNodeId) const
179 return TCCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1));
184 ::GetCoordSlice(vtkIdType theNodeId)
186 return TCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1));
190 //---------------------------------------------------------------
193 ::Init(vtkIdType theNbPoints,
195 const TVectorID& theVectorID)
197 TPointCoords::Init(theNbPoints,theDim);
198 myPointsDim.resize(theDim);
199 myVectorID = theVectorID;
201 for(vtkIdType anID = 0, anEnd = theVectorID.size(); anID < anEnd; anID++)
202 myObj2VTKID[theVectorID[anID]] = anID;
207 ::GetName(vtkIdType theDim)
209 return myPointsDim[theDim];
214 ::GetName(vtkIdType theDim) const
216 return myPointsDim[theDim];
221 ::GetObjID(vtkIdType theID) const
223 if(myVectorID.empty())
226 return myVectorID[theID];
232 ::GetVTKID(vtkIdType theID) const
234 if(myObj2VTKID.empty())
237 TObj2VTKID::const_iterator anIter = myObj2VTKID.find(theID);
238 if(anIter != myObj2VTKID.end())
239 return anIter->second;
246 ::GetNodeName(vtkIdType theObjID) const
251 //---------------------------------------------------------------
252 TMeshImpl::TMeshImpl():
253 myPoints(vtkPoints::New()),
260 //---------------------------------------------------------------
261 TSubProfileImpl::TSubProfileImpl():
269 ::GetElemObjID(vtkIdType theID) const
275 //---------------------------------------------------------------
277 operator<(const PSubProfile& theLeft, const PSubProfile& theRight)
279 PSubProfileImpl aLeft(theLeft), aRight(theRight);
281 if(aLeft->myGeom != aRight->myGeom)
282 return aLeft->myGeom < aRight->myGeom;
284 if(aLeft->myStatus != aRight->myStatus)
285 return aLeft->myStatus < aRight->myStatus;
287 return aLeft->myName < aRight->myName;
291 //---------------------------------------------------------------
292 TProfileImpl::TProfileImpl():
299 ::GetNodeObjID(vtkIdType theID) const
301 return myNamedPointCoords->GetObjID(theID);
306 ::GetNodeVTKID(vtkIdType theID) const
308 return myNamedPointCoords->GetVTKID(theID);
311 vtkFloatingPointType*
313 ::GetNodeCoord(vtkIdType theObjID)
316 return myMeshOnEntity->GetNodeCoord(theObjID);
318 vtkIdType aVtkID = GetNodeVTKID(theObjID);
319 return GetFilter()->GetOutput()->GetPoint(aVtkID);
324 ::GetElemObjID(vtkIdType theID) const
327 return myMeshOnEntity->GetElemObjID(theID);
329 vtkIdType anInputID, aStartID, anInputDataSetID;
330 const TVTKAppendFilter& anAppendFilter = GetFilter();
331 anAppendFilter->GetCellInputID(theID,anInputID,aStartID,anInputDataSetID);
332 PSubProfileImpl aSubProfileImpl = mySubProfileArr[anInputDataSetID];
333 return aSubProfileImpl->GetElemObjID(anInputID);
338 ::GetElemVTKID(vtkIdType theID) const
341 return myMeshOnEntity->GetElemVTKID(theID);
343 if(myElemObj2VTKID.empty())
346 TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
347 if(anIter != myElemObj2VTKID.end())
348 return anIter->second;
355 ::GetElemCell(vtkIdType theObjID)
358 return myMeshOnEntity->GetElemCell(theObjID);
360 vtkIdType aVtkID = GetElemVTKID(theObjID);
361 return GetFilter()->GetOutput()->GetCell(aVtkID);
368 const TVTKAppendFilter& anAppendFilter = GetFilter();
369 return anAppendFilter->GetOutput();
374 ::GetNodeName(vtkIdType theObjID) const
376 return myNamedPointCoords->GetNodeName(theObjID);
381 ::GetElemName(vtkIdType theObjID) const
384 return myMeshOnEntity->GetElemName(theObjID);
386 vtkIdType aVTKId = GetElemVTKID(theObjID);
387 vtkIdType anInputID, aStartID, anInputDataSetID;
388 const TVTKAppendFilter& anAppendFilter = GetFilter();
389 anAppendFilter->GetCellInputID(aVTKId,anInputID,aStartID,anInputDataSetID);
390 PSubProfileImpl aSubProfileImpl = mySubProfileArr[anInputDataSetID];
391 vtkIdType anEntityObjId = aSubProfileImpl->GetElemObjID(anInputID);
392 return myMeshOnEntity->GetElemName(anEntityObjId);
396 //---------------------------------------------------------------
401 if(!myFilter.GetPointer()){
402 const TVTKAppendFilter& anAppendFilter = myIDMapper.GetFilter();
403 TVTKOutput* aGeometry = anAppendFilter->GetOutput();
405 const TVTKSource& aSource = mySource.GetSource();
406 TDataSet* aDataSet = aSource.GetPointer();
407 aDataSet->ShallowCopy(aGeometry);
409 const TVTKMergeFilter& aFilter = GetFilter();
410 aFilter->SetGeometry(aGeometry);
411 aFilter->SetScalars(aDataSet);
412 aFilter->SetVectors(aDataSet);
413 aFilter->AddField("VISU_FIELD",aDataSet);
415 return myFilter->GetUnstructuredGridOutput();
420 ::GetNodeObjID(vtkIdType theID) const
422 return myIDMapper.GetNodeObjID(theID);
427 ::GetNodeVTKID(vtkIdType theID) const
429 return myIDMapper.GetNodeVTKID(theID);
432 vtkFloatingPointType*
434 ::GetNodeCoord(vtkIdType theObjID)
436 return myIDMapper.GetNodeCoord(theObjID);
441 ::GetElemObjID(vtkIdType theID) const
443 return myIDMapper.GetElemObjID(theID);
448 ::GetElemVTKID(vtkIdType theID) const
450 return myIDMapper.GetElemVTKID(theID);
455 ::GetElemCell(vtkIdType theObjID)
457 return myIDMapper.GetElemCell(theObjID);
461 //---------------------------------------------------------------
464 ::LessThan(const PGaussImpl& theGauss,
465 bool& theResult) const
471 //---------------------------------------------------------------
472 TGaussSubMeshImpl::TGaussSubMeshImpl():
478 ::GetObjID(vtkIdType theID,
479 vtkIdType theStartID) const
481 TCellID aCellID = theStartID + theID / myGauss->myNbPoints;
482 TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
484 return TGaussPointID(aCellID,aLocalPntID);
487 //---------------------------------------------------------------
489 operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight)
491 PGaussSubMeshImpl aLeft(theLeft), aRight(theRight);
492 const PGaussImpl& aGaussLeft = aLeft->myGauss;
493 const PGaussImpl& aGaussRight = aRight->myGauss;
495 if(aGaussLeft->myGeom != aGaussRight->myGeom)
496 return aGaussLeft->myGeom < aGaussRight->myGeom;
498 if(aLeft->mySubProfile != aRight->mySubProfile)
499 return aLeft->mySubProfile < aRight->mySubProfile;
502 aGaussLeft->LessThan(aGaussRight,aResult);
508 //---------------------------------------------------------------
516 ::GetObjID(vtkIdType theID) const
518 vtkIdType anInputID, aStartId, anInputDataSetID;
519 const TVTKAppendFilter& anAppendFilter = GetFilter();
520 anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID);
521 const TGaussSubMeshImpl& aSubMeshImpl = myGaussSubMeshArr[anInputDataSetID];
523 return aSubMeshImpl.GetObjID(anInputID,aStartId);
530 return mySource.GetVTKOutput();
541 //---------------------------------------------------------------
544 ::GetObjID(vtkIdType theID) const
546 return myGaussPtsIDMapper->GetObjID(theID);
553 return myGaussPtsIDMapper->GetParent();
557 //---------------------------------------------------------------
560 ::GetElemObjID(vtkIdType theID) const
562 return myStartID + theID;
567 ::GetElemName(vtkIdType theObjID) const
572 //---------------------------------------------------------------
575 ::GetNodeVTKID(vtkIdType theID) const
577 return myNamedPointCoords->GetVTKID(theID);
582 ::GetNodeObjID(vtkIdType theID) const
584 return myNamedPointCoords->GetObjID(theID);
589 ::GetElemVTKID(vtkIdType theID) const
591 if(myElemObj2VTKID.empty())
594 TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
595 if(anIter != myElemObj2VTKID.end())
596 return anIter->second;
603 ::GetElemObjID(vtkIdType theID) const
605 vtkIdType anInputID, aStartId, anInputDataSetID;
606 const TVTKAppendFilter& anAppendFilter = GetFilter();
607 anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID);
608 const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputDataSetID];
609 return aSubMesh->GetElemObjID(anInputID);
614 ::GetNodeName(vtkIdType theObjID) const
616 return myNamedPointCoords->GetNodeName(theObjID);
621 ::GetElemName(vtkIdType theObjID) const
623 vtkIdType aVTKId = GetElemVTKID(theObjID);
624 vtkIdType anInputID, aStartId, anInputDataSetID;
625 const TVTKAppendFilter& anAppendFilter = GetFilter();
626 anAppendFilter->GetCellInputID(aVTKId,anInputID,aStartId,anInputDataSetID);
627 const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputDataSetID];
628 return aSubMesh->GetElemName(anInputID);
631 //---------------------------------------------------------------
634 ::GetElemVTKID(vtkIdType theID) const
636 if(myElemObj2VTKID.empty())
639 TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
640 if(anIter != myElemObj2VTKID.end())
641 return anIter->second;
648 ::GetElemObjID(vtkIdType theID) const
650 return myMeshID[theID];
655 ::GetNodeObjID(vtkIdType theID) const
657 return myNamedPointCoords->GetObjID(theID);
662 ::GetNodeVTKID(vtkIdType theID) const
664 return myNamedPointCoords->GetVTKID(theID);
671 return TSource::GetVTKOutput();
675 //---------------------------------------------------------------
678 ::GetNbASizeCells() const
680 vtkIdType aNbCells = 0, aCellsSize = 0;
681 TFamilySet::const_iterator anIter = myFamilySet.begin();
682 for(; anIter != myFamilySet.end(); anIter++){
683 PFamilyImpl aFamily = *anIter;
684 aNbCells += aFamily->myNbCells;
685 aCellsSize += aFamily->myCellsSize;
687 return make_pair(aNbCells,aCellsSize);
692 ::GetElemVTKID(vtkIdType theID) const
694 if(myElemObj2VTKID.empty())
697 TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
698 if(anIter != myElemObj2VTKID.end())
699 return anIter->second;
706 ::GetElemObjID(vtkIdType theID) const
708 vtkIdType anInputID, aStartId, anInputDataSetID;
709 const TVTKAppendFilter& anAppendFilter = GetFilter();
710 anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID);
711 const PFamilyImpl& aFamily = myFamilyArr[anInputDataSetID];
712 return aFamily->GetElemObjID(anInputID);
717 ::GetNodeObjID(vtkIdType theID) const
719 return myNamedPointCoords->GetObjID(theID);
724 ::GetNodeVTKID(vtkIdType theID) const
726 return myNamedPointCoords->GetVTKID(theID);
730 //---------------------------------------------------------------
738 ::InitArrays(vtkIdType theNbComp)
740 myNbComp = theNbComp;
741 myCompNames.resize(theNbComp);
742 myUnitNames.resize(theNbComp);
743 myMinMaxArr.resize(theNbComp + 1);
744 for(vtkIdType iComp = 0; iComp <= theNbComp; iComp++){
745 TMinMax& aMinMax = myMinMaxArr[iComp];
746 aMinMax.first = VTK_LARGE_FLOAT;
747 aMinMax.second = -VTK_LARGE_FLOAT;
753 ::GetMinMax(vtkIdType theCompID)
755 return myMinMaxArr[theCompID];
759 //---------------------------------------------------------------
762 ::Init(vtkIdType theNbElem,
763 vtkIdType theNbGauss,
766 myNbElem = theNbElem;
767 myNbGauss = theNbGauss;
768 myNbComp = theNbComp;
770 myStep = theNbComp*theNbGauss;
772 myValue.resize(theNbElem*myStep);
777 ::GetGaussValueSliceArr(vtkIdType theElemId) const
779 TCValueSliceArr aValueSliceArr(myNbGauss);
780 vtkIdType anId = theElemId*myStep;
781 for(vtkIdType aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
782 aValueSliceArr[aGaussId] =
783 TCValueSlice(myValue,std::slice(anId,myNbComp,1));
786 return aValueSliceArr;
791 ::GetGaussValueSliceArr(vtkIdType theElemId)
793 TValueSliceArr aValueSliceArr(myNbGauss);
794 vtkIdType anId = theElemId*myStep;
795 for(vtkIdType aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
796 aValueSliceArr[aGaussId] =
797 TValueSlice(myValue,std::slice(anId,myNbComp,1));
800 return aValueSliceArr;
805 ::GetCompValueSliceArr(vtkIdType theElemId) const
807 TCValueSliceArr aValueSliceArr(myNbComp);
808 vtkIdType anId = theElemId*myStep;
809 for(vtkIdType aCompId = 0; aCompId < myNbComp; aCompId++){
810 aValueSliceArr[aCompId] =
811 TCValueSlice(myValue,std::slice(anId,myNbGauss,myNbComp));
814 return aValueSliceArr;
819 ::GetCompValueSliceArr(vtkIdType theElemId)
821 TValueSliceArr aValueSliceArr(myNbComp);
822 vtkIdType anId = theElemId*myStep;
823 for(vtkIdType aCompId = 0; aCompId < myNbComp; aCompId++){
824 aValueSliceArr[aCompId] =
825 TValueSlice(myValue,std::slice(anId,myNbGauss,myNbComp));
828 return aValueSliceArr;
832 //---------------------------------------------------------------
835 myGaussPtsIDFilter(new TGaussPtsIDFilter()),
836 myIDMapperFilter(new TIDMapperFilter())
841 ::GetMeshValue(EGeometry theGeom) const
843 TGeom2Value::const_iterator anIter = myGeom2Value.find(theGeom);
844 if(anIter == myGeom2Value.end())
845 EXCEPTION(runtime_error,"TValForTimeImpl::GetMeshValue - myGeom2Value.find(theGeom) fails");
846 return anIter->second;
851 ::GetMeshValue(EGeometry theGeom)
853 return myGeom2Value[theGeom];
858 ::GetNbGauss(EGeometry theGeom) const
860 TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom);
861 if(anIter == myGeom2NbGauss.end()){
862 //EXCEPTION(runtime_error,"TValForTimeImpl::GetNbGauss - myGeom2NbGauss.find(theGeom) fails");
865 return anIter->second;
869 //---------------------------------------------------------------
871 VISUGeom2NbNodes(EGeometry theGeom)
874 #ifndef VISU_ENABLE_QUADRATIC
890 case VISU::ePOLYGONE:
891 case VISU::ePOLYEDRE:
894 return theGeom % 100;
899 VISUGeom2VTK(EGeometry theGeom)
913 return VTK_HEXAHEDRON;
919 case VISU::ePOLYGONE:
921 case VISU::ePOLYEDRE:
922 return VTK_CONVEX_POINT_SET;
924 #ifndef VISU_ENABLE_QUADRATIC
934 return VTK_HEXAHEDRON;
943 #if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)
944 return VTK_QUADRATIC_EDGE;
946 return VTK_POLY_LINE;
950 #if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)
951 return VTK_QUADRATIC_TRIANGLE;
957 #if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)
958 return VTK_QUADRATIC_QUAD;
964 #if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)
965 return VTK_QUADRATIC_TETRA;
967 return VTK_CONVEX_POINT_SET;
971 #if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC)
972 return VTK_QUADRATIC_HEXAHEDRON;
974 return VTK_CONVEX_POINT_SET;
978 #if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC)
979 return VTK_QUADRATIC_WEDGE;
981 return VTK_CONVEX_POINT_SET;
985 #if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)
986 return VTK_QUADRATIC_PYRAMID;
988 return VTK_CONVEX_POINT_SET;
991 #endif //VISU_ENABLE_QUADRATIC
1002 //---------------------------------------------------------------
1005 dtos(const std::string& fmt, T val)
1007 static QString aString;
1008 aString.sprintf(fmt.c_str(),val);
1009 return aString.latin1();
1013 //---------------------------------------------------------------
1014 enum ECoordName{eX, eY, eZ, eNone};
1015 typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice);
1017 template<ECoordName TCoordId>
1019 GetCoord(const VISU::TCCoordSlice& theCoordSlice)
1021 return theCoordSlice[TCoordId];
1026 GetCoord<eNone>(const VISU::TCCoordSlice& theCoordSlice)
1032 TGetCoord aXYZGetCoord[3] = {
1039 TGetCoord aXYGetCoord[3] = {
1045 TGetCoord aYZGetCoord[3] = {
1051 TGetCoord aXZGetCoord[3] = {
1058 TGetCoord aXGetCoord[3] = {
1064 TGetCoord aYGetCoord[3] = {
1070 TGetCoord aZGetCoord[3] = {
1078 TGetCoord* myGetCoord;
1080 TCoordHelper(TGetCoord* theGetCoord):
1081 myGetCoord(theGetCoord)
1089 GetCoord(VISU::TCCoordSlice& theCoordSlice,
1092 return (*myGetCoord[theCoordId])(theCoordSlice);
1095 typedef std::auto_ptr<TCoordHelper> TCoordHelperPtr;
1098 //---------------------------------------------------------------
1100 GetPoints(const PMeshImpl& theMesh)
1102 TVTKPoints& aPoints = theMesh->myPoints;
1103 const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
1105 if(!theMesh->myIsVTKDone){
1106 TCoordHelperPtr aCoordHelperPtr;
1108 int aMeshDimension = theMesh->myDim;
1109 bool anIsDimPresent[3] = {false, false, false};
1110 for(int iDim = 0; iDim < aMeshDimension; iDim++){
1111 const std::string& aName = aCoords.GetName(iDim);
1112 if(aName == "x" || aName == "X")
1113 anIsDimPresent[eX] = true;
1114 else if(aName == "y" || aName == "Y")
1115 anIsDimPresent[eY] = true;
1116 else if(aName == "z" || aName == "Z")
1117 anIsDimPresent[eZ] = true;
1120 switch(aMeshDimension){
1122 aCoordHelperPtr.reset(new TCoordHelper(aXYZGetCoord));
1125 if(anIsDimPresent[eY] && anIsDimPresent[eZ])
1126 aCoordHelperPtr.reset(new TCoordHelper(aYZGetCoord));
1127 else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
1128 aCoordHelperPtr.reset(new TCoordHelper(aXZGetCoord));
1130 aCoordHelperPtr.reset(new TCoordHelper(aXYGetCoord));
1133 if(anIsDimPresent[eY])
1134 aCoordHelperPtr.reset(new TCoordHelper(aYGetCoord));
1135 else if(anIsDimPresent[eZ])
1136 aCoordHelperPtr.reset(new TCoordHelper(aZGetCoord));
1138 aCoordHelperPtr.reset(new TCoordHelper(aXGetCoord));
1143 vtkIdType aNbPoints = aCoords.GetNbPoints();
1144 aPoints->SetNumberOfPoints(aNbPoints);
1146 INITMSG(MYDEBUG,"GetPoints - aNbPoints = "<<aNbPoints<<
1147 "; aDim = "<<theMesh->myDim<<
1150 for(vtkIdType aNodeId = 0; aNodeId < aNbPoints; aNodeId++){
1151 TCCoordSlice aCoordSlice = aCoords.GetCoordSlice(aNodeId);
1152 aPoints->SetPoint(aNodeId,
1153 aCoordHelperPtr->GetCoord(aCoordSlice,eX),
1154 aCoordHelperPtr->GetCoord(aCoordSlice,eY),
1155 aCoordHelperPtr->GetCoord(aCoordSlice,eZ));
1158 theMesh->myIsVTKDone = true;
1160 if(MYVTKDEBUG) aPoints->DebugOn();
1163 return aPoints.GetPointer();
1167 //---------------------------------------------------------------
1169 PrintCells(int& theStartId,
1170 vtkCellArray* theConnectivity,
1171 const VISU::TConnect& theVector)
1173 vtkIdList *anIdList = vtkIdList::New();
1174 int kEnd = theVector.size();
1175 anIdList->SetNumberOfIds(kEnd);
1176 for(int k = 0; k < kEnd; k++)
1177 anIdList->SetId(k,theVector[k]);
1178 theConnectivity->InsertNextCell(anIdList);
1183 //---------------------------------------------------------------
1185 GetCellsOnSubMesh(const TVTKSource& theSource,
1186 const PMeshOnEntityImpl& theMeshOnEntity,
1187 const PSubMeshImpl& theSubMesh,
1188 const vtkIdType theGeom)
1190 const VISU::TCell2Connect& anArray = theSubMesh->myCell2Connect;
1191 vtkIdType aCellsSize = theSubMesh->myCellsSize;
1192 vtkIdType aNbCells = theSubMesh->myNbCells;
1193 INITMSG(MYDEBUG,"GetCellsOnSubMesh "<<
1194 "- theGeom = "<<theGeom<<
1195 "; aNbCells = "<<aNbCells<<
1199 vtkCellArray* aConnectivity = vtkCellArray::New();
1200 aConnectivity->Allocate(aCellsSize,0);
1201 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1202 aCellTypesArray->SetNumberOfComponents(1);
1203 aCellTypesArray->SetNumberOfTuples(aNbCells);
1205 for(vtkIdType anID = 0; anID < aNbCells; anID++){
1206 PrintCells(anID,aConnectivity,anArray[anID]);
1207 aCellTypesArray->SetValue(anID,(unsigned char)theGeom);
1210 vtkIdType *pts = 0, npts = 0;
1211 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
1212 aCellLocationsArray->SetNumberOfComponents(1);
1213 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1214 aConnectivity->InitTraversal();
1215 for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
1216 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
1217 theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
1219 if(MYVTKDEBUG) aConnectivity->DebugOn();
1221 aCellLocationsArray->Delete();
1222 aCellTypesArray->Delete();
1223 aConnectivity->Delete();
1227 //---------------------------------------------------------------
1229 GetCellsOnFamily(const TVTKSource& theSource,
1230 const PMeshOnEntityImpl& theMeshOnEntity,
1231 const PFamilyImpl& theFamily)
1233 INITMSG(MYDEBUG,"GetCellsOnFamily"<<endl);
1235 vtkIdType aNbCells = theFamily->myNbCells;
1236 vtkIdType aCellsSize = theFamily->myCellsSize;
1238 vtkCellArray* aConnectivity = vtkCellArray::New();
1239 aConnectivity->Allocate(aCellsSize,0);
1240 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1241 aCellTypesArray->SetNumberOfComponents(1);
1242 aCellTypesArray->SetNumberOfTuples(aNbCells);
1244 TSubMeshID& aMeshID = theFamily->myMeshID;
1245 aMeshID.resize(aNbCells);
1247 VISU::TID2ID& anElemObj2VTKID = theFamily->myElemObj2VTKID;
1249 const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
1250 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
1251 for(vtkIdType i = 0, j = 0; anIter != aGeom2SubMesh.end(); anIter++){
1252 VISU::EGeometry aEGeom = anIter->first;
1253 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
1255 const VISU::TSubMeshImpl& aSubMesh = anIter->second;
1256 const VISU::TCell2Connect& anArray = aSubMesh.myCell2Connect;
1258 const VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
1259 if(aGeom2SubMeshID.empty())
1260 EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!");
1262 VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aEGeom);
1263 if(aGeom2SubMeshIDIter == aGeom2SubMeshID.end())
1266 const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second;
1269 " - aEGeom = "<<aEGeom<<
1270 "; aVGeom = "<<aVGeom<<
1271 "; aSubMeshID.size() = "<<aSubMeshID.size()<<
1274 VISU::TSubMeshID::const_iterator aSubMeshIDIter = aSubMeshID.begin();
1275 for(; aSubMeshIDIter != aSubMeshID.end(); aSubMeshIDIter++, i++){
1276 vtkIdType anID = *aSubMeshIDIter;
1277 PrintCells(i,aConnectivity,anArray[anID]);
1278 aCellTypesArray->SetValue(j++,(unsigned char)aVGeom);
1280 anElemObj2VTKID[anID] = i;
1284 vtkIdType *pts = 0, npts = 0;
1285 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
1286 aCellLocationsArray->SetNumberOfComponents(1);
1287 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1288 aConnectivity->InitTraversal();
1289 for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
1290 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
1291 theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
1293 if(MYVTKDEBUG) aConnectivity->DebugOn();
1295 aCellLocationsArray->Delete();
1296 aCellTypesArray->Delete();
1297 aConnectivity->Delete();
1301 //---------------------------------------------------------------
1303 GenerateFieldName(const PFieldImpl& theField,
1304 const PValForTimeImpl& theValForTime)
1306 const VISU::TTime& aTime = theValForTime->myTime;
1307 string aFieldName = theField->myMeshName + ", " + theField->myName + ": " +
1308 VISU_Convertor::GenerateName(aTime);
1313 //---------------------------------------------------------------
1315 GetTimeStampOnProfile(const TVTKSource& theSource,
1316 const PFieldImpl& theField,
1317 const PValForTimeImpl& theValForTime,
1318 const VISU::TEntity& theEntity)
1320 int aNbTuples = theField->myDataSize/theField->myNbComp;
1321 std::string aFieldName = GenerateFieldName(theField,theValForTime);
1323 vtkDataSetAttributes* aDataSetAttributes;
1325 case VISU::NODE_ENTITY :
1326 aDataSetAttributes = theSource->GetPointData();
1329 aDataSetAttributes = theSource->GetCellData();
1332 int aNbComp = theField->myNbComp;
1333 vtkFloatArray *aFloatArray = vtkFloatArray::New();
1337 aFloatArray->SetNumberOfComponents(1);
1338 aDataSetAttributes->SetScalars(aFloatArray);
1341 aFloatArray->SetNumberOfComponents(3);
1342 aDataSetAttributes->SetVectors(aFloatArray);
1344 aFloatArray->SetNumberOfTuples(aNbTuples);
1345 aFloatArray->SetName(aFieldName.c_str());
1347 vtkFloatArray *aDataArray = vtkFloatArray::New();
1348 aDataArray->SetNumberOfComponents(aNbComp);
1349 aDataArray->SetNumberOfTuples(aNbTuples);
1350 aDataArray->SetName("VISU_FIELD");
1351 aDataSetAttributes->AddArray(aDataArray);
1353 INITMSG(MYDEBUG,"GetTimeStampOnProfile "<<
1354 "- theEntity = "<<theEntity<<
1355 "; aNbTuples = "<<aNbTuples<<
1356 "; aNbComp = "<<aNbComp<<
1359 int aSize = max(3,aNbComp);
1360 TVector<float> aDataValues(aSize,0.0);
1362 TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
1363 TGeom2Value::const_iterator anIter = aGeom2Value.begin();
1364 for(int aTupleId = 0; anIter != aGeom2Value.end(); anIter++){
1365 EGeometry aEGeom = anIter->first;
1366 const TMeshValue& aMeshValue = anIter->second;
1368 int aNbElem = aMeshValue.myNbElem;
1369 int aNbGauss = aMeshValue.myNbGauss;
1371 "- aEGeom = "<<aEGeom<<
1372 "; aNbElem = "<<aNbElem<<
1373 "; aNbGauss = "<<aNbGauss<<
1376 for(int iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
1377 TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iElem);
1378 for(int iComp = 0; iComp < aNbComp; iComp++){
1379 const TCValueSlice& aValueSlice = aValueSliceArr[iComp];
1380 aDataValues[iComp] = 0.0;
1381 for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
1382 aDataValues[iComp] += aValueSlice[iGauss];
1384 aDataValues[iComp] /= aNbGauss;
1386 aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
1387 aDataArray->SetTuple(aTupleId,&aDataValues[0]);
1390 aFloatArray->Delete();
1391 aDataArray->Delete();
1395 //---------------------------------------------------------------
1397 GetCells(const TVTKSource& theSource,
1398 const PSubProfileImpl& theSubProfile,
1399 const PProfileImpl& theProfile,
1400 const PMeshOnEntityImpl& theMeshOnEntity)
1402 vtkIdType aNbCells = theSubProfile->myNbCells;
1403 vtkIdType aCellsSize = theSubProfile->myCellsSize;
1404 VISU::EGeometry aEGeom = theSubProfile->myGeom;
1405 vtkIdType aNbNodes = VISUGeom2NbNodes(aEGeom);
1406 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
1408 INITMSG(MYDEBUG,"GetCells - aVGeom = "<<aVGeom<<endl);
1410 const TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID;
1412 const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
1413 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.find(aEGeom);
1414 if(anIter == aGeom2SubMesh.end())
1415 EXCEPTION(runtime_error,"GetCells >> There is no elements for the GEOM("<<aEGeom<<")");
1417 const VISU::TSubMeshImpl& aSubMesh = anIter->second;
1418 const TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect;
1420 vtkCellArray* aConnectivity = vtkCellArray::New();
1421 aConnectivity->Allocate(aCellsSize,0);
1422 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1423 aCellTypesArray->SetNumberOfComponents(1);
1424 aCellTypesArray->SetNumberOfTuples(aNbCells);
1426 if(theSubProfile->myStatus == eAddAll){
1427 VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin();
1428 for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){
1429 const TConnect& anArray = aCell2Connect[anId];
1430 PrintCells(aConnId,aConnectivity,anArray);
1431 aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
1432 aConnId += aNbNodes;
1436 VISU::TSubMeshID::const_iterator anIter = aSubMeshID.begin();
1437 for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){
1438 vtkIdType aSubId = *anIter;
1439 const TConnect& anArray = aCell2Connect[aSubId];
1440 PrintCells(aConnId,aConnectivity,anArray);
1441 aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
1442 aConnId += aNbNodes;
1447 vtkIdType *pts = 0, npts = 0;
1448 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
1450 aCellLocationsArray->SetNumberOfComponents(1);
1451 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1452 aConnectivity->InitTraversal();
1453 for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
1454 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
1455 theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
1457 aCellLocationsArray->Delete();
1458 aCellTypesArray->Delete();
1459 aConnectivity->Delete();
1463 //---------------------------------------------------------------
1465 GetMeshOnSubProfile(const PMeshImpl& theMesh,
1466 const PMeshOnEntityImpl& theMeshOnEntity,
1467 const PProfileImpl& theProfile,
1468 const PSubProfileImpl& theSubProfile)
1470 INITMSG(MYDEBUG,"GetMeshOnSubProfile - aEGeom = "<<theSubProfile->myGeom<<endl);
1472 const TVTKSource& aSource = theSubProfile->GetSource();
1473 if(theSubProfile->myIsVTKDone)
1476 aSource->SetPoints(GetPoints(theMesh));
1477 INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
1478 GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
1479 BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
1481 theSubProfile->myIsVTKDone = true;
1485 //---------------------------------------------------------------
1487 GetMeshOnProfile(const PMeshImpl& theMesh,
1488 const PMeshOnEntityImpl& theMeshOnEntity,
1489 const PProfileImpl& theProfile)
1491 INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<endl);
1493 if(theProfile->myIsVTKDone)
1496 theProfile->myMeshOnEntity = theMeshOnEntity.get();
1497 const TVTKAppendFilter& anAppendFilter = theProfile->GetFilter();
1498 anAppendFilter->SetPoints(GetPoints(theMesh));
1500 if(theProfile->myIsAll){
1501 TVTKOutput* aDataSet = theMeshOnEntity->GetVTKOutput();
1502 anAppendFilter->AddInput(aDataSet);
1504 const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
1506 TID2ID& anElemObj2VTKID = theProfile->myElemObj2VTKID;
1508 TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr;
1509 aSubProfileArr.resize(aGeom2SubProfile.size());
1511 TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
1512 for(vtkIdType anInputID = 0, aCellID = 0; anIter != aGeom2SubProfile.end(); anIter++){
1513 PSubProfileImpl aSubProfile = anIter->second;
1514 if(aSubProfile->myStatus == eRemoveAll)
1517 GetMeshOnSubProfile(theMesh,
1522 const TVTKSource& aSource = aSubProfile->GetSource();
1523 anAppendFilter->AddInput(aSource.GetPointer());
1525 vtkIdType aNbCells = aSource->GetNumberOfCells();
1526 for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
1527 anElemObj2VTKID[aSubProfile->GetElemObjID(aCell)] = aCellID;
1530 aSubProfileArr[anInputID++] = aSubProfile;
1533 anAppendFilter->Update(); // Fix on VTK
1534 theProfile->myNamedPointCoords = theMesh->myNamedPointCoords;
1536 theProfile->myIsVTKDone = true;
1540 //---------------------------------------------------------------
1542 GetTimeStampOnGaussMesh(const TVTKSource& theSource,
1543 const PFieldImpl& theField,
1544 const PValForTimeImpl& theValForTime)
1546 int aNbTuples = theSource->GetNumberOfPoints();
1547 std::string aFieldName = GenerateFieldName(theField,theValForTime);
1549 vtkDataSetAttributes* aDataSetAttributes;
1550 switch(theField->myEntity){
1551 case VISU::NODE_ENTITY :
1552 aDataSetAttributes = theSource->GetPointData();
1555 aDataSetAttributes = theSource->GetCellData();
1558 int aNbComp = theField->myNbComp;
1559 vtkFloatArray *aFloatArray = vtkFloatArray::New();
1562 aFloatArray->SetNumberOfComponents(1);
1563 aDataSetAttributes->SetScalars(aFloatArray);
1566 aFloatArray->SetNumberOfComponents(3);
1567 aDataSetAttributes->SetVectors(aFloatArray);
1569 aFloatArray->SetNumberOfTuples(aNbTuples);
1570 aFloatArray->SetName(aFieldName.c_str());
1572 vtkFloatArray *aDataArray = vtkFloatArray::New();
1573 aDataArray->SetNumberOfComponents(aNbComp);
1574 aDataArray->SetNumberOfTuples(aNbTuples);
1575 aDataArray->SetName("VISU_FIELD");
1576 aDataSetAttributes->AddArray(aDataArray);
1578 INITMSG(MYDEBUG,"GetTimeStampOnGaussMesh "<<
1579 "- aNbTuples = "<<aNbTuples<<
1580 "; aNbComp = "<<aNbComp<<
1583 int aSize = max(3,aNbComp);
1584 TVector<vtkFloatingPointType> aDataValues(aSize,0.0);
1586 const TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
1588 PGaussMeshImpl aGaussMesh = theValForTime->myGaussMesh;
1589 const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
1590 TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
1591 for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
1592 EGeometry aEGeom = anIter->first;
1594 PGaussSubMeshImpl aGaussSubMesh = anIter->second;
1595 if(!aGaussSubMesh->myIsDone)
1598 TGeom2Value::const_iterator anIter2 = aGeom2Value.find(aEGeom);
1599 if(anIter2 == aGeom2Value.end()){
1600 EXCEPTION(runtime_error,
1601 "GetTimeStampOnGaussMesh >> Can't find values for corresponding Gauss Points SubMesh");
1603 const TMeshValue& aMeshValue = anIter2->second;
1604 int aNbGauss = aMeshValue.myNbGauss;
1605 int aNbElem = aMeshValue.myNbElem;
1610 const TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
1613 "- aEGeom = "<<aEGeom<<
1614 "; aNbElem = "<<aNbElem<<
1615 "; aNbGauss = "<<aNbGauss<<
1616 "; aCoords.GetNbPoints() = "<<aCoords.GetNbPoints()<<
1619 if(aCoords.GetNbPoints() == aNbElem*aNbGauss){
1620 for(int iElem = 0; iElem < aNbElem; iElem++){
1621 TCValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);
1622 for(int iGauss = 0; iGauss < aNbGauss; iGauss++, aTupleId++){
1623 const TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
1624 for(int iComp = 0; iComp < aNbComp; iComp++){
1625 aDataValues[iComp] = aValueSlice[iComp];
1627 aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
1628 aDataArray->SetTuple(aTupleId,&aDataValues[0]);
1632 for(int iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
1633 TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iElem);
1634 for(int iComp = 0; iComp < aNbComp; iComp++){
1635 const TCValueSlice& aValueSlice = aValueSliceArr[iComp];
1636 aDataValues[iComp] = 0.0;
1637 for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
1638 aDataValues[iComp] += aValueSlice[iGauss];
1640 aDataValues[iComp] /= aNbGauss;
1642 aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
1643 aDataArray->SetTuple(aTupleId,&aDataValues[0]);
1647 aFloatArray->Delete();
1648 aDataArray->Delete();
1652 //---------------------------------------------------------------
1654 GetSource(const TVTKSource& theSource,
1655 const PGaussSubMeshImpl& theGaussSubMesh,
1656 const PMeshOnEntityImpl& theMeshOnEntity)
1658 const TPointCoords& aCoords = theGaussSubMesh->myPointCoords;
1659 vtkIdType aNbPoints = aCoords.GetNbPoints();
1660 vtkIdType aDim = aCoords.GetDim();
1662 vtkIdType aNbCells = theGaussSubMesh->myNbCells;
1663 vtkIdType aCellsSize = theGaussSubMesh->myCellsSize;
1665 vtkCellArray* aConnectivity = vtkCellArray::New();
1666 aConnectivity->Allocate(aCellsSize,0);
1667 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1668 aCellTypesArray->SetNumberOfComponents(1);
1669 aCellTypesArray->SetNumberOfTuples(aNbCells);
1671 const TVTKPoints& aPoints = aCoords.GetPoints();
1672 vtkIdList *anIdList = vtkIdList::New();
1673 anIdList->SetNumberOfIds(1);
1674 for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
1675 TCCoordSlice aSlice = aCoords.GetCoordSlice(aPointId);
1677 vtkFloatingPointType aCoords[3] = {0.0, 0.0, 0.0};
1678 for(vtkIdType aDimId = 0; aDimId < aDim; aDimId++)
1679 aCoords[aDimId] = aSlice[aDimId];
1681 aPoints->SetPoint(aPointId,aCoords);
1683 anIdList->SetId(0,aPointId);
1684 aConnectivity->InsertNextCell(anIdList);
1685 aCellTypesArray->SetValue(aPointId,(unsigned char)VTK_VERTEX);
1689 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
1690 aCellLocationsArray->SetNumberOfComponents(1);
1691 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1693 vtkIdType *pts = 0, npts = 0;
1694 aConnectivity->InitTraversal();
1695 for(int i = 0; aConnectivity->GetNextCell(npts,pts); i++)
1696 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
1698 const TVTKSource& aSource = theGaussSubMesh->GetSource();
1699 aSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
1700 aSource->SetPoints(aPoints.GetPointer());
1702 aCellLocationsArray->Delete();
1703 aCellTypesArray->Delete();
1704 aConnectivity->Delete();
1708 //---------------------------------------------------------------
1710 GetGaussSubMesh(const PMeshImpl& theMesh,
1711 const PMeshOnEntityImpl& theMeshOnEntity,
1712 const PGaussMeshImpl& theGaussMesh,
1713 const PGaussSubMeshImpl& theGaussSubMesh)
1715 PGaussImpl aGauss = theGaussSubMesh->myGauss;
1716 INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<<aGauss->myGeom<<endl);
1718 if(!theGaussSubMesh->myIsDone)
1721 if(theGaussSubMesh->myIsVTKDone)
1724 const TVTKSource& aSource = theGaussSubMesh->GetSource();
1725 GetSource(aSource,theGaussSubMesh,theMeshOnEntity);
1726 INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
1727 BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
1729 theGaussSubMesh->myIsVTKDone = true;
1733 //---------------------------------------------------------------
1735 BuildGaussMesh(const PMeshImpl& theMesh,
1736 const PMeshOnEntityImpl& theMeshOnEntity,
1737 const PGaussMeshImpl& theGaussMesh)
1739 if(theGaussMesh->myIsVTKDone)
1742 INITMSG(MYDEBUG,"BuildGaussMesh"<<endl);
1743 const TVTKAppendFilter& anAppendFilter = theGaussMesh->GetFilter();
1744 const TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
1745 TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
1746 for(; anIter != aGeom2GaussSubMesh.end(); anIter++){
1747 PGaussSubMeshImpl aGaussSubMesh = anIter->second;
1748 if(aGaussSubMesh->myStatus == eRemoveAll)
1751 GetGaussSubMesh(theMesh,
1756 const TVTKSource& aSource = aGaussSubMesh->GetSource();
1758 anAppendFilter->AddInput(aSource.GetPointer());
1760 anAppendFilter->Update(); // Fix on VTK
1762 theMeshOnEntity->GetVTKOutput()->Update();
1764 vtkDataSet* aSource = anAppendFilter->GetOutput();
1765 INITMSGA(MYDEBUG,0,"aNbPoints - "<<aSource->GetNumberOfPoints()<<endl);
1766 BEGMSG(MYDEBUG,"aNbCells - "<<aSource->GetNumberOfCells()<<endl);
1768 theGaussMesh->myIsVTKDone = true;
1772 //---------------------------------------------------------------
1774 PrintMemorySize(vtkUnstructuredGrid* theDataSet)
1776 theDataSet->Update();
1777 BEGMSG(1,"GetPoints() = "<<vtkFloatingPointType(theDataSet->GetPoints()->GetActualMemorySize()*1000)<<endl);
1778 BEGMSG(1,"GetCells() = "<<vtkFloatingPointType(theDataSet->GetCells()->GetActualMemorySize()*1000)<<endl);
1779 BEGMSG(1,"GetCellTypesArray() = "<<vtkFloatingPointType(theDataSet->GetCellTypesArray()->GetActualMemorySize()*1000)<<endl);
1780 BEGMSG(1,"GetCellLocationsArray() = "<<vtkFloatingPointType(theDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000)<<endl);
1781 theDataSet->BuildLinks();
1782 BEGMSG(1,"GetCellLinks() = "<<vtkFloatingPointType(theDataSet->GetCellLinks()->GetActualMemorySize()*1000)<<endl);
1783 BEGMSG(1,"GetPointData() = "<<vtkFloatingPointType(theDataSet->GetPointData()->GetActualMemorySize()*1000)<<endl);
1784 BEGMSG(1,"GetCellData() = "<<vtkFloatingPointType(theDataSet->GetCellData()->GetActualMemorySize()*1000)<<endl);
1785 BEGMSG(1,"GetActualMemorySize() = "<<vtkFloatingPointType(theDataSet->GetActualMemorySize()*1000)<<endl);
1790 //---------------------------------------------------------------
1792 ::VISU_Convertor_impl()
1798 //---------------------------------------------------------------
1800 ::~VISU_Convertor_impl()
1804 //---------------------------------------------------------------
1848 //---------------------------------------------------------------
1849 VISU::PNamedIDMapper
1851 ::GetMeshOnEntity(const string& theMeshName,
1852 const VISU::TEntity& theEntity)
1854 INITMSG(MYDEBUG,"GetMeshOnEntity"<<
1855 "; theMeshName = '"<<theMeshName<<"'"<<
1856 "; theEntity = "<<theEntity<<
1859 //Cheching possibility do the query
1860 TFindMeshOnEntity aFindMeshOnEntity =
1861 FindMeshOnEntity(theMeshName,theEntity);
1863 PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
1864 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1870 if(!aMeshOnEntity->myIsVTKDone){
1871 const TVTKAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter();
1872 if(MYVTKDEBUG) anAppendFilter->DebugOn();
1874 LoadMeshOnEntity(aMesh,aMeshOnEntity);
1875 anAppendFilter->SetPoints(GetPoints(aMesh));
1877 const TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
1878 TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
1880 TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID;
1881 TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr;
1882 aSubMeshArr.resize(aGeom2SubMesh.size());
1884 for(vtkIdType anID = 0, aCellID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){
1885 EGeometry aEGeom = anIter->first;
1886 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
1887 PSubMeshImpl aSubMesh = anIter->second;
1888 const TVTKSource& aSource = aSubMesh->GetSource();
1889 aSource->SetPoints(GetPoints(aMesh));
1890 GetCellsOnSubMesh(aSource,aMeshOnEntity,aSubMesh,aVGeom);
1891 anAppendFilter->AddInput(aSource.GetPointer());
1893 aSubMesh->myStartID = aCellID;
1894 vtkIdType aNbCells = aSource->GetNumberOfCells();
1895 for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
1896 vtkIdType anObjID = aSubMesh->GetElemObjID(aCell);
1897 anElemObj2VTKID[anObjID] = aCellID;
1899 aSubMeshArr[anID] = aSubMesh;
1901 aMeshOnEntity->myNamedPointCoords = aMesh->myNamedPointCoords;
1903 aMeshOnEntity->myIsVTKDone = true;
1905 if(MYDEBUGWITHFILES){
1906 std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
1907 std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
1908 aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-Conv.vtk";
1909 VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
1913 GetMeshOnEntitySize(theMeshName,theEntity);
1914 PrintMemorySize(anAppendFilter->GetOutput());
1924 return aMeshOnEntity;
1928 //---------------------------------------------------------------
1931 ::GetFamilyOnEntity(const std::string& theMeshName,
1932 const VISU::TEntity& theEntity,
1933 const std::string& theFamilyName)
1935 INITMSG(MYDEBUG,"GetFamilyOnEntity"<<
1936 "; theMeshName = '"<<theMeshName<<"'"<<
1937 "; theEntity = "<<theEntity<<
1938 "; theFamilyName = '"<<theFamilyName<<"'"<<
1941 //Cheching possibility do the query
1942 TFindFamilyOnEntity aFindFamilyOnEntity =
1943 FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
1945 PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);;
1946 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
1947 PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
1953 if(!aFamily->myIsVTKDone){
1954 const TVTKSource& aSource = aFamily->GetSource();
1955 if(MYVTKDEBUG) aSource->DebugOn();
1957 GetMeshOnEntity(theMeshName,theEntity);
1959 LoadFamilyOnEntity(aMesh,aMeshOnEntity,aFamily);
1960 aSource->SetPoints(GetPoints(aMesh));
1961 GetCellsOnFamily(aSource,aMeshOnEntity,aFamily);
1963 aFamily->myNamedPointCoords = aMesh->myNamedPointCoords;
1965 aFamily->myIsVTKDone = true;
1967 if(MYDEBUGWITHFILES){
1968 std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
1969 std::string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1();
1970 std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
1971 aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-Conv.vtk";
1972 VISU::WriteToFile(aSource.GetPointer(),aFileName);
1976 GetFamilyOnEntitySize(theMeshName,theEntity,theFamilyName);
1977 PrintMemorySize(aSource.GetPointer());
1991 //---------------------------------------------------------------
1994 ::GetMeshOnGroup(const string& theMeshName,
1995 const string& theGroupName)
1997 INITMSG(MYDEBUG,"GetMeshOnGroup\n");
1999 "- theMeshName = '"<<theMeshName<<
2000 "'; theGroupName = '"<<theGroupName<<"'"<<
2003 //Cheching possibility do the query
2004 TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
2005 PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
2006 PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
2012 if(!aGroup->myIsVTKDone){
2013 const TVTKAppendFilter& anAppendFilter = aGroup->GetFilter();
2014 const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
2016 LoadMeshOnGroup(aMesh,aFamilySet);
2017 anAppendFilter->SetPoints(GetPoints(aMesh));
2019 TFamilySet::const_iterator anIter = aFamilySet.begin();
2021 TID2ID& anElemObj2VTKID = aGroup->myElemObj2VTKID;
2022 TFamilyArr& aFamilyArr = aGroup->myFamilyArr;
2023 aFamilyArr.resize(aFamilySet.size());
2025 for(vtkIdType anID = 0; anIter != aFamilySet.end(); anIter++){
2026 PFamilyImpl aFamily = *anIter;
2027 const std::string& aFamilyName = aFamily->myName;
2028 const VISU::TEntity& anEntity = aFamily->myEntity;
2030 VISU::PIDMapper anIDMapper = GetFamilyOnEntity(theMeshName,anEntity,aFamilyName);
2031 VISU::TVTKOutput* anOutput = anIDMapper->GetVTKOutput();
2032 anAppendFilter->AddInput(anOutput);
2034 vtkIdType aNbCells = anOutput->GetNumberOfCells();
2035 for(vtkIdType aCellID = 0; aCellID < aNbCells; aCellID++){
2036 anElemObj2VTKID[aFamily->GetElemObjID(aCellID)] = aCellID;
2038 aFamilyArr[anID] = aFamily;
2040 aGroup->myNamedPointCoords = aMesh->myNamedPointCoords;
2042 aGroup->myIsVTKDone = true;
2044 if(MYDEBUGWITHFILES){
2045 std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
2046 std::string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1();
2047 std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
2048 aFileName += aMeshName + "-" + aGroupName + "-Conv.vtk";
2049 VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
2062 //---------------------------------------------------------------
2065 ::GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh,
2066 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
2067 const VISU::PFieldImpl& theField,
2068 const VISU::PValForTimeImpl& theValForTime,
2069 const VISU::PIDMapperFilter& theIDMapperFilter,
2070 const VISU::PProfileImpl& theProfile,
2071 const VISU::TEntity& theEntity)
2073 LoadMeshOnEntity(theMesh,theMeshOnEntity);
2074 GetMeshOnEntity(theMeshOnEntity->myMeshName,theMeshOnEntity->myEntity);
2075 GetMeshOnProfile(theMesh,theMeshOnEntity,theProfile);
2077 theIDMapperFilter->myIDMapper = theProfile;
2078 TVTKOutput* anOutput = theIDMapperFilter->GetVTKOutput();
2079 const TVTKSource& aSource = theIDMapperFilter->mySource.GetSource();
2080 ::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity);
2086 //---------------------------------------------------------------
2089 ::GetTimeStampOnMesh(const string& theMeshName,
2090 const VISU::TEntity& theEntity,
2091 const string& theFieldName,
2094 INITMSG(MYDEBUG,"GetTimeStampOnMesh"<<
2095 "; theMeshName = '"<<theMeshName<<"'"<<
2096 "; theEntity = "<<theEntity<<
2097 "; theFieldName = '"<<theFieldName<<"'"<<
2098 "; theStampsNum = "<<theStampsNum<<
2101 //Cheching possibility do the query
2102 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
2107 PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
2108 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
2109 PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
2110 PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
2111 PFieldImpl aField = boost::get<3>(aFindTimeStamp);
2114 PIDMapperFilter anIDMapperFilter = aValForTime->myIDMapperFilter;
2118 if(!anIDMapperFilter->myIsVTKDone){
2119 LoadValForTimeOnMesh(aMesh,aMeshOnEntity,aField,aValForTime);
2121 TVTKOutput* anOutput;
2123 anOutput = GetTimeStampOnProfile(aMesh,
2128 aValForTime->myProfile,
2129 aMeshOnEntity->myEntity);
2130 }catch(std::exception& exc){
2131 MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
2132 anOutput = GetTimeStampOnProfile(aMesh,
2137 aValForTime->myProfile,
2138 aVTKMeshOnEntity->myEntity);
2141 anIDMapperFilter->myIsVTKDone = true;
2143 if(MYDEBUGWITHFILES){
2144 string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
2145 string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
2146 string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-";
2147 string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
2148 aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk";
2149 VISU::WriteToFile(anOutput,aFileName);
2152 GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum);
2154 if(theEntity == VISU::NODE_ENTITY)
2155 BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
2157 BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
2158 BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
2162 }catch(std::exception& exc){
2169 return anIDMapperFilter;
2173 //---------------------------------------------------------------
2174 VISU::PGaussPtsIDMapper
2176 ::GetTimeStampOnGaussPts(const string& theMeshName,
2177 const VISU::TEntity& theEntity,
2178 const string& theFieldName,
2181 INITMSG(MYDEBUG,"GetTimeStampOnGaussPts"<<
2182 "; theMeshName = '"<<theMeshName<<"'"<<
2183 "; theEntity = "<<theEntity<<
2184 "; theFieldName = '"<<theFieldName<<"'"<<
2185 "; theStampsNum = "<<theStampsNum<<
2188 //Cheching possibility do the query
2189 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
2194 PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
2195 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
2196 PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
2197 PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
2198 PFieldImpl aField = boost::get<3>(aFindTimeStamp);
2201 PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
2205 if(!aGaussPtsIDFilter->myIsVTKDone){
2206 LoadValForTimeOnGaussPts(aMesh,aMeshOnEntity,aField,aValForTime);
2208 GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity);
2210 PProfileImpl aProfile = aValForTime->myProfile;
2211 GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile);
2213 PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh;
2214 TSource& aGaussPtsSource = aGaussMesh->mySource;
2215 if(!aGaussPtsSource.myIsVTKDone){
2216 BuildGaussMesh(aMesh,aVTKMeshOnEntity,aGaussMesh);
2217 aGaussMesh->myParent = aProfile.get();
2218 aGaussPtsSource.myIsVTKDone = true;
2221 aGaussPtsIDFilter->myIDMapper = aGaussMesh;
2222 aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh;
2223 TVTKOutput* anOutput = aGaussPtsIDFilter->GetVTKOutput();
2224 const TVTKSource& aSource = aGaussPtsIDFilter->mySource.GetSource();
2225 GetTimeStampOnGaussMesh(aSource,aField,aValForTime);
2227 aGaussPtsIDFilter->myIsVTKDone = true;
2229 if(MYDEBUGWITHFILES){
2230 string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
2231 string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
2232 string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-";
2233 string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
2234 aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk";
2235 VISU::WriteToFile(anOutput,aFileName);
2238 GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum);
2240 if(theEntity == VISU::NODE_ENTITY)
2241 BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
2243 BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
2244 BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
2248 }catch(std::exception& exc){
2255 return aGaussPtsIDFilter;
2258 //---------------------------------------------------------------
2261 ::FindMesh(const string& theMeshName)
2264 TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName);
2265 if(aMeshMapIter == myMeshMap.end())
2266 EXCEPTION(runtime_error,"FindMesh >> There is no mesh with the name - '"<<theMeshName<<"'!!!");
2268 PMeshImpl aMesh = aMeshMapIter->second;
2273 //---------------------------------------------------------------
2274 VISU_Convertor_impl::TFindMeshOnEntity
2276 ::FindMeshOnEntity(const string& theMeshName,
2277 const VISU::TEntity& theEntity)
2279 PMeshImpl aMesh = FindMesh(theMeshName);
2280 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
2281 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
2282 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
2283 EXCEPTION(runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
2285 PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
2287 return TFindMeshOnEntity(aMesh,
2292 //---------------------------------------------------------------
2293 VISU_Convertor_impl::TFindFamilyOnEntity
2295 ::FindFamilyOnEntity(const string& theMeshName,
2296 const VISU::TEntity& theEntity,
2297 const string& theFamilyName)
2299 if(theFamilyName != ""){
2300 PMeshImpl aMesh = FindMesh(theMeshName);
2301 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
2302 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
2303 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
2304 EXCEPTION(runtime_error,"FindFamilyOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
2306 PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
2308 TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
2309 TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName);
2310 if(aFamilyMapIter != aFamilyMap.end()){
2311 const PFamily& aFamily = aFamilyMapIter->second;
2312 return TFindFamilyOnEntity(aMesh,
2317 return TFindFamilyOnEntity();
2321 //---------------------------------------------------------------
2322 vtkFloatingPointType
2326 vtkFloatingPointType aResult = 0.0;
2327 const VISU::TMeshMap& aMeshMap = GetMeshMap();
2328 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
2329 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
2330 const string& aMeshName = aMeshMapIter->first;
2331 const VISU::PMesh aMesh = aMeshMapIter->second;
2332 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
2333 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
2335 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
2336 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
2337 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
2338 const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
2339 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
2340 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
2341 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
2342 const string& aFieldName = aFieldMapIter->first;
2343 const VISU::PField aField = aFieldMapIter->second;
2344 const VISU::TValField& aValField = aField->myValField;
2345 VISU::TValField::const_iterator aValFieldIter = aValField.begin();
2346 for(; aValFieldIter != aValField.end(); aValFieldIter++){
2347 int aTimeStamp = aValFieldIter->first;
2348 aResult += GetTimeStampSize(aMeshName,anEntity,aFieldName,aTimeStamp);
2352 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
2353 VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
2354 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
2355 const string& aGroupName = aGroupMapIter->first;
2356 aResult += GetMeshOnGroupSize(aMeshName,aGroupName);
2359 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
2360 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
2361 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
2362 const string& aFamilyName = aFamilyMapIter->first;
2363 aResult += GetFamilyOnEntitySize(aMeshName,anEntity,aFamilyName);
2365 //Import mesh on entity
2366 aResult += GetMeshOnEntitySize(aMeshName,anEntity);
2369 MSG(MYDEBUG,"GetSize - aResult = "<<vtkFloatingPointType(aResult));
2374 //---------------------------------------------------------------
2375 vtkFloatingPointType
2377 ::GetMeshOnEntitySize(const std::string& theMeshName,
2378 const VISU::TEntity& theEntity)
2380 TFindMeshOnEntity aFindMeshOnEntity =
2381 FindMeshOnEntity(theMeshName,theEntity);
2383 PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
2384 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
2386 vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
2387 vtkIdType aNbCells = aMeshOnEntity->myNbCells;
2388 vtkIdType aCellsSize = aMeshOnEntity->myCellsSize;
2390 vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
2391 vtkIdType aTypesSize = aNbCells*sizeof(char);
2392 vtkIdType aLocationsSize = aNbCells*sizeof(int);
2393 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
2394 vtkIdType aLinksSize = aMesh->myNbPoints *
2395 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
2397 vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
2399 MSG(MYDEBUG,"GetMeshOnEntitySize "<<
2400 "- aResult = "<<vtkFloatingPointType(aResult)<<
2401 "; theMeshName = '"<<theMeshName<<"'"<<
2402 "; theEntity = "<<theEntity);
2404 INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
2405 BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
2406 BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
2407 BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
2408 BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
2411 aResult = vtkIdType(aResult*ERR_SIZE_CALC);
2416 //---------------------------------------------------------------
2417 vtkFloatingPointType
2419 ::GetFamilyOnEntitySize(const std::string& theMeshName,
2420 const VISU::TEntity& theEntity,
2421 const std::string& theFamilyName)
2423 TFindFamilyOnEntity aFindFamilyOnEntity =
2424 FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
2425 PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);
2426 PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
2427 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
2429 vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
2430 vtkIdType aNbCells = aFamily->myNbCells;
2431 vtkIdType aCellsSize = aFamily->myCellsSize;
2433 vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
2434 vtkIdType aTypesSize = aNbCells*sizeof(char);
2435 vtkIdType aLocationsSize = aNbCells*sizeof(int);
2436 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
2437 vtkIdType aLinksSize = aMesh->myNbPoints *
2438 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
2440 vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
2442 MSG(MYDEBUG,"GetFamilyOnEntitySize "<<
2443 "- aResult = "<<vtkFloatingPointType(aResult)<<
2444 "; theMeshName = '"<<theMeshName<<"'"<<
2445 "; theEntity = "<<theEntity<<
2446 "; theFamilyName = '"<<theFamilyName<<"'");
2448 INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
2449 BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
2450 BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
2451 BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
2452 BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
2455 aResult = vtkIdType(aResult*ERR_SIZE_CALC);
2460 //---------------------------------------------------------------
2461 VISU_Convertor_impl::TFindMeshOnGroup
2463 ::FindMeshOnGroup(const std::string& theMeshName,
2464 const std::string& theGroupName)
2466 PMeshImpl aMesh = FindMesh(theMeshName);
2467 VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
2468 VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName);
2469 if(aGroupMapIter == aGroupMap.end())
2470 EXCEPTION(runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<<theGroupName<<"'");
2472 VISU::PGroupImpl aGroup = aGroupMapIter->second;
2473 return TFindMeshOnGroup(aMesh,aGroup);
2477 vtkFloatingPointType
2479 ::GetMeshOnGroupSize(const std::string& theMeshName,
2480 const std::string& theGroupName)
2482 TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
2483 PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
2484 PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
2486 vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
2487 TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells();
2488 vtkIdType aNbCells = aNbASizeCells.first;
2489 vtkIdType aCellsSize = aNbASizeCells.second;
2490 vtkIdType aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
2491 vtkIdType aLocationsSize = aNbCells*sizeof(int);
2492 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
2493 vtkIdType aLinksSize = aMesh->myNbPoints *
2494 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
2496 vtkIdType aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
2498 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aPointsSize = "<<vtkFloatingPointType(aPointsSize));
2499 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<vtkFloatingPointType(aConnectivityAndTypesSize));
2500 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLocationsSize = "<<vtkFloatingPointType(aLocationsSize));
2501 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLinksSize = "<<vtkFloatingPointType(aLinksSize));
2503 MSG(MYDEBUG,"GetMeshOnGroupSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"
2504 <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
2506 aResult = vtkIdType(aResult*ERR_SIZE_CALC);
2511 VISU_Convertor_impl::TFindField
2513 ::FindField(const string& theMeshName,
2514 const VISU::TEntity& theEntity,
2515 const string& theFieldName)
2517 TFindMeshOnEntity aFindMeshOnEntity =
2518 FindMeshOnEntity(theMeshName,theEntity);
2520 PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
2521 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
2523 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
2524 PMeshOnEntityImpl aVTKMeshOnEntity;
2525 if(theEntity == VISU::NODE_ENTITY){
2526 if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) != aMeshOnEntityMap.end())
2527 aVTKMeshOnEntity = aMeshOnEntityMap[VISU::CELL_ENTITY];
2528 else if(aMeshOnEntityMap.find(VISU::FACE_ENTITY) != aMeshOnEntityMap.end())
2529 aVTKMeshOnEntity = aMeshOnEntityMap[VISU::FACE_ENTITY];
2530 else if(aMeshOnEntityMap.find(VISU::NODE_ENTITY) != aMeshOnEntityMap.end())
2531 aVTKMeshOnEntity = aMeshOnEntityMap[VISU::EDGE_ENTITY];
2533 aVTKMeshOnEntity = aMeshOnEntity;
2535 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
2536 VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find(theFieldName);
2537 if(aFieldIter == aFieldMap.end())
2538 EXCEPTION(runtime_error,"FindField >> There is no field on the mesh!!!");
2540 PFieldImpl aField = aFieldIter->second;
2542 return TFindField(aMesh,
2549 vtkFloatingPointType
2551 ::GetFieldOnMeshSize(const std::string& theMeshName,
2552 const VISU::TEntity& theEntity,
2553 const std::string& theFieldName)
2555 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
2556 PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
2557 PFieldImpl aField = boost::get<3>(aFindField);
2559 vtkFloatingPointType aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
2560 vtkFloatingPointType aFieldOnMeshSize = vtkFloatingPointType(aField->myDataSize*sizeof(vtkFloatingPointType)*aField->myValField.size()*ERR_SIZE_CALC);
2561 vtkFloatingPointType aResult = aMeshSize + aFieldOnMeshSize;
2563 MSG(MYVTKDEBUG,"GetFieldOnMeshSize - aFieldOnMeshSize = "<<vtkFloatingPointType(aFieldOnMeshSize));
2564 MSG(MYDEBUG,"GetFieldOnMeshSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"<<theMeshName<<
2565 "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
2571 VISU_Convertor_impl::TFindTimeStamp
2573 ::FindTimeStamp(const std::string& theMeshName,
2574 const VISU::TEntity& theEntity,
2575 const std::string& theFieldName,
2578 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
2579 PField aField = boost::get<3>(aFindField);
2581 VISU::TValField& aValField = aField->myValField;
2582 VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum);
2583 if(aValFieldIter == aValField.end())
2584 EXCEPTION(runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!");
2586 PMeshImpl aMesh = boost::get<0>(aFindField);
2587 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField);
2588 PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
2589 PValForTimeImpl aValForTime = aValFieldIter->second;
2591 return TFindTimeStamp(aMesh,
2599 vtkFloatingPointType
2601 ::GetTimeStampSize(const std::string& theMeshName,
2602 const VISU::TEntity& theEntity,
2603 const std::string& theFieldName,
2606 TFindTimeStamp aFindTimeStamp =
2607 FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
2608 PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
2609 PFieldImpl aField = boost::get<3>(aFindTimeStamp);
2611 vtkFloatingPointType aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
2612 vtkFloatingPointType aTimeStampSize = vtkFloatingPointType(aField->myDataSize*sizeof(vtkFloatingPointType) * ERR_SIZE_CALC);
2613 vtkFloatingPointType aResult = aMeshSize + aTimeStampSize;
2615 MSG(MYDEBUG && MYVTKDEBUG,"GetTimeStampSize - aTimeStampSize = "<<vtkFloatingPointType(aTimeStampSize));
2616 MSG(MYDEBUG,"GetTimeStampSize - aResult = "<<vtkFloatingPointType(aResult)<<
2617 "; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
2618 "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
2626 ::GetField(const string& theMeshName,
2627 VISU::TEntity theEntity,
2628 const string& theFieldName)
2630 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
2631 PField aField = boost::get<3>(aFindField);
2636 const VISU::PValForTime
2638 ::GetTimeStamp(const std::string& theMeshName,
2639 const VISU::TEntity& theEntity,
2640 const std::string& theFieldName,
2643 TFindTimeStamp aFindTimeStamp =
2644 FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
2645 PValForTime aValForTime = boost::get<4>(aFindTimeStamp);