[vtkusers] vtkQuadricDecimation and colors
Bradley Lowekamp
blowekamp at mail.nih.gov
Thu Feb 18 16:45:53 EST 2010
Hello,
If I recall correctly you must enable the usage of the AttributeErrorMetric. Then configure what attributes you wish to include, ie scalars, colors, normals etc. Then there is also the relative weights of the attributes, which would need to be set up with trial and error to obtain the best results. This last parameter determines how much of a trade off geometric error is to color error. ( I believe that this complication is why it is disabled by default ).
Good Luck.
Brad
On Feb 17, 2010, at 4:48 AM, Olli wrote:
> Hi,
>
> I'm rendering elevation data. Originally data is a structured grid and very dense. But looks fine. When I try to reduce number of polygons using vtkQuadricDecimation I loose all colors and get a gray scale image. I wonder why? What does decimation do to the data so that mapper cannot color it any more?
>
> Btw. Using vtkDecimatePro solves the coloring problem. But the question remains: why colors disappear when I use vtkQuadricDecimation? Why?
>
> The pipeline I use is below. (No smart pointers, I know. It's a sample and easier to read, when not using smart pointers). It works just fine if I skip quadric decimation.
>
> Thanks,
>
> Olli
>
>
> vtkImageImport* reader = vtkImageImport::New();
> // import settings
> // ...
> reader->Update();
>
> vtkDataSetSurfaceFilter* filter = vtkDataSetSurfaceFilter::New();
> filter->SetInputConnection(reader->GetOutputPort());
> reader->Delete();
> filter->ReleaseDataFlagOn();
> filter->Update();
>
> vtkWarpScalar* warp = vtkWarpScalar::New();
> warp->SetInputConnection(filter->GetOutputPort());
> filter->Delete();
> warp->SetScaleFactor(3);
> warp->Update();
>
> vtkQuadricClustering* cluster = vtkQuadricClustering::New();
> cluster->SetInputConnection(warp->GetOutputPort());
> warp->Delete();
> cluster->AutoAdjustNumberOfDivisionsOff();
> cluster->SetNumberOfDivisions(240, 240, 10);
> cluster->PreventDuplicateCellsOn();
> cluster->UseInputPointsOn();
> cluster->Update();
>
> vtkQuadricDecimation *dec=vtkQuadricDecimation ::New();
> dec->SetInputConnection(cluster->GetOutputPort());
> cluster->Delete();
> dec->SetTargetReduction(.80);
> dec->Update();
>
> // color map for terrain
> vtkColorTransferFunction* lut = vtkColorTransferFunction::New();
> lut->AddHSVSegment(1, 0.3, 0.7, 0.7, 2000, 0.1, 0.7, 0.7); // terrain
> lut->AddHSVPoint(0, 0.667, 0.7, 1); // sea level
>
> vtkPolyDataMapper* mapper = vtkPolyDataMapper::New();
> mapper->SetInputConnection(dec->GetOutputPort());
> dec->Delete();
> mapper->ScalarVisibilityOn();
> mapper->SetScalarRange(0, 1000);
> mapper->SetLookupTable(lut);
> lut->Delete();
> mapper->Update();
> ...
> <ATT00001..txt>
More information about the vtkusers
mailing list