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.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org
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"
32 #include <vtkPoints.h>
33 #include <vtkUnstructuredGrid.h>
35 #include <vtkIdList.h>
36 #include <vtkCellType.h>
37 #include <vtkIntArray.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 float 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);
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);
330 const TVTKAppendFilter& anAppendFilter = GetFilter();
331 vtkIdType aID = anAppendFilter->GetCellInputID(theID,anInputID);
332 PSubProfileImpl aSubProfileImpl = mySubProfileArr[anInputID];
333 return aSubProfileImpl->GetElemObjID(aID);
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);
387 vtkIdType aVTKId = GetElemVTKID(theObjID);
388 const TVTKAppendFilter& anAppendFilter = GetFilter();
389 vtkIdType aSubID = anAppendFilter->GetCellInputID(aVTKId,anInputID);
390 PSubProfileImpl aSubProfileImpl = mySubProfileArr[anInputID];
391 vtkIdType anEntityObjId = aSubProfileImpl->GetElemObjID(aSubID);
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);
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) const
480 TCellID aCellID = theID / myGauss->myNbPoints;
481 TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
483 return TGaussPointID(aCellID,aLocalPntID);
486 //---------------------------------------------------------------
488 operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight)
490 PGaussSubMeshImpl aLeft(theLeft), aRight(theRight);
491 const PGaussImpl& aGaussLeft = aLeft->myGauss;
492 const PGaussImpl& aGaussRight = aRight->myGauss;
494 if(aGaussLeft->myGeom != aGaussRight->myGeom)
495 return aGaussLeft->myGeom < aGaussRight->myGeom;
497 if(aLeft->mySubProfile != aRight->mySubProfile)
498 return aLeft->mySubProfile < aRight->mySubProfile;
501 aGaussLeft->LessThan(aGaussRight,aResult);
507 //---------------------------------------------------------------
515 ::GetObjID(vtkIdType theID) const
517 const TVTKAppendFilter& anAppendFilter = GetFilter();
518 vtkIdType anInputDataSetID;
519 vtkIdType anInputID = anAppendFilter->GetCellInputID(theID,anInputDataSetID);
520 const TGaussSubMeshImpl& aSubMeshImpl = myGaussSubMeshArr[anInputDataSetID];
522 return aSubMeshImpl.GetObjID(anInputID);
529 return mySource.GetVTKOutput();
540 //---------------------------------------------------------------
543 ::GetObjID(vtkIdType theID) const
545 return myGaussPtsIDMapper->GetObjID(theID);
552 return myGaussPtsIDMapper->GetParent();
556 //---------------------------------------------------------------
559 ::GetElemObjID(vtkIdType theID) const
561 return myStartID + theID;
566 ::GetElemName(vtkIdType theObjID) const
571 //---------------------------------------------------------------
574 ::GetNodeVTKID(vtkIdType theID) const
576 return myNamedPointCoords->GetVTKID(theID);
581 ::GetNodeObjID(vtkIdType theID) const
583 return myNamedPointCoords->GetObjID(theID);
588 ::GetElemVTKID(vtkIdType theID) const
590 if(myElemObj2VTKID.empty())
593 TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
594 if(anIter != myElemObj2VTKID.end())
595 return anIter->second;
602 ::GetElemObjID(vtkIdType theID) const
605 const TVTKAppendFilter& anAppendFilter = GetFilter();
606 vtkIdType aID = anAppendFilter->GetCellInputID(theID,anInputID);
607 const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputID];
608 return aSubMesh->GetElemObjID(aID);
613 ::GetNodeName(vtkIdType theObjID) const
615 return myNamedPointCoords->GetNodeName(theObjID);
620 ::GetElemName(vtkIdType theObjID) const
622 vtkIdType aVTKId = GetElemVTKID(theObjID);
624 const TVTKAppendFilter& anAppendFilter = GetFilter();
625 vtkIdType aSubID = anAppendFilter->GetCellInputID(aVTKId,anInputID);
626 const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputID];
627 return aSubMesh->GetElemName(aSubID);
630 //---------------------------------------------------------------
633 ::GetElemVTKID(vtkIdType theID) const
635 if(myElemObj2VTKID.empty())
638 TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
639 if(anIter != myElemObj2VTKID.end())
640 return anIter->second;
647 ::GetElemObjID(vtkIdType theID) const
649 return myMeshID[theID];
654 ::GetNodeObjID(vtkIdType theID) const
656 return myNamedPointCoords->GetObjID(theID);
661 ::GetNodeVTKID(vtkIdType theID) const
663 return myNamedPointCoords->GetVTKID(theID);
670 return TSource::GetVTKOutput();
674 //---------------------------------------------------------------
677 ::GetNbASizeCells() const
679 vtkIdType aNbCells = 0, aCellsSize = 0;
680 TFamilySet::const_iterator anIter = myFamilySet.begin();
681 for(; anIter != myFamilySet.end(); anIter++){
682 PFamilyImpl aFamily = *anIter;
683 aNbCells += aFamily->myNbCells;
684 aCellsSize += aFamily->myCellsSize;
686 return make_pair(aNbCells,aCellsSize);
691 ::GetElemVTKID(vtkIdType theID) const
693 if(myElemObj2VTKID.empty())
696 TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
697 if(anIter != myElemObj2VTKID.end())
698 return anIter->second;
705 ::GetElemObjID(vtkIdType theID) const
708 const TVTKAppendFilter& anAppendFilter = GetFilter();
709 vtkIdType anID = anAppendFilter->GetCellInputID(theID,anInputID);
710 const PFamilyImpl& aFamily = myFamilyArr[anInputID];
711 return aFamily->GetElemObjID(anID);
716 ::GetNodeObjID(vtkIdType theID) const
718 return myNamedPointCoords->GetObjID(theID);
723 ::GetNodeVTKID(vtkIdType theID) const
725 return myNamedPointCoords->GetVTKID(theID);
729 //---------------------------------------------------------------
737 ::InitArrays(vtkIdType theNbComp)
739 myNbComp = theNbComp;
740 myCompNames.resize(theNbComp);
741 myUnitNames.resize(theNbComp);
742 myMinMaxArr.resize(theNbComp + 1);
743 for(vtkIdType iComp = 0; iComp <= theNbComp; iComp++){
744 TMinMax& aMinMax = myMinMaxArr[iComp];
745 aMinMax.first = VTK_LARGE_FLOAT;
746 aMinMax.second = -VTK_LARGE_FLOAT;
752 ::GetMinMax(vtkIdType theCompID)
754 return myMinMaxArr[theCompID];
758 //---------------------------------------------------------------
761 ::Init(vtkIdType theNbElem,
762 vtkIdType theNbGauss,
765 myNbElem = theNbElem;
766 myNbGauss = theNbGauss;
767 myNbComp = theNbComp;
769 myStep = theNbComp*theNbGauss;
771 myValue.resize(theNbElem*myStep);
776 ::GetGaussValueSliceArr(vtkIdType theElemId) const
778 TCValueSliceArr aValueSliceArr(myNbGauss);
779 vtkIdType anId = theElemId*myStep;
780 for(vtkIdType aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
781 aValueSliceArr[aGaussId] =
782 TCValueSlice(myValue,std::slice(anId,myNbComp,1));
785 return aValueSliceArr;
790 ::GetGaussValueSliceArr(vtkIdType theElemId)
792 TValueSliceArr aValueSliceArr(myNbGauss);
793 vtkIdType anId = theElemId*myStep;
794 for(vtkIdType aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
795 aValueSliceArr[aGaussId] =
796 TValueSlice(myValue,std::slice(anId,myNbComp,1));
799 return aValueSliceArr;
804 ::GetCompValueSliceArr(vtkIdType theElemId) const
806 TCValueSliceArr aValueSliceArr(myNbComp);
807 vtkIdType anId = theElemId*myStep;
808 for(vtkIdType aCompId = 0; aCompId < myNbComp; aCompId++){
809 aValueSliceArr[aCompId] =
810 TCValueSlice(myValue,std::slice(anId,myNbGauss,myNbComp));
813 return aValueSliceArr;
818 ::GetCompValueSliceArr(vtkIdType theElemId)
820 TValueSliceArr aValueSliceArr(myNbComp);
821 vtkIdType anId = theElemId*myStep;
822 for(vtkIdType aCompId = 0; aCompId < myNbComp; aCompId++){
823 aValueSliceArr[aCompId] =
824 TValueSlice(myValue,std::slice(anId,myNbGauss,myNbComp));
827 return aValueSliceArr;
831 //---------------------------------------------------------------
834 myGaussPtsIDFilter(new TGaussPtsIDFilter()),
835 myIDMapperFilter(new TIDMapperFilter())
840 ::GetMeshValue(EGeometry theGeom) const
842 TGeom2Value::const_iterator anIter = myGeom2Value.find(theGeom);
843 if(anIter == myGeom2Value.end())
844 EXCEPTION(runtime_error,"TValForTimeImpl::GetMeshValue - myGeom2Value.find(theGeom) fails");
845 return anIter->second;
850 ::GetMeshValue(EGeometry theGeom)
852 return myGeom2Value[theGeom];
857 ::GetNbGauss(EGeometry theGeom) const
859 TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom);
860 if(anIter == myGeom2NbGauss.end()){
861 //EXCEPTION(runtime_error,"TValForTimeImpl::GetNbGauss - myGeom2NbGauss.find(theGeom) fails");
864 return anIter->second;
868 //---------------------------------------------------------------
870 VISUGeom2NbNodes(EGeometry theGeom)
873 #ifndef VISU_ENABLE_QUADRATIC
889 case VISU::ePOLYGONE:
890 case VISU::ePOLYEDRE:
893 return theGeom % 100;
898 VISUGeom2VTK(EGeometry theGeom)
912 return VTK_HEXAHEDRON;
918 case VISU::ePOLYGONE:
920 case VISU::ePOLYEDRE:
921 return VTK_CONVEX_POINT_SET;
923 #ifndef VISU_ENABLE_QUADRATIC
933 return VTK_HEXAHEDRON;
942 #if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)
943 return VTK_QUADRATIC_EDGE;
945 return VTK_POLY_LINE;
949 #if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)
950 return VTK_QUADRATIC_TRIANGLE;
956 #if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)
957 return VTK_QUADRATIC_QUAD;
963 #if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)
964 return VTK_QUADRATIC_TETRA;
966 return VTK_CONVEX_POINT_SET;
970 #if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC)
971 return VTK_QUADRATIC_HEXAHEDRON;
973 return VTK_CONVEX_POINT_SET;
977 #if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC)
978 return VTK_QUADRATIC_WEDGE;
980 return VTK_CONVEX_POINT_SET;
984 #if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)
985 return VTK_QUADRATIC_PYRAMID;
987 return VTK_CONVEX_POINT_SET;
990 #endif //VISU_ENABLE_QUADRATIC
1001 //---------------------------------------------------------------
1004 dtos(const std::string& fmt, T val)
1006 static QString aString;
1007 aString.sprintf(fmt.c_str(),val);
1008 return aString.latin1();
1012 //---------------------------------------------------------------
1013 enum ECoordName{eX, eY, eZ, eNone};
1014 typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice);
1016 template<ECoordName TCoordId>
1018 GetCoord(const VISU::TCCoordSlice& theCoordSlice)
1020 return theCoordSlice[TCoordId];
1025 GetCoord<eNone>(const VISU::TCCoordSlice& theCoordSlice)
1031 TGetCoord aXYZGetCoord[3] = {
1038 TGetCoord aXYGetCoord[3] = {
1044 TGetCoord aYZGetCoord[3] = {
1050 TGetCoord aXZGetCoord[3] = {
1057 TGetCoord aXGetCoord[3] = {
1063 TGetCoord aYGetCoord[3] = {
1069 TGetCoord aZGetCoord[3] = {
1077 TGetCoord* myGetCoord;
1079 TCoordHelper(TGetCoord* theGetCoord):
1080 myGetCoord(theGetCoord)
1088 GetCoord(VISU::TCCoordSlice& theCoordSlice,
1091 return (*myGetCoord[theCoordId])(theCoordSlice);
1094 typedef std::auto_ptr<TCoordHelper> TCoordHelperPtr;
1097 //---------------------------------------------------------------
1099 GetPoints(const PMeshImpl& theMesh)
1101 TVTKPoints& aPoints = theMesh->myPoints;
1102 const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
1104 if(!theMesh->myIsVTKDone){
1105 TCoordHelperPtr aCoordHelperPtr;
1107 int aMeshDimension = theMesh->myDim;
1108 bool anIsDimPresent[3] = {false, false, false};
1109 for(int iDim = 0; iDim < aMeshDimension; iDim++){
1110 const std::string& aName = aCoords.GetName(iDim);
1111 if(aName == "x" || aName == "X")
1112 anIsDimPresent[eX] = true;
1113 else if(aName == "y" || aName == "Y")
1114 anIsDimPresent[eY] = true;
1115 else if(aName == "z" || aName == "Z")
1116 anIsDimPresent[eZ] = true;
1119 switch(aMeshDimension){
1121 aCoordHelperPtr.reset(new TCoordHelper(aXYZGetCoord));
1124 if(anIsDimPresent[eY] && anIsDimPresent[eZ])
1125 aCoordHelperPtr.reset(new TCoordHelper(aYZGetCoord));
1126 else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
1127 aCoordHelperPtr.reset(new TCoordHelper(aXZGetCoord));
1129 aCoordHelperPtr.reset(new TCoordHelper(aXYGetCoord));
1132 if(anIsDimPresent[eY])
1133 aCoordHelperPtr.reset(new TCoordHelper(aYGetCoord));
1134 else if(anIsDimPresent[eZ])
1135 aCoordHelperPtr.reset(new TCoordHelper(aZGetCoord));
1137 aCoordHelperPtr.reset(new TCoordHelper(aXGetCoord));
1142 vtkIdType aNbPoints = aCoords.GetNbPoints();
1143 aPoints->SetNumberOfPoints(aNbPoints);
1145 INITMSG(MYDEBUG,"GetPoints - aNbPoints = "<<aNbPoints<<
1146 "; aDim = "<<theMesh->myDim<<
1149 for(vtkIdType aNodeId = 0; aNodeId < aNbPoints; aNodeId++){
1150 TCCoordSlice aCoordSlice = aCoords.GetCoordSlice(aNodeId);
1151 aPoints->SetPoint(aNodeId,
1152 aCoordHelperPtr->GetCoord(aCoordSlice,eX),
1153 aCoordHelperPtr->GetCoord(aCoordSlice,eY),
1154 aCoordHelperPtr->GetCoord(aCoordSlice,eZ));
1157 theMesh->myIsVTKDone = true;
1159 if(MYVTKDEBUG) aPoints->DebugOn();
1162 return aPoints.GetPointer();
1166 //---------------------------------------------------------------
1168 PrintCells(int& theStartId,
1169 vtkCellArray* theConnectivity,
1170 const VISU::TConnect& theVector)
1172 vtkIdList *anIdList = vtkIdList::New();
1173 int kEnd = theVector.size();
1174 anIdList->SetNumberOfIds(kEnd);
1175 for(int k = 0; k < kEnd; k++)
1176 anIdList->SetId(k,theVector[k]);
1177 theConnectivity->InsertNextCell(anIdList);
1182 //---------------------------------------------------------------
1184 GetCellsOnSubMesh(const TVTKSource& theSource,
1185 const PMeshOnEntityImpl& theMeshOnEntity,
1186 const PSubMeshImpl& theSubMesh,
1187 const vtkIdType theGeom)
1189 const VISU::TCell2Connect& anArray = theSubMesh->myCell2Connect;
1190 vtkIdType aCellsSize = theSubMesh->myCellsSize;
1191 vtkIdType aNbCells = theSubMesh->myNbCells;
1192 INITMSG(MYDEBUG,"GetCellsOnSubMesh "<<
1193 "- theGeom = "<<theGeom<<
1194 "; aNbCells = "<<aNbCells<<
1198 vtkCellArray* aConnectivity = vtkCellArray::New();
1199 aConnectivity->Allocate(aCellsSize,0);
1200 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1201 aCellTypesArray->SetNumberOfComponents(1);
1202 aCellTypesArray->SetNumberOfTuples(aNbCells);
1204 for(vtkIdType anID = 0; anID < aNbCells; anID++){
1205 PrintCells(anID,aConnectivity,anArray[anID]);
1206 aCellTypesArray->SetValue(anID,(unsigned char)theGeom);
1209 vtkIdType *pts = 0, npts = 0;
1210 vtkIntArray* aCellLocationsArray = vtkIntArray::New();
1211 aCellLocationsArray->SetNumberOfComponents(1);
1212 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1213 aConnectivity->InitTraversal();
1214 for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
1215 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
1216 theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
1218 if(MYVTKDEBUG) aConnectivity->DebugOn();
1220 aCellLocationsArray->Delete();
1221 aCellTypesArray->Delete();
1222 aConnectivity->Delete();
1226 //---------------------------------------------------------------
1228 GetCellsOnFamily(const TVTKSource& theSource,
1229 const PMeshOnEntityImpl& theMeshOnEntity,
1230 const PFamilyImpl& theFamily)
1232 INITMSG(MYDEBUG,"GetCellsOnFamily"<<endl);
1234 vtkIdType aNbCells = theFamily->myNbCells;
1235 vtkIdType aCellsSize = theFamily->myCellsSize;
1237 vtkCellArray* aConnectivity = vtkCellArray::New();
1238 aConnectivity->Allocate(aCellsSize,0);
1239 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1240 aCellTypesArray->SetNumberOfComponents(1);
1241 aCellTypesArray->SetNumberOfTuples(aNbCells);
1243 TSubMeshID& aMeshID = theFamily->myMeshID;
1244 aMeshID.resize(aNbCells);
1246 VISU::TID2ID& anElemObj2VTKID = theFamily->myElemObj2VTKID;
1248 const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
1249 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
1250 for(vtkIdType i = 0, j = 0; anIter != aGeom2SubMesh.end(); anIter++){
1251 VISU::EGeometry aEGeom = anIter->first;
1252 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
1254 const VISU::TSubMeshImpl& aSubMesh = anIter->second;
1255 const VISU::TCell2Connect& anArray = aSubMesh.myCell2Connect;
1257 const VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
1258 if(aGeom2SubMeshID.empty())
1259 EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!");
1261 VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aEGeom);
1262 if(aGeom2SubMeshIDIter == aGeom2SubMeshID.end())
1265 const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second;
1268 " - aEGeom = "<<aEGeom<<
1269 "; aVGeom = "<<aVGeom<<
1270 "; aSubMeshID.size() = "<<aSubMeshID.size()<<
1273 VISU::TSubMeshID::const_iterator aSubMeshIDIter = aSubMeshID.begin();
1274 for(; aSubMeshIDIter != aSubMeshID.end(); aSubMeshIDIter++, i++){
1275 vtkIdType anID = *aSubMeshIDIter;
1276 PrintCells(i,aConnectivity,anArray[anID]);
1277 aCellTypesArray->SetValue(j++,(unsigned char)aVGeom);
1279 anElemObj2VTKID[anID] = i;
1283 vtkIdType *pts = 0, npts = 0;
1284 vtkIntArray* aCellLocationsArray = vtkIntArray::New();
1285 aCellLocationsArray->SetNumberOfComponents(1);
1286 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1287 aConnectivity->InitTraversal();
1288 for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
1289 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
1290 theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
1292 if(MYVTKDEBUG) aConnectivity->DebugOn();
1294 aCellLocationsArray->Delete();
1295 aCellTypesArray->Delete();
1296 aConnectivity->Delete();
1300 //---------------------------------------------------------------
1302 GenerateFieldName(const PFieldImpl& theField,
1303 const PValForTimeImpl& theValForTime)
1305 const VISU::TTime& aTime = theValForTime->myTime;
1306 string aFieldName = theField->myMeshName + ", " + theField->myName + ": " +
1307 VISU_Convertor::GenerateName(aTime);
1312 //---------------------------------------------------------------
1314 GetTimeStampOnProfile(const TVTKSource& theSource,
1315 const PFieldImpl& theField,
1316 const PValForTimeImpl& theValForTime,
1317 const VISU::TEntity& theEntity)
1319 int aNbTuples = theField->myDataSize/theField->myNbComp;
1320 std::string aFieldName = GenerateFieldName(theField,theValForTime);
1322 vtkDataSetAttributes* aDataSetAttributes;
1324 case VISU::NODE_ENTITY :
1325 aDataSetAttributes = theSource->GetPointData();
1328 aDataSetAttributes = theSource->GetCellData();
1331 int aNbComp = theField->myNbComp;
1332 vtkFloatArray *aFloatArray = vtkFloatArray::New();
1336 aFloatArray->SetNumberOfComponents(1);
1337 aDataSetAttributes->SetScalars(aFloatArray);
1340 aFloatArray->SetNumberOfComponents(3);
1341 aDataSetAttributes->SetVectors(aFloatArray);
1343 aFloatArray->SetNumberOfTuples(aNbTuples);
1344 aFloatArray->SetName(aFieldName.c_str());
1346 vtkFloatArray *aDataArray = vtkFloatArray::New();
1347 aDataArray->SetNumberOfComponents(aNbComp);
1348 aDataArray->SetNumberOfTuples(aNbTuples);
1349 aDataArray->SetName("VISU_FIELD");
1350 aDataSetAttributes->AddArray(aDataArray);
1352 INITMSG(MYDEBUG,"GetTimeStampOnProfile "<<
1353 "- theEntity = "<<theEntity<<
1354 "; aNbTuples = "<<aNbTuples<<
1355 "; aNbComp = "<<aNbComp<<
1358 int aSize = max(3,aNbComp);
1359 TVector<float> aDataValues(aSize,0.0);
1361 TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
1362 TGeom2Value::const_iterator anIter = aGeom2Value.begin();
1363 for(int aTupleId = 0; anIter != aGeom2Value.end(); anIter++){
1364 EGeometry aEGeom = anIter->first;
1365 const TMeshValue& aMeshValue = anIter->second;
1367 int aNbElem = aMeshValue.myNbElem;
1368 int aNbGauss = aMeshValue.myNbGauss;
1370 "- aEGeom = "<<aEGeom<<
1371 "; aNbElem = "<<aNbElem<<
1372 "; aNbGauss = "<<aNbGauss<<
1375 for(int iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
1376 TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iElem);
1377 for(int iComp = 0; iComp < aNbComp; iComp++){
1378 const TCValueSlice& aValueSlice = aValueSliceArr[iComp];
1379 aDataValues[iComp] = 0.0;
1380 for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
1381 aDataValues[iComp] += aValueSlice[iGauss];
1383 aDataValues[iComp] /= aNbGauss;
1385 aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
1386 aDataArray->SetTuple(aTupleId,&aDataValues[0]);
1389 aFloatArray->Delete();
1390 aDataArray->Delete();
1394 //---------------------------------------------------------------
1396 GetCells(const TVTKSource& theSource,
1397 const PSubProfileImpl& theSubProfile,
1398 const PProfileImpl& theProfile,
1399 const PMeshOnEntityImpl& theMeshOnEntity)
1401 vtkIdType aNbCells = theSubProfile->myNbCells;
1402 vtkIdType aCellsSize = theSubProfile->myCellsSize;
1403 VISU::EGeometry aEGeom = theSubProfile->myGeom;
1404 vtkIdType aNbNodes = VISUGeom2NbNodes(aEGeom);
1405 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
1407 INITMSG(MYDEBUG,"GetCells - aVGeom = "<<aVGeom<<endl);
1409 const TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID;
1411 const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
1412 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.find(aEGeom);
1413 if(anIter == aGeom2SubMesh.end())
1414 EXCEPTION(runtime_error,"GetCells >> There is no elements for the GEOM("<<aEGeom<<")");
1416 const VISU::TSubMeshImpl& aSubMesh = anIter->second;
1417 const TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect;
1419 vtkCellArray* aConnectivity = vtkCellArray::New();
1420 aConnectivity->Allocate(aCellsSize,0);
1421 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1422 aCellTypesArray->SetNumberOfComponents(1);
1423 aCellTypesArray->SetNumberOfTuples(aNbCells);
1425 if(theSubProfile->myStatus == eAddAll){
1426 VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin();
1427 for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){
1428 const TConnect& anArray = aCell2Connect[anId];
1429 PrintCells(aConnId,aConnectivity,anArray);
1430 aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
1431 aConnId += aNbNodes;
1435 VISU::TSubMeshID::const_iterator anIter = aSubMeshID.begin();
1436 for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){
1437 vtkIdType aSubId = *anIter;
1438 const TConnect& anArray = aCell2Connect[aSubId];
1439 PrintCells(aConnId,aConnectivity,anArray);
1440 aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
1441 aConnId += aNbNodes;
1446 vtkIdType *pts = 0, npts = 0;
1447 vtkIntArray* aCellLocationsArray = vtkIntArray::New();
1449 aCellLocationsArray->SetNumberOfComponents(1);
1450 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1451 aConnectivity->InitTraversal();
1452 for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
1453 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
1454 theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
1456 aCellLocationsArray->Delete();
1457 aCellTypesArray->Delete();
1458 aConnectivity->Delete();
1462 //---------------------------------------------------------------
1464 GetMeshOnSubProfile(const PMeshImpl& theMesh,
1465 const PMeshOnEntityImpl& theMeshOnEntity,
1466 const PProfileImpl& theProfile,
1467 const PSubProfileImpl& theSubProfile)
1469 INITMSG(MYDEBUG,"GetMeshOnSubProfile - aEGeom = "<<theSubProfile->myGeom<<endl);
1471 const TVTKSource& aSource = theSubProfile->GetSource();
1472 if(theSubProfile->myIsVTKDone)
1475 aSource->SetPoints(GetPoints(theMesh));
1476 INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
1477 GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
1478 BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
1480 theSubProfile->myIsVTKDone = true;
1484 //---------------------------------------------------------------
1486 GetMeshOnProfile(const PMeshImpl& theMesh,
1487 const PMeshOnEntityImpl& theMeshOnEntity,
1488 const PProfileImpl& theProfile)
1490 INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<endl);
1492 if(theProfile->myIsVTKDone)
1495 theProfile->myMeshOnEntity = theMeshOnEntity.get();
1496 const TVTKAppendFilter& anAppendFilter = theProfile->GetFilter();
1497 anAppendFilter->SetPoints(GetPoints(theMesh));
1499 if(theProfile->myIsAll){
1500 TVTKOutput* aDataSet = theMeshOnEntity->GetVTKOutput();
1501 anAppendFilter->AddInput(aDataSet);
1503 const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
1505 TID2ID& anElemObj2VTKID = theProfile->myElemObj2VTKID;
1507 TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr;
1508 aSubProfileArr.resize(aGeom2SubProfile.size());
1510 TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
1511 for(vtkIdType anInputID = 0, aCellID = 0; anIter != aGeom2SubProfile.end(); anIter++){
1512 PSubProfileImpl aSubProfile = anIter->second;
1513 if(aSubProfile->myStatus == eRemoveAll)
1516 GetMeshOnSubProfile(theMesh,
1521 const TVTKSource& aSource = aSubProfile->GetSource();
1522 anAppendFilter->AddInput(aSource.GetPointer());
1524 vtkIdType aNbCells = aSource->GetNumberOfCells();
1525 for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
1526 anElemObj2VTKID[aSubProfile->GetElemObjID(aCell)] = aCellID;
1529 aSubProfileArr[anInputID++] = aSubProfile;
1532 anAppendFilter->Update(); // Fix on VTK
1533 theProfile->myNamedPointCoords = theMesh->myNamedPointCoords;
1535 theProfile->myIsVTKDone = true;
1539 //---------------------------------------------------------------
1541 GetTimeStampOnGaussMesh(const TVTKSource& theSource,
1542 const PFieldImpl& theField,
1543 const PValForTimeImpl& theValForTime)
1545 int aNbTuples = theSource->GetNumberOfPoints();
1546 std::string aFieldName = GenerateFieldName(theField,theValForTime);
1548 vtkDataSetAttributes* aDataSetAttributes;
1549 switch(theField->myEntity){
1550 case VISU::NODE_ENTITY :
1551 aDataSetAttributes = theSource->GetPointData();
1554 aDataSetAttributes = theSource->GetCellData();
1557 int aNbComp = theField->myNbComp;
1558 vtkFloatArray *aFloatArray = vtkFloatArray::New();
1561 aFloatArray->SetNumberOfComponents(1);
1562 aDataSetAttributes->SetScalars(aFloatArray);
1565 aFloatArray->SetNumberOfComponents(3);
1566 aDataSetAttributes->SetVectors(aFloatArray);
1568 aFloatArray->SetNumberOfTuples(aNbTuples);
1569 aFloatArray->SetName(aFieldName.c_str());
1571 vtkFloatArray *aDataArray = vtkFloatArray::New();
1572 aDataArray->SetNumberOfComponents(aNbComp);
1573 aDataArray->SetNumberOfTuples(aNbTuples);
1574 aDataArray->SetName("VISU_FIELD");
1575 aDataSetAttributes->AddArray(aDataArray);
1577 INITMSG(MYDEBUG,"GetTimeStampOnGaussMesh "<<
1578 "- aNbTuples = "<<aNbTuples<<
1579 "; aNbComp = "<<aNbComp<<
1582 int aSize = max(3,aNbComp);
1583 TVector<float> aDataValues(aSize,0.0);
1585 const TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
1587 PGaussMeshImpl aGaussMesh = theValForTime->myGaussMesh;
1588 const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
1589 TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
1590 for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
1591 EGeometry aEGeom = anIter->first;
1593 PGaussSubMeshImpl aGaussSubMesh = anIter->second;
1594 if(!aGaussSubMesh->myIsDone)
1597 TGeom2Value::const_iterator anIter2 = aGeom2Value.find(aEGeom);
1598 if(anIter2 == aGeom2Value.end()){
1599 EXCEPTION(runtime_error,
1600 "GetTimeStampOnGaussMesh >> Can't find values for corresponding Gauss Points SubMesh");
1602 const TMeshValue& aMeshValue = anIter2->second;
1603 int aNbGauss = aMeshValue.myNbGauss;
1604 int aNbElem = aMeshValue.myNbElem;
1609 const TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
1612 "- aEGeom = "<<aEGeom<<
1613 "; aNbElem = "<<aNbElem<<
1614 "; aNbGauss = "<<aNbGauss<<
1615 "; aCoords.GetNbPoints() = "<<aCoords.GetNbPoints()<<
1618 if(aCoords.GetNbPoints() == aNbElem*aNbGauss){
1619 for(int iElem = 0; iElem < aNbElem; iElem++){
1620 TCValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);
1621 for(int iGauss = 0; iGauss < aNbGauss; iGauss++, aTupleId++){
1622 const TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
1623 for(int iComp = 0; iComp < aNbComp; iComp++){
1624 aDataValues[iComp] = aValueSlice[iComp];
1626 aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
1627 aDataArray->SetTuple(aTupleId,&aDataValues[0]);
1631 for(int iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
1632 TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iElem);
1633 for(int iComp = 0; iComp < aNbComp; iComp++){
1634 const TCValueSlice& aValueSlice = aValueSliceArr[iComp];
1635 aDataValues[iComp] = 0.0;
1636 for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
1637 aDataValues[iComp] += aValueSlice[iGauss];
1639 aDataValues[iComp] /= aNbGauss;
1641 aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
1642 aDataArray->SetTuple(aTupleId,&aDataValues[0]);
1646 aFloatArray->Delete();
1647 aDataArray->Delete();
1651 //---------------------------------------------------------------
1653 GetSource(const TVTKSource& theSource,
1654 const PGaussSubMeshImpl& theGaussSubMesh,
1655 const PMeshOnEntityImpl& theMeshOnEntity)
1657 const TPointCoords& aCoords = theGaussSubMesh->myPointCoords;
1658 vtkIdType aNbPoints = aCoords.GetNbPoints();
1659 vtkIdType aDim = aCoords.GetDim();
1661 vtkIdType aNbCells = theGaussSubMesh->myNbCells;
1662 vtkIdType aCellsSize = theGaussSubMesh->myCellsSize;
1664 vtkCellArray* aConnectivity = vtkCellArray::New();
1665 aConnectivity->Allocate(aCellsSize,0);
1666 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
1667 aCellTypesArray->SetNumberOfComponents(1);
1668 aCellTypesArray->SetNumberOfTuples(aNbCells);
1670 const TVTKPoints& aPoints = aCoords.GetPoints();
1671 vtkIdList *anIdList = vtkIdList::New();
1672 anIdList->SetNumberOfIds(1);
1673 for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
1674 TCCoordSlice aSlice = aCoords.GetCoordSlice(aPointId);
1676 float aCoords[3] = {0.0, 0.0, 0.0};
1677 for(vtkIdType aDimId = 0; aDimId < aDim; aDimId++)
1678 aCoords[aDimId] = aSlice[aDimId];
1680 aPoints->SetPoint(aPointId,aCoords);
1682 anIdList->SetId(0,aPointId);
1683 aConnectivity->InsertNextCell(anIdList);
1684 aCellTypesArray->SetValue(aPointId,(unsigned char)VTK_VERTEX);
1688 vtkIntArray* aCellLocationsArray = vtkIntArray::New();
1689 aCellLocationsArray->SetNumberOfComponents(1);
1690 aCellLocationsArray->SetNumberOfTuples(aNbCells);
1692 vtkIdType *pts = 0, npts = 0;
1693 aConnectivity->InitTraversal();
1694 for(int i = 0; aConnectivity->GetNextCell(npts,pts); i++)
1695 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
1697 const TVTKSource& aSource = theGaussSubMesh->GetSource();
1698 aSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
1699 aSource->SetPoints(aPoints.GetPointer());
1701 aCellLocationsArray->Delete();
1702 aCellTypesArray->Delete();
1703 aConnectivity->Delete();
1707 //---------------------------------------------------------------
1709 GetGaussSubMesh(const PMeshImpl& theMesh,
1710 const PMeshOnEntityImpl& theMeshOnEntity,
1711 const PGaussMeshImpl& theGaussMesh,
1712 const PGaussSubMeshImpl& theGaussSubMesh)
1714 PGaussImpl aGauss = theGaussSubMesh->myGauss;
1715 INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<<aGauss->myGeom<<endl);
1717 if(!theGaussSubMesh->myIsDone)
1720 if(theGaussSubMesh->myIsVTKDone)
1723 const TVTKSource& aSource = theGaussSubMesh->GetSource();
1724 GetSource(aSource,theGaussSubMesh,theMeshOnEntity);
1725 INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
1726 BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
1728 theGaussSubMesh->myIsVTKDone = true;
1732 //---------------------------------------------------------------
1734 BuildGaussMesh(const PMeshImpl& theMesh,
1735 const PMeshOnEntityImpl& theMeshOnEntity,
1736 const PGaussMeshImpl& theGaussMesh)
1738 if(theGaussMesh->myIsVTKDone)
1741 INITMSG(MYDEBUG,"BuildGaussMesh"<<endl);
1742 const TVTKAppendFilter& anAppendFilter = theGaussMesh->GetFilter();
1743 const TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
1744 TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
1745 for(; anIter != aGeom2GaussSubMesh.end(); anIter++){
1746 PGaussSubMeshImpl aGaussSubMesh = anIter->second;
1747 if(aGaussSubMesh->myStatus == eRemoveAll)
1750 GetGaussSubMesh(theMesh,
1755 const TVTKSource& aSource = aGaussSubMesh->GetSource();
1757 anAppendFilter->AddInput(aSource.GetPointer());
1759 anAppendFilter->Update(); // Fix on VTK
1761 theMeshOnEntity->GetVTKOutput()->Update();
1763 vtkDataSet* aSource = anAppendFilter->GetOutput();
1764 INITMSGA(MYDEBUG,0,"aNbPoints - "<<aSource->GetNumberOfPoints()<<endl);
1765 BEGMSG(MYDEBUG,"aNbCells - "<<aSource->GetNumberOfCells()<<endl);
1767 theGaussMesh->myIsVTKDone = true;
1771 //---------------------------------------------------------------
1773 PrintMemorySize(vtkUnstructuredGrid* theDataSet)
1775 theDataSet->Update();
1776 BEGMSG(1,"GetPoints() = "<<float(theDataSet->GetPoints()->GetActualMemorySize()*1000)<<endl);
1777 BEGMSG(1,"GetCells() = "<<float(theDataSet->GetCells()->GetActualMemorySize()*1000)<<endl);
1778 BEGMSG(1,"GetCellTypesArray() = "<<float(theDataSet->GetCellTypesArray()->GetActualMemorySize()*1000)<<endl);
1779 BEGMSG(1,"GetCellLocationsArray() = "<<float(theDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000)<<endl);
1780 theDataSet->BuildLinks();
1781 BEGMSG(1,"GetCellLinks() = "<<float(theDataSet->GetCellLinks()->GetActualMemorySize()*1000)<<endl);
1782 BEGMSG(1,"GetPointData() = "<<float(theDataSet->GetPointData()->GetActualMemorySize()*1000)<<endl);
1783 BEGMSG(1,"GetCellData() = "<<float(theDataSet->GetCellData()->GetActualMemorySize()*1000)<<endl);
1784 BEGMSG(1,"GetActualMemorySize() = "<<float(theDataSet->GetActualMemorySize()*1000)<<endl);
1789 //---------------------------------------------------------------
1791 ::VISU_Convertor_impl()
1797 //---------------------------------------------------------------
1799 ::~VISU_Convertor_impl()
1803 //---------------------------------------------------------------
1847 //---------------------------------------------------------------
1848 VISU::PNamedIDMapper
1850 ::GetMeshOnEntity(const string& theMeshName,
1851 const VISU::TEntity& theEntity)
1853 INITMSG(MYDEBUG,"GetMeshOnEntity"<<
1854 "; theMeshName = '"<<theMeshName<<"'"<<
1855 "; theEntity = "<<theEntity<<
1858 //Cheching possibility do the query
1859 TFindMeshOnEntity aFindMeshOnEntity =
1860 FindMeshOnEntity(theMeshName,theEntity);
1862 PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
1863 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1869 if(!aMeshOnEntity->myIsVTKDone){
1870 const TVTKAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter();
1871 if(MYVTKDEBUG) anAppendFilter->DebugOn();
1873 LoadMeshOnEntity(aMesh,aMeshOnEntity);
1874 anAppendFilter->SetPoints(GetPoints(aMesh));
1876 const TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
1877 TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
1879 TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID;
1880 TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr;
1881 aSubMeshArr.resize(aGeom2SubMesh.size());
1883 for(vtkIdType anID = 0, aCellID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){
1884 EGeometry aEGeom = anIter->first;
1885 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
1886 PSubMeshImpl aSubMesh = anIter->second;
1887 const TVTKSource& aSource = aSubMesh->GetSource();
1888 aSource->SetPoints(GetPoints(aMesh));
1889 GetCellsOnSubMesh(aSource,aMeshOnEntity,aSubMesh,aVGeom);
1890 anAppendFilter->AddInput(aSource.GetPointer());
1892 aSubMesh->myStartID = aCellID;
1893 vtkIdType aNbCells = aSource->GetNumberOfCells();
1894 for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
1895 vtkIdType anObjID = aSubMesh->GetElemObjID(aCell);
1896 anElemObj2VTKID[anObjID] = aCellID;
1898 aSubMeshArr[anID] = aSubMesh;
1900 aMeshOnEntity->myNamedPointCoords = aMesh->myNamedPointCoords;
1902 aMeshOnEntity->myIsVTKDone = true;
1904 if(MYDEBUGWITHFILES){
1905 std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
1906 std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
1907 aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-Conv.vtk";
1908 VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
1912 GetMeshOnEntitySize(theMeshName,theEntity);
1913 PrintMemorySize(anAppendFilter->GetOutput());
1923 return aMeshOnEntity;
1927 //---------------------------------------------------------------
1930 ::GetFamilyOnEntity(const std::string& theMeshName,
1931 const VISU::TEntity& theEntity,
1932 const std::string& theFamilyName)
1934 INITMSG(MYDEBUG,"GetFamilyOnEntity"<<
1935 "; theMeshName = '"<<theMeshName<<"'"<<
1936 "; theEntity = "<<theEntity<<
1937 "; theFamilyName = '"<<theFamilyName<<"'"<<
1940 //Cheching possibility do the query
1941 TFindFamilyOnEntity aFindFamilyOnEntity =
1942 FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
1944 PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);;
1945 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
1946 PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
1952 if(!aFamily->myIsVTKDone){
1953 const TVTKSource& aSource = aFamily->GetSource();
1954 if(MYVTKDEBUG) aSource->DebugOn();
1956 GetMeshOnEntity(theMeshName,theEntity);
1958 LoadFamilyOnEntity(aMesh,aMeshOnEntity,aFamily);
1959 aSource->SetPoints(GetPoints(aMesh));
1960 GetCellsOnFamily(aSource,aMeshOnEntity,aFamily);
1962 aFamily->myNamedPointCoords = aMesh->myNamedPointCoords;
1964 aFamily->myIsVTKDone = true;
1966 if(MYDEBUGWITHFILES){
1967 std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
1968 std::string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1();
1969 std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
1970 aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-Conv.vtk";
1971 VISU::WriteToFile(aSource.GetPointer(),aFileName);
1975 GetFamilyOnEntitySize(theMeshName,theEntity,theFamilyName);
1976 PrintMemorySize(aSource.GetPointer());
1990 //---------------------------------------------------------------
1993 ::GetMeshOnGroup(const string& theMeshName,
1994 const string& theGroupName)
1996 INITMSG(MYDEBUG,"GetMeshOnGroup\n");
1998 "- theMeshName = '"<<theMeshName<<
1999 "'; theGroupName = '"<<theGroupName<<"'"<<
2002 //Cheching possibility do the query
2003 TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
2004 PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
2005 PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
2011 if(!aGroup->myIsVTKDone){
2012 const TVTKAppendFilter& anAppendFilter = aGroup->GetFilter();
2013 const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
2015 LoadMeshOnGroup(aMesh,aFamilySet);
2016 anAppendFilter->SetPoints(GetPoints(aMesh));
2018 TFamilySet::const_iterator anIter = aFamilySet.begin();
2020 TID2ID& anElemObj2VTKID = aGroup->myElemObj2VTKID;
2021 TFamilyArr& aFamilyArr = aGroup->myFamilyArr;
2022 aFamilyArr.resize(aFamilySet.size());
2024 for(vtkIdType anID = 0; anIter != aFamilySet.end(); anIter++){
2025 PFamilyImpl aFamily = *anIter;
2026 const std::string& aFamilyName = aFamily->myName;
2027 const VISU::TEntity& anEntity = aFamily->myEntity;
2029 VISU::PIDMapper anIDMapper = GetFamilyOnEntity(theMeshName,anEntity,aFamilyName);
2030 VISU::TVTKOutput* anOutput = anIDMapper->GetVTKOutput();
2031 anAppendFilter->AddInput(anOutput);
2033 vtkIdType aNbCells = anOutput->GetNumberOfCells();
2034 for(vtkIdType aCellID = 0; aCellID < aNbCells; aCellID++){
2035 anElemObj2VTKID[aFamily->GetElemObjID(aCellID)] = aCellID;
2037 aFamilyArr[anID] = aFamily;
2039 aGroup->myNamedPointCoords = aMesh->myNamedPointCoords;
2041 aGroup->myIsVTKDone = true;
2043 if(MYDEBUGWITHFILES){
2044 std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
2045 std::string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1();
2046 std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
2047 aFileName += aMeshName + "-" + aGroupName + "-Conv.vtk";
2048 VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
2061 //---------------------------------------------------------------
2064 ::GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh,
2065 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
2066 const VISU::PFieldImpl& theField,
2067 const VISU::PValForTimeImpl& theValForTime,
2068 const VISU::PIDMapperFilter& theIDMapperFilter,
2069 const VISU::PProfileImpl& theProfile,
2070 const VISU::TEntity& theEntity)
2072 LoadMeshOnEntity(theMesh,theMeshOnEntity);
2073 GetMeshOnEntity(theMeshOnEntity->myMeshName,theMeshOnEntity->myEntity);
2074 GetMeshOnProfile(theMesh,theMeshOnEntity,theProfile);
2076 theIDMapperFilter->myIDMapper = theProfile;
2077 TVTKOutput* anOutput = theIDMapperFilter->GetVTKOutput();
2078 const TVTKSource& aSource = theIDMapperFilter->mySource.GetSource();
2079 ::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity);
2085 //---------------------------------------------------------------
2088 ::GetTimeStampOnMesh(const string& theMeshName,
2089 const VISU::TEntity& theEntity,
2090 const string& theFieldName,
2093 INITMSG(MYDEBUG,"GetTimeStampOnMesh"<<
2094 "; theMeshName = '"<<theMeshName<<"'"<<
2095 "; theEntity = "<<theEntity<<
2096 "; theFieldName = '"<<theFieldName<<"'"<<
2097 "; theStampsNum = "<<theStampsNum<<
2100 //Cheching possibility do the query
2101 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
2106 PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
2107 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
2108 PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
2109 PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
2110 PFieldImpl aField = boost::get<3>(aFindTimeStamp);
2113 PIDMapperFilter anIDMapperFilter = aValForTime->myIDMapperFilter;
2117 if(!anIDMapperFilter->myIsVTKDone){
2118 LoadValForTimeOnMesh(aMesh,aMeshOnEntity,aField,aValForTime);
2120 TVTKOutput* anOutput;
2122 anOutput = GetTimeStampOnProfile(aMesh,
2127 aValForTime->myProfile,
2128 aMeshOnEntity->myEntity);
2129 }catch(std::exception& exc){
2130 MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
2131 anOutput = GetTimeStampOnProfile(aMesh,
2136 aValForTime->myProfile,
2137 aVTKMeshOnEntity->myEntity);
2140 anIDMapperFilter->myIsVTKDone = true;
2142 if(MYDEBUGWITHFILES){
2143 string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
2144 string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
2145 string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-";
2146 string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
2147 aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk";
2148 VISU::WriteToFile(anOutput,aFileName);
2151 GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum);
2153 if(theEntity == VISU::NODE_ENTITY)
2154 BEGMSG(MYVTKDEBUG,"GetPointData() = "<<float(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
2156 BEGMSG(MYVTKDEBUG,"GetCellData() = "<<float(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
2157 BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<float(anOutput->GetActualMemorySize()*1000)<<endl);
2161 }catch(std::exception& exc){
2168 return anIDMapperFilter;
2172 //---------------------------------------------------------------
2173 VISU::PGaussPtsIDMapper
2175 ::GetTimeStampOnGaussPts(const string& theMeshName,
2176 const VISU::TEntity& theEntity,
2177 const string& theFieldName,
2180 INITMSG(MYDEBUG,"GetTimeStampOnGaussPts"<<
2181 "; theMeshName = '"<<theMeshName<<"'"<<
2182 "; theEntity = "<<theEntity<<
2183 "; theFieldName = '"<<theFieldName<<"'"<<
2184 "; theStampsNum = "<<theStampsNum<<
2187 //Cheching possibility do the query
2188 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
2193 PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
2194 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
2195 PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
2196 PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
2197 PFieldImpl aField = boost::get<3>(aFindTimeStamp);
2200 PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
2204 if(!aGaussPtsIDFilter->myIsVTKDone){
2205 LoadValForTimeOnGaussPts(aMesh,aMeshOnEntity,aField,aValForTime);
2207 GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity);
2209 PProfileImpl aProfile = aValForTime->myProfile;
2210 GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile);
2212 PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh;
2213 TSource& aGaussPtsSource = aGaussMesh->mySource;
2214 if(!aGaussPtsSource.myIsVTKDone){
2215 BuildGaussMesh(aMesh,aVTKMeshOnEntity,aGaussMesh);
2216 aGaussMesh->myParent = aProfile.get();
2217 aGaussPtsSource.myIsVTKDone = true;
2220 aGaussPtsIDFilter->myIDMapper = aGaussMesh;
2221 aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh;
2222 TVTKOutput* anOutput = aGaussPtsIDFilter->GetVTKOutput();
2223 const TVTKSource& aSource = aGaussPtsIDFilter->mySource.GetSource();
2224 GetTimeStampOnGaussMesh(aSource,aField,aValForTime);
2226 aGaussPtsIDFilter->myIsVTKDone = true;
2228 if(MYDEBUGWITHFILES){
2229 string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
2230 string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
2231 string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-";
2232 string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
2233 aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk";
2234 VISU::WriteToFile(anOutput,aFileName);
2237 GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum);
2239 if(theEntity == VISU::NODE_ENTITY)
2240 BEGMSG(MYVTKDEBUG,"GetPointData() = "<<float(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
2242 BEGMSG(MYVTKDEBUG,"GetCellData() = "<<float(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
2243 BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<float(anOutput->GetActualMemorySize()*1000)<<endl);
2247 }catch(std::exception& exc){
2254 return aGaussPtsIDFilter;
2257 //---------------------------------------------------------------
2260 ::FindMesh(const string& theMeshName)
2263 TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName);
2264 if(aMeshMapIter == myMeshMap.end())
2265 EXCEPTION(runtime_error,"FindMesh >> There is no mesh with the name - '"<<theMeshName<<"'!!!");
2267 PMeshImpl aMesh = aMeshMapIter->second;
2272 //---------------------------------------------------------------
2273 VISU_Convertor_impl::TFindMeshOnEntity
2275 ::FindMeshOnEntity(const string& theMeshName,
2276 const VISU::TEntity& theEntity)
2278 PMeshImpl aMesh = FindMesh(theMeshName);
2279 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
2280 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
2281 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
2282 EXCEPTION(runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
2284 PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
2286 return TFindMeshOnEntity(aMesh,
2291 //---------------------------------------------------------------
2292 VISU_Convertor_impl::TFindFamilyOnEntity
2294 ::FindFamilyOnEntity(const string& theMeshName,
2295 const VISU::TEntity& theEntity,
2296 const string& theFamilyName)
2298 if(theFamilyName != ""){
2299 PMeshImpl aMesh = FindMesh(theMeshName);
2300 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
2301 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
2302 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
2303 EXCEPTION(runtime_error,"FindFamilyOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
2305 PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
2307 TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
2308 TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName);
2309 if(aFamilyMapIter != aFamilyMap.end()){
2310 const PFamily& aFamily = aFamilyMapIter->second;
2311 return TFindFamilyOnEntity(aMesh,
2316 return TFindFamilyOnEntity();
2320 //---------------------------------------------------------------
2325 float aResult = 0.0;
2326 const VISU::TMeshMap& aMeshMap = GetMeshMap();
2327 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
2328 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
2329 const string& aMeshName = aMeshMapIter->first;
2330 const VISU::PMesh aMesh = aMeshMapIter->second;
2331 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
2332 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
2334 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
2335 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
2336 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
2337 const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
2338 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
2339 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
2340 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
2341 const string& aFieldName = aFieldMapIter->first;
2342 const VISU::PField aField = aFieldMapIter->second;
2343 const VISU::TValField& aValField = aField->myValField;
2344 VISU::TValField::const_iterator aValFieldIter = aValField.begin();
2345 for(; aValFieldIter != aValField.end(); aValFieldIter++){
2346 int aTimeStamp = aValFieldIter->first;
2347 aResult += GetTimeStampSize(aMeshName,anEntity,aFieldName,aTimeStamp);
2351 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
2352 VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
2353 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
2354 const string& aGroupName = aGroupMapIter->first;
2355 aResult += GetMeshOnGroupSize(aMeshName,aGroupName);
2358 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
2359 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
2360 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
2361 const string& aFamilyName = aFamilyMapIter->first;
2362 aResult += GetFamilyOnEntitySize(aMeshName,anEntity,aFamilyName);
2364 //Import mesh on entity
2365 aResult += GetMeshOnEntitySize(aMeshName,anEntity);
2368 MSG(MYDEBUG,"GetSize - aResult = "<<float(aResult));
2373 //---------------------------------------------------------------
2376 ::GetMeshOnEntitySize(const std::string& theMeshName,
2377 const VISU::TEntity& theEntity)
2379 TFindMeshOnEntity aFindMeshOnEntity =
2380 FindMeshOnEntity(theMeshName,theEntity);
2382 PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
2383 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
2385 vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
2386 vtkIdType aNbCells = aMeshOnEntity->myNbCells;
2387 vtkIdType aCellsSize = aMeshOnEntity->myCellsSize;
2389 vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
2390 vtkIdType aTypesSize = aNbCells*sizeof(char);
2391 vtkIdType aLocationsSize = aNbCells*sizeof(int);
2392 float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
2393 vtkIdType aLinksSize = aMesh->myNbPoints *
2394 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
2396 vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
2398 MSG(MYDEBUG,"GetMeshOnEntitySize "<<
2399 "- aResult = "<<float(aResult)<<
2400 "; theMeshName = '"<<theMeshName<<"'"<<
2401 "; theEntity = "<<theEntity);
2403 INITMSG(MYVTKDEBUG,"- aPointsSize = "<<float(aPointsSize)<<"\n");
2404 BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<float(aConnectivitySize)<<"\n");
2405 BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<float(aTypesSize)<<"\n");
2406 BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<float(aLocationsSize)<<"\n");
2407 BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<float(aLinksSize)<<"\n");
2410 aResult = vtkIdType(aResult*ERR_SIZE_CALC);
2415 //---------------------------------------------------------------
2418 ::GetFamilyOnEntitySize(const std::string& theMeshName,
2419 const VISU::TEntity& theEntity,
2420 const std::string& theFamilyName)
2422 TFindFamilyOnEntity aFindFamilyOnEntity =
2423 FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
2424 PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);
2425 PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
2426 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
2428 vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
2429 vtkIdType aNbCells = aFamily->myNbCells;
2430 vtkIdType aCellsSize = aFamily->myCellsSize;
2432 vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
2433 vtkIdType aTypesSize = aNbCells*sizeof(char);
2434 vtkIdType aLocationsSize = aNbCells*sizeof(int);
2435 float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
2436 vtkIdType aLinksSize = aMesh->myNbPoints *
2437 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
2439 vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
2441 MSG(MYDEBUG,"GetFamilyOnEntitySize "<<
2442 "- aResult = "<<float(aResult)<<
2443 "; theMeshName = '"<<theMeshName<<"'"<<
2444 "; theEntity = "<<theEntity<<
2445 "; theFamilyName = '"<<theFamilyName<<"'");
2447 INITMSG(MYVTKDEBUG,"- aPointsSize = "<<float(aPointsSize)<<"\n");
2448 BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<float(aConnectivitySize)<<"\n");
2449 BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<float(aTypesSize)<<"\n");
2450 BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<float(aLocationsSize)<<"\n");
2451 BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<float(aLinksSize)<<"\n");
2454 aResult = vtkIdType(aResult*ERR_SIZE_CALC);
2459 //---------------------------------------------------------------
2460 VISU_Convertor_impl::TFindMeshOnGroup
2462 ::FindMeshOnGroup(const std::string& theMeshName,
2463 const std::string& theGroupName)
2465 PMeshImpl aMesh = FindMesh(theMeshName);
2466 VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
2467 VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName);
2468 if(aGroupMapIter == aGroupMap.end())
2469 EXCEPTION(runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<<theGroupName<<"'");
2471 VISU::PGroupImpl aGroup = aGroupMapIter->second;
2472 return TFindMeshOnGroup(aMesh,aGroup);
2478 ::GetMeshOnGroupSize(const std::string& theMeshName,
2479 const std::string& theGroupName)
2481 TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
2482 PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
2483 PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
2485 vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
2486 TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells();
2487 vtkIdType aNbCells = aNbASizeCells.first;
2488 vtkIdType aCellsSize = aNbASizeCells.second;
2489 vtkIdType aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
2490 vtkIdType aLocationsSize = aNbCells*sizeof(int);
2491 float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
2492 vtkIdType aLinksSize = aMesh->myNbPoints *
2493 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
2495 vtkIdType aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
2497 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aPointsSize = "<<float(aPointsSize));
2498 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<float(aConnectivityAndTypesSize));
2499 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLocationsSize = "<<float(aLocationsSize));
2500 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLinksSize = "<<float(aLinksSize));
2502 MSG(MYDEBUG,"GetMeshOnGroupSize - aResult = "<<float(aResult)<<"; theMeshName = '"
2503 <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
2505 aResult = vtkIdType(aResult*ERR_SIZE_CALC);
2510 VISU_Convertor_impl::TFindField
2512 ::FindField(const string& theMeshName,
2513 const VISU::TEntity& theEntity,
2514 const string& theFieldName)
2516 TFindMeshOnEntity aFindMeshOnEntity =
2517 FindMeshOnEntity(theMeshName,theEntity);
2519 PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
2520 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
2522 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
2523 PMeshOnEntityImpl aVTKMeshOnEntity;
2524 if(theEntity == VISU::NODE_ENTITY){
2525 if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) != aMeshOnEntityMap.end())
2526 aVTKMeshOnEntity = aMeshOnEntityMap[VISU::CELL_ENTITY];
2527 else if(aMeshOnEntityMap.find(VISU::FACE_ENTITY) != aMeshOnEntityMap.end())
2528 aVTKMeshOnEntity = aMeshOnEntityMap[VISU::FACE_ENTITY];
2529 else if(aMeshOnEntityMap.find(VISU::NODE_ENTITY) != aMeshOnEntityMap.end())
2530 aVTKMeshOnEntity = aMeshOnEntityMap[VISU::EDGE_ENTITY];
2532 aVTKMeshOnEntity = aMeshOnEntity;
2534 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
2535 VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find(theFieldName);
2536 if(aFieldIter == aFieldMap.end())
2537 EXCEPTION(runtime_error,"FindField >> There is no field on the mesh!!!");
2539 PFieldImpl aField = aFieldIter->second;
2541 return TFindField(aMesh,
2550 ::GetFieldOnMeshSize(const std::string& theMeshName,
2551 const VISU::TEntity& theEntity,
2552 const std::string& theFieldName)
2554 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
2555 PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
2556 PFieldImpl aField = boost::get<3>(aFindField);
2558 float aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
2559 float aFieldOnMeshSize = float(aField->myDataSize*sizeof(float)*aField->myValField.size()*ERR_SIZE_CALC);
2560 float aResult = aMeshSize + aFieldOnMeshSize;
2562 MSG(MYVTKDEBUG,"GetFieldOnMeshSize - aFieldOnMeshSize = "<<float(aFieldOnMeshSize));
2563 MSG(MYDEBUG,"GetFieldOnMeshSize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
2564 "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
2570 VISU_Convertor_impl::TFindTimeStamp
2572 ::FindTimeStamp(const std::string& theMeshName,
2573 const VISU::TEntity& theEntity,
2574 const std::string& theFieldName,
2577 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
2578 PField aField = boost::get<3>(aFindField);
2580 VISU::TValField& aValField = aField->myValField;
2581 VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum);
2582 if(aValFieldIter == aValField.end())
2583 EXCEPTION(runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!");
2585 PMeshImpl aMesh = boost::get<0>(aFindField);
2586 PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField);
2587 PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
2588 PValForTimeImpl aValForTime = aValFieldIter->second;
2590 return TFindTimeStamp(aMesh,
2600 ::GetTimeStampSize(const std::string& theMeshName,
2601 const VISU::TEntity& theEntity,
2602 const std::string& theFieldName,
2605 TFindTimeStamp aFindTimeStamp =
2606 FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
2607 PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
2608 PFieldImpl aField = boost::get<3>(aFindTimeStamp);
2610 float aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
2611 float aTimeStampSize = float(aField->myDataSize*sizeof(float) * ERR_SIZE_CALC);
2612 float aResult = aMeshSize + aTimeStampSize;
2614 MSG(MYDEBUG && MYVTKDEBUG,"GetTimeStampSize - aTimeStampSize = "<<float(aTimeStampSize));
2615 MSG(MYDEBUG,"GetTimeStampSize - aResult = "<<float(aResult)<<
2616 "; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
2617 "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
2625 ::GetField(const string& theMeshName,
2626 VISU::TEntity theEntity,
2627 const string& theFieldName)
2629 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
2630 PField aField = boost::get<3>(aFindField);
2635 const VISU::PValForTime
2637 ::GetTimeStamp(const std::string& theMeshName,
2638 const VISU::TEntity& theEntity,
2639 const std::string& theFieldName,
2642 TFindTimeStamp aFindTimeStamp =
2643 FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
2644 PValForTime aValForTime = boost::get<4>(aFindTimeStamp);