POV-Ray : Newsgroups : povray.general : Newbie Question: a simple polygon in 3D Server Time
15 Nov 2024 17:12:28 EST (-0500)
  Newbie Question: a simple polygon in 3D (Message 1 to 10 of 13)  
Goto Latest 10 Messages Next 3 Messages >>>
From: nomail
Subject: Newbie Question: a simple polygon in 3D
Date: 16 Jul 2004 04:50:01
Message: <web.40f7958f7069c0019335918f0@news.povray.org>
Hi everyone;

I have cut an object into many slices. For each slice I have taken a
photographical image... I can get the X Y coordinates of the perimeter of
this object in each slice.. Using POV-Ray, I 'd like to reconstruct this
object in 3D. Someone can help me?.. How can I make a 3D polygon for each
slice, and then put the 3D polygons together?..

if you have a simple example that i can change it to get what I want,I would
be most grateful !!

Here you are the coordinates X Y  of this object for two successive
slices...The thickness (according to Z) is 10 for example.

346 224
345 224
345 227
344 227
344 229
343 229
343 231
342 231
342 232
341 232
341 233
340 233
340 234
339 234
339 235
337 235
337 236
335 236
335 237
333 237
333 238
324 238
324 237
322 237
322 236
320 236
320 235
318 235
318 234
317 234
317 233
316 233
316 232
315 232
315 231
314 231
314 229
313 229
313 227
312 227
312 224
311 224
311 215
312 215
312 212
313 212
313 210
314 210
314 208
315 208
315 207
316 207
316 206
317 206
317 205
318 205
318 204
320 204
320 203
322 203
322 202
324 202
324 201
333 201
333 202
335 202
335 203
337 203
337 204
339 204
339 205
340 205
340 206
341 206
341 207
342 207
342 208
343 208
343 210
344 210
344 212
345 212
345 215
346 215
*****************************************************
346 224
345 224
345 227
344 227
344 229
343 229
343 231
342 231
342 232
341 232
341 233
340 233
340 234
339 234
339 235
338 235
338 236
337 236
337 237
335 237
335 238
332 238
332 239
324 239
324 238
321 238
321 237
319 237
319 236
318 236
318 235
317 235
317 234
316 234
316 233
315 233
315 232
314 232
314 231
313 231
313 229
312 229
312 227
311 227
311 224
310 224
310 214
311 214
311 211
312 211
312 209
313 209
313 207
314 207
314 206
315 206
315 205
316 205
316 204
317 204
317 203
318 203
318 202
319 202
319 201
321 201
321 200
324 200
324 199
332 199
332 200
335 200
335 201
337 201
337 202
338 202
338 203
339 203
339 204
340 204
340 205
341 205
341 206
342 206
342 207
343 207
343 209
344 209
344 211
345 211
345 214
346 214
*************************


thanks for you help


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Newbie Question: a simple polygon in 3D
Date: 16 Jul 2004 12:01:22
Message: <40f7fbd2$1@news.povray.org>
nomail@nomail wrote:
> Hi everyone;
> 
> I have cut an object into many slices. For each slice I have taken a
> photographical image... I can get the X Y coordinates of the perimeter of
> this object in each slice.. Using POV-Ray, I 'd like to reconstruct this
> object in 3D. Someone can help me?.. How can I make a 3D polygon for each
> slice, and then put the 3D polygons together?..
> 
> if you have a simple example that i can change it to get what I want,I would
> be most grateful !!
> 
> Here you are the coordinates X Y  of this object for two successive
> slices...The thickness (according to Z) is 10 for example.

If the number of sampled points from each slice contour
is equal, then you can write a little macro that produces
triangles that connects each pair of successive slices.

(All the triangles can be merged into a mesh.)

-- 
Tor Olav
http://subcube.net
http://subcube.com


Post a reply to this message

From: Apache
Subject: Re: Newbie Question: a simple polygon in 3D
Date: 16 Jul 2004 16:53:54
Message: <40f84062$1@news.povray.org>
If I'm right POV-Ray does have a polygon primitive.


Post a reply to this message

From: nomail
Subject: Re: Newbie Question: a simple polygon in 3D
Date: 16 Jul 2004 16:55:00
Message: <web.40f83f6530a9f2a0c523eabf0@news.povray.org>
Tor Olav Kristensen <tor### [at] TOBEREMOVEDhotmailcom> wrote:
> nomail@nomail wrote:
>
> If the number of sampled points from each slice contour
> is equal, then you can write a little macro that produces
> triangles that connects each pair of successive slices.
>
> (All the triangles can be merged into a mesh.)
>
> --
> Tor Olav
> http://subcube.net
> http://subcube.com

Thanks Tor for your response.
I saw your web-site. The photos were great, but I am still newbie, and your
images are very complicated for me...
Do you have a simple example??.


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Newbie Question: a simple polygon in 3D
Date: 17 Jul 2004 09:53:05
Message: <40f92f41$1@news.povray.org>
nomail@nomail wrote:
> Tor Olav Kristensen <tor### [at] TOBEREMOVEDhotmailcom> wrote:
> 
>>nomail@nomail wrote:
>>
>>If the number of sampled points from each slice contour
>>is equal, then you can write a little macro that produces
>>triangles that connects each pair of successive slices.
>>
>>(All the triangles can be merged into a mesh.)
...
> Thanks Tor for your response.
> I saw your web-site. The photos were great, but I am still newbie, and your
> images are very complicated for me...
> Do you have a simple example??.

See below for an example.

Note that I have commented out some points in the second contour
in order to get the same amount of samples around each slice.

Better results can be achieved by using a mesh2{} mesh instead of
triangles.

The code can also be made more efficient (and optimal in other ways),
but I've tried to keep it simple.


Tor Olav


// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#macro Slice(ContourA, ContourB, FromZ, ToZ)

   #local Size = dimension_size(ContourA, 1);

   #local Cnt = 0;
   #while (Cnt < Size - 1)
     #local p1 = ContourA[Cnt] + z*FromZ;
     #local p2 = ContourB[Cnt] + z*ToZ;
     #local p3 = ContourA[Cnt + 1] + z*FromZ;
     #local p4 = ContourB[Cnt + 1] + z*ToZ;
     triangle { p1, p2, p3 }
     triangle { p2, p3, p4 }
     #local Cnt = Cnt + 1;
   #end // while

#end // macro Slice

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare Contour1 =
   array[84] {
     <346, 224, 0>,
     <345, 224, 0>,
     <345, 227, 0>,
     <344, 227, 0>,
     <344, 229, 0>,
     <343, 229, 0>,
     <343, 231, 0>,
     <342, 231, 0>,
     <342, 232, 0>,
     <341, 232, 0>,
     <341, 233, 0>,
     <340, 233, 0>,
     <340, 234, 0>,
     <339, 234, 0>,
     <339, 235, 0>,

     <337, 235, 0>,
     <337, 236, 0>,
     <335, 236, 0>,
     <335, 237, 0>,

     <333, 237, 0>,
     <333, 238, 0>,
     <324, 238, 0>,
     <324, 237, 0>,
     <322, 237, 0>,
     <322, 236, 0>,
     <320, 236, 0>,
     <320, 235, 0>,

     <318, 235, 0>,
     <318, 234, 0>,
     <317, 234, 0>,
     <317, 233, 0>,
     <316, 233, 0>,
     <316, 232, 0>,
     <315, 232, 0>,
     <315, 231, 0>,
     <314, 231, 0>,
     <314, 229, 0>,
     <313, 229, 0>,
     <313, 227, 0>,
     <312, 227, 0>,
     <312, 224, 0>,

     <311, 224, 0>,
     <311, 215, 0>,
     <312, 215, 0>,
     <312, 212, 0>,
     <313, 212, 0>,
     <313, 210, 0>,
     <314, 210, 0>,
     <314, 208, 0>,
     <315, 208, 0>,
     <315, 207, 0>,
     <316, 207, 0>,
     <316, 206, 0>,
     <317, 206, 0>,
     <317, 205, 0>,
     <318, 205, 0>,
     <318, 204, 0>,

     <320, 204, 0>,
     <320, 203, 0>,
     <322, 203, 0>,
     <322, 202, 0>,
     <324, 202, 0>,
     <324, 201, 0>,
     <333, 201, 0>,
     <333, 202, 0>,
     <335, 202, 0>,
     <335, 203, 0>,
     <337, 203, 0>,
     <337, 204, 0>,

     <339, 204, 0>,
     <339, 205, 0>,
     <340, 205, 0>,
     <340, 206, 0>,
     <341, 206, 0>,
     <341, 207, 0>,
     <342, 207, 0>,
     <342, 208, 0>,
     <343, 208, 0>,
     <343, 210, 0>,
     <344, 210, 0>,
     <344, 212, 0>,
     <345, 212, 0>,
     <345, 215, 0>,
     <346, 215, 0>
   }


#declare Contour2 =
   array[84] {
     <346, 224, 0>,
     <345, 224, 0>,
     <345, 227, 0>,
     <344, 227, 0>,
     <344, 229, 0>,
     <343, 229, 0>,
     <343, 231, 0>,
     <342, 231, 0>,
     <342, 232, 0>,
     <341, 232, 0>,
     <341, 233, 0>,
     <340, 233, 0>,
     <340, 234, 0>,
     <339, 234, 0>,
     <339, 235, 0>,

//    <338, 235, 0>,
//    <338, 236, 0>,
     <337, 236, 0>,
     <337, 237, 0>,
     <335, 237, 0>,
     <335, 238, 0>,

     <332, 238, 0>,
     <332, 239, 0>,
     <324, 239, 0>,
     <324, 238, 0>,
     <321, 238, 0>,
     <321, 237, 0>,
     <319, 237, 0>,
     <319, 236, 0>,

     <318, 236, 0>,
     <318, 235, 0>,
     <317, 235, 0>,
     <317, 234, 0>,
     <316, 234, 0>,
     <316, 233, 0>,
     <315, 233, 0>,
     <315, 232, 0>,
     <314, 232, 0>,
     <314, 231, 0>,
     <313, 231, 0>,
     <313, 229, 0>,
//    <312, 229, 0>,
     <312, 227, 0>,

//    <311, 227, 0>,
     <311, 224, 0>,
//    <310, 224, 0>,
     <310, 214, 0>,

     <311, 214, 0>,
     <311, 211, 0>,
//    <312, 211, 0>,
     <312, 209, 0>,
     <313, 209, 0>,
     <313, 207, 0>,
     <314, 207, 0>,
     <314, 206, 0>,
     <315, 206, 0>,
     <315, 205, 0>,
     <316, 205, 0>,
     <316, 204, 0>,
     <317, 204, 0>,
     <317, 203, 0>,
     <318, 203, 0>,
     <318, 202, 0>,

     <319, 202, 0>,
     <319, 201, 0>,
     <321, 201, 0>,
     <321, 200, 0>,
     <324, 200, 0>,
     <324, 199, 0>,
     <332, 199, 0>,
     <332, 200, 0>,
     <335, 200, 0>,
     <335, 201, 0>,
     <337, 201, 0>,
     <337, 202, 0>,
//    <338, 202, 0>,
//    <338, 203, 0>,

     <339, 203, 0>,
     <339, 204, 0>,
     <340, 204, 0>,
     <340, 205, 0>,
     <341, 205, 0>,
     <341, 206, 0>,
     <342, 206, 0>,
     <342, 207, 0>,
     <343, 207, 0>,
     <343, 209, 0>,
     <344, 209, 0>,
     <344, 211, 0>,
     <345, 211, 0>,
     <345, 214, 0>,
     <346, 214, 0>
   }

union {
   Slice(Contour1, Contour2, -10, 0)
   pigment { color rgb <1, 0, 0> }
}

/*
union {
   Slice(Contour1, Contour2, 0, 10)
   pigment { color rgb <1, 0, 0> }
}

union {
   Slice(Contour1, Contour2, 10, 20)
   pigment { color rgb <1, 0, 0> }
}
*/

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7

#declare pCenter = <311 + (346 - 311)/2, 199 + (239 - 199)/2, 0>;

camera {
   location <5, 4, -10>*10
   look_at <0, 0, 0>
   translate pCenter
}

background { color rgb <1, 1, 1>*0.4 }

light_source {
   <8, 10, 10>*100
   color rgb <1, 1, 1>
}

// ===== 1 ======= 2 ======= 3 ======= 4 ======= 5 ======= 6 ======= 7


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Newbie Question: a simple polygon in 3D
Date: 17 Jul 2004 09:57:04
Message: <40f93030$1@news.povray.org>
Tor Olav Kristensen wrote:

...
> 
> #macro Slice(ContourA, ContourB, FromZ, ToZ)
> 
>   #local Size = dimension_size(ContourA, 1);
> 
>   #local Cnt = 0;
>   #while (Cnt < Size - 1)
>     #local p1 = ContourA[Cnt] + z*FromZ;
>     #local p2 = ContourB[Cnt] + z*ToZ;
>     #local p3 = ContourA[Cnt + 1] + z*FromZ;
>     #local p4 = ContourB[Cnt + 1] + z*ToZ;
>     triangle { p1, p2, p3 }
>     triangle { p2, p3, p4 }
>     #local Cnt = Cnt + 1;
>   #end // while
> 
> #end // macro Slice
> 
...

If you want the slice to be connected all the way around, then just
use this macro instead:


#macro Slice(ContourA, ContourB, FromZ, ToZ)

   #local Size = dimension_size(ContourA, 1);

   #local Cnt = 0;
   #while (Cnt < Size)
     #local p1 = ContourA[mod(Cnt, Size)] + z*FromZ;
     #local p2 = ContourB[mod(Cnt, Size)] + z*ToZ;
     #local p3 = ContourA[mod(Cnt + 1, Size)] + z*FromZ;
     #local p4 = ContourB[mod(Cnt + 1, Size)] + z*ToZ;
     triangle { p1, p2, p3 }
     triangle { p2, p3, p4 }
     #local Cnt = Cnt + 1;
   #end // while

#end // macro Slice


-- 
Tor Olav
http://subcube.net
http://subcube.com


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Newbie Question: a simple polygon in 3D
Date: 17 Jul 2004 10:01:13
Message: <40f93129$1@news.povray.org>
Tor Olav Kristensen wrote:

...
> union {
>   Slice(Contour1, Contour2, -10, 0)
>   pigment { color rgb <1, 0, 0> }
> }
> 
> /*
> union {
>   Slice(Contour1, Contour2, 0, 10)
>   pigment { color rgb <1, 0, 0> }
> }
> 
> union {
>   Slice(Contour1, Contour2, 10, 20)
>   pigment { color rgb <1, 0, 0> }
> }
> */
...


Ooops - I meant to write this:


union {
   Slice(Contour1, Contour2, -10, 0)
   pigment { color rgb <1, 0, 0> }
}

union {
   Slice(Contour2, Contour3, 0, 10)
   pigment { color rgb <1, 0, 0> }
}

union {
   Slice(Contour3, Contour4, 10, 20)
   pigment { color rgb <1, 0, 0> }
}


-- 
Tor Olav
http://subcube.net
http://subcube.com


Post a reply to this message

From: nomail
Subject: Re: Newbie Question: a simple polygon in 3D
Date: 17 Jul 2004 11:05:00
Message: <web.40f93efd30a9f2a09335918f0@news.povray.org>
Tor Olav Kristensen <tor### [at] TOBEREMOVEDhotmailcom> wrote:
> Tor Olav Kristensen wrote:
>
> ...
> > union {
> >   Slice(Contour1, Contour2, -10, 0)
> >   pigment { color rgb <1, 0, 0> }
> > }
> >
> > /*
> > union {
> >   Slice(Contour1, Contour2, 0, 10)
> >   pigment { color rgb <1, 0, 0> }
> > }
> >
> > union {
> >   Slice(Contour1, Contour2, 10, 20)
> >   pigment { color rgb <1, 0, 0> }
> > }
> > */
> ...
>
>
> Ooops - I meant to write this:
>
>
> union {
>    Slice(Contour1, Contour2, -10, 0)
>    pigment { color rgb <1, 0, 0> }
> }
>
> union {
>    Slice(Contour2, Contour3, 0, 10)
>    pigment { color rgb <1, 0, 0> }
> }
>
> union {
>    Slice(Contour3, Contour4, 10, 20)
>    pigment { color rgb <1, 0, 0> }
> }

Thanks again for your help Tor.... But the contours of my geometry don't
have the same number of points in each slice.
More clearly, I cut a mouse into 240 slices to do a phantom for medical
applications. I need to re-build the mouse in 3D using the photos of the
slices.. The form of organs is not regular. I mean, they have a polygon
shape. Take the kidney for example: when I start the cut, it appears small,

on for the other organs.
Another thing, I am looking for solid polygons and NOT for hollow

If it is posissible, I just want the method....Many thanks


Post a reply to this message

From: Tor Olav Kristensen
Subject: Re: Newbie Question: a simple polygon in 3D
Date: 17 Jul 2004 11:27:44
Message: <40f94570$1@news.povray.org>
nomail@nomail wrote:

...
> Thanks again for your help Tor.... But the contours of my geometry don't
> have the same number of points in each slice.
> More clearly, I cut a mouse into 240 slices to do a phantom for medical
> applications. I need to re-build the mouse in 3D using the photos of the
> slices.. The form of organs is not regular. I mean, they have a polygon
> shape. Take the kidney for example: when I start the cut, it appears small,

> on for the other organs.
> Another thing, I am looking for solid polygons and NOT for hollow

> If it is posissible, I just want the method....Many thanks

I think (but I'm not sure) that you can achieve what you want
with POV-Ray if you put some work into it.

I don't have time to explain more right now, but in the mean
time you can have a look at this page:

http://staff.aist.go.jp/r-suzuki/e/povray/iso/df_body.htm

-- 
Tor Olav
http://subcube.net
http://subcube.com


Post a reply to this message

From: ingo
Subject: Re: Newbie Question: a simple polygon in 3D
Date: 17 Jul 2004 14:10:11
Message: <Xns9529CD309EDD5seed7@news.povray.org>
in news:web.40f7958f7069c0019335918f0@news.povray.org  wrote:

>  have cut an object into many slices. For each slice I have taken a
> photographical image... I can get the X Y coordinates of the
> perimeter of this object in each slice.. Using POV-Ray, I 'd like to
> reconstruct this object in 3D. Someone can help me?.. 


Have a look at this:
http://mi.eng.cam.ac.uk/~gmt11/software/isosurf/isosurf.html
the problem may be how to convert the output to a POV-Ray mesh object.

Another option is to convert your images to grayscale TGA's and then turn 
it into a df3-file  http://www.users.on.net/~pod/df3/
This then can be used with isosurfaces or media for the latter:   
http://news.povray.org/povray.binaries.images/13012/

Ingo


Post a reply to this message

Goto Latest 10 Messages Next 3 Messages >>>

Copyright 2003-2023 Persistence of Vision Raytracer Pty. Ltd.