Commit 8063ad4b authored by Yohann Bearzi's avatar Yohann Bearzi
Browse files

Point Data to Cell Data in htg

vtkHyperTreeGrid used to store its data as a point data.
It makes more sense to treat it as cell data, given that
datas are stored in nodes of a hypertrees which are
being visualized as voxels.
parent 60d96056
......@@ -13,15 +13,15 @@ htg.Initialize()
scalarArray = vtk.vtkDoubleArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(0)
htg.GetPointData().AddArray(scalarArray)
htg.GetPointData().SetActiveScalars('scalar')
htg.GetCellData().AddArray(scalarArray)
htg.GetCellData().SetActiveScalars('scalar')
vecArray = vtk.vtkDoubleArray()
vecArray.SetName('vector')
vecArray.SetNumberOfValues(0)
vecArray.SetNumberOfComponents(3)
htg.GetPointData().AddArray(vecArray)
htg.GetPointData().SetActiveScalars('vector')
htg.GetCellData().AddArray(vecArray)
htg.GetCellData().SetActiveScalars('vector')
htg.SetDimensions([4, 3, 1])
htg.SetBranchFactor(2)
......
......@@ -14,8 +14,8 @@ htg.Initialize()
scalarArray = vtk.vtkUnsignedCharArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(26)
htg.GetPointData().AddArray(scalarArray)
htg.GetPointData().SetActiveScalars('scalar')
htg.GetCellData().AddArray(scalarArray)
htg.GetCellData().SetActiveScalars('scalar')
for i in range(26):
scalarArray.InsertTuple1(i, i+1)
......
......@@ -12,7 +12,7 @@ htg.Initialize()
scalarArray = vtk.vtkUnsignedCharArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(0)
htg.GetPointData().AddArray(scalarArray)
htg.GetCellData().AddArray(scalarArray)
mask = vtk.vtkBitArray()
mask.SetName('mask')
......
......@@ -7,8 +7,8 @@ htg.Initialize()
scalarArray = vtk.vtkDoubleArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(0)
htg.GetPointData().AddArray(scalarArray)
htg.GetPointData().SetActiveScalars('scalar')
htg.GetCellData().AddArray(scalarArray)
htg.GetCellData().SetActiveScalars('scalar')
htg.SetDimensions([4, 3, 1])
htg.SetBranchFactor(2)
......
......@@ -100,12 +100,12 @@ sideArray = vtk.vtkUnsignedCharArray()
sideArray.SetName('sideArray')
sideArray.SetNumberOfValues(0)
sideArray.SetNumberOfComponents(1)
htg.GetPointData().AddArray(sideArray)
htg.GetCellData().AddArray(sideArray)
#quand je mets cela je n'ai plus rien d'affiche
#htg.GetPointData().SetScalars(levels)
#htg.GetPointData().AddArray(sideArray)
#htg.GetPointData().SetActiveScalars('levels')
#htg.GetCellData().SetScalars(levels)
#htg.GetCellData().AddArray(sideArray)
#htg.GetCellData().SetActiveScalars('levels')
#htg.SetMaterialMask(mask)
mask = vtk.vtkBitArray()
......@@ -145,10 +145,10 @@ print('offsetIndex: ', offsetIndex)
htg.Squeeze()
# Activation d'une scalaire
htg.GetPointData().SetActiveScalars('sideArray')
htg.GetCellData().SetActiveScalars('sideArray')
# DataRange sideArray on PointData HTG
dataRange = htg.GetPointData().GetArray('sideArray').GetRange()
dataRange = htg.GetCellData().GetArray('sideArray').GetRange()
print('sideArray on PointData HTG:', dataRange)
print('HTG:', htg.GetNumberOfVertices())
......
......@@ -13,8 +13,8 @@ htg.Initialize()
scalarArray = vtk.vtkDoubleArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(0)
htg.GetPointData().AddArray(scalarArray)
htg.GetPointData().SetActiveScalars('scalar')
htg.GetCellData().AddArray(scalarArray)
htg.GetCellData().SetActiveScalars('scalar')
htg.SetDimensions([4, 3, 3])
htg.SetBranchFactor(2)
......
......@@ -100,7 +100,7 @@ sideArray = vtk.vtkUnsignedCharArray()
sideArray.SetName('sideArray')
sideArray.SetNumberOfValues(0)
sideArray.SetNumberOfComponents(1)
htg.GetPointData().AddArray(sideArray)
htg.GetCellData().AddArray(sideArray)
mask = vtk.vtkBitArray()
mask.SetName('mask')
......@@ -139,10 +139,10 @@ print('offsetIndex: ', offsetIndex)
htg.Squeeze()
# Activation d'une scalaire
htg.GetPointData().SetActiveScalars('sideArray')
htg.GetCellData().SetActiveScalars('sideArray')
# DataRange sideArray on PointData HTG
dataRange = htg.GetPointData().GetArray('sideArray').GetRange()
dataRange = htg.GetCellData().GetArray('sideArray').GetRange()
print('sideArray on PointData HTG:', dataRange)
isFilter = False
......
......@@ -13,8 +13,8 @@ htg.Initialize()
scalarArray = vtk.vtkDoubleArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(0)
htg.GetPointData().AddArray(scalarArray)
htg.GetPointData().SetActiveScalars('scalar')
htg.GetCellData().AddArray(scalarArray)
htg.GetCellData().SetActiveScalars('scalar')
mask = vtk.vtkBitArray()
mask.SetName('mask')
......
......@@ -7,8 +7,8 @@ htg.Initialize()
scalarArray = vtk.vtkDoubleArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(0)
htg.GetPointData().AddArray(scalarArray)
htg.GetPointData().SetActiveScalars('scalar')
htg.GetCellData().AddArray(scalarArray)
htg.GetCellData().SetActiveScalars('scalar')
htg.SetDimensions([4, 3, 3])
htg.SetBranchFactor(2)
......
......@@ -13,8 +13,8 @@ htg.Initialize()
scalarArray = vtk.vtkDoubleArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(0)
htg.GetPointData().AddArray(scalarArray)
htg.GetPointData().SetActiveScalars('scalar')
htg.GetCellData().AddArray(scalarArray)
htg.GetCellData().SetActiveScalars('scalar')
htg.SetDimensions([4, 3, 1])
htg.SetBranchFactor(2)
......
......@@ -12,8 +12,8 @@ htg.Initialize()
scalarArray = vtk.vtkUnsignedCharArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(0)
htg.GetPointData().AddArray(scalarArray)
htg.GetPointData().SetActiveScalars('scalar')
htg.GetCellData().AddArray(scalarArray)
htg.GetCellData().SetActiveScalars('scalar')
mask = vtk.vtkBitArray()
mask.SetName('mask')
......
......@@ -7,8 +7,8 @@ htg.Initialize()
scalarArray = vtk.vtkDoubleArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(0)
htg.GetPointData().AddArray(scalarArray)
htg.GetPointData().SetActiveScalars('scalar')
htg.GetCellData().AddArray(scalarArray)
htg.GetCellData().SetActiveScalars('scalar')
htg.SetDimensions([4, 3, 1])
htg.SetBranchFactor(2)
......
......@@ -7,8 +7,8 @@ htg.Initialize()
scalarArray = vtk.vtkDoubleArray()
scalarArray.SetName('scalar')
scalarArray.SetNumberOfValues(0)
htg.GetPointData().AddArray(scalarArray)
htg.GetPointData().SetActiveScalars('scalar')
htg.GetCellData().AddArray(scalarArray)
htg.GetCellData().SetActiveScalars('scalar')
htg.SetDimensions([4, 3, 3])
htg.SetBranchFactor(2)
......
......@@ -16,6 +16,7 @@ PURPOSE. See the above copyright notice for more information.
#include "vtkBitArray.h"
#include "vtkBoundingBox.h"
#include "vtkCellData.h"
#include "vtkCollection.h"
#include "vtkDoubleArray.h"
#include "vtkFieldData.h"
......@@ -39,7 +40,6 @@ PURPOSE. See the above copyright notice for more information.
#include "vtkMath.h"
#include "vtkNew.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkSmartPointer.h"
#include "vtkStructuredData.h"
#include "vtkUnsignedCharArray.h"
......@@ -200,8 +200,8 @@ vtkHyperTreeGrid::vtkHyperTreeGrid()
void vtkHyperTreeGrid::Initialize()
{
this->Superclass::Initialize();
// DataObject Initialize will not do PointData
this->PointData->Initialize();
// DataObject Initialize will not do CellData
this->CellData->Initialize();
// Delete existing trees
this->HyperTrees.clear();
......@@ -413,8 +413,8 @@ void vtkHyperTreeGrid::PrintSelf(ostream& os, vtkIndent indent)
}
os << indent << "HyperTrees: " << this->HyperTrees.size() << endl;
os << indent << "PointData:" << endl;
this->PointData->PrintSelf(os, indent.GetNextIndent());
os << indent << "CellData:" << endl;
this->CellData->PrintSelf(os, indent.GetNextIndent());
}
//----------------------------------------------------------------------------
......@@ -467,7 +467,7 @@ void vtkHyperTreeGrid::CopyEmptyStructure(vtkDataObject* ds)
this->SetInterfaceNormalsName(htg->InterfaceNormalsName);
this->SetInterfaceInterceptsName(htg->InterfaceInterceptsName);
this->PointData->CopyStructure(htg->GetPointData());
this->CellData->CopyStructure(htg->GetCellData());
}
//-----------------------------------------------------------------------------
......@@ -512,7 +512,7 @@ void vtkHyperTreeGrid::CopyStructure(vtkDataObject* ds)
this->SetMask(htg->GetMask());
vtkSetObjectBodyMacro(PureMask, vtkBitArray, htg->GetPureMask());
this->PointData->CopyStructure(htg->GetPointData());
this->CellData->CopyStructure(htg->GetCellData());
// Search for hyper tree with given index
this->HyperTrees.clear();
......@@ -1159,7 +1159,7 @@ void vtkHyperTreeGrid::ShallowCopy(vtkDataObject* src)
// Copy member variables
this->CopyStructure(htg);
this->PointData->ShallowCopy(htg->GetPointData());
this->CellData->ShallowCopy(htg->GetCellData());
// Call superclass
this->Superclass::ShallowCopy(src);
......@@ -1204,7 +1204,7 @@ void vtkHyperTreeGrid::DeepCopy(vtkDataObject* src)
this->InitPureMask = htg->InitPureMask;
}
this->PointData->DeepCopy(htg->GetPointData());
this->CellData->DeepCopy(htg->GetCellData());
// Rectilinear part
memcpy(this->Dimensions, htg->GetDimensions(), 3 * sizeof(unsigned int));
......@@ -1376,7 +1376,7 @@ unsigned long vtkHyperTreeGrid::GetActualMemorySizeBytes()
// JB Faut il compter le cout des grandeurs dans la representation ???
// JB Il ne me semble pas que cela soit fait ainsi dans les autres representations
size += this->PointData->GetActualMemorySize() << 10;
size += this->CellData->GetActualMemorySize() << 10;
return static_cast<unsigned long>(size);
}
......@@ -1659,9 +1659,9 @@ void vtkHyperTreeGrid::GetCenter(double* octr)
}
//-----------------------------------------------------------------------------
vtkPointData* vtkHyperTreeGrid::GetPointData()
vtkCellData* vtkHyperTreeGrid::GetCellData()
{
return this->PointData.GetPointer();
return this->CellData.GetPointer();
}
//-----------------------------------------------------------------------------
......@@ -1670,12 +1670,12 @@ vtkUnsignedCharArray* vtkHyperTreeGrid::GetTreeGhostArray()
if (!this->TreeGhostArrayCached)
{
this->TreeGhostArray = vtkArrayDownCast<vtkUnsignedCharArray>(
this->GetPointData()->GetArray(vtkDataSetAttributes::GhostArrayName()));
this->GetCellData()->GetArray(vtkDataSetAttributes::GhostArrayName()));
this->TreeGhostArrayCached = true;
}
assert(this->TreeGhostArray ==
vtkArrayDownCast<vtkUnsignedCharArray>(
this->GetPointData()->GetArray(vtkDataSetAttributes::GhostArrayName())));
this->GetCellData()->GetArray(vtkDataSetAttributes::GhostArrayName())));
return this->TreeGhostArray;
}
......@@ -1689,7 +1689,7 @@ vtkUnsignedCharArray* vtkHyperTreeGrid::AllocateTreeGhostArray()
ghosts->SetNumberOfComponents(1);
ghosts->SetNumberOfTuples(this->GetMaxNumberOfTrees());
ghosts->Fill(0);
this->GetPointData()->AddArray(ghosts);
this->GetCellData()->AddArray(ghosts);
ghosts->Delete();
this->TreeGhostArray = ghosts;
this->TreeGhostArrayCached = true;
......@@ -1701,11 +1701,11 @@ vtkUnsignedCharArray* vtkHyperTreeGrid::AllocateTreeGhostArray()
vtkUnsignedCharArray* vtkHyperTreeGrid::GetGhostCells()
{
return vtkUnsignedCharArray::SafeDownCast(
this->PointData->GetArray(vtkDataSetAttributes::GhostArrayName()));
this->CellData->GetArray(vtkDataSetAttributes::GhostArrayName()));
}
//----------------------------------------------------------------------------
bool vtkHyperTreeGrid::HasAnyGhostCells() const
{
return this->PointData->GetArray(vtkDataSetAttributes::GhostArrayName()) != nullptr;
return this->CellData->GetArray(vtkDataSetAttributes::GhostArrayName()) != nullptr;
}
......@@ -64,7 +64,6 @@
#include "vtkNew.h" // vtkSmartPointer
#include "vtkSmartPointer.h" // vtkSmartPointer
// #include "vtkPointData.h" // vtkPointData
#include <cassert> // std::assert
#include <map> // std::map
......@@ -90,7 +89,7 @@ class vtkIdTypeArray;
class vtkLine;
class vtkPixel;
class vtkPoints;
class vtkPointData;
class vtkCellData;
class vtkUnsignedCharArray;
class VTKCOMMONDATAMODEL_EXPORT vtkHyperTreeGrid : public vtkDataObject
......@@ -720,7 +719,7 @@ public:
* Return a pointer to this dataset's point/tree data.
* THIS METHOD IS THREAD SAFE
*/
vtkPointData* GetPointData();
vtkCellData* GetCellData();
//@}
protected:
......@@ -788,7 +787,7 @@ protected:
std::map<vtkIdType, vtkSmartPointer<vtkHyperTree> > HyperTrees;
vtkNew<vtkPointData> PointData; // Scalars, vectors, etc. associated w/ each point
vtkNew<vtkCellData> CellData; // Scalars, vectors, etc. associated w/ each point
unsigned int DepthLimiter;
......
......@@ -546,7 +546,7 @@ vtkAbstractArray* vtkAlgorithm::GetInputAbstractArrayToProcess(
if (vtkHyperTreeGrid::SafeDownCast(input))
{
return vtkHyperTreeGrid::SafeDownCast(input)->GetPointData()->GetAbstractArray(name);
return vtkHyperTreeGrid::SafeDownCast(input)->GetCellData()->GetAbstractArray(name);
}
vtkDataSet* inputDS = vtkDataSet::SafeDownCast(input);
......@@ -578,7 +578,7 @@ vtkAbstractArray* vtkAlgorithm::GetInputAbstractArrayToProcess(
if (vtkHyperTreeGrid::SafeDownCast(input))
{
int fType = inArrayInfo->Get(vtkDataObject::FIELD_ATTRIBUTE_TYPE());
return vtkHyperTreeGrid::SafeDownCast(input)->GetPointData()->GetAbstractAttribute(fType);
return vtkHyperTreeGrid::SafeDownCast(input)->GetCellData()->GetAbstractAttribute(fType);
}
vtkErrorMacro("Attempt to get point or cell data from a data object");
return nullptr;
......
......@@ -16,11 +16,11 @@
#include "vtkBitArray.h"
#include "vtkCommand.h"
#include "vtkDataSetAttributes.h"
#include "vtkHyperTreeGrid.h"
#include "vtkInformation.h"
#include "vtkInformationVector.h"
#include "vtkObjectFactory.h"
#include "vtkPointData.h"
#include "vtkPolyData.h"
#include "vtkStreamingDemandDrivenPipeline.h"
#include "vtkUnstructuredGrid.h"
......
......@@ -23,6 +23,7 @@
#include "vtkPointData.h"
#include "vtkPolygonBuilder.h"
//----------------------------------------------------------------------------
vtkContourHelper::vtkContourHelper(vtkIncrementalPointLocator* locator, vtkCellArray* verts,
vtkCellArray* lines, vtkCellArray* polys, vtkPointData* inPd, vtkCellData* inCd,
vtkPointData* outPd, vtkCellData* outCd, int estimatedSize, bool outputTriangles)
......@@ -46,6 +47,7 @@ vtkContourHelper::vtkContourHelper(vtkIncrementalPointLocator* locator, vtkCellA
this->PolyCollection = vtkIdListCollection::New();
}
//----------------------------------------------------------------------------
vtkContourHelper::~vtkContourHelper()
{
this->Tris->Delete();
......@@ -53,6 +55,7 @@ vtkContourHelper::~vtkContourHelper()
this->PolyCollection->Delete();
}
//----------------------------------------------------------------------------
void vtkContourHelper::Contour(
vtkCell* cell, double value, vtkDataArray* cellScalars, vtkIdType cellId)
{
......
......@@ -216,7 +216,7 @@ int vtkGenericProbeFilter::RequestData(vtkInformation* vtkNotUsed(request),
}
else
{
outputPD->NullPoint(ptId);
outputPD->NullData(ptId);
}
}
cellIt->Delete();
......
......@@ -183,7 +183,7 @@ int vtkAdaptiveDataSetSurfaceFilter::DataSetExecute(vtkDataObject* inputDS, vtkP
this->Orientation = input->GetOrientation();
// Initialize output cell data
this->InData = static_cast<vtkDataSetAttributes*>(input->GetPointData());
this->InData = static_cast<vtkDataSetAttributes*>(input->GetCellData());
this->OutData = static_cast<vtkDataSetAttributes*>(output->GetCellData());
this->OutData->CopyAllocate(this->InData);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment