From: apo Date: Tue, 26 Dec 2006 09:39:36 +0000 (+0000) Subject: Implementation of direct passing of MED node coords to VTK X-Git-Tag: WP1_2_3_29-12-2006_MED_to_VTK_data_passing~9 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d51d7ea48a25c4f4946e2b2b8aae171fc7594d54;p=modules%2Fvisu.git Implementation of direct passing of MED node coords to VTK --- diff --git a/src/CONVERTOR/VISU_Convertor.hxx b/src/CONVERTOR/VISU_Convertor.hxx index 2a819f89..ad38703b 100644 --- a/src/CONVERTOR/VISU_Convertor.hxx +++ b/src/CONVERTOR/VISU_Convertor.hxx @@ -77,7 +77,7 @@ namespace VISU TMeshOnEntityMap myMeshOnEntityMap; //!< Contains corresponding meshes for MED ENTITIES TGroupMap myGroupMap; //!< Contains map of bounded MED GROUPS TName myName; //! Name of the corresponding MED MESH - int myDim; //! Dimension of the corresponding MED MESH + vtkIdType myDim; //! Dimension of the corresponding MED MESH std::string myGroupsEntry; //!< To simplify publication of the groups in a data tree std::string myFieldsEntry; //!< To simplify publication of the fiels in a data tree diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index c889ff2d..10ea9e20 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -216,39 +216,65 @@ namespace VISU ::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; } @@ -259,14 +285,19 @@ namespace VISU 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& @@ -287,10 +318,7 @@ namespace VISU TNamedPointCoords ::GetObjID(vtkIdType theID) const { - if(myVectorID.empty()) - return theID; - else - return myVectorID[theID]; + return theID; } @@ -298,14 +326,7 @@ namespace VISU 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 @@ -315,23 +336,183 @@ namespace VISU return ""; } + //--------------------------------------------------------------- + enum ECoordName{eX, eY, eZ, eNoneCoord}; + typedef VISU::TCoord (*TGetCoord)(const VISU::TCCoordSlice& theCoordSlice); + + template + VISU::TCoord + GetCoord(const VISU::TCCoordSlice& theCoordSlice) + { + return theCoordSlice[TCoordId]; + } + + template<> + VISU::TCoord + GetCoord(const VISU::TCCoordSlice& theCoordSlice) + { + return 0.0; + } + + + TGetCoord aXYZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + + TGetCoord aXYGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord aYZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord aXZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + + TGetCoord aXGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord aYGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + TGetCoord aZGetCoord[3] = { + &GetCoord, + &GetCoord, + &GetCoord + }; + + + 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 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 = "<SetNumberOfPoints(aNbPoints); - - INITMSG(MYDEBUG,"GetPoints - aNbPoints = "<GetNumberOfPoints()<GetNumberOfCells()<myMeshOnEntity = theMeshOnEntity.get(); const TVTKAppendFilter& anAppendFilter = theProfile->GetFilter(); - anAppendFilter->SetPoints(GetPoints(theMesh)); + anAppendFilter->SetPoints(theMesh->GetPoints()); if(theProfile->myIsAll){ TVTKOutput* aDataSet = theMeshOnEntity->GetVTKOutput(); @@ -1895,7 +1920,7 @@ namespace 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++){ @@ -1905,11 +1930,11 @@ namespace 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(); @@ -1920,11 +1945,11 @@ namespace 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(); @@ -2099,7 +2124,7 @@ VISU_Convertor_impl 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(); @@ -2113,7 +2138,7 @@ VISU_Convertor_impl 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()); @@ -2184,7 +2209,7 @@ VISU_Convertor_impl GetMeshOnEntity(theMeshName,theEntity); LoadFamilyOnEntity(aMesh,aMeshOnEntity,aFamily); - aSource->SetPoints(GetPoints(aMesh)); + aSource->SetPoints(aMesh->GetPoints()); GetCellsOnFamily(aSource,aMeshOnEntity,aFamily); aFamily->myNamedPointCoords = aMesh->myNamedPointCoords; @@ -2241,7 +2266,7 @@ VISU_Convertor_impl const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet; LoadMeshOnGroup(aMesh,aFamilySet); - anAppendFilter->SetPoints(GetPoints(aMesh)); + anAppendFilter->SetPoints(aMesh->GetPoints()); TFamilySet::const_iterator anIter = aFamilySet.begin(); @@ -2611,7 +2636,7 @@ VISU_Convertor_impl 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; @@ -2619,7 +2644,7 @@ VISU_Convertor_impl 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; @@ -2654,7 +2679,7 @@ VISU_Convertor_impl 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; @@ -2662,7 +2687,7 @@ VISU_Convertor_impl 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; @@ -2711,14 +2736,14 @@ VISU_Convertor_impl 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; @@ -2749,7 +2774,7 @@ VISU_Convertor_impl 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]; @@ -2757,8 +2782,7 @@ VISU_Convertor_impl 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); diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index 3dd566de..4e316b7e 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -41,6 +41,7 @@ class VISU_MergeFilter; #include "VISU_Convertor.hxx" #include "MED_SliceArray.hxx" +#include "MED_Structures.hxx" #ifndef VISU_ENABLE_QUADRATIC #define VISU_ENABLE_QUADRATIC @@ -76,15 +77,13 @@ namespace VISU typedef vtkSmartPointer 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 }; @@ -183,9 +182,9 @@ namespace VISU //--------------------------------------------------------------- - typedef TVector TCoordArray; - typedef TSlice TCoordSlice; - typedef TCSlice 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 @@ -199,12 +198,21 @@ namespace VISU 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, @@ -224,11 +232,9 @@ namespace VISU 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 @@ -239,21 +245,17 @@ namespace VISU //--------------------------------------------------------------- - typedef TVector TVectorID; - typedef std::map 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 TPointsDim; TPointsDim myPointsDim; //!< Keeps name of each dimension - TVectorID myVectorID; //!< Keeps objects numeration - TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one public: @@ -261,7 +263,12 @@ namespace VISU 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& @@ -286,6 +293,10 @@ namespace VISU 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 @@ -300,11 +311,19 @@ namespace VISU 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 PMeshImpl; diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index d6789c62..0055bdf9 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -1004,11 +1004,17 @@ namespace 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; } @@ -1019,7 +1025,30 @@ namespace 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 @@ -1034,8 +1063,8 @@ namespace 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); } @@ -1044,7 +1073,14 @@ namespace ::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; } @@ -1055,11 +1091,21 @@ namespace ::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 @@ -1088,13 +1134,23 @@ namespace 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 @@ -1103,10 +1159,10 @@ namespace MED::EVersion theVersion) { myIsElemNum = theElemInfo->IsElemNum(); - if(myIsElemNum) myElemNum = theElemInfo->myElemNum; + myIsElemNames = theElemInfo->IsElemNames(); if(theElemInfo->IsElemNames()) myElemNames = theElemInfo->myElemNames; } @@ -1115,17 +1171,14 @@ namespace 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); } @@ -1134,8 +1187,8 @@ namespace 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); } @@ -1144,11 +1197,17 @@ namespace ::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; diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index 15e31e9c..278f98f8 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -30,11 +30,24 @@ namespace VISU { //--------------------------------------------------------------- + typedef std::map TObj2VTKID; + class TMEDNamedPointCoords: public virtual TNamedPointCoords { + MED::EBooleen myIsElemNum; //!< Keeps whether the numeration exists or not + MED::PElemNum myElemNum; //!< Keeps objects numeration + TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one + MED::EVersion myVersion; - MED::TString myElemNames; + MED::PString myElemNames; //!< Keeps whether the names exists or not + MED::EBooleen myIsElemNames; //!< Keeps objects names + public: + TMEDNamedPointCoords(): + myIsElemNum(MED::eFAUX), + myIsElemNames(MED::eFAUX) + {} + void Init(vtkIdType theNbPoints, vtkIdType theDim, @@ -46,6 +59,17 @@ namespace VISU vtkIdType theDim, const MED::PGrilleInfo& theGrilleInfo); + //! Get object number for node by its VTK one + virtual + vtkIdType + GetObjID(vtkIdType theID) const; + + //! Get VTK number for node by its object one + virtual + vtkIdType + GetVTKID(vtkIdType theID) const; + + //! Get name of node by its object number virtual std::string GetNodeName(vtkIdType theObjID) const; @@ -77,11 +101,16 @@ namespace VISU {} MED::EBooleen myIsElemNum; - MED::TElemNum myElemNum; + MED::PElemNum myElemNum; virtual vtkIdType GetElemObjID(vtkIdType theID) const; + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); }; typedef SharedPtr PMEDSubProfile; @@ -114,12 +143,17 @@ namespace VISU {} MED::EBooleen myIsElemNum; - MED::TElemNum myElemNum; + MED::PElemNum myElemNum; virtual TGaussPointID GetObjID(vtkIdType theID, vtkIdType theStartID) const; + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); }; typedef SharedPtr PMEDGaussSubMesh; @@ -134,14 +168,16 @@ namespace VISU struct TMEDSubMesh: virtual TSubMeshImpl { TMEDSubMesh(): - myIsElemNum(MED::eFAUX) + myIsElemNum(MED::eFAUX), + myIsElemNames(MED::eFAUX) {} MED::EBooleen myIsElemNum; - MED::TElemNum myElemNum; + MED::PElemNum myElemNum; MED::EVersion myVersion; - MED::TString myElemNames; + MED::PString myElemNames; + MED::EBooleen myIsElemNames; void Init(const MED::PElemInfo& theElemInfo,