#include <vtkCellData.h>
#include <vtkDataSet.h>
+#include <vtkIntArray.h>
+#include <algorithm>
+
#ifdef _DEBUG_
static int MYDEBUG = 0;
#else
namespace VISU
{
+ //---------------------------------------------------------------
void
WriteToFile(vtkUnstructuredGrid* theDataSet, const std::string& theFileName)
{
}
+ //---------------------------------------------------------------
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<vtkIntArray*>(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<vtkIntArray*>(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<vtkIntArray*>(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<vtkIntArray*>(aDataArray)){
+ return anIntArray->GetValue(theID);
+ }
+ }
+ return -1;
}
+ //---------------------------------------------------------------
TTimerLog
::TTimerLog(int theIsDebug,
const std::string& theName):
BEGMSG(myIsDebug > 1,"{\n");
}
+ //---------------------------------------------------------------
TTimerLog
::~TTimerLog()
{