[vtkusers] Using vtkCutter to produce lines from a surface
glennuggah
tobias at magnander.se
Thu Mar 7 07:13:08 EST 2013
Hi!
I'm using a vtkCutter to generate lines from a vtkPolyData surface. My
vtkPolydataSurface contains different colored regions. Is it possible to
grab the color information from the vtkpolydata surface to the output of the
vtkCutter? Cutting through my beautifully colored vtkPolyData regions
results in white lines.
Here is my code:
vtkContourFilter* cf=vtkContourFilter::New();
vtkPolyDataConnectivityFilter* pcf=vtkPolyDataConnectivityFilter::New();
cf->SetInput(imageData);
cf->SetValue(0,threshold);
cf->ComputeScalarsOn();
cf->Update();
pcf->SetExtractionModeToAllRegions();
pcf->ColorRegionsOn();
pcf->SetInput(cf->GetOutput());
pcf->Update();
int numberOfRegions=pcf->GetNumberOfExtractedRegions();
vtkPlane* plane=vtkPlane::New();
plane->SetOrigin(Origin);
plane->SetNormal(Normal);
vtkCutter* cutter=vtkCutter::New();
cutter->SetInput(pcf->GetOutput());
cutter->SetCutFunction((vtkImplicitFunction*)plane);
cutter->GenerateCutScalarsOff();
cutter->Update();
vtkPolyDataMapper* mapper0=vtkPolyDataMapper::New();
mapper0->SetInput(cutter->GetOutput());
mapper0->SetScalarVisibility(1);
mapper0->SetScalarRange(0,numberOfRegions-1);
vtkActor* actor0=vtkActor::New();
actor0->SetMapper(mapper0);
actor0->GetProperty()->SetLighting(false);
ren0->AddActor(actor0);
vtkPolyDataMapper* mapper1=vtkPolyDataMapper::New();
vtkActor* actor1=vtkActor::New();
mapper1->SetInput(pcf->GetOutput());
mapper1->ScalarVisibilityOn();
mapper1->SetScalarRange(0,numberOfRegions-1);
actor1->SetMapper(mapper1);
ren1->AddActor(actor1);
--
View this message in context: http://vtk.1045678.n5.nabble.com/Using-vtkCutter-to-produce-lines-from-a-surface-tp5719150.html
Sent from the VTK - Users mailing list archive at Nabble.com.
More information about the vtkusers
mailing list