1 // Copyright (C) 2007-2011 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
23 // VISU OBJECT : interactive object for VISU entities implementation
24 // File : VISU_Convertor_impl.cxx
25 // Author : Alexey PETROV
28 #include "VISU_Convertor_impl.hxx"
29 #include "VISU_Structures_impl.hxx"
30 #include "VISU_PointCoords.hxx"
31 #include "VISU_MeshValue.hxx"
33 #include "VISU_AppendFilter.hxx"
34 #include "VISU_AppendPolyData.hxx"
35 #include "VTKViewer_CellLocationsArray.h"
36 #include "VISU_CommonCellsFilter.hxx"
38 #include "VISU_ConvertorUtils.hxx"
40 #include <vtkUnstructuredGrid.h>
41 #include <vtkPolyData.h>
43 #include <vtkPoints.h>
44 #include <vtkPointData.h>
45 #include <vtkCellData.h>
47 #include <vtkIdList.h>
48 #include <vtkCellType.h>
49 #include <vtkCellArray.h>
50 #include <vtkCellLinks.h>
51 #include <vtkUnsignedCharArray.h>
58 static vtkFloatingPointType ERR_SIZE_CALC = 1.00;
60 static int MYVTKDEBUG = 0;
63 static int MYDEBUG = 0;
64 static int MYDEBUGWITHFILES = 0;
67 static int MYDEBUG = 0;
68 static int MYDEBUGWITHFILES = 0;
74 //---------------------------------------------------------------
77 dtos(const std::string& fmt, T val)
79 static QString aString;
80 aString.sprintf(fmt.c_str(),val);
81 return (const char*)aString.toLatin1();
85 //---------------------------------------------------------------
88 PrintCells( vtkCellArray* theConnectivity,
89 const VISU::TConnect& theVector)
91 theConnectivity->InsertNextCell( theVector.size(), &theVector[ 0 ] );
95 //---------------------------------------------------------------
97 GetCellsOnSubMesh(const VISU::PUnstructuredGrid& theSource,
98 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
99 const VISU::PSubMeshImpl& theSubMesh,
100 const vtkIdType theGeom)
102 VISU::TTimerLog aTimerLog(MYDEBUG,"GetCellsOnSubMesh");
103 const VISU::TCell2Connect& anArray = theSubMesh->myCell2Connect;
104 vtkIdType aCellsSize = theSubMesh->myCellsSize;
105 vtkIdType aNbCells = theSubMesh->myNbCells;
106 INITMSG(MYDEBUG,"GetCellsOnSubMesh "<<
107 "- theGeom = "<<theGeom<<
108 "; aNbCells = "<<aNbCells<<
112 vtkCellArray* aConnectivity = vtkCellArray::New();
113 aConnectivity->Allocate(aCellsSize,0);
114 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
115 aCellTypesArray->SetNumberOfComponents(1);
116 aCellTypesArray->SetNumberOfTuples(aNbCells);
118 for(vtkIdType anID = 0; anID < aNbCells; anID++){
119 PrintCells( aConnectivity, anArray[ anID ] );
120 aCellTypesArray->SetValue(anID,(unsigned char)theGeom);
124 int aNbTuples = aNbCells;
125 int anEntity = int(theMeshOnEntity->myEntity);
126 vtkIntArray *aDataArray = vtkIntArray::New();
127 aDataArray->SetName("VISU_CELLS_MAPPER");
128 aDataArray->SetNumberOfComponents(2);
129 aDataArray->SetNumberOfTuples(aNbTuples);
130 int *aDataArrayPtr = aDataArray->GetPointer(0);
131 for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
132 int anObjID = theSubMesh->GetElemObjID(aTupleId);
133 *aDataArrayPtr++ = anObjID;
134 *aDataArrayPtr++ = anEntity;
136 theSource->GetCellData()->AddArray(aDataArray);
137 aDataArray->Delete();
140 vtkIdType *pts = 0, npts = 0;
141 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
142 aCellLocationsArray->SetNumberOfComponents(1);
143 aCellLocationsArray->SetNumberOfTuples(aNbCells);
144 aConnectivity->InitTraversal();
145 for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
146 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
147 theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
149 if(MYVTKDEBUG) aConnectivity->DebugOn();
151 aCellLocationsArray->Delete();
152 aCellTypesArray->Delete();
153 aConnectivity->Delete();
157 //---------------------------------------------------------------
159 GetCellsOnFamily(const VISU::PUnstructuredGrid& theSource,
160 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
161 const VISU::PFamilyImpl& theFamily)
163 INITMSG(MYDEBUG,"GetCellsOnFamily"<<endl);
165 vtkIdType aNbCells = theFamily->myNbCells;
166 vtkIdType aCellsSize = theFamily->myCellsSize;
168 vtkCellArray* aConnectivity = vtkCellArray::New();
169 aConnectivity->Allocate(aCellsSize,0);
170 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
171 aCellTypesArray->SetNumberOfComponents(1);
172 aCellTypesArray->SetNumberOfTuples(aNbCells);
174 VISU::TSubMeshID& aMeshID = theFamily->myMeshID;
175 aMeshID.resize(aNbCells);
177 vtkIntArray *aDataArray = vtkIntArray::New();
178 int anEntity = int(theMeshOnEntity->myEntity);
179 aDataArray->SetName("VISU_CELLS_MAPPER");
180 aDataArray->SetNumberOfComponents(2);
181 aDataArray->SetNumberOfTuples(aNbCells);
182 int *aDataArrayPtr = aDataArray->GetPointer(0);
184 VISU::TID2ID& anElemObj2VTKID = theFamily->myElemObj2VTKID;
186 const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
187 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
188 for(vtkIdType aCellId = 0; anIter != aGeom2SubMesh.end(); anIter++){
189 VISU::EGeometry aEGeom = anIter->first;
190 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
192 const VISU::TSubMeshImpl& aSubMesh = anIter->second;
193 const VISU::TCell2Connect& anArray = aSubMesh.myCell2Connect;
195 const VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
196 if(aGeom2SubMeshID.empty())
197 EXCEPTION(std::runtime_error,"GetCells >> There is no elements on the family !!!");
199 VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aEGeom);
200 if(aGeom2SubMeshIDIter == aGeom2SubMeshID.end())
203 const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second;
206 " - aEGeom = "<<aEGeom<<
207 "; aVGeom = "<<aVGeom<<
208 "; aSubMeshID.size() = "<<aSubMeshID.size()<<
211 VISU::TSubMeshID::const_iterator aSubMeshIDIter = aSubMeshID.begin();
212 for(; aSubMeshIDIter != aSubMeshID.end(); aSubMeshIDIter++, aCellId++){
213 vtkIdType anID = *aSubMeshIDIter;
214 PrintCells( aConnectivity, anArray[ anID ] );
215 aCellTypesArray->SetValue(aCellId, (unsigned char)aVGeom);
216 vtkIdType anObjID = aSubMesh.GetElemObjID(anID);
217 anElemObj2VTKID[anObjID] = aCellId;
218 aMeshID[aCellId] = anObjID;
219 *aDataArrayPtr++ = anObjID;
220 *aDataArrayPtr++ = anEntity;
224 theSource->GetCellData()->AddArray(aDataArray);
225 aDataArray->Delete();
227 vtkIdType *pts = 0, npts = 0;
228 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
229 aCellLocationsArray->SetNumberOfComponents(1);
230 aCellLocationsArray->SetNumberOfTuples(aNbCells);
231 aConnectivity->InitTraversal();
232 for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
233 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
234 theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
236 if(MYVTKDEBUG) aConnectivity->DebugOn();
238 aCellLocationsArray->Delete();
239 aCellTypesArray->Delete();
240 aConnectivity->Delete();
244 //---------------------------------------------------------------
246 GetCells(const VISU::PUnstructuredGrid& theSource,
247 const VISU::PSubProfileImpl& theSubProfile,
248 const VISU::PProfileImpl& theProfile,
249 const VISU::PMeshOnEntityImpl& theMeshOnEntity)
251 vtkIdType aNbCells = theSubProfile->myNbCells;
252 vtkIdType aCellsSize = theSubProfile->myCellsSize;
253 VISU::EGeometry aEGeom = theSubProfile->myGeom;
254 vtkIdType aNbNodes = VISUGeom2NbNodes(aEGeom);
255 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
257 INITMSG(MYDEBUG,"GetCells - aVGeom = "<<aVGeom<<endl);
259 const VISU::TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID;
261 const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
262 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.find(aEGeom);
263 if(anIter == aGeom2SubMesh.end())
264 EXCEPTION(std::runtime_error,"GetCells >> There is no elements for the GEOM("<<aEGeom<<")");
266 const VISU::TSubMeshImpl& aSubMesh = anIter->second;
267 const VISU::TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect;
269 vtkCellArray* aConnectivity = vtkCellArray::New();
270 aConnectivity->Allocate(aCellsSize,0);
271 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
272 aCellTypesArray->SetNumberOfComponents(1);
273 aCellTypesArray->SetNumberOfTuples(aNbCells);
275 if(theSubProfile->myStatus == VISU::eAddAll){
276 VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin();
277 for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){
278 const VISU::TConnect& anArray = aCell2Connect[anId];
279 PrintCells( aConnectivity, anArray );
280 aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
285 VISU::TSubMeshID::const_iterator anIter = aSubMeshID.begin();
286 for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){
287 vtkIdType aSubId = *anIter;
288 const VISU::TConnect& anArray = aCell2Connect[aSubId];
289 PrintCells( aConnectivity, anArray );
290 aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
296 vtkIdType *pts = 0, npts = 0;
297 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
299 aCellLocationsArray->SetNumberOfComponents(1);
300 aCellLocationsArray->SetNumberOfTuples(aNbCells);
301 aConnectivity->InitTraversal();
302 for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
303 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
304 theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
307 int aNbTuples = aNbCells;
308 int anEntity = int(theMeshOnEntity->myEntity);
309 vtkIntArray *aDataArray = vtkIntArray::New();
310 aDataArray->SetName("VISU_CELLS_MAPPER");
311 aDataArray->SetNumberOfComponents(2);
312 aDataArray->SetNumberOfTuples(aNbTuples);
313 int *aDataArrayPtr = aDataArray->GetPointer(0);
314 for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
315 int anObjID = theSubProfile->GetElemObjID(aTupleId);
316 *aDataArrayPtr++ = anObjID;
317 *aDataArrayPtr++ = anEntity;
319 theSource->GetCellData()->AddArray(aDataArray);
320 aDataArray->Delete();
323 aCellLocationsArray->Delete();
324 aCellTypesArray->Delete();
325 aConnectivity->Delete();
329 //---------------------------------------------------------------
331 GetMeshOnSubProfile(const VISU::PMeshImpl& theMesh,
332 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
333 const VISU::PProfileImpl& theProfile,
334 const VISU::PSubProfileImpl& theSubProfile,
335 const bool checkEntity = true)
337 INITMSG(MYDEBUG,"GetMeshOnSubProfile - aEGeom = "<<theSubProfile->myGeom<<endl);
339 //rnv to fix the: 21040: [CEA 428] Bug of visualization of node field on profile
340 //throw exception in case if the profile on node.
341 //This exception catch in tne VISU_Convertor_impl::GetTimeStampOnMesh(...) function.
342 if( theMeshOnEntity->myEntity == VISU::CELL_ENTITY &&
343 theSubProfile->myGeom == VISU::ePOINT1 &&
344 !theSubProfile->isDefault() && checkEntity )
345 EXCEPTION(std::runtime_error,"theMeshOnEntity->myEntity == VISU::CELL_ENTITY && theSubProfile->myGeom == VISU::ePOINT1 && theSubProfile->isDefault()");
347 const VISU::PUnstructuredGrid& aSource = theSubProfile->GetSource();
348 if(theSubProfile->myIsVTKDone)
351 aSource->ShallowCopy(theMesh->GetPointSet());
352 INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
353 GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
354 BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
356 theSubProfile->myIsVTKDone = true;
360 //---------------------------------------------------------------
362 GetMeshOnProfile(const VISU::PMeshImpl& theMesh,
363 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
364 const VISU::PProfileImpl& theProfile,
365 const bool checkEntity = true)
367 //rnv fix for bug IPAL18514 4x (CRASH after trying to build of presentation):
368 // throw exection in case if pointer on profile =0
369 if(!theProfile.get())
370 EXCEPTION(std::runtime_error,"GetMeshOnProfile: theProfile.get() == NULL");
372 // rnv fix for issue 19999:
373 // Throw exception in case if mesh on entity from profile is not equal
374 // input mesh on entity. This exception catch in tne VISU_Convertor_impl::GetTimeStampOnMesh
376 if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
377 EXCEPTION(std::runtime_error,"GetMeshOnProfile >> theProfile->myMeshOnEntity != theMeshOnEntity.get()");
379 if(theProfile->myIsVTKDone)
382 // if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
385 VISU::TTimerLog aTimerLog(MYDEBUG,"GetMeshOnProfile");
386 INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<std::endl);
388 const VISU::PAppendFilter& anAppendFilter = theProfile->GetFilter();
389 anAppendFilter->SetSharedPointSet(theMesh->GetPointSet());
391 if(theProfile->myIsAll){
392 vtkUnstructuredGrid* aDataSet = theMeshOnEntity->GetUnstructuredGridOutput();
393 anAppendFilter->AddInput(aDataSet);
395 const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
397 VISU::TID2ID& anElemObj2VTKID = theProfile->myElemObj2VTKID;
399 VISU::TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr;
400 aSubProfileArr.resize(aGeom2SubProfile.size());
402 VISU::TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
403 for(vtkIdType anInputID = 0, aCellID = 0; anIter != aGeom2SubProfile.end(); anIter++){
404 VISU::PSubProfileImpl aSubProfile = anIter->second;
405 if(aSubProfile->myStatus == VISU::eRemoveAll)
408 GetMeshOnSubProfile(theMesh,
414 const VISU::PUnstructuredGrid& aSource = aSubProfile->GetSource();
415 anAppendFilter->AddInput(aSource.GetPointer());
417 vtkIdType aNbCells = aSource->GetNumberOfCells();
418 for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
419 vtkIdType anObjID = aSubProfile->GetElemObjID(aCell);
420 anElemObj2VTKID[anObjID] = aCellID;
423 aSubProfileArr[anInputID++] = aSubProfile;
426 anAppendFilter->Update(); // Fix on VTK
427 theProfile->myMeshOnEntity = theMeshOnEntity.get();
428 theProfile->myNamedPointCoords = theMesh->myNamedPointCoords;
430 theProfile->myIsVTKDone = true;
435 //---------------------------------------------------------------
437 GetGaussSubMeshSource(const VISU::PPolyData& theSource,
438 const VISU::PGaussSubMeshImpl& theGaussSubMesh,
439 const VISU::PMeshOnEntityImpl& theMeshOnEntity)
441 vtkCellArray* aConnectivity = vtkCellArray::New();
442 vtkIdType aCellsSize = theGaussSubMesh->myCellsSize;
443 aConnectivity->Allocate(aCellsSize, 0);
445 vtkIdList *anIdList = vtkIdList::New();
446 anIdList->SetNumberOfIds(1);
448 const VISU::TPointCoords& aCoords = theGaussSubMesh->myPointCoords;
449 vtkIdType aNbPoints = aCoords.GetNbPoints();
450 for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
451 anIdList->SetId(0, aPointId);
452 aConnectivity->InsertNextCell(anIdList);
456 const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
457 aSource->ShallowCopy(aCoords.GetPointSet());
458 aSource->SetVerts(aConnectivity);
460 aConnectivity->Delete();
463 vtkIdType aNbTuples = aNbPoints;
464 vtkIntArray *aDataArray = vtkIntArray::New();
465 aDataArray->SetName("VISU_POINTS_MAPPER");
466 aDataArray->SetNumberOfComponents(2);
467 aDataArray->SetNumberOfTuples(aNbTuples);
468 int *aDataArrayPtr = aDataArray->GetPointer(0);
469 for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
470 vtkIdType aGlobalID = theGaussSubMesh->GetGlobalID(aTupleId);
471 *aDataArrayPtr++ = aGlobalID;
472 *aDataArrayPtr++ = 0;
474 aSource->GetPointData()->AddArray(aDataArray);
475 aDataArray->Delete();
479 vtkIdType aNbTuples = aNbPoints;
480 vtkIntArray *aDataArray = vtkIntArray::New();
481 aDataArray->SetName("VISU_CELLS_MAPPER");
482 aDataArray->SetNumberOfComponents(2);
483 aDataArray->SetNumberOfTuples(aNbTuples);
484 int *aDataArrayPtr = aDataArray->GetPointer(0);
485 for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
486 VISU::TGaussPointID aGaussPointID = theGaussSubMesh->GetObjID(aTupleId);
487 *aDataArrayPtr++ = aGaussPointID.first;
488 *aDataArrayPtr++ = aGaussPointID.second;
490 aSource->GetCellData()->AddArray(aDataArray);
491 aDataArray->Delete();
496 //---------------------------------------------------------------
498 GetGaussSubMesh(const VISU::PMeshImpl& theMesh,
499 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
500 const VISU::PGaussMeshImpl& theGaussMesh,
501 const VISU::PGaussSubMeshImpl& theGaussSubMesh)
503 VISU::PGaussImpl aGauss = theGaussSubMesh->myGauss;
505 if(!theGaussSubMesh->myIsDone)
508 if(theGaussSubMesh->myIsVTKDone)
511 VISU::TTimerLog aTimerLog(MYDEBUG,"GetGaussSubMesh");
512 INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<<aGauss->myGeom<<endl);
514 const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
515 GetGaussSubMeshSource(aSource, theGaussSubMesh, theMeshOnEntity);
517 INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
518 BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
520 theGaussSubMesh->myIsVTKDone = true;
524 //---------------------------------------------------------------
526 BuildGaussMesh(const VISU::PMeshImpl& theMesh,
527 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
528 const VISU::PGaussMeshImpl& theGaussMesh)
530 if(theGaussMesh->myIsVTKDone)
533 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGaussMesh");
534 const VISU::PAppendPolyData& anAppendFilter = theGaussMesh->GetFilter();
535 const VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
536 VISU::TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
537 for(vtkIdType aStartID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
538 VISU::PGaussSubMeshImpl aGaussSubMesh = anIter->second;
539 if(aGaussSubMesh->myStatus == VISU::eRemoveAll)
542 aGaussSubMesh->myStartID = aStartID;
544 GetGaussSubMesh(theMesh,
549 const VISU::PPolyData& aSource = aGaussSubMesh->GetSource();
550 aStartID += aSource->GetNumberOfCells();
552 anAppendFilter->AddInput(aSource.GetPointer());
554 anAppendFilter->Update(); // Fix on VTK
556 theMeshOnEntity->GetOutput()->Update();
558 vtkDataSet* aSource = anAppendFilter->GetOutput();
559 INITMSGA(MYDEBUG,0,"aNbPoints - "<<aSource->GetNumberOfPoints()<<endl);
560 BEGMSG(MYDEBUG,"aNbCells - "<<aSource->GetNumberOfCells()<<endl);
562 theGaussMesh->myIsVTKDone = true;
566 //---------------------------------------------------------------
568 PrintMemorySize(vtkUnstructuredGrid* theDataSet)
570 theDataSet->Update();
571 BEGMSG(1,"GetPoints() = "<<vtkFloatingPointType(theDataSet->GetPoints()->GetActualMemorySize()*1000)<<endl);
572 BEGMSG(1,"GetCells() = "<<vtkFloatingPointType(theDataSet->GetCells()->GetActualMemorySize()*1000)<<endl);
573 BEGMSG(1,"GetCellTypesArray() = "<<vtkFloatingPointType(theDataSet->GetCellTypesArray()->GetActualMemorySize()*1000)<<endl);
574 BEGMSG(1,"GetCellLocationsArray() = "<<vtkFloatingPointType(theDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000)<<endl);
575 theDataSet->BuildLinks();
576 BEGMSG(1,"GetCellLinks() = "<<vtkFloatingPointType(theDataSet->GetCellLinks()->GetActualMemorySize()*1000)<<endl);
577 BEGMSG(1,"GetPointData() = "<<vtkFloatingPointType(theDataSet->GetPointData()->GetActualMemorySize()*1000)<<endl);
578 BEGMSG(1,"GetCellData() = "<<vtkFloatingPointType(theDataSet->GetCellData()->GetActualMemorySize()*1000)<<endl);
579 BEGMSG(1,"GetActualMemorySize() = "<<vtkFloatingPointType(theDataSet->GetActualMemorySize()*1000)<<endl);
584 //---------------------------------------------------------------
586 ::VISU_Convertor_impl()
590 //---------------------------------------------------------------
592 ::~VISU_Convertor_impl()
596 //---------------------------------------------------------------
642 //---------------------------------------------------------------
645 ::GetMeshOnEntity(const std::string& theMeshName,
646 const VISU::TEntity& theEntity)
648 INITMSG(MYDEBUG,"GetMeshOnEntity"<<
649 "; theMeshName = '"<<theMeshName<<"'"<<
650 "; theEntity = "<<theEntity<<
653 //Cheching possibility do the query
654 TFindMeshOnEntity aFindMeshOnEntity =
655 FindMeshOnEntity(theMeshName,theEntity);
657 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
658 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
664 if(!aMeshOnEntity->myIsVTKDone){
665 VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetMeshOnEntity");
666 const VISU::PAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter();
667 if(MYVTKDEBUG) anAppendFilter->DebugOn();
669 LoadMeshOnEntity(aMesh,aMeshOnEntity);
670 anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
672 const VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
673 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
675 VISU::TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID;
676 VISU::TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr;
677 aSubMeshArr.resize(aGeom2SubMesh.size());
679 for(vtkIdType anID = 0, aCellID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){
680 VISU::EGeometry aEGeom = anIter->first;
681 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
682 VISU::PSubMeshImpl aSubMesh = anIter->second;
684 aSubMesh->CopyStructure( aMesh );
686 aSubMesh->myStartID = aCellID;
688 const VISU::PUnstructuredGrid& aSource = aSubMesh->GetSource();
689 GetCellsOnSubMesh(aSource, aMeshOnEntity, aSubMesh, aVGeom);
690 anAppendFilter->AddInput(aSource.GetPointer());
692 vtkIdType aNbCells = aSource->GetNumberOfCells();
693 for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
694 vtkIdType anObjID = aSubMesh->GetElemObjID(aCell);
695 anElemObj2VTKID[anObjID] = aCellID;
698 aSubMeshArr[anID] = aSubMesh;
701 aMeshOnEntity->CopyStructure( aMesh );
703 aMeshOnEntity->myIsVTKDone = true;
705 if(MYDEBUGWITHFILES){
706 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
707 std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
708 aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-MeshOnEntity.vtk";
709 VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
713 GetMeshOnEntitySize(theMeshName,theEntity);
714 PrintMemorySize(anAppendFilter->GetOutput());
724 return aMeshOnEntity;
728 //---------------------------------------------------------------
729 VISU::PUnstructuredGridIDMapper
731 ::GetFamilyOnEntity(const std::string& theMeshName,
732 const VISU::TEntity& theEntity,
733 const std::string& theFamilyName)
735 INITMSG(MYDEBUG,"GetFamilyOnEntity"<<
736 "; theMeshName = '"<<theMeshName<<"'"<<
737 "; theEntity = "<<theEntity<<
738 "; theFamilyName = '"<<theFamilyName<<"'"<<
741 //Cheching possibility do the query
742 TFindFamilyOnEntity aFindFamilyOnEntity =
743 FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
745 VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);;
746 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
747 VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
753 if ( !aFamily->myIsVTKDone ) {
754 GetMeshOnEntity( theMeshName, theEntity );
756 LoadFamilyOnEntity( aMesh, aMeshOnEntity, aFamily );
758 aFamily->CopyStructure( aMesh );
760 const VISU::PUnstructuredGrid& aSource = aFamily->GetSource();
761 GetCellsOnFamily( aSource, aMeshOnEntity, aFamily );
763 aFamily->myIsVTKDone = true;
765 if(MYDEBUGWITHFILES){
766 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
767 std::string aFamilyName = (const char*)QString(theFamilyName.c_str()).simplified().toLatin1();
768 std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
769 aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-FamilyOnEntity.vtk";
770 VISU::WriteToFile(aSource.GetPointer(),aFileName);
774 GetFamilyOnEntitySize(theMeshName,theEntity,theFamilyName);
775 PrintMemorySize(aSource.GetPointer());
789 //---------------------------------------------------------------
790 VISU::PUnstructuredGridIDMapper
792 ::GetMeshOnGroup(const std::string& theMeshName,
793 const std::string& theGroupName)
795 INITMSG(MYDEBUG,"GetMeshOnGroup\n");
797 "- theMeshName = '"<<theMeshName<<
798 "'; theGroupName = '"<<theGroupName<<"'"<<
801 //Cheching possibility do the query
802 TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
803 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
804 VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
810 if(!aGroup->myIsVTKDone){
811 const VISU::PAppendFilter& anAppendFilter = aGroup->GetFilter();
812 const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
814 LoadMeshOnGroup(aMesh,aFamilySet);
815 anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
817 VISU::TFamilySet::const_iterator anIter = aFamilySet.begin();
819 VISU::TID2ID& anElemObj2VTKID = aGroup->myElemObj2VTKID;
820 VISU::TFamilyArr& aFamilyArr = aGroup->myFamilyArr;
821 aFamilyArr.resize(aFamilySet.size());
823 for(vtkIdType anID = 0; anIter != aFamilySet.end(); anIter++, anID++){
824 VISU::PFamilyImpl aFamily = (*anIter).second;
825 const std::string& aFamilyName = aFamily->myName;
826 const VISU::TEntity& anEntity = aFamily->myEntity;
828 VISU::PIDMapper anIDMapper = GetFamilyOnEntity(theMeshName,anEntity,aFamilyName);
829 vtkDataSet* anOutput = anIDMapper->GetOutput();
830 anAppendFilter->AddInput(anOutput);
832 vtkIdType aStartID = anElemObj2VTKID.size();
833 vtkIdType aNbCells = anOutput->GetNumberOfCells();
834 for(vtkIdType aCellID = 0; aCellID < aNbCells; aCellID++){
835 anElemObj2VTKID[aFamily->GetElemObjID(aCellID)] = aStartID + aCellID;
837 aFamilyArr[anID] = aFamily;
840 aGroup->CopyStructure( aMesh );
842 aGroup->myIsVTKDone = true;
844 if(MYDEBUGWITHFILES){
845 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
846 std::string aGroupName = (const char*)QString(theGroupName.c_str()).simplified().toLatin1();
847 std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
848 aFileName += aMeshName + "-" + aGroupName + "-MeshOnGroup.vtk";
849 VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
862 //---------------------------------------------------------------
865 ::GetTimeStampOnProfile( const VISU::PMeshImpl& theMesh,
866 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
867 const VISU::PFieldImpl& theField,
868 const VISU::PValForTimeImpl& theValForTime,
869 const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper,
870 const VISU::PProfileImpl& theProfile,
871 const VISU::TEntity& theEntity )
873 LoadMeshOnEntity( theMesh, theMeshOnEntity );
874 GetMeshOnEntity( theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity );
875 GetMeshOnProfile( theMesh, theMeshOnEntity, theProfile );
877 theUnstructuredGridIDMapper->myIDMapper = theProfile;
879 if ( theMeshOnEntity->myEntity == VISU::NODE_ENTITY ) {
880 // add geometry elements to output,
881 // if timestamp on NODE_ENTITY and
882 // on profiles with status eAddPart
883 const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
884 VISU::TGeom2SubProfile::const_iterator aSubProfileIter = aGeom2SubProfile.begin();
885 for ( ; aSubProfileIter != aGeom2SubProfile.end(); aSubProfileIter++ ) {
886 const VISU::EGeometry& aGeom = aSubProfileIter->first;
887 const VISU::PSubProfileImpl& aSubProfile = aSubProfileIter->second;
888 if ( aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1 ) {
889 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
890 VISU::TMeshOnEntityMap::const_reverse_iterator aMeshOnEntityIter = aMeshOnEntityMap.rbegin();
891 for( ; aMeshOnEntityIter != aMeshOnEntityMap.rend(); aMeshOnEntityIter++ ) {
892 VISU::TEntity anEntity = aMeshOnEntityIter->first;
893 if ( anEntity == VISU::NODE_ENTITY )
895 VISU::PNamedIDMapper aNamedIDMapper = GetMeshOnEntity( theMesh->myName, anEntity );
896 if( aNamedIDMapper ) {
897 theUnstructuredGridIDMapper->SetReferencedMesh( aNamedIDMapper );
898 VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
899 VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
901 return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
908 VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
909 VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
911 return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
915 //---------------------------------------------------------------
916 VISU::PUnstructuredGridIDMapper
918 ::GetTimeStampOnMesh( const std::string& theMeshName,
919 const VISU::TEntity& theEntity,
920 const std::string& theFieldName,
923 INITMSG(MYDEBUG,"GetTimeStampOnMesh"<<
924 "; theMeshName = '"<<theMeshName<<"'"<<
925 "; theEntity = "<<theEntity<<
926 "; theFieldName = '"<<theFieldName<<"'"<<
927 "; theStampsNum = "<<theStampsNum<<
930 //Cheching possibility do the query
931 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
936 VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
937 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
938 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
939 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
940 VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
943 VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
947 if(!anUnstructuredGridIDMapper->myIsVTKDone){
948 VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnMesh");
949 LoadValForTimeOnMesh(aMesh, aMeshOnEntity, aField, aValForTime);
951 vtkUnstructuredGrid* anOutput = NULL;
953 anOutput = GetTimeStampOnProfile(aMesh,
957 anUnstructuredGridIDMapper,
958 aValForTime->myProfile,
959 aMeshOnEntity->myEntity);
960 }catch(std::exception& exc){
961 MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
962 anOutput = GetTimeStampOnProfile(aMesh,
966 anUnstructuredGridIDMapper,
967 aValForTime->myProfile,
968 aVTKMeshOnEntity->myEntity);
971 anUnstructuredGridIDMapper->CopyStructure( aMesh );
973 anUnstructuredGridIDMapper->myIsVTKDone = true;
975 if(MYDEBUGWITHFILES){
976 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
977 std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1();
978 std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
979 std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
980 aFieldName + dtos("-%d", theStampsNum) + "-TimeStampOnMesh.vtk";
981 VISU::WriteToFile(anOutput,aFileName);
984 GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
986 if(theEntity == VISU::NODE_ENTITY)
987 BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
989 BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
990 BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
994 }catch(std::exception& exc){
1001 return anUnstructuredGridIDMapper;
1005 //---------------------------------------------------------------
1006 VISU::PGaussPtsIDMapper
1008 ::GetTimeStampOnGaussPts(const std::string& theMeshName,
1009 const VISU::TEntity& theEntity,
1010 const std::string& theFieldName,
1013 INITMSG(MYDEBUG,"GetTimeStampOnGaussPts"<<
1014 "; theMeshName = '"<<theMeshName<<"'"<<
1015 "; theEntity = "<<theEntity<<
1016 "; theFieldName = '"<<theFieldName<<"'"<<
1017 "; theStampsNum = "<<theStampsNum<<
1020 if(theEntity == VISU::NODE_ENTITY)
1021 EXCEPTION(std::runtime_error, "It is impossible to reate Gauss Points on NODE_ENTITY !!!");
1023 //Cheching possibility do the query
1024 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1029 VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
1030 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
1031 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
1032 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1033 VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
1036 VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
1040 if(!aGaussPtsIDFilter->myIsVTKDone){
1041 VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnGaussPts");
1042 LoadValForTimeOnGaussPts(aMesh, aMeshOnEntity, aField, aValForTime);
1044 GetMeshOnEntity(aVTKMeshOnEntity->myMeshName, aVTKMeshOnEntity->myEntity);
1046 VISU::PProfileImpl aProfile = aValForTime->myProfile;
1047 GetMeshOnProfile(aMesh, aVTKMeshOnEntity, aProfile, false);
1049 VISU::PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh;
1050 if(!aGaussMesh->myIsVTKDone){
1051 BuildGaussMesh(aMesh, aVTKMeshOnEntity, aGaussMesh);
1052 aGaussMesh->myParent = aProfile.get();
1053 aGaussMesh->myIsVTKDone = true;
1056 aGaussPtsIDFilter->myIDMapper = aGaussMesh;
1057 aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh;
1058 VISU::PPolyData aSource = aGaussPtsIDFilter->GetSource();
1059 VISU::GetTimeStampOnGaussMesh(aSource, aField, aValForTime);
1060 vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput();
1062 aGaussPtsIDFilter->myIsVTKDone = true;
1064 if(MYDEBUGWITHFILES){
1065 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
1066 std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1();
1067 std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
1068 std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
1069 aFieldName + dtos("-%d",theStampsNum) + "-TimeStampOnGaussPts.vtk";
1070 VISU::WriteToFile(anOutput, aFileName);
1073 GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
1075 if(theEntity == VISU::NODE_ENTITY)
1076 BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
1078 BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
1079 BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
1083 }catch(std::exception& exc){
1090 return aGaussPtsIDFilter;
1093 //---------------------------------------------------------------
1096 ::FindMesh(const std::string& theMeshName)
1099 VISU::TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName);
1100 if(aMeshMapIter == myMeshMap.end())
1101 EXCEPTION(std::runtime_error,"FindMesh >> There is no mesh with the name - '"<<theMeshName<<"'!!!");
1103 VISU::PMeshImpl aMesh = aMeshMapIter->second;
1108 //---------------------------------------------------------------
1109 VISU_Convertor_impl::TFindMeshOnEntity
1111 ::FindMeshOnEntity(const std::string& theMeshName,
1112 const VISU::TEntity& theEntity)
1114 VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1115 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1116 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
1117 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1118 EXCEPTION(std::runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
1120 VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
1122 return TFindMeshOnEntity(aMesh,
1127 //---------------------------------------------------------------
1128 VISU_Convertor_impl::TFindFamilyOnEntity
1130 ::FindFamilyOnEntity(const std::string& theMeshName,
1131 const VISU::TEntity& theEntity,
1132 const std::string& theFamilyName)
1134 if(theFamilyName != ""){
1135 VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1136 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1137 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
1138 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1139 EXCEPTION(std::runtime_error,"FindFamilyOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
1141 VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
1143 VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1144 VISU::TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName);
1145 if(aFamilyMapIter != aFamilyMap.end()){
1146 const VISU::PFamily& aFamily = aFamilyMapIter->second;
1147 return TFindFamilyOnEntity(aMesh,
1152 return TFindFamilyOnEntity();
1156 //---------------------------------------------------------------
1162 const VISU::TMeshMap& aMeshMap = GetMeshMap();
1163 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
1164 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
1165 const std::string& aMeshName = aMeshMapIter->first;
1166 const VISU::PMesh aMesh = aMeshMapIter->second;
1167 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1168 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
1170 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
1171 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
1172 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
1173 const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
1174 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1175 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
1176 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
1177 const std::string& aFieldName = aFieldMapIter->first;
1178 const VISU::PField aField = aFieldMapIter->second;
1179 const VISU::TValField& aValField = aField->myValField;
1180 VISU::TValField::const_iterator aValFieldIter = aValField.begin();
1181 for(; aValFieldIter != aValField.end(); aValFieldIter++){
1182 int aTimeStamp = aValFieldIter->first;
1183 aResult += GetTimeStampSize(aMeshName,anEntity,aFieldName,aTimeStamp);
1187 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1188 VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
1189 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
1190 const std::string& aGroupName = aGroupMapIter->first;
1191 aResult += GetMeshOnGroupSize(aMeshName,aGroupName);
1194 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1195 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
1196 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
1197 const std::string& aFamilyName = aFamilyMapIter->first;
1198 aResult += GetFamilyOnEntitySize(aMeshName,anEntity,aFamilyName);
1200 //Import mesh on entity
1201 aResult += GetMeshOnEntitySize(aMeshName,anEntity);
1204 MSG(MYDEBUG,"GetSize - aResult = "<<vtkFloatingPointType(aResult));
1209 //---------------------------------------------------------------
1212 ::GetMeshOnEntitySize(const std::string& theMeshName,
1213 const VISU::TEntity& theEntity)
1215 TFindMeshOnEntity aFindMeshOnEntity =
1216 FindMeshOnEntity(theMeshName, theEntity);
1218 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
1219 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1221 size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1222 size_t aNbCells = aMeshOnEntity->myNbCells;
1223 size_t aCellsSize = aMeshOnEntity->myCellsSize;
1225 size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
1226 size_t aTypesSize = aNbCells*sizeof(char);
1227 size_t aLocationsSize = aNbCells*sizeof(int);
1228 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1229 size_t aLinksSize = aMesh->GetNbPoints() *
1230 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
1232 size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
1234 MSG(MYDEBUG,"GetMeshOnEntitySize "<<
1235 "- aResult = "<<vtkFloatingPointType(aResult)<<
1236 "; theMeshName = '"<<theMeshName<<"'"<<
1237 "; theEntity = "<<theEntity);
1239 INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
1240 BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
1241 BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
1242 BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
1243 BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
1246 aResult = size_t(aResult*ERR_SIZE_CALC);
1251 //---------------------------------------------------------------
1254 ::GetFamilyOnEntitySize(const std::string& theMeshName,
1255 const VISU::TEntity& theEntity,
1256 const std::string& theFamilyName)
1258 TFindFamilyOnEntity aFindFamilyOnEntity =
1259 FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
1260 VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);
1261 VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
1262 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
1264 size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1265 size_t aNbCells = aFamily->myNbCells;
1266 size_t aCellsSize = aFamily->myCellsSize;
1268 size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
1269 size_t aTypesSize = aNbCells*sizeof(char);
1270 size_t aLocationsSize = aNbCells*sizeof(int);
1271 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1272 size_t aLinksSize = aMesh->GetNbPoints() *
1273 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
1275 size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
1277 MSG(MYDEBUG,"GetFamilyOnEntitySize "<<
1278 "- aResult = "<<vtkFloatingPointType(aResult)<<
1279 "; theMeshName = '"<<theMeshName<<"'"<<
1280 "; theEntity = "<<theEntity<<
1281 "; theFamilyName = '"<<theFamilyName<<"'");
1283 INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
1284 BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
1285 BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
1286 BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
1287 BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
1290 aResult = size_t(aResult*ERR_SIZE_CALC);
1295 //---------------------------------------------------------------
1296 VISU_Convertor_impl::TFindMeshOnGroup
1298 ::FindMeshOnGroup(const std::string& theMeshName,
1299 const std::string& theGroupName)
1301 VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1302 VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1303 VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName);
1304 if(aGroupMapIter == aGroupMap.end())
1305 EXCEPTION(std::runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<<theGroupName<<"'");
1307 VISU::PGroupImpl aGroup = aGroupMapIter->second;
1308 return TFindMeshOnGroup(aMesh,aGroup);
1314 ::GetMeshOnGroupSize(const std::string& theMeshName,
1315 const std::string& theGroupName)
1317 TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
1318 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
1319 VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
1321 size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1322 VISU::TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells();
1323 size_t aNbCells = aNbASizeCells.first;
1324 size_t aCellsSize = aNbASizeCells.second;
1325 size_t aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
1326 size_t aLocationsSize = aNbCells*sizeof(int);
1327 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1328 size_t aLinksSize = aMesh->GetNbPoints() *
1329 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
1331 size_t aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
1333 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aPointsSize = "<<vtkFloatingPointType(aPointsSize));
1334 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<vtkFloatingPointType(aConnectivityAndTypesSize));
1335 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLocationsSize = "<<vtkFloatingPointType(aLocationsSize));
1336 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLinksSize = "<<vtkFloatingPointType(aLinksSize));
1338 MSG(MYDEBUG,"GetMeshOnGroupSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"
1339 <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
1341 aResult = size_t(aResult*ERR_SIZE_CALC);
1346 VISU_Convertor_impl::TFindField
1348 ::FindField(const std::string& theMeshName,
1349 const VISU::TEntity& theEntity,
1350 const std::string& theFieldName)
1352 TFindMeshOnEntity aFindMeshOnEntity =
1353 FindMeshOnEntity(theMeshName,theEntity);
1355 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
1356 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1358 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1359 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
1360 if ( theEntity == VISU::NODE_ENTITY ) {
1361 if(aMeshOnEntityMap.find( VISU::CELL_ENTITY ) != aMeshOnEntityMap.end())
1362 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::CELL_ENTITY ];
1363 else if (aMeshOnEntityMap.find( VISU::FACE_ENTITY ) != aMeshOnEntityMap.end() )
1364 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::FACE_ENTITY ];
1365 else if (aMeshOnEntityMap.find( VISU::EDGE_ENTITY ) != aMeshOnEntityMap.end() )
1366 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::EDGE_ENTITY ];
1367 else if ( aMeshOnEntityMap.find( VISU::NODE_ENTITY ) != aMeshOnEntityMap.end() )
1368 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::NODE_ENTITY ];
1370 aVTKMeshOnEntity = aMeshOnEntity;
1372 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1373 VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find( theFieldName );
1374 if(aFieldIter == aFieldMap.end())
1375 EXCEPTION(std::runtime_error,"FindField >> There is no field on the mesh!!!");
1377 VISU::PFieldImpl aField = aFieldIter->second;
1379 return TFindField( aMesh,
1388 ::GetFieldOnMeshSize(const std::string& theMeshName,
1389 const VISU::TEntity& theEntity,
1390 const std::string& theFieldName)
1392 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1393 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
1394 VISU::PFieldImpl aField = boost::get<3>(aFindField);
1396 size_t aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
1397 size_t aFieldOnMeshSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType)*aField->myValField.size()*ERR_SIZE_CALC);
1398 size_t aResult = aMeshSize + aFieldOnMeshSize;
1400 MSG(MYVTKDEBUG,"GetFieldOnMeshSize - aFieldOnMeshSize = "<<vtkFloatingPointType(aFieldOnMeshSize));
1401 MSG(MYDEBUG,"GetFieldOnMeshSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"<<theMeshName<<
1402 "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
1408 VISU_Convertor_impl::TFindTimeStamp
1410 ::FindTimeStamp(const std::string& theMeshName,
1411 const VISU::TEntity& theEntity,
1412 const std::string& theFieldName,
1415 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1416 VISU::PField aField = boost::get<3>(aFindField);
1418 VISU::TValField& aValField = aField->myValField;
1419 VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum);
1420 if(aValFieldIter == aValField.end())
1421 EXCEPTION(std::runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!");
1423 VISU::PMeshImpl aMesh = boost::get<0>(aFindField);
1424 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField);
1425 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
1426 VISU::PValForTimeImpl aValForTime = aValFieldIter->second;
1428 return TFindTimeStamp(aMesh,
1438 ::GetTimeStampSize(const std::string& theMeshName,
1439 const VISU::TEntity& theEntity,
1440 const std::string& theFieldName,
1443 TFindTimeStamp aFindTimeStamp =
1444 FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
1445 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
1446 VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
1448 size_t aMeshSize = GetMeshOnEntitySize(theMeshName, aVTKMeshOnEntity->myEntity);
1449 size_t aTimeStampSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType) * ERR_SIZE_CALC);
1450 size_t aResult = aMeshSize + aTimeStampSize;
1452 MSG(MYDEBUG && MYVTKDEBUG,"GetTimeStampSize - aTimeStampSize = "<<vtkFloatingPointType(aTimeStampSize));
1453 MSG(MYDEBUG,"GetTimeStampSize - aResult = "<<vtkFloatingPointType(aResult)<<
1454 "; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
1455 "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
1463 ::GetTimeStampOnMeshSize(const std::string& theMeshName,
1464 const VISU::TEntity& theEntity,
1465 const std::string& theFieldName,
1466 int theTimeStampNumber,
1467 bool& theIsEstimated)
1471 //Cheching possibility do the query
1472 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1475 theTimeStampNumber);
1477 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1478 VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
1479 if(anUnstructuredGridIDMapper->myIsVTKDone){
1480 VISU::PIDMapper anIDMapper = GetTimeStampOnMesh(theMeshName,
1483 theTimeStampNumber);
1484 anIDMapper->GetOutput();
1485 aSize += anIDMapper->GetMemorySize();
1487 aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
1489 theIsEstimated = !(anUnstructuredGridIDMapper->myIsVTKDone);
1491 //cout<<"VISU_Convertor_impl::GetTimeStampOnMeshSize - "<<aSize<<"; "<<(anIDMapperFilter->myIsVTKDone)<<endl;
1498 ::GetTimeStampOnGaussPtsSize(const std::string& theMeshName,
1499 const VISU::TEntity& theEntity,
1500 const std::string& theFieldName,
1501 int theTimeStampNumber,
1502 bool& theIsEstimated)
1506 //Cheching possibility do the query
1507 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1510 theTimeStampNumber);
1512 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1513 VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
1514 if(aGaussPtsIDFilter->myIsVTKDone){
1515 VISU::PGaussPtsIDMapper aGaussPtsIDMapper = GetTimeStampOnGaussPts(theMeshName,
1518 theTimeStampNumber);
1519 aGaussPtsIDMapper->GetOutput();
1520 aSize += aGaussPtsIDMapper->GetMemorySize();
1522 aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
1524 theIsEstimated = !(aGaussPtsIDFilter->myIsVTKDone);
1526 //cout<<"VISU_Convertor_impl::GetTimeStampOnGaussPtsSize - "<<aSize<<"; "<<(aGaussPtsIDFilter->myIsVTKDone)<<endl;
1533 ::GetField(const std::string& theMeshName,
1534 VISU::TEntity theEntity,
1535 const std::string& theFieldName)
1537 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1538 VISU::PField aField = boost::get<3>(aFindField);
1543 const VISU::PValForTime
1545 ::GetTimeStamp(const std::string& theMeshName,
1546 const VISU::TEntity& theEntity,
1547 const std::string& theFieldName,
1550 TFindTimeStamp aFindTimeStamp =
1551 FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
1552 VISU::PValForTime aValForTime = boost::get<4>(aFindTimeStamp);