[vtkusers] 答复: vtkusers Digest, Vol 3, Issue 89
杨衡
yhq at sjtu.edu.cn
Thu Jul 29 08:40:47 EDT 2004
-----邮件原件-----
发件人: vtkusers-bounces at vtk.org [mailto:vtkusers-bounces at vtk.org] 代表
vtkusers-request at vtk.org
发送时间: 2004年7月29日 16:50
收件人: vtkusers at vtk.org
主题: vtkusers Digest, Vol 3, Issue 89
Send vtkusers mailing list submissions to
vtkusers at vtk.org
To subscribe or unsubscribe via the World Wide Web, visit
http://www.vtk.org/mailman/listinfo/vtkusers
or, via email, send a message with subject or body 'help' to
vtkusers-request at vtk.org
You can reach the person managing the list at
vtkusers-owner at vtk.org
When replying, please edit your Subject line so it is more specific
than "Re: Contents of vtkusers digest..."
Today's Topics:
1. Re: vtkInteractorStyle and animation (Akshay Sthapit)
2. Re: Re: MarchingCubes (Sean McInerney)
3. Take a look here for VTK! (Toth Istvan)
4. Re: Take a look here for VTK! (Sean McInerney)
5. Re: vtkPolyDataMapper2D + vtkCoordinate (Laurent Mundeleer)
6. problem with surface (Germain PRUNIER)
----------------------------------------------------------------------
Message: 1
Date: Wed, 28 Jul 2004 19:02:17 -0700 (PDT)
From: Akshay Sthapit <sthapit at yahoo.com>
Subject: Re: [vtkusers] vtkInteractorStyle and animation
To: seanm at nmr.mgh.harvard.edu
Cc: vtkusers at vtk.org
Message-ID: <20040729020217.76877.qmail at web60003.mail.yahoo.com>
Content-Type: text/plain; charset=us-ascii
Genius! That works :) Thanks Sean.
Akshay
--- Sean McInerney <seanm at nmr.mgh.harvard.edu> wrote:
> Akshay,
>
> It probably segfaults since the Style is not yet associated with
> an
> Interactor. Try rearranging your code like this:
>
> vtkInteractorStyle *style = vtkInteractorStyle::New();
> vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> iren->SetRenderWindow(renWin);
> iren->SetInteractorStyle(style);
> style->StartAnimate();
> iren->Start();
>
> Does this work?
>
> -Sean
>
> Akshay Sthapit wrote:
> > Can someone please tell me why the following code causes a crash?
> I'm
> > trying to create a simple animation
> >
> > ---------------------------------------------------------
> > vtkInteractorStyle *style = vtkInteractorStyle::New();
> > style->StartAnimate();
> >
> > vtkRenderWindowInteractor *iren = vtkRenderWindowInteractor::New();
> > iren->SetRenderWindow(renWin);
> > iren->SetInteractorStyle(style);
> > iren->Start();
> > ----------------------------------------------------------
> >
> > Thanks!
> > Akshay
> >
>
__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com
------------------------------
Message: 2
Date: Wed, 28 Jul 2004 22:09:53 -0400
From: Sean McInerney <seanm at nmr.mgh.harvard.edu>
Subject: Re: [vtkusers] Re: MarchingCubes
To: Jonathan Bailleul <Jonathan.Bailleul at greyc.ismra.fr>
Cc: vtkusers at public.kitware.com, baghdadi at sickkids.ca, Goodwin Lawlor
<goodwin.lawlor at ucd.ie>
Message-ID: <41085C71.8090500 at nmr.mgh.harvard.edu>
Content-Type: text/plain; charset="us-ascii"
Jonathan,
I'll check out your code.
In the meantime, I had a quicker and dirtier idea that I decided to
try out using vtkSurfaceReconstructionFilter and vtkImageThreshold to
produce an binary ImageData volume from a PolyData surface. It's rough
but interesting. The output is a volume rendering.
-Sean
Jonathan Bailleul wrote:
> Sean McInerney wrote:
>
>>Jonathan,
>>
>> That's a cool idea!
>>
>> Foreach desired slice plane for the ImageData volume that you will
>>ultimately produce, do something like this:
>>
>>1.) Use vtkClipPolyData to get the 2D contour of the given slice.
>>
>>2.) Use vtkPolyDataToImageStencil to produce ImageStencilData
>>
>>3.) Use vtkImageStencil to produce the ImageData
>> (need to do a little filtering to produce the desired binary image).
>>
>>4.) Use vtkAppendFilter to fuse the 2D binary images into a 3D volume.
>> Hopefully, the ImageStencilData retains a 3D extent.
>>
>>5.) Voila! Binary volume from PolyData ... maybe.
>>
>>-Sean
>
>
>
> Thanks for the help!
>
> If someone is inspirated to actually implement this (or has already
> completed this), please notify me!
> Anyway, here is a stupid but working solution. Code is sometimes ugly,
> but it works (only voxels at border of each slice are "colored"). Output
> is AIR analyse format, recognized on ITK and usable on VTK if you know
> the parameters and consider the .img file as the raw volume.
>
> All personal includes in:
> http://www.greyc.ismra.fr/~bailleul/Ressources/summary.html (see gpl
> code section)
> for those who really want to end up testing the program.
>
> I really should have been more investigating on VTK abilities before
> doing all this by hand, but I was VTK newbie when I coded this and had
> most of the necessary code at hand on my personal libraries.
>
>
-------------- next part --------------
// VTK Common
#include "vtkPolyData.h"
#include "vtkImageData.h"
#include "vtkPiecewiseFunction.h"
#include "vtkColorTransferFunction.h"
// VTK Imaging
#include "vtkSurfaceReconstructionFilter.h"
#include "vtkImageThreshold.h"
#include "vtkImageToStructuredPoints.h"
// VTK Graphics
#include "vtkOutlineFilter.h"
// VTK IO
#include "vtkBYUReader.h"
// VTK Rendering
#include "vtkPolyDataMapper.h"
#include "vtkProperty.h"
#include "vtkActor.h"
#include "vtkVolumeRayCastCompositeFunction.h"
#include "vtkVolumeRayCastMapper.h"
#include "vtkVolumeProperty.h"
#include "vtkVolume.h"
#include "vtkRenderer.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
int
main (int argc, char* argv[])
{
const char* dataRoot = getenv("VTK_DATA_ROOT");
if (dataRoot == NULL)
{
cerr << "Must set VTK_DATA_ROOT!" << endl;
return 0;
}
const char* subdir = "/Data/";
const char* file1 = "Viewpoint/cow.g";
char* path1 = new char [strlen(dataRoot)+strlen(subdir)+strlen(file1)+1];
strcpy(path1, dataRoot);
strcat(path1, subdir);
strcat(path1, file1);
double length;
double range[2];
double bounds[6];
int extent[6];
vtkRenderer* ren1 = vtkRenderer::New();
vtkRenderWindow* renWin = vtkRenderWindow::New();
{
renWin->AddRenderer(ren1);
renWin->SetSize(300,300);
ren1->Delete();
}
vtkRenderWindowInteractor* iren = vtkRenderWindowInteractor::New();
{
iren->SetRenderWindow(renWin);
renWin->Delete();
}
vtkImageData* imageData = vtkImageData::New();
{
vtkSurfaceReconstructionFilter* surfaceRecon =
vtkSurfaceReconstructionFilter::New();
{
vtkBYUReader* reader = vtkBYUReader::New();
{
reader->SetGeometryFileName(path1);
reader->Update();
}
surfaceRecon->SetInput(reader->GetOutput());
surfaceRecon->SetNeighborhoodSize(10);
surfaceRecon->SetSampleSpacing(reader->GetOutput()->GetLength()/100.0);
surfaceRecon->Update();
reader->Delete();
}
imageData->DeepCopy(surfaceRecon->GetOutput());
surfaceRecon->Delete();
}
vtkActor* outlineActor = vtkActor::New();
{
vtkPolyDataMapper* outlineMapper = vtkPolyDataMapper::New();
{
vtkOutlineFilter* outlineFilter = vtkOutlineFilter::New();
{
outlineFilter->SetInput(imageData);
}
outlineMapper->SetInput(outlineFilter->GetOutput());
outlineFilter->Delete();
}
outlineActor->SetMapper(outlineMapper);
outlineMapper->Delete();
}
ren1->AddProp(outlineActor);
outlineActor->Delete();
renWin->Render();
vtkVolume* volume = vtkVolume::New();
{
vtkVolumeRayCastMapper* volumeMapper = vtkVolumeRayCastMapper::New();
{
vtkVolumeRayCastCompositeFunction* compositeFunction =
vtkVolumeRayCastCompositeFunction::New();
vtkImageThreshold* imageThreshold = vtkImageThreshold::New();
{
imageThreshold->SetInput(imageData);
imageThreshold->ReplaceInOn();
imageThreshold->ReplaceOutOn();
imageThreshold->SetInValue(1.0);
imageThreshold->SetOutValue(0.0);
imageThreshold->ThresholdByLower(0.0);
imageThreshold->SetOutputScalarTypeToUnsignedChar();
}
volumeMapper->SetVolumeRayCastFunction(compositeFunction);
volumeMapper->SetInput(imageThreshold->GetOutput());
imageThreshold->Delete();
}
vtkVolumeProperty* volumeProperty = vtkVolumeProperty::New();
{
// Create transfer mapping scalar value to opacity
vtkPiecewiseFunction* opacityTF = vtkPiecewiseFunction::New();
{
opacityTF->AddPoint(0.0, 0.167);
opacityTF->AddPoint(1.0, 0.667);
opacityTF->ClampingOn();
}
// Create transfer mapping scalar value to color
vtkColorTransferFunction* colorTF = vtkColorTransferFunction::New();
{
colorTF->AddHSVPoint(0.0, 0.00, 1.0, 1.0);
colorTF->AddHSVPoint(1.0, 0.50, 1.0, 1.0);
}
volumeProperty->SetColor(colorTF);
volumeProperty->SetScalarOpacity(opacityTF);
volumeProperty->SetInterpolationTypeToLinear();
opacityTF->Delete();
colorTF->Delete();
}
volume->SetMapper(volumeMapper);
volume->SetProperty(volumeProperty);
volumeMapper->Delete();
volumeProperty->Delete();
}
ren1->AddProp(volume);
volume->Delete();
renWin->Render();
iren->Start();
iren->Delete();
imageData->Delete();
delete [] path1;
return 0;
}
------------------------------
Message: 3
Date: Thu, 29 Jul 2004 09:31:57 -0700
From: "Toth Istvan" <istvan at dmmd.net>
Subject: [vtkusers] Take a look here for VTK!
To: <vtkusers at vtk.org>
Message-ID: <005b01c47589$976a9350$085a1e0a at Istvan>
Content-Type: text/plain; charset="iso-8859-1"
Hi
I have a problem with a VTK file.
I don't know if it is a valid VTK file format..
I try to open with ParaView but I can't view it..
Take a look for this file , from: http://www.geocities.com/istynet/vtk.zip
If you can help me please reply!
Istvan
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://public.kitware.com/pipermail/vtkusers/attachments/20040729/ff861b22/a
ttachment.htm
------------------------------
Message: 4
Date: Thu, 29 Jul 2004 03:12:53 -0400
From: Sean McInerney <seanm at nmr.mgh.harvard.edu>
Subject: Re: [vtkusers] Take a look here for VTK!
To: vtkusers at vtk.org
Message-ID: <4108A375.2040707 at nmr.mgh.harvard.edu>
Content-Type: text/plain; charset=us-ascii; format=flowed
Is it just me, or could a request to the list possibly look more
suspect? This does not seem to be a valid VTK file! I'm wary of anything
stinking of an invalid request and zipped. If I am just being paranoid,
please accept my apologies.
-Sean
Toth Istvan wrote:
> Hi
> I have a problem with a VTK file.
> I don't know if it is a valid VTK file format..
> I try to open with ParaView but I can't view it..
> Take a look for this file , from: http://www.geocities.com/istynet/vtk.zip
> If you can help me please reply!
> Istvan
>
------------------------------
Message: 5
Date: Thu, 29 Jul 2004 09:51:37 +0200
From: Laurent Mundeleer <lmundele at ulb.ac.be>
Subject: [vtkusers] Re: vtkPolyDataMapper2D + vtkCoordinate
To: vtk <vtkusers at vtk.org>
Message-ID: <4108AC89.4090207 at ulb.ac.be>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Hello all,
I was thinking, maybe should I use SetClippingPlanes() instead of
vtkCoordinate()?
There must be a simple way to render polyData in 2D easely...
Thanks,
Best Regards,
Laurent
Laurent Mundeleer wrote:
> Hello all,
> I've a 3D scene with several polyDatas, I visualize it in 3D.
> I'd like to have 2D views of it, so I use vtkPolyDataMapper2D.
> With default values, it's ok, I have one 2D view.
> But I'd like to have 3 differents 2D views of the same 3D scene, so
> the mapper2D has to take projections from differents points of view (3
> orthogonal planes for example).
> I don't know how to use vtkCoordinate to have this working...
>
> Thanks for any help,
> Regards,
>
> Laurent
>
--
********************************************
Laurent Mundeleer
Universiti Libre de Bruxelles (ULB)
Service des Systhmes Logiques et Numiriques (SLN) CP165/57
50, Av. F.Roosevelt
1050 Bruxelles
Belgium
tel : ++32.2.650.22.97
fax : ++32.2.650.22.98
e-mail : lmundele at ulb.ac.be
********************************************
------------------------------
Message: 6
Date: Thu, 29 Jul 2004 10:49:44 +0200
From: "Germain PRUNIER" <Germain.PRUNIER at cerealog.fr>
Subject: [vtkusers] problem with surface
To: <vtkusers at vtk.org>
Message-ID: <48005AA56235E547B719C751B2E05C9837A3DB at terra.cerealog.fr>
Content-Type: text/plain; charset="iso-8859-1"
Hi all,
I would like to display a surface from a cloud of points.
I tried vtkDelaunay3D and vtkSurfaceReconstructionFilter but for both
methods I get unpleasant results.
I attached some pictures that presents the cloud of points, and the result
with the 2 methods...
I think that some of you could help me. It seems not to be really difficult
but I don't know how to do that!
Please, where are my problems ??
Thank you!
Germain
<<cloud_points.jpg>> <<cloud_points2.jpg>> <<Delaunay3D.jpg>>
<<SurfaceReconstructionFilter.jpg>>
//with vtkDelaunay3D, I wrote:
vtkDelaunay3D *delpts = vtkDelaunay3D::New();
delpts->SetInput(data); //data: my
points
delpts->SetTolerance(0.01);
delpts->SetAlpha(0.0);
vtkDataSetMapper *cloudMapper2 = vtkDataSetMapper::New();
cloudMapper->SetInput(delpts->GetOutput());
.....
**********************************************************
//with vtkSurfaceReconstructionFilter:
vtkSurfaceReconstructionFilter *surf =
vtkSurfaceReconstructionFilter::New();
surf->SetInput(data);
vtkContourFilter *cf = vtkContourFilter::New();
cf->SetInput((vtkDataSet*)surf->GetOutput());
cf->SetValue(0,0.0);
vtkReverseSense *reverse = vtkReverseSense::New();
reverse->SetInput(cf->GetOutput());
reverse->ReverseCellsOn();
reverse->ReverseNormalsOn();
reverse->Update();
vtkPolyDataMapper *cloudMapper = vtkPolyDataMapper::New();
cloudMapper->SetInput(reverse->GetOutput());
...
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cloud_points.jpg
Type: image/jpeg
Size: 13070 bytes
Desc: cloud_points.jpg
Url :
http://public.kitware.com/pipermail/vtkusers/attachments/20040729/152849bb/c
loud_points.jpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cloud_points2.jpg
Type: image/jpeg
Size: 10386 bytes
Desc: cloud_points2.jpg
Url :
http://public.kitware.com/pipermail/vtkusers/attachments/20040729/152849bb/c
loud_points2.jpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Delaunay3D.jpg
Type: image/jpeg
Size: 22713 bytes
Desc: Delaunay3D.jpg
Url :
http://public.kitware.com/pipermail/vtkusers/attachments/20040729/152849bb/D
elaunay3D.jpg
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SurfaceReconstructionFilter.jpg
Type: image/jpeg
Size: 19865 bytes
Desc: SurfaceReconstructionFilter.jpg
Url :
http://public.kitware.com/pipermail/vtkusers/attachments/20040729/152849bb/S
urfaceReconstructionFilter.jpg
------------------------------
_______________________________________________
vtkusers mailing list
vtkusers at vtk.org
http://www.vtk.org/mailman/listinfo/vtkusers
End of vtkusers Digest, Vol 3, Issue 89
***************************************
More information about the vtkusers
mailing list