From: apo Date: Wed, 28 Mar 2007 07:11:11 +0000 (+0000) Subject: To introduce the common functionality which can be used for mapping ids purposes X-Git-Tag: V3_2_6pre3~1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=538bc3bdc7f25209a387b5a889138cf6a3e77fa7;p=modules%2Fvisu.git To introduce the common functionality which can be used for mapping ids purposes (In context of fix for Bug NPAL15278 - "EDF 347 : ScalarMaponDeformedShape") --- diff --git a/src/CONVERTOR/VISU_ConvertorUtils.cxx b/src/CONVERTOR/VISU_ConvertorUtils.cxx index a926628f..d1334e02 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.cxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.cxx @@ -32,6 +32,9 @@ #include #include +#include +#include + #ifdef _DEBUG_ static int MYDEBUG = 0; #else @@ -41,6 +44,7 @@ static int MYDEBUG = 0; namespace VISU { + //--------------------------------------------------------------- void WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName) { @@ -53,26 +57,99 @@ namespace VISU } + //--------------------------------------------------------------- bool IsDataOnPoints(vtkDataSet* theDataSet) { theDataSet->Update(); - if(theDataSet->GetPointData()->GetArray("VISU_POINTS_MAPPER")) - return theDataSet->GetPointData()->GetNumberOfArrays() > 1; - return theDataSet->GetPointData()->GetNumberOfArrays() > 0; + vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData(); + if(aDataSetAttributes->GetArray("VISU_POINTS_MAPPER")) + return aDataSetAttributes->GetNumberOfArrays() > 1; + return aDataSetAttributes->GetNumberOfArrays() > 0; } + //--------------------------------------------------------------- bool IsDataOnCells(vtkDataSet* theDataSet) { theDataSet->Update(); - if(theDataSet->GetCellData()->GetArray("VISU_CELLS_MAPPER")) - return theDataSet->GetCellData()->GetNumberOfArrays() > 1; - return theDataSet->GetCellData()->GetNumberOfArrays() > 0; + vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData(); + if(aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")) + return aDataSetAttributes->GetNumberOfArrays() > 1; + return aDataSetAttributes->GetNumberOfArrays() > 0; + } + + + //--------------------------------------------------------------- + vtkIdType + GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID) + { + theDataSet->Update(); + vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData(); + if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")){ + if(vtkIntArray *anIntArray = dynamic_cast(aDataArray)){ + int aMaxId = anIntArray->GetMaxId(); + int* aPointer = anIntArray->GetPointer(0); + int* anEndPointer = anIntArray->GetPointer(aMaxId + 1); + int* aPtr = std::find(aPointer, anEndPointer, theID); + return aPtr - aPointer; + } + } + return -1; + } + + + //--------------------------------------------------------------- + vtkIdType + GetElemObjID(vtkDataSet *theDataSet, vtkIdType theID) + { + theDataSet->Update(); + vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetCellData(); + if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_CELLS_MAPPER")){ + if(vtkIntArray *anIntArray = dynamic_cast(aDataArray)){ + return anIntArray->GetValue(theID); + } + } + return -1; + } + + + //--------------------------------------------------------------- + vtkIdType + GetNodeVTKID(vtkDataSet *theDataSet, vtkIdType theID) + { + theDataSet->Update(); + vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData(); + if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_POINTS_MAPPER")){ + if(vtkIntArray *anIntArray = dynamic_cast(aDataArray)){ + int aMaxId = anIntArray->GetMaxId(); + int* aPointer = anIntArray->GetPointer(0); + int* anEndPointer = anIntArray->GetPointer(aMaxId + 1); + int* aPtr = std::find(aPointer, anEndPointer, theID); + return aPtr - aPointer; + } + } + return -1; + } + + + //--------------------------------------------------------------- + vtkIdType + GetNodeObjID(vtkDataSet *theDataSet, vtkIdType theID) + { + theDataSet->Update(); + vtkDataSetAttributes *aDataSetAttributes = theDataSet->GetPointData(); + if(vtkDataArray *aDataArray = aDataSetAttributes->GetArray("VISU_POINTS_MAPPER")){ + if(vtkIntArray *anIntArray = dynamic_cast(aDataArray)){ + return anIntArray->GetValue(theID); + } + } + return -1; } + //--------------------------------------------------------------- TTimerLog ::TTimerLog(int theIsDebug, const std::string& theName): @@ -85,6 +162,7 @@ namespace VISU BEGMSG(myIsDebug > 1,"{\n"); } + //--------------------------------------------------------------- TTimerLog ::~TTimerLog() { diff --git a/src/CONVERTOR/VISU_ConvertorUtils.hxx b/src/CONVERTOR/VISU_ConvertorUtils.hxx index 2a86f810..6c952733 100644 --- a/src/CONVERTOR/VISU_ConvertorUtils.hxx +++ b/src/CONVERTOR/VISU_ConvertorUtils.hxx @@ -30,6 +30,7 @@ #include #include +#include #include "MED_Utilities.hxx" @@ -54,6 +55,18 @@ namespace VISU bool IsDataOnPoints(vtkDataSet* theDataSet); + vtkIdType + GetElemVTKID(vtkDataSet *theDataSet, vtkIdType theID); + + vtkIdType + GetElemObjID(vtkDataSet *theDataSet, vtkIdType theID); + + vtkIdType + GetNodeVTKID(vtkDataSet *theDataSet, vtkIdType theID); + + vtkIdType + GetNodeObjID(vtkDataSet *theDataSet, vtkIdType theID); + class TTimerLog { int myIsDebug;