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
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)
336 INITMSG(MYDEBUG,"GetMeshOnSubProfile - aEGeom = "<<theSubProfile->myGeom<<endl);
338 const VISU::PUnstructuredGrid& aSource = theSubProfile->GetSource();
339 if(theSubProfile->myIsVTKDone)
342 aSource->ShallowCopy(theMesh->GetPointSet());
343 INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
344 GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
345 BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
347 theSubProfile->myIsVTKDone = true;
351 //---------------------------------------------------------------
353 GetMeshOnProfile(const VISU::PMeshImpl& theMesh,
354 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
355 const VISU::PProfileImpl& theProfile)
357 //rnv fix for bug IPAL18514 4x (CRASH after trying to build of presentation):
358 // throw exection in case if pointer on profile =0
359 if(!theProfile.get())
360 EXCEPTION(std::runtime_error,"GetMeshOnProfile: theProfile.get() == NULL");
362 // rnv fix for issue 19999:
363 // Throw exception in case if mesh on entity from profile is not equal
364 // input mesh on entity. This exception catch in tne VISU_Convertor_impl::GetTimeStampOnMesh
366 if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
367 EXCEPTION(std::runtime_error,"GetMeshOnProfile >> theProfile->myMeshOnEntity != theMeshOnEntity.get()");
369 if(theProfile->myIsVTKDone)
372 // if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
375 VISU::TTimerLog aTimerLog(MYDEBUG,"GetMeshOnProfile");
376 INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<std::endl);
378 const VISU::PAppendFilter& anAppendFilter = theProfile->GetFilter();
379 anAppendFilter->SetSharedPointSet(theMesh->GetPointSet());
381 if(theProfile->myIsAll){
382 vtkUnstructuredGrid* aDataSet = theMeshOnEntity->GetUnstructuredGridOutput();
383 anAppendFilter->AddInput(aDataSet);
385 const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
387 VISU::TID2ID& anElemObj2VTKID = theProfile->myElemObj2VTKID;
389 VISU::TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr;
390 aSubProfileArr.resize(aGeom2SubProfile.size());
392 VISU::TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
393 for(vtkIdType anInputID = 0, aCellID = 0; anIter != aGeom2SubProfile.end(); anIter++){
394 VISU::PSubProfileImpl aSubProfile = anIter->second;
395 if(aSubProfile->myStatus == VISU::eRemoveAll)
398 GetMeshOnSubProfile(theMesh,
403 const VISU::PUnstructuredGrid& aSource = aSubProfile->GetSource();
404 anAppendFilter->AddInput(aSource.GetPointer());
406 vtkIdType aNbCells = aSource->GetNumberOfCells();
407 for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
408 vtkIdType anObjID = aSubProfile->GetElemObjID(aCell);
409 anElemObj2VTKID[anObjID] = aCellID;
412 aSubProfileArr[anInputID++] = aSubProfile;
415 anAppendFilter->Update(); // Fix on VTK
416 theProfile->myMeshOnEntity = theMeshOnEntity.get();
417 theProfile->myNamedPointCoords = theMesh->myNamedPointCoords;
419 theProfile->myIsVTKDone = true;
424 //---------------------------------------------------------------
426 GetGaussSubMeshSource(const VISU::PPolyData& theSource,
427 const VISU::PGaussSubMeshImpl& theGaussSubMesh,
428 const VISU::PMeshOnEntityImpl& theMeshOnEntity)
430 vtkCellArray* aConnectivity = vtkCellArray::New();
431 vtkIdType aCellsSize = theGaussSubMesh->myCellsSize;
432 aConnectivity->Allocate(aCellsSize, 0);
434 vtkIdList *anIdList = vtkIdList::New();
435 anIdList->SetNumberOfIds(1);
437 const VISU::TPointCoords& aCoords = theGaussSubMesh->myPointCoords;
438 vtkIdType aNbPoints = aCoords.GetNbPoints();
439 for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
440 anIdList->SetId(0, aPointId);
441 aConnectivity->InsertNextCell(anIdList);
445 const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
446 aSource->ShallowCopy(aCoords.GetPointSet());
447 aSource->SetVerts(aConnectivity);
449 aConnectivity->Delete();
452 vtkIdType aNbTuples = aNbPoints;
453 vtkIntArray *aDataArray = vtkIntArray::New();
454 aDataArray->SetName("VISU_POINTS_MAPPER");
455 aDataArray->SetNumberOfComponents(2);
456 aDataArray->SetNumberOfTuples(aNbTuples);
457 int *aDataArrayPtr = aDataArray->GetPointer(0);
458 for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
459 vtkIdType aGlobalID = theGaussSubMesh->GetGlobalID(aTupleId);
460 *aDataArrayPtr++ = aGlobalID;
461 *aDataArrayPtr++ = 0;
463 aSource->GetPointData()->AddArray(aDataArray);
464 aDataArray->Delete();
468 vtkIdType aNbTuples = aNbPoints;
469 vtkIntArray *aDataArray = vtkIntArray::New();
470 aDataArray->SetName("VISU_CELLS_MAPPER");
471 aDataArray->SetNumberOfComponents(2);
472 aDataArray->SetNumberOfTuples(aNbTuples);
473 int *aDataArrayPtr = aDataArray->GetPointer(0);
474 for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
475 VISU::TGaussPointID aGaussPointID = theGaussSubMesh->GetObjID(aTupleId);
476 *aDataArrayPtr++ = aGaussPointID.first;
477 *aDataArrayPtr++ = aGaussPointID.second;
479 aSource->GetCellData()->AddArray(aDataArray);
480 aDataArray->Delete();
485 //---------------------------------------------------------------
487 GetGaussSubMesh(const VISU::PMeshImpl& theMesh,
488 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
489 const VISU::PGaussMeshImpl& theGaussMesh,
490 const VISU::PGaussSubMeshImpl& theGaussSubMesh)
492 VISU::PGaussImpl aGauss = theGaussSubMesh->myGauss;
494 if(!theGaussSubMesh->myIsDone)
497 if(theGaussSubMesh->myIsVTKDone)
500 VISU::TTimerLog aTimerLog(MYDEBUG,"GetGaussSubMesh");
501 INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<<aGauss->myGeom<<endl);
503 const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
504 GetGaussSubMeshSource(aSource, theGaussSubMesh, theMeshOnEntity);
506 INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
507 BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
509 theGaussSubMesh->myIsVTKDone = true;
513 //---------------------------------------------------------------
515 BuildGaussMesh(const VISU::PMeshImpl& theMesh,
516 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
517 const VISU::PGaussMeshImpl& theGaussMesh)
519 if(theGaussMesh->myIsVTKDone)
522 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGaussMesh");
523 const VISU::PAppendPolyData& anAppendFilter = theGaussMesh->GetFilter();
524 const VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
525 VISU::TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
526 for(vtkIdType aStartID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
527 VISU::PGaussSubMeshImpl aGaussSubMesh = anIter->second;
528 if(aGaussSubMesh->myStatus == VISU::eRemoveAll)
531 aGaussSubMesh->myStartID = aStartID;
533 GetGaussSubMesh(theMesh,
538 const VISU::PPolyData& aSource = aGaussSubMesh->GetSource();
539 aStartID += aSource->GetNumberOfCells();
541 anAppendFilter->AddInput(aSource.GetPointer());
543 anAppendFilter->Update(); // Fix on VTK
545 theMeshOnEntity->GetOutput()->Update();
547 vtkDataSet* aSource = anAppendFilter->GetOutput();
548 INITMSGA(MYDEBUG,0,"aNbPoints - "<<aSource->GetNumberOfPoints()<<endl);
549 BEGMSG(MYDEBUG,"aNbCells - "<<aSource->GetNumberOfCells()<<endl);
551 theGaussMesh->myIsVTKDone = true;
555 //---------------------------------------------------------------
557 PrintMemorySize(vtkUnstructuredGrid* theDataSet)
559 theDataSet->Update();
560 BEGMSG(1,"GetPoints() = "<<vtkFloatingPointType(theDataSet->GetPoints()->GetActualMemorySize()*1000)<<endl);
561 BEGMSG(1,"GetCells() = "<<vtkFloatingPointType(theDataSet->GetCells()->GetActualMemorySize()*1000)<<endl);
562 BEGMSG(1,"GetCellTypesArray() = "<<vtkFloatingPointType(theDataSet->GetCellTypesArray()->GetActualMemorySize()*1000)<<endl);
563 BEGMSG(1,"GetCellLocationsArray() = "<<vtkFloatingPointType(theDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000)<<endl);
564 theDataSet->BuildLinks();
565 BEGMSG(1,"GetCellLinks() = "<<vtkFloatingPointType(theDataSet->GetCellLinks()->GetActualMemorySize()*1000)<<endl);
566 BEGMSG(1,"GetPointData() = "<<vtkFloatingPointType(theDataSet->GetPointData()->GetActualMemorySize()*1000)<<endl);
567 BEGMSG(1,"GetCellData() = "<<vtkFloatingPointType(theDataSet->GetCellData()->GetActualMemorySize()*1000)<<endl);
568 BEGMSG(1,"GetActualMemorySize() = "<<vtkFloatingPointType(theDataSet->GetActualMemorySize()*1000)<<endl);
573 //---------------------------------------------------------------
575 ::VISU_Convertor_impl()
579 //---------------------------------------------------------------
581 ::~VISU_Convertor_impl()
585 //---------------------------------------------------------------
631 //---------------------------------------------------------------
634 ::GetMeshOnEntity(const std::string& theMeshName,
635 const VISU::TEntity& theEntity)
637 INITMSG(MYDEBUG,"GetMeshOnEntity"<<
638 "; theMeshName = '"<<theMeshName<<"'"<<
639 "; theEntity = "<<theEntity<<
642 //Cheching possibility do the query
643 TFindMeshOnEntity aFindMeshOnEntity =
644 FindMeshOnEntity(theMeshName,theEntity);
646 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
647 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
653 if(!aMeshOnEntity->myIsVTKDone){
654 VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetMeshOnEntity");
655 const VISU::PAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter();
656 if(MYVTKDEBUG) anAppendFilter->DebugOn();
658 LoadMeshOnEntity(aMesh,aMeshOnEntity);
659 anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
661 const VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
662 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
664 VISU::TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID;
665 VISU::TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr;
666 aSubMeshArr.resize(aGeom2SubMesh.size());
668 for(vtkIdType anID = 0, aCellID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){
669 VISU::EGeometry aEGeom = anIter->first;
670 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
671 VISU::PSubMeshImpl aSubMesh = anIter->second;
673 aSubMesh->CopyStructure( aMesh );
675 aSubMesh->myStartID = aCellID;
677 const VISU::PUnstructuredGrid& aSource = aSubMesh->GetSource();
678 GetCellsOnSubMesh(aSource, aMeshOnEntity, aSubMesh, aVGeom);
679 anAppendFilter->AddInput(aSource.GetPointer());
681 vtkIdType aNbCells = aSource->GetNumberOfCells();
682 for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
683 vtkIdType anObjID = aSubMesh->GetElemObjID(aCell);
684 anElemObj2VTKID[anObjID] = aCellID;
687 aSubMeshArr[anID] = aSubMesh;
690 aMeshOnEntity->CopyStructure( aMesh );
692 aMeshOnEntity->myIsVTKDone = true;
694 if(MYDEBUGWITHFILES){
695 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
696 std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
697 aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-MeshOnEntity.vtk";
698 VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
702 GetMeshOnEntitySize(theMeshName,theEntity);
703 PrintMemorySize(anAppendFilter->GetOutput());
713 return aMeshOnEntity;
717 //---------------------------------------------------------------
718 VISU::PUnstructuredGridIDMapper
720 ::GetFamilyOnEntity(const std::string& theMeshName,
721 const VISU::TEntity& theEntity,
722 const std::string& theFamilyName)
724 INITMSG(MYDEBUG,"GetFamilyOnEntity"<<
725 "; theMeshName = '"<<theMeshName<<"'"<<
726 "; theEntity = "<<theEntity<<
727 "; theFamilyName = '"<<theFamilyName<<"'"<<
730 //Cheching possibility do the query
731 TFindFamilyOnEntity aFindFamilyOnEntity =
732 FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
734 VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);;
735 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
736 VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
742 if ( !aFamily->myIsVTKDone ) {
743 GetMeshOnEntity( theMeshName, theEntity );
745 LoadFamilyOnEntity( aMesh, aMeshOnEntity, aFamily );
747 aFamily->CopyStructure( aMesh );
749 const VISU::PUnstructuredGrid& aSource = aFamily->GetSource();
750 GetCellsOnFamily( aSource, aMeshOnEntity, aFamily );
752 aFamily->myIsVTKDone = true;
754 if(MYDEBUGWITHFILES){
755 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
756 std::string aFamilyName = (const char*)QString(theFamilyName.c_str()).simplified().toLatin1();
757 std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
758 aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-FamilyOnEntity.vtk";
759 VISU::WriteToFile(aSource.GetPointer(),aFileName);
763 GetFamilyOnEntitySize(theMeshName,theEntity,theFamilyName);
764 PrintMemorySize(aSource.GetPointer());
778 //---------------------------------------------------------------
779 VISU::PUnstructuredGridIDMapper
781 ::GetMeshOnGroup(const std::string& theMeshName,
782 const std::string& theGroupName)
784 INITMSG(MYDEBUG,"GetMeshOnGroup\n");
786 "- theMeshName = '"<<theMeshName<<
787 "'; theGroupName = '"<<theGroupName<<"'"<<
790 //Cheching possibility do the query
791 TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
792 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
793 VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
799 if(!aGroup->myIsVTKDone){
800 const VISU::PAppendFilter& anAppendFilter = aGroup->GetFilter();
801 const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
803 LoadMeshOnGroup(aMesh,aFamilySet);
804 anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
806 VISU::TFamilySet::const_iterator anIter = aFamilySet.begin();
808 VISU::TID2ID& anElemObj2VTKID = aGroup->myElemObj2VTKID;
809 VISU::TFamilyArr& aFamilyArr = aGroup->myFamilyArr;
810 aFamilyArr.resize(aFamilySet.size());
812 for(vtkIdType anID = 0; anIter != aFamilySet.end(); anIter++, anID++){
813 VISU::PFamilyImpl aFamily = (*anIter).second;
814 const std::string& aFamilyName = aFamily->myName;
815 const VISU::TEntity& anEntity = aFamily->myEntity;
817 VISU::PIDMapper anIDMapper = GetFamilyOnEntity(theMeshName,anEntity,aFamilyName);
818 vtkDataSet* anOutput = anIDMapper->GetOutput();
819 anAppendFilter->AddInput(anOutput);
821 vtkIdType aStartID = anElemObj2VTKID.size();
822 vtkIdType aNbCells = anOutput->GetNumberOfCells();
823 for(vtkIdType aCellID = 0; aCellID < aNbCells; aCellID++){
824 anElemObj2VTKID[aFamily->GetElemObjID(aCellID)] = aStartID + aCellID;
826 aFamilyArr[anID] = aFamily;
829 aGroup->CopyStructure( aMesh );
831 aGroup->myIsVTKDone = true;
833 if(MYDEBUGWITHFILES){
834 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
835 std::string aGroupName = (const char*)QString(theGroupName.c_str()).simplified().toLatin1();
836 std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
837 aFileName += aMeshName + "-" + aGroupName + "-MeshOnGroup.vtk";
838 VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
851 //---------------------------------------------------------------
854 ::GetTimeStampOnProfile( const VISU::PMeshImpl& theMesh,
855 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
856 const VISU::PFieldImpl& theField,
857 const VISU::PValForTimeImpl& theValForTime,
858 const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper,
859 const VISU::PProfileImpl& theProfile,
860 const VISU::TEntity& theEntity )
862 LoadMeshOnEntity( theMesh, theMeshOnEntity );
863 GetMeshOnEntity( theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity );
864 GetMeshOnProfile( theMesh, theMeshOnEntity, theProfile );
866 theUnstructuredGridIDMapper->myIDMapper = theProfile;
868 if ( theMeshOnEntity->myEntity == VISU::NODE_ENTITY ) {
869 // add geometry elements to output,
870 // if timestamp on NODE_ENTITY and
871 // on profiles with status eAddPart
872 const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
873 VISU::TGeom2SubProfile::const_iterator aSubProfileIter = aGeom2SubProfile.begin();
874 for ( ; aSubProfileIter != aGeom2SubProfile.end(); aSubProfileIter++ ) {
875 const VISU::EGeometry& aGeom = aSubProfileIter->first;
876 const VISU::PSubProfileImpl& aSubProfile = aSubProfileIter->second;
877 if ( aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1 ) {
878 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
879 VISU::TMeshOnEntityMap::const_reverse_iterator aMeshOnEntityIter = aMeshOnEntityMap.rbegin();
880 for( ; aMeshOnEntityIter != aMeshOnEntityMap.rend(); aMeshOnEntityIter++ ) {
881 VISU::TEntity anEntity = aMeshOnEntityIter->first;
882 if ( anEntity == VISU::NODE_ENTITY )
884 VISU::PNamedIDMapper aNamedIDMapper = GetMeshOnEntity( theMesh->myName, anEntity );
885 if( aNamedIDMapper ) {
886 theUnstructuredGridIDMapper->SetReferencedMesh( aNamedIDMapper );
887 VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
888 VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
890 return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
897 VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
898 VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
900 return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
904 //---------------------------------------------------------------
905 VISU::PUnstructuredGridIDMapper
907 ::GetTimeStampOnMesh( const std::string& theMeshName,
908 const VISU::TEntity& theEntity,
909 const std::string& theFieldName,
912 INITMSG(MYDEBUG,"GetTimeStampOnMesh"<<
913 "; theMeshName = '"<<theMeshName<<"'"<<
914 "; theEntity = "<<theEntity<<
915 "; theFieldName = '"<<theFieldName<<"'"<<
916 "; theStampsNum = "<<theStampsNum<<
919 //Cheching possibility do the query
920 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
925 VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
926 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
927 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
928 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
929 VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
932 VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
936 if(!anUnstructuredGridIDMapper->myIsVTKDone){
937 VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnMesh");
938 LoadValForTimeOnMesh(aMesh, aMeshOnEntity, aField, aValForTime);
940 vtkUnstructuredGrid* anOutput = NULL;
942 anOutput = GetTimeStampOnProfile(aMesh,
946 anUnstructuredGridIDMapper,
947 aValForTime->myProfile,
948 aMeshOnEntity->myEntity);
949 }catch(std::exception& exc){
950 MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
951 anOutput = GetTimeStampOnProfile(aMesh,
955 anUnstructuredGridIDMapper,
956 aValForTime->myProfile,
957 aVTKMeshOnEntity->myEntity);
960 anUnstructuredGridIDMapper->CopyStructure( aMesh );
962 anUnstructuredGridIDMapper->myIsVTKDone = true;
964 if(MYDEBUGWITHFILES){
965 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
966 std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1();
967 std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
968 std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
969 aFieldName + dtos("-%d", theStampsNum) + "-TimeStampOnMesh.vtk";
970 VISU::WriteToFile(anOutput,aFileName);
973 GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
975 if(theEntity == VISU::NODE_ENTITY)
976 BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
978 BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
979 BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
983 }catch(std::exception& exc){
990 return anUnstructuredGridIDMapper;
994 //---------------------------------------------------------------
995 VISU::PGaussPtsIDMapper
997 ::GetTimeStampOnGaussPts(const std::string& theMeshName,
998 const VISU::TEntity& theEntity,
999 const std::string& theFieldName,
1002 INITMSG(MYDEBUG,"GetTimeStampOnGaussPts"<<
1003 "; theMeshName = '"<<theMeshName<<"'"<<
1004 "; theEntity = "<<theEntity<<
1005 "; theFieldName = '"<<theFieldName<<"'"<<
1006 "; theStampsNum = "<<theStampsNum<<
1009 if(theEntity == VISU::NODE_ENTITY)
1010 EXCEPTION(std::runtime_error, "It is impossible to reate Gauss Points on NODE_ENTITY !!!");
1012 //Cheching possibility do the query
1013 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1018 VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
1019 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
1020 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
1021 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1022 VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
1025 VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
1029 if(!aGaussPtsIDFilter->myIsVTKDone){
1030 VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnGaussPts");
1031 LoadValForTimeOnGaussPts(aMesh, aMeshOnEntity, aField, aValForTime);
1033 GetMeshOnEntity(aVTKMeshOnEntity->myMeshName, aVTKMeshOnEntity->myEntity);
1035 VISU::PProfileImpl aProfile = aValForTime->myProfile;
1036 GetMeshOnProfile(aMesh, aVTKMeshOnEntity, aProfile);
1038 VISU::PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh;
1039 if(!aGaussMesh->myIsVTKDone){
1040 BuildGaussMesh(aMesh, aVTKMeshOnEntity, aGaussMesh);
1041 aGaussMesh->myParent = aProfile.get();
1042 aGaussMesh->myIsVTKDone = true;
1045 aGaussPtsIDFilter->myIDMapper = aGaussMesh;
1046 aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh;
1047 VISU::PPolyData aSource = aGaussPtsIDFilter->GetSource();
1048 VISU::GetTimeStampOnGaussMesh(aSource, aField, aValForTime);
1049 vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput();
1051 aGaussPtsIDFilter->myIsVTKDone = true;
1053 if(MYDEBUGWITHFILES){
1054 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
1055 std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1();
1056 std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
1057 std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
1058 aFieldName + dtos("-%d",theStampsNum) + "-TimeStampOnGaussPts.vtk";
1059 VISU::WriteToFile(anOutput, aFileName);
1062 GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
1064 if(theEntity == VISU::NODE_ENTITY)
1065 BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
1067 BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
1068 BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
1072 }catch(std::exception& exc){
1079 return aGaussPtsIDFilter;
1082 //---------------------------------------------------------------
1085 ::FindMesh(const std::string& theMeshName)
1088 VISU::TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName);
1089 if(aMeshMapIter == myMeshMap.end())
1090 EXCEPTION(std::runtime_error,"FindMesh >> There is no mesh with the name - '"<<theMeshName<<"'!!!");
1092 VISU::PMeshImpl aMesh = aMeshMapIter->second;
1097 //---------------------------------------------------------------
1098 VISU_Convertor_impl::TFindMeshOnEntity
1100 ::FindMeshOnEntity(const std::string& theMeshName,
1101 const VISU::TEntity& theEntity)
1103 VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1104 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1105 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
1106 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1107 EXCEPTION(std::runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
1109 VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
1111 return TFindMeshOnEntity(aMesh,
1116 //---------------------------------------------------------------
1117 VISU_Convertor_impl::TFindFamilyOnEntity
1119 ::FindFamilyOnEntity(const std::string& theMeshName,
1120 const VISU::TEntity& theEntity,
1121 const std::string& theFamilyName)
1123 if(theFamilyName != ""){
1124 VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1125 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1126 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
1127 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1128 EXCEPTION(std::runtime_error,"FindFamilyOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
1130 VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
1132 VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1133 VISU::TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName);
1134 if(aFamilyMapIter != aFamilyMap.end()){
1135 const VISU::PFamily& aFamily = aFamilyMapIter->second;
1136 return TFindFamilyOnEntity(aMesh,
1141 return TFindFamilyOnEntity();
1145 //---------------------------------------------------------------
1151 const VISU::TMeshMap& aMeshMap = GetMeshMap();
1152 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
1153 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
1154 const std::string& aMeshName = aMeshMapIter->first;
1155 const VISU::PMesh aMesh = aMeshMapIter->second;
1156 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1157 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
1159 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
1160 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
1161 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
1162 const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
1163 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1164 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
1165 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
1166 const std::string& aFieldName = aFieldMapIter->first;
1167 const VISU::PField aField = aFieldMapIter->second;
1168 const VISU::TValField& aValField = aField->myValField;
1169 VISU::TValField::const_iterator aValFieldIter = aValField.begin();
1170 for(; aValFieldIter != aValField.end(); aValFieldIter++){
1171 int aTimeStamp = aValFieldIter->first;
1172 aResult += GetTimeStampSize(aMeshName,anEntity,aFieldName,aTimeStamp);
1176 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1177 VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
1178 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
1179 const std::string& aGroupName = aGroupMapIter->first;
1180 aResult += GetMeshOnGroupSize(aMeshName,aGroupName);
1183 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1184 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
1185 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
1186 const std::string& aFamilyName = aFamilyMapIter->first;
1187 aResult += GetFamilyOnEntitySize(aMeshName,anEntity,aFamilyName);
1189 //Import mesh on entity
1190 aResult += GetMeshOnEntitySize(aMeshName,anEntity);
1193 MSG(MYDEBUG,"GetSize - aResult = "<<vtkFloatingPointType(aResult));
1198 //---------------------------------------------------------------
1201 ::GetMeshOnEntitySize(const std::string& theMeshName,
1202 const VISU::TEntity& theEntity)
1204 TFindMeshOnEntity aFindMeshOnEntity =
1205 FindMeshOnEntity(theMeshName, theEntity);
1207 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
1208 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1210 size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1211 size_t aNbCells = aMeshOnEntity->myNbCells;
1212 size_t aCellsSize = aMeshOnEntity->myCellsSize;
1214 size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
1215 size_t aTypesSize = aNbCells*sizeof(char);
1216 size_t aLocationsSize = aNbCells*sizeof(int);
1217 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1218 size_t aLinksSize = aMesh->GetNbPoints() *
1219 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
1221 size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
1223 MSG(MYDEBUG,"GetMeshOnEntitySize "<<
1224 "- aResult = "<<vtkFloatingPointType(aResult)<<
1225 "; theMeshName = '"<<theMeshName<<"'"<<
1226 "; theEntity = "<<theEntity);
1228 INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
1229 BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
1230 BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
1231 BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
1232 BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
1235 aResult = size_t(aResult*ERR_SIZE_CALC);
1240 //---------------------------------------------------------------
1243 ::GetFamilyOnEntitySize(const std::string& theMeshName,
1244 const VISU::TEntity& theEntity,
1245 const std::string& theFamilyName)
1247 TFindFamilyOnEntity aFindFamilyOnEntity =
1248 FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
1249 VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);
1250 VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
1251 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
1253 size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1254 size_t aNbCells = aFamily->myNbCells;
1255 size_t aCellsSize = aFamily->myCellsSize;
1257 size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
1258 size_t aTypesSize = aNbCells*sizeof(char);
1259 size_t aLocationsSize = aNbCells*sizeof(int);
1260 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1261 size_t aLinksSize = aMesh->GetNbPoints() *
1262 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
1264 size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
1266 MSG(MYDEBUG,"GetFamilyOnEntitySize "<<
1267 "- aResult = "<<vtkFloatingPointType(aResult)<<
1268 "; theMeshName = '"<<theMeshName<<"'"<<
1269 "; theEntity = "<<theEntity<<
1270 "; theFamilyName = '"<<theFamilyName<<"'");
1272 INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
1273 BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
1274 BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
1275 BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
1276 BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
1279 aResult = size_t(aResult*ERR_SIZE_CALC);
1284 //---------------------------------------------------------------
1285 VISU_Convertor_impl::TFindMeshOnGroup
1287 ::FindMeshOnGroup(const std::string& theMeshName,
1288 const std::string& theGroupName)
1290 VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1291 VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1292 VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName);
1293 if(aGroupMapIter == aGroupMap.end())
1294 EXCEPTION(std::runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<<theGroupName<<"'");
1296 VISU::PGroupImpl aGroup = aGroupMapIter->second;
1297 return TFindMeshOnGroup(aMesh,aGroup);
1303 ::GetMeshOnGroupSize(const std::string& theMeshName,
1304 const std::string& theGroupName)
1306 TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
1307 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
1308 VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
1310 size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1311 VISU::TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells();
1312 size_t aNbCells = aNbASizeCells.first;
1313 size_t aCellsSize = aNbASizeCells.second;
1314 size_t aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
1315 size_t aLocationsSize = aNbCells*sizeof(int);
1316 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1317 size_t aLinksSize = aMesh->GetNbPoints() *
1318 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
1320 size_t aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
1322 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aPointsSize = "<<vtkFloatingPointType(aPointsSize));
1323 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<vtkFloatingPointType(aConnectivityAndTypesSize));
1324 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLocationsSize = "<<vtkFloatingPointType(aLocationsSize));
1325 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLinksSize = "<<vtkFloatingPointType(aLinksSize));
1327 MSG(MYDEBUG,"GetMeshOnGroupSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"
1328 <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
1330 aResult = size_t(aResult*ERR_SIZE_CALC);
1335 VISU_Convertor_impl::TFindField
1337 ::FindField(const std::string& theMeshName,
1338 const VISU::TEntity& theEntity,
1339 const std::string& theFieldName)
1341 TFindMeshOnEntity aFindMeshOnEntity =
1342 FindMeshOnEntity(theMeshName,theEntity);
1344 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
1345 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1347 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1348 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
1349 if ( theEntity == VISU::NODE_ENTITY ) {
1350 if(aMeshOnEntityMap.find( VISU::CELL_ENTITY ) != aMeshOnEntityMap.end())
1351 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::CELL_ENTITY ];
1352 else if (aMeshOnEntityMap.find( VISU::FACE_ENTITY ) != aMeshOnEntityMap.end() )
1353 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::FACE_ENTITY ];
1354 else if (aMeshOnEntityMap.find( VISU::EDGE_ENTITY ) != aMeshOnEntityMap.end() )
1355 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::EDGE_ENTITY ];
1356 else if ( aMeshOnEntityMap.find( VISU::NODE_ENTITY ) != aMeshOnEntityMap.end() )
1357 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::NODE_ENTITY ];
1359 aVTKMeshOnEntity = aMeshOnEntity;
1361 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1362 VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find( theFieldName );
1363 if(aFieldIter == aFieldMap.end())
1364 EXCEPTION(std::runtime_error,"FindField >> There is no field on the mesh!!!");
1366 VISU::PFieldImpl aField = aFieldIter->second;
1368 return TFindField( aMesh,
1377 ::GetFieldOnMeshSize(const std::string& theMeshName,
1378 const VISU::TEntity& theEntity,
1379 const std::string& theFieldName)
1381 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1382 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
1383 VISU::PFieldImpl aField = boost::get<3>(aFindField);
1385 size_t aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
1386 size_t aFieldOnMeshSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType)*aField->myValField.size()*ERR_SIZE_CALC);
1387 size_t aResult = aMeshSize + aFieldOnMeshSize;
1389 MSG(MYVTKDEBUG,"GetFieldOnMeshSize - aFieldOnMeshSize = "<<vtkFloatingPointType(aFieldOnMeshSize));
1390 MSG(MYDEBUG,"GetFieldOnMeshSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"<<theMeshName<<
1391 "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
1397 VISU_Convertor_impl::TFindTimeStamp
1399 ::FindTimeStamp(const std::string& theMeshName,
1400 const VISU::TEntity& theEntity,
1401 const std::string& theFieldName,
1404 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1405 VISU::PField aField = boost::get<3>(aFindField);
1407 VISU::TValField& aValField = aField->myValField;
1408 VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum);
1409 if(aValFieldIter == aValField.end())
1410 EXCEPTION(std::runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!");
1412 VISU::PMeshImpl aMesh = boost::get<0>(aFindField);
1413 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField);
1414 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
1415 VISU::PValForTimeImpl aValForTime = aValFieldIter->second;
1417 return TFindTimeStamp(aMesh,
1427 ::GetTimeStampSize(const std::string& theMeshName,
1428 const VISU::TEntity& theEntity,
1429 const std::string& theFieldName,
1432 TFindTimeStamp aFindTimeStamp =
1433 FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
1434 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
1435 VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
1437 size_t aMeshSize = GetMeshOnEntitySize(theMeshName, aVTKMeshOnEntity->myEntity);
1438 size_t aTimeStampSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType) * ERR_SIZE_CALC);
1439 size_t aResult = aMeshSize + aTimeStampSize;
1441 MSG(MYDEBUG && MYVTKDEBUG,"GetTimeStampSize - aTimeStampSize = "<<vtkFloatingPointType(aTimeStampSize));
1442 MSG(MYDEBUG,"GetTimeStampSize - aResult = "<<vtkFloatingPointType(aResult)<<
1443 "; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
1444 "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
1452 ::GetTimeStampOnMeshSize(const std::string& theMeshName,
1453 const VISU::TEntity& theEntity,
1454 const std::string& theFieldName,
1455 int theTimeStampNumber,
1456 bool& theIsEstimated)
1460 //Cheching possibility do the query
1461 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1464 theTimeStampNumber);
1466 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1467 VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
1468 if(anUnstructuredGridIDMapper->myIsVTKDone){
1469 VISU::PIDMapper anIDMapper = GetTimeStampOnMesh(theMeshName,
1472 theTimeStampNumber);
1473 anIDMapper->GetOutput();
1474 aSize += anIDMapper->GetMemorySize();
1476 aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
1478 theIsEstimated = !(anUnstructuredGridIDMapper->myIsVTKDone);
1480 //cout<<"VISU_Convertor_impl::GetTimeStampOnMeshSize - "<<aSize<<"; "<<(anIDMapperFilter->myIsVTKDone)<<endl;
1487 ::GetTimeStampOnGaussPtsSize(const std::string& theMeshName,
1488 const VISU::TEntity& theEntity,
1489 const std::string& theFieldName,
1490 int theTimeStampNumber,
1491 bool& theIsEstimated)
1495 //Cheching possibility do the query
1496 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1499 theTimeStampNumber);
1501 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1502 VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
1503 if(aGaussPtsIDFilter->myIsVTKDone){
1504 VISU::PGaussPtsIDMapper aGaussPtsIDMapper = GetTimeStampOnGaussPts(theMeshName,
1507 theTimeStampNumber);
1508 aGaussPtsIDMapper->GetOutput();
1509 aSize += aGaussPtsIDMapper->GetMemorySize();
1511 aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
1513 theIsEstimated = !(aGaussPtsIDFilter->myIsVTKDone);
1515 //cout<<"VISU_Convertor_impl::GetTimeStampOnGaussPtsSize - "<<aSize<<"; "<<(aGaussPtsIDFilter->myIsVTKDone)<<endl;
1522 ::GetField(const std::string& theMeshName,
1523 VISU::TEntity theEntity,
1524 const std::string& theFieldName)
1526 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1527 VISU::PField aField = boost::get<3>(aFindField);
1532 const VISU::PValForTime
1534 ::GetTimeStamp(const std::string& theMeshName,
1535 const VISU::TEntity& theEntity,
1536 const std::string& theFieldName,
1539 TFindTimeStamp aFindTimeStamp =
1540 FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
1541 VISU::PValForTime aValForTime = boost::get<4>(aFindTimeStamp);