[vtkusers] Re: multimiresregistration thanks, vtk!
Christos Panagiotou
C.Panagiotou at cs.ucl.ac.uk
Mon Feb 23 02:22:11 EST 2004
luis
in case i forget something somewhere else, i ll just paste the whole source
(both readers dont work :( )
----------------------------------------------------------------------------------------
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkImageReader2.h"
#include "vtkPolyDataMapper.h"
#include "vtkActor.h"
#include "vtkOutlineFilter.h"
#include "vtkCamera.h"
#include "vtkProperty.h"
#include "vtkPolyDataNormals.h"
#include "vtkContourFilter.h"
#include "vtkMetaImageReader.h"
#include "vtkImageData.h"
#include "vtkDataSet.h"
#include "vtkPolyData.h"
int main (int argc, char **argv)
{
//const char *fname =
"/home/christos/PhD/Data/raw/Brain1Rot/Brain/brainweb1e1a10f20Rot10Tx15.raw";
const char *metafname =
"/home/christos/PhD/Data/raw/Brain1Rot/Brain/brainweb1e1a10f20Rot10Tx15.mha";
vtkRenderer *aRenderer = vtkRenderer::New();
vtkRenderWindow *renWin = vtkRenderWindow::New();
renWin->AddRenderer(aRenderer);
vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
iren->SetRenderWindow(renWin);
/*
vtkImageReader2 *v = vtkImageReader2::New();
v->SetDataExtent(0,180,0,216,0,180 );
v->SetDataByteOrderToLittleEndian();
v->SetDataScalarTypeToUnsignedChar();
v->SetFileName(fname);
v->SetFileDimensionality(3);
v->SetDataSpacing (1.0,1.0,1.0);
v->DebugOn();
v->Update();
*/
vtkMetaImageReader *meta = vtkMetaImageReader::New();
meta->SetFileName(metafname);
vtkContourFilter *skinExtractor = vtkContourFilter::New();
//skinExtractor->SetInput(v->GetOutput());
skinExtractor->SetInput(meta->GetOutput());
//skinExtractor->SetValue(0, 255);
skinExtractor->ComputeNormalsOff();
skinExtractor->ComputeGradientsOff();
skinExtractor->Update();
vtkPolyDataNormals *skinNormals = vtkPolyDataNormals::New();
skinNormals->SetInput(skinExtractor->GetOutput());
skinNormals->SetFeatureAngle(60.0);
skinNormals->Update();
vtkPolyDataMapper *skinMapper = vtkPolyDataMapper::New();
skinMapper->SetInput(skinNormals->GetOutput());
skinMapper->ScalarVisibilityOn();
skinMapper->SetScalarModeToUsePointFieldData();
skinMapper->DebugOn();
skinMapper->Update();
vtkActor *skin = vtkActor::New();
skin->SetMapper(skinMapper);
vtkOutlineFilter *outlineData = vtkOutlineFilter::New();
//outlineData->SetInput(v->GetOutput());
outlineData->SetInput(meta->GetOutput());
vtkPolyDataMapper *mapOutline = vtkPolyDataMapper::New();
mapOutline->SetInput(outlineData->GetOutput());
vtkActor *outline = vtkActor::New();
outline->SetMapper(mapOutline);
outline->GetProperty()->SetColor(0,0,0);
aRenderer->AddActor(outline);
aRenderer->AddActor(skin);
aRenderer->ResetCamera ();
aRenderer->SetBackground(1,1,1);
renWin->SetSize(640, 480);
aRenderer->ResetCameraClippingRange();
iren->Initialize();
iren->Start();
//v->Delete();
meta->Delete();
skinExtractor->Delete();
skinNormals->Delete();
skinMapper->Delete();
skin->Delete();
outlineData->Delete();
mapOutline->Delete();
outline->Delete();
iren->Delete();
renWin->Delete();
aRenderer->Delete();
}
--------------------------------------------------------
Luis Ibanez wrote:
>
> Hi Christos,
>
> Is there any particular reason why you are forcing the
> casting the output of the vtkMetaImageReader ?
>
>> vtkContourFilter *skinExtractor = vtkContourFilter::New();
>> skinExtractor->SetInput((vtkDataSet *)meta->GetOutput());
>
>
>
> You shouldn't need to cast this output.
>
>
> Please let us know,
>
>
> Thanks,
>
>
> Luis
>
More information about the vtkusers
mailing list