Author Topic: Create custom volume from slices  (Read 7977 times)

Offline gerferra

  • byte
  • *
  • Posts: 11
    • View Profile
Create custom volume from slices
« on: August 23, 2010, 03:19:37 pm »
Hi.

I'm evaluating jpct to use it internally in a personal project. My principal requirement is being able to show a volume in 3D given a set of "slices" of the volume in the form of polygons separated by a regular interval.

How easy/difficult it is to do this with jpct?

Thank you very much.

Regards,
Germain.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Create custom volume from slices
« Reply #1 on: August 23, 2010, 05:13:39 pm »
I'm not sure if i get what you mean. Do you have a screen shot or a drawing to illustrate it?

Offline gerferra

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Create custom volume from slices
« Reply #2 on: August 23, 2010, 05:46:51 pm »
Hi. Thank you for your response.

This image, which I found via google, shows the kind of "slices" I'm talking about:

http://www.mlahanas.de/MOEA/HDRMOGA/Image134.gif

Regards,
Germán.

Offline gerferra

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Create custom volume from slices
« Reply #3 on: August 23, 2010, 05:49:51 pm »
To clarify, the picture has slices for two distinct volumes. I couldn't find a better picture to show what I mean.

Thank you.
Germán.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Create custom volume from slices
« Reply #4 on: August 23, 2010, 10:07:20 pm »
And you only want to visualize such a situation or you do want to create the slices out of some geometry on the fly?

Offline gerferra

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Create custom volume from slices
« Reply #5 on: August 23, 2010, 10:19:43 pm »
I have the polygons corresponding to each slice. I want to visualize the slices like in the picture posted but also I'm looking for a way to generate an estimation of the original volume from which the slices were taken.

Thank you.


Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Create custom volume from slices
« Reply #6 on: August 23, 2010, 10:32:21 pm »

Offline gerferra

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Create custom volume from slices
« Reply #7 on: August 23, 2010, 11:05:31 pm »

Well, I want two different but somewhat complementary things. The first thing I want to display are some slices much like in the brain example you posted, but simpler because I only want to show the outline of each slice (my slices are polygons).

The second thing is more complicated. In the brain example, I would like to generate some suface that estimates the "skin" of the head from which the slices were taken. I would like to show a solid volume estimating the head from which the slices were taken. Note that in my case the slices are  polygons.

Thank you for the time spent on this. This is one of the moments when I wish I had taken some more english classes, I can't express myself as I would like...

Thank you.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Create custom volume from slices
« Reply #8 on: August 23, 2010, 11:15:25 pm »
I think i got more or less...yes, you can do this with jPCT, but you have to compute the hull of your slices by yourself. There's no magic method in jPCT that does this. I'm not sure about the slices themselves...that "they are polygons" means that they already are somekind of 3D mesh or that they are nothing but a vectorized outline? In the latter case, you'll need some kind of tessellator (not sure if this is the right word for it...) that creates a triangle mesh from your outline. Or do you just want to render the outline?

Offline gerferra

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Create custom volume from slices
« Reply #9 on: August 23, 2010, 11:25:23 pm »
Ok. I was looking for some magic method to generate the hull and don't have to do it by myself. The slices are a vectorized outline, yes, that's what I was trying to say. I only want to render the outline.

Do you know of some free library that can help me to generate the hull?

Thanks

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Create custom volume from slices
« Reply #10 on: August 23, 2010, 11:46:52 pm »
As long as the slices all have the same number of points that define the outline, it should be pretty easy to create the hull object. Do they?
« Last Edit: August 23, 2010, 11:48:33 pm by EgonOlsen »

Offline gerferra

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Create custom volume from slices
« Reply #11 on: August 24, 2010, 12:29:54 am »
No. The slices are defined by a user by hand and can have arbitrary points.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Create custom volume from slices
« Reply #12 on: August 24, 2010, 04:51:30 pm »
I see. I don't know of any library that does this albeit i'm pretty sure that something has to exist for this task. However, i always like to write my own stuff, so this is my idea on this:

  • iterate over the slices to find the one with the most points
  • tessellate all other slices's vectors so that you end up with an identical number of points for each slice (even if some or all fall onto one point in space)
  • find a starting point on each slice. I would start with a random one of the first slice and take the closest one from the next slice and so on
  • take slice n and n+1, start at the starting point and create triangles that connect the points and create the hull
  • continue with n+1 and n+2...until the last slice has been processed

IMHO, this should give you a good enough hull. But maybe i'm missing something...it sounds just too easy... ;)

Offline gerferra

  • byte
  • *
  • Posts: 11
    • View Profile
Re: Create custom volume from slices
« Reply #13 on: August 24, 2010, 05:33:12 pm »
Thank you  :).  I'll keep this on mind, I can't tell if its too simple or not
Can you give me a list of the principal api elements I would need to study in order to try this? (ie, to represent and render the vectorized outlines and the hull).

Thanks again.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Create custom volume from slices
« Reply #14 on: August 24, 2010, 06:22:25 pm »
Render the outlines with jPCT might feel a bit strange, because there's no line drawing method or something. The basic primitive in jPCT is the triangle. Everything you want to render has to be composed out of triangles. What you basically have to do is to create an Object3D from each vector of your outline giving it a real "body", i.e a kind of tube or prism. I would take the outline and create an Object3D from each vector by hand using the addTriangle()-method.