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 //rnv to fix the: 21040: [CEA 428] Bug of visualization of node field on profile
339 //throw exception in case if the profile on node.
340 //This exception catch in tne VISU_Convertor_impl::GetTimeStampOnMesh(...) function.
341 if( theMeshOnEntity->myEntity == VISU::CELL_ENTITY &&
342 theSubProfile->myGeom == VISU::ePOINT1 &&
343 !theSubProfile->isDefault() )
344 EXCEPTION(std::runtime_error,"theMeshOnEntity->myEntity == VISU::CELL_ENTITY && theSubProfile->myGeom == VISU::ePOINT1 && theSubProfile->isDefault()");
346 const VISU::PUnstructuredGrid& aSource = theSubProfile->GetSource();
347 if(theSubProfile->myIsVTKDone)
350 aSource->ShallowCopy(theMesh->GetPointSet());
351 INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
352 GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
353 BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
355 theSubProfile->myIsVTKDone = true;
359 //---------------------------------------------------------------
361 GetMeshOnProfile(const VISU::PMeshImpl& theMesh,
362 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
363 const VISU::PProfileImpl& theProfile)
365 //rnv fix for bug IPAL18514 4x (CRASH after trying to build of presentation):
366 // throw exection in case if pointer on profile =0
367 if(!theProfile.get())
368 EXCEPTION(std::runtime_error,"GetMeshOnProfile: theProfile.get() == NULL");
370 // rnv fix for issue 19999:
371 // Throw exception in case if mesh on entity from profile is not equal
372 // input mesh on entity. This exception catch in tne VISU_Convertor_impl::GetTimeStampOnMesh
374 if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
375 EXCEPTION(std::runtime_error,"GetMeshOnProfile >> theProfile->myMeshOnEntity != theMeshOnEntity.get()");
377 if(theProfile->myIsVTKDone)
380 // if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
383 VISU::TTimerLog aTimerLog(MYDEBUG,"GetMeshOnProfile");
384 INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<std::endl);
386 const VISU::PAppendFilter& anAppendFilter = theProfile->GetFilter();
387 anAppendFilter->SetSharedPointSet(theMesh->GetPointSet());
389 if(theProfile->myIsAll){
390 vtkUnstructuredGrid* aDataSet = theMeshOnEntity->GetUnstructuredGridOutput();
391 anAppendFilter->AddInput(aDataSet);
393 const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
395 VISU::TID2ID& anElemObj2VTKID = theProfile->myElemObj2VTKID;
397 VISU::TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr;
398 aSubProfileArr.resize(aGeom2SubProfile.size());
400 VISU::TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
401 for(vtkIdType anInputID = 0, aCellID = 0; anIter != aGeom2SubProfile.end(); anIter++){
402 VISU::PSubProfileImpl aSubProfile = anIter->second;
403 if(aSubProfile->myStatus == VISU::eRemoveAll)
406 GetMeshOnSubProfile(theMesh,
411 const VISU::PUnstructuredGrid& aSource = aSubProfile->GetSource();
412 anAppendFilter->AddInput(aSource.GetPointer());
414 vtkIdType aNbCells = aSource->GetNumberOfCells();
415 for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
416 vtkIdType anObjID = aSubProfile->GetElemObjID(aCell);
417 anElemObj2VTKID[anObjID] = aCellID;
420 aSubProfileArr[anInputID++] = aSubProfile;
423 anAppendFilter->Update(); // Fix on VTK
424 theProfile->myMeshOnEntity = theMeshOnEntity.get();
425 theProfile->myNamedPointCoords = theMesh->myNamedPointCoords;
427 theProfile->myIsVTKDone = true;
432 //---------------------------------------------------------------
434 GetGaussSubMeshSource(const VISU::PPolyData& theSource,
435 const VISU::PGaussSubMeshImpl& theGaussSubMesh,
436 const VISU::PMeshOnEntityImpl& theMeshOnEntity)
438 vtkCellArray* aConnectivity = vtkCellArray::New();
439 vtkIdType aCellsSize = theGaussSubMesh->myCellsSize;
440 aConnectivity->Allocate(aCellsSize, 0);
442 vtkIdList *anIdList = vtkIdList::New();
443 anIdList->SetNumberOfIds(1);
445 const VISU::TPointCoords& aCoords = theGaussSubMesh->myPointCoords;
446 vtkIdType aNbPoints = aCoords.GetNbPoints();
447 for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
448 anIdList->SetId(0, aPointId);
449 aConnectivity->InsertNextCell(anIdList);
453 const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
454 aSource->ShallowCopy(aCoords.GetPointSet());
455 aSource->SetVerts(aConnectivity);
457 aConnectivity->Delete();
460 vtkIdType aNbTuples = aNbPoints;
461 vtkIntArray *aDataArray = vtkIntArray::New();
462 aDataArray->SetName("VISU_POINTS_MAPPER");
463 aDataArray->SetNumberOfComponents(2);
464 aDataArray->SetNumberOfTuples(aNbTuples);
465 int *aDataArrayPtr = aDataArray->GetPointer(0);
466 for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
467 vtkIdType aGlobalID = theGaussSubMesh->GetGlobalID(aTupleId);
468 *aDataArrayPtr++ = aGlobalID;
469 *aDataArrayPtr++ = 0;
471 aSource->GetPointData()->AddArray(aDataArray);
472 aDataArray->Delete();
476 vtkIdType aNbTuples = aNbPoints;
477 vtkIntArray *aDataArray = vtkIntArray::New();
478 aDataArray->SetName("VISU_CELLS_MAPPER");
479 aDataArray->SetNumberOfComponents(2);
480 aDataArray->SetNumberOfTuples(aNbTuples);
481 int *aDataArrayPtr = aDataArray->GetPointer(0);
482 for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
483 VISU::TGaussPointID aGaussPointID = theGaussSubMesh->GetObjID(aTupleId);
484 *aDataArrayPtr++ = aGaussPointID.first;
485 *aDataArrayPtr++ = aGaussPointID.second;
487 aSource->GetCellData()->AddArray(aDataArray);
488 aDataArray->Delete();
493 //---------------------------------------------------------------
495 GetGaussSubMesh(const VISU::PMeshImpl& theMesh,
496 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
497 const VISU::PGaussMeshImpl& theGaussMesh,
498 const VISU::PGaussSubMeshImpl& theGaussSubMesh)
500 VISU::PGaussImpl aGauss = theGaussSubMesh->myGauss;
502 if(!theGaussSubMesh->myIsDone)
505 if(theGaussSubMesh->myIsVTKDone)
508 VISU::TTimerLog aTimerLog(MYDEBUG,"GetGaussSubMesh");
509 INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<<aGauss->myGeom<<endl);
511 const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
512 GetGaussSubMeshSource(aSource, theGaussSubMesh, theMeshOnEntity);
514 INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
515 BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
517 theGaussSubMesh->myIsVTKDone = true;
521 //---------------------------------------------------------------
523 BuildGaussMesh(const VISU::PMeshImpl& theMesh,
524 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
525 const VISU::PGaussMeshImpl& theGaussMesh)
527 if(theGaussMesh->myIsVTKDone)
530 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGaussMesh");
531 const VISU::PAppendPolyData& anAppendFilter = theGaussMesh->GetFilter();
532 const VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
533 VISU::TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
534 for(vtkIdType aStartID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
535 VISU::PGaussSubMeshImpl aGaussSubMesh = anIter->second;
536 if(aGaussSubMesh->myStatus == VISU::eRemoveAll)
539 aGaussSubMesh->myStartID = aStartID;
541 GetGaussSubMesh(theMesh,
546 const VISU::PPolyData& aSource = aGaussSubMesh->GetSource();
547 aStartID += aSource->GetNumberOfCells();
549 anAppendFilter->AddInput(aSource.GetPointer());
551 anAppendFilter->Update(); // Fix on VTK
553 theMeshOnEntity->GetOutput()->Update();
555 vtkDataSet* aSource = anAppendFilter->GetOutput();
556 INITMSGA(MYDEBUG,0,"aNbPoints - "<<aSource->GetNumberOfPoints()<<endl);
557 BEGMSG(MYDEBUG,"aNbCells - "<<aSource->GetNumberOfCells()<<endl);
559 theGaussMesh->myIsVTKDone = true;
563 //---------------------------------------------------------------
565 PrintMemorySize(vtkUnstructuredGrid* theDataSet)
567 theDataSet->Update();
568 BEGMSG(1,"GetPoints() = "<<vtkFloatingPointType(theDataSet->GetPoints()->GetActualMemorySize()*1000)<<endl);
569 BEGMSG(1,"GetCells() = "<<vtkFloatingPointType(theDataSet->GetCells()->GetActualMemorySize()*1000)<<endl);
570 BEGMSG(1,"GetCellTypesArray() = "<<vtkFloatingPointType(theDataSet->GetCellTypesArray()->GetActualMemorySize()*1000)<<endl);
571 BEGMSG(1,"GetCellLocationsArray() = "<<vtkFloatingPointType(theDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000)<<endl);
572 theDataSet->BuildLinks();
573 BEGMSG(1,"GetCellLinks() = "<<vtkFloatingPointType(theDataSet->GetCellLinks()->GetActualMemorySize()*1000)<<endl);
574 BEGMSG(1,"GetPointData() = "<<vtkFloatingPointType(theDataSet->GetPointData()->GetActualMemorySize()*1000)<<endl);
575 BEGMSG(1,"GetCellData() = "<<vtkFloatingPointType(theDataSet->GetCellData()->GetActualMemorySize()*1000)<<endl);
576 BEGMSG(1,"GetActualMemorySize() = "<<vtkFloatingPointType(theDataSet->GetActualMemorySize()*1000)<<endl);
581 //---------------------------------------------------------------
583 ::VISU_Convertor_impl()
587 //---------------------------------------------------------------
589 ::~VISU_Convertor_impl()
593 //---------------------------------------------------------------
639 //---------------------------------------------------------------
642 ::GetMeshOnEntity(const std::string& theMeshName,
643 const VISU::TEntity& theEntity)
645 INITMSG(MYDEBUG,"GetMeshOnEntity"<<
646 "; theMeshName = '"<<theMeshName<<"'"<<
647 "; theEntity = "<<theEntity<<
650 //Cheching possibility do the query
651 TFindMeshOnEntity aFindMeshOnEntity =
652 FindMeshOnEntity(theMeshName,theEntity);
654 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
655 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
661 if(!aMeshOnEntity->myIsVTKDone){
662 VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetMeshOnEntity");
663 const VISU::PAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter();
664 if(MYVTKDEBUG) anAppendFilter->DebugOn();
666 LoadMeshOnEntity(aMesh,aMeshOnEntity);
667 anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
669 const VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
670 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
672 VISU::TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID;
673 VISU::TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr;
674 aSubMeshArr.resize(aGeom2SubMesh.size());
676 for(vtkIdType anID = 0, aCellID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){
677 VISU::EGeometry aEGeom = anIter->first;
678 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
679 VISU::PSubMeshImpl aSubMesh = anIter->second;
681 aSubMesh->CopyStructure( aMesh );
683 aSubMesh->myStartID = aCellID;
685 const VISU::PUnstructuredGrid& aSource = aSubMesh->GetSource();
686 GetCellsOnSubMesh(aSource, aMeshOnEntity, aSubMesh, aVGeom);
687 anAppendFilter->AddInput(aSource.GetPointer());
689 vtkIdType aNbCells = aSource->GetNumberOfCells();
690 for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
691 vtkIdType anObjID = aSubMesh->GetElemObjID(aCell);
692 anElemObj2VTKID[anObjID] = aCellID;
695 aSubMeshArr[anID] = aSubMesh;
698 aMeshOnEntity->CopyStructure( aMesh );
700 aMeshOnEntity->myIsVTKDone = true;
702 if(MYDEBUGWITHFILES){
703 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
704 std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
705 aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-MeshOnEntity.vtk";
706 VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
710 GetMeshOnEntitySize(theMeshName,theEntity);
711 PrintMemorySize(anAppendFilter->GetOutput());
721 return aMeshOnEntity;
725 //---------------------------------------------------------------
726 VISU::PUnstructuredGridIDMapper
728 ::GetFamilyOnEntity(const std::string& theMeshName,
729 const VISU::TEntity& theEntity,
730 const std::string& theFamilyName)
732 INITMSG(MYDEBUG,"GetFamilyOnEntity"<<
733 "; theMeshName = '"<<theMeshName<<"'"<<
734 "; theEntity = "<<theEntity<<
735 "; theFamilyName = '"<<theFamilyName<<"'"<<
738 //Cheching possibility do the query
739 TFindFamilyOnEntity aFindFamilyOnEntity =
740 FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
742 VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);;
743 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
744 VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
750 if ( !aFamily->myIsVTKDone ) {
751 GetMeshOnEntity( theMeshName, theEntity );
753 LoadFamilyOnEntity( aMesh, aMeshOnEntity, aFamily );
755 aFamily->CopyStructure( aMesh );
757 const VISU::PUnstructuredGrid& aSource = aFamily->GetSource();
758 GetCellsOnFamily( aSource, aMeshOnEntity, aFamily );
760 aFamily->myIsVTKDone = true;
762 if(MYDEBUGWITHFILES){
763 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
764 std::string aFamilyName = (const char*)QString(theFamilyName.c_str()).simplified().toLatin1();
765 std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
766 aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-FamilyOnEntity.vtk";
767 VISU::WriteToFile(aSource.GetPointer(),aFileName);
771 GetFamilyOnEntitySize(theMeshName,theEntity,theFamilyName);
772 PrintMemorySize(aSource.GetPointer());
786 //---------------------------------------------------------------
787 VISU::PUnstructuredGridIDMapper
789 ::GetMeshOnGroup(const std::string& theMeshName,
790 const std::string& theGroupName)
792 INITMSG(MYDEBUG,"GetMeshOnGroup\n");
794 "- theMeshName = '"<<theMeshName<<
795 "'; theGroupName = '"<<theGroupName<<"'"<<
798 //Cheching possibility do the query
799 TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
800 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
801 VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
807 if(!aGroup->myIsVTKDone){
808 const VISU::PAppendFilter& anAppendFilter = aGroup->GetFilter();
809 const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
811 LoadMeshOnGroup(aMesh,aFamilySet);
812 anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
814 VISU::TFamilySet::const_iterator anIter = aFamilySet.begin();
816 VISU::TID2ID& anElemObj2VTKID = aGroup->myElemObj2VTKID;
817 VISU::TFamilyArr& aFamilyArr = aGroup->myFamilyArr;
818 aFamilyArr.resize(aFamilySet.size());
820 for(vtkIdType anID = 0; anIter != aFamilySet.end(); anIter++, anID++){
821 VISU::PFamilyImpl aFamily = (*anIter).second;
822 const std::string& aFamilyName = aFamily->myName;
823 const VISU::TEntity& anEntity = aFamily->myEntity;
825 VISU::PIDMapper anIDMapper = GetFamilyOnEntity(theMeshName,anEntity,aFamilyName);
826 vtkDataSet* anOutput = anIDMapper->GetOutput();
827 anAppendFilter->AddInput(anOutput);
829 vtkIdType aStartID = anElemObj2VTKID.size();
830 vtkIdType aNbCells = anOutput->GetNumberOfCells();
831 for(vtkIdType aCellID = 0; aCellID < aNbCells; aCellID++){
832 anElemObj2VTKID[aFamily->GetElemObjID(aCellID)] = aStartID + aCellID;
834 aFamilyArr[anID] = aFamily;
837 aGroup->CopyStructure( aMesh );
839 aGroup->myIsVTKDone = true;
841 if(MYDEBUGWITHFILES){
842 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
843 std::string aGroupName = (const char*)QString(theGroupName.c_str()).simplified().toLatin1();
844 std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
845 aFileName += aMeshName + "-" + aGroupName + "-MeshOnGroup.vtk";
846 VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
859 //---------------------------------------------------------------
862 ::GetTimeStampOnProfile( const VISU::PMeshImpl& theMesh,
863 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
864 const VISU::PFieldImpl& theField,
865 const VISU::PValForTimeImpl& theValForTime,
866 const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper,
867 const VISU::PProfileImpl& theProfile,
868 const VISU::TEntity& theEntity )
870 LoadMeshOnEntity( theMesh, theMeshOnEntity );
871 GetMeshOnEntity( theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity );
872 GetMeshOnProfile( theMesh, theMeshOnEntity, theProfile );
874 theUnstructuredGridIDMapper->myIDMapper = theProfile;
876 if ( theMeshOnEntity->myEntity == VISU::NODE_ENTITY ) {
877 // add geometry elements to output,
878 // if timestamp on NODE_ENTITY and
879 // on profiles with status eAddPart
880 const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
881 VISU::TGeom2SubProfile::const_iterator aSubProfileIter = aGeom2SubProfile.begin();
882 for ( ; aSubProfileIter != aGeom2SubProfile.end(); aSubProfileIter++ ) {
883 const VISU::EGeometry& aGeom = aSubProfileIter->first;
884 const VISU::PSubProfileImpl& aSubProfile = aSubProfileIter->second;
885 if ( aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1 ) {
886 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
887 VISU::TMeshOnEntityMap::const_reverse_iterator aMeshOnEntityIter = aMeshOnEntityMap.rbegin();
888 for( ; aMeshOnEntityIter != aMeshOnEntityMap.rend(); aMeshOnEntityIter++ ) {
889 VISU::TEntity anEntity = aMeshOnEntityIter->first;
890 if ( anEntity == VISU::NODE_ENTITY )
892 VISU::PNamedIDMapper aNamedIDMapper = GetMeshOnEntity( theMesh->myName, anEntity );
893 if( aNamedIDMapper ) {
894 theUnstructuredGridIDMapper->SetReferencedMesh( aNamedIDMapper );
895 VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
896 VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
898 return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
905 VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
906 VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
908 return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
912 //---------------------------------------------------------------
913 VISU::PUnstructuredGridIDMapper
915 ::GetTimeStampOnMesh( const std::string& theMeshName,
916 const VISU::TEntity& theEntity,
917 const std::string& theFieldName,
920 INITMSG(MYDEBUG,"GetTimeStampOnMesh"<<
921 "; theMeshName = '"<<theMeshName<<"'"<<
922 "; theEntity = "<<theEntity<<
923 "; theFieldName = '"<<theFieldName<<"'"<<
924 "; theStampsNum = "<<theStampsNum<<
927 //Cheching possibility do the query
928 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
933 VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
934 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
935 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
936 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
937 VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
940 VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
944 if(!anUnstructuredGridIDMapper->myIsVTKDone){
945 VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnMesh");
946 LoadValForTimeOnMesh(aMesh, aMeshOnEntity, aField, aValForTime);
948 vtkUnstructuredGrid* anOutput = NULL;
950 anOutput = GetTimeStampOnProfile(aMesh,
954 anUnstructuredGridIDMapper,
955 aValForTime->myProfile,
956 aMeshOnEntity->myEntity);
957 }catch(std::exception& exc){
958 MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
959 anOutput = GetTimeStampOnProfile(aMesh,
963 anUnstructuredGridIDMapper,
964 aValForTime->myProfile,
965 aVTKMeshOnEntity->myEntity);
968 anUnstructuredGridIDMapper->CopyStructure( aMesh );
970 anUnstructuredGridIDMapper->myIsVTKDone = true;
972 if(MYDEBUGWITHFILES){
973 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
974 std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1();
975 std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
976 std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
977 aFieldName + dtos("-%d", theStampsNum) + "-TimeStampOnMesh.vtk";
978 VISU::WriteToFile(anOutput,aFileName);
981 GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
983 if(theEntity == VISU::NODE_ENTITY)
984 BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
986 BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
987 BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
991 }catch(std::exception& exc){
998 return anUnstructuredGridIDMapper;
1002 //---------------------------------------------------------------
1003 VISU::PGaussPtsIDMapper
1005 ::GetTimeStampOnGaussPts(const std::string& theMeshName,
1006 const VISU::TEntity& theEntity,
1007 const std::string& theFieldName,
1010 INITMSG(MYDEBUG,"GetTimeStampOnGaussPts"<<
1011 "; theMeshName = '"<<theMeshName<<"'"<<
1012 "; theEntity = "<<theEntity<<
1013 "; theFieldName = '"<<theFieldName<<"'"<<
1014 "; theStampsNum = "<<theStampsNum<<
1017 if(theEntity == VISU::NODE_ENTITY)
1018 EXCEPTION(std::runtime_error, "It is impossible to reate Gauss Points on NODE_ENTITY !!!");
1020 //Cheching possibility do the query
1021 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1026 VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
1027 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
1028 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
1029 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1030 VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
1033 VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
1037 if(!aGaussPtsIDFilter->myIsVTKDone){
1038 VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnGaussPts");
1039 LoadValForTimeOnGaussPts(aMesh, aMeshOnEntity, aField, aValForTime);
1041 GetMeshOnEntity(aVTKMeshOnEntity->myMeshName, aVTKMeshOnEntity->myEntity);
1043 VISU::PProfileImpl aProfile = aValForTime->myProfile;
1044 GetMeshOnProfile(aMesh, aVTKMeshOnEntity, aProfile);
1046 VISU::PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh;
1047 if(!aGaussMesh->myIsVTKDone){
1048 BuildGaussMesh(aMesh, aVTKMeshOnEntity, aGaussMesh);
1049 aGaussMesh->myParent = aProfile.get();
1050 aGaussMesh->myIsVTKDone = true;
1053 aGaussPtsIDFilter->myIDMapper = aGaussMesh;
1054 aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh;
1055 VISU::PPolyData aSource = aGaussPtsIDFilter->GetSource();
1056 VISU::GetTimeStampOnGaussMesh(aSource, aField, aValForTime);
1057 vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput();
1059 aGaussPtsIDFilter->myIsVTKDone = true;
1061 if(MYDEBUGWITHFILES){
1062 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
1063 std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1();
1064 std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
1065 std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
1066 aFieldName + dtos("-%d",theStampsNum) + "-TimeStampOnGaussPts.vtk";
1067 VISU::WriteToFile(anOutput, aFileName);
1070 GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
1072 if(theEntity == VISU::NODE_ENTITY)
1073 BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
1075 BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
1076 BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
1080 }catch(std::exception& exc){
1087 return aGaussPtsIDFilter;
1090 //---------------------------------------------------------------
1093 ::FindMesh(const std::string& theMeshName)
1096 VISU::TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName);
1097 if(aMeshMapIter == myMeshMap.end())
1098 EXCEPTION(std::runtime_error,"FindMesh >> There is no mesh with the name - '"<<theMeshName<<"'!!!");
1100 VISU::PMeshImpl aMesh = aMeshMapIter->second;
1105 //---------------------------------------------------------------
1106 VISU_Convertor_impl::TFindMeshOnEntity
1108 ::FindMeshOnEntity(const std::string& theMeshName,
1109 const VISU::TEntity& theEntity)
1111 VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1112 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1113 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
1114 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1115 EXCEPTION(std::runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
1117 VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
1119 return TFindMeshOnEntity(aMesh,
1124 //---------------------------------------------------------------
1125 VISU_Convertor_impl::TFindFamilyOnEntity
1127 ::FindFamilyOnEntity(const std::string& theMeshName,
1128 const VISU::TEntity& theEntity,
1129 const std::string& theFamilyName)
1131 if(theFamilyName != ""){
1132 VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1133 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1134 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
1135 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1136 EXCEPTION(std::runtime_error,"FindFamilyOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
1138 VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
1140 VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1141 VISU::TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName);
1142 if(aFamilyMapIter != aFamilyMap.end()){
1143 const VISU::PFamily& aFamily = aFamilyMapIter->second;
1144 return TFindFamilyOnEntity(aMesh,
1149 return TFindFamilyOnEntity();
1153 //---------------------------------------------------------------
1159 const VISU::TMeshMap& aMeshMap = GetMeshMap();
1160 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
1161 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
1162 const std::string& aMeshName = aMeshMapIter->first;
1163 const VISU::PMesh aMesh = aMeshMapIter->second;
1164 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1165 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
1167 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
1168 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
1169 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
1170 const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
1171 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1172 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
1173 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
1174 const std::string& aFieldName = aFieldMapIter->first;
1175 const VISU::PField aField = aFieldMapIter->second;
1176 const VISU::TValField& aValField = aField->myValField;
1177 VISU::TValField::const_iterator aValFieldIter = aValField.begin();
1178 for(; aValFieldIter != aValField.end(); aValFieldIter++){
1179 int aTimeStamp = aValFieldIter->first;
1180 aResult += GetTimeStampSize(aMeshName,anEntity,aFieldName,aTimeStamp);
1184 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1185 VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
1186 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
1187 const std::string& aGroupName = aGroupMapIter->first;
1188 aResult += GetMeshOnGroupSize(aMeshName,aGroupName);
1191 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1192 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
1193 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
1194 const std::string& aFamilyName = aFamilyMapIter->first;
1195 aResult += GetFamilyOnEntitySize(aMeshName,anEntity,aFamilyName);
1197 //Import mesh on entity
1198 aResult += GetMeshOnEntitySize(aMeshName,anEntity);
1201 MSG(MYDEBUG,"GetSize - aResult = "<<vtkFloatingPointType(aResult));
1206 //---------------------------------------------------------------
1209 ::GetMeshOnEntitySize(const std::string& theMeshName,
1210 const VISU::TEntity& theEntity)
1212 TFindMeshOnEntity aFindMeshOnEntity =
1213 FindMeshOnEntity(theMeshName, theEntity);
1215 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
1216 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1218 size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1219 size_t aNbCells = aMeshOnEntity->myNbCells;
1220 size_t aCellsSize = aMeshOnEntity->myCellsSize;
1222 size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
1223 size_t aTypesSize = aNbCells*sizeof(char);
1224 size_t aLocationsSize = aNbCells*sizeof(int);
1225 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1226 size_t aLinksSize = aMesh->GetNbPoints() *
1227 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
1229 size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
1231 MSG(MYDEBUG,"GetMeshOnEntitySize "<<
1232 "- aResult = "<<vtkFloatingPointType(aResult)<<
1233 "; theMeshName = '"<<theMeshName<<"'"<<
1234 "; theEntity = "<<theEntity);
1236 INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
1237 BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
1238 BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
1239 BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
1240 BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
1243 aResult = size_t(aResult*ERR_SIZE_CALC);
1248 //---------------------------------------------------------------
1251 ::GetFamilyOnEntitySize(const std::string& theMeshName,
1252 const VISU::TEntity& theEntity,
1253 const std::string& theFamilyName)
1255 TFindFamilyOnEntity aFindFamilyOnEntity =
1256 FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
1257 VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);
1258 VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
1259 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
1261 size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1262 size_t aNbCells = aFamily->myNbCells;
1263 size_t aCellsSize = aFamily->myCellsSize;
1265 size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
1266 size_t aTypesSize = aNbCells*sizeof(char);
1267 size_t aLocationsSize = aNbCells*sizeof(int);
1268 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1269 size_t aLinksSize = aMesh->GetNbPoints() *
1270 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
1272 size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
1274 MSG(MYDEBUG,"GetFamilyOnEntitySize "<<
1275 "- aResult = "<<vtkFloatingPointType(aResult)<<
1276 "; theMeshName = '"<<theMeshName<<"'"<<
1277 "; theEntity = "<<theEntity<<
1278 "; theFamilyName = '"<<theFamilyName<<"'");
1280 INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
1281 BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
1282 BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
1283 BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
1284 BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
1287 aResult = size_t(aResult*ERR_SIZE_CALC);
1292 //---------------------------------------------------------------
1293 VISU_Convertor_impl::TFindMeshOnGroup
1295 ::FindMeshOnGroup(const std::string& theMeshName,
1296 const std::string& theGroupName)
1298 VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1299 VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1300 VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName);
1301 if(aGroupMapIter == aGroupMap.end())
1302 EXCEPTION(std::runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<<theGroupName<<"'");
1304 VISU::PGroupImpl aGroup = aGroupMapIter->second;
1305 return TFindMeshOnGroup(aMesh,aGroup);
1311 ::GetMeshOnGroupSize(const std::string& theMeshName,
1312 const std::string& theGroupName)
1314 TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
1315 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
1316 VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
1318 size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1319 VISU::TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells();
1320 size_t aNbCells = aNbASizeCells.first;
1321 size_t aCellsSize = aNbASizeCells.second;
1322 size_t aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
1323 size_t aLocationsSize = aNbCells*sizeof(int);
1324 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1325 size_t aLinksSize = aMesh->GetNbPoints() *
1326 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
1328 size_t aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
1330 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aPointsSize = "<<vtkFloatingPointType(aPointsSize));
1331 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<vtkFloatingPointType(aConnectivityAndTypesSize));
1332 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLocationsSize = "<<vtkFloatingPointType(aLocationsSize));
1333 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLinksSize = "<<vtkFloatingPointType(aLinksSize));
1335 MSG(MYDEBUG,"GetMeshOnGroupSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"
1336 <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
1338 aResult = size_t(aResult*ERR_SIZE_CALC);
1343 VISU_Convertor_impl::TFindField
1345 ::FindField(const std::string& theMeshName,
1346 const VISU::TEntity& theEntity,
1347 const std::string& theFieldName)
1349 TFindMeshOnEntity aFindMeshOnEntity =
1350 FindMeshOnEntity(theMeshName,theEntity);
1352 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
1353 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1355 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1356 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
1357 if ( theEntity == VISU::NODE_ENTITY ) {
1358 if(aMeshOnEntityMap.find( VISU::CELL_ENTITY ) != aMeshOnEntityMap.end())
1359 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::CELL_ENTITY ];
1360 else if (aMeshOnEntityMap.find( VISU::FACE_ENTITY ) != aMeshOnEntityMap.end() )
1361 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::FACE_ENTITY ];
1362 else if (aMeshOnEntityMap.find( VISU::EDGE_ENTITY ) != aMeshOnEntityMap.end() )
1363 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::EDGE_ENTITY ];
1364 else if ( aMeshOnEntityMap.find( VISU::NODE_ENTITY ) != aMeshOnEntityMap.end() )
1365 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::NODE_ENTITY ];
1367 aVTKMeshOnEntity = aMeshOnEntity;
1369 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1370 VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find( theFieldName );
1371 if(aFieldIter == aFieldMap.end())
1372 EXCEPTION(std::runtime_error,"FindField >> There is no field on the mesh!!!");
1374 VISU::PFieldImpl aField = aFieldIter->second;
1376 return TFindField( aMesh,
1385 ::GetFieldOnMeshSize(const std::string& theMeshName,
1386 const VISU::TEntity& theEntity,
1387 const std::string& theFieldName)
1389 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1390 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
1391 VISU::PFieldImpl aField = boost::get<3>(aFindField);
1393 size_t aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
1394 size_t aFieldOnMeshSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType)*aField->myValField.size()*ERR_SIZE_CALC);
1395 size_t aResult = aMeshSize + aFieldOnMeshSize;
1397 MSG(MYVTKDEBUG,"GetFieldOnMeshSize - aFieldOnMeshSize = "<<vtkFloatingPointType(aFieldOnMeshSize));
1398 MSG(MYDEBUG,"GetFieldOnMeshSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"<<theMeshName<<
1399 "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
1405 VISU_Convertor_impl::TFindTimeStamp
1407 ::FindTimeStamp(const std::string& theMeshName,
1408 const VISU::TEntity& theEntity,
1409 const std::string& theFieldName,
1412 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1413 VISU::PField aField = boost::get<3>(aFindField);
1415 VISU::TValField& aValField = aField->myValField;
1416 VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum);
1417 if(aValFieldIter == aValField.end())
1418 EXCEPTION(std::runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!");
1420 VISU::PMeshImpl aMesh = boost::get<0>(aFindField);
1421 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField);
1422 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
1423 VISU::PValForTimeImpl aValForTime = aValFieldIter->second;
1425 return TFindTimeStamp(aMesh,
1435 ::GetTimeStampSize(const std::string& theMeshName,
1436 const VISU::TEntity& theEntity,
1437 const std::string& theFieldName,
1440 TFindTimeStamp aFindTimeStamp =
1441 FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
1442 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
1443 VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
1445 size_t aMeshSize = GetMeshOnEntitySize(theMeshName, aVTKMeshOnEntity->myEntity);
1446 size_t aTimeStampSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType) * ERR_SIZE_CALC);
1447 size_t aResult = aMeshSize + aTimeStampSize;
1449 MSG(MYDEBUG && MYVTKDEBUG,"GetTimeStampSize - aTimeStampSize = "<<vtkFloatingPointType(aTimeStampSize));
1450 MSG(MYDEBUG,"GetTimeStampSize - aResult = "<<vtkFloatingPointType(aResult)<<
1451 "; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
1452 "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
1460 ::GetTimeStampOnMeshSize(const std::string& theMeshName,
1461 const VISU::TEntity& theEntity,
1462 const std::string& theFieldName,
1463 int theTimeStampNumber,
1464 bool& theIsEstimated)
1468 //Cheching possibility do the query
1469 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1472 theTimeStampNumber);
1474 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1475 VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
1476 if(anUnstructuredGridIDMapper->myIsVTKDone){
1477 VISU::PIDMapper anIDMapper = GetTimeStampOnMesh(theMeshName,
1480 theTimeStampNumber);
1481 anIDMapper->GetOutput();
1482 aSize += anIDMapper->GetMemorySize();
1484 aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
1486 theIsEstimated = !(anUnstructuredGridIDMapper->myIsVTKDone);
1488 //cout<<"VISU_Convertor_impl::GetTimeStampOnMeshSize - "<<aSize<<"; "<<(anIDMapperFilter->myIsVTKDone)<<endl;
1495 ::GetTimeStampOnGaussPtsSize(const std::string& theMeshName,
1496 const VISU::TEntity& theEntity,
1497 const std::string& theFieldName,
1498 int theTimeStampNumber,
1499 bool& theIsEstimated)
1503 //Cheching possibility do the query
1504 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1507 theTimeStampNumber);
1509 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1510 VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
1511 if(aGaussPtsIDFilter->myIsVTKDone){
1512 VISU::PGaussPtsIDMapper aGaussPtsIDMapper = GetTimeStampOnGaussPts(theMeshName,
1515 theTimeStampNumber);
1516 aGaussPtsIDMapper->GetOutput();
1517 aSize += aGaussPtsIDMapper->GetMemorySize();
1519 aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
1521 theIsEstimated = !(aGaussPtsIDFilter->myIsVTKDone);
1523 //cout<<"VISU_Convertor_impl::GetTimeStampOnGaussPtsSize - "<<aSize<<"; "<<(aGaussPtsIDFilter->myIsVTKDone)<<endl;
1530 ::GetField(const std::string& theMeshName,
1531 VISU::TEntity theEntity,
1532 const std::string& theFieldName)
1534 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1535 VISU::PField aField = boost::get<3>(aFindField);
1540 const VISU::PValForTime
1542 ::GetTimeStamp(const std::string& theMeshName,
1543 const VISU::TEntity& theEntity,
1544 const std::string& theFieldName,
1547 TFindTimeStamp aFindTimeStamp =
1548 FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
1549 VISU::PValForTime aValForTime = boost::get<4>(aFindTimeStamp);