#include "VISU_Convertor_impl.hxx"
#include "VISU_ConvertorUtils.hxx"
+#include "VTKViewer_AppendFilter.h"
+#include "VISU_MergeFilter.hxx"
+
+#include <vtkPoints.h>
+#include <vtkUnstructuredGrid.h>
#include <vtkIdList.h>
#include <vtkCellType.h>
#include <vtkCellData.h>
#include <vtkCellLinks.h>
-#include <vtkMergeDataObjectFilter.h>
-
-#include <vtkUnstructuredGridWriter.h>
#include <qstring.h>
#include <qfileinfo.h>
#include <memory>
using namespace std;
+using namespace VISU;
static float ERR_SIZE_CALC = 1.00;
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
+//#define _DEXCEPT_
#else
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
#endif
-void VISU::WriteToFile(vtkUnstructuredGrid* theDataSet, const string& theFileName){
- //vtkUnstructuredGridWriter* aWriter = vtkUnstructuredGridWriter::New();
- //if(MYVTKDEBUG) aWriter->DebugOn();
- ////aWriter->SetFileType(VTK_BINARY);
- //aWriter->SetFileName(theFileName.c_str());
- //aWriter->SetInput(theDataSet);
- //aWriter->Write();
- //aWriter->Delete();
-}
+namespace VISU
+{
+ //---------------------------------------------------------------
+ TIsVTKDone::TIsVTKDone():
+ myIsVTKDone(false),
+ myIsDone(false)
+ {}
-enum ECoordName{eX, eY, eZ, eNone};
-typedef VISU::TMesh::TCoord (*TGetCoord)(const VISU::TMesh::TPointsCoord&, int);
-template<ECoordName TheCoordId>
-VISU::TMesh::TCoord GetCoord(const VISU::TMesh::TPointsCoord& thePointsCoord,
- int theStartPos)
-{
- return thePointsCoord[theStartPos+TheCoordId];
+ //---------------------------------------------------------------
+ TSizeCounter::TSizeCounter():
+ myNbCells(0),
+ myCellsSize(0)
+ {}
+
+
+ //---------------------------------------------------------------
+ TSource::TSource()
+ {}
+
+ const TVTKSource&
+ TSource
+ ::GetSource() const
+ {
+ if(!mySource.GetPointer()){
+ mySource = vtkUnstructuredGrid::New();
+ mySource->Delete();
+ }
+ return mySource;
+ }
+
+ TVTKOutput*
+ TSource
+ ::GetVTKOutput()
+ {
+ return GetSource().GetPointer();
+ }
+
+
+ //---------------------------------------------------------------
+ TAppendFilter::TAppendFilter()
+ {}
+
+ const TVTKAppendFilter&
+ TAppendFilter
+ ::GetFilter() const
+ {
+ if(!myFilter.GetPointer()){
+ myFilter = VTKViewer_AppendFilter::New();
+ myFilter->Delete();
+ myFilter->SetDoMappingFlag(true);
+ }
+ return myFilter;
+ }
+
+ TVTKOutput*
+ TAppendFilter
+ ::GetVTKOutput()
+ {
+ GetFilter()->Update();
+ return GetFilter()->GetOutput();
+ }
+
+
+ //---------------------------------------------------------------
+ TMergeFilter::TMergeFilter()
+ {}
+
+ const TVTKMergeFilter&
+ TMergeFilter
+ ::GetFilter() const
+ {
+ if(!myFilter.GetPointer()){
+ myFilter = VISU_MergeFilter::New();
+ myFilter->Delete();
+ }
+ return myFilter;
+ }
+
+ TVTKOutput*
+ TMergeFilter
+ ::GetVTKOutput()
+ {
+ GetFilter()->Update();
+ return GetFilter()->GetUnstructuredGridOutput();
+ }
+
+
+ //---------------------------------------------------------------
+ TPointCoords
+ ::TPointCoords():
+ myPoints(vtkPoints::New())
+ {
+ myPoints->Delete();
+ }
+
+ void
+ TPointCoords
+ ::Init(vtkIdType theNbPoints,
+ vtkIdType theDim)
+ {
+ myDim = theDim;
+ myNbPoints = theNbPoints;
+ myCoord.resize(theNbPoints*theDim);
+ myPoints->SetNumberOfPoints(theNbPoints);
+ }
+
+ TCCoordSlice
+ TPointCoords
+ ::GetCoordSlice(vtkIdType theNodeId) const
+ {
+ return TCCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1));
+ }
+
+ TCoordSlice
+ TPointCoords
+ ::GetCoordSlice(vtkIdType theNodeId)
+ {
+ return TCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1));
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ TNamedPointCoords
+ ::Init(vtkIdType theNbPoints,
+ vtkIdType theDim,
+ const TVectorID& theVectorID)
+ {
+ TPointCoords::Init(theNbPoints,theDim);
+ myPointsDim.resize(theDim);
+ myVectorID = theVectorID;
+
+ for(vtkIdType anID = 0, anEnd = theVectorID.size(); anID < anEnd; anID++)
+ myObj2VTKID[theVectorID[anID]] = anID;
+ }
+
+ std::string&
+ TNamedPointCoords
+ ::GetName(vtkIdType theDim)
+ {
+ return myPointsDim[theDim];
+ }
+
+ const std::string&
+ TNamedPointCoords
+ ::GetName(vtkIdType theDim) const
+ {
+ return myPointsDim[theDim];
+ }
+
+ vtkIdType
+ TNamedPointCoords
+ ::GetObjID(vtkIdType theID) const
+ {
+ if(myVectorID.empty())
+ return theID;
+ else
+ return myVectorID[theID];
+ }
+
+
+ vtkIdType
+ TNamedPointCoords
+ ::GetVTKID(vtkIdType theID) const
+ {
+ if(myObj2VTKID.empty())
+ return theID;
+ else{
+ TObj2VTKID::const_iterator anIter = myObj2VTKID.find(theID);
+ if(anIter != myObj2VTKID.end())
+ return anIter->second;
+ }
+ return -1;
+ }
+
+ std::string
+ TNamedPointCoords
+ ::GetNodeName(vtkIdType theObjID) const
+ {
+ return "";
+ }
+
+ //---------------------------------------------------------------
+ TMeshImpl::TMeshImpl():
+ myPoints(vtkPoints::New()),
+ myNbPoints(0)
+ {
+ myPoints->Delete();
+ }
+
+
+ //---------------------------------------------------------------
+ TSubProfileImpl::TSubProfileImpl():
+ myStatus(eNone),
+ myGeom(eNONE)
+ {}
+
+
+ vtkIdType
+ TSubProfileImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return theID;
+ }
+
+
+ //---------------------------------------------------------------
+ bool
+ operator<(const PSubProfile& theLeft, const PSubProfile& theRight)
+ {
+ PSubProfileImpl aLeft(theLeft), aRight(theRight);
+
+ if(aLeft->myGeom != aRight->myGeom)
+ return aLeft->myGeom < aRight->myGeom;
+
+ if(aLeft->myStatus != aRight->myStatus)
+ return aLeft->myStatus < aRight->myStatus;
+
+ return aLeft->myName < aRight->myName;
+ }
+
+
+ //---------------------------------------------------------------
+ TProfileImpl::TProfileImpl():
+ myIsAll(true),
+ myMeshOnEntity(NULL)
+ {}
+
+ vtkIdType
+ TProfileImpl
+ ::GetNodeObjID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetObjID(theID);
+ }
+
+ vtkIdType
+ TProfileImpl
+ ::GetNodeVTKID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetVTKID(theID);
+ }
+
+ float*
+ TProfileImpl
+ ::GetNodeCoord(vtkIdType theObjID)
+ {
+ if(myIsAll)
+ return myMeshOnEntity->GetNodeCoord(theObjID);
+
+ vtkIdType aVtkID = GetNodeVTKID(theObjID);
+ return GetFilter()->GetOutput()->GetPoint(aVtkID);
+ }
+
+ vtkIdType
+ TProfileImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ if(myIsAll)
+ return myMeshOnEntity->GetElemObjID(theID);
+
+ vtkIdType anInputID, aStartID, anInputDataSetID;
+ const TVTKAppendFilter& anAppendFilter = GetFilter();
+ anAppendFilter->GetCellInputID(theID,anInputID,aStartID,anInputDataSetID);
+ PSubProfileImpl aSubProfileImpl = mySubProfileArr[anInputDataSetID];
+ return aSubProfileImpl->GetElemObjID(anInputID);
+ }
+
+ vtkIdType
+ TProfileImpl
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ if(myIsAll)
+ return myMeshOnEntity->GetElemVTKID(theID);
+
+ if(myElemObj2VTKID.empty())
+ return theID;
+ else{
+ TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
+ if(anIter != myElemObj2VTKID.end())
+ return anIter->second;
+ }
+ return -1;
+ }
+
+ vtkCell*
+ TProfileImpl
+ ::GetElemCell(vtkIdType theObjID)
+ {
+ if(myIsAll)
+ return myMeshOnEntity->GetElemCell(theObjID);
+
+ vtkIdType aVtkID = GetElemVTKID(theObjID);
+ return GetFilter()->GetOutput()->GetCell(aVtkID);
+ }
+
+ TVTKOutput*
+ TProfileImpl
+ ::GetVTKOutput()
+ {
+ const TVTKAppendFilter& anAppendFilter = GetFilter();
+ return anAppendFilter->GetOutput();
+ }
+
+ std::string
+ TProfileImpl
+ ::GetNodeName(vtkIdType theObjID) const
+ {
+ return myNamedPointCoords->GetNodeName(theObjID);
+ }
+
+ std::string
+ TProfileImpl
+ ::GetElemName(vtkIdType theObjID) const
+ {
+ if(myIsAll)
+ return myMeshOnEntity->GetElemName(theObjID);
+
+ vtkIdType aVTKId = GetElemVTKID(theObjID);
+ vtkIdType anInputID, aStartID, anInputDataSetID;
+ const TVTKAppendFilter& anAppendFilter = GetFilter();
+ anAppendFilter->GetCellInputID(aVTKId,anInputID,aStartID,anInputDataSetID);
+ PSubProfileImpl aSubProfileImpl = mySubProfileArr[anInputDataSetID];
+ vtkIdType anEntityObjId = aSubProfileImpl->GetElemObjID(anInputID);
+ return myMeshOnEntity->GetElemName(anEntityObjId);
+ }
+
+
+ //---------------------------------------------------------------
+ TVTKOutput*
+ TIDMapperFilter
+ ::GetVTKOutput()
+ {
+ if(!myFilter.GetPointer()){
+ const TVTKAppendFilter& anAppendFilter = myIDMapper.GetFilter();
+ TVTKOutput* aGeometry = anAppendFilter->GetOutput();
+
+ const TVTKSource& aSource = mySource.GetSource();
+ TDataSet* aDataSet = aSource.GetPointer();
+ aDataSet->ShallowCopy(aGeometry);
+
+ const TVTKMergeFilter& aFilter = GetFilter();
+ aFilter->SetGeometry(aGeometry);
+ aFilter->SetScalars(aDataSet);
+ aFilter->SetVectors(aDataSet);
+ aFilter->AddField("VISU_FIELD",aDataSet);
+ }
+ return myFilter->GetUnstructuredGridOutput();
+ }
+
+ vtkIdType
+ TIDMapperFilter
+ ::GetNodeObjID(vtkIdType theID) const
+ {
+ return myIDMapper.GetNodeObjID(theID);
+ }
+
+ vtkIdType
+ TIDMapperFilter
+ ::GetNodeVTKID(vtkIdType theID) const
+ {
+ return myIDMapper.GetNodeVTKID(theID);
+ }
+
+ float*
+ TIDMapperFilter
+ ::GetNodeCoord(vtkIdType theObjID)
+ {
+ return myIDMapper.GetNodeCoord(theObjID);
+ }
+
+ vtkIdType
+ TIDMapperFilter
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return myIDMapper.GetElemObjID(theID);
+ }
+
+ vtkIdType
+ TIDMapperFilter
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ return myIDMapper.GetElemVTKID(theID);
+ }
+
+ vtkCell*
+ TIDMapperFilter
+ ::GetElemCell(vtkIdType theObjID)
+ {
+ return myIDMapper.GetElemCell(theObjID);
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ TGaussImpl
+ ::LessThan(const PGaussImpl& theGauss,
+ bool& theResult) const
+ {
+ theResult = false;
+ }
+
+
+ //---------------------------------------------------------------
+ TGaussSubMeshImpl::TGaussSubMeshImpl():
+ myStatus(eNone)
+ {}
+
+ TGaussPointID
+ TGaussSubMeshImpl
+ ::GetObjID(vtkIdType theID,
+ vtkIdType theStartID) const
+ {
+ TCellID aCellID = theStartID + theID / myGauss->myNbPoints;
+ TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
+
+ return TGaussPointID(aCellID,aLocalPntID);
+ }
+
+ //---------------------------------------------------------------
+ bool
+ operator<(const PGaussSubMesh& theLeft, const PGaussSubMesh& theRight)
+ {
+ PGaussSubMeshImpl aLeft(theLeft), aRight(theRight);
+ const PGaussImpl& aGaussLeft = aLeft->myGauss;
+ const PGaussImpl& aGaussRight = aRight->myGauss;
+
+ if(aGaussLeft->myGeom != aGaussRight->myGeom)
+ return aGaussLeft->myGeom < aGaussRight->myGeom;
+
+ if(aLeft->mySubProfile != aRight->mySubProfile)
+ return aLeft->mySubProfile < aRight->mySubProfile;
+
+ bool aResult;
+ aGaussLeft->LessThan(aGaussRight,aResult);
+
+ return aResult;
+ }
+
+
+ //---------------------------------------------------------------
+ TGaussMeshImpl
+ ::TGaussMeshImpl():
+ myParent(NULL)
+ {}
+
+ TGaussPointID
+ TGaussMeshImpl
+ ::GetObjID(vtkIdType theID) const
+ {
+ vtkIdType anInputID, aStartId, anInputDataSetID;
+ const TVTKAppendFilter& anAppendFilter = GetFilter();
+ anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID);
+ const TGaussSubMeshImpl& aSubMeshImpl = myGaussSubMeshArr[anInputDataSetID];
+
+ return aSubMeshImpl.GetObjID(anInputID,aStartId);
+ }
+
+ TVTKOutput*
+ TGaussMeshImpl
+ ::GetVTKOutput()
+ {
+ return mySource.GetVTKOutput();
+ }
+
+ TNamedIDMapper*
+ TGaussMeshImpl::
+ GetParent()
+ {
+ return myParent;
+ }
+
+
+ //---------------------------------------------------------------
+ TGaussPointID
+ TGaussPtsIDFilter
+ ::GetObjID(vtkIdType theID) const
+ {
+ return myGaussPtsIDMapper->GetObjID(theID);
+ }
+
+ TNamedIDMapper*
+ TGaussPtsIDFilter::
+ GetParent()
+ {
+ return myGaussPtsIDMapper->GetParent();
+ }
+
+
+ //---------------------------------------------------------------
+ vtkIdType
+ TSubMeshImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return myStartID + theID;
+ }
+
+ std::string
+ TSubMeshImpl
+ ::GetElemName(vtkIdType theObjID) const
+ {
+ return "";
+ }
+
+ //---------------------------------------------------------------
+ vtkIdType
+ TMeshOnEntityImpl
+ ::GetNodeVTKID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetVTKID(theID);
+ }
+
+ vtkIdType
+ TMeshOnEntityImpl
+ ::GetNodeObjID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetObjID(theID);
+ }
+
+ vtkIdType
+ TMeshOnEntityImpl
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ if(myElemObj2VTKID.empty())
+ return theID;
+ else{
+ TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
+ if(anIter != myElemObj2VTKID.end())
+ return anIter->second;
+ }
+ return -1;
+ }
+
+ vtkIdType
+ TMeshOnEntityImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ vtkIdType anInputID, aStartId, anInputDataSetID;
+ const TVTKAppendFilter& anAppendFilter = GetFilter();
+ anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID);
+ const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputDataSetID];
+ return aSubMesh->GetElemObjID(anInputID);
+ }
+
+ std::string
+ TMeshOnEntityImpl
+ ::GetNodeName(vtkIdType theObjID) const
+ {
+ return myNamedPointCoords->GetNodeName(theObjID);
+ }
+
+ std::string
+ TMeshOnEntityImpl
+ ::GetElemName(vtkIdType theObjID) const
+ {
+ vtkIdType aVTKId = GetElemVTKID(theObjID);
+ vtkIdType anInputID, aStartId, anInputDataSetID;
+ const TVTKAppendFilter& anAppendFilter = GetFilter();
+ anAppendFilter->GetCellInputID(aVTKId,anInputID,aStartId,anInputDataSetID);
+ const PSubMeshImpl& aSubMesh = mySubMeshArr[anInputDataSetID];
+ return aSubMesh->GetElemName(anInputID);
+ }
+
+ //---------------------------------------------------------------
+ vtkIdType
+ TFamilyImpl
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ if(myElemObj2VTKID.empty())
+ return theID;
+ else{
+ TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
+ if(anIter != myElemObj2VTKID.end())
+ return anIter->second;
+ }
+ return -1;
+ }
+
+ vtkIdType
+ TFamilyImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ return myMeshID[theID];
+ }
+
+ vtkIdType
+ TFamilyImpl
+ ::GetNodeObjID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetObjID(theID);
+ }
+
+ vtkIdType
+ TFamilyImpl
+ ::GetNodeVTKID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetVTKID(theID);
+ }
+
+ TVTKOutput*
+ TFamilyImpl
+ ::GetVTKOutput()
+ {
+ return TSource::GetVTKOutput();
+ }
+
+
+ //---------------------------------------------------------------
+ TNbASizeCells
+ TGroupImpl
+ ::GetNbASizeCells() const
+ {
+ vtkIdType aNbCells = 0, aCellsSize = 0;
+ TFamilySet::const_iterator anIter = myFamilySet.begin();
+ for(; anIter != myFamilySet.end(); anIter++){
+ PFamilyImpl aFamily = *anIter;
+ aNbCells += aFamily->myNbCells;
+ aCellsSize += aFamily->myCellsSize;
+ }
+ return make_pair(aNbCells,aCellsSize);
+ }
+
+ vtkIdType
+ TGroupImpl
+ ::GetElemVTKID(vtkIdType theID) const
+ {
+ if(myElemObj2VTKID.empty())
+ return theID;
+ else{
+ TID2ID::const_iterator anIter = myElemObj2VTKID.find(theID);
+ if(anIter != myElemObj2VTKID.end())
+ return anIter->second;
+ }
+ return -1;
+ }
+
+ vtkIdType
+ TGroupImpl
+ ::GetElemObjID(vtkIdType theID) const
+ {
+ vtkIdType anInputID, aStartId, anInputDataSetID;
+ const TVTKAppendFilter& anAppendFilter = GetFilter();
+ anAppendFilter->GetCellInputID(theID,anInputID,aStartId,anInputDataSetID);
+ const PFamilyImpl& aFamily = myFamilyArr[anInputDataSetID];
+ return aFamily->GetElemObjID(anInputID);
+ }
+
+ vtkIdType
+ TGroupImpl
+ ::GetNodeObjID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetObjID(theID);
+ }
+
+ vtkIdType
+ TGroupImpl
+ ::GetNodeVTKID(vtkIdType theID) const
+ {
+ return myNamedPointCoords->GetVTKID(theID);
+ }
+
+
+ //---------------------------------------------------------------
+ TFieldImpl
+ ::TFieldImpl():
+ myDataSize(0)
+ {}
+
+ void
+ TFieldImpl
+ ::InitArrays(vtkIdType theNbComp)
+ {
+ myNbComp = theNbComp;
+ myCompNames.resize(theNbComp);
+ myUnitNames.resize(theNbComp);
+ myMinMaxArr.resize(theNbComp + 1);
+ for(vtkIdType iComp = 0; iComp <= theNbComp; iComp++){
+ TMinMax& aMinMax = myMinMaxArr[iComp];
+ aMinMax.first = VTK_LARGE_FLOAT;
+ aMinMax.second = -VTK_LARGE_FLOAT;
+ }
+ }
+
+ TMinMax
+ TFieldImpl
+ ::GetMinMax(vtkIdType theCompID)
+ {
+ return myMinMaxArr[theCompID];
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ TMeshValue
+ ::Init(vtkIdType theNbElem,
+ vtkIdType theNbGauss,
+ vtkIdType theNbComp)
+ {
+ myNbElem = theNbElem;
+ myNbGauss = theNbGauss;
+ myNbComp = theNbComp;
+
+ myStep = theNbComp*theNbGauss;
+
+ myValue.resize(theNbElem*myStep);
+ }
+
+ TCValueSliceArr
+ TMeshValue
+ ::GetGaussValueSliceArr(vtkIdType theElemId) const
+ {
+ TCValueSliceArr aValueSliceArr(myNbGauss);
+ vtkIdType anId = theElemId*myStep;
+ for(vtkIdType aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TCValueSlice(myValue,std::slice(anId,myNbComp,1));
+ anId += myNbComp;
+ }
+ return aValueSliceArr;
+ }
+
+ TValueSliceArr
+ TMeshValue
+ ::GetGaussValueSliceArr(vtkIdType theElemId)
+ {
+ TValueSliceArr aValueSliceArr(myNbGauss);
+ vtkIdType anId = theElemId*myStep;
+ for(vtkIdType aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
+ aValueSliceArr[aGaussId] =
+ TValueSlice(myValue,std::slice(anId,myNbComp,1));
+ anId += myNbComp;
+ }
+ return aValueSliceArr;
+ }
+
+ TCValueSliceArr
+ TMeshValue
+ ::GetCompValueSliceArr(vtkIdType theElemId) const
+ {
+ TCValueSliceArr aValueSliceArr(myNbComp);
+ vtkIdType anId = theElemId*myStep;
+ for(vtkIdType aCompId = 0; aCompId < myNbComp; aCompId++){
+ aValueSliceArr[aCompId] =
+ TCValueSlice(myValue,std::slice(anId,myNbGauss,myNbComp));
+ anId += 1;
+ }
+ return aValueSliceArr;
+ }
+
+ TValueSliceArr
+ TMeshValue
+ ::GetCompValueSliceArr(vtkIdType theElemId)
+ {
+ TValueSliceArr aValueSliceArr(myNbComp);
+ vtkIdType anId = theElemId*myStep;
+ for(vtkIdType aCompId = 0; aCompId < myNbComp; aCompId++){
+ aValueSliceArr[aCompId] =
+ TValueSlice(myValue,std::slice(anId,myNbGauss,myNbComp));
+ anId += 1;
+ }
+ return aValueSliceArr;
+ }
+
+
+ //---------------------------------------------------------------
+ TValForTimeImpl
+ ::TValForTimeImpl():
+ myGaussPtsIDFilter(new TGaussPtsIDFilter()),
+ myIDMapperFilter(new TIDMapperFilter())
+ {}
+
+ const TMeshValue&
+ TValForTimeImpl
+ ::GetMeshValue(EGeometry theGeom) const
+ {
+ TGeom2Value::const_iterator anIter = myGeom2Value.find(theGeom);
+ if(anIter == myGeom2Value.end())
+ EXCEPTION(runtime_error,"TValForTimeImpl::GetMeshValue - myGeom2Value.find(theGeom) fails");
+ return anIter->second;
+ }
+
+ TMeshValue&
+ TValForTimeImpl
+ ::GetMeshValue(EGeometry theGeom)
+ {
+ return myGeom2Value[theGeom];
+ }
+
+ int
+ TValForTimeImpl
+ ::GetNbGauss(EGeometry theGeom) const
+ {
+ TGeom2NbGauss::const_iterator anIter = myGeom2NbGauss.find(theGeom);
+ if(anIter == myGeom2NbGauss.end()){
+ //EXCEPTION(runtime_error,"TValForTimeImpl::GetNbGauss - myGeom2NbGauss.find(theGeom) fails");
+ return 1;
+ }
+ return anIter->second;
+ }
+
+
+ //---------------------------------------------------------------
+ vtkIdType
+ VISUGeom2NbNodes(EGeometry theGeom)
+ {
+ switch(theGeom){
+#ifndef VISU_ENABLE_QUADRATIC
+ case VISU::eSEG3:
+ return 2;
+ case VISU::eTRIA6:
+ return 3;
+ case VISU::eQUAD8:
+ return 4;
+ case VISU::eTETRA10:
+ return 4;
+ case VISU::eHEXA20:
+ return 8;
+ case VISU::ePENTA15:
+ return 6;
+ case VISU::ePYRA13:
+ return 5;
+#endif
+ case VISU::ePOLYGONE:
+ case VISU::ePOLYEDRE:
+ return -1;
+ default:
+ return theGeom % 100;
+ }
+ }
+
+ vtkIdType
+ VISUGeom2VTK(EGeometry theGeom)
+ {
+ switch(theGeom){
+ case VISU::ePOINT1:
+ return VTK_VERTEX;
+ case VISU::eSEG2:
+ return VTK_LINE;
+ case VISU::eTRIA3:
+ return VTK_TRIANGLE;
+ case VISU::eQUAD4:
+ return VTK_QUAD;
+ case VISU::eTETRA4:
+ return VTK_TETRA;
+ case VISU::eHEXA8:
+ return VTK_HEXAHEDRON;
+ case VISU::ePENTA6:
+ return VTK_WEDGE;
+ case VISU::ePYRA5:
+ return VTK_PYRAMID;
+
+ case VISU::ePOLYGONE:
+ return VTK_POLYGON;
+ case VISU::ePOLYEDRE:
+ return VTK_CONVEX_POINT_SET;
+
+#ifndef VISU_ENABLE_QUADRATIC
+ case VISU::eSEG3:
+ return VTK_LINE;
+ case VISU::eTRIA6:
+ return VTK_TRIANGLE;
+ case VISU::eQUAD8:
+ return VTK_QUAD;
+ case VISU::eTETRA10:
+ return VTK_TETRA;
+ case VISU::eHEXA20:
+ return VTK_HEXAHEDRON;
+ case VISU::ePENTA15:
+ return VTK_WEDGE;
+ case VISU::ePYRA13:
+ return VTK_PYRAMID;
+
+#else
+
+ case VISU::eSEG3:
+#if defined(VTK_QUADRATIC_EDGE) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_EDGE;
+#else
+ return VTK_POLY_LINE;
+#endif
+
+ case VISU::eTRIA6:
+#if defined(VTK_QUADRATIC_TRIANGLE) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_TRIANGLE;
+#else
+ return VTK_POLYGON;
+#endif
+
+ case VISU::eQUAD8:
+#if defined(VTK_QUADRATIC_QUAD) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_QUAD;
+#else
+ return VTK_POLYGON;
+#endif
+
+ case VISU::eTETRA10:
+#if defined(VTK_QUADRATIC_TETRA) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_TETRA;
+#else
+ return VTK_CONVEX_POINT_SET;
+#endif
+
+ case VISU::eHEXA20:
+#if defined(VTK_QUADRATIC_HEXAHEDRON) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_HEXAHEDRON;
+#else
+ return VTK_CONVEX_POINT_SET;
+#endif
+
+ case VISU::ePENTA15:
+#if defined(VTK_QUADRATIC_WEDGE) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_WEDGE;
+#else
+ return VTK_CONVEX_POINT_SET;
+#endif
+
+ case VISU::ePYRA13:
+#if defined(VTK_QUADRATIC_PYRAMID) && defined(VISU_USE_VTK_QUADRATIC)
+ return VTK_QUADRATIC_PYRAMID;
+#else
+ return VTK_CONVEX_POINT_SET;
+#endif
+
+#endif //VISU_ENABLE_QUADRATIC
+
+ default:
+ return -1;
+ }
+ }
}
-template<>
-VISU::TMesh::TCoord GetCoord<eNone>(const VISU::TMesh::TPointsCoord& thePointsCoord,
- int theStartPos)
+
+namespace
{
- return 0.0;
-}
+ //---------------------------------------------------------------
+ template<class T>
+ std::string
+ dtos(const std::string& fmt, T val)
+ {
+ static QString aString;
+ aString.sprintf(fmt.c_str(),val);
+ return aString.latin1();
+ }
-static TGetCoord aXYZGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eY>,
- &GetCoord<eZ>
-};
-
-
-static TGetCoord aXYGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eY>,
- &GetCoord<eNone>
-};
-
-static TGetCoord aYZGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eX>,
- &GetCoord<eY>
-};
-
-static TGetCoord aXZGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eNone>,
- &GetCoord<eY>
-};
-
-
-static TGetCoord aXGetCoord[3] = {
- &GetCoord<eX>,
- &GetCoord<eNone>,
- &GetCoord<eNone>
-};
-
-static TGetCoord aYGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eX>,
- &GetCoord<eNone>
-};
-
-static TGetCoord aZGetCoord[3] = {
- &GetCoord<eNone>,
- &GetCoord<eNone>,
- &GetCoord<eX>
-};
-
-
-class TCoordHelper{
- const VISU::TMesh::TPointsCoord& myPointsCoord;
- TGetCoord* myGetCoord;
-public:
- TCoordHelper(const VISU::TMesh::TPointsCoord& thePointsCoord,
- TGetCoord* theGetCoord):
- myPointsCoord(thePointsCoord),
- myGetCoord(theGetCoord)
- {}
- virtual ~TCoordHelper(){}
- VISU::TMesh::TCoord GetCoord(int theStartPos, int theCoodId){
- return (*myGetCoord[theCoodId])(myPointsCoord,theStartPos);
+ //---------------------------------------------------------------
+ enum ECoordName{eX, eY, eZ, eNone};
+ typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice);
+
+ template<ECoordName TCoordId>
+ VISU::TCoord
+ GetCoord(const VISU::TCCoordSlice& theCoordSlice)
+ {
+ return theCoordSlice[TCoordId];
}
-};
-typedef std::auto_ptr<TCoordHelper> TCoordHelperPtr;
+
+ template<>
+ VISU::TCoord
+ GetCoord<eNone>(const VISU::TCCoordSlice& theCoordSlice)
+ {
+ return 0.0;
+ }
+
+
+ TGetCoord aXYZGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eY>,
+ &GetCoord<eZ>
+ };
+
+
+ TGetCoord aXYGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eY>,
+ &GetCoord<eNone>
+ };
+
+ TGetCoord aYZGetCoord[3] = {
+ &GetCoord<eNone>,
+ &GetCoord<eX>,
+ &GetCoord<eY>
+ };
+
+ TGetCoord aXZGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eNone>,
+ &GetCoord<eY>
+ };
+
+
+ TGetCoord aXGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eNone>,
+ &GetCoord<eNone>
+ };
+
+ TGetCoord aYGetCoord[3] = {
+ &GetCoord<eNone>,
+ &GetCoord<eX>,
+ &GetCoord<eNone>
+ };
+
+ TGetCoord aZGetCoord[3] = {
+ &GetCoord<eNone>,
+ &GetCoord<eNone>,
+ &GetCoord<eX>
+ };
+
+ class TCoordHelper{
+ TGetCoord* myGetCoord;
+ public:
+ TCoordHelper(TGetCoord* theGetCoord):
+ myGetCoord(theGetCoord)
+ {}
+
+ virtual
+ ~TCoordHelper()
+ {}
+
+ VISU::TCoord
+ GetCoord(VISU::TCCoordSlice& theCoordSlice,
+ int theCoordId)
+ {
+ return (*myGetCoord[theCoordId])(theCoordSlice);
+ }
+ };
+ typedef std::auto_ptr<TCoordHelper> TCoordHelperPtr;
+
-namespace{
- void GetPoints(VISU::TVTKSource& theStorage, VISU::TMesh& theMesh)
+ //---------------------------------------------------------------
+ vtkPoints*
+ GetPoints(const PMeshImpl& theMesh)
{
- vtkPoints* aPoints = theMesh.myPoints.GetPointer();
- if(!aPoints){
- aPoints = vtkPoints::New();
+ TVTKPoints& aPoints = theMesh->myPoints;
+ const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
+
+ if(!theMesh->myIsVTKDone){
TCoordHelperPtr aCoordHelperPtr;
- const VISU::TMesh::TPointsCoord& anArray = theMesh.myPointsCoord;
{
- int aMeshDimension = theMesh.myDim;
+ int aMeshDimension = theMesh->myDim;
bool anIsDimPresent[3] = {false, false, false};
for(int iDim = 0; iDim < aMeshDimension; iDim++){
- string aDimName = theMesh.myPointsDim.at(iDim);
- if(aDimName == "x" || aDimName == "X")
+ const std::string& aName = aCoords.GetName(iDim);
+ if(aName == "x" || aName == "X")
anIsDimPresent[eX] = true;
- else if(aDimName == "y" || aDimName == "Y")
+ else if(aName == "y" || aName == "Y")
anIsDimPresent[eY] = true;
- else if(aDimName == "z" || aDimName == "Z")
+ else if(aName == "z" || aName == "Z")
anIsDimPresent[eZ] = true;
}
switch(aMeshDimension){
case 3:
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aXYZGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aXYZGetCoord));
break;
case 2:
if(anIsDimPresent[eY] && anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aYZGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aYZGetCoord));
else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aXZGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aXZGetCoord));
else
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aXYGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aXYGetCoord));
break;
case 1:
if(anIsDimPresent[eY])
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aYGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aYGetCoord));
else if(anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aZGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aZGetCoord));
else
- aCoordHelperPtr.reset(new TCoordHelper(anArray,aXGetCoord));
+ aCoordHelperPtr.reset(new TCoordHelper(aXGetCoord));
break;
}
}
- if(MYVTKDEBUG) aPoints->DebugOn();
- vtkIdType iEnd = theMesh.myPointsCoord.size();
- vtkIdType aNbPoints = iEnd / theMesh.myDim;
+ vtkIdType aNbPoints = aCoords.GetNbPoints();
aPoints->SetNumberOfPoints(aNbPoints);
- if(MYDEBUG)
- MESSAGE("GetPoints - aNbPoints = "<<aNbPoints<<"; myDim = "<<theMesh.myDim);
- for (vtkIdType i = 0, j = 0; i < iEnd; i += theMesh.myDim, j++)
- aPoints->SetPoint(j,
- aCoordHelperPtr->GetCoord(i,eX),
- aCoordHelperPtr->GetCoord(i,eY),
- aCoordHelperPtr->GetCoord(i,eZ));
- theMesh.myPoints = aPoints;
+
+ INITMSG(MYDEBUG,"GetPoints - aNbPoints = "<<aNbPoints<<
+ "; aDim = "<<theMesh->myDim<<
+ endl);
+
+ for(vtkIdType aNodeId = 0; aNodeId < aNbPoints; aNodeId++){
+ TCCoordSlice aCoordSlice = aCoords.GetCoordSlice(aNodeId);
+ aPoints->SetPoint(aNodeId,
+ aCoordHelperPtr->GetCoord(aCoordSlice,eX),
+ aCoordHelperPtr->GetCoord(aCoordSlice,eY),
+ aCoordHelperPtr->GetCoord(aCoordSlice,eZ));
+ }
+
+ theMesh->myIsVTKDone = true;
+
+ if(MYVTKDEBUG) aPoints->DebugOn();
}
- theStorage->SetPoints(aPoints);
+
+ return aPoints.GetPointer();
}
- inline void PrintCells(int& theStartId,
- vtkCellArray* theConnectivity,
- const VISU::TMeshOnEntity::TConnect& theVector)
+ //---------------------------------------------------------------
+ void
+ PrintCells(int& theStartId,
+ vtkCellArray* theConnectivity,
+ const VISU::TConnect& theVector)
{
vtkIdList *anIdList = vtkIdList::New();
int kEnd = theVector.size();
anIdList->Delete();
}
- void GetCellsOnEntity(VISU::TVTKSource& theStorage,
- const VISU::TMeshOnEntity& theMeshOnEntity,
- const string& theFamilyName)
+
+ //---------------------------------------------------------------
+ void
+ GetCellsOnSubMesh(const TVTKSource& theSource,
+ const PMeshOnEntityImpl& theMeshOnEntity,
+ const PSubMeshImpl& theSubMesh,
+ const vtkIdType theGeom)
{
- //Check on existing family
- const VISU::TFamily* pFamily = VISU::GetFamily(theMeshOnEntity,theFamilyName);
- bool isFamilyPresent = (pFamily != NULL);
- const VISU::TFamily& aFamily = *pFamily;
- //Main part of code
- pair<int,int> aCellsDim = theMeshOnEntity.GetCellsDims(theFamilyName);
- int aNbCells = aCellsDim.first, aCellsSize = aCellsDim.second;
+ const VISU::TCell2Connect& anArray = theSubMesh->myCell2Connect;
+ vtkIdType aCellsSize = theSubMesh->myCellsSize;
+ vtkIdType aNbCells = theSubMesh->myNbCells;
+ INITMSG(MYDEBUG,"GetCellsOnSubMesh "<<
+ "- theGeom = "<<theGeom<<
+ "; aNbCells = "<<aNbCells<<
+ endl);
+
+
vtkCellArray* aConnectivity = vtkCellArray::New();
aConnectivity->Allocate(aCellsSize,0);
vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
aCellTypesArray->SetNumberOfComponents(1);
aCellTypesArray->SetNumberOfTuples(aNbCells);
- if(MYDEBUG) MESSAGE("GetCellsOnEntity - isFamilyPresent = "<<isFamilyPresent);
- const VISU::TMeshOnEntity::TCellsConn &aCellsConn = theMeshOnEntity.myCellsConn;
- VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
- for(int i = 0, j = 0; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
- const VISU::TMeshOnEntity::TConnForCellType& anArray = aCellsConnIter->second;
- int aVtkType = aCellsConnIter->first;
- if(MYDEBUG)
- MESSAGE("GetCellsOnEntity - aVtkType = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
- if(!isFamilyPresent)
- for(int k = 0, kEnd = anArray.size(); k < kEnd; k++, i++){
- PrintCells(i,aConnectivity,anArray[k]);
- aCellTypesArray->SetValue(j++,(unsigned char)aVtkType);
+
+ for(vtkIdType anID = 0; anID < aNbCells; anID++){
+ PrintCells(anID,aConnectivity,anArray[anID]);
+ aCellTypesArray->SetValue(anID,(unsigned char)theGeom);
+ }
+
+ vtkIdType *pts = 0, npts = 0;
+ vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+ aCellLocationsArray->SetNumberOfComponents(1);
+ aCellLocationsArray->SetNumberOfTuples(aNbCells);
+ aConnectivity->InitTraversal();
+ for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
+ aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
+ theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
+
+ if(MYVTKDEBUG) aConnectivity->DebugOn();
+
+ aCellLocationsArray->Delete();
+ aCellTypesArray->Delete();
+ aConnectivity->Delete();
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetCellsOnFamily(const TVTKSource& theSource,
+ const PMeshOnEntityImpl& theMeshOnEntity,
+ const PFamilyImpl& theFamily)
+ {
+ INITMSG(MYDEBUG,"GetCellsOnFamily"<<endl);
+
+ vtkIdType aNbCells = theFamily->myNbCells;
+ vtkIdType aCellsSize = theFamily->myCellsSize;
+
+ vtkCellArray* aConnectivity = vtkCellArray::New();
+ aConnectivity->Allocate(aCellsSize,0);
+ vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+ aCellTypesArray->SetNumberOfComponents(1);
+ aCellTypesArray->SetNumberOfTuples(aNbCells);
+
+ TSubMeshID& aMeshID = theFamily->myMeshID;
+ aMeshID.resize(aNbCells);
+
+ VISU::TID2ID& anElemObj2VTKID = theFamily->myElemObj2VTKID;
+
+ const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
+ VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
+ for(vtkIdType i = 0, j = 0; anIter != aGeom2SubMesh.end(); anIter++){
+ VISU::EGeometry aEGeom = anIter->first;
+ vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
+
+ const VISU::TSubMeshImpl& aSubMesh = anIter->second;
+ const VISU::TCell2Connect& anArray = aSubMesh.myCell2Connect;
+
+ const VISU::TGeom2SubMeshID& aGeom2SubMeshID = theFamily->myGeom2SubMeshID;
+ if(aGeom2SubMeshID.empty())
+ EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!");
+
+ VISU::TGeom2SubMeshID::const_iterator aGeom2SubMeshIDIter = aGeom2SubMeshID.find(aEGeom);
+ if(aGeom2SubMeshIDIter == aGeom2SubMeshID.end())
+ continue;
+
+ const VISU::TSubMeshID& aSubMeshID = aGeom2SubMeshIDIter->second;
+
+ INITMSG(MYDEBUG,
+ " - aEGeom = "<<aEGeom<<
+ "; aVGeom = "<<aVGeom<<
+ "; aSubMeshID.size() = "<<aSubMeshID.size()<<
+ endl);
+
+ VISU::TSubMeshID::const_iterator aSubMeshIDIter = aSubMeshID.begin();
+ for(; aSubMeshIDIter != aSubMeshID.end(); aSubMeshIDIter++, i++){
+ vtkIdType anID = *aSubMeshIDIter;
+ PrintCells(i,aConnectivity,anArray[anID]);
+ aCellTypesArray->SetValue(j++,(unsigned char)aVGeom);
+
+ anElemObj2VTKID[anID] = i;
+ aMeshID[i] = anID;
+ }
+ }
+ vtkIdType *pts = 0, npts = 0;
+ vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+ aCellLocationsArray->SetNumberOfComponents(1);
+ aCellLocationsArray->SetNumberOfTuples(aNbCells);
+ aConnectivity->InitTraversal();
+ for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
+ aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
+ theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
+
+ if(MYVTKDEBUG) aConnectivity->DebugOn();
+
+ aCellLocationsArray->Delete();
+ aCellTypesArray->Delete();
+ aConnectivity->Delete();
+ }
+
+
+ //---------------------------------------------------------------
+ std::string
+ GenerateFieldName(const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime)
+ {
+ const VISU::TTime& aTime = theValForTime->myTime;
+ string aFieldName = theField->myMeshName + ", " + theField->myName + ": " +
+ VISU_Convertor::GenerateName(aTime);
+ return aFieldName;
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetTimeStampOnProfile(const TVTKSource& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime,
+ const VISU::TEntity& theEntity)
+ {
+ int aNbTuples = theField->myDataSize/theField->myNbComp;
+ std::string aFieldName = GenerateFieldName(theField,theValForTime);
+
+ vtkDataSetAttributes* aDataSetAttributes;
+ switch(theEntity){
+ case VISU::NODE_ENTITY :
+ aDataSetAttributes = theSource->GetPointData();
+ break;
+ default:
+ aDataSetAttributes = theSource->GetCellData();
+ }
+
+ int aNbComp = theField->myNbComp;
+ vtkFloatArray *aFloatArray = vtkFloatArray::New();
+
+ switch(aNbComp) {
+ case 1:
+ aFloatArray->SetNumberOfComponents(1);
+ aDataSetAttributes->SetScalars(aFloatArray);
+ break;
+ default:
+ aFloatArray->SetNumberOfComponents(3);
+ aDataSetAttributes->SetVectors(aFloatArray);
+ }
+ aFloatArray->SetNumberOfTuples(aNbTuples);
+ aFloatArray->SetName(aFieldName.c_str());
+
+ vtkFloatArray *aDataArray = vtkFloatArray::New();
+ aDataArray->SetNumberOfComponents(aNbComp);
+ aDataArray->SetNumberOfTuples(aNbTuples);
+ aDataArray->SetName("VISU_FIELD");
+ aDataSetAttributes->AddArray(aDataArray);
+
+ INITMSG(MYDEBUG,"GetTimeStampOnProfile "<<
+ "- theEntity = "<<theEntity<<
+ "; aNbTuples = "<<aNbTuples<<
+ "; aNbComp = "<<aNbComp<<
+ endl);
+
+ int aSize = max(3,aNbComp);
+ TVector<float> aDataValues(aSize,0.0);
+
+ TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
+ TGeom2Value::const_iterator anIter = aGeom2Value.begin();
+ for(int aTupleId = 0; anIter != aGeom2Value.end(); anIter++){
+ EGeometry aEGeom = anIter->first;
+ const TMeshValue& aMeshValue = anIter->second;
+
+ int aNbElem = aMeshValue.myNbElem;
+ int aNbGauss = aMeshValue.myNbGauss;
+ INITMSG(MYDEBUG,
+ "- aEGeom = "<<aEGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ endl);
+
+ for(int iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
+ TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iElem);
+ for(int iComp = 0; iComp < aNbComp; iComp++){
+ const TCValueSlice& aValueSlice = aValueSliceArr[iComp];
+ aDataValues[iComp] = 0.0;
+ for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
+ aDataValues[iComp] += aValueSlice[iGauss];
+ }
+ aDataValues[iComp] /= aNbGauss;
+ }
+ aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
+ aDataArray->SetTuple(aTupleId,&aDataValues[0]);
+ }
+ }
+ aFloatArray->Delete();
+ aDataArray->Delete();
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetCells(const TVTKSource& theSource,
+ const PSubProfileImpl& theSubProfile,
+ const PProfileImpl& theProfile,
+ const PMeshOnEntityImpl& theMeshOnEntity)
+ {
+ vtkIdType aNbCells = theSubProfile->myNbCells;
+ vtkIdType aCellsSize = theSubProfile->myCellsSize;
+ VISU::EGeometry aEGeom = theSubProfile->myGeom;
+ vtkIdType aNbNodes = VISUGeom2NbNodes(aEGeom);
+ vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
+
+ INITMSG(MYDEBUG,"GetCells - aVGeom = "<<aVGeom<<endl);
+
+ const TSubMeshID& aSubMeshID = theSubProfile->mySubMeshID;
+
+ const VISU::TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
+ VISU::TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.find(aEGeom);
+ if(anIter == aGeom2SubMesh.end())
+ EXCEPTION(runtime_error,"GetCells >> There is no elements for the GEOM("<<aEGeom<<")");
+
+ const VISU::TSubMeshImpl& aSubMesh = anIter->second;
+ const TCell2Connect& aCell2Connect = aSubMesh.myCell2Connect;
+
+ vtkCellArray* aConnectivity = vtkCellArray::New();
+ aConnectivity->Allocate(aCellsSize,0);
+ vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
+ aCellTypesArray->SetNumberOfComponents(1);
+ aCellTypesArray->SetNumberOfTuples(aNbCells);
+
+ if(theSubProfile->myStatus == eAddAll){
+ VISU::TCell2Connect::const_iterator anIter = aCell2Connect.begin();
+ for(vtkIdType anId = 0, aConnId = 0; anIter != aCell2Connect.end(); anIter++){
+ const TConnect& anArray = aCell2Connect[anId];
+ PrintCells(aConnId,aConnectivity,anArray);
+ aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
+ aConnId += aNbNodes;
+ anId++;
+ }
+ }else{
+ VISU::TSubMeshID::const_iterator anIter = aSubMeshID.begin();
+ for(vtkIdType anId = 0, aConnId = 0; anIter != aSubMeshID.end(); anIter++){
+ vtkIdType aSubId = *anIter;
+ const TConnect& anArray = aCell2Connect[aSubId];
+ PrintCells(aConnId,aConnectivity,anArray);
+ aCellTypesArray->SetValue(anId,(unsigned char)aVGeom);
+ aConnId += aNbNodes;
+ anId++;
+ }
+ }
+
+ vtkIdType *pts = 0, npts = 0;
+ vtkIntArray* aCellLocationsArray = vtkIntArray::New();
+
+ aCellLocationsArray->SetNumberOfComponents(1);
+ aCellLocationsArray->SetNumberOfTuples(aNbCells);
+ aConnectivity->InitTraversal();
+ for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
+ aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
+ theSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
+
+ aCellLocationsArray->Delete();
+ aCellTypesArray->Delete();
+ aConnectivity->Delete();
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetMeshOnSubProfile(const PMeshImpl& theMesh,
+ const PMeshOnEntityImpl& theMeshOnEntity,
+ const PProfileImpl& theProfile,
+ const PSubProfileImpl& theSubProfile)
+ {
+ INITMSG(MYDEBUG,"GetMeshOnSubProfile - aEGeom = "<<theSubProfile->myGeom<<endl);
+
+ const TVTKSource& aSource = theSubProfile->GetSource();
+ if(theSubProfile->myIsVTKDone)
+ return;
+
+ aSource->SetPoints(GetPoints(theMesh));
+ INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
+ GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
+ BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
+
+ theSubProfile->myIsVTKDone = true;
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetMeshOnProfile(const PMeshImpl& theMesh,
+ const PMeshOnEntityImpl& theMeshOnEntity,
+ const PProfileImpl& theProfile)
+ {
+ INITMSG(MYDEBUG,"GetMeshOnProfile - anEntity = "<<theMeshOnEntity->myEntity<<endl);
+
+ if(theProfile->myIsVTKDone)
+ return;
+
+ theProfile->myMeshOnEntity = theMeshOnEntity.get();
+ const TVTKAppendFilter& anAppendFilter = theProfile->GetFilter();
+ anAppendFilter->SetPoints(GetPoints(theMesh));
+
+ if(theProfile->myIsAll){
+ TVTKOutput* aDataSet = theMeshOnEntity->GetVTKOutput();
+ anAppendFilter->AddInput(aDataSet);
+ }else{
+ const TGeom2SubProfile& aGeom2SubProfile = theProfile->myGeom2SubProfile;
+
+ TID2ID& anElemObj2VTKID = theProfile->myElemObj2VTKID;
+
+ TSubProfileArr& aSubProfileArr = theProfile->mySubProfileArr;
+ aSubProfileArr.resize(aGeom2SubProfile.size());
+
+ TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
+ for(vtkIdType anInputID = 0, aCellID = 0; anIter != aGeom2SubProfile.end(); anIter++){
+ PSubProfileImpl aSubProfile = anIter->second;
+ if(aSubProfile->myStatus == eRemoveAll)
+ continue;
+
+ GetMeshOnSubProfile(theMesh,
+ theMeshOnEntity,
+ theProfile,
+ aSubProfile);
+
+ const TVTKSource& aSource = aSubProfile->GetSource();
+ anAppendFilter->AddInput(aSource.GetPointer());
+
+ vtkIdType aNbCells = aSource->GetNumberOfCells();
+ for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
+ anElemObj2VTKID[aSubProfile->GetElemObjID(aCell)] = aCellID;
+ }
+
+ aSubProfileArr[anInputID++] = aSubProfile;
+ }
+ }
+ anAppendFilter->Update(); // Fix on VTK
+ theProfile->myNamedPointCoords = theMesh->myNamedPointCoords;
+
+ theProfile->myIsVTKDone = true;
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetTimeStampOnGaussMesh(const TVTKSource& theSource,
+ const PFieldImpl& theField,
+ const PValForTimeImpl& theValForTime)
+ {
+ int aNbTuples = theSource->GetNumberOfPoints();
+ std::string aFieldName = GenerateFieldName(theField,theValForTime);
+
+ vtkDataSetAttributes* aDataSetAttributes;
+ switch(theField->myEntity){
+ case VISU::NODE_ENTITY :
+ aDataSetAttributes = theSource->GetPointData();
+ break;
+ default:
+ aDataSetAttributes = theSource->GetCellData();
+ }
+
+ int aNbComp = theField->myNbComp;
+ vtkFloatArray *aFloatArray = vtkFloatArray::New();
+ switch(aNbComp){
+ case 1:
+ aFloatArray->SetNumberOfComponents(1);
+ aDataSetAttributes->SetScalars(aFloatArray);
+ break;
+ default:
+ aFloatArray->SetNumberOfComponents(3);
+ aDataSetAttributes->SetVectors(aFloatArray);
+ }
+ aFloatArray->SetNumberOfTuples(aNbTuples);
+ aFloatArray->SetName(aFieldName.c_str());
+
+ vtkFloatArray *aDataArray = vtkFloatArray::New();
+ aDataArray->SetNumberOfComponents(aNbComp);
+ aDataArray->SetNumberOfTuples(aNbTuples);
+ aDataArray->SetName("VISU_FIELD");
+ aDataSetAttributes->AddArray(aDataArray);
+
+ INITMSG(MYDEBUG,"GetTimeStampOnGaussMesh "<<
+ "- aNbTuples = "<<aNbTuples<<
+ "; aNbComp = "<<aNbComp<<
+ endl);
+
+ int aSize = max(3,aNbComp);
+ TVector<float> aDataValues(aSize,0.0);
+
+ const TGeom2Value& aGeom2Value = theValForTime->myGeom2Value;
+
+ PGaussMeshImpl aGaussMesh = theValForTime->myGaussMesh;
+ const TGeom2GaussSubMesh& aGeom2GaussSubMesh = aGaussMesh->myGeom2GaussSubMesh;
+ TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
+ for(int aTupleId = 0; anIter != aGeom2GaussSubMesh.end(); anIter++){
+ EGeometry aEGeom = anIter->first;
+
+ PGaussSubMeshImpl aGaussSubMesh = anIter->second;
+ if(!aGaussSubMesh->myIsDone)
+ continue;
+
+ TGeom2Value::const_iterator anIter2 = aGeom2Value.find(aEGeom);
+ if(anIter2 == aGeom2Value.end()){
+ EXCEPTION(runtime_error,
+ "GetTimeStampOnGaussMesh >> Can't find values for corresponding Gauss Points SubMesh");
+ }
+ const TMeshValue& aMeshValue = anIter2->second;
+ int aNbGauss = aMeshValue.myNbGauss;
+ int aNbElem = aMeshValue.myNbElem;
+
+ if(aNbGauss < 1)
+ continue;
+
+ const TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
+
+ INITMSG(MYDEBUG,
+ "- aEGeom = "<<aEGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ "; aCoords.GetNbPoints() = "<<aCoords.GetNbPoints()<<
+ endl);
+
+ if(aCoords.GetNbPoints() == aNbElem*aNbGauss){
+ for(int iElem = 0; iElem < aNbElem; iElem++){
+ TCValueSliceArr aValueSliceArr = aMeshValue.GetGaussValueSliceArr(iElem);
+ for(int iGauss = 0; iGauss < aNbGauss; iGauss++, aTupleId++){
+ const TCValueSlice& aValueSlice = aValueSliceArr[iGauss];
+ for(int iComp = 0; iComp < aNbComp; iComp++){
+ aDataValues[iComp] = aValueSlice[iComp];
+ }
+ aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
+ aDataArray->SetTuple(aTupleId,&aDataValues[0]);
+ }
}
- else{
- const VISU::TFamily::TSubMesh& aSubMesh = aFamily.mySubMesh;
- if(aSubMesh.empty())
- throw std::runtime_error(EXCEPTION("GetCells >> There is no elements on the family !!!"));
- VISU::TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType);
- if(aSubMeshIter == aSubMesh.end()) continue;
- const VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second;
- if(MYDEBUG)
- MESSAGE("GetCellsOnEntity - aSubMeshOnCellType.size() = "<<aSubMeshOnCellType.size());
- VISU::TFamily::TSubMeshOnCellType::const_iterator aSubMeshOnCellTypeIter = aSubMeshOnCellType.begin();
- for(; aSubMeshOnCellTypeIter != aSubMeshOnCellType.end(); aSubMeshOnCellTypeIter++, i++){
- PrintCells(i,aConnectivity,anArray[*aSubMeshOnCellTypeIter]);
- aCellTypesArray->SetValue(j++,(unsigned char)aVtkType);
+ }else{
+ for(int iElem = 0; iElem < aNbElem; iElem++, aTupleId++){
+ TCValueSliceArr aValueSliceArr = aMeshValue.GetCompValueSliceArr(iElem);
+ for(int iComp = 0; iComp < aNbComp; iComp++){
+ const TCValueSlice& aValueSlice = aValueSliceArr[iComp];
+ aDataValues[iComp] = 0.0;
+ for(int iGauss = 0; iGauss < aNbGauss; iGauss++){
+ aDataValues[iComp] += aValueSlice[iGauss];
+ }
+ aDataValues[iComp] /= aNbGauss;
+ }
+ aFloatArray->SetTuple(aTupleId,&aDataValues[0]);
+ aDataArray->SetTuple(aTupleId,&aDataValues[0]);
}
}
}
- vtkIdType *pts = 0, npts = 0;
- vtkIntArray* aCellLocationsArray = vtkIntArray::New();
- aCellLocationsArray->SetNumberOfComponents(1);
- aCellLocationsArray->SetNumberOfTuples(aNbCells);
- aConnectivity->InitTraversal();
- for(int i=0; aConnectivity->GetNextCell(npts,pts); i++)
- aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
- theStorage->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
- if(MYVTKDEBUG) aConnectivity->DebugOn();
- aCellLocationsArray->Delete();
- aCellTypesArray->Delete();
- aConnectivity->Delete();
- }
-
-
- void GetCellsOnGroup(VISU::TVTKSource& theStorage,
- const VISU::TMesh& theMesh,
- const VISU::TFamilyAndEntitySet& theFamilyAndEntitySet)
+ aFloatArray->Delete();
+ aDataArray->Delete();
+ }
+
+
+ //---------------------------------------------------------------
+ void
+ GetSource(const TVTKSource& theSource,
+ const PGaussSubMeshImpl& theGaussSubMesh,
+ const PMeshOnEntityImpl& theMeshOnEntity)
{
- //Calculate dimentions of the group
- int aNbCells = 0, aCellsSize = 0;
- VISU::TFamilyAndEntitySet::const_iterator aFamilyAndEntitySetIter = theFamilyAndEntitySet.begin();
- for(; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){
- const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter;
- const string& aFamilyName = aFamilyAndEntity.first;
- const VISU::TEntity& anEntity = aFamilyAndEntity.second;
- const VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap.find(anEntity)->second;
- pair<int,int> aCellsDim = aMeshOnEntity.GetCellsDims(aFamilyName);
- aNbCells += aCellsDim.first;
- aCellsSize += aCellsDim.second;
- }
+ const TPointCoords& aCoords = theGaussSubMesh->myPointCoords;
+ vtkIdType aNbPoints = aCoords.GetNbPoints();
+ vtkIdType aDim = aCoords.GetDim();
+
+ vtkIdType aNbCells = theGaussSubMesh->myNbCells;
+ vtkIdType aCellsSize = theGaussSubMesh->myCellsSize;
+
vtkCellArray* aConnectivity = vtkCellArray::New();
aConnectivity->Allocate(aCellsSize,0);
vtkUnsignedCharArray* aCellTypesArray = vtkUnsignedCharArray::New();
aCellTypesArray->SetNumberOfComponents(1);
aCellTypesArray->SetNumberOfTuples(aNbCells);
- aFamilyAndEntitySetIter = theFamilyAndEntitySet.begin();
- for(int i = 0, j = 0; aFamilyAndEntitySetIter != theFamilyAndEntitySet.end(); aFamilyAndEntitySetIter++){
- const VISU::TFamilyAndEntity& aFamilyAndEntity = *aFamilyAndEntitySetIter;
- const string& aFamilyName = aFamilyAndEntity.first;
- const VISU::TEntity& anEntity = aFamilyAndEntity.second;
- const VISU::TMeshOnEntity& aMeshOnEntity = theMesh.myMeshOnEntityMap.find(anEntity)->second;
- const VISU::TFamily& aFamily = *(VISU::GetFamily(aMeshOnEntity,aFamilyName));
- const VISU::TMeshOnEntity::TCellsConn &aCellsConn = aMeshOnEntity.myCellsConn;
- VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
- for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
- const VISU::TMeshOnEntity::TConnForCellType& anArray = aCellsConnIter->second;
- int aVtkType = aCellsConnIter->first;
- if(MYDEBUG)
- MESSAGE("GetCellsOnGroup - aVtkType = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
- const VISU::TFamily::TSubMesh& aSubMesh = aFamily.mySubMesh;
- if(aSubMesh.empty())
- throw std::runtime_error(EXCEPTION("GetCells >> There is no elements on the family !!!"));
- VISU::TFamily::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType);
- if(aSubMeshIter == aSubMesh.end()) continue;
- const VISU::TFamily::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second;
- if(MYDEBUG)
- MESSAGE("GetCellsOnGroup - aSubMeshOnCellType.size() = "<<aSubMeshOnCellType.size());
- VISU::TFamily::TSubMeshOnCellType::const_iterator aSubMeshOnCellTypeIter = aSubMeshOnCellType.begin();
- for(; aSubMeshOnCellTypeIter != aSubMeshOnCellType.end(); aSubMeshOnCellTypeIter++, i++){
- PrintCells(i,aConnectivity,anArray[*aSubMeshOnCellTypeIter]);
- aCellTypesArray->SetValue(j++,(unsigned char)aVtkType);
- }
- }
+
+ const TVTKPoints& aPoints = aCoords.GetPoints();
+ vtkIdList *anIdList = vtkIdList::New();
+ anIdList->SetNumberOfIds(1);
+ for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
+ TCCoordSlice aSlice = aCoords.GetCoordSlice(aPointId);
+
+ float aCoords[3] = {0.0, 0.0, 0.0};
+ for(vtkIdType aDimId = 0; aDimId < aDim; aDimId++)
+ aCoords[aDimId] = aSlice[aDimId];
+
+ aPoints->SetPoint(aPointId,aCoords);
+
+ anIdList->SetId(0,aPointId);
+ aConnectivity->InsertNextCell(anIdList);
+ aCellTypesArray->SetValue(aPointId,(unsigned char)VTK_VERTEX);
}
- vtkIdType *pts = 0, npts = 0;
+ anIdList->Delete();
+
vtkIntArray* aCellLocationsArray = vtkIntArray::New();
aCellLocationsArray->SetNumberOfComponents(1);
aCellLocationsArray->SetNumberOfTuples(aNbCells);
+
+ vtkIdType *pts = 0, npts = 0;
aConnectivity->InitTraversal();
for(int i = 0; aConnectivity->GetNextCell(npts,pts); i++)
aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
- theStorage->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
+
+ const TVTKSource& aSource = theGaussSubMesh->GetSource();
+ aSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
+ aSource->SetPoints(aPoints.GetPointer());
+
aCellLocationsArray->Delete();
aCellTypesArray->Delete();
aConnectivity->Delete();
- }
+ }
- void InitProfile(VISU::TVTKExtractFilter& theFilter,
- const VISU::TMeshOnEntity& theMeshOnEntity,
- const VISU::TField::TValForTime& theValForTime)
- {
- const VISU::TField::TValForCells& aValForCells = theValForTime.myValForCells;
- const VISU::TMeshOnEntity::TCellsConn &aCellsConn = theMeshOnEntity.myCellsConn;
- VISU::TMeshOnEntity::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
- for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
- const vtkIdType& aCellType = aCellsConnIter->first;
- if(aValForCells.find(aCellType) == aValForCells.end())
- theFilter->RemoveCellsWithType(aCellType);
- }
- }
-
-
- void GetValsOnTimeStamp(vtkFloatArray *theFloatArray,
- const vtkIdType& theNumberOfTuples,
- const std::string& theFieldName,
- const VISU::TField& theField,
- const VISU::TField::TValForTime& theValForTime)
- {
- //theFloatArray->DebugOn();
- theFloatArray->SetNumberOfTuples(theNumberOfTuples);
- theFloatArray->SetName(theFieldName.c_str());
- if(MYDEBUG) MESSAGE("GetValsOnTimeStamp - theNumberOfTuples = "<<theNumberOfTuples);
- const VISU::TField::TValForCells& aValForCells = theValForTime.myValForCells;
- VISU::TField::TValForCells::const_iterator aValForCellsIter = aValForCells.begin();
- for(int k = 0; aValForCellsIter != aValForCells.end(); aValForCellsIter++) {
- const VISU::TField::TValForCellsWithType& anArray = aValForCellsIter->second;
- int iEnd = anArray.size()/theField.myNbComp;
- int aVtkType = aValForCellsIter->first;
- if(MYDEBUG) MESSAGE("GetValsOnTimeStamp - iEnd = "<<iEnd<<"; aVtkType = "<<aVtkType);
- switch(theField.myNbComp) {
- case 1:
- for (int i = 0; i < iEnd; i++)
- theFloatArray->SetTuple1(k++,anArray[i]);
- break;
- case 2:
- for (int i = 0, ji = 0; i < iEnd; ++i, ji = i*2)
- theFloatArray->SetTuple3(k++,anArray[ji],anArray[ji+1],0.0);
- break;
- case 3:
- for (int i = 0, ji = 0; i < iEnd; ++i, ji = i*3)
- theFloatArray->SetTuple3(k++,anArray[ji],anArray[ji+1],anArray[ji+2]);
- break;
- case 4:
- for (int i = 0, ji = 0; i < iEnd; ++i, ji = i*4)
- theFloatArray->SetTuple3(k++,anArray[ji],anArray[ji+2],0.0);
- break;
- case 6:
- for (int i = 0, ji = 0; i < iEnd; ++i, ji = i*4)
- theFloatArray->SetTuple3(k++,anArray[ji],anArray[ji+2],anArray[ji+5]);
- break;
- default:
- throw std::runtime_error(EXCEPTION("GetValsOnTimeStamp - There is no an algorithm for representation of the field !!!"));
- }
- }
- }
-
- string GenerateFieldName(const VISU::TField& theField,
- const VISU::TField::TValForTime& theValForTime)
+ //---------------------------------------------------------------
+ void
+ GetGaussSubMesh(const PMeshImpl& theMesh,
+ const PMeshOnEntityImpl& theMeshOnEntity,
+ const PGaussMeshImpl& theGaussMesh,
+ const PGaussSubMeshImpl& theGaussSubMesh)
{
- const VISU::TField::TTime& aTime = theValForTime.myTime;
- string aFieldName = theField.myMeshName + ", " + theField.myName + ": " +
- VISU_Convertor::GenerateName(aTime);
- return aFieldName;
+ PGaussImpl aGauss = theGaussSubMesh->myGauss;
+ INITMSG(MYDEBUG,"GetGaussSubMesh - aVGeom = "<<aGauss->myGeom<<endl);
+
+ if(!theGaussSubMesh->myIsDone)
+ return;
+
+ if(theGaussSubMesh->myIsVTKDone)
+ return;
+
+ const TVTKSource& aSource = theGaussSubMesh->GetSource();
+ GetSource(aSource,theGaussSubMesh,theMeshOnEntity);
+ INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
+ BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
+
+ theGaussSubMesh->myIsVTKDone = true;
}
+
- void GetTimeStamp(VISU::TVTKSource& theStorage,
- const VISU::TMesh& theMesh,
- const VISU::TMeshOnEntity& theMeshOnEntity,
- const VISU::TField& theField,
- const VISU::TField::TValForTime& theValForTime)
+ //---------------------------------------------------------------
+ void
+ BuildGaussMesh(const PMeshImpl& theMesh,
+ const PMeshOnEntityImpl& theMeshOnEntity,
+ const PGaussMeshImpl& theGaussMesh)
{
- int aNumberOfTuples = theField.myDataSize/theField.myNbComp;
- string aFieldName = GenerateFieldName(theField,theValForTime);
- if(MYDEBUG)
- MESSAGE("GetTimeStamp(TVTKSource) - aFieldName = "<<aFieldName<<
- "; aNumberOfTuples = "<<aNumberOfTuples);
-
- vtkDataSetAttributes* aDataSetAttributes;
- switch(theField.myEntity){
- case VISU::NODE_ENTITY :
- aDataSetAttributes = theStorage->GetPointData();
- break;
- default:
- aDataSetAttributes = theStorage->GetCellData();
+ if(theGaussMesh->myIsVTKDone)
+ return;
+
+ INITMSG(MYDEBUG,"BuildGaussMesh"<<endl);
+ const TVTKAppendFilter& anAppendFilter = theGaussMesh->GetFilter();
+ const TGeom2GaussSubMesh& aGeom2GaussSubMesh = theGaussMesh->myGeom2GaussSubMesh;
+ TGeom2GaussSubMesh::const_iterator anIter = aGeom2GaussSubMesh.begin();
+ for(; anIter != aGeom2GaussSubMesh.end(); anIter++){
+ PGaussSubMeshImpl aGaussSubMesh = anIter->second;
+ if(aGaussSubMesh->myStatus == eRemoveAll)
+ continue;
+
+ GetGaussSubMesh(theMesh,
+ theMeshOnEntity,
+ theGaussMesh,
+ aGaussSubMesh);
+
+ const TVTKSource& aSource = aGaussSubMesh->GetSource();
+
+ anAppendFilter->AddInput(aSource.GetPointer());
}
+ anAppendFilter->Update(); // Fix on VTK
- vtkFloatArray *aFloatArray = vtkFloatArray::New();
- switch(theField.myNbComp) {
- case 1:
- aFloatArray->SetNumberOfComponents(1);
- aDataSetAttributes->SetScalars(aFloatArray);
- break;
- default:
- aFloatArray->SetNumberOfComponents(3);
- aDataSetAttributes->SetVectors(aFloatArray);
- }
+ theMeshOnEntity->GetVTKOutput()->Update();
- GetValsOnTimeStamp(aFloatArray,aNumberOfTuples,aFieldName,theField,theValForTime);
+ vtkDataSet* aSource = anAppendFilter->GetOutput();
+ INITMSGA(MYDEBUG,0,"aNbPoints - "<<aSource->GetNumberOfPoints()<<endl);
+ BEGMSG(MYDEBUG,"aNbCells - "<<aSource->GetNumberOfCells()<<endl);
+
+ theGaussMesh->myIsVTKDone = true;
}
- void GetTimeStamp(VISU::TVTKAttribyteFilter& theAttribyteFilter,
- VISU::TVTKMergetFilter& theMergeFilter,
- VISU::TVTKExtractFilter& theExtractFilter,
- const VISU::TMesh& theMesh,
- const VISU::TMeshOnEntity& theMeshOnEntity,
- const VISU::TField& theField,
- const VISU::TField::TValForTime& theValForTime)
+
+ //---------------------------------------------------------------
+ void
+ PrintMemorySize(vtkUnstructuredGrid* theDataSet)
{
- int aNumberOfTuples = theField.myDataSize/theField.myNbComp;
- string aFieldName = GenerateFieldName(theField,theValForTime);
- if(MYDEBUG)
- MESSAGE("GetTimeStamp(TVTKAttribyteFilter) - aFieldName = "<<aFieldName<<
- "; aNumberOfTuples = "<<aNumberOfTuples);
+ theDataSet->Update();
+ BEGMSG(1,"GetPoints() = "<<float(theDataSet->GetPoints()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(1,"GetCells() = "<<float(theDataSet->GetCells()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(1,"GetCellTypesArray() = "<<float(theDataSet->GetCellTypesArray()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(1,"GetCellLocationsArray() = "<<float(theDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000)<<endl);
+ theDataSet->BuildLinks();
+ BEGMSG(1,"GetCellLinks() = "<<float(theDataSet->GetCellLinks()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(1,"GetPointData() = "<<float(theDataSet->GetPointData()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(1,"GetCellData() = "<<float(theDataSet->GetCellData()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(1,"GetActualMemorySize() = "<<float(theDataSet->GetActualMemorySize()*1000)<<endl);
+ }
+}
- vtkDataObject* aDataObject = vtkDataObject::New();
- theMergeFilter->SetDataObject(aDataObject);
- aDataObject->Delete();
- theMergeFilter->SetInput(theExtractFilter->GetOutput());
- theAttribyteFilter->SetInput(theMergeFilter->GetOutput());
+//---------------------------------------------------------------
+VISU_Convertor_impl
+::VISU_Convertor_impl()
+{
+ myIsDone = false;
+}
- switch(theField.myEntity){
- case VISU::NODE_ENTITY :
- theMergeFilter->SetOutputFieldToPointDataField();
- theAttribyteFilter->SetInputFieldToPointDataField();
- theAttribyteFilter->SetOutputAttributeDataToPointData();
- break;
- default:
- theMergeFilter->SetOutputFieldToCellDataField();
- theAttribyteFilter->SetInputFieldToCellDataField();
- theAttribyteFilter->SetOutputAttributeDataToCellData();
- }
- vtkFloatArray *aFloatArray = vtkFloatArray::New();
- switch(theField.myNbComp) {
- case 1:
- aFloatArray->SetNumberOfComponents(1);
- theAttribyteFilter->SetScalarComponent(0,aFieldName.c_str(),0);
- break;
- default:
- aFloatArray->SetNumberOfComponents(3);
- theAttribyteFilter->SetVectorComponent(0,aFieldName.c_str(),0);
- theAttribyteFilter->SetVectorComponent(1,aFieldName.c_str(),1);
- theAttribyteFilter->SetVectorComponent(2,aFieldName.c_str(),2);
- }
+//---------------------------------------------------------------
+VISU_Convertor_impl
+::~VISU_Convertor_impl()
+{}
- vtkFieldData* aFieldData = aDataObject->GetFieldData();
- aFieldData->AddArray(aFloatArray);
- aFloatArray->Delete();
- GetValsOnTimeStamp(aFloatArray,aNumberOfTuples,aFieldName,theField,theValForTime);
+//---------------------------------------------------------------
+VISU_Convertor*
+VISU_Convertor_impl
+::Build()
+{
+ if(!myIsDone){
+ myIsDone = true;
+ BuildEntities();
+ BuildFields();
+ BuildMinMax();
+ BuildGroups();
}
+ return this;
}
-VISU_Convertor_impl::VISU_Convertor_impl() {
- myIsDone = false;
+VISU_Convertor*
+VISU_Convertor_impl
+::BuildEntities()
+{
+ return this;
+}
+
+VISU_Convertor*
+VISU_Convertor_impl
+::BuildFields()
+{
+ return this;
+}
+
+VISU_Convertor*
+VISU_Convertor_impl
+::BuildMinMax()
+{
+ return this;
+}
+
+VISU_Convertor*
+VISU_Convertor_impl
+::BuildGroups()
+{
+ return this;
+}
+
+
+//---------------------------------------------------------------
+VISU::PNamedIDMapper
+VISU_Convertor_impl
+::GetMeshOnEntity(const string& theMeshName,
+ const VISU::TEntity& theEntity)
+{
+ INITMSG(MYDEBUG,"GetMeshOnEntity"<<
+ "; theMeshName = '"<<theMeshName<<"'"<<
+ "; theEntity = "<<theEntity<<
+ endl);
+
+ //Cheching possibility do the query
+ TFindMeshOnEntity aFindMeshOnEntity =
+ FindMeshOnEntity(theMeshName,theEntity);
+
+ PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
+ PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
+
+ //Main part of code
+#ifndef _DEXCEPT_
+ try{
+#endif
+ if(!aMeshOnEntity->myIsVTKDone){
+ const TVTKAppendFilter& anAppendFilter = aMeshOnEntity->GetFilter();
+ if(MYVTKDEBUG) anAppendFilter->DebugOn();
+
+ LoadMeshOnEntity(aMesh,aMeshOnEntity);
+ anAppendFilter->SetPoints(GetPoints(aMesh));
+
+ const TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
+ TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
+
+ TID2ID& anElemObj2VTKID = aMeshOnEntity->myElemObj2VTKID;
+ TSubMeshArr& aSubMeshArr = aMeshOnEntity->mySubMeshArr;
+ aSubMeshArr.resize(aGeom2SubMesh.size());
+
+ for(vtkIdType anID = 0, aCellID = 0; anIter != aGeom2SubMesh.end(); anIter++, anID++){
+ EGeometry aEGeom = anIter->first;
+ vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
+ PSubMeshImpl aSubMesh = anIter->second;
+ const TVTKSource& aSource = aSubMesh->GetSource();
+ aSource->SetPoints(GetPoints(aMesh));
+ GetCellsOnSubMesh(aSource,aMeshOnEntity,aSubMesh,aVGeom);
+ anAppendFilter->AddInput(aSource.GetPointer());
+
+ aSubMesh->myStartID = aCellID;
+ vtkIdType aNbCells = aSource->GetNumberOfCells();
+ for(vtkIdType aCell = 0; aCell < aNbCells; aCell++, aCellID++){
+ vtkIdType anObjID = aSubMesh->GetElemObjID(aCell);
+ anElemObj2VTKID[anObjID] = aCellID;
+ }
+ aSubMeshArr[anID] = aSubMesh;
+ }
+ aMeshOnEntity->myNamedPointCoords = aMesh->myNamedPointCoords;
+
+ aMeshOnEntity->myIsVTKDone = true;
+
+ if(MYDEBUGWITHFILES){
+ std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
+ std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
+ aFileName += aMeshName + dtos("-%d-",int(theEntity)) + "-Conv.vtk";
+ VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
+ }
+
+ if(MYVTKDEBUG){
+ GetMeshOnEntitySize(theMeshName,theEntity);
+ PrintMemorySize(anAppendFilter->GetOutput());
+ }
+ }
+
+#ifndef _DEXCEPT_
+ }catch(...){
+ throw;
+ }
+#endif
+
+ return aMeshOnEntity;
}
-VISU_Convertor_impl::~VISU_Convertor_impl() {}
-VISU_Convertor::TOutput*
-VISU_Convertor_impl::GetMeshOnEntity(const string& theMeshName,
- const VISU::TEntity& theEntity,
- const string& theFamilyName)
+//---------------------------------------------------------------
+VISU::PIDMapper
+VISU_Convertor_impl
+::GetFamilyOnEntity(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFamilyName)
{
- if(MYDEBUG)
- MESSAGE("GetMeshOnEntity - theMeshName = '"<<theMeshName<<
- "'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
+ INITMSG(MYDEBUG,"GetFamilyOnEntity"<<
+ "; theMeshName = '"<<theMeshName<<"'"<<
+ "; theEntity = "<<theEntity<<
+ "; theFamilyName = '"<<theFamilyName<<"'"<<
+ endl);
+
//Cheching possibility do the query
- VISU::TMesh* pMesh = NULL;
- VISU::TFamily* pFamily = NULL;
- VISU::TMeshOnEntity* pMeshOnEntity = NULL;
- FindMeshOnEntity(theMeshName,pMesh,theEntity,pMeshOnEntity,theFamilyName,pFamily);
- VISU::TMesh& aMesh = *pMesh;
- VISU::TMeshOnEntity& aMeshOnEntity = *pMeshOnEntity;
- VISU::TVTKSource* pSource;
- if(pFamily != NULL)
- pSource = &(pFamily->myStorage);
- else
- pSource = &(aMeshOnEntity.myStorage);
- VISU::TVTKSource& aSource = *pSource;
+ TFindFamilyOnEntity aFindFamilyOnEntity =
+ FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
+
+ PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);;
+ PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
+ PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
+
//Main part of code
+#ifndef _DEXCEPT_
try{
- if(aSource.GetPointer() == NULL){
- aSource = TOutput::New();
- aSource->Delete();
+#endif
+ if(!aFamily->myIsVTKDone){
+ const TVTKSource& aSource = aFamily->GetSource();
if(MYVTKDEBUG) aSource->DebugOn();
- LoadMeshOnEntity(aMeshOnEntity,theFamilyName);
- GetPoints(aSource,aMesh);
- GetCellsOnEntity(aSource,aMeshOnEntity,theFamilyName);
+
+ GetMeshOnEntity(theMeshName,theEntity);
+
+ LoadFamilyOnEntity(aMesh,aMeshOnEntity,aFamily);
+ aSource->SetPoints(GetPoints(aMesh));
+ GetCellsOnFamily(aSource,aMeshOnEntity,aFamily);
+
+ aFamily->myNamedPointCoords = aMesh->myNamedPointCoords;
+
+ aFamily->myIsVTKDone = true;
+
if(MYDEBUGWITHFILES){
- string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
- string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1();
- string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
+ std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
+ std::string aFamilyName = QString(theFamilyName.c_str()).simplifyWhiteSpace().latin1();
+ std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
aFileName += aMeshName + dtos("-%d-",int(theEntity)) + aFamilyName + "-Conv.vtk";
VISU::WriteToFile(aSource.GetPointer(),aFileName);
}
+
+ if(MYVTKDEBUG){
+ GetFamilyOnEntitySize(theMeshName,theEntity,theFamilyName);
+ PrintMemorySize(aSource.GetPointer());
+ }
}
- if(MYVTKDEBUG){
- GetMeshOnEntitySize(theMeshName,theEntity,theFamilyName);
- vtkUnstructuredGrid* aDataSet = aSource.GetPointer();
- aDataSet->Update();
- MESSAGE("GetMeshOnEntity - GetPoints() = "<<float(aDataSet->GetPoints()->GetActualMemorySize()*1000));
- MESSAGE("GetMeshOnEntity - GetCells() = "<<float(aDataSet->GetCells()->GetActualMemorySize()*1000));
- MESSAGE("GetMeshOnEntity - GetCellTypesArray() = "<<float(aDataSet->GetCellTypesArray()->GetActualMemorySize()*1000));
- MESSAGE("GetMeshOnEntity - GetCellLocationsArray() = "<<float(aDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000));
- aDataSet->BuildLinks();
- MESSAGE("GetMeshOnEntity - GetCellLinks() = "<<float(aDataSet->GetCellLinks()->GetActualMemorySize()*1000));
- MESSAGE("GetMeshOnEntity - GetActualMemorySize() = "<<float(aDataSet->GetActualMemorySize()*1000));
- }
+
+#ifndef _DEXCEPT_
}catch(...){
- aSource = vtkSmartPointerBase();
throw;
}
- return aSource.GetPointer();
+#endif
+
+ return aFamily;
}
-VISU_Convertor::TOutput*
-VISU_Convertor_impl::GetMeshOnGroup(const string& theMeshName,
- const string& theGroupName)
+
+//---------------------------------------------------------------
+VISU::PIDMapper
+VISU_Convertor_impl
+::GetMeshOnGroup(const string& theMeshName,
+ const string& theGroupName)
{
- if(MYDEBUG) MESSAGE("GetMeshOnGroup - theMeshName = '"<<theMeshName<<
- "'; theGroupName = '"<<theGroupName<<"'");
+ INITMSG(MYDEBUG,"GetMeshOnGroup\n");
+ INITMSGA(MYDEBUG,0,
+ "- theMeshName = '"<<theMeshName<<
+ "'; theGroupName = '"<<theGroupName<<"'"<<
+ endl);
+
//Cheching possibility do the query
- VISU::TMesh* pMesh = NULL;
- VISU::TGroup* pGroup = NULL;
- FindMeshOnGroup(theMeshName,pMesh,theGroupName,pGroup);
- VISU::TMesh& aMesh = *pMesh;
- VISU::TGroup& aGroup = *pGroup;
- const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup.myFamilyAndEntitySet;
- VISU::TVTKSource& aSource = aGroup.myStorage;
+ TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
+ PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
+ PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
+
//Main part of code
+#ifndef _DEXCEPT_
try{
- if(aSource.GetPointer() == NULL){
- aSource = TOutput::New();
- aSource->Delete();
- LoadMeshOnGroup(aMesh,aFamilyAndEntitySet);
- GetPoints(aSource,aMesh);
- GetCellsOnGroup(aSource,aMesh,aFamilyAndEntitySet);
+#endif
+ if(!aGroup->myIsVTKDone){
+ const TVTKAppendFilter& anAppendFilter = aGroup->GetFilter();
+ const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
+
+ LoadMeshOnGroup(aMesh,aFamilySet);
+ anAppendFilter->SetPoints(GetPoints(aMesh));
+
+ TFamilySet::const_iterator anIter = aFamilySet.begin();
+
+ TID2ID& anElemObj2VTKID = aGroup->myElemObj2VTKID;
+ TFamilyArr& aFamilyArr = aGroup->myFamilyArr;
+ aFamilyArr.resize(aFamilySet.size());
+
+ for(vtkIdType anID = 0; anIter != aFamilySet.end(); anIter++){
+ PFamilyImpl aFamily = *anIter;
+ const std::string& aFamilyName = aFamily->myName;
+ const VISU::TEntity& anEntity = aFamily->myEntity;
+
+ VISU::PIDMapper anIDMapper = GetFamilyOnEntity(theMeshName,anEntity,aFamilyName);
+ VISU::TVTKOutput* anOutput = anIDMapper->GetVTKOutput();
+ anAppendFilter->AddInput(anOutput);
+
+ vtkIdType aNbCells = anOutput->GetNumberOfCells();
+ for(vtkIdType aCellID = 0; aCellID < aNbCells; aCellID++){
+ anElemObj2VTKID[aFamily->GetElemObjID(aCellID)] = aCellID;
+ }
+ aFamilyArr[anID] = aFamily;
+ }
+ aGroup->myNamedPointCoords = aMesh->myNamedPointCoords;
+
+ aGroup->myIsVTKDone = true;
+
if(MYDEBUGWITHFILES){
- string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
- string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1();
- string aFileName = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
+ std::string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
+ std::string aGroupName = QString(theGroupName.c_str()).simplifyWhiteSpace().latin1();
+ std::string aFileName = string(getenv("HOME"))+"/"+getenv("USER")+"-";
aFileName += aMeshName + "-" + aGroupName + "-Conv.vtk";
- VISU::WriteToFile(aSource.GetPointer(),aFileName);
+ VISU::WriteToFile(anAppendFilter->GetOutput(),aFileName);
}
}
+#ifndef _DEXCEPT_
}catch(...){
- aSource = vtkSmartPointerBase();
throw;
}
- return aSource.GetPointer();
+#endif
+
+ return aGroup;
}
-VISU_Convertor::TOutput*
-VISU_Convertor_impl::GetTimeStampOnMesh(const string& theMeshName,
- const VISU::TEntity& theEntity,
- const string& theFieldName,
- int theStampsNum)
+
+//---------------------------------------------------------------
+VISU::TVTKOutput*
+VISU_Convertor_impl
+::GetTimeStampOnProfile(const VISU::PMeshImpl& theMesh,
+ const VISU::PMeshOnEntityImpl& theMeshOnEntity,
+ const VISU::PFieldImpl& theField,
+ const VISU::PValForTimeImpl& theValForTime,
+ const VISU::PIDMapperFilter& theIDMapperFilter,
+ const VISU::PProfileImpl& theProfile,
+ const VISU::TEntity& theEntity)
{
- if(MYDEBUG){
- MESSAGE("GetTimeStampOnMesh - theMeshName = '"<<theMeshName<<"; theEntity = "<<theEntity);
- MESSAGE("GetTimeStampOnMesh - theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
+ LoadMeshOnEntity(theMesh,theMeshOnEntity);
+ GetMeshOnEntity(theMeshOnEntity->myMeshName,theMeshOnEntity->myEntity);
+ GetMeshOnProfile(theMesh,theMeshOnEntity,theProfile);
+
+ theIDMapperFilter->myIDMapper = theProfile;
+ TVTKOutput* anOutput = theIDMapperFilter->GetVTKOutput();
+ const TVTKSource& aSource = theIDMapperFilter->mySource.GetSource();
+ ::GetTimeStampOnProfile(aSource,theField,theValForTime,theEntity);
+
+ return anOutput;
+}
+
+
+//---------------------------------------------------------------
+VISU::PIDMapper
+VISU_Convertor_impl
+::GetTimeStampOnMesh(const string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const string& theFieldName,
+ int theStampsNum)
+{
+ INITMSG(MYDEBUG,"GetTimeStampOnMesh"<<
+ "; theMeshName = '"<<theMeshName<<"'"<<
+ "; theEntity = "<<theEntity<<
+ "; theFieldName = '"<<theFieldName<<"'"<<
+ "; theStampsNum = "<<theStampsNum<<
+ endl);
+
+ //Cheching possibility do the query
+ TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
+ theEntity,
+ theFieldName,
+ theStampsNum);
+
+ PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
+ PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
+ PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
+ PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
+ PFieldImpl aField = boost::get<3>(aFindTimeStamp);
+
+ //Main part of code
+ PIDMapperFilter anIDMapperFilter = aValForTime->myIDMapperFilter;
+#ifndef _DEXCEPT_
+ try{
+#endif
+ if(!anIDMapperFilter->myIsVTKDone){
+ LoadValForTimeOnMesh(aMesh,aMeshOnEntity,aField,aValForTime);
+
+ TVTKOutput* anOutput;
+ try{
+ anOutput = GetTimeStampOnProfile(aMesh,
+ aVTKMeshOnEntity,
+ aField,
+ aValForTime,
+ anIDMapperFilter,
+ aValForTime->myProfile,
+ aMeshOnEntity->myEntity);
+ }catch(std::exception& exc){
+ MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
+ anOutput = GetTimeStampOnProfile(aMesh,
+ aMeshOnEntity,
+ aField,
+ aValForTime,
+ anIDMapperFilter,
+ aValForTime->myProfile,
+ aVTKMeshOnEntity->myEntity);
+ }
+
+ anIDMapperFilter->myIsVTKDone = true;
+
+ if(MYDEBUGWITHFILES){
+ string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
+ string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
+ string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-";
+ string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
+ aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk";
+ VISU::WriteToFile(anOutput,aFileName);
+ }
+ if(MYVTKDEBUG){
+ GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum);
+ anOutput->Update();
+ if(theEntity == VISU::NODE_ENTITY)
+ BEGMSG(MYVTKDEBUG,"GetPointData() = "<<float(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
+ else
+ BEGMSG(MYVTKDEBUG,"GetCellData() = "<<float(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<float(anOutput->GetActualMemorySize()*1000)<<endl);
+ }
+ }
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ throw;
+ }catch(...){
+ throw;
}
+#endif
+
+ return anIDMapperFilter;
+}
+
+
+//---------------------------------------------------------------
+VISU::PGaussPtsIDMapper
+VISU_Convertor_impl
+::GetTimeStampOnGaussPts(const string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const string& theFieldName,
+ int theStampsNum)
+{
+ INITMSG(MYDEBUG,"GetTimeStampOnGaussPts"<<
+ "; theMeshName = '"<<theMeshName<<"'"<<
+ "; theEntity = "<<theEntity<<
+ "; theFieldName = '"<<theFieldName<<"'"<<
+ "; theStampsNum = "<<theStampsNum<<
+ endl);
+
//Cheching possibility do the query
- VISU::TMesh* pMesh = NULL;
- VISU::TField* pField = NULL;
- VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL;
- VISU::TField::TValForTime* pValForTime = NULL;
- FindTimeStamp(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity,
- theFieldName,pField,theStampsNum,pValForTime);
- VISU::TMesh& aMesh = *pMesh;
- VISU::TMeshOnEntity& aMeshOnEntity = *pMeshOnEntity;
- VISU::TField& aField = *pField;
- VISU::TField::TValForTime& aValForTime = *pValForTime;
- VISU::TVTKAttribyteFilter& anAttribyteFilter = aValForTime.myAttribyteFilter;
- VISU::TVTKSource& aSource = aValForTime.myStorage;
- TOutput* anOutput = NULL;
+ TFindTimeStamp aFindTimeStamp = FindTimeStamp(theMeshName,
+ theEntity,
+ theFieldName,
+ theStampsNum);
+
+ PMeshImpl aMesh = boost::get<0>(aFindTimeStamp);
+ PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindTimeStamp);
+ PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
+ PValForTimeImpl aValForTime = boost::get<4>(aFindTimeStamp);
+ PFieldImpl aField = boost::get<3>(aFindTimeStamp);
+
//Main part of code
+ PGaussPtsIDFilter aGaussPtsIDFilter = aValForTime->myGaussPtsIDFilter;
+#ifndef _DEXCEPT_
try{
- if(aSource.GetPointer())
- return aSource.GetPointer();
- else if(anAttribyteFilter.GetPointer())
- return anAttribyteFilter->GetUnstructuredGridOutput();
- else{
- LoadFieldOnMesh(aMesh,aMeshOnEntity,aField,aValForTime);
-
- VISU::TVTKExtractFilter& anExtractFilter = aField.myExtractFilter;
- if(anExtractFilter.GetPointer() == NULL){
- anExtractFilter = VISU_ExtractUnstructuredGrid::New();
- anExtractFilter->Delete();
- //anExtractFilter->DebugOn();
- try{
- LoadMeshOnEntity(*pVTKMeshOnEntity);
- }catch(std::runtime_error& exc){
- pVTKMeshOnEntity = pMeshOnEntity;
- MESSAGE("Follow exception was accured :\n"<<exc.what());
- }catch(...){
- pVTKMeshOnEntity = pMeshOnEntity;
- MESSAGE("Unknown exception was accured!");
- }
- GetMeshOnEntity(pVTKMeshOnEntity->myMeshName,pVTKMeshOnEntity->myEntity);
-
- anExtractFilter->SetInput(pVTKMeshOnEntity->myStorage.GetPointer());
- ::InitProfile(anExtractFilter,*pMeshOnEntity,aValForTime);
- }
- if(!anExtractFilter->IsRemoving()){
- aSource = TOutput::New();
- aSource->Delete();
- aSource->ShallowCopy(pVTKMeshOnEntity->myStorage.GetPointer());
- ::GetTimeStamp(aSource,aMesh,*pVTKMeshOnEntity,aField,aValForTime);
- anOutput = aSource.GetPointer();
- }else{
- anAttribyteFilter = vtkFieldDataToAttributeDataFilter::New();
- anAttribyteFilter->Delete();
- //anAttribyteFilter->DebugOn();
-
- VISU::TVTKMergetFilter& aMergeFilter = aValForTime.myMergeFilter;
- aMergeFilter = vtkMergeDataObjectFilter::New();
- aMergeFilter->Delete();
- //aMergeFilter->DebugOn();
-
- ::GetTimeStamp(anAttribyteFilter,aMergeFilter,anExtractFilter,
- aMesh,*pVTKMeshOnEntity,aField,aValForTime);
- anOutput = anAttribyteFilter->GetUnstructuredGridOutput();
+#endif
+ if(!aGaussPtsIDFilter->myIsVTKDone){
+ LoadValForTimeOnGaussPts(aMesh,aMeshOnEntity,aField,aValForTime);
+
+ GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity);
+
+ PProfileImpl aProfile = aValForTime->myProfile;
+ GetMeshOnProfile(aMesh,aVTKMeshOnEntity,aProfile);
+
+ PGaussMeshImpl aGaussMesh = aValForTime->myGaussMesh;
+ TSource& aGaussPtsSource = aGaussMesh->mySource;
+ if(!aGaussPtsSource.myIsVTKDone){
+ BuildGaussMesh(aMesh,aVTKMeshOnEntity,aGaussMesh);
+ aGaussMesh->myParent = aProfile.get();
+ aGaussPtsSource.myIsVTKDone = true;
}
+
+ aGaussPtsIDFilter->myIDMapper = aGaussMesh;
+ aGaussPtsIDFilter->myGaussPtsIDMapper = aGaussMesh;
+ TVTKOutput* anOutput = aGaussPtsIDFilter->GetVTKOutput();
+ const TVTKSource& aSource = aGaussPtsIDFilter->mySource.GetSource();
+ GetTimeStampOnGaussMesh(aSource,aField,aValForTime);
+
+ aGaussPtsIDFilter->myIsVTKDone = true;
+
if(MYDEBUGWITHFILES){
string aMeshName = QString(theMeshName.c_str()).simplifyWhiteSpace().latin1();
string aFieldName = QString(theFieldName.c_str()).simplifyWhiteSpace().latin1();
- string aPrefix = string("/users/")+getenv("USER")+"/"+getenv("USER")+"-";
+ string aPrefix = string(getenv("HOME"))+"/"+getenv("USER")+"-";
string aFileName = aPrefix + aMeshName + dtos("-%d-",int(theEntity)) +
aFieldName + dtos("-%d",theStampsNum) + "-Conv.vtk";
VISU::WriteToFile(anOutput,aFileName);
}
if(MYVTKDEBUG){
GetTimeStampSize(theMeshName,theEntity,theFieldName,theStampsNum);
- vtkUnstructuredGrid *aDataSet = anAttribyteFilter->GetUnstructuredGridOutput();
- aDataSet->Update();
+ anOutput->Update();
if(theEntity == VISU::NODE_ENTITY)
- MESSAGE("GetTimeStampOnMesh - GetData() = "<<float(aDataSet->GetPointData()->GetActualMemorySize()*1000));
+ BEGMSG(MYVTKDEBUG,"GetPointData() = "<<float(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
else
- MESSAGE("GetMeshOnEntity - GetData() = "<<float(aDataSet->GetCellData()->GetActualMemorySize()*1000));
- MESSAGE("GetTimeStampOnMesh - GetActualMemorySize() = "<<float(aDataSet->GetActualMemorySize()*1000));
+ BEGMSG(MYVTKDEBUG,"GetCellData() = "<<float(anOutput->GetCellData()->GetActualMemorySize()*1000)<<endl);
+ BEGMSG(MYVTKDEBUG,"GetActualMemorySize() = "<<float(anOutput->GetActualMemorySize()*1000)<<endl);
}
}
+#ifndef _DEXCEPT_
+ }catch(std::exception& exc){
+ throw;
}catch(...){
- aSource = vtkSmartPointerBase();
- anAttribyteFilter = vtkSmartPointerBase();
throw;
}
- return anOutput;
+#endif
+
+ return aGaussPtsIDFilter;
}
-void VISU_Convertor_impl::FindMesh(const string& theMeshName, VISU::TMesh*& theMesh)
+//---------------------------------------------------------------
+VISU::PMeshImpl
+VISU_Convertor_impl
+::FindMesh(const string& theMeshName)
{
GetMeshMap();
- if(myMeshMap.find(theMeshName) == myMeshMap.end())
- throw std::runtime_error(EXCEPT("FindMesh >> There is no mesh with the name - '%1'!!!").
- arg(theMeshName.c_str()).latin1());
- theMesh = &myMeshMap[theMeshName];
+ TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName);
+ if(aMeshMapIter == myMeshMap.end())
+ EXCEPTION(runtime_error,"FindMesh >> There is no mesh with the name - '"<<theMeshName<<"'!!!");
+
+ PMeshImpl aMesh = aMeshMapIter->second;
+ return aMesh;
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor_impl::TFindMeshOnEntity
+VISU_Convertor_impl
+::FindMeshOnEntity(const string& theMeshName,
+ const VISU::TEntity& theEntity)
+{
+ PMeshImpl aMesh = FindMesh(theMeshName);
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
+ if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
+ EXCEPTION(runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
+
+ PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
+
+ return TFindMeshOnEntity(aMesh,
+ aMeshOnEntity);
}
-void VISU_Convertor_impl::FindMeshOnEntity(const string& theMeshName,
- VISU::TMesh*& theMesh,
- const VISU::TEntity& theEntity,
- VISU::TMeshOnEntity*& theMeshOnEntity,
- const string& theFamilyName,
- VISU::TFamily*& theFamily)
+//---------------------------------------------------------------
+VISU_Convertor_impl::TFindFamilyOnEntity
+VISU_Convertor_impl
+::FindFamilyOnEntity(const string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const string& theFamilyName)
{
- FindMesh(theMeshName,theMesh);
- VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
- if(aMeshOnEntityMap.find(theEntity) == aMeshOnEntityMap.end())
- throw std::runtime_error(EXCEPT("FindMeshOnEntity >> There is no mesh on the entity - %1!!!").
- arg(int(theEntity)).latin1());
- theMeshOnEntity = &aMeshOnEntityMap[theEntity];
- theFamily = VISU::GetFamily(*theMeshOnEntity,theFamilyName);
+ if(theFamilyName != ""){
+ PMeshImpl aMesh = FindMesh(theMeshName);
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter = aMeshOnEntityMap.find(theEntity);
+ if(aMeshOnEntityMapIter == aMeshOnEntityMap.end())
+ EXCEPTION(runtime_error,"FindFamilyOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
+
+ PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
+
+ TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
+ TFamilyMap::iterator aFamilyMapIter = aFamilyMap.find(theFamilyName);
+ if(aFamilyMapIter != aFamilyMap.end()){
+ const PFamily& aFamily = aFamilyMapIter->second;
+ return TFindFamilyOnEntity(aMesh,
+ aMeshOnEntity,
+ aFamily);
+ }
+ }
+ return TFindFamilyOnEntity();
}
-float VISU_Convertor_impl::GetSize() {
+//---------------------------------------------------------------
+float
+VISU_Convertor_impl
+::GetSize()
+{
float aResult = 0.0;
const VISU::TMeshMap& aMeshMap = GetMeshMap();
VISU::TMeshMap::const_iterator aMeshMapIter = aMeshMap.begin();
for(; aMeshMapIter != aMeshMap.end(); aMeshMapIter++){
const string& aMeshName = aMeshMapIter->first;
- const VISU::TMesh& aMesh = aMeshMapIter->second;
- const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh.myMeshOnEntityMap;
+ const VISU::PMesh aMesh = aMeshMapIter->second;
+ const VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
VISU::TMeshOnEntityMap::const_iterator aMeshOnEntityMapIter;
//Import fields
aMeshOnEntityMapIter = aMeshOnEntityMap.begin();
for(; aMeshOnEntityMapIter != aMeshOnEntityMap.end(); aMeshOnEntityMapIter++){
const VISU::TEntity& anEntity = aMeshOnEntityMapIter->first;
- const VISU::TMeshOnEntity& aMeshOnEntity = aMeshOnEntityMapIter->second;
- const VISU::TFieldMap& aFieldMap = aMeshOnEntity.myFieldMap;
+ const VISU::PMeshOnEntity aMeshOnEntity = aMeshOnEntityMapIter->second;
+ const VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
VISU::TFieldMap::const_iterator aFieldMapIter = aFieldMap.begin();
for(; aFieldMapIter != aFieldMap.end(); aFieldMapIter++){
const string& aFieldName = aFieldMapIter->first;
- const VISU::TField& aField = aFieldMapIter->second;
- const VISU::TField::TValField& aValField = aField.myValField;
- VISU::TField::TValField::const_iterator aValFieldIter = aValField.begin();
+ const VISU::PField aField = aFieldMapIter->second;
+ const VISU::TValField& aValField = aField->myValField;
+ VISU::TValField::const_iterator aValFieldIter = aValField.begin();
for(; aValFieldIter != aValField.end(); aValFieldIter++){
int aTimeStamp = aValFieldIter->first;
aResult += GetTimeStampSize(aMeshName,anEntity,aFieldName,aTimeStamp);
}
}
//Importing groups
- const VISU::TGroupMap& aGroupMap = aMesh.myGroupMap;
+ const VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
VISU::TGroupMap::const_iterator aGroupMapIter = aGroupMap.begin();
for(; aGroupMapIter != aGroupMap.end(); aGroupMapIter++){
const string& aGroupName = aGroupMapIter->first;
aResult += GetMeshOnGroupSize(aMeshName,aGroupName);
}
//Import families
- const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity.myFamilyMap;
+ const VISU::TFamilyMap& aFamilyMap = aMeshOnEntity->myFamilyMap;
VISU::TFamilyMap::const_iterator aFamilyMapIter = aFamilyMap.begin();
for(; aFamilyMapIter != aFamilyMap.end(); aFamilyMapIter++){
const string& aFamilyName = aFamilyMapIter->first;
- aResult += GetMeshOnEntitySize(aMeshName,anEntity,aFamilyName);
+ aResult += GetFamilyOnEntitySize(aMeshName,anEntity,aFamilyName);
}
//Import mesh on entity
aResult += GetMeshOnEntitySize(aMeshName,anEntity);
}
}
- if(MYDEBUG)
- MESSAGE("GetSize - aResult = "<<float(aResult));
+ MSG(MYDEBUG,"GetSize - aResult = "<<float(aResult));
return aResult;
}
-float VISU_Convertor_impl::GetMeshOnEntitySize(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFamilyName)
+//---------------------------------------------------------------
+float
+VISU_Convertor_impl
+::GetMeshOnEntitySize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity)
{
- VISU::TMesh* pMesh = NULL;
- VISU::TFamily* pFamily = NULL;
- VISU::TMeshOnEntity* pMeshOnEntity = NULL;
- FindMeshOnEntity(theMeshName,pMesh,theEntity,pMeshOnEntity,theFamilyName,pFamily);
- vtkIdType aPointsSize = 3*pMesh->myNbPoints*sizeof(VISU::TMesh::TCoord);
- vtkIdType aNbCells, aCellsSize;
- if(!pFamily){
- aNbCells = pMeshOnEntity->myNbCells;
- aCellsSize = pMeshOnEntity->myCellsSize;
- }else{
- aNbCells = pFamily->myNbCells;
- aCellsSize = pFamily->myCellsSize;
+ TFindMeshOnEntity aFindMeshOnEntity =
+ FindMeshOnEntity(theMeshName,theEntity);
+
+ PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
+ PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
+
+ vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
+ vtkIdType aNbCells = aMeshOnEntity->myNbCells;
+ vtkIdType aCellsSize = aMeshOnEntity->myCellsSize;
+
+ vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
+ vtkIdType aTypesSize = aNbCells*sizeof(char);
+ vtkIdType aLocationsSize = aNbCells*sizeof(int);
+ float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
+ vtkIdType aLinksSize = aMesh->myNbPoints *
+ (vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
+ aLinksSize = 0;
+ vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
+
+ MSG(MYDEBUG,"GetMeshOnEntitySize "<<
+ "- aResult = "<<float(aResult)<<
+ "; theMeshName = '"<<theMeshName<<"'"<<
+ "; theEntity = "<<theEntity);
+ if(MYDEBUG){
+ INITMSG(MYVTKDEBUG,"- aPointsSize = "<<float(aPointsSize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<float(aConnectivitySize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<float(aTypesSize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<float(aLocationsSize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<float(aLinksSize)<<"\n");
}
+
+ aResult = vtkIdType(aResult*ERR_SIZE_CALC);
+ return aResult;
+}
+
+
+//---------------------------------------------------------------
+float
+VISU_Convertor_impl
+::GetFamilyOnEntitySize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFamilyName)
+{
+ TFindFamilyOnEntity aFindFamilyOnEntity =
+ FindFamilyOnEntity(theMeshName,theEntity,theFamilyName);
+ PMeshImpl aMesh = boost::get<0>(aFindFamilyOnEntity);
+ PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
+ PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
+
+ vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
+ vtkIdType aNbCells = aFamily->myNbCells;
+ vtkIdType aCellsSize = aFamily->myCellsSize;
+
vtkIdType aConnectivitySize = aCellsSize*sizeof(vtkIdType);
vtkIdType aTypesSize = aNbCells*sizeof(char);
vtkIdType aLocationsSize = aNbCells*sizeof(int);
float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
- vtkIdType aLinksSize = pMesh->myNbPoints *
+ vtkIdType aLinksSize = aMesh->myNbPoints *
(vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
aLinksSize = 0;
vtkIdType aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
+
+ MSG(MYDEBUG,"GetFamilyOnEntitySize "<<
+ "- aResult = "<<float(aResult)<<
+ "; theMeshName = '"<<theMeshName<<"'"<<
+ "; theEntity = "<<theEntity<<
+ "; theFamilyName = '"<<theFamilyName<<"'");
if(MYDEBUG){
- if(MYVTKDEBUG){
- MESSAGE("GetMeshOnEntitySize - aPointsSize = "<<float(aPointsSize));
- MESSAGE("GetMeshOnEntitySize - aConnectivitySize = "<<float(aConnectivitySize));
- MESSAGE("GetMeshOnEntitySize - aTypesSize = "<<float(aTypesSize));
- MESSAGE("GetMeshOnEntitySize - aLocationsSize = "<<float(aLocationsSize));
- MESSAGE("GetMeshOnEntitySize - aLinksSize = "<<float(aLinksSize));
- }
- MESSAGE("GetMeshOnEntitySize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
- "'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
+ INITMSG(MYVTKDEBUG,"- aPointsSize = "<<float(aPointsSize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aConnectivitySize = "<<float(aConnectivitySize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aTypesSize = "<<float(aTypesSize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aLocationsSize = "<<float(aLocationsSize)<<"\n");
+ BEGMSG(MYVTKDEBUG,"- aLinksSize = "<<float(aLinksSize)<<"\n");
}
+
aResult = vtkIdType(aResult*ERR_SIZE_CALC);
return aResult;
}
-void VISU_Convertor_impl::FindMeshOnGroup(const std::string& theMeshName, VISU::TMesh*& theMesh,
- const std::string& theGroupName, VISU::TGroup*& theGroup)
+//---------------------------------------------------------------
+VISU_Convertor_impl::TFindMeshOnGroup
+VISU_Convertor_impl
+::FindMeshOnGroup(const std::string& theMeshName,
+ const std::string& theGroupName)
{
- FindMesh(theMeshName,theMesh);
- VISU::TGroupMap& aGroupMap = theMesh->myGroupMap;
+ PMeshImpl aMesh = FindMesh(theMeshName);
+ VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
VISU::TGroupMap::iterator aGroupMapIter = aGroupMap.find(theGroupName);
if(aGroupMapIter == aGroupMap.end())
- throw std::runtime_error(EXCEPT("FindMesh >> There is no the group in the mesh!!! - '%1'").arg(theGroupName.c_str()).latin1());
- theGroup = &aGroupMapIter->second;
+ EXCEPTION(runtime_error,"FindMesh >> There is no the group in the mesh!!! - '"<<theGroupName<<"'");
+
+ VISU::PGroupImpl aGroup = aGroupMapIter->second;
+ return TFindMeshOnGroup(aMesh,aGroup);
}
-float VISU_Convertor_impl::GetMeshOnGroupSize(const std::string& theMeshName,
- const std::string& theGroupName)
+float
+VISU_Convertor_impl
+::GetMeshOnGroupSize(const std::string& theMeshName,
+ const std::string& theGroupName)
{
- VISU::TMesh* pMesh = NULL;
- VISU::TGroup* pGroup = NULL;
- FindMeshOnGroup(theMeshName,pMesh,theGroupName,pGroup);
- vtkIdType aPointsSize = 3*pMesh->myNbPoints*sizeof(VISU::TMesh::TCoord);
- vtkIdType aNbCells = pGroup->myNbCells, aCellsSize = pGroup->myCellsSize;
+ TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
+ PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
+ PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
+
+ vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
+ TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells();
+ vtkIdType aNbCells = aNbASizeCells.first;
+ vtkIdType aCellsSize = aNbASizeCells.second;
vtkIdType aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
vtkIdType aLocationsSize = aNbCells*sizeof(int);
float aNbCellsPerPoint = aCellsSize / aNbCells - 1;
- vtkIdType aLinksSize = pMesh->myNbPoints *
+ vtkIdType aLinksSize = aMesh->myNbPoints *
(vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
aLinksSize = 0;
vtkIdType aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
if(MYDEBUG){
- if(MYVTKDEBUG){
- MESSAGE("GetMeshOnGroupSize - aPointsSize = "<<float(aPointsSize));
- MESSAGE("GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<float(aConnectivityAndTypesSize));
- MESSAGE("GetMeshOnGroupSize - aLocationsSize = "<<float(aLocationsSize));
- MESSAGE("GetMeshOnGroupSize - aLinksSize = "<<float(aLinksSize));
- }
- MESSAGE("GetMeshOnGroupSize - aResult = "<<float(aResult)<<"; theMeshName = '"
- <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
+ MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aPointsSize = "<<float(aPointsSize));
+ MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aConnectivityAndTypesSize = "<<float(aConnectivityAndTypesSize));
+ MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLocationsSize = "<<float(aLocationsSize));
+ MSG(MYVTKDEBUG,"GetMeshOnGroupSize - aLinksSize = "<<float(aLinksSize));
}
+ MSG(MYDEBUG,"GetMeshOnGroupSize - aResult = "<<float(aResult)<<"; theMeshName = '"
+ <<theMeshName<<"'; theGroupName = '"<<theGroupName<<"'");
+
aResult = vtkIdType(aResult*ERR_SIZE_CALC);
return aResult;
}
-void VISU_Convertor_impl::FindField(const string& theMeshName, VISU::TMesh*& theMesh,
- const VISU::TEntity& theEntity,
- VISU::TMeshOnEntity*& theMeshOnEntity,
- VISU::TMeshOnEntity*& theVTKMeshOnEntity,
- const string& theFieldName, VISU::TField*& theField)
+VISU_Convertor_impl::TFindField
+VISU_Convertor_impl
+::FindField(const string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const string& theFieldName)
{
- VISU::TFamily* pFamily = NULL;
- VISU::TMeshOnEntity* pMeshOnEntity = NULL;
- FindMeshOnEntity(theMeshName,theMesh,theEntity,pMeshOnEntity,"",pFamily);
- theMeshOnEntity = pMeshOnEntity;
- VISU::TMeshOnEntityMap& aMeshOnEntityMap = theMesh->myMeshOnEntityMap;
+ TFindMeshOnEntity aFindMeshOnEntity =
+ FindMeshOnEntity(theMeshName,theEntity);
+
+ PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
+ PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
+
+ VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
+ PMeshOnEntityImpl aVTKMeshOnEntity;
if(theEntity == VISU::NODE_ENTITY){
if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) != aMeshOnEntityMap.end())
- pMeshOnEntity = &aMeshOnEntityMap[VISU::CELL_ENTITY];
+ aVTKMeshOnEntity = aMeshOnEntityMap[VISU::CELL_ENTITY];
else if(aMeshOnEntityMap.find(VISU::FACE_ENTITY) != aMeshOnEntityMap.end())
- pMeshOnEntity = &aMeshOnEntityMap[VISU::FACE_ENTITY];
+ aVTKMeshOnEntity = aMeshOnEntityMap[VISU::FACE_ENTITY];
else if(aMeshOnEntityMap.find(VISU::NODE_ENTITY) != aMeshOnEntityMap.end())
- pMeshOnEntity = &aMeshOnEntityMap[VISU::EDGE_ENTITY];
- }
- theVTKMeshOnEntity = pMeshOnEntity;
- VISU::TFieldMap& aFieldMap = theMeshOnEntity->myFieldMap;
- if(aFieldMap.find(theFieldName) == aFieldMap.end())
- throw std::runtime_error(EXCEPTION("FindField >> There is no field on the mesh!!!"));
- theField = &aFieldMap[theFieldName];
+ aVTKMeshOnEntity = aMeshOnEntityMap[VISU::EDGE_ENTITY];
+ }else
+ aVTKMeshOnEntity = aMeshOnEntity;
+
+ VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find(theFieldName);
+ if(aFieldIter == aFieldMap.end())
+ EXCEPTION(runtime_error,"FindField >> There is no field on the mesh!!!");
+
+ PFieldImpl aField = aFieldIter->second;
+
+ return TFindField(aMesh,
+ aMeshOnEntity,
+ aVTKMeshOnEntity,
+ aField);
}
-float VISU_Convertor_impl::GetFieldOnMeshSize(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName)
+float
+VISU_Convertor_impl
+::GetFieldOnMeshSize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName)
{
- VISU::TMesh* pMesh = NULL;
- VISU::TField* pField = NULL;
- VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL;
- FindField(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity,
- theFieldName,pField);
- float aMeshSize = GetMeshOnEntitySize(theMeshName,pVTKMeshOnEntity->myEntity);
- float aFieldOnMeshSize = float(pField->myDataSize*sizeof(float)*pField->myNbValField * ERR_SIZE_CALC);
+ TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
+ PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
+ PFieldImpl aField = boost::get<3>(aFindField);
+
+ float aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
+ float aFieldOnMeshSize = float(aField->myDataSize*sizeof(float)*aField->myValField.size()*ERR_SIZE_CALC);
float aResult = aMeshSize + aFieldOnMeshSize;
- if(MYDEBUG){
- if(MYVTKDEBUG)
- MESSAGE("GetFieldOnMeshSize - aFieldOnMeshSize = "<<float(aFieldOnMeshSize));
- MESSAGE("GetFieldOnMeshSize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
- "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
- }
+ if(MYDEBUG)
+ MSG(MYVTKDEBUG,"GetFieldOnMeshSize - aFieldOnMeshSize = "<<float(aFieldOnMeshSize));
+ MSG(MYDEBUG,"GetFieldOnMeshSize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
+ "'; theEntity = "<<theEntity<<"; theFieldName = '"<<theFieldName<<"'");
+
return aResult;
}
-void VISU_Convertor_impl::FindTimeStamp(const std::string& theMeshName, VISU::TMesh*& theMesh,
- const VISU::TEntity& theEntity,
- VISU::TMeshOnEntity*& theMeshOnEntity,
- VISU::TMeshOnEntity*& theVTKMeshOnEntity,
- const std::string& theFieldName, VISU::TField*& theField,
- int theStampsNum, VISU::TField::TValForTime*& theValForTime)
+VISU_Convertor_impl::TFindTimeStamp
+VISU_Convertor_impl
+::FindTimeStamp(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theStampsNum)
{
- FindField(theMeshName,theMesh,theEntity,theMeshOnEntity,theVTKMeshOnEntity,theFieldName,theField);
- VISU::TField::TValField& aValField = theField->myValField;
- if(aValField.find(theStampsNum) == aValField.end())
- throw std::runtime_error(EXCEPTION("FindTimeStamp >> There is no field with the timestamp!!!"));
- theValForTime = &aValField[theStampsNum];
+ TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
+ PField aField = boost::get<3>(aFindField);
+
+ VISU::TValField& aValField = aField->myValField;
+ VISU::TValField::const_iterator aValFieldIter= aValField.find(theStampsNum);
+ if(aValFieldIter == aValField.end())
+ EXCEPTION(runtime_error,"FindTimeStamp >> There is no field with the timestamp!!!");
+
+ PMeshImpl aMesh = boost::get<0>(aFindField);
+ PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindField);
+ PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
+ PValForTimeImpl aValForTime = aValFieldIter->second;
+
+ return TFindTimeStamp(aMesh,
+ aMeshOnEntity,
+ aVTKMeshOnEntity,
+ aField,
+ aValForTime);
}
-float VISU_Convertor_impl::GetTimeStampSize(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName,
- int theStampsNum)
+float
+VISU_Convertor_impl
+::GetTimeStampSize(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theStampsNum)
{
- VISU::TMesh* pMesh = NULL;
- VISU::TField* pField = NULL;
- VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL;
- VISU::TField::TValForTime* pValForTime = NULL;
- FindTimeStamp(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity,
- theFieldName,pField,theStampsNum,pValForTime);
- float aMeshSize = GetMeshOnEntitySize(theMeshName,pVTKMeshOnEntity->myEntity);
- float aTimeStampSize = float(pField->myDataSize*sizeof(float) * ERR_SIZE_CALC);
+ TFindTimeStamp aFindTimeStamp =
+ FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
+ PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
+ PFieldImpl aField = boost::get<3>(aFindTimeStamp);
+
+ float aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
+ float aTimeStampSize = float(aField->myDataSize*sizeof(float) * ERR_SIZE_CALC);
float aResult = aMeshSize + aTimeStampSize;
- if(MYDEBUG){
- if(MYVTKDEBUG)
- MESSAGE("GetTimeStampSize - aTimeStampSize = "<<float(aTimeStampSize));
- MESSAGE("GetTimeStampSize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
- "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
- }
+
+ MSG(MYDEBUG && MYVTKDEBUG,"GetTimeStampSize - aTimeStampSize = "<<float(aTimeStampSize));
+ MSG(MYDEBUG,"GetTimeStampSize - aResult = "<<float(aResult)<<
+ "; theMeshName = '"<<theMeshName<<"'; theEntity = "<<theEntity<<
+ "; theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<theStampsNum);
+
return aResult;
}
-const VISU::TField&
-VISU_Convertor_impl::GetField(const string& theMeshName,
- VISU::TEntity theEntity,
- const string& theFieldName)
+const VISU::PField
+VISU_Convertor_impl
+::GetField(const string& theMeshName,
+ VISU::TEntity theEntity,
+ const string& theFieldName)
{
- VISU::TMesh* pMesh = NULL;
- VISU::TField* pField = NULL;
- VISU::TFamily* pFamily = NULL;
- VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL;
- FindField(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity,
- theFieldName,pField);
- return *pField;
+ TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
+ PField aField = boost::get<3>(aFindField);
+ return aField;
}
-const VISU::TField::TValForTime&
-VISU_Convertor_impl::GetTimeStamp(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName,
- int theStampsNum)
+const VISU::PValForTime
+VISU_Convertor_impl
+::GetTimeStamp(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theStampsNum)
{
- VISU::TMesh* pMesh = NULL;
- VISU::TField* pField = NULL;
- VISU::TMeshOnEntity *pMeshOnEntity = NULL, *pVTKMeshOnEntity = NULL;
- VISU::TField::TValForTime* pValForTime = NULL;
- FindTimeStamp(theMeshName,pMesh,theEntity,pMeshOnEntity,pVTKMeshOnEntity,
- theFieldName,pField,theStampsNum,pValForTime);
- return *pValForTime;
+ TFindTimeStamp aFindTimeStamp =
+ FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
+ PValForTime aValForTime = boost::get<4>(aFindTimeStamp);
+ return aValForTime;
}
-
-