[vtkusers] vtkUnstructuredGridVolumeRayCastMapper (05B22CB8): Can't use the ray cast mapper without scalars!
Ali Habib
ali.mahmoud.habib at gmail.com
Tue Oct 6 17:56:21 EDT 2009
I tried your suggestion but it gave the same error
int shade = 0, compos = 0, interp = 0;
// renderer
vtkRenderer ^ren1 = gcnew vtkRenderer();
ren1->SetBackground(1.0, 1.0, 1.0);
// render window
// vtkRenderWindow renWin = new vtkRenderWindow();
// renWin.AddRenderer(ren1);
// renWin.SetSize(800, 600);
this->vtkFormsWindowControl1->GetRenderWindow()->AddRenderer(ren1);
vtkUnstructuredGrid ^grid = gcnew vtkUnstructuredGrid();
// interactor
vtkRenderWindowInteractor ^iren1 = gcnew vtkRenderWindowInteractor();
iren1->SetRenderWindow(this->vtkFormsWindowControl1->GetRenderWindow());
// set up the input file for unstructured grid reader
//1.Create a volume data
// create sphere geometry
vtkSphereSource ^sphere = gcnew vtkSphereSource();
sphere->SetRadius(1.0);
sphere->SetThetaResolution(18);
sphere->SetPhiResolution(18);
// grid.SetCells(new vtkTypeUInt16Array(),
sphere.GetOutput().GetCellData());
//2.Apply the tetrahedral mish
// vtkPolyData vp = new vtkPolyData();
// sphere.Update();
// grid.DeepCopy(sphere.GetOutputDataObject());
vtkDelaunay3D ^unstructuredReader = gcnew vtkDelaunay3D();
// this.vtkFormsWindowControl1.GetRenderWindow().get
// set up opacity transfer function
vtkPiecewiseFunction ^opacityTransferFunction = gcnewvtkPiecewiseFunction();
opacityTransferFunction->AddPoint(0, 0.02);
opacityTransferFunction->AddPoint(4095.0, 1.0);
// set up color transfer function
vtkColorTransferFunction ^colorTransferFunction =
gcnewvtkColorTransferFunction();
colorTransferFunction->AddRGBPoint(0.0, 0.1, 0.1, 0.1);
colorTransferFunction->AddRGBPoint(4095.0, 1.0, 0.0, 1.0);
// set up volume property
vtkVolumeProperty ^volumeProperty = gcnew vtkVolumeProperty();
volumeProperty->SetColor(colorTransferFunction);
volumeProperty->SetScalarOpacity(opacityTransferFunction);
volumeProperty->SetInterpolationType(interp);
volumeProperty->SetShade(shade);
// Add scaler value
vtkDoubleArray ^arr = gcnew vtkDoubleArray();
arr->SetNumberOfTuples(unstructuredReader->GetOutput()->GetNumberOfPoints());
arr->FillComponent(0, 1.0); // e.g. double value = 1.0;
arr->SetName("myarray");
// MessageBox.Show(arr.GetData(
//unstructuredReader.GetOutput().GetPointData().SetScalars();
unstructuredReader->Update();
grid->DeepCopy(safe_cast<vtkDataObject^>(unstructuredReader->GetOutput()));
grid->GetPointData()->AddArray(arr);
grid->GetPointData()->SetScalars(arr);
// unstructuredReader.GetOutput().GetPointData().AddArray();
// unstructuredReader.GetOutput().GetPointData().
// composite function for strucured grid renderer
vtkVolumeRayCastCompositeFunction ^compositeFunction =
gcnewvtkVolumeRayCastCompositeFunction();
compositeFunction->SetCompositeMethod(compos);
//unstructuredGridRendering
vtkUnstructuredGridVolumeRayCastMapper ^volumeUnstructedMapper =
gcnewvtkUnstructuredGridVolumeRayCastMapper();
//vtkVolumeRayCastMapper volumeUnstructedMapper = new
vtk.vtkVolumeRayCastMapper();
//volumeUnstructedMapper.set (compositeFunction);
volumeUnstructedMapper->SetInput(grid);
//volumeUnstructedMapper.SetScalarModeToUseCellData();
vtkVolume ^volume = gcnew vtkVolume();
volume->SetMapper(volumeUnstructedMapper);
volume->SetProperty(volumeProperty);
// add volume to renderer
ren1->AddVolume(volume);
this->vtkFormsWindowControl1->GetRenderWindow()->Render();
iren1->Start();
delete ren1;
this->vtkFormsWindowControl1->GetRenderWindow()->Dispose();
delete iren1;
delete opacityTransferFunction;
delete colorTransferFunction;
delete volumeProperty;
delete compositeFunction;
// unstructured grid case
delete volumeUnstructedMapper;
delete unstructuredReader;
delete volume;
delete grid;
On Mon, Oct 5, 2009 at 4:01 PM, Kevin H. Hobbs <hobbsk at ohiou.edu> wrote:
> On Tue, 2009-09-29 at 21:47 +0200, Ali Habib wrote:
> > I wrote a code to make tetrahedral mesh on sphere , but it no give
> > result except :
> >
> > ERROR: In m:\dev\cur\vtkdotnet\branch\50\VolumeRendering
> > \vtkUnstructuredGridVolumeRayCastMapper.cxx, line 274
> > vtkUnstructuredGridVolumeRayCastMapper (05B22CB8): Can't use the ray
> > cast mapper without scalars!
> >
> >
>
>
> You are trying to add a scalar array to the output of the vtkDelaunay3D
> filter.
>
> You cannot modify the output of a filter without disconnecting the
> output from the pipeline.
>
> I've never understood how to disconnect the output of a filter from the
> filter so I always just do :
>
> vtkUnstructuredGrid * my_grid = vtkUnstructuredGrid::New();
> filter->Update();
> my_grid->DeepCopy( filter->GetOutput() );
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.vtk.org/pipermail/vtkusers/attachments/20091006/a76d6208/attachment.htm>
More information about the vtkusers
mailing list