[Insight-users] questions about generate and display sparse point cloud

Shaohua Fan sfan53704 at yahoo . com
Thu, 2 Oct 2003 10:29:14 -0700 (PDT)


--0-1225210933-1065115754=:61169
Content-Type: text/plain; charset=us-ascii
Content-Id: 
Content-Disposition: inline

Hello,

I am playing with some samples in ITK, and trying to
generate a set of sparse points and display it. I got
it run somehow, but have two questions:

1. When I displayed the 3D images in raw format with
VTK, it was automatically display with mesh instead of
just points. Can I turn the mesh display off? Or
should I output those points into a different format?

2. In the code(attached, line 199), if I initialize
the whole 3D volume with value -1.0, the generated
semi-sphere would show up. However, when I initialize
it with value 0, the whole image is black. Why it
makes difference?

Anyone could help and have a quick look and point out
the problem? Honestly, I am not sure whether I am
generating/outputing the sparse points in a good way.
It would be appreciated if someone point me to some
sample codes or how to do this.

Thanks a lot,

Shaohua

__________________________________
Do you Yahoo!?
The New Yahoo! Shopping - with improved product search
http://shopping . yahoo . com
--0-1225210933-1065115754=:61169
Content-Type: application/octet-stream; name="sparsePoints.cxx"
Content-Transfer-Encoding: base64
Content-Description: sparsePoints.cxx
Content-Disposition: attachment; filename="sparsePoints.cxx"

Lyo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09
PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09DQoNCiAgUHJvZ3JhbTog
ICBJbnNpZ2h0IFNlZ21lbnRhdGlvbiAmIFJlZ2lzdHJhdGlvbiBUb29sa2l0
DQogIE1vZHVsZTogICAgJFJDU2ZpbGU6IFJHQlBvaW50U2V0LmN4eCx2ICQN
CiAgTGFuZ3VhZ2U6ICBDKysNCiAgRGF0ZTogICAgICAkRGF0ZTogMjAwMy8w
MS8xOSAwNDoyOTo0MyAkDQogIFZlcnNpb246ICAgJFJldmlzaW9uOiAxLjQg
JA0KDQogIENvcHlyaWdodCAoYykgMjAwMiBJbnNpZ2h0IENvbnNvcnRpdW0u
IEFsbCByaWdodHMgcmVzZXJ2ZWQuDQogIFNlZSBJVEtDb3B5cmlnaHQudHh0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