[vtkusers] Problem in displaying a dual colored volume

Sentil Balaji profbalse at yahoo.co.in
Wed Feb 11 01:28:19 EST 2004


Hey,

    I used a structured dataset to render an object.I
used two colors to indicate two regions of the
volume.The rendering was perfect but when I interact
with the window the volume  coloring  disperses{ie.the
regions merge )...How to avoid this problem?I used
Setcolor() for coloring the required regions of the
volume.Is there an other way to color regions of
volume [a structured data set].The
code is below:
---------------------------------
#include <VTK4.4/vtkRenderWindow.h>
#include <VTK4.4/vtkRenderWindowInteractor.h>
#include <VTK4.4/vtkRenderer.h>
#include <VTK4.4/vtkPolyData.h>
#include <VTK4.4/vtkDataSetMapper.h>
#include <VTK4.4/vtkDataSetTriangleFilter.h>
#include <VTK4.4/vtkStructuredGridReader.h>
#include <VTk4.4/vtkStructuredGrid.h>
#include <VTK4.4/vtkUnstructuredGrid.h>
#include <VTK4.4/vtkActor.h>
#include <VTK4.4/vtkOutlineFilter.h>
#include <VTK4.4/vtkDelaunay3D.h>
#include <VTK4.4/vtkProperty.h>
#include <VTk4.4/vtkPlane.h>
#include <VTK4.4/vtkClipDataSet.h>
#include <stdio.h>
void main()
{

    char A[50],B[50];
	printf("\n\nENTER THE VTK PHANTOM  DATA FILE:");
	gets(A);
	printf("\n\nENTER THE VTK BONE  DATA FILE:");
	gets(B);
	//------------INITIALIZING---------------------
	vtkVolume *vol=vtkVolume::New();
	vtkStructuredGridReader
*reader1=vtkStructuredGridReader::New();
	vtkStructuredGridReader
*reader2=vtkStructuredGridReader::New();
	vtkDelaunay3D *d31=vtkDelaunay3D::New();
	vtkDelaunay3D *d32=vtkDelaunay3D::New();
	vtkDataSetTriangleFilter
*dtf=vtkDataSetTriangleFilter::New();
    vtkOutlineFilter *cf=vtkOutlineFilter::New();
	vtkDataSetMapper *mapper1=vtkDataSetMapper::New();
	vtkDataSetMapper *mapper2=vtkDataSetMapper::New();
	vtkDataSetMapper *mapper3=vtkDataSetMapper::New();
	vtkDataSetMapper *mapper4=vtkDataSetMapper::New();
  	vtkActor *actor1=vtkActor::New();
	vtkActor *actor2=vtkActor::New();
  	vtkActor *actor3=vtkActor::New();
	vtkActor *actor4=vtkActor::New();
	vtkRenderer *ren=vtkRenderer::New();
	vtkRenderer *ren1=vtkRenderer::New();
	vtkRenderWindow *win=vtkRenderWindow::New();
	vtkRenderWindowInteractor
*iren=vtkRenderWindowInteractor::New();
	vtkClipDataSet *cd1=vtkClipDataSet::New();
	vtkClipDataSet *cd2=vtkClipDataSet::New();
	vtkPlane *plane=vtkPlane::New();
	//--------------RENDERING----------------
    reader1->SetFileName(A);
	reader2->SetFileName(B);
	d31->SetInput(reader1->GetOutput());
	d32->SetInput(reader2->GetOutput());
	mapper1->SetInput(d31->GetOutput());
	mapper2->SetInput(d32->GetOutput());
	actor1->SetMapper(mapper1);
	actor1->GetProperty()->SetColor(1.0,1.0,0.0);
	actor2->SetMapper(mapper2);
    actor2->GetProperty()->SetColor(1.0,0.0,1.0);
	ren->AddActor(actor1);
	ren->AddActor(actor2);
	ren->SetViewport(0.0,0.0,0.5,1.0);
	plane->SetOrigin(0.2,0,0);
	plane->SetNormal(-1,-1,0);
	cd1->SetInput(d31->GetOutput());
	cd1->SetClipFunction(plane);
	cd2->SetInput(d32->GetOutput());
	cd2->SetClipFunction(plane);
	mapper3->SetInput(cd1->GetOutput());
	mapper4->SetInput(cd2->GetOutput());
	actor3->SetMapper(mapper3);
	actor3->GetProperty()->SetColor(1.0,1.0,0.0);
	actor4->SetMapper(mapper4);
    actor4->GetProperty()->SetColor(1.0,0.0,1.0);
	ren1->AddActor(actor3);
	ren1->AddActor(actor4);
	ren1->SetViewport(0.5, 0.0, 1.0, 1.0);
	win->AddRenderer(ren1);
	win->AddRenderer(ren);
	iren->SetRenderWindow(win);
	iren->Initialize();
	iren->Start();
}

-----------------------------------------------
Sorry, for making the question complicated...Thanks

Cheers

BeeJay



________________________________________________________________________
Yahoo! India Education Special: Study in the UK now.
Go to http://in.specials.yahoo.com/index1.html



More information about the vtkusers mailing list