1 // Copyright (C) 2007-2008 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
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISU_Convertor_impl.cxx
24 // Author : Alexey PETROV
27 #include "VISU_Convertor_impl.hxx"
28 #include "VISU_Structures_impl.hxx"
29 #include "VISU_PointCoords.hxx"
30 #include "VISU_MeshValue.hxx"
32 #include "VISU_AppendFilter.hxx"
33 #include "VISU_AppendPolyData.hxx"
34 #include "VTKViewer_CellLocationsArray.h"
35 #include "VISU_CommonCellsFilter.hxx"
37 #include "VISU_ConvertorUtils.hxx"
39 #include <vtkUnstructuredGrid.h>
40 #include <vtkPolyData.h>
42 #include <vtkPoints.h>
43 #include <vtkPointData.h>
44 #include <vtkCellData.h>
46 #include <vtkIdList.h>
47 #include <vtkCellType.h>
48 #include <vtkCellArray.h>
49 #include <vtkCellLinks.h>
50 #include <vtkUnsignedCharArray.h>
57 static vtkFloatingPointType ERR_SIZE_CALC = 1.00;
59 static int MYVTKDEBUG = 0;
62 static int MYDEBUG = 0;
63 static int MYDEBUGWITHFILES = 0;
66 static int MYDEBUG = 0;
67 static int MYDEBUGWITHFILES = 0;
73 //---------------------------------------------------------------
76 dtos(const std::string& fmt, T val)
78 static QString aString;
79 aString.sprintf(fmt.c_str(),val);
80 return (const char*)aString.toLatin1();
84 //---------------------------------------------------------------
87 PrintCells( vtkCellArray* theConnectivity,
88 const VISU::TConnect& theVector)
90 theConnectivity->InsertNextCell( theVector.size(), &theVector[ 0 ] );
94 //---------------------------------------------------------------
96 GetCellsOnSubMesh(const VISU::PUnstructuredGrid& theSource,
97 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
98 const VISU::PSubMeshImpl& theSubMesh,
99 const vtkIdType theGeom)
101 VISU::TTimerLog aTimerLog(MYDEBUG,"GetCellsOnSubMesh");
102 const VISU::TCell2Connect& anArray = theSubMesh->myCell2Connect;
103 vtkIdType aCellsSize = theSubMesh->myCellsSize;
104 vtkIdType aNbCells = theSubMesh->myNbCells;
105 INITMSG(MYDEBUG,"GetCellsOnSubMesh "<<
106 "- theGeom = "<<theGeom<<
107 "; aNbCells = "<<aNbCells<<
111 vtkCellArray* aConnectivity = vtkCellArray::New();
112 aConnectivity->Allocate(aCellsSize,0);
113 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
114 aCellTypesArray->SetNumberOfComponents(1);
115 aCellTypesArray->SetNumberOfTuples(aNbCells);
117 for(vtkIdType anID = 0; anID < aNbCells; anID++){
118 PrintCells( aConnectivity, anArray[ anID ] );
119 aCellTypesArray->SetValue(anID,(unsigned char)theGeom);
123 int aNbTuples = aNbCells;
124 int anEntity = int(theMeshOnEntity->myEntity);
125 vtkIntArray *aDataArray = vtkIntArray::New();
126 aDataArray->SetName("VISU_CELLS_MAPPER");
127 aDataArray->SetNumberOfComponents(2);
128 aDataArray->SetNumberOfTuples(aNbTuples);
129 int *aDataArrayPtr = aDataArray->GetPointer(0);
130 for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
131 int anObjID = theSubMesh->GetElemObjID(aTupleId);
132 *aDataArrayPtr++ = anObjID;
133 *aDataArrayPtr++ = anEntity;
135 theSource->GetCellData()->AddArray(aDataArray);
136 aDataArray->Delete();
139 vtkIdType *pts = 0, npts = 0;
140 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
141 aCellLocationsArray->SetNumberOfComponents(1);
142 aCellLocationsArray->SetNumberOfTuples(aNbCells);
143 aConnectivity->InitTraversal();
144 for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
145 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
146 theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
148 if(MYVTKDEBUG) aConnectivity->DebugOn();
150 aCellLocationsArray->Delete();
151 aCellTypesArray->Delete();
152 aConnectivity->Delete();
156 //---------------------------------------------------------------
158 GetCellsOnFamily(const VISU::PUnstructuredGrid& theSource,
159 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
160 const VISU::PFamilyImpl& theFamily)
162 INITMSG(MYDEBUG,"GetCellsOnFamily"<<endl);
164 vtkIdType aNbCells = theFamily->myNbCells;
165 vtkIdType aCellsSize = theFamily->myCellsSize;
167 vtkCellArray* aConnectivity = vtkCellArray::New();
168 aConnectivity->Allocate(aCellsSize,0);
169 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
170 aCellTypesArray->SetNumberOfComponents(1);
171 aCellTypesArray->SetNumberOfTuples(aNbCells);
173 VISU::TSubMeshID& aMeshID = theFamily->myMeshID;
174 aMeshID.resize(aNbCells);
176 vtkIntArray *aDataArray = vtkIntArray::New();
177 int anEntity = int(theMeshOnEntity->myEntity);
178 aDataArray->SetName("VISU_CELLS_MAPPER");
179 aDataArray->SetNumberOfComponents(2);
180 aDataArray->SetNumberOfTuples(aNbCells);
181 int *aDataArrayPtr = aDataArray->GetPointer(0);
183 VISU::TID2ID& anElemObj2VTKID = theFamily->myElemObj2VTKID;
185 const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
186 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
187 for(vtkIdType aCellId = 0; anIter != aGeom2SubMesh.end(); anIter++){
188 VISU::EGeometry aEGeom = anIter->first;
189 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
191 const VISU::TSubMeshImpl& aSubMesh = anIter->second;
192 const VISU::TCell2Connect& anArray = aSubMesh.myCell2Connect;
194 const VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
195 if(aGeom2SubMeshID.empty())
196 EXCEPTION(std::runtime_error,"GetCells >> There is no elements on the family !!!");
198 VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aEGeom);
199 if(aGeom2SubMeshIDIter == aGeom2SubMeshID.end())
202 const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second;
205 " - aEGeom = "<<aEGeom<<
206 "; aVGeom = "<<aVGeom<<
207 "; aSubMeshID.size() = "<<aSubMeshID.size()<<
210 VISU::TSubMeshID::const_iterator aSubMeshIDIter = aSubMeshID.begin();
211 for(; aSubMeshIDIter != aSubMeshID.end(); aSubMeshIDIter++, aCellId++){
212 vtkIdType anID = *aSubMeshIDIter;
213 PrintCells( aConnectivity, anArray[ anID ] );
214 aCellTypesArray->SetValue(aCellId, (unsigned char)aVGeom);
215 vtkIdType anObjID = aSubMesh.GetElemObjID(anID);
216 anElemObj2VTKID[anObjID] = aCellId;
217 aMeshID[aCellId] = anObjID;
218 *aDataArrayPtr++ = anObjID;
219 *aDataArrayPtr++ = anEntity;
223 theSource->GetCellData()->AddArray(aDataArray);
224 aDataArray->Delete();
226 vtkIdType *pts = 0, npts = 0;
227 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
228 aCellLocationsArray->SetNumberOfComponents(1);
229 aCellLocationsArray->SetNumberOfTuples(aNbCells);
230 aConnectivity->InitTraversal();
231 for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
232 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
233 theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
235 if(MYVTKDEBUG) aConnectivity->DebugOn();
237 aCellLocationsArray->Delete();
238 aCellTypesArray->Delete();
239 aConnectivity->Delete();
243 //---------------------------------------------------------------
245 GetCells(const VISU::PUnstructuredGrid& theSource,
246 const VISU::PSubProfileImpl& theSubProfile,
247 const VISU::PProfileImpl& theProfile,
248 const VISU::PMeshOnEntityImpl& theMeshOnEntity)
250 vtkIdType aNbCells = theSubProfile->myNbCells;
251 vtkIdType aCellsSize = theSubProfile->myCellsSize;
252 VISU::EGeometry aEGeom = theSubProfile->myGeom;
253 vtkIdType aNbNodes = VISUGeom2NbNodes(aEGeom);
254 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
256 INITMSG(MYDEBUG,"GetCells - aVGeom = "<<aVGeom<<endl);
258 const VISU::TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID;
260 const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
261 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.find(aEGeom);
262 if(anIter == aGeom2SubMesh.end())
263 EXCEPTION(std::runtime_error,"GetCells >> There is no elements for the GEOM("<<aEGeom<<")");
265 const VISU::TSubMeshImpl& aSubMesh = anIter->second;
266 const VISU::TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect;
268 vtkCellArray* aConnectivity = vtkCellArray::New();
269 aConnectivity->Allocate(aCellsSize,0);
270 vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
271 aCellTypesArray->SetNumberOfComponents(1);
272 aCellTypesArray->SetNumberOfTuples(aNbCells);
274 if(theSubProfile->myStatus == VISU::eAddAll){
275 VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin();
276 for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){
277 const VISU::TConnect& anArray = aCell2Connect[anId];
278 PrintCells( aConnectivity, anArray );
279 aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
284 VISU::TSubMeshID::const_iterator anIter = aSubMeshID.begin();
285 for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){
286 vtkIdType aSubId = *anIter;
287 const VISU::TConnect& anArray = aCell2Connect[aSubId];
288 PrintCells( aConnectivity, anArray );
289 aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
295 vtkIdType *pts = 0, npts = 0;
296 VTKViewer_CellLocationsArray* aCellLocationsArray = VTKViewer_CellLocationsArray::New();
298 aCellLocationsArray->SetNumberOfComponents(1);
299 aCellLocationsArray->SetNumberOfTuples(aNbCells);
300 aConnectivity->InitTraversal();
301 for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
302 aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
303 theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
306 int aNbTuples = aNbCells;
307 int anEntity = int(theMeshOnEntity->myEntity);
308 vtkIntArray *aDataArray = vtkIntArray::New();
309 aDataArray->SetName("VISU_CELLS_MAPPER");
310 aDataArray->SetNumberOfComponents(2);
311 aDataArray->SetNumberOfTuples(aNbTuples);
312 int *aDataArrayPtr = aDataArray->GetPointer(0);
313 for(int aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
314 int anObjID = theSubProfile->GetElemObjID(aTupleId);
315 *aDataArrayPtr++ = anObjID;
316 *aDataArrayPtr++ = anEntity;
318 theSource->GetCellData()->AddArray(aDataArray);
319 aDataArray->Delete();
322 aCellLocationsArray->Delete();
323 aCellTypesArray->Delete();
324 aConnectivity->Delete();
328 //---------------------------------------------------------------
330 GetMeshOnSubProfile(const VISU::PMeshImpl& theMesh,
331 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
332 const VISU::PProfileImpl& theProfile,
333 const VISU::PSubProfileImpl& theSubProfile)
335 INITMSG(MYDEBUG,"GetMeshOnSubProfile - aEGeom = "<<theSubProfile->myGeom<<endl);
337 const VISU::PUnstructuredGrid& aSource = theSubProfile->GetSource();
338 if(theSubProfile->myIsVTKDone)
341 aSource->ShallowCopy(theMesh->GetPointSet());
342 INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
343 GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
344 BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
346 theSubProfile->myIsVTKDone = true;
350 //---------------------------------------------------------------
352 GetMeshOnProfile(const VISU::PMeshImpl& theMesh,
353 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
354 const VISU::PProfileImpl& theProfile)
356 //rnv fix for bug IPAL18514 4x (CRASH after trying to build of presentation):
357 // throw exection in case if pointer on profile =0
358 if(!theProfile.get())
359 EXCEPTION(std::runtime_error,"GetMeshOnProfile: theProfile.get() == NULL");
361 // rnv fix for issue 19999:
362 // Throw exception in case if mesh on entity from profile is not equal
363 // input mesh on entity. This exception catch in tne VISU_Convertor_impl::GetTimeStampOnMesh
365 if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
366 EXCEPTION(std::runtime_error,"GetMeshOnProfile >> theProfile->myMeshOnEntity != theMeshOnEntity.get()");
368 if(theProfile->myIsVTKDone)
371 // if(theProfile->myMeshOnEntity && theProfile->myMeshOnEntity != theMeshOnEntity.get())
374 VISU::TTimerLog aTimerLog(MYDEBUG,"GetMeshOnProfile");
375 INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<std::endl);
377 const VISU::PAppendFilter& anAppendFilter = theProfile->GetFilter();
378 anAppendFilter->SetSharedPointSet(theMesh->GetPointSet());
380 if(theProfile->myIsAll){
381 vtkUnstructuredGrid* aDataSet = theMeshOnEntity->GetUnstructuredGridOutput();
382 anAppendFilter->AddInput(aDataSet);
384 const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
386 VISU::TID2ID& anElemObj2VTKID = theProfile->myElemObj2VTKID;
388 VISU::TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr;
389 aSubProfileArr.resize(aGeom2SubProfile.size());
391 VISU::TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
392 for(vtkIdType anInputID = 0, aCellID = 0; anIter != aGeom2SubProfile.end(); anIter++){
393 VISU::PSubProfileImpl aSubProfile = anIter->second;
394 if(aSubProfile->myStatus == VISU::eRemoveAll)
397 GetMeshOnSubProfile(theMesh,
402 const VISU::PUnstructuredGrid& aSource = aSubProfile->GetSource();
403 anAppendFilter->AddInput(aSource.GetPointer());
405 vtkIdType aNbCells = aSource->GetNumberOfCells();
406 for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
407 vtkIdType anObjID = aSubProfile->GetElemObjID(aCell);
408 anElemObj2VTKID[anObjID] = aCellID;
411 aSubProfileArr[anInputID++] = aSubProfile;
414 anAppendFilter->Update(); // Fix on VTK
415 theProfile->myMeshOnEntity = theMeshOnEntity.get();
416 theProfile->myNamedPointCoords = theMesh->myNamedPointCoords;
418 theProfile->myIsVTKDone = true;
423 //---------------------------------------------------------------
425 GetGaussSubMeshSource(const VISU::PPolyData& theSource,
426 const VISU::PGaussSubMeshImpl& theGaussSubMesh,
427 const VISU::PMeshOnEntityImpl& theMeshOnEntity)
429 vtkCellArray* aConnectivity = vtkCellArray::New();
430 vtkIdType aCellsSize = theGaussSubMesh->myCellsSize;
431 aConnectivity->Allocate(aCellsSize, 0);
433 vtkIdList *anIdList = vtkIdList::New();
434 anIdList->SetNumberOfIds(1);
436 const VISU::TPointCoords& aCoords = theGaussSubMesh->myPointCoords;
437 vtkIdType aNbPoints = aCoords.GetNbPoints();
438 for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
439 anIdList->SetId(0, aPointId);
440 aConnectivity->InsertNextCell(anIdList);
444 const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
445 aSource->ShallowCopy(aCoords.GetPointSet());
446 aSource->SetVerts(aConnectivity);
448 aConnectivity->Delete();
451 vtkIdType aNbTuples = aNbPoints;
452 vtkIntArray *aDataArray = vtkIntArray::New();
453 aDataArray->SetName("VISU_POINTS_MAPPER");
454 aDataArray->SetNumberOfComponents(2);
455 aDataArray->SetNumberOfTuples(aNbTuples);
456 int *aDataArrayPtr = aDataArray->GetPointer(0);
457 for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
458 vtkIdType aGlobalID = theGaussSubMesh->GetGlobalID(aTupleId);
459 *aDataArrayPtr++ = aGlobalID;
460 *aDataArrayPtr++ = 0;
462 aSource->GetPointData()->AddArray(aDataArray);
463 aDataArray->Delete();
467 vtkIdType aNbTuples = aNbPoints;
468 vtkIntArray *aDataArray = vtkIntArray::New();
469 aDataArray->SetName("VISU_CELLS_MAPPER");
470 aDataArray->SetNumberOfComponents(2);
471 aDataArray->SetNumberOfTuples(aNbTuples);
472 int *aDataArrayPtr = aDataArray->GetPointer(0);
473 for(vtkIdType aTupleId = 0; aTupleId < aNbTuples; aTupleId++){
474 VISU::TGaussPointID aGaussPointID = theGaussSubMesh->GetObjID(aTupleId);
475 *aDataArrayPtr++ = aGaussPointID.first;
476 *aDataArrayPtr++ = aGaussPointID.second;
478 aSource->GetCellData()->AddArray(aDataArray);
479 aDataArray->Delete();
484 //---------------------------------------------------------------
486 GetGaussSubMesh(const VISU::PMeshImpl& theMesh,
487 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
488 const VISU::PGaussMeshImpl& theGaussMesh,
489 const VISU::PGaussSubMeshImpl& theGaussSubMesh)
491 VISU::PGaussImpl aGauss = theGaussSubMesh->myGauss;
493 if(!theGaussSubMesh->myIsDone)
496 if(theGaussSubMesh->myIsVTKDone)
499 VISU::TTimerLog aTimerLog(MYDEBUG,"GetGaussSubMesh");
500 INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<<aGauss->myGeom<<endl);
502 const VISU::PPolyData& aSource = theGaussSubMesh->GetSource();
503 GetGaussSubMeshSource(aSource, theGaussSubMesh, theMeshOnEntity);
505 INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
506 BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
508 theGaussSubMesh->myIsVTKDone = true;
512 //---------------------------------------------------------------
514 BuildGaussMesh(const VISU::PMeshImpl& theMesh,
515 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
516 const VISU::PGaussMeshImpl& theGaussMesh)
518 if(theGaussMesh->myIsVTKDone)
521 VISU::TTimerLog aTimerLog(MYDEBUG,"BuildGaussMesh");
522 const VISU::PAppendPolyData& anAppendFilter = theGaussMesh->GetFilter();
523 const VISU::TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
524 VISU::TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
525 for(vtkIdType aStartID = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
526 VISU::PGaussSubMeshImpl aGaussSubMesh = anIter->second;
527 if(aGaussSubMesh->myStatus == VISU::eRemoveAll)
530 aGaussSubMesh->myStartID = aStartID;
532 GetGaussSubMesh(theMesh,
537 const VISU::PPolyData& aSource = aGaussSubMesh->GetSource();
538 aStartID += aSource->GetNumberOfCells();
540 anAppendFilter->AddInput(aSource.GetPointer());
542 anAppendFilter->Update(); // Fix on VTK
544 theMeshOnEntity->GetOutput()->Update();
546 vtkDataSet* aSource = anAppendFilter->GetOutput();
547 INITMSGA(MYDEBUG,0,"aNbPoints - "<<aSource->GetNumberOfPoints()<<endl);
548 BEGMSG(MYDEBUG,"aNbCells - "<<aSource->GetNumberOfCells()<<endl);
550 theGaussMesh->myIsVTKDone = true;
554 //---------------------------------------------------------------
556 PrintMemorySize(vtkUnstructuredGrid* theDataSet)
558 theDataSet->Update();
559 BEGMSG(1,"GetPoints() = "<<vtkFloatingPointType(theDataSet->GetPoints()->GetActualMemorySize()*1000)<<endl);
560 BEGMSG(1,"GetCells() = "<<vtkFloatingPointType(theDataSet->GetCells()->GetActualMemorySize()*1000)<<endl);
561 BEGMSG(1,"GetCellTypesArray() = "<<vtkFloatingPointType(theDataSet->GetCellTypesArray()->GetActualMemorySize()*1000)<<endl);
562 BEGMSG(1,"GetCellLocationsArray() = "<<vtkFloatingPointType(theDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000)<<endl);
563 theDataSet->BuildLinks();
564 BEGMSG(1,"GetCellLinks() = "<<vtkFloatingPointType(theDataSet->GetCellLinks()->GetActualMemorySize()*1000)<<endl);
565 BEGMSG(1,"GetPointData() = "<<vtkFloatingPointType(theDataSet->GetPointData()->GetActualMemorySize()*1000)<<endl);
566 BEGMSG(1,"GetCellData() = "<<vtkFloatingPointType(theDataSet->GetCellData()->GetActualMemorySize()*1000)<<endl);
567 BEGMSG(1,"GetActualMemorySize() = "<<vtkFloatingPointType(theDataSet->GetActualMemorySize()*1000)<<endl);
572 //---------------------------------------------------------------
574 ::VISU_Convertor_impl()
578 //---------------------------------------------------------------
580 ::~VISU_Convertor_impl()
584 //---------------------------------------------------------------
630 //---------------------------------------------------------------
633 ::GetMeshOnEntity(const std::string& theMeshName,
634 const VISU::TEntity& theEntity)
636 INITMSG(MYDEBUG,"GetMeshOnEntity"<<
637 "; theMeshName = '"<<theMeshName<<"'"<<
638 "; theEntity = "<<theEntity<<
641 //Cheching possibility do the query
642 TFindMeshOnEntity aFindMeshOnEntity =
643 FindMeshOnEntity(theMeshName,theEntity);
645 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
646 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
652 if(!aMeshOnEntity->myIsVTKDone){
653 VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetMeshOnEntity");
654 const VISU::PAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter();
655 if(MYVTKDEBUG) anAppendFilter->DebugOn();
657 LoadMeshOnEntity(aMesh,aMeshOnEntity);
658 anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
660 const VISU::TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
661 VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
663 VISU::TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID;
664 VISU::TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr;
665 aSubMeshArr.resize(aGeom2SubMesh.size());
667 for(vtkIdType anID = 0, aCellID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){
668 VISU::EGeometry aEGeom = anIter->first;
669 vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
670 VISU::PSubMeshImpl aSubMesh = anIter->second;
672 aSubMesh->CopyStructure( aMesh );
674 aSubMesh->myStartID = aCellID;
676 const VISU::PUnstructuredGrid& aSource = aSubMesh->GetSource();
677 GetCellsOnSubMesh(aSource, aMeshOnEntity, aSubMesh, aVGeom);
678 anAppendFilter->AddInput(aSource.GetPointer());
680 vtkIdType aNbCells = aSource->GetNumberOfCells();
681 for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
682 vtkIdType anObjID = aSubMesh->GetElemObjID(aCell);
683 anElemObj2VTKID[anObjID] = aCellID;
686 aSubMeshArr[anID] = aSubMesh;
689 aMeshOnEntity->CopyStructure( aMesh );
691 aMeshOnEntity->myIsVTKDone = true;
693 if(MYDEBUGWITHFILES){
694 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
695 std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
696 aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-MeshOnEntity.vtk";
697 VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
701 GetMeshOnEntitySize(theMeshName,theEntity);
702 PrintMemorySize(anAppendFilter->GetOutput());
712 return aMeshOnEntity;
716 //---------------------------------------------------------------
717 VISU::PUnstructuredGridIDMapper
719 ::GetFamilyOnEntity(const std::string& theMeshName,
720 const VISU::TEntity& theEntity,
721 const std::string& theFamilyName)
723 INITMSG(MYDEBUG,"GetFamilyOnEntity"<<
724 "; theMeshName = '"<<theMeshName<<"'"<<
725 "; theEntity = "<<theEntity<<
726 "; theFamilyName = '"<<theFamilyName<<"'"<<
729 //Cheching possibility do the query
730 TFindFamilyOnEntity aFindFamilyOnEntity =
731 FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
733 VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);;
734 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
735 VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
741 if ( !aFamily->myIsVTKDone ) {
742 GetMeshOnEntity( theMeshName, theEntity );
744 LoadFamilyOnEntity( aMesh, aMeshOnEntity, aFamily );
746 aFamily->CopyStructure( aMesh );
748 const VISU::PUnstructuredGrid& aSource = aFamily->GetSource();
749 GetCellsOnFamily( aSource, aMeshOnEntity, aFamily );
751 aFamily->myIsVTKDone = true;
753 if(MYDEBUGWITHFILES){
754 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
755 std::string aFamilyName = (const char*)QString(theFamilyName.c_str()).simplified().toLatin1();
756 std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
757 aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-FamilyOnEntity.vtk";
758 VISU::WriteToFile(aSource.GetPointer(),aFileName);
762 GetFamilyOnEntitySize(theMeshName,theEntity,theFamilyName);
763 PrintMemorySize(aSource.GetPointer());
777 //---------------------------------------------------------------
778 VISU::PUnstructuredGridIDMapper
780 ::GetMeshOnGroup(const std::string& theMeshName,
781 const std::string& theGroupName)
783 INITMSG(MYDEBUG,"GetMeshOnGroup\n");
785 "- theMeshName = '"<<theMeshName<<
786 "'; theGroupName = '"<<theGroupName<<"'"<<
789 //Cheching possibility do the query
790 TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
791 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
792 VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
798 if(!aGroup->myIsVTKDone){
799 const VISU::PAppendFilter& anAppendFilter = aGroup->GetFilter();
800 const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
802 LoadMeshOnGroup(aMesh,aFamilySet);
803 anAppendFilter->SetSharedPointSet(aMesh->GetPointSet());
805 VISU::TFamilySet::const_iterator anIter = aFamilySet.begin();
807 VISU::TID2ID& anElemObj2VTKID = aGroup->myElemObj2VTKID;
808 VISU::TFamilyArr& aFamilyArr = aGroup->myFamilyArr;
809 aFamilyArr.resize(aFamilySet.size());
811 for(vtkIdType anID = 0; anIter != aFamilySet.end(); anIter++, anID++){
812 VISU::PFamilyImpl aFamily = *anIter;
813 const std::string& aFamilyName = aFamily->myName;
814 const VISU::TEntity& anEntity = aFamily->myEntity;
816 VISU::PIDMapper anIDMapper = GetFamilyOnEntity(theMeshName,anEntity,aFamilyName);
817 vtkDataSet* anOutput = anIDMapper->GetOutput();
818 anAppendFilter->AddInput(anOutput);
820 vtkIdType aStartID = anElemObj2VTKID.size();
821 vtkIdType aNbCells = anOutput->GetNumberOfCells();
822 for(vtkIdType aCellID = 0; aCellID < aNbCells; aCellID++){
823 anElemObj2VTKID[aFamily->GetElemObjID(aCellID)] = aStartID + aCellID;
825 aFamilyArr[anID] = aFamily;
828 aGroup->CopyStructure( aMesh );
830 aGroup->myIsVTKDone = true;
832 if(MYDEBUGWITHFILES){
833 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
834 std::string aGroupName = (const char*)QString(theGroupName.c_str()).simplified().toLatin1();
835 std::string aFileName = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
836 aFileName += aMeshName + "-" + aGroupName + "-MeshOnGroup.vtk";
837 VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
850 //---------------------------------------------------------------
853 ::GetTimeStampOnProfile( const VISU::PMeshImpl& theMesh,
854 const VISU::PMeshOnEntityImpl& theMeshOnEntity,
855 const VISU::PFieldImpl& theField,
856 const VISU::PValForTimeImpl& theValForTime,
857 const VISU::PUnstructuredGridIDMapperImpl& theUnstructuredGridIDMapper,
858 const VISU::PProfileImpl& theProfile,
859 const VISU::TEntity& theEntity )
861 LoadMeshOnEntity( theMesh, theMeshOnEntity );
862 GetMeshOnEntity( theMeshOnEntity->myMeshName, theMeshOnEntity->myEntity );
863 GetMeshOnProfile( theMesh, theMeshOnEntity, theProfile );
865 theUnstructuredGridIDMapper->myIDMapper = theProfile;
867 if ( theMeshOnEntity->myEntity == VISU::NODE_ENTITY ) {
868 // add geometry elements to output,
869 // if timestamp on NODE_ENTITY and
870 // on profiles with status eAddPart
871 const VISU::TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
872 VISU::TGeom2SubProfile::const_iterator aSubProfileIter = aGeom2SubProfile.begin();
873 for ( ; aSubProfileIter != aGeom2SubProfile.end(); aSubProfileIter++ ) {
874 const VISU::EGeometry& aGeom = aSubProfileIter->first;
875 const VISU::PSubProfileImpl& aSubProfile = aSubProfileIter->second;
876 if ( aSubProfile->myStatus == VISU::eAddPart && aGeom == VISU::ePOINT1 ) {
877 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
878 VISU::TMeshOnEntityMap::const_reverse_iterator aMeshOnEntityIter = aMeshOnEntityMap.rbegin();
879 for( ; aMeshOnEntityIter != aMeshOnEntityMap.rend(); aMeshOnEntityIter++ ) {
880 VISU::TEntity anEntity = aMeshOnEntityIter->first;
881 if ( anEntity == VISU::NODE_ENTITY )
883 VISU::PNamedIDMapper aNamedIDMapper = GetMeshOnEntity( theMesh->myName, anEntity );
884 if( aNamedIDMapper ) {
885 theUnstructuredGridIDMapper->SetReferencedMesh( aNamedIDMapper );
886 VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
887 VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
889 return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
896 VISU::PUnstructuredGrid aSource = theUnstructuredGridIDMapper->GetSource();
897 VISU::GetTimeStampOnProfile( aSource, theField, theValForTime, theEntity );
899 return theUnstructuredGridIDMapper->GetUnstructuredGridOutput();
903 //---------------------------------------------------------------
904 VISU::PUnstructuredGridIDMapper
906 ::GetTimeStampOnMesh( const std::string& theMeshName,
907 const VISU::TEntity& theEntity,
908 const std::string& theFieldName,
911 INITMSG(MYDEBUG,"GetTimeStampOnMesh"<<
912 "; theMeshName = '"<<theMeshName<<"'"<<
913 "; theEntity = "<<theEntity<<
914 "; theFieldName = '"<<theFieldName<<"'"<<
915 "; theStampsNum = "<<theStampsNum<<
918 //Cheching possibility do the query
919 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
924 VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
925 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
926 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
927 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
928 VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
931 VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
935 if(!anUnstructuredGridIDMapper->myIsVTKDone){
936 VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnMesh");
937 LoadValForTimeOnMesh(aMesh, aMeshOnEntity, aField, aValForTime);
939 vtkUnstructuredGrid* anOutput = NULL;
941 anOutput = GetTimeStampOnProfile(aMesh,
945 anUnstructuredGridIDMapper,
946 aValForTime->myProfile,
947 aMeshOnEntity->myEntity);
948 }catch(std::exception& exc){
949 MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
950 anOutput = GetTimeStampOnProfile(aMesh,
954 anUnstructuredGridIDMapper,
955 aValForTime->myProfile,
956 aVTKMeshOnEntity->myEntity);
959 anUnstructuredGridIDMapper->CopyStructure( aMesh );
961 anUnstructuredGridIDMapper->myIsVTKDone = true;
963 if(MYDEBUGWITHFILES){
964 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
965 std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1();
966 std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
967 std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
968 aFieldName + dtos("-%d", theStampsNum) + "-TimeStampOnMesh.vtk";
969 VISU::WriteToFile(anOutput,aFileName);
972 GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
974 if(theEntity == VISU::NODE_ENTITY)
975 BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
977 BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
978 BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
982 }catch(std::exception& exc){
989 return anUnstructuredGridIDMapper;
993 //---------------------------------------------------------------
994 VISU::PGaussPtsIDMapper
996 ::GetTimeStampOnGaussPts(const std::string& theMeshName,
997 const VISU::TEntity& theEntity,
998 const std::string& theFieldName,
1001 INITMSG(MYDEBUG,"GetTimeStampOnGaussPts"<<
1002 "; theMeshName = '"<<theMeshName<<"'"<<
1003 "; theEntity = "<<theEntity<<
1004 "; theFieldName = '"<<theFieldName<<"'"<<
1005 "; theStampsNum = "<<theStampsNum<<
1008 if(theEntity == VISU::NODE_ENTITY)
1009 EXCEPTION(std::runtime_error, "It is impossible to reate Gauss Points on NODE_ENTITY !!!");
1011 //Cheching possibility do the query
1012 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1017 VISU::PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
1018 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
1019 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
1020 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1021 VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
1024 VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
1028 if(!aGaussPtsIDFilter->myIsVTKDone){
1029 VISU::TTimerLog aTimerLog(MYDEBUG,"VISU_Convertor_impl::GetTimeStampOnGaussPts");
1030 LoadValForTimeOnGaussPts(aMesh, aMeshOnEntity, aField, aValForTime);
1032 GetMeshOnEntity(aVTKMeshOnEntity->myMeshName, aVTKMeshOnEntity->myEntity);
1034 VISU::PProfileImpl aProfile = aValForTime->myProfile;
1035 GetMeshOnProfile(aMesh, aVTKMeshOnEntity, aProfile);
1037 VISU::PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh;
1038 if(!aGaussMesh->myIsVTKDone){
1039 BuildGaussMesh(aMesh, aVTKMeshOnEntity, aGaussMesh);
1040 aGaussMesh->myParent = aProfile.get();
1041 aGaussMesh->myIsVTKDone = true;
1044 aGaussPtsIDFilter->myIDMapper = aGaussMesh;
1045 aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh;
1046 VISU::PPolyData aSource = aGaussPtsIDFilter->GetSource();
1047 VISU::GetTimeStampOnGaussMesh(aSource, aField, aValForTime);
1048 vtkPolyData* anOutput = aGaussPtsIDFilter->GetPolyDataOutput();
1050 aGaussPtsIDFilter->myIsVTKDone = true;
1052 if(MYDEBUGWITHFILES){
1053 std::string aMeshName = (const char*)QString(theMeshName.c_str()).simplified().toLatin1();
1054 std::string aFieldName = (const char*)QString(theFieldName.c_str()).simplified().toLatin1();
1055 std::string aPrefix = std::string(getenv("HOME"))+"/"+getenv("USER")+"-";
1056 std::string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
1057 aFieldName + dtos("-%d",theStampsNum) + "-TimeStampOnGaussPts.vtk";
1058 VISU::WriteToFile(anOutput, aFileName);
1061 GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum);
1063 if(theEntity == VISU::NODE_ENTITY)
1064 BEGMSG(MYVTKDEBUG,"GetPointData() = "<<vtkFloatingPointType(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
1066 BEGMSG(MYVTKDEBUG,"GetCellData() = "<<vtkFloatingPointType(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
1067 BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<vtkFloatingPointType(anOutput->GetActualMemorySize()*1000)<<endl);
1071 }catch(std::exception& exc){
1078 return aGaussPtsIDFilter;
1081 //---------------------------------------------------------------
1084 ::FindMesh(const std::string& theMeshName)
1087 VISU::TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName);
1088 if(aMeshMapIter == myMeshMap.end())
1089 EXCEPTION(std::runtime_error,"FindMesh >> There is no mesh with the name - '"<<theMeshName<<"'!!!");
1091 VISU::PMeshImpl aMesh = aMeshMapIter->second;
1096 //---------------------------------------------------------------
1097 VISU_Convertor_impl::TFindMeshOnEntity
1099 ::FindMeshOnEntity(const std::string& theMeshName,
1100 const VISU::TEntity& theEntity)
1102 VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1103 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1104 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
1105 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1106 EXCEPTION(std::runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
1108 VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
1110 return TFindMeshOnEntity(aMesh,
1115 //---------------------------------------------------------------
1116 VISU_Convertor_impl::TFindFamilyOnEntity
1118 ::FindFamilyOnEntity(const std::string& theMeshName,
1119 const VISU::TEntity& theEntity,
1120 const std::string& theFamilyName)
1122 if(theFamilyName != ""){
1123 VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1124 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1125 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
1126 if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
1127 EXCEPTION(std::runtime_error,"FindFamilyOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
1129 VISU::PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
1131 VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1132 VISU::TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName);
1133 if(aFamilyMapIter != aFamilyMap.end()){
1134 const VISU::PFamily& aFamily = aFamilyMapIter->second;
1135 return TFindFamilyOnEntity(aMesh,
1140 return TFindFamilyOnEntity();
1144 //---------------------------------------------------------------
1150 const VISU::TMeshMap& aMeshMap = GetMeshMap();
1151 VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
1152 for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
1153 const std::string& aMeshName = aMeshMapIter->first;
1154 const VISU::PMesh aMesh = aMeshMapIter->second;
1155 const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1156 VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
1158 aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
1159 for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
1160 const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
1161 const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
1162 const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1163 VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
1164 for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
1165 const std::string& aFieldName = aFieldMapIter->first;
1166 const VISU::PField aField = aFieldMapIter->second;
1167 const VISU::TValField& aValField = aField->myValField;
1168 VISU::TValField::const_iterator aValFieldIter = aValField.begin();
1169 for(; aValFieldIter != aValField.end(); aValFieldIter++){
1170 int aTimeStamp = aValFieldIter->first;
1171 aResult += GetTimeStampSize(aMeshName,anEntity,aFieldName,aTimeStamp);
1175 const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1176 VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
1177 for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
1178 const std::string& aGroupName = aGroupMapIter->first;
1179 aResult += GetMeshOnGroupSize(aMeshName,aGroupName);
1182 const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
1183 VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
1184 for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
1185 const std::string& aFamilyName = aFamilyMapIter->first;
1186 aResult += GetFamilyOnEntitySize(aMeshName,anEntity,aFamilyName);
1188 //Import mesh on entity
1189 aResult += GetMeshOnEntitySize(aMeshName,anEntity);
1192 MSG(MYDEBUG,"GetSize - aResult = "<<vtkFloatingPointType(aResult));
1197 //---------------------------------------------------------------
1200 ::GetMeshOnEntitySize(const std::string& theMeshName,
1201 const VISU::TEntity& theEntity)
1203 TFindMeshOnEntity aFindMeshOnEntity =
1204 FindMeshOnEntity(theMeshName, theEntity);
1206 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
1207 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1209 size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1210 size_t aNbCells = aMeshOnEntity->myNbCells;
1211 size_t aCellsSize = aMeshOnEntity->myCellsSize;
1213 size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
1214 size_t aTypesSize = aNbCells*sizeof(char);
1215 size_t aLocationsSize = aNbCells*sizeof(int);
1216 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1217 size_t aLinksSize = aMesh->GetNbPoints() *
1218 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
1220 size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
1222 MSG(MYDEBUG,"GetMeshOnEntitySize "<<
1223 "- aResult = "<<vtkFloatingPointType(aResult)<<
1224 "; theMeshName = '"<<theMeshName<<"'"<<
1225 "; theEntity = "<<theEntity);
1227 INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
1228 BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
1229 BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
1230 BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
1231 BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
1234 aResult = size_t(aResult*ERR_SIZE_CALC);
1239 //---------------------------------------------------------------
1242 ::GetFamilyOnEntitySize(const std::string& theMeshName,
1243 const VISU::TEntity& theEntity,
1244 const std::string& theFamilyName)
1246 TFindFamilyOnEntity aFindFamilyOnEntity =
1247 FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
1248 VISU::PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);
1249 VISU::PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
1250 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
1252 size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1253 size_t aNbCells = aFamily->myNbCells;
1254 size_t aCellsSize = aFamily->myCellsSize;
1256 size_t aConnectivitySize = aCellsSize*sizeof(vtkIdType);
1257 size_t aTypesSize = aNbCells*sizeof(char);
1258 size_t aLocationsSize = aNbCells*sizeof(int);
1259 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1260 size_t aLinksSize = aMesh->GetNbPoints() *
1261 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
1263 size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
1265 MSG(MYDEBUG,"GetFamilyOnEntitySize "<<
1266 "- aResult = "<<vtkFloatingPointType(aResult)<<
1267 "; theMeshName = '"<<theMeshName<<"'"<<
1268 "; theEntity = "<<theEntity<<
1269 "; theFamilyName = '"<<theFamilyName<<"'");
1271 INITMSG(MYVTKDEBUG,"- aPointsSize = "<<vtkFloatingPointType(aPointsSize)<<"\n");
1272 BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<vtkFloatingPointType(aConnectivitySize)<<"\n");
1273 BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<vtkFloatingPointType(aTypesSize)<<"\n");
1274 BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<vtkFloatingPointType(aLocationsSize)<<"\n");
1275 BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<vtkFloatingPointType(aLinksSize)<<"\n");
1278 aResult = size_t(aResult*ERR_SIZE_CALC);
1283 //---------------------------------------------------------------
1284 VISU_Convertor_impl::TFindMeshOnGroup
1286 ::FindMeshOnGroup(const std::string& theMeshName,
1287 const std::string& theGroupName)
1289 VISU::PMeshImpl aMesh = FindMesh(theMeshName);
1290 VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
1291 VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName);
1292 if(aGroupMapIter == aGroupMap.end())
1293 EXCEPTION(std::runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<<theGroupName<<"'");
1295 VISU::PGroupImpl aGroup = aGroupMapIter->second;
1296 return TFindMeshOnGroup(aMesh,aGroup);
1302 ::GetMeshOnGroupSize(const std::string& theMeshName,
1303 const std::string& theGroupName)
1305 TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
1306 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
1307 VISU::PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
1309 size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
1310 VISU::TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells();
1311 size_t aNbCells = aNbASizeCells.first;
1312 size_t aCellsSize = aNbASizeCells.second;
1313 size_t aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
1314 size_t aLocationsSize = aNbCells*sizeof(int);
1315 vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
1316 size_t aLinksSize = aMesh->GetNbPoints() *
1317 (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
1319 size_t aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
1321 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aPointsSize = "<<vtkFloatingPointType(aPointsSize));
1322 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<vtkFloatingPointType(aConnectivityAndTypesSize));
1323 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLocationsSize = "<<vtkFloatingPointType(aLocationsSize));
1324 MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLinksSize = "<<vtkFloatingPointType(aLinksSize));
1326 MSG(MYDEBUG,"GetMeshOnGroupSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"
1327 <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
1329 aResult = size_t(aResult*ERR_SIZE_CALC);
1334 VISU_Convertor_impl::TFindField
1336 ::FindField(const std::string& theMeshName,
1337 const VISU::TEntity& theEntity,
1338 const std::string& theFieldName)
1340 TFindMeshOnEntity aFindMeshOnEntity =
1341 FindMeshOnEntity(theMeshName,theEntity);
1343 VISU::PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
1344 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
1346 VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
1347 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
1348 if ( theEntity == VISU::NODE_ENTITY ) {
1349 if(aMeshOnEntityMap.find( VISU::CELL_ENTITY ) != aMeshOnEntityMap.end())
1350 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::CELL_ENTITY ];
1351 else if (aMeshOnEntityMap.find( VISU::FACE_ENTITY ) != aMeshOnEntityMap.end() )
1352 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::FACE_ENTITY ];
1353 else if (aMeshOnEntityMap.find( VISU::EDGE_ENTITY ) != aMeshOnEntityMap.end() )
1354 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::EDGE_ENTITY ];
1355 else if ( aMeshOnEntityMap.find( VISU::NODE_ENTITY ) != aMeshOnEntityMap.end() )
1356 aVTKMeshOnEntity = aMeshOnEntityMap[ VISU::NODE_ENTITY ];
1358 aVTKMeshOnEntity = aMeshOnEntity;
1360 VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
1361 VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find( theFieldName );
1362 if(aFieldIter == aFieldMap.end())
1363 EXCEPTION(std::runtime_error,"FindField >> There is no field on the mesh!!!");
1365 VISU::PFieldImpl aField = aFieldIter->second;
1367 return TFindField( aMesh,
1376 ::GetFieldOnMeshSize(const std::string& theMeshName,
1377 const VISU::TEntity& theEntity,
1378 const std::string& theFieldName)
1380 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1381 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
1382 VISU::PFieldImpl aField = boost::get<3>(aFindField);
1384 size_t aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
1385 size_t aFieldOnMeshSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType)*aField->myValField.size()*ERR_SIZE_CALC);
1386 size_t aResult = aMeshSize + aFieldOnMeshSize;
1388 MSG(MYVTKDEBUG,"GetFieldOnMeshSize - aFieldOnMeshSize = "<<vtkFloatingPointType(aFieldOnMeshSize));
1389 MSG(MYDEBUG,"GetFieldOnMeshSize - aResult = "<<vtkFloatingPointType(aResult)<<"; theMeshName = '"<<theMeshName<<
1390 "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
1396 VISU_Convertor_impl::TFindTimeStamp
1398 ::FindTimeStamp(const std::string& theMeshName,
1399 const VISU::TEntity& theEntity,
1400 const std::string& theFieldName,
1403 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1404 VISU::PField aField = boost::get<3>(aFindField);
1406 VISU::TValField& aValField = aField->myValField;
1407 VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum);
1408 if(aValFieldIter == aValField.end())
1409 EXCEPTION(std::runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!");
1411 VISU::PMeshImpl aMesh = boost::get<0>(aFindField);
1412 VISU::PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField);
1413 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
1414 VISU::PValForTimeImpl aValForTime = aValFieldIter->second;
1416 return TFindTimeStamp(aMesh,
1426 ::GetTimeStampSize(const std::string& theMeshName,
1427 const VISU::TEntity& theEntity,
1428 const std::string& theFieldName,
1431 TFindTimeStamp aFindTimeStamp =
1432 FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
1433 VISU::PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
1434 VISU::PFieldImpl aField = boost::get<3>(aFindTimeStamp);
1436 size_t aMeshSize = GetMeshOnEntitySize(theMeshName, aVTKMeshOnEntity->myEntity);
1437 size_t aTimeStampSize = size_t(aField->myDataSize*sizeof(vtkFloatingPointType) * ERR_SIZE_CALC);
1438 size_t aResult = aMeshSize + aTimeStampSize;
1440 MSG(MYDEBUG && MYVTKDEBUG,"GetTimeStampSize - aTimeStampSize = "<<vtkFloatingPointType(aTimeStampSize));
1441 MSG(MYDEBUG,"GetTimeStampSize - aResult = "<<vtkFloatingPointType(aResult)<<
1442 "; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
1443 "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
1451 ::GetTimeStampOnMeshSize(const std::string& theMeshName,
1452 const VISU::TEntity& theEntity,
1453 const std::string& theFieldName,
1454 int theTimeStampNumber,
1455 bool& theIsEstimated)
1459 //Cheching possibility do the query
1460 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1463 theTimeStampNumber);
1465 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1466 VISU::PUnstructuredGridIDMapperImpl anUnstructuredGridIDMapper = aValForTime->myUnstructuredGridIDMapper;
1467 if(anUnstructuredGridIDMapper->myIsVTKDone){
1468 VISU::PIDMapper anIDMapper = GetTimeStampOnMesh(theMeshName,
1471 theTimeStampNumber);
1472 anIDMapper->GetOutput();
1473 aSize += anIDMapper->GetMemorySize();
1475 aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
1477 theIsEstimated = !(anUnstructuredGridIDMapper->myIsVTKDone);
1479 //cout<<"VISU_Convertor_impl::GetTimeStampOnMeshSize - "<<aSize<<"; "<<(anIDMapperFilter->myIsVTKDone)<<endl;
1486 ::GetTimeStampOnGaussPtsSize(const std::string& theMeshName,
1487 const VISU::TEntity& theEntity,
1488 const std::string& theFieldName,
1489 int theTimeStampNumber,
1490 bool& theIsEstimated)
1494 //Cheching possibility do the query
1495 TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
1498 theTimeStampNumber);
1500 VISU::PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
1501 VISU::PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
1502 if(aGaussPtsIDFilter->myIsVTKDone){
1503 VISU::PGaussPtsIDMapper aGaussPtsIDMapper = GetTimeStampOnGaussPts(theMeshName,
1506 theTimeStampNumber);
1507 aGaussPtsIDMapper->GetOutput();
1508 aSize += aGaussPtsIDMapper->GetMemorySize();
1510 aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theTimeStampNumber);
1512 theIsEstimated = !(aGaussPtsIDFilter->myIsVTKDone);
1514 //cout<<"VISU_Convertor_impl::GetTimeStampOnGaussPtsSize - "<<aSize<<"; "<<(aGaussPtsIDFilter->myIsVTKDone)<<endl;
1521 ::GetField(const std::string& theMeshName,
1522 VISU::TEntity theEntity,
1523 const std::string& theFieldName)
1525 TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
1526 VISU::PField aField = boost::get<3>(aFindField);
1531 const VISU::PValForTime
1533 ::GetTimeStamp(const std::string& theMeshName,
1534 const VISU::TEntity& theEntity,
1535 const std::string& theFieldName,
1538 TFindTimeStamp aFindTimeStamp =
1539 FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
1540 VISU::PValForTime aValForTime = boost::get<4>(aFindTimeStamp);