1 // Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
24 // Author: Alexey PETROV
27 #include "VISU_Structures_impl.hxx"
28 #include "VISU_PointCoords.hxx"
29 #include "VISU_MeshValue.hxx"
31 #include "VISU_AppendFilter.hxx"
32 #include "VISU_AppendPolyData.hxx"
33 #include "VISU_MergeFilter.hxx"
35 #include "VISU_ConvertorUtils.hxx"
36 #include "VISU_CommonCellsFilter.hxx"
38 #include <vtkUnstructuredGrid.h>
39 #include <vtkPolyData.h>
40 #include <vtkCellType.h>
46 VISUGeom2NbNodes(EGeometry theGeom)
49 #ifndef VISU_ENABLE_QUADRATIC
74 VISUGeom2VTK(EGeometry theGeom)
88 return VTK_HEXAHEDRON;
97 return VTK_CONVEX_POINT_SET;
99 #ifndef VISU_ENABLE_QUADRATIC
109 return VTK_HEXAHEDRON;
118 #if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)
119 return VTK_QUADRATIC_EDGE;
121 return VTK_POLY_LINE;
125 #if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)
126 return VTK_QUADRATIC_TRIANGLE;
132 #if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)
133 return VTK_QUADRATIC_QUAD;
139 #if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)
140 return VTK_QUADRATIC_TETRA;
142 return VTK_CONVEX_POINT_SET;
146 #if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC)
147 return VTK_QUADRATIC_HEXAHEDRON;
149 return VTK_CONVEX_POINT_SET;
153 #if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC)
154 return VTK_QUADRATIC_WEDGE;
156 return VTK_CONVEX_POINT_SET;
160 #if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)
161 return VTK_QUADRATIC_PYRAMID;
163 return VTK_CONVEX_POINT_SET;
166 #endif //VISU_ENABLE_QUADRATIC
175 VTKGeom2VISU(vtkIdType theGeom)
179 return VISU::ePOINT1;
187 return VISU::eTETRA4;
191 return VISU::ePENTA6;
196 return VISU::ePOLYGONE;
197 case VTK_CONVEX_POINT_SET:
198 return VISU::ePOLYEDRE;
200 #if defined(VISU_ENABLE_QUADRATIC) && defined(VISU_USE_VTK_QUADRATIC)
201 #if defined(VTK_QUADRATIC_EDGE)
202 case VTK_QUADRATIC_EDGE:
206 #if defined(VTK_QUADRATIC_TRIANGLE)
207 case VTK_QUADRATIC_TRIANGLE:
211 #if defined(VTK_QUADRATIC_QUAD)
212 case VTK_QUADRATIC_QUAD:
216 #if defined(VTK_QUADRATIC_TETRA)
217 case VTK_QUADRATIC_TETRA:
218 return VISU::eTETRA10;
221 #if defined(VTK_QUADRATIC_HEXAHEDRON)
222 case VTK_QUADRATIC_HEXAHEDRON:
223 return VISU::eHEXA20;
226 #if defined(VTK_QUADRATIC_WEDGE)
227 case VTK_QUADRATIC_WEDGE:
228 return VISU::ePENTA15;
231 #if defined(VTK_QUADRATIC_PYRAMID)
232 case VTK_QUADRATIC_PYRAMID:
233 return VISU::ePYRA13;
236 #endif //VISU_ENABLE_QUADRATIC
239 return EGeometry(-1);
243 //---------------------------------------------------------------
244 /*! Computes number of points by the given number of cells
245 * in assumption of regular hexahedral mesh structure
248 GetNumberOfPoints(size_t theNbCells)
250 return size_t(pow(pow(theNbCells, 1.0/3.0) + 1.0, 3.0));
253 //---------------------------------------------------------------
254 /*! Computes size dataset the given number of mesh macro metrics
255 * in assumption of regular hexahedral mesh structure
258 GetDataSetSize(size_t theNbOfPoints,
261 bool theComputeLinks)
263 size_t aPointsSize = 3*theNbOfPoints*sizeof(VISU::TCoord);
264 size_t aConnectivityAndTypesSize = theCellsSize*sizeof(vtkIdType);
265 size_t aLocationsSize = theNbOfCells*sizeof(int);
266 vtkFloatingPointType aNbCellsPerPoint = theCellsSize / theNbOfCells - 1;
267 size_t aLinksSize = theNbOfPoints * (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
270 size_t aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
274 //---------------------------------------------------------------
282 //---------------------------------------------------------------
291 if(!mySource.GetPointer()){
292 mySource = vtkPolyData::New();
300 ::GetPolyDataOutput()
302 return GetSource().GetPointer();
309 if(vtkDataSet* anOutput = GetPolyDataOutput()){
311 return anOutput->GetActualMemorySize() * 1024;
314 size_t aNbPoints = GetNumberOfPoints(myNbCells);
315 return GetDataSetSize(aNbPoints, myNbCells, myCellsSize, false);
317 throw std::runtime_error("TUnstructuredGridHolder::GetMemorySize - myIsDone == false !!!");
321 //---------------------------------------------------------------
322 TUnstructuredGridHolder
323 ::TUnstructuredGridHolder()
326 const PUnstructuredGrid&
327 TUnstructuredGridHolder
330 if(!mySource.GetPointer()){
331 mySource = vtkUnstructuredGrid::New();
338 TUnstructuredGridHolder
339 ::GetUnstructuredGridOutput()
341 return GetSource().GetPointer();
345 TUnstructuredGridHolder
348 if(vtkDataSet* anOutput = GetUnstructuredGridOutput()){
350 return anOutput->GetActualMemorySize() * 1024;
353 size_t aNbPoints = GetNumberOfPoints(myNbCells);
354 return GetDataSetSize(aNbPoints, myNbCells, myCellsSize, false);
356 throw std::runtime_error("TUnstructuredGridHolder::GetMemorySize - myIsDone == false !!!");
360 //---------------------------------------------------------------
366 if(vtkDataSet* anOutput = GetOutput()){
368 return anOutput->GetActualMemorySize() * 1024;
371 throw std::runtime_error("TMemoryCheckIDMapper::GetMemorySize - myIsVTKDone == false !!!");
376 //---------------------------------------------------------------
378 ::TAppendFilterHolder()
385 if(!myFilter.GetPointer()){
386 myFilter = VISU_AppendFilter::New();
388 myFilter->SetMappingInputs(true);
395 ::GetUnstructuredGridOutput()
397 GetFilter()->Update();
398 return GetFilter()->GetOutput();
401 //---------------------------------------------------------------
402 TAppendPolyDataHolder
403 ::TAppendPolyDataHolder()
406 const PAppendPolyData&
407 TAppendPolyDataHolder
410 if(!myFilter.GetPointer()){
411 myFilter = VISU_AppendPolyData::New();
412 myFilter->SetMappingInputs(true);
419 TAppendPolyDataHolder
420 ::GetPolyDataOutput()
422 GetFilter()->Update();
423 return GetFilter()->GetOutput();
427 //---------------------------------------------------------------
429 ::TMergeFilterHolder()
436 if(!myFilter.GetPointer()){
437 myFilter = VISU_MergeFilter::New();
447 GetFilter()->Update();
448 return GetFilter()->GetOutput();
452 //---------------------------------------------------------------
476 return myNamedPointCoords->GetPointSet();
480 //---------------------------------------------------------------
481 TSubProfileImpl::TSubProfileImpl():
489 ::GetElemObjID(vtkIdType theID) const
491 if ( !mySubMeshID.empty() )
492 return mySubMeshID[theID];
500 ::GetElemVTKID(vtkIdType theID) const
502 if ( !mySubMeshID.empty() )
503 for ( size_t anId = 0; anId < mySubMeshID.size(); anId++ )
504 if ( mySubMeshID[ anId ] == theID )
514 size_t aSize = TUnstructuredGridHolder::GetMemorySize();
515 aSize += sizeof(vtkIdType) * mySubMeshID.size();
520 //---------------------------------------------------------------
522 operator<(const PSubProfile& theLeft, const PSubProfile& theRight)
524 PSubProfileImpl aLeft(theLeft), aRight(theRight);
526 if(aLeft->myGeom != aRight->myGeom)
527 return aLeft->myGeom < aRight->myGeom;
529 if(aLeft->myStatus != aRight->myStatus)
530 return aLeft->myStatus < aRight->myStatus;
532 return aLeft->myName < aRight->myName;
536 //---------------------------------------------------------------
545 ::GetNodeObjID(vtkIdType theID) const
547 return myNamedPointCoords->GetObjID(theID);
552 ::GetNodeVTKID(vtkIdType theID) const
554 return myNamedPointCoords->GetVTKID(theID);
557 vtkFloatingPointType*
559 ::GetNodeCoord(vtkIdType theObjID)
562 return myMeshOnEntity->GetNodeCoord(theObjID);
564 vtkIdType aVtkID = GetNodeVTKID(theObjID);
565 return GetFilter()->GetOutput()->GetPoint(aVtkID);
570 ::GetElemObjID(vtkIdType theID) const
572 return VISU::GetElemObjID(GetFilter()->GetOutput(), theID);
577 ::GetElemVTKID(vtkIdType theID) const
579 return VISU::GetElemVTKID(GetFilter()->GetOutput(), theID);
584 ::GetElemCell(vtkIdType theObjID)
587 return myMeshOnEntity->GetElemCell(theObjID);
589 vtkIdType aVtkID = GetElemVTKID(theObjID);
590 return GetFilter()->GetOutput()->GetCell(aVtkID);
595 ::GetUnstructuredGridOutput()
597 const PAppendFilter& anAppendFilter = GetFilter();
598 return anAppendFilter->GetOutput();
605 size_t aSize = TAppendFilterHolder::GetMemorySize();
606 aSize += myNamedPointCoords->GetMemorySize();
607 aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType);
608 TGeom2SubProfile::const_iterator anIter = myGeom2SubProfile.begin();
609 TGeom2SubProfile::const_iterator anIterEnd = myGeom2SubProfile.end();
610 for(; anIter != anIterEnd; anIter++){
611 const PSubProfileImpl& aSubProfile = anIter->second;
612 aSize += aSubProfile->GetMemorySize();
613 aSize += sizeof(EGeometry);
620 ::GetNodeName(vtkIdType theObjID) const
622 return myNamedPointCoords->GetNodeName(theObjID);
627 ::GetElemName(vtkIdType theObjID) const
629 return myMeshOnEntity->GetElemName(theObjID);
633 //---------------------------------------------------------------
634 TUnstructuredGridIDMapperImpl
635 ::TUnstructuredGridIDMapperImpl()
637 if ( !myCommonCellsFilter.GetPointer() ) {
638 myCommonCellsFilter = VISU_CommonCellsFilter::New();
639 myCommonCellsFilter->Delete();
644 TUnstructuredGridIDMapperImpl
645 ::GetNodeObjID(vtkIdType theID) const
647 return myIDMapper->GetNodeObjID(theID);
651 TUnstructuredGridIDMapperImpl
652 ::GetNodeVTKID(vtkIdType theID) const
654 return myIDMapper->GetNodeVTKID(theID);
657 vtkFloatingPointType*
658 TUnstructuredGridIDMapperImpl
659 ::GetNodeCoord(vtkIdType theObjID)
661 return myIDMapper->GetNodeCoord(theObjID);
665 TUnstructuredGridIDMapperImpl
666 ::GetElemObjID(vtkIdType theID) const
668 return myIDMapper->GetElemObjID(theID);
672 TUnstructuredGridIDMapperImpl
673 ::GetElemVTKID(vtkIdType theID) const
675 return myIDMapper->GetElemVTKID(theID);
679 TUnstructuredGridIDMapperImpl
680 ::GetElemCell(vtkIdType theObjID)
682 return myIDMapper->GetElemCell(theObjID);
686 TUnstructuredGridIDMapperImpl
687 ::SetReferencedMesh( const PNamedIDMapper& theNamedIDMapper )
689 myCommonCellsFilter->SetCellsUG( theNamedIDMapper->GetUnstructuredGridOutput() );
693 TUnstructuredGridIDMapperImpl
696 if ( !myFilter.GetPointer() ) {
697 const PAppendFilter& anAppendFilter = myIDMapper->GetFilter();
699 vtkUnstructuredGrid* aGeometry = anAppendFilter->GetOutput();
700 const PUnstructuredGrid& aSource = mySource.GetSource();
701 vtkUnstructuredGrid* aDataSet = aSource.GetPointer();
702 aDataSet->ShallowCopy( aGeometry );
704 const PMergeFilter& aFilter = GetFilter();
705 aFilter->SetGeometry( aGeometry );
706 aFilter->SetScalars( aDataSet );
707 aFilter->SetVectors( aDataSet );
708 aFilter->AddField( "VISU_FIELD", aDataSet );
709 aFilter->AddField( "VISU_FIELD_GAUSS_MIN", aDataSet );
710 aFilter->AddField( "VISU_FIELD_GAUSS_MAX", aDataSet );
711 aFilter->AddField( "VISU_FIELD_GAUSS_MOD", aDataSet );
712 aFilter->AddField( "VISU_CELLS_MAPPER", aDataSet );
713 aFilter->AddField( "ELNO_FIELD", aDataSet );
714 aFilter->AddField( "ELNO_COMPONENT_MAPPER", aDataSet );
715 aFilter->AddField( "VISU_POINTS_MAPPER", aDataSet );
717 myCommonCellsFilter->SetProfileUG( aFilter->GetUnstructuredGridOutput() );
722 TUnstructuredGridIDMapperImpl
723 ::GetUnstructuredGridOutput()
726 return myCommonCellsFilter->GetOutput();
730 TUnstructuredGridIDMapperImpl
733 return GetUnstructuredGridOutput();
737 TUnstructuredGridIDMapperImpl
741 return mySource.GetSource();
745 TUnstructuredGridIDMapperImpl
748 size_t aSize = myIDMapper->GetMemorySize();
750 aSize += mySource.GetMemorySize();
752 if ( vtkUnstructuredGrid* anOutput = myCommonCellsFilter->GetOutput() )
753 aSize += anOutput->GetActualMemorySize() * 1024;
758 //---------------------------------------------------------------
760 TPolyDataIDMapperImpl
761 ::GetNodeObjID(vtkIdType theID) const
763 return myIDMapper->GetNodeObjID(theID);
767 TPolyDataIDMapperImpl
768 ::GetNodeVTKID(vtkIdType theID) const
770 return myIDMapper->GetNodeVTKID(theID);
773 vtkFloatingPointType*
774 TPolyDataIDMapperImpl
775 ::GetNodeCoord(vtkIdType theObjID)
777 return myIDMapper->GetNodeCoord(theObjID);
781 TPolyDataIDMapperImpl
782 ::GetElemObjID(vtkIdType theID) const
784 return myIDMapper->GetElemObjID(theID);
788 TPolyDataIDMapperImpl
789 ::GetElemVTKID(vtkIdType theID) const
791 return myIDMapper->GetElemVTKID(theID);
795 TPolyDataIDMapperImpl
796 ::GetElemCell(vtkIdType theObjID)
798 return myIDMapper->GetElemCell(theObjID);
802 TPolyDataIDMapperImpl
805 if ( !myFilter.GetPointer() ) {
806 const PAppendPolyData& anAppendFilter = myIDMapper->GetFilter();
807 vtkPolyData* aGeometry = anAppendFilter->GetOutput();
809 const PPolyData& aSource = mySource.GetSource();
810 vtkPolyData* aDataSet = aSource.GetPointer();
811 aDataSet->ShallowCopy( aGeometry );
813 const PMergeFilter& aFilter = GetFilter();
814 aFilter->SetGeometry( aGeometry );
815 aFilter->SetScalars( aDataSet );
816 aFilter->SetVectors( aDataSet );
817 aFilter->AddField( "VISU_FIELD", aDataSet );
818 aFilter->AddField( "VISU_FIELD_GAUSS_MIN", aDataSet );
819 aFilter->AddField( "VISU_FIELD_GAUSS_MAX", aDataSet );
820 aFilter->AddField( "VISU_FIELD_GAUSS_MOD", aDataSet );
821 aFilter->AddField( "VISU_CELLS_MAPPER", aDataSet );
822 aFilter->AddField( "VISU_POINTS_MAPPER", aDataSet );
827 TPolyDataIDMapperImpl
828 ::GetPolyDataOutput()
831 return myFilter->GetPolyDataOutput();
835 TPolyDataIDMapperImpl
838 return GetPolyDataOutput();
842 TPolyDataIDMapperImpl
846 return mySource.GetSource();
850 TPolyDataIDMapperImpl
853 size_t aSize = myIDMapper->GetMemorySize();
854 aSize += mySource.GetMemorySize();
859 //---------------------------------------------------------------
862 myGeom(EGeometry(-1)),
868 ::LessThan(const PGaussImpl& theGauss,
869 bool& theResult) const
875 //---------------------------------------------------------------
877 ::TGaussSubMeshImpl():
878 myPointCoords(new TPointCoords()),
885 ::GetObjID(vtkIdType theID) const
887 TCellID aCellID = myStartID + theID / myGauss->myNbPoints;
888 TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
890 return TGaussPointID(aCellID, aLocalPntID);
895 ::GetVTKID(const TGaussPointID& theID) const
897 vtkIdType aResult = -1;
899 TCellID aCellID = theID.first;
900 TLocalPntID aLocalPntID = theID.second;
902 vtkIdType aNbPoints = myGauss->myNbPoints;
903 if ( aLocalPntID >= aNbPoints )
906 return ( aCellID - myStartID ) * aNbPoints + aLocalPntID;
910 VISU::TGaussSubMeshImpl
911 ::GetElemObjID(vtkIdType theID) const
913 return mySubProfile->GetElemObjID( theID );
918 VISU::TGaussSubMeshImpl
919 ::GetElemVTKID(vtkIdType theID) const
921 return mySubProfile->GetElemVTKID( theID );
926 ::GetGlobalID(vtkIdType theID) const
928 return myStartID + theID;
935 size_t aSize = TPolyDataHolder::GetMemorySize();
936 aSize += myPointCoords->GetMemorySize();
940 //---------------------------------------------------------------
942 operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight)
944 PGaussSubMeshImpl aLeft(theLeft), aRight(theRight);
945 const PGaussImpl& aGaussLeft = aLeft->myGauss;
946 const PGaussImpl& aGaussRight = aRight->myGauss;
948 if(aGaussLeft->myGeom != aGaussRight->myGeom)
949 return aGaussLeft->myGeom < aGaussRight->myGeom;
951 if(aLeft->mySubProfile != aRight->mySubProfile)
952 return aLeft->mySubProfile < aRight->mySubProfile;
955 aGaussLeft->LessThan(aGaussRight,aResult);
961 //---------------------------------------------------------------
969 ::GetObjID(vtkIdType theID) const
971 const PAppendPolyData& aFilter = GetFilter();
972 return VISU::GetObjID(aFilter->GetOutput(), theID);
977 ::GetVTKID(const TGaussPointID& theID) const
979 vtkIdType aResult = -1;
981 TCellID aCellID = theID.first;
983 vtkIdType aVTKCellId = GetParent()->GetElemVTKID( aCellID );
984 if ( aVTKCellId < 0 )
987 vtkCell* aCell = GetParent()->GetElemCell( aCellID );
991 EGeometry aVGeom = VISU::VTKGeom2VISU( aCell->GetCellType() );
992 if ( aVGeom < EGeometry(0) )
995 TGeom2GaussSubMesh::const_iterator anIter = myGeom2GaussSubMesh.find( aVGeom );
996 if ( anIter == myGeom2GaussSubMesh.end() )
999 size_t aSubMeshEnd = myGaussSubMeshArr.size();
1000 const PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
1001 for ( size_t aSubMeshId = 0; aSubMeshId < aSubMeshEnd; aSubMeshId++ ) {
1002 const PGaussSubMeshImpl& aSubMesh = myGaussSubMeshArr[aSubMeshId];
1003 if ( aGaussSubMesh.get() == aSubMesh.get() ) {
1004 return aGaussSubMesh->GetVTKID(theID);
1013 ::GetPolyDataOutput()
1015 return TAppendPolyDataHolder::GetPolyDataOutput();
1022 size_t aSize = TAppendPolyDataHolder::GetMemorySize();
1023 TGeom2GaussSubMesh::const_iterator anIter = myGeom2GaussSubMesh.begin();
1024 TGeom2GaussSubMesh::const_iterator anIterEnd = myGeom2GaussSubMesh.end();
1025 for(; anIter != anIterEnd; anIter++){
1026 const PGaussSubMeshImpl& aGaussSubMesh = anIter->second;
1027 aSize += aGaussSubMesh->GetMemorySize();
1028 aSize += sizeof(EGeometry);
1041 //---------------------------------------------------------------
1044 ::GetObjID(vtkIdType theID) const
1046 return myGaussPtsIDMapper->GetObjID(theID);
1051 ::GetVTKID(const TGaussPointID& theID) const
1053 return myGaussPtsIDMapper->GetVTKID(theID);
1060 return myGaussPtsIDMapper->GetParent();
1065 ::GetPolyDataOutput()
1067 return TPolyDataIDMapperImpl::GetPolyDataOutput();
1074 return GetPolyDataOutput();
1078 //---------------------------------------------------------------
1086 ::CopyStructure( PStructured theStructured )
1088 TStructured::CopyStructure( theStructured );
1090 if ( PMeshImpl aMesh = theStructured )
1091 GetSource()->ShallowCopy( aMesh->GetPointSet() );
1096 ::GetElemObjID(vtkIdType theID) const
1098 return myStartID + theID;
1103 ::GetElemName(vtkIdType theObjID) const
1112 size_t aSize = TUnstructuredGridHolder::GetMemorySize();
1113 for(size_t anId = 0; anId < myCell2Connect.size(); anId++){
1114 const TConnect& aConnect = myCell2Connect[anId];
1115 aSize += aConnect.size() * sizeof(vtkIdType);
1120 //---------------------------------------------------------------
1122 ::TMeshOnEntityImpl()
1124 const PAppendFilter& anAppendFilter = GetFilter();
1125 anAppendFilter->SetMappingInputs(true);
1130 ::CopyStructure( PStructured theStructured )
1132 TStructured::CopyStructure( theStructured );
1134 if ( PMeshImpl aMesh = theStructured )
1135 myNamedPointCoords = aMesh->myNamedPointCoords;
1140 ::GetNodeVTKID(vtkIdType theID) const
1142 return myNamedPointCoords->GetVTKID(theID);
1147 ::GetNodeObjID(vtkIdType theID) const
1149 return myNamedPointCoords->GetObjID(theID);
1154 ::GetElemVTKID(vtkIdType theID) const
1156 return VISU::GetElemVTKID(GetFilter()->GetOutput(), theID);
1161 ::GetElemObjID(vtkIdType theID) const
1163 return VISU::GetElemObjID(GetFilter()->GetOutput(), theID);
1168 ::GetNodeName(vtkIdType theObjID) const
1170 return myNamedPointCoords->GetNodeName(theObjID);
1175 ::GetElemName(vtkIdType theObjID) const
1177 TInputCellID anInputCellID = VISU::GetInputCellID(GetFilter()->GetOutput(), theObjID);
1178 const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputCellID.first];
1179 return aSubMesh->GetElemName(anInputCellID.second);
1182 vtkUnstructuredGrid*
1184 ::GetUnstructuredGridOutput()
1186 return TAppendFilterHolder::GetUnstructuredGridOutput();
1193 size_t aSize = TAppendFilterHolder::GetMemorySize();
1194 aSize += myNamedPointCoords->GetMemorySize();
1195 aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType);
1196 TGeom2SubMesh::const_iterator anIter = myGeom2SubMesh.begin();
1197 TGeom2SubMesh::const_iterator anIterEnd = myGeom2SubMesh.end();
1198 for(; anIter != anIterEnd; anIter++){
1199 const PSubMeshImpl& aSubMesh = anIter->second;
1200 aSize += aSubMesh->GetMemorySize();
1201 aSize += sizeof(EGeometry);
1206 //---------------------------------------------------------------
1209 ::CopyStructure( PStructured theStructured )
1211 TStructured::CopyStructure( theStructured );
1213 if ( PMeshImpl aMesh = theStructured ) {
1214 myNamedPointCoords = aMesh->myNamedPointCoords;
1215 GetSource()->ShallowCopy( aMesh->GetPointSet() );
1221 ::GetElemVTKID(vtkIdType theID) const
1223 if(myElemObj2VTKID.empty())
1226 TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
1227 if(anIter != myElemObj2VTKID.end())
1228 return anIter->second;
1235 ::GetElemObjID(vtkIdType theID) const
1237 return myMeshID[theID];
1242 ::GetNodeObjID(vtkIdType theID) const
1244 return myNamedPointCoords->GetObjID(theID);
1249 ::GetNodeVTKID(vtkIdType theID) const
1251 return myNamedPointCoords->GetVTKID(theID);
1254 vtkUnstructuredGrid*
1256 ::GetUnstructuredGridOutput()
1258 return TUnstructuredGridHolder::GetUnstructuredGridOutput();
1265 size_t aSize = TUnstructuredGridHolder::GetMemorySize();
1266 aSize += myNamedPointCoords->GetMemorySize();
1267 aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType);
1268 aSize += myMeshID.size() * sizeof(vtkIdType);
1269 TGeom2SubMeshID::const_iterator anIter = myGeom2SubMeshID.begin();
1270 TGeom2SubMeshID::const_iterator anIterEnd = myGeom2SubMeshID.end();
1271 for(; anIter != anIterEnd; anIter++){
1272 const TSubMeshID& aSubMeshID = anIter->second;
1273 aSize += aSubMeshID.size() * sizeof(vtkIdType);
1274 aSize += sizeof(EGeometry);
1280 //---------------------------------------------------------------
1283 ::CopyStructure( PStructured theStructured )
1285 TStructured::CopyStructure( theStructured );
1287 if ( PMeshImpl aMesh = theStructured )
1288 myNamedPointCoords = aMesh->myNamedPointCoords;
1293 ::GetNbASizeCells() const
1295 vtkIdType aNbCells = 0, aCellsSize = 0;
1296 TFamilySet::const_iterator anIter = myFamilySet.begin();
1297 for(; anIter != myFamilySet.end(); anIter++){
1298 PFamilyImpl aFamily = (*anIter).second;
1299 aNbCells += aFamily->myNbCells;
1300 aCellsSize += aFamily->myCellsSize;
1302 return std::make_pair(aNbCells,aCellsSize);
1307 ::GetElemVTKID(vtkIdType theID) const
1309 if(myElemObj2VTKID.empty())
1312 TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
1313 if(anIter != myElemObj2VTKID.end())
1314 return anIter->second;
1321 ::GetElemObjID(vtkIdType theID) const
1323 return VISU::GetElemObjID(GetFilter()->GetOutput(), theID);
1328 ::GetNodeObjID(vtkIdType theID) const
1330 return myNamedPointCoords->GetObjID(theID);
1335 ::GetNodeVTKID(vtkIdType theID) const
1337 return myNamedPointCoords->GetVTKID(theID);
1340 vtkUnstructuredGrid*
1342 ::GetUnstructuredGridOutput()
1344 return TAppendFilterHolder::GetUnstructuredGridOutput();
1351 size_t aSize = TAppendFilterHolder::GetMemorySize();
1352 aSize += myNamedPointCoords->GetMemorySize();
1353 aSize += myElemObj2VTKID.size() * 2 * sizeof(vtkIdType);
1354 for(size_t anId = 0; anId < myFamilyArr.size(); anId++){
1355 const PFamilyImpl& aFamily = myFamilyArr[anId];
1356 aSize += aFamily->GetMemorySize();
1363 //---------------------------------------------------------------
1372 ::Init(vtkIdType theNbComp,
1373 vtkIdType theDataType)
1375 myNbComp = theNbComp;
1376 myDataType = theDataType;
1377 myCompNames.resize(theNbComp);
1378 myUnitNames.resize(theNbComp);
1380 myMetric2Comp2MinMax.resize(3);
1381 myMetric2Comp2AverageMinMax.resize(3);
1382 myMetric2Comp2Group2MinMax.resize(3);
1383 myMetric2Comp2Group2AverageMinMax.resize(3);
1384 for(int aGaussMetric = (int)VISU::AVERAGE_METRIC; aGaussMetric <= (int)VISU::MAXIMUM_METRIC; aGaussMetric++){
1385 TComp2MinMax& aComp2MinMax = myMetric2Comp2MinMax[aGaussMetric];
1386 TComp2MinMax& aComp2AverageMinMax = myMetric2Comp2AverageMinMax[aGaussMetric];
1387 TComp2Group2MinMax& aComp2Group2MinMax = myMetric2Comp2Group2MinMax[aGaussMetric];
1388 TComp2Group2MinMax& aComp2Group2AverageMinMax = myMetric2Comp2Group2AverageMinMax[aGaussMetric];
1390 aComp2MinMax.resize(theNbComp + 1);
1391 aComp2AverageMinMax.resize(theNbComp + 1);
1392 aComp2Group2MinMax.resize(theNbComp + 1);
1393 aComp2Group2AverageMinMax.resize(theNbComp + 1);
1394 for(vtkIdType iComp = 0; iComp <= theNbComp; iComp++){
1395 TMinMax& aMinMax = aComp2MinMax[iComp];
1396 aMinMax.first = VTK_LARGE_FLOAT;
1397 aMinMax.second = -VTK_LARGE_FLOAT;
1398 TMinMax& anAverageMinMax = aComp2AverageMinMax[iComp];
1399 anAverageMinMax.first = VTK_LARGE_FLOAT;
1400 anAverageMinMax.second = -VTK_LARGE_FLOAT;
1407 ::GetDataType() const
1414 ::GetMinMax(vtkIdType theCompID, const TNames& theGroupNames, TGaussMetric theGaussMetric)
1417 bool anIsMinMaxInitialized = false;
1418 if( !theGroupNames.empty() ) {
1419 aMinMax.first = VTK_LARGE_FLOAT;
1420 aMinMax.second = -VTK_LARGE_FLOAT;
1422 const TGroup2MinMax& aGroup2MinMax = myMetric2Comp2Group2MinMax[theGaussMetric][theCompID];
1423 TNames::const_iterator aNameIter = theGroupNames.begin();
1424 for( ; aNameIter != theGroupNames.end(); aNameIter++ ) {
1425 TGroup2MinMax::const_iterator aGroup2MinMaxIter = aGroup2MinMax.find( *aNameIter );
1426 if( aGroup2MinMaxIter != aGroup2MinMax.end() ) {
1427 const TMinMax& aGroupMinMax = aGroup2MinMaxIter->second;
1428 aMinMax.first = std::min( aMinMax.first, aGroupMinMax.first );
1429 aMinMax.second = std::max( aMinMax.second, aGroupMinMax.second );
1430 anIsMinMaxInitialized = true;
1435 if( !anIsMinMaxInitialized )
1436 aMinMax = myMetric2Comp2MinMax[theGaussMetric][theCompID];
1444 ::GetAverageMinMax(vtkIdType theCompID, const TNames& theGroupNames, TGaussMetric theGaussMetric)
1447 bool anIsMinMaxInitialized = false;
1448 if( !theGroupNames.empty() ) {
1449 aMinMax.first = VTK_LARGE_FLOAT;
1450 aMinMax.second = -VTK_LARGE_FLOAT;
1452 const TGroup2MinMax& aGroup2MinMax = myMetric2Comp2Group2AverageMinMax[theGaussMetric][theCompID];
1453 TNames::const_iterator aNameIter = theGroupNames.begin();
1454 for( ; aNameIter != theGroupNames.end(); aNameIter++ ) {
1455 TGroup2MinMax::const_iterator aGroup2MinMaxIter = aGroup2MinMax.find( *aNameIter );
1456 if( aGroup2MinMaxIter != aGroup2MinMax.end() ) {
1457 const TMinMax& aGroupMinMax = aGroup2MinMaxIter->second;
1458 aMinMax.first = std::min( aMinMax.first, aGroupMinMax.first );
1459 aMinMax.second = std::max( aMinMax.second, aGroupMinMax.second );
1460 anIsMinMaxInitialized = true;
1465 if( !anIsMinMaxInitialized )
1466 aMinMax = myMetric2Comp2AverageMinMax[theGaussMetric][theCompID];
1471 //----------------------------------------------------------------------------
1474 ::GetMeshValue(EGeometry theGeom) const
1476 TGeom2MeshValue::const_iterator anIter = myGeom2MeshValue.find(theGeom);
1477 if(anIter == myGeom2MeshValue.end())
1478 EXCEPTION(std::runtime_error,"TGeom2Value::GetMeshValue - myGeom2MeshValue.find(theGeom) fails");
1479 return anIter->second;
1484 ::GetMeshValue(EGeometry theGeom)
1486 return myGeom2MeshValue[theGeom];
1490 //----------------------------------------------------------------------------
1493 ::GetGeom2MeshValue()
1495 return myGeom2MeshValue;
1498 const TGeom2MeshValue&
1500 ::GetGeom2MeshValue() const
1502 return myGeom2MeshValue;
1507 ::GetFirstMeshValue() const
1509 if(myGeom2MeshValue.size() == 1)
1510 return myGeom2MeshValue.begin()->second;
1511 return PMeshValue();
1515 //---------------------------------------------------------------
1517 ::TValForTimeImpl():
1518 myGaussPtsIDFilter(new TGaussPtsIDFilter()),
1519 myUnstructuredGridIDMapper(new TUnstructuredGridIDMapperImpl())
1524 ::GetMeshValue(EGeometry theGeom) const
1526 return myGeom2Value.GetMeshValue(theGeom);
1531 ::GetMeshValue(EGeometry theGeom)
1533 return myGeom2Value.GetMeshValue(theGeom);
1538 ::GetGeom2MeshValue()
1540 return myGeom2Value.GetGeom2MeshValue();
1543 const TGeom2MeshValue&
1545 ::GetGeom2MeshValue() const
1547 return myGeom2Value.GetGeom2MeshValue();
1552 ::GetFirstMeshValue() const
1554 return myGeom2Value.GetFirstMeshValue();
1559 ::GetNbGauss(EGeometry theGeom) const
1561 TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom);
1562 if(anIter == myGeom2NbGauss.end()){
1565 return anIter->second;
1570 ::GetMaxNbGauss() const
1573 TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.begin();
1574 for(; anIter != myGeom2NbGauss.end(); anIter++){
1575 aNbGauss = std::max<int>(aNbGauss, anIter->second);
1584 size_t aSize = sizeof(TValForTimeImpl);
1585 const TGeom2MeshValue& aGeom2MeshValue = GetGeom2MeshValue();
1586 TGeom2MeshValue::const_iterator anIter = aGeom2MeshValue.begin();
1587 TGeom2MeshValue::const_iterator anIterEnd = aGeom2MeshValue.end();
1588 for(; anIter != anIterEnd; anIter++){
1589 const PMeshValue& aMeshValue = anIter->second;
1590 aSize += aMeshValue->GetMemorySize();
1591 aSize += sizeof(EGeometry);
1596 //---------------------------------------------------------------