vtkDecimatePro using vtkDataSet

Hi,

I’m trying to use vtkDecimatePro for a surface mesh.

An input data I use is a format of the vtkDataSet.

However, the vtkDecimatePro seems to need a vtkPolyData format.

I’ve already tried to vtkPolyData::safeDownCast(myDataSet), and the process failed for some reason.

the data was converted to the vtkImageData, though.

I want to use vtkSmoothPolyDataFilter, vtkPolyDataNormal, vtkStripper after the vtkDecimatePro.

Is this an awesome way to use these filters with my dataset?


this is my dataset, and I wrote this file with a vtkDataSetReader.

volumeData.zip (8.3 KB)

Just use the vtkExtractSurface filter to get the vtkPolyData that you need from your dataset.

1 Like

I got an error!, what have I done wrong?

vtkNew<vtkExtractSurface> surface;
surface->SetInputData(m_VolumeReader->GetOutput());
surface->SetRadius(5 * .99);
surface->Update();

vtkNew<vtkPolyData> testPolyData;
testPolyData->DeepCopy(surface->GetOutput());
vtkNew<vtkPolyDataMapper> testMapper;
testMapper->SetInputData(testPolyData);
testMapper->Update();
vtkNew<vtkActor> testActor;
testActor->SetMapper(testMapper);

m_ren->AddActor(testActor);

ERROR: In D:\Libraries\VTK\VTK 9.0.1\VTK-9.0.1\Common\ExecutionModel\vtkExecutive.cxx, line 753
vtkCompositeDataPipeline (161CBD28): Algorithm vtkExtractSurface(161CBAA8) returned failure for request: vtkInformation (17B37C28)
Debug: Off
Modified Time: 11830
Reference Count: 1
Registered Events: (none)
Request: REQUEST_DATA
FORWARD_DIRECTION: 0
ALGORITHM_AFTER_FORWARD: 1
FROM_OUTPUT_PORT: 0

Nothing obvious but why don’t you use the pipeline (port/connection) rather than data object, updates, deepCopy?

1 Like

I was converting VTK version from 5.0.3 to 9.0.1.
Therefore, I’d to change some custom vtk clas using vtkPolyDataAlgorithm.
In that process, I changed the pipeline.
I’m finding why converted source don’t render actors correctly, so I tried to change some code between pipeline and just data.

1: about RequestData - #7 by Hyunwoo_Kim
2: vtkImageData rendering issue

here is my issues, and If you have any solution, It would be so appreciated…

I think the volume data is wrong.
I wrote a dataset file.

It is incorrect data, isn’t it?

.vtkvol

vtk DataFile Version 5.1
vtk output
ASCII
DATASET STRUCTURED_POINTS
DIMENSIONS 128 128 256
SPACING 0.2 0.2 0.1
ORIGIN -12.8 -12.8 0
POINT_DATA 4194304
SCALARS ImageScalars short
LOOKUP_TABLE default
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851
-12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851 -12851

vtkVolumeData->SetOrigin(sx, sy, sz);
vtkVolumeData->SetSpacing(dx, dy, fPosZ);
vtkVolumeData->AllocateScalars(VTK_SHORT, 1);
vtkVolumeData->SetDimensions(cxImageData,cyImageData,czImageData);
vtkVolumeData->GlobalReleaseDataFlagOn();

scalars->SetArray(m_pFullVolume->GetData(), cxImageData*cyImageData*czImageData, 0);

vtkVolumeData->GetPointData()->SetScalars(scalars);

is this style not supported anymore in the VTK 9 version?

this is a piece of additional information!

Changed Data

vtk DataFile Version 5.1
vtk output
ASCII
DATASET STRUCTURED_POINTS
DIMENSIONS 128 128 256
SPACING 0.2 0.2 0.1
ORIGIN -12.8 -12.8 0
POINT_DATA 4194304
SCALARS ImageScalars short
LOOKUP_TABLE default
1000 999 999 999 999 999 999 999 999
999 999 999 999 999 999 999 999 999
999 999 999 999 999 999 999 999 999
999 999 999 999 999 999 999 999 999
999 999 999 999 999 999 999 999 999
999 999 999 999 999 999 999 999 999
999 999 999 999 999 999 999 999 999
999 999 999 999 999 999 999 999 999
999 999 999 999 999 999 999 999 999
999 999 999 999 999 999 999 999 999
999 999 999 999 999 999 999 999 999
999 999 999 999 999 999 999 999 999
999 999 999 999 999 999 999 999 999
999 999 999 999 999 999 999 999 999
999 1000 998 998 998 998 998 998 998
998 998 998 998 998 998 998 998 998
998 998 998 998 998 998 998 998 998
998 998 998 998 998 998 998 998 998
998 998 998 998 998 998 998 998 998
998 998 998 998 998 998 998 998 998
998 998 998 998 998 998 998 998 998
998 998 998 998 998 998 998 998 998
998 998 998 998 998 998 998 998 998
998 998 998 998 998 998 998 998 998
998 998 998 998 998 998 998 998 998
998 998 998 998 998 998 998 998 998
998 998 998 998 998 998 998 998 998

Read DataSet & check max index

vtkDataSetReader* m_VolumeReader = vtkDataSetReader::New();
m_VolumeReader->SetFileName("D:\\Data\\.vtkvol");
m_VolumeReader->ReadAllScalarsOn();
m_VolumeReader->Update();

vtkDataSet* dataset = m_VolumeReader->GetOutput();
double num = dataset->GetNumberOfPoints();
vtkPointData* pointdata = dataset->GetPointData();
vtkDataArray* array_ = pointdata->GetScalars();

int numpts = array_->GetMaxId();

That seems correct with VTK 9.

1 Like