::TPointCoords():
myPoints(vtkPoints::New())
{
+ myPoints->SetDataType(VTK_DOUBLE);
myPoints->Delete();
}
void
TPointCoords
::Init(vtkIdType theNbPoints,
- vtkIdType theDim)
+ vtkIdType theDim,
+ const MED::PNodeCoord& theCoord)
{
myDim = theDim;
myNbPoints = theNbPoints;
- myCoord.resize(theNbPoints*theDim);
myPoints->SetNumberOfPoints(theNbPoints);
+ myCoord = theCoord;
+ }
+
+ void
+ TPointCoords
+ ::Init(vtkIdType theNbPoints,
+ vtkIdType theDim)
+ {
+ MED::PNodeCoord aCoord(new MED::TNodeCoord(theNbPoints * theDim));
+ Init(theNbPoints, theDim, aCoord);
}
TCCoordSlice
TPointCoords
::GetCoordSlice(vtkIdType theNodeId) const
{
- return TCCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1));
+ return TCCoordSlice(*myCoord, std::slice(theNodeId * myDim, myDim, 1));
}
TCoordSlice
TPointCoords
::GetCoordSlice(vtkIdType theNodeId)
{
- return TCoordSlice(myCoord,std::slice(theNodeId*myDim,myDim,1));
+ return TCoordSlice(*myCoord, std::slice(theNodeId * myDim, myDim, 1));
+ }
+
+ void
+ TPointCoords
+ ::SetVoidArray() const
+ {
+ vtkDataArray* aDataArray = myPoints->GetData();
+ aDataArray->SetVoidArray(&(*myCoord)[0], myCoord->size(), false);
+ }
+
+ vtkPoints*
+ TPointCoords
+ ::GetPoints() const
+ {
+ return myPoints.GetPointer();
}
unsigned long int
TPointCoords
::GetMemorySize()
{
- size_t aSize = sizeof(TCoord) * myCoord.size();
+ size_t aSize = sizeof(TCoord) * myCoord->size();
aSize += myPoints->GetActualMemorySize() * 1024;
return aSize;
}
TNamedPointCoords
::Init(vtkIdType theNbPoints,
vtkIdType theDim,
- const TVectorID& theVectorID)
+ const MED::PNodeCoord& theCoord)
{
- TPointCoords::Init(theNbPoints,theDim);
+ TPointCoords::Init(theNbPoints, theDim, theCoord);
myPointsDim.resize(theDim);
- myVectorID = theVectorID;
+ }
- for(vtkIdType anID = 0, anEnd = theVectorID.size(); anID < anEnd; anID++)
- myObj2VTKID[theVectorID[anID]] = anID;
+ void
+ TNamedPointCoords
+ ::Init(vtkIdType theNbPoints,
+ vtkIdType theDim)
+ {
+ TPointCoords::Init(theNbPoints, theDim);
+ myPointsDim.resize(theDim);
}
std::string&
TNamedPointCoords
::GetObjID(vtkIdType theID) const
{
- if(myVectorID.empty())
- return theID;
- else
- return myVectorID[theID];
+ return theID;
}
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;
+ return theID;
}
std::string
return "";
}
+ //---------------------------------------------------------------
+ enum ECoordName{eX, eY, eZ, eNoneCoord};
+ typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice);
+
+ template<ECoordName TCoordId>
+ VISU::TCoord
+ GetCoord(const VISU::TCCoordSlice& theCoordSlice)
+ {
+ return theCoordSlice[TCoordId];
+ }
+
+ template<>
+ VISU::TCoord
+ GetCoord<eNoneCoord>(const VISU::TCCoordSlice& theCoordSlice)
+ {
+ return 0.0;
+ }
+
+
+ TGetCoord aXYZGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eY>,
+ &GetCoord<eZ>
+ };
+
+
+ TGetCoord aXYGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eY>,
+ &GetCoord<eNoneCoord>
+ };
+
+ TGetCoord aYZGetCoord[3] = {
+ &GetCoord<eNoneCoord>,
+ &GetCoord<eX>,
+ &GetCoord<eY>
+ };
+
+ TGetCoord aXZGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eNoneCoord>,
+ &GetCoord<eY>
+ };
+
+
+ TGetCoord aXGetCoord[3] = {
+ &GetCoord<eX>,
+ &GetCoord<eNoneCoord>,
+ &GetCoord<eNoneCoord>
+ };
+
+ TGetCoord aYGetCoord[3] = {
+ &GetCoord<eNoneCoord>,
+ &GetCoord<eX>,
+ &GetCoord<eNoneCoord>
+ };
+
+ TGetCoord aZGetCoord[3] = {
+ &GetCoord<eNoneCoord>,
+ &GetCoord<eNoneCoord>,
+ &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;
+
+
+ //---------------------------------------------------------------
+ vtkPoints*
+ TNamedPointCoords
+ ::GetPoints() const
+ {
+ if(!myIsVTKDone){
+ TCoordHelperPtr aCoordHelperPtr;
+ bool anIsDimPresent[3] = {false, false, false};
+ for(int iDim = 0; iDim < GetDim(); iDim++){
+ std::string aName = GetName(iDim);
+ if ( aName.size() > 1 ) // PAL13021 (PAL12148), aName has size 8 or 16
+ aName = aName.substr(0,1);
+ if(aName == "x" || aName == "X")
+ anIsDimPresent[eX] = true;
+ else if(aName == "y" || aName == "Y")
+ anIsDimPresent[eY] = true;
+ else if(aName == "z" || aName == "Z")
+ anIsDimPresent[eZ] = true;
+ }
+
+ switch(GetDim()){
+ case 3:
+ aCoordHelperPtr.reset(new TCoordHelper(aXYZGetCoord));
+ break;
+ case 2:
+ if(anIsDimPresent[eY] && anIsDimPresent[eZ])
+ aCoordHelperPtr.reset(new TCoordHelper(aYZGetCoord));
+ else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
+ aCoordHelperPtr.reset(new TCoordHelper(aXZGetCoord));
+ else
+ aCoordHelperPtr.reset(new TCoordHelper(aXYGetCoord));
+ break;
+ case 1:
+ if(anIsDimPresent[eY])
+ aCoordHelperPtr.reset(new TCoordHelper(aYGetCoord));
+ else if(anIsDimPresent[eZ])
+ aCoordHelperPtr.reset(new TCoordHelper(aZGetCoord));
+ else
+ aCoordHelperPtr.reset(new TCoordHelper(aXGetCoord));
+ break;
+ }
+
+ INITMSG(MYDEBUG,"TNamedPointCoords::GetPoints - aNbPoints = "<<GetNbPoints()<<
+ "; aDim = "<<GetDim()<<
+ endl);
+
+ if(anIsDimPresent[eX] && anIsDimPresent[eY] && anIsDimPresent[eZ]){
+ SetVoidArray();
+ }else{
+ for(vtkIdType aNodeId = 0; aNodeId < GetNbPoints(); aNodeId++){
+ TCCoordSlice aCoordSlice = GetCoordSlice(aNodeId);
+ myPoints->SetPoint(aNodeId,
+ aCoordHelperPtr->GetCoord(aCoordSlice,eX),
+ aCoordHelperPtr->GetCoord(aCoordSlice,eY),
+ aCoordHelperPtr->GetCoord(aCoordSlice,eZ));
+ }
+ }
+
+ myIsVTKDone = true;
+ }
+
+ return myPoints.GetPointer();
+ }
+
unsigned long int
TNamedPointCoords
::GetMemorySize()
{
- size_t aSize = TPointCoords::GetMemorySize();
- aSize += myObj2VTKID.size() * sizeof(vtkIdType) * 2;
- aSize += myVectorID.size() * sizeof(vtkIdType);
- return aSize;
+ return TPointCoords::GetMemorySize();
}
//---------------------------------------------------------------
- TMeshImpl::TMeshImpl():
- myPoints(vtkPoints::New()),
- myNbPoints(0)
+ vtkIdType
+ TMeshImpl::
+ GetNbPoints() const
{
- myPoints->Delete();
+ return myNbPoints;
+ }
+
+ vtkIdType
+ TMeshImpl::
+ GetDim() const
+ {
+ return myDim;
+ }
+
+ vtkPoints*
+ TMeshImpl::
+ GetPoints()
+ {
+ return myNamedPointCoords->GetPoints();
}
}
- //---------------------------------------------------------------
- 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];
- }
-
- 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;
-
-
- //---------------------------------------------------------------
- vtkPoints*
- GetPoints(const PMeshImpl& theMesh)
- {
- TVTKPoints& aPoints = theMesh->myPoints;
- const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
-
- if(!theMesh->myIsVTKDone){
- TCoordHelperPtr aCoordHelperPtr;
- {
- int aMeshDimension = theMesh->myDim;
- bool anIsDimPresent[3] = {false, false, false};
- for(int iDim = 0; iDim < aMeshDimension; iDim++){
- std::string aName = aCoords.GetName(iDim);
- if ( aName.size() > 1 ) // PAL13021 (PAL12148), aName has size 8 or 16
- aName = aName.substr(0,1);
- if(aName == "x" || aName == "X")
- anIsDimPresent[eX] = true;
- else if(aName == "y" || aName == "Y")
- anIsDimPresent[eY] = true;
- else if(aName == "z" || aName == "Z")
- anIsDimPresent[eZ] = true;
- }
-
- switch(aMeshDimension){
- case 3:
- aCoordHelperPtr.reset(new TCoordHelper(aXYZGetCoord));
- break;
- case 2:
- if(anIsDimPresent[eY] && anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(aYZGetCoord));
- else if(anIsDimPresent[eX] && anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(aXZGetCoord));
- else
- aCoordHelperPtr.reset(new TCoordHelper(aXYGetCoord));
- break;
- case 1:
- if(anIsDimPresent[eY])
- aCoordHelperPtr.reset(new TCoordHelper(aYGetCoord));
- else if(anIsDimPresent[eZ])
- aCoordHelperPtr.reset(new TCoordHelper(aZGetCoord));
- else
- aCoordHelperPtr.reset(new TCoordHelper(aXGetCoord));
- break;
- }
- }
-
- vtkIdType aNbPoints = aCoords.GetNbPoints();
- aPoints->SetNumberOfPoints(aNbPoints);
-
- 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();
- }
-
- return aPoints.GetPointer();
- }
-
-
//---------------------------------------------------------------
void
PrintCells(int& theStartId,
if(theSubProfile->myIsVTKDone)
return;
- aSource->SetPoints(GetPoints(theMesh));
+ aSource->SetPoints(theMesh->GetPoints());
INITMSGA(MYDEBUG,0,"GetNumberOfPoints - "<<aSource->GetNumberOfPoints()<<endl);
GetCells(aSource,theSubProfile,theProfile,theMeshOnEntity);
BEGMSG(MYDEBUG,"GetNumberOfCells - "<<aSource->GetNumberOfCells()<<endl);
theProfile->myMeshOnEntity = theMeshOnEntity.get();
const TVTKAppendFilter& anAppendFilter = theProfile->GetFilter();
- anAppendFilter->SetPoints(GetPoints(theMesh));
+ anAppendFilter->SetPoints(theMesh->GetPoints());
if(theProfile->myIsAll){
TVTKOutput* aDataSet = theMeshOnEntity->GetVTKOutput();
aCellTypesArray->SetNumberOfComponents(1);
aCellTypesArray->SetNumberOfTuples(aNbCells);
- const TVTKPoints& aPoints = aCoords.GetPoints();
+ vtkPoints* aPoints = aCoords.GetPoints();
vtkIdList *anIdList = vtkIdList::New();
anIdList->SetNumberOfIds(1);
for(vtkIdType aPointId = 0; aPointId < aNbPoints; aPointId++){
for(vtkIdType aDimId = 0; aDimId < aDim; aDimId++)
aCoords[aDimId] = aSlice[aDimId];
- aPoints->SetPoint(aPointId,aCoords);
+ aPoints->SetPoint(aPointId, aCoords);
anIdList->SetId(0,aPointId);
aConnectivity->InsertNextCell(anIdList);
- aCellTypesArray->SetValue(aPointId,(unsigned char)VTK_VERTEX);
+ aCellTypesArray->SetValue(aPointId, (unsigned char)VTK_VERTEX);
}
anIdList->Delete();
vtkIdType *pts = 0, npts = 0;
aConnectivity->InitTraversal();
for(int i = 0; aConnectivity->GetNextCell(npts,pts); i++)
- aCellLocationsArray->SetValue(i,aConnectivity->GetTraversalLocation(npts));
+ aCellLocationsArray->SetValue(i, aConnectivity->GetTraversalLocation(npts));
const TVTKSource& aSource = theGaussSubMesh->GetSource();
- aSource->SetCells(aCellTypesArray,aCellLocationsArray,aConnectivity);
- aSource->SetPoints(aPoints.GetPointer());
+ aSource->SetCells(aCellTypesArray, aCellLocationsArray, aConnectivity);
+ aSource->SetPoints(aPoints);
aCellLocationsArray->Delete();
aCellTypesArray->Delete();
if(MYVTKDEBUG) anAppendFilter->DebugOn();
LoadMeshOnEntity(aMesh,aMeshOnEntity);
- anAppendFilter->SetPoints(GetPoints(aMesh));
+ anAppendFilter->SetPoints(aMesh->GetPoints());
const TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh;
TGeom2SubMesh::const_iterator anIter = aGeom2SubMesh.begin();
vtkIdType aVGeom = VISUGeom2VTK(aEGeom);
PSubMeshImpl aSubMesh = anIter->second;
const TVTKSource& aSource = aSubMesh->GetSource();
- aSource->SetPoints(GetPoints(aMesh));
+ aSource->SetPoints(aMesh->GetPoints());
GetCellsOnSubMesh(aSource,aMeshOnEntity,aSubMesh,aVGeom);
anAppendFilter->AddInput(aSource.GetPointer());
GetMeshOnEntity(theMeshName,theEntity);
LoadFamilyOnEntity(aMesh,aMeshOnEntity,aFamily);
- aSource->SetPoints(GetPoints(aMesh));
+ aSource->SetPoints(aMesh->GetPoints());
GetCellsOnFamily(aSource,aMeshOnEntity,aFamily);
aFamily->myNamedPointCoords = aMesh->myNamedPointCoords;
const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet;
LoadMeshOnGroup(aMesh,aFamilySet);
- anAppendFilter->SetPoints(GetPoints(aMesh));
+ anAppendFilter->SetPoints(aMesh->GetPoints());
TFamilySet::const_iterator anIter = aFamilySet.begin();
PMeshImpl aMesh = boost::get<0>(aFindMeshOnEntity);
PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
- size_t aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
+ size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
size_t aNbCells = aMeshOnEntity->myNbCells;
size_t aCellsSize = aMeshOnEntity->myCellsSize;
size_t aTypesSize = aNbCells*sizeof(char);
size_t aLocationsSize = aNbCells*sizeof(int);
vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
- size_t aLinksSize = aMesh->myNbPoints *
+ size_t aLinksSize = aMesh->GetNbPoints() *
(vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
aLinksSize = 0;
size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
PFamilyImpl aFamily = boost::get<2>(aFindFamilyOnEntity);
PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindFamilyOnEntity);
- size_t aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
+ size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
size_t aNbCells = aFamily->myNbCells;
size_t aCellsSize = aFamily->myCellsSize;
size_t aTypesSize = aNbCells*sizeof(char);
size_t aLocationsSize = aNbCells*sizeof(int);
vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
- size_t aLinksSize = aMesh->myNbPoints *
+ size_t aLinksSize = aMesh->GetNbPoints() *
(vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(vtkCellLinks::Link));
aLinksSize = 0;
size_t aResult = aPointsSize + aConnectivitySize + aTypesSize + aLocationsSize + aLinksSize;
PMeshImpl aMesh = boost::get<0>(aFindMeshOnGroup);
PGroupImpl aGroup = boost::get<1>(aFindMeshOnGroup);
- size_t aPointsSize = 3*aMesh->myNbPoints*sizeof(VISU::TCoord);
+ size_t aPointsSize = 3*aMesh->GetNbPoints()*sizeof(VISU::TCoord);
TNbASizeCells aNbASizeCells = aGroup->GetNbASizeCells();
size_t aNbCells = aNbASizeCells.first;
size_t aCellsSize = aNbASizeCells.second;
size_t aConnectivityAndTypesSize = aCellsSize*sizeof(vtkIdType);
size_t aLocationsSize = aNbCells*sizeof(int);
vtkFloatingPointType aNbCellsPerPoint = aCellsSize / aNbCells - 1;
- size_t aLinksSize = aMesh->myNbPoints *
+ size_t aLinksSize = aMesh->GetNbPoints() *
(vtkIdType(sizeof(vtkIdType)*aNbCellsPerPoint) + sizeof(short));
aLinksSize = 0;
size_t aResult = aPointsSize + aConnectivityAndTypesSize + aLocationsSize + aLinksSize;
PMeshOnEntityImpl aMeshOnEntity = boost::get<1>(aFindMeshOnEntity);
VISU::TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
- PMeshOnEntityImpl aVTKMeshOnEntity;
+ PMeshOnEntityImpl aVTKMeshOnEntity = aMeshOnEntity;
if(theEntity == VISU::NODE_ENTITY){
if(aMeshOnEntityMap.find(VISU::CELL_ENTITY) != aMeshOnEntityMap.end())
aVTKMeshOnEntity = aMeshOnEntityMap[VISU::CELL_ENTITY];
aVTKMeshOnEntity = aMeshOnEntityMap[VISU::FACE_ENTITY];
else if(aMeshOnEntityMap.find(VISU::NODE_ENTITY) != aMeshOnEntityMap.end())
aVTKMeshOnEntity = aMeshOnEntityMap[VISU::EDGE_ENTITY];
- }else
- aVTKMeshOnEntity = aMeshOnEntity;
+ }
VISU::TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
VISU::TFieldMap::const_iterator aFieldIter= aFieldMap.find(theFieldName);
#include "VISU_Convertor.hxx"
#include "MED_SliceArray.hxx"
+#include "MED_Structures.hxx"
#ifndef VISU_ENABLE_QUADRATIC
#define VISU_ENABLE_QUADRATIC
typedef vtkSmartPointer<VTKViewer_AppendFilter> TVTKAppendFilter;
- typedef vtkFloatingPointType TCoord;
-
//---------------------------------------------------------------
//! Define an utility base class which is repsonsible for preventing repetion
struct TIsVTKDone: virtual TBaseStructure
{
TIsVTKDone();
- bool myIsDone; //!< Say, is the corresponding MED entity already loaded into intermediate data structure
- bool myIsVTKDone; //!< Say, is the corresponding intermediate data structure already mapped into VTK representation
+ mutable bool myIsDone; //!< Say, is the corresponding MED entity already loaded into intermediate data structure
+ mutable bool myIsVTKDone; //!< Say, is the corresponding intermediate data structure already mapped into VTK representation
};
//---------------------------------------------------------------
- typedef TVector<TCoord> TCoordArray;
- typedef TSlice<TCoordArray> TCoordSlice;
- typedef TCSlice<TCoordArray> TCCoordSlice;
+ typedef MED::TFloat TCoord;
+ using MED::TCoordSlice;
+ using MED::TCCoordSlice;
//! This class is responsible for representation of mesh nodes
class TPointCoords: public virtual TBaseStructure
Usage of slices allow to minimize amount of memory to store the nodal coordinates and
provide unifirm way of conversation with this coordinates (independant from mesh dimension)
*/
- TCoordArray myCoord;
+ MED::PNodeCoord myCoord;
TVTKPoints myPoints; //!< VTK representation for the mesh nodes
+ void
+ SetVoidArray() const; //!< Passes the MED node coordinates data directly to VTK
+
public:
TPointCoords();
+ //! To initilize the class
+ void
+ Init(vtkIdType theNbPoints,
+ vtkIdType theDim,
+ const MED::PNodeCoord& theCoord);
+
//! To initilize the class
void
Init(vtkIdType theNbPoints,
vtkIdType
GetDim() const { return myDim; }
- vtkIdType
- size() const { return GetNbPoints(); }
-
- const TVTKPoints&
- GetPoints() const { return myPoints;}
+ virtual
+ vtkPoints*
+ GetPoints() const; //!< Gets corresponding VTK structure
//! Gets memory size used by the instance (bytes).
virtual
//---------------------------------------------------------------
- typedef TVector<vtkIdType> TVectorID;
- typedef std::map<vtkIdType,vtkIdType> TObj2VTKID;
-
//! This class is responsible for representation of mesh nodes
/*!
In additition to its base functionlity it support mapping of VTK to object numeration and
keeps names for each of nodes.
*/
- class TNamedPointCoords: public virtual TPointCoords
+ class TNamedPointCoords: public virtual TPointCoords,
+ public virtual TIsVTKDone
{
protected:
typedef TVector<std::string> TPointsDim;
TPointsDim myPointsDim; //!< Keeps name of each dimension
- TVectorID myVectorID; //!< Keeps objects numeration
- TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one
public:
void
Init(vtkIdType theNbPoints,
vtkIdType theDim,
- const TVectorID& theVectorID = TVectorID());
+ const MED::PNodeCoord& theCoord);
+
+ //! To initilize the class (numeration of the nodes can be missed)
+ void
+ Init(vtkIdType theNbPoints,
+ vtkIdType theDim);
//! Get name for defined dimension
std::string&
std::string
GetNodeName(vtkIdType theObjID) const;
+ virtual
+ vtkPoints*
+ GetPoints() const; //!< Gets initialized corresponding VTK structure
+
//! Gets memory size used by the instance (bytes).
virtual
unsigned long int
virtual TIsVTKDone
{
PNamedPointCoords myNamedPointCoords; //!< Keeps intermediate representation of the nodes
-
- TVTKPoints myPoints; //!< Keeps VTK representation of the nodes
vtkIdType myNbPoints; //!< Keeps number of the nodes
- TMeshImpl();
+ TMeshImpl(): myNbPoints(0)
+ {}
+
+ vtkIdType
+ GetNbPoints() const;
+
+ vtkIdType
+ GetDim() const;
+
+ vtkPoints*
+ GetPoints(); //!< Gets initialized corresponding VTK structure
};
typedef SharedPtr<TMeshImpl> PMeshImpl;
const MED::PNodeInfo& theNodeInfo,
MED::EVersion theVersion)
{
+ TNamedPointCoords::Init(theNbPoints, theDim, theNodeInfo->myCoord);
myVersion = theVersion;
- if(theNodeInfo->IsElemNum())
- TNamedPointCoords::Init(theNbPoints,theDim,theNodeInfo->myElemNum);
- else
- TNamedPointCoords::Init(theNbPoints,theDim);
+
+ myIsElemNum = theNodeInfo->IsElemNum();
+ if(theNodeInfo->IsElemNum()){
+ myElemNum = theNodeInfo->myElemNum;
+ for(vtkIdType anID = 0, anEnd = myElemNum->size(); anID < anEnd; anID++)
+ myObj2VTKID[(*myElemNum)[anID]] = anID;
+ }
+
+ myIsElemNames = theNodeInfo->IsElemNames();
if(theNodeInfo->IsElemNames())
myElemNames = theNodeInfo->myElemNames;
}
vtkIdType theDim,
const MED::PGrilleInfo& theInfo)
{
- TNamedPointCoords::Init(theNbPoints,theDim);
+ TNamedPointCoords::Init(theNbPoints, theDim);
+ }
+
+ vtkIdType
+ TMEDNamedPointCoords
+ ::GetObjID(vtkIdType theID) const
+ {
+ if(myIsElemNum)
+ return (*myElemNum)[theID];
+ return TNamedPointCoords::GetObjID(theID);
+ }
+
+
+ vtkIdType
+ TMEDNamedPointCoords
+ ::GetVTKID(vtkIdType theID) const
+ {
+ if(myIsElemNum){
+ TObj2VTKID::const_iterator anIter = myObj2VTKID.find(theID);
+ if(anIter != myObj2VTKID.end())
+ return anIter->second;
+ return -1;
+ }
+ return TNamedPointCoords::GetVTKID(theID);
}
MED::TInt
TMEDNamedPointCoords
::GetNodeName(vtkIdType theObjID) const
{
- if(!myElemNames.empty())
- return GetString(theObjID, GetPNOMLength(myVersion), myElemNames);
+ if(myIsElemNames)
+ return GetString(theObjID, GetPNOMLength(myVersion), *myElemNames);
return TNamedPointCoords::GetNodeName(theObjID);
}
::GetMemorySize()
{
size_t aSize = TNamedPointCoords::GetMemorySize();
- aSize += myElemNames.size() * sizeof(char);
+
+ if(myElemNum){
+ aSize += myObj2VTKID.size() * sizeof(vtkIdType) * 2;
+ aSize += myElemNum->size() * sizeof(MED::TInt);
+ }
+
+ if(myIsElemNames)
+ aSize += myElemNames->size() * sizeof(char);
return aSize;
}
::GetElemObjID(vtkIdType theID) const
{
if(myIsElemNum)
- return myElemNum[theID];
+ return (*myElemNum)[theID];
else
return theID;
}
+ unsigned long int
+ TMEDSubProfile
+ ::GetMemorySize()
+ {
+ size_t aSize = TSubProfileImpl::GetMemorySize();
+ if(myIsElemNum)
+ aSize += myElemNum->size() * sizeof(MED::TInt);
+ return aSize;
+ }
+
//---------------------------------------------------------------
void
TLocalPntID aLocalPntID = theID % myGauss->myNbPoints;
if(myIsElemNum)
- aCellID = myElemNum[aCellID];
+ aCellID = (*myElemNum)[aCellID];
else
aCellID += theStartID;
- return TGaussPointID(aCellID,aLocalPntID);
+ return TGaussPointID(aCellID, aLocalPntID);
}
+ unsigned long int
+ TMEDGaussSubMesh
+ ::GetMemorySize()
+ {
+ size_t aSize = TGaussSubMeshImpl::GetMemorySize();
+ if(myIsElemNum)
+ aSize += myElemNum->size() * sizeof(MED::TInt);
+ return aSize;
+ }
+
//---------------------------------------------------------------
void
MED::EVersion theVersion)
{
myIsElemNum = theElemInfo->IsElemNum();
-
if(myIsElemNum)
myElemNum = theElemInfo->myElemNum;
+ myIsElemNames = theElemInfo->IsElemNames();
if(theElemInfo->IsElemNames())
myElemNames = theElemInfo->myElemNames;
}
void
TMEDSubMesh
::Init(const MED::PGrilleInfo& theGrilleInfo)
- {
- myIsElemNum = MED::eFAUX;
- // must be implemented
- }
+ {}
vtkIdType
TMEDSubMesh
::GetElemObjID(vtkIdType theID) const
{
if(myIsElemNum)
- return myElemNum[theID];
+ return (*myElemNum)[theID];
else
return TSubMeshImpl::GetElemObjID(theID);
}
TMEDSubMesh
::GetElemName(vtkIdType theObjID) const
{
- if(!myElemNames.empty())
- return GetString(theObjID, GetPNOMLength(myVersion), myElemNames);
+ if(myIsElemNames)
+ return GetString(theObjID, GetPNOMLength(myVersion), *myElemNames);
return TSubMeshImpl::GetElemName(theObjID);
}
::GetMemorySize()
{
size_t aSize = TSubMeshImpl::GetMemorySize();
- aSize += myElemNum.size() * sizeof(MED::TInt);
- aSize += myElemNames.size() * sizeof(char);
+
+ if(myIsElemNum)
+ aSize += myElemNum->size() * sizeof(MED::TInt);
+
+ if(myIsElemNames)
+ aSize += myElemNames->size() * sizeof(char);
+
return aSize;
}
+ //---------------------------------------------------------------
struct TSetIsDone
{
bool& myIsDone;