#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 <qstring.h>
#include <qfileinfo.h>
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
+//#define _DEXCEPT_
#else
static int MYDEBUG = 0;
static int MYDEBUGWITHFILES = 0;
#endif
+namespace VISU
+{
+ //---------------------------------------------------------------
+ TIsVTKDone::TIsVTKDone():
+ myIsVTKDone(false),
+ myIsDone(false)
+ {}
+
+
+ //---------------------------------------------------------------
+ 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
-namespace{
+ default:
+ return -1;
+ }
+ }
+}
+
+namespace
+{
+ //---------------------------------------------------------------
template<class T>
- std::string dtos(const std::string& fmt, T val){
+ std::string
+ dtos(const std::string& fmt, T val)
+ {
static QString aString;
aString.sprintf(fmt.c_str(),val);
return aString.latin1();
}
+
+ //---------------------------------------------------------------
enum ECoordName{eX, eY, eZ, eNone};
- typedef VISU::TCoord (*TGetCoord)(const VISU::TMeshImpl::TPointsCoord&, int);
+ typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice);
- template<ECoordName TheCoordId>
+ template<ECoordName TCoordId>
VISU::TCoord
- GetCoord(const VISU::TMeshImpl::TPointsCoord& thePointsCoord,
- int theStartPos)
+ GetCoord(const VISU::TCCoordSlice& theCoordSlice)
{
- return thePointsCoord[theStartPos+TheCoordId];
+ return theCoordSlice[TCoordId];
}
template<>
VISU::TCoord
- GetCoord<eNone>(const VISU::TMeshImpl::TPointsCoord& thePointsCoord,
- int theStartPos)
+ GetCoord<eNone>(const VISU::TCCoordSlice& theCoordSlice)
{
return 0.0;
}
class TCoordHelper{
- const VISU::TMeshImpl::TPointsCoord& myPointsCoord;
TGetCoord* myGetCoord;
public:
- TCoordHelper(const VISU::TMeshImpl::TPointsCoord& thePointsCoord,
- TGetCoord* theGetCoord):
- myPointsCoord(thePointsCoord),
+ TCoordHelper(TGetCoord* theGetCoord):
myGetCoord(theGetCoord)
{}
- virtual ~TCoordHelper(){}
+
+ virtual
+ ~TCoordHelper()
+ {}
+
VISU::TCoord
- GetCoord(int theStartPos, int theCoodId)
+ GetCoord(VISU::TCCoordSlice& theCoordSlice,
+ int theCoordId)
{
- return (*myGetCoord[theCoodId])(myPointsCoord,theStartPos);
+ return (*myGetCoord[theCoordId])(theCoordSlice);
}
};
typedef std::auto_ptr<TCoordHelper> TCoordHelperPtr;
- void GetPoints(VISU::TVTKSource& theStorage, VISU::PMeshImpl 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::TMeshImpl::TPointsCoord& anArray = theMesh->myPointsCoord;
{
int aMeshDimension = theMesh->myDim;
bool anIsDimPresent[3] = {false, false, false};
for(int iDim = 0; iDim < aMeshDimension; iDim++){
- string aDimName = theMesh->myPointsDim[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);
- MSG(MYDEBUG,"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::TMeshOnEntityImpl::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::PMeshOnEntityImpl theMeshOnEntity,
- const string& theFamilyName)
+
+ //---------------------------------------------------------------
+ void
+ GetCellsOnSubMesh(const TVTKSource& theSource,
+ const PMeshOnEntityImpl& theMeshOnEntity,
+ const PSubMeshImpl& theSubMesh,
+ const vtkIdType theGeom)
{
- //Check on existing family
- PFamilyImpl aFamily = GetFamily(theMeshOnEntity,theFamilyName);
- //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);
- MSG(MYDEBUG,"GetCellsOnEntity - isFamilyPresent = "<<bool(aFamily));
- const VISU::TMeshOnEntityImpl::TCellsConn &aCellsConn = theMeshOnEntity->myCellsConn;
- VISU::TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
- for(int i = 0, j = 0; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
- const VISU::TMeshOnEntityImpl::TConnForCellType& anArray = aCellsConnIter->second;
- int aVtkType = aCellsConnIter->first;
- MSG(MYDEBUG,"GetCellsOnEntity - aVtkType = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
- if(!aFamily)
- 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::TFamilyImpl::TSubMesh& aSubMesh = aFamily->mySubMesh;
- if(aSubMesh.empty())
- EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!");
- VISU::TFamilyImpl::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType);
- if(aSubMeshIter == aSubMesh.end()) continue;
- const VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second;
- MSG(MYDEBUG,"GetCellsOnEntity - aSubMeshOnCellType.size() = "<<aSubMeshOnCellType.size());
- VISU::TFamilyImpl::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,
- VISU::PMeshImpl 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::PMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
- 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;
- PMeshOnEntityImpl aMeshOnEntity = theMesh->myMeshOnEntityMap[anEntity];
- PFamilyImpl aFamily = GetFamily(aMeshOnEntity,aFamilyName);
- const VISU::TMeshOnEntityImpl::TCellsConn &aCellsConn = aMeshOnEntity->myCellsConn;
- VISU::TMeshOnEntityImpl::TCellsConn::const_iterator aCellsConnIter = aCellsConn.begin();
- for(; aCellsConnIter != aCellsConn.end(); aCellsConnIter++){
- const VISU::TMeshOnEntityImpl::TConnForCellType& anArray = aCellsConnIter->second;
- int aVtkType = aCellsConnIter->first;
- MSG(MYDEBUG,"GetCellsOnGroup - aVtkType = "<<aVtkType<<"; anArray.size() = "<<anArray.size());
- const VISU::TFamilyImpl::TSubMesh& aSubMesh = aFamily->mySubMesh;
- if(aSubMesh.empty())
- EXCEPTION(runtime_error,"GetCells >> There is no elements on the family !!!");
- VISU::TFamilyImpl::TSubMesh::const_iterator aSubMeshIter = aSubMesh.find(aVtkType);
- if(aSubMeshIter == aSubMesh.end()) continue;
- const VISU::TFamilyImpl::TSubMeshOnCellType& aSubMeshOnCellType = aSubMeshIter->second;
- MSG(MYDEBUG,"GetCellsOnGroup - aSubMeshOnCellType.size() = "<<aSubMeshOnCellType.size());
- VISU::TFamilyImpl::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,
- PMeshOnEntityImpl theMeshOnEntity,
- PValForTimeImpl theValForTime)
- {
- const VISU::TValForTimeImpl::TValForCells& aValForCells = theValForTime->myValForCells;
- const VISU::TMeshOnEntityImpl::TCellsConn &aCellsConn = theMeshOnEntity->myCellsConn;
- VISU::TMeshOnEntityImpl::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,
- VISU::PFieldImpl theField,
- VISU::PValForTimeImpl theValForTime)
- {
- //theFloatArray->DebugOn();
- theFloatArray->SetNumberOfTuples(theNumberOfTuples);
- theFloatArray->SetName(theFieldName.c_str());
- MSG(MYDEBUG,"GetValsOnTimeStamp - theNumberOfTuples = "<<theNumberOfTuples);
- const VISU::TValForTimeImpl::TValForCells& aValForCells = theValForTime->myValForCells;
- VISU::TValForTimeImpl::TValForCells::const_iterator aValForCellsIter = aValForCells.begin();
- for(int k = 0; aValForCellsIter != aValForCells.end(); aValForCellsIter++) {
- const VISU::TValForTimeImpl::TValForCellsWithType& anArray = aValForCellsIter->second;
- int iEnd = anArray.size()/theField->myNbComp;
- int aVtkType = aValForCellsIter->first;
- MSG(MYDEBUG,"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:
- EXCEPTION(runtime_error,"GetValsOnTimeStamp - There is no an algorithm for representation of the field !!!");
- }
- }
- }
-
- string GenerateFieldName(const VISU::PFieldImpl theField,
- const VISU::PValForTimeImpl theValForTime)
+ //---------------------------------------------------------------
+ void
+ GetGaussSubMesh(const PMeshImpl& theMesh,
+ const PMeshOnEntityImpl& theMeshOnEntity,
+ const PGaussMeshImpl& theGaussMesh,
+ const PGaussSubMeshImpl& theGaussSubMesh)
{
- const VISU::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::PFieldImpl theField,
- const VISU::PValForTimeImpl theValForTime)
+ //---------------------------------------------------------------
+ void
+ BuildGaussMesh(const PMeshImpl& theMesh,
+ const PMeshOnEntityImpl& theMeshOnEntity,
+ const PGaussMeshImpl& theGaussMesh)
{
- int aNumberOfTuples = theField->myDataSize/theField->myNbComp;
- string aFieldName = GenerateFieldName(theField,theValForTime);
- MSG(MYDEBUG,"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::PFieldImpl theField,
- const VISU::PValForTimeImpl theValForTime)
+
+ //---------------------------------------------------------------
+ void
+ PrintMemorySize(vtkUnstructuredGrid* theDataSet)
{
- int aNumberOfTuples = theField->myDataSize/theField->myNbComp;
- string aFieldName = GenerateFieldName(theField,theValForTime);
- MSG(MYDEBUG,"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_Convertor_impl::~VISU_Convertor_impl() {}
-VISU_Convertor::TOutput*
-VISU_Convertor_impl::GetMeshOnEntity(const string& theMeshName,
- const VISU::TEntity& theEntity,
- const string& theFamilyName)
+//---------------------------------------------------------------
+VISU::PNamedIDMapper
+VISU_Convertor_impl
+::GetMeshOnEntity(const string& theMeshName,
+ const VISU::TEntity& theEntity)
{
- MSG(MYDEBUG,"GetMeshOnEntity - theMeshName = '"<<theMeshName<<
- "'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
+ INITMSG(MYDEBUG,"GetMeshOnEntity"<<
+ "; theMeshName = '"<<theMeshName<<"'"<<
+ "; theEntity = "<<theEntity<<
+ endl);
+
//Cheching possibility do the query
TFindMeshOnEntity aFindMeshOnEntity =
- FindMeshOnEntity(theMeshName,theEntity,theFamilyName);
- VISU::TVTKSource* pSource;
+ FindMeshOnEntity(theMeshName,theEntity);
+
PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
- PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity);
PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
- if(aFamily)
- pSource = &(aFamily->myStorage);
- else
- pSource = &(aMeshOnEntity->myStorage);
- VISU::TVTKSource& aSource = *pSource;
+
+ //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::PIDMapper
+VISU_Convertor_impl
+::GetFamilyOnEntity(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFamilyName)
+{
+ INITMSG(MYDEBUG,"GetFamilyOnEntity"<<
+ "; theMeshName = '"<<theMeshName<<"'"<<
+ "; theEntity = "<<theEntity<<
+ "; theFamilyName = '"<<theFamilyName<<"'"<<
+ endl);
+
+ //Cheching possibility do the query
+ 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();
- MSG(MYVTKDEBUG,"GetMeshOnEntity - GetPoints() = "<<float(aDataSet->GetPoints()->GetActualMemorySize()*1000));
- MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCells() = "<<float(aDataSet->GetCells()->GetActualMemorySize()*1000));
- MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellTypesArray() = "<<float(aDataSet->GetCellTypesArray()->GetActualMemorySize()*1000));
- MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellLocationsArray() = "<<float(aDataSet->GetCellLocationsArray()->GetActualMemorySize()*1000));
- aDataSet->BuildLinks();
- MSG(MYVTKDEBUG,"GetMeshOnEntity - GetCellLinks() = "<<float(aDataSet->GetCellLinks()->GetActualMemorySize()*1000));
- MSG(MYVTKDEBUG,"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)
{
- MSG(MYDEBUG,"GetMeshOnGroup - theMeshName = '"<<theMeshName<<
- "'; theGroupName = '"<<theGroupName<<"'");
+ INITMSG(MYDEBUG,"GetMeshOnGroup\n");
+ INITMSGA(MYDEBUG,0,
+ "- theMeshName = '"<<theMeshName<<
+ "'; theGroupName = '"<<theGroupName<<"'"<<
+ endl);
+
//Cheching possibility do the query
TFindMeshOnGroup aFindMeshOnGroup = FindMeshOnGroup(theMeshName,theGroupName);
PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
- const VISU::TFamilyAndEntitySet& aFamilyAndEntitySet = aGroup->myFamilyAndEntitySet;
- VISU::TVTKSource& aSource = aGroup->myStorage;
+
//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)
+{
+ 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)
{
- MSG(MYDEBUG,"GetTimeStampOnMesh - theMeshName = '"<<theMeshName<<"; theEntity = "<<theEntity);
- MSG(MYDEBUG,"GetTimeStampOnMesh - theFieldName = '"<<theFieldName<<"'; theStampsNum = "<<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);
+ 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);
- VISU::TVTKAttribyteFilter& anAttribyteFilter = aValForTime->myAttribyteFilter;
- VISU::TVTKSource& aSource = aValForTime->myStorage;
- TOutput* anOutput = NULL;
//Main part of code
+ PIDMapperFilter anIDMapperFilter = aValForTime->myIDMapperFilter;
+#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(aVTKMeshOnEntity);
- }catch(std::exception& exc){
- aVTKMeshOnEntity = aMeshOnEntity;
- MSG(MYDEBUG,"Follow exception was occured :\n"<<exc.what());
- }catch(...){
- aVTKMeshOnEntity = aMeshOnEntity;
- MSG(MYDEBUG,"Unknown exception was occured!");
- }
- GetMeshOnEntity(aVTKMeshOnEntity->myMeshName,aVTKMeshOnEntity->myEntity);
-
- anExtractFilter->SetInput(aVTKMeshOnEntity->myStorage.GetPointer());
- ::InitProfile(anExtractFilter,aMeshOnEntity,aValForTime);
- }
- if(!anExtractFilter->IsRemoving()){
- aSource = TOutput::New();
- aSource->Delete();
- aSource->ShallowCopy(aVTKMeshOnEntity->myStorage.GetPointer());
- ::GetTimeStamp(aSource,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,
- aField,aValForTime);
- anOutput = anAttribyteFilter->GetUnstructuredGridOutput();
+#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("/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)
- MSG(MYVTKDEBUG,"GetTimeStampOnMesh - GetData() = "<<float(aDataSet->GetPointData()->GetActualMemorySize()*1000));
+ BEGMSG(MYVTKDEBUG,"GetPointData() = "<<float(anOutput->GetPointData()->GetActualMemorySize()*1000)<<endl);
else
- MSG(MYVTKDEBUG,"GetMeshOnEntity - GetData() = "<<float(aDataSet->GetCellData()->GetActualMemorySize()*1000));
- MSG(MYVTKDEBUG,"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 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
+ 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{
+#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(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 aGaussPtsIDFilter;
}
+//---------------------------------------------------------------
VISU::PMeshImpl
-VISU_Convertor_impl::FindMesh(const string& theMeshName)
+VISU_Convertor_impl
+::FindMesh(const string& theMeshName)
{
GetMeshMap();
TMeshMap::iterator aMeshMapIter = myMeshMap.find(theMeshName);
}
+//---------------------------------------------------------------
VISU_Convertor_impl::TFindMeshOnEntity
-VISU_Convertor_impl::FindMeshOnEntity(const string& theMeshName,
- const VISU::TEntity& theEntity,
- const string& theFamilyName)
+VISU_Convertor_impl
+::FindMeshOnEntity(const string& theMeshName,
+ const VISU::TEntity& theEntity)
{
PMeshImpl aMesh = FindMesh(theMeshName);
VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
EXCEPTION(runtime_error,"FindMeshOnEntity >> There is no mesh on the entity - "<<theEntity<<"!!!");
PMeshOnEntityImpl aMeshOnEntity = aMeshOnEntityMapIter->second;
-
+
return TFindMeshOnEntity(aMesh,
- aMeshOnEntityMap[theEntity],
- GetFamily(aMeshOnEntity,theFamilyName));
+ aMeshOnEntity);
+}
+
+
+//---------------------------------------------------------------
+VISU_Convertor_impl::TFindFamilyOnEntity
+VISU_Convertor_impl
+::FindFamilyOnEntity(const string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const string& 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();
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);
}
-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)
{
TFindMeshOnEntity aFindMeshOnEntity =
- FindMeshOnEntity(theMeshName,theEntity,theFamilyName);
+ FindMeshOnEntity(theMeshName,theEntity);
+
PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
- PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity);
PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
vtkIdType aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
- vtkIdType aNbCells, aCellsSize;
+ 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;
- if(!aFamily){
- aNbCells = aMeshOnEntity->myNbCells;
- aCellsSize = aMeshOnEntity->myCellsSize;
- }else{
- aNbCells = aFamily->myNbCells;
- aCellsSize = aFamily->myCellsSize;
+ 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);
(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){
- MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aPointsSize = "<<float(aPointsSize));
- MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aConnectivitySize = "<<float(aConnectivitySize));
- MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aTypesSize = "<<float(aTypesSize));
- MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aLocationsSize = "<<float(aLocationsSize));
- MSG(MYVTKDEBUG,"GetMeshOnEntitySize - aLinksSize = "<<float(aLinksSize));
+ 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");
}
- MSG(MYDEBUG,"GetMeshOnEntitySize - aResult = "<<float(aResult)<<"; theMeshName = '"<<theMeshName<<
- "'; theEntity = "<<theEntity<<"; theFamilyName = '"<<theFamilyName<<"'");
aResult = vtkIdType(aResult*ERR_SIZE_CALC);
return aResult;
}
+//---------------------------------------------------------------
VISU_Convertor_impl::TFindMeshOnGroup
-VISU_Convertor_impl::FindMeshOnGroup(const std::string& theMeshName,
- const std::string& theGroupName)
+VISU_Convertor_impl
+::FindMeshOnGroup(const std::string& theMeshName,
+ const std::string& theGroupName)
{
PMeshImpl aMesh = FindMesh(theMeshName);
VISU::TGroupMap& aGroupMap = aMesh->myGroupMap;
}
-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)
{
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);
- vtkIdType aNbCells = aGroup->myNbCells, aCellsSize = aGroup->myCellsSize;
+ 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;
return aResult;
}
+
VISU_Convertor_impl::TFindField
-VISU_Convertor_impl::FindField(const string& theMeshName,
- const VISU::TEntity& theEntity,
- const string& theFieldName)
+VISU_Convertor_impl
+::FindField(const string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const string& theFieldName)
{
- TFindMeshOnEntity aFindMeshOnEntity = FindMeshOnEntity(theMeshName,theEntity,"");
+ TFindMeshOnEntity aFindMeshOnEntity =
+ FindMeshOnEntity(theMeshName,theEntity);
+
PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);;
- PFamilyImpl aFamily = boost::get<2>(aFindMeshOnEntity);
PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
}
-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)
{
TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindField);
- PField aField = boost::get<3>(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);
VISU_Convertor_impl::TFindTimeStamp
-VISU_Convertor_impl::FindTimeStamp(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName,
- int theStampsNum)
+VISU_Convertor_impl
+::FindTimeStamp(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theStampsNum)
{
TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
PField aField = boost::get<3>(aFindField);
}
-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)
{
TFindTimeStamp aFindTimeStamp =
FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);
PMeshOnEntityImpl aVTKMeshOnEntity = boost::get<2>(aFindTimeStamp);
- PField aField = boost::get<3>(aFindTimeStamp);
+ PFieldImpl aField = boost::get<3>(aFindTimeStamp);
float aMeshSize = GetMeshOnEntitySize(theMeshName,aVTKMeshOnEntity->myEntity);
float aTimeStampSize = float(aField->myDataSize*sizeof(float) * ERR_SIZE_CALC);
const VISU::PField
-VISU_Convertor_impl::GetField(const string& theMeshName,
- VISU::TEntity theEntity,
- const string& theFieldName)
+VISU_Convertor_impl
+::GetField(const string& theMeshName,
+ VISU::TEntity theEntity,
+ const string& theFieldName)
{
TFindField aFindField = FindField(theMeshName,theEntity,theFieldName);
PField aField = boost::get<3>(aFindField);
const VISU::PValForTime
-VISU_Convertor_impl::GetTimeStamp(const std::string& theMeshName,
- const VISU::TEntity& theEntity,
- const std::string& theFieldName,
- int theStampsNum)
+VISU_Convertor_impl
+::GetTimeStamp(const std::string& theMeshName,
+ const VISU::TEntity& theEntity,
+ const std::string& theFieldName,
+ int theStampsNum)
{
TFindTimeStamp aFindTimeStamp =
FindTimeStamp(theMeshName,theEntity,theFieldName,theStampsNum);