[vtkusers] color mapping isosurface: Normals to scalars: vtkVectorNorm vtkContourFilter

T R compubi3d at hotmail.com
Fri Mar 19 23:12:38 EST 2004


dear vtk gurus,

I am trying to  map gradients as it was shaown in HeadBone.tcl in VTK 3.2
That example used  vtkMarchingCubes  and 
ComputeGradientsOn()/ComputeNormalsOn
and further vtkVectorNorm to create a Scalar map

in VTK 4.2  one has to use vtkContourFilter, also  vtkVectorNorm doesn't 
work ("No vector norm to compute"), unless I   set  Vectors pointer to 
Normals
point_data_prt->SetVectors(point_data_ptr->GetNormals());
Then  vtkVectorNorm doesn't report any problems,  but it produce  Scalar 
data  of one value.

How do I color map gradients on the reconstructed surface?
why doesn't  headBone.tcl/ vtkVectorNorm work in VTK 42 the same way as it 
did in VTK 3.2?
Please help,

Art


vtkContourFilter  *iso = vtkContourFilter::New();
    iso->SetInput((vtkDataSet *) v16->GetOutput());
    iso->SetValue(0, 1150);
    iso->ComputeGradientsOn();
	iso->Update();

  vtkPolyDataNormals *normals = vtkPolyDataNormals::New();
    normals->SetInput(iso->GetOutput());
    normals->SetFeatureAngle(60.0);
   normals->ComputeCellNormalsOn();
   normals->ComputePointNormalsOn();
   normals->Update();

//  using normals as vectors ??
  vtkPointData *pd=(normals->GetOutput())->GetPointData();
  vtkCellData *cd= (normals->GetOutput())->GetCellData();
	cd->SetVectors(cd->GetNormals());
	pd->SetVectors(pd->GetNormals());

vtkVectorNorm *gradient = vtkVectorNorm::New();
        gradient->SetInput(normals->GetOutput());
        gradient->SetAttributeModeToUseCellData();
		//gradient->NormalizeOn();

  vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New();
    skinMapper->SetInput(gradient->GetPolyDataOutput());
    skinMapper->ScalarVisibilityOn();
    skinMapper->SetScalarRange (1, 1150); //((gradient-> 
GetOutput())->GetScalarRange());
skinMapper->SetColorModeToMapScalars();
float* arr = (gradient-> GetOutput())->GetScalarRange();

cout << arr[0] << " " << arr[1] << endl;

//	skinMapper -> SetScalarModeToUsePointData();


  vtkActor *skin = vtkActor::New();
    skin->SetMapper(skinMapper);

_________________________________________________________________
Find a broadband plan that fits. Great local deals on high-speed Internet 
access. http://click.atdmt.com/AVE/go/onm00200360ave/direct/01/




More information about the vtkusers mailing list