return GetFilter()->GetUnstructuredGridOutput();
}
+
+ //---------------------------------------------------------------
+ void
+ TCoordHolderBase
+ ::Init(vtkIdType theNbPoints,
+ vtkIdType theDim)
+ {
+ myDim = theDim;
+ myNbPoints = theNbPoints;
+ }
+
+ vtkIdType
+ TCoordHolderBase
+ ::GetNbPoints() const
+ {
+ return myNbPoints;
+ }
+
+ vtkIdType
+ TCoordHolderBase
+ ::GetDim() const
+ {
+ return myDim;
+ }
+
+ size_t
+ TCoordHolderBase
+ ::size() const
+ {
+ return GetNbPoints() * GetDim();
+ }
+
+ unsigned long int
+ TCoordHolderBase
+ ::GetMemorySize()
+ {
+ return sizeof(TCoord) * size();
+ }
+
+
//---------------------------------------------------------------
TPointCoords
::TPointCoords():
void
TPointCoords
- ::Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const MED::PNodeCoord& theCoord)
+ ::Init(const PCoordHolder& theCoord)
{
- myDim = theDim;
- myNbPoints = theNbPoints;
- myPoints->SetNumberOfPoints(theNbPoints);
+ myPoints->SetNumberOfPoints(theCoord->GetNbPoints());
myCoord = theCoord;
}
- void
+ vtkIdType
TPointCoords
- ::Init(vtkIdType theNbPoints,
- vtkIdType theDim)
+ ::GetNbPoints() const
{
- MED::PNodeCoord aCoord(new MED::TNodeCoord(theNbPoints * theDim));
- Init(theNbPoints, theDim, aCoord);
+ return myCoord->GetNbPoints();
+ }
+
+ vtkIdType
+ TPointCoords
+ ::GetDim() const
+ {
+ return myCoord->GetDim();
}
TCCoordSlice
TPointCoords
::GetCoordSlice(vtkIdType theNodeId) const
{
- return TCCoordSlice(*myCoord, std::slice(theNodeId * myDim, myDim, 1));
+ return myCoord->GetCoordSlice(theNodeId);
}
TCoordSlice
TPointCoords
::GetCoordSlice(vtkIdType theNodeId)
{
- return TCoordSlice(*myCoord, std::slice(theNodeId * myDim, myDim, 1));
+ return myCoord->GetCoordSlice(theNodeId);
}
void
::SetVoidArray() const
{
vtkDataArray* aDataArray = myPoints->GetData();
- aDataArray->SetVoidArray(&(*myCoord)[0], myCoord->size(), false);
+ aDataArray->SetVoidArray(myCoord->GetValuePtr(), myCoord->size(), false);
}
vtkPoints*
TPointCoords
::GetMemorySize()
{
- size_t aSize = sizeof(TCoord) * myCoord->size();
+ size_t aSize = myCoord->GetMemorySize();
aSize += myPoints->GetActualMemorySize() * 1024;
return aSize;
}
//---------------------------------------------------------------
void
TNamedPointCoords
- ::Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const MED::PNodeCoord& theCoord)
- {
- TPointCoords::Init(theNbPoints, theDim, theCoord);
- myPointsDim.resize(theDim);
- }
-
- void
- TNamedPointCoords
- ::Init(vtkIdType theNbPoints,
- vtkIdType theDim)
+ ::Init(const PCoordHolder& theCoord)
{
- TPointCoords::Init(theNbPoints, theDim);
- myPointsDim.resize(theDim);
+ TPointCoords::Init(theCoord);
+ myPointsDim.resize(theCoord->GetDim());
}
std::string&
return theID;
}
-
vtkIdType
TNamedPointCoords
::GetVTKID(vtkIdType theID) const
return "";
}
+
//---------------------------------------------------------------
enum ECoordName{eX, eY, eZ, eNoneCoord};
typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice);
vtkIdType anId = theElemId*myStep;
for(vtkIdType aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
aValueSliceArr[aGaussId] =
- TCValueSlice(myValue,std::slice(anId,myNbComp,1));
+ TCValueSlice(myValue,std::slice(anId, myNbComp, 1));
anId += myNbComp;
}
return aValueSliceArr;
vtkIdType anId = theElemId*myStep;
for(vtkIdType aGaussId = 0; aGaussId < myNbGauss; aGaussId++){
aValueSliceArr[aGaussId] =
- TValueSlice(myValue,std::slice(anId,myNbComp,1));
+ TValueSlice(myValue, std::slice(anId, myNbComp, 1));
anId += myNbComp;
}
return aValueSliceArr;
vtkIdType anId = theElemId*myStep;
for(vtkIdType aCompId = 0; aCompId < myNbComp; aCompId++){
aValueSliceArr[aCompId] =
- TCValueSlice(myValue,std::slice(anId,myNbGauss,myNbComp));
+ TCValueSlice(myValue,std::slice(anId, myNbGauss, myNbComp));
anId += 1;
}
return aValueSliceArr;
vtkIdType anId = theElemId*myStep;
for(vtkIdType aCompId = 0; aCompId < myNbComp; aCompId++){
aValueSliceArr[aCompId] =
- TValueSlice(myValue,std::slice(anId,myNbGauss,myNbComp));
+ TValueSlice(myValue,std::slice(anId, myNbGauss, myNbComp));
anId += 1;
}
return aValueSliceArr;
using MED::TCoordSlice;
using MED::TCCoordSlice;
- //! This class is responsible for representation of mesh nodes
- class TPointCoords: public virtual TBaseStructure
+ //! This class is responsible for keeping the mesh node coordinates
+ class TCoordHolderBase: public virtual TBaseStructure
{
- protected:
vtkIdType myDim; //!< Dimension of the nodal coordinates
vtkIdType myNbPoints; //!< Number of nodes in corresponding mesh
+ public:
+ //! To initilize the instance
+ void
+ Init(vtkIdType theNbPoints,
+ vtkIdType theDim);
+
+ vtkIdType
+ GetNbPoints() const;
+
+ vtkIdType
+ GetDim() const;
+
+ size_t
+ size() const;
+
+ //! Gets memory size used by the instance (bytes).
+ virtual
+ unsigned long int
+ GetMemorySize();
+
+ //! Get slice of coordinates for defined node (const version)
+ virtual
+ TCCoordSlice
+ GetCoordSlice(vtkIdType theNodeId) const = 0;
+
+ //! Get slice of coordinates for defined node
+ virtual
+ TCoordSlice
+ GetCoordSlice(vtkIdType theNodeId) = 0;
+
+ virtual
+ unsigned char*
+ GetValuePtr() = 0;
+ };
+ typedef SharedPtr<TCoordHolderBase> PCoordHolder;
+
+
+ //---------------------------------------------------------------
+ template<class TContainerType>
+ class TCoordHolder: public virtual TCoordHolderBase
+ {
+ protected:
+ mutable TContainerType myCoord; //!< Keeps the node coordinates container itself
+
+ public:
+ //! To initilize the class
+ void
+ Init(vtkIdType theNbPoints,
+ vtkIdType theDim,
+ const TContainerType& theCoord)
+ {
+ TCoordHolderBase::Init(theNbPoints, theDim);
+ myCoord = theCoord;
+ }
+
+ virtual
+ const TCoord*
+ GetPointer() const = 0;
+
+ //! Get slice of coordinates for defined node (const version)
+ virtual
+ TCCoordSlice
+ GetCoordSlice(vtkIdType theNodeId) const
+ {
+ return TCCoordSlice(this->GetPointer(),
+ this->size(),
+ std::slice(theNodeId * this->GetDim(), this->GetDim(), 1));
+ }
+
+ virtual
+ TCoord*
+ GetPointer() = 0;
+
+ //! Get slice of coordinates for defined node
+ virtual
+ TCoordSlice
+ GetCoordSlice(vtkIdType theNodeId)
+ {
+ return TCoordSlice(this->GetPointer(),
+ this->size(),
+ std::slice(theNodeId * this->GetDim(), this->GetDim(), 1));
+ }
+
+ virtual
+ unsigned char*
+ GetValuePtr()
+ {
+ return (unsigned char*)this->GetPointer();
+ }
+ };
+
+
+ //---------------------------------------------------------------
+ //! This class is responsible for representation of mesh nodes
+ class TPointCoords: public virtual TBaseStructure
+ {
+ protected:
//! An container for coordinates of the nodes
/*!
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)
*/
- MED::PNodeCoord myCoord;
+ PCoordHolder myCoord; //!< A pointer to the coordinates container holder
TVTKPoints myPoints; //!< VTK representation for the mesh nodes
void
//! To initilize the class
void
- Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const MED::PNodeCoord& theCoord);
+ Init(const PCoordHolder& theCoord);
- //! To initilize the class
- void
- Init(vtkIdType theNbPoints,
- vtkIdType theDim);
+ vtkIdType
+ GetNbPoints() const;
+
+ vtkIdType
+ GetDim() const;
//! Get slice of coordinates for defined node (const version)
TCCoordSlice
TCoordSlice
GetCoordSlice(vtkIdType theNodeId);
- vtkIdType
- GetNbPoints() const { return myNbPoints; }
-
- vtkIdType
- GetDim() const { return myDim; }
-
virtual
vtkPoints*
GetPoints() const; //!< Gets corresponding VTK structure
//! To initilize the class (numeration of the nodes can be missed)
void
- Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const MED::PNodeCoord& theCoord);
-
- //! To initilize the class (numeration of the nodes can be missed)
- void
- Init(vtkIdType theNbPoints,
- vtkIdType theDim);
+ Init(const PCoordHolder& theCoord);
//! Get name for defined dimension
std::string&
//---------------------------------------------------------------
typedef TVector<vtkFloatingPointType> TValue;
- typedef TSlice<TValue> TValueSlice;
- typedef TCSlice<TValue> TCValueSlice;
+ typedef TSlice<vtkFloatingPointType> TValueSlice;
+ typedef TCSlice<vtkFloatingPointType> TCValueSlice;
typedef TVector<TCValueSlice> TCValueSliceArr;
typedef TVector<TValueSlice> TValueSliceArr;
//---------------------------------------------------------------
void
TMEDNamedPointCoords
- ::Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const MED::PNodeInfo& theNodeInfo,
+ ::Init(const MED::PNodeInfo& theNodeInfo,
MED::EVersion theVersion)
{
- TNamedPointCoords::Init(theNbPoints, theDim, theNodeInfo->myCoord);
+ TMEDCoordHolder* aCoordHolder = new TMEDCoordHolder();
+ TInt aNbElem = theNodeInfo->GetNbElem();
+ TInt aDim = theNodeInfo->GetMeshInfo()->GetDim();
+ aCoordHolder->Init(aNbElem, aDim, theNodeInfo->myCoord);
+ TNamedPointCoords::Init(PCoordHolder(aCoordHolder));
myVersion = theVersion;
myIsElemNum = theNodeInfo->IsElemNum();
void
TMEDNamedPointCoords
- ::Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const MED::PGrilleInfo& theInfo)
+ ::Init(const MED::PGrilleInfo& theGrilleInfo)
{
- TNamedPointCoords::Init(theNbPoints, theDim);
+ TMEDCoordHolder* aCoordHolder = new TMEDCoordHolder();
+ TInt aNbElem = theGrilleInfo->GetNbNodes();
+ TInt aDim = theGrilleInfo->GetMeshInfo()->GetDim();
+ MED::PNodeCoord aCoord(new MED::TNodeCoord(aNbElem * aDim));
+ aCoordHolder->Init(aNbElem, aDim, aCoord);
+ TNamedPointCoords::Init(PCoordHolder(aCoordHolder));
}
vtkIdType
PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
TMEDNamedPointCoords& aCoords = aNamedPointCoords;
- aCoords.Init(aNbElem,aDim,aNodeInfo,theMed->GetVersion());
+ aCoords.Init(aNodeInfo, theMed->GetVersion());
for(int iDim = 0; iDim < aDim; iDim++)
aCoords.GetName(iDim) = aNodeInfo->GetCoordName(iDim);
PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords;
TMEDNamedPointCoords& aCoords = aNamedPointCoords;
- aCoords.Init(aNbElem,aDim,aGrilleInfo);
+ aCoords.Init(aGrilleInfo);
for(int iDim = 0; iDim < aDim; iDim++)
aCoords.GetName(iDim) = aGrilleInfo->GetCoordName(iDim);
aGaussSubMesh->myElemNum = anElemInfo->myElemNum;
std::string aName;
- MED::TGaussCoord aGaussCoord;
bool anIsGaussCoord3D = false;
+ MED::PGaussCoord aGaussCoordPtr(new MED::TGaussCoord());
+ MED::TGaussCoord& aGaussCoord = *aGaussCoordPtr;
MED::TGeom2Gauss::const_iterator aGaussIter = aGeom2Gauss.find(aMGeom);
if(aGaussIter != aGeom2Gauss.end()){
if(anIsGaussCoord3D){
TPointCoords& aCoords = aGaussSubMesh->myPointCoords;
- TInt aNbGauss = aGaussCoord.GetNbGauss();
- TInt aNbElem = aGaussCoord.GetNbElem();
- TInt aDim = aGaussCoord.GetDim();
- vtkIdType aNbCells = aNbElem*aNbGauss;
- aCoords.Init(aNbCells,aDim);
- for(TInt anElemId = 0, aNodeId = 0; anElemId < aNbElem; anElemId++){
- MED::TCoordSliceArr aCoordSliceArr = aGaussCoord.GetCoordSliceArr(anElemId);
- for(TInt aGaussId = 0; aGaussId < aNbGauss; aGaussId++, aNodeId++){
- MED::TCoordSlice aCoordSlice = aCoordSliceArr[aGaussId];
- TCoordSlice aSlice = aCoords.GetCoordSlice(aNodeId);
- for(TInt aDimId = 0; aDimId < aDim; aDimId++)
- aSlice[aDimId] = aCoordSlice[aDimId];
- }
- }
+ TMEDGaussCoordHolder* aCoordHolder = new TMEDGaussCoordHolder();
+ aCoordHolder->Init(aGaussCoordPtr);
+ aCoords.Init(PCoordHolder(aCoordHolder));
- aGaussSubMesh->myIsDone = true;;
+ aGaussSubMesh->myIsDone = true;
+ TInt aNbGauss = aGaussCoord.GetNbGauss();
+ TInt aNbElem = aGaussCoord.GetNbElem();
+ TInt aNbCells = aNbElem*aNbGauss;
+
INITMSG(MYDEBUG,
"- aEGeom = "<<aEGeom<<
"; aName = '"<<aName<<"'"<<
#include "MED_Common.hxx"
#include "MED_Structures.hxx"
+#include "MED_GaussUtils.hxx"
#include <boost/thread/mutex.hpp>
#include <qfileinfo.h>
namespace VISU
{
+ //---------------------------------------------------------------
+ struct TMEDCoordHolder: TCoordHolder<MED::PNodeCoord>
+ {
+ virtual
+ const TCoord*
+ GetPointer() const
+ {
+ return &(*myCoord)[0];
+ }
+
+ virtual
+ TCoord*
+ GetPointer()
+ {
+ return &(*myCoord)[0];
+ }
+ };
+
+
+ //---------------------------------------------------------------
+ struct TMEDGaussCoordHolder: TCoordHolderBase
+ {
+ MED::PGaussCoord myGaussCoord;
+
+ //! To initilize the instance
+ void
+ Init(const MED::PGaussCoord& theGaussCoord)
+ {
+ MED::TInt aNbGauss = theGaussCoord->GetNbGauss();
+ MED::TInt aNbElem = theGaussCoord->GetNbElem();
+ MED::TInt aDim = theGaussCoord->GetDim();
+ MED::TInt aNbCells = aNbElem * aNbGauss;
+ TCoordHolderBase::Init(aNbCells, aDim);
+ myGaussCoord = theGaussCoord;
+ }
+
+ //! Get slice of coordinates for defined node (const version)
+ virtual
+ TCCoordSlice
+ GetCoordSlice(vtkIdType theNodeId) const
+ {
+ MED::TInt anElemId = theNodeId / myGaussCoord->GetNbGauss();
+ MED::TCCoordSliceArr aCoordSliceArr = myGaussCoord->GetCoordSliceArr(anElemId);
+ MED::TInt aGaussId = theNodeId % myGaussCoord->GetNbGauss();
+ return aCoordSliceArr[aGaussId];
+ }
+
+ //! Get slice of coordinates for defined node
+ virtual
+ TCoordSlice
+ GetCoordSlice(vtkIdType theNodeId)
+ {
+ MED::TInt anElemId = theNodeId / myGaussCoord->GetNbGauss();
+ MED::TCoordSliceArr aCoordSliceArr = myGaussCoord->GetCoordSliceArr(anElemId);
+ MED::TInt aGaussId = theNodeId % myGaussCoord->GetNbGauss();
+ return aCoordSliceArr[aGaussId];
+ }
+
+ virtual
+ unsigned char*
+ GetValuePtr()
+ {
+ return myGaussCoord->GetValuePtr();
+ }
+ };
+
+
//---------------------------------------------------------------
typedef std::map<vtkIdType, vtkIdType> TObj2VTKID;
{}
void
- Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const MED::PNodeInfo& theNodeInfo,
+ Init(const MED::PNodeInfo& theNodeInfo,
MED::EVersion theVersion);
void
- Init(vtkIdType theNbPoints,
- vtkIdType theDim,
- const MED::PGrilleInfo& theGrilleInfo);
+ Init(const MED::PGrilleInfo& theGrilleInfo);
//! Get object number for node by its VTK one
virtual
aMesh->myName = aMeshName.in();
aMesh->myMesh = aMEDMesh;
- TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
- aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
-
if(MYDEBUG) MESSAGE("VISU_MEDFieldConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
TMeshOnEntityMap& aMeshOnEntityMap = aMesh->myMeshOnEntityMap;
aMesh->myName = aMeshName.in();
aMesh->myMesh = aMEDMesh;
- TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
- aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
-
if(MYDEBUG)
MESSAGE("VISU_MEDConvertor::Build - aMeshName = "<<aMeshName<<"; myDim = "<<aMesh->myDim);
aMesh->myName = aMeshName.in();
aMesh->myMesh = aMEDMesh;
- TNamedPointCoords& aCoords = aMesh->myNamedPointCoords;
- aCoords.Init(aMesh->myNbPoints,aMesh->myDim);
-
myMeshMap[aMeshName.in()] = aMesh;
if(MYDEBUG)
return 0;
SALOME_MED::MESH_var& aMedMesh = theMesh->myMesh;
- int aDim = theMesh->myDim;
- TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
- int aNbElem = aCoords.GetNbPoints();
+ vtkIdType aDim = theMesh->GetDim();
+ vtkIdType aNbElem = theMesh->GetNbPoints();
if(MYDEBUG) MESSAGE("LoadPoints - aNbElem = "<<aNbElem);
throw std::runtime_error("LoadPoints >> There is no points in the mesh !!!");
SALOME_MED::double_array_var aCCoord = aMedMesh->getCoordinates(SALOME_MED::MED_FULL_INTERLACE);
- for(int iElem = 0, anId = 0; iElem < aNbElem; iElem++){
- VISU::TCoordSlice aCoordSlice = aCoords.GetCoordSlice(iElem);
- for(int iDim = 0; iDim < aDim; iDim++)
- aCoordSlice[iDim] = aCCoord[anId++];
- }
+ TCMEDCoordHolder* aCoordHolder = new TCMEDCoordHolder();
+ aCoordHolder->Init(aNbElem, aDim, aCCoord);
+
+ TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
+ aCoords.Init(PCoordHolder(aCoordHolder));
if(MYDEBUG) MESSAGE("LoadPoints - Filling aMeshOnEntity with type NODE_ENTITY");
if(theFamily->myIsDone)
return 0;
- TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
- int aNbElem = aCoords.GetNbPoints();
-
+ vtkIdType aNbElem = theMesh->GetNbPoints();
SALOME_MED::FAMILY_var aMedFamily = theFamily->myFamily;
CORBA::Boolean anIsOnAllElements = aMedFamily->isOnAllElements();
TSubMeshID& aSubMeshID = theFamily->myGeom2SubMeshID[VISU::ePOINT1];
const TEntity& aVEntity = theMeshOnEntity->myEntity;
int iGeomEnd = GetEntity2Geom(aVEntity,aGeomElems);
const SALOME_MED::medEntityMesh& aMEntity = VTKEntityToMED(aVEntity);
- const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
TGeom2SubMesh& aGeom2SubMesh = theMeshOnEntity->myGeom2SubMesh;
- int aNbPoints = aCoords.GetNbPoints();
+ vtkIdType aNbPoints = theMesh->GetNbPoints();
for(int iGeom = 0, aCounter = 0; iGeom < iGeomEnd; iGeom++){
SALOME_MED::medGeometryElement aMGeom = aGeomElems[iGeom];
if(theField->myEntity == NODE_ENTITY){
VISU::EGeometry aEGeom = VISU::ePOINT1;
int aNbGauss = theValForTime->GetNbGauss(aEGeom);
- const TNamedPointCoords& aCoords = theMesh->myNamedPointCoords;
- int aNbElem = aCoords.GetNbPoints();
+ vtkIdType aNbElem = theMesh->GetNbPoints();
if(MYDEBUG) MESSAGE("ImportField - aNbElem = "<<aNbElem);
namespace VISU
{
+ //---------------------------------------------------------------
+ struct TCMEDCoordHolder: TCoordHolder<SALOME_MED::double_array_var>
+ {
+ virtual
+ const TCoord*
+ GetPointer() const
+ {
+ return &myCoord[0];
+ }
+
+ virtual
+ TCoord*
+ GetPointer()
+ {
+ return &myCoord[0];
+ }
+ };
+
+
//---------------------------------------------------------------
struct TCMesh: virtual TMeshImpl
{
}
-class VISU_MEDConvertor: public VISU_Convertor_impl{
+//---------------------------------------------------------------
+class VISU_MEDConvertor: public VISU_Convertor_impl
+{
protected:
SALOMEDS::SObject_var mySObject;
VISU_MEDConvertor() {};
};
+
+//---------------------------------------------------------------
class VISU_MEDFieldConvertor: public VISU_MEDConvertor
{
protected: