POV-Ray : Newsgroups : povray.general : How to extrude a mesh : Re: How to extrude a mesh Server Time
29 Jul 2024 18:27:07 EDT (-0400)
  Re: How to extrude a mesh  
From: Nekar Xenos
Date: 11 Nov 2010 08:59:44
Message: <op.vl0ehqxaufxv4h@go-dynamite>
On Thu, 11 Nov 2010 03:59:52 +0200, Alain <aze### [at] qwertyorg> wrote:


>> Alain<aze### [at] qwertyorg>  wrote:

>>>> Hi there, I'd like to know if there is any way to extrude a mesh li
ke  

>>>> this :
>>>>
>>>> mesh {
>>>> triangle  

>>>> {<1,13.2146,-23.2146>,<3,14.286,-24.286>,<17,14.286,-24.286>   }
>>>> triangle  

>>>> {<17,14.286,-24.286>,<19,13.2146,-23.2146>,<1,13.2146,-23.2146>   }

>>>> triangle  

>>>> {<19,13.2146,-23.2146>,<17,14.286,-24.286>,<17,18.2146,-28.2146>   
}
>>>> triangle  

>>>> {<17,18.2146,-28.2146>,<19,19.2861,-29.2861>,<19,13.2146,-23.2146> 
  }
>>>> triangle  

>>>> {<19,19.2861,-29.2861>,<17,18.2146,-28.2146>,<3,18.2146,-28.2146>  
 }
>>>> triangle  

>>>> {<3,18.2146,-28.2146>,<1,19.2861,-29.2861>,<19,19.2861,-29.2861>   
}
>>>> triangle  

>>>> {<1,19.2861,-29.2861>,<3,18.2146,-28.2146>,<3,14.286,-24.286>   }
>>>> triangle  

>>>> {<3,14.286,-24.286>,<1,13.2146,-23.2146>,<1,19.2861,-29.2861>   }
>>>> triangle  

>>>> {<3,15.7146,-25.7146>,<17,15.7146,-25.7146>,<17,16.786,-26.786>   }

>>>> triangle  

>>>> {<17,16.786,-26.786>,<3,16.786,-26.786>,<3,15.7146,-25.7146>   }
>>>> triangle  

>>>> {<5,14.286,-24.286>,<7,14.286,-24.286>,<7,18.2146,-28.2146>   }
>>>> triangle  

>>>> {<7,18.2146,-28.2146>,<5,18.2146,-28.2146>,<5,14.286,-24.286>   }
>>>> triangle  

>>>> {<9,14.286,-24.286>,<11,14.286,-24.286>,<11,18.2146,-28.2146>   }
>>>> triangle  

>>>> {<11,18.2146,-28.2146>,<9,18.2146,-28.2146>,<9,14.286,-24.286>   }
>>>> triangle  

>>>> {<13,14.286,-24.286>,<15,14.286,-24.286>,<15,18.2146,-28.2146>   }
>>>> triangle  

>>>> {<15,18.2146,-28.2146>,<13,18.2146,-28.2146>,<13,14.286,-24.286>   
}
>>>> }
>>>>
>>>> I'd like to extrude it following the y axis.
>>>>
>>>> I know I can do it using the "prism" fonction by keeping only the  

>>>> triangles
>>>> points without the y coordinate, but it's kinda boring to do it  

>>>> manually.
>>>>
>>>> Maybe there is a solution to extrude every kind of 2D or 3D objects
  

>>>> along an
>>>> axis !?
>>>>
>>>>
>>>> Thanks in advance for your reply.
>>>>
>>>>
>>>
>>> There is no surefire way to do that.
>>> You can:
>>> scale the mesh by a very large value along the Y axis and take the
>>> intersection with a box of the desired thickness.
>>> intersection{
>>>   object{Your_mesh scale<1, 1e6,1>}
>>>   box{<1,1,-30><19,-1,-20>}
>>> }
>>>
>>> Extract the outermost points and use them to define a prism.
>>>
>>> Use an external programm to create a pre-extruded prism.
>>>
>>>
>>>
>>>
>>> Alain
>>
>> Thanks for your reply but I'm afraid these ways to do it won't be ok 
 

>> for me.
>>
>> To extract the outermost points will request any kind of programm to 
do  

>> it, then
>> I can't and I don't want to use an external programm.
>>
>> I've tried the first solution, I see what you meant by scaling it alo
ng  

>> the y
>> axis, but the example I gave is a inclined plane surface made of  

>> triangles, so
>> scaling it along y only creates another plane surface.
>>
>> Let's say there is only one triangle in my mesh, like that :
>>
>> mesh {
>>              triangle {<0,0,0>,<1,0,1>,<1,1,0>}
>> }
>>
>> How can I extrude it using only the 3 dimensions coordinates of the 3
  

>> points of
>> the triangle. Of course I would like something quick and easy to do  

>> because I
>> have to extrude more complex mesh (like the one on my first post)
>>
>>
>>
>>
>>
>
> Sory, but there is no easy solution.
>
> You can make your mesh solid by adding an inside_vector, BUT, the  

> resulting solid mesh don't have any side. You can intersect it from a 
 

> box that is very slightly smaller than the mesh. It ONLY works IF the 
 

> mesh is square.
> Whener you don't see the side of the box, there sill be no side. Any  

> opening will also be invisible.
>
> If the mesh is some arbitrary non-square shape, you'll only get the to
p  

> and bottom faces.
>
> Also, whenever you have an even number of coplanar triangles you get a
n  

> opening.
>
> Another solution would be to have the mesh in a text file, read that  

> file in a loop and construct your prism definition from that.
>
> Then, if you want the top and bottom to follow the vertical shape of t
he  

> mesh, you'll need to cut away the prism with the mesh itself using  

> intersection for the top and difference for the bottom. Here again, yo
u  

> need a mesh made solid using inside_vector y.
>
> Not realy easy, but you can automate the process, so you only need to 
 

> code it once.
>
>
>
>
> Alain

I'm thinking something along the lines of saving the mesh as a separate 
 

file and reading the file and writing a new file after replacing each  

triangle with a group of triangles.

Let's say a triangle has corner co-ordinates T1, T2 and T3 and you want 
to  

extrude it in direction of vector V1

You then replace
triangle{T1,T2,T3}
with the following:
////////////////////////////////////////////////////////

triangle{T1,T2,T3}// original triangle

triangle{T1,T2,T1+V1}    //side of T1 and T2
triangle{T1,T2+V1,T1+V1} //

triangle{T2,T2+V1,T3}    // side of T2 and T3
triangle{T2+V1,T2,T3+V1} //

triangle{T1,T3+V1,T3}    // side of T3 and T1
triangle{T1+V1,T3+V1,T3} //

triangle{T1+V1,T2+V1,T3+V1}// Original triangle fully displaced by vecto
r  

V1

////////////////////////////////////////////////////////////////////////
//////

-Nekar Xenos-


Post a reply to this message

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