From abba06a5492c6fcce4448b397229870502f3ebe1 Mon Sep 17 00:00:00 2001 From: apo Date: Wed, 31 Aug 2005 12:19:26 +0000 Subject: [PATCH] To introduce ID's mapping for Family mesh --- src/CONVERTOR/VISU_Convertor_impl.cxx | 75 +++++++++++++++++++++++++-- src/CONVERTOR/VISU_Convertor_impl.hxx | 32 +++++++++++- 2 files changed, 103 insertions(+), 4 deletions(-) diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index cd0f1599..0869c283 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -371,6 +371,28 @@ namespace VISU //--------------------------------------------------------------- + float* + TMeshOnEntityImpl + ::GetNodeCoord(vtkIdType theObjID) + { + vtkIdType aVtkID = GetNodeVTKID(theObjID); + return GetFilter()->GetOutput()->GetPoint(aVtkID); + } + + vtkIdType + TMeshOnEntityImpl + ::GetNodeVTKID(vtkIdType theID) const + { + return myNamedPointCoords->GetVTKID(theID); + } + + vtkIdType + TMeshOnEntityImpl + ::GetNodeObjID(vtkIdType theID) const + { + return myNamedPointCoords->GetObjID(theID); + } + vtkCell* TMeshOnEntityImpl ::GetElemCell(int theObjID) @@ -451,6 +473,39 @@ namespace VISU return make_pair(aNbCells,aCellsSize); } + vtkCell* + TGroupImpl + ::GetElemCell(int theObjID) + { + vtkIdType aVtkID = GetElemVTKID(theObjID); + return GetFilter()->GetOutput()->GetCell(aVtkID); + } + + 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; + const TVTKAppendFilter& anAppendFilter = GetFilter(); + vtkIdType anID = anAppendFilter->GetCellInputID(theID,anInputID); + const PFamilyImpl& aFamily = myFamilyArr[anInputID]; + return aFamily->GetElemObjID(anID); + } + //--------------------------------------------------------------- void @@ -1492,6 +1547,8 @@ VISU_Convertor_impl aSource->SetPoints(GetPoints(aMesh)); GetCellsOnFamily(aSource,aMeshOnEntity,aFamily); + aFamily->myNamedPointCoords = aMesh->myNamedPointCoords; + aFamily->myIsVTKDone = true; if(MYDEBUGWITHFILES){ @@ -1544,14 +1601,26 @@ VISU_Convertor_impl const VISU::TFamilySet& aFamilySet = aGroup->myFamilySet; LoadMeshOnGroup(aMesh,aFamilySet); - TFamilySet::const_iterator aFamilyIter = aFamilySet.begin(); - for(; aFamilyIter != aFamilySet.end(); aFamilyIter++){ - PFamilyImpl aFamily = *aFamilyIter; + 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; TOutput* anOutput = GetFamilyOnEntity(theMeshName,anEntity,aFamilyName); 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; diff --git a/src/CONVERTOR/VISU_Convertor_impl.hxx b/src/CONVERTOR/VISU_Convertor_impl.hxx index 51f65ff0..11c1fe87 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.hxx +++ b/src/CONVERTOR/VISU_Convertor_impl.hxx @@ -297,9 +297,21 @@ namespace VISU struct TMeshOnEntityImpl: virtual TMeshOnEntity, virtual TAppendFilter, virtual TSizeCounter { + virtual + float* + GetNodeCoord(vtkIdType theObjID); + + virtual + vtkIdType + GetNodeVTKID(vtkIdType theID) const; + + virtual + vtkIdType + GetNodeObjID(vtkIdType theID) const; + virtual vtkCell* - GetElemCell(int theObjID); + GetElemCell(vtkIdType theID); virtual vtkIdType @@ -335,6 +347,7 @@ namespace VISU vtkIdType GetElemObjID(vtkIdType theID) const; + PNamedPointCoords myNamedPointCoords; TID2ID myElemObj2VTKID; TSubMeshID myMeshID; @@ -345,11 +358,28 @@ namespace VISU //--------------------------------------------------------------- typedef std::pair TNbASizeCells; + typedef TVector TFamilyArr; struct TGroupImpl: virtual TGroup, virtual TAppendFilter { TNbASizeCells GetNbASizeCells() const; + + virtual + vtkCell* + GetElemCell(int theObjID); + + virtual + vtkIdType + GetElemVTKID(vtkIdType theID) const; + + virtual + vtkIdType + GetElemObjID(vtkIdType theID) const; + + TID2ID myElemObj2VTKID; + TFamilyArr myFamilyArr; + PNamedPointCoords myNamedPointCoords; }; typedef SharedPtr PGroupImpl; -- 2.39.2