POV-Ray : Newsgroups : povray.unofficial.patches : mesh2 question Server Time
2 Sep 2024 16:14:45 EDT (-0400)
  mesh2 question (Message 1 to 10 of 10)  
From: Margus Ramst
Subject: mesh2 question
Date: 10 Aug 1999 20:08:11
Message: <37B0BEEE.2AE722CB@peak.edu.ee>
Because of the triangle malloc bug in the superpatch, I recently had to use
mesh2 instead of mesh. While the format is quite elegant, I had one major
problem with it: the need to specify the number of elements in the arrays. Since
I was reading in coordinates from a file, I had no way of predicting this
number. This made mesh2 generation rather cumbersome.
So the question: is specifying the number of elements really necessary? I would
imagine it only speeds up initial parsing. Dropping it would, IMO, make using
mesh2 easier.

Margus


Post a reply to this message

From: Nieminen Mika
Subject: Re: mesh2 question
Date: 11 Aug 1999 02:59:07
Message: <37b11f3b@news.povray.org>
Margus Ramst <mar### [at] peakeduee> wrote:
: So the question: is specifying the number of elements really necessary?

  I think that the idea is that when you know the number of triangles, you
can allocate a memory block of that size (ie. just one array). This way
you save quite lot of memory (you don't need to waste memory for extra
information put into the nodes of a binary tree and the memory block the
system has to keep to control the allocations and deallocations). Handling
the triangles is also faster since you can directly index them instead
of having to walk through a tree structure.

-- 
main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Margus Ramst
Subject: Re: mesh2 question
Date: 11 Aug 1999 14:50:47
Message: <37B1C608.C7113280@peak.edu.ee>
Isn't mesh2 converted to mesh internally?
If so, does what you said still apply?

Margus

Nieminen Mika wrote:
> 
> Margus Ramst <mar### [at] peakeduee> wrote:
> : So the question: is specifying the number of elements really necessary?
> 
>   I think that the idea is that when you know the number of triangles, you
> can allocate a memory block of that size (ie. just one array). This way
> you save quite lot of memory (you don't need to waste memory for extra
> information put into the nodes of a binary tree and the memory block the
> system has to keep to control the allocations and deallocations). Handling
> the triangles is also faster since you can directly index them instead
> of having to walk through a tree structure.
> 
> --
> main(i,_){for(_?--i,main(i+2,"FhhQHFIJD|FQTITFN]zRFHhhTBFHhhTBFysdB"[i]
> ):5;i&&_>1;printf("%s",_-70?_&1?"[]":" ":(_=0,"\n")),_/=2);} /*- Warp -*/


Post a reply to this message

From: Ron Parker
Subject: Re: mesh2 question
Date: 11 Aug 1999 14:56:56
Message: <37b1c778@news.povray.org>
On Wed, 11 Aug 1999 21:50:48 +0300, Margus Ramst wrote:
>Isn't mesh2 converted to mesh internally?
>If so, does what you said still apply?

Yes.  The reason is that mesh2 is converted into the INTERNAL representation
of a mesh.  The internal representation is a pile of arrays.  The difference
is that a mesh is first put into a set of hash tables while the sizes of the
arrays are computed, then the contents of the hash tables are transferred to
the arrays.  Mesh2 is able to skip this intermediate step by adding explicit
counts to the syntax.  Mesh2 is really only intended for a machine-generated
mesh anyway.


Post a reply to this message

From: TonyB
Subject: Re: mesh2 question
Date: 11 Aug 1999 18:52:18
Message: <37B1F009.F3C2BF01@panama.phoenix.net>
So should we make mesh3 for humans?

--
Anthony L. Bennett
http://welcome.to/TonyB

Non nova, sed nove.


Post a reply to this message

From: Nigel Stewart
Subject: Re: mesh2 question
Date: 11 Aug 1999 23:00:47
Message: <37B23883.698F491B@eisa.net.au>
> So should we make mesh3 for humans?

	Maybe an external filter would do the
	job.  I have some code to convert
	VRML indexed face sets to POV mesh,
	maybe mesh2 would be useful too...

--
NIGEL STEWART nig### [at] nigelscom
Research Student + Software Developer
"Time is a train, makes the future the past"


Post a reply to this message

From: Nathan Kopp
Subject: Re: mesh2 question
Date: 11 Aug 1999 23:26:43
Message: <37B23E96.2DAC4966@Kopp.com>
Margus Ramst wrote:
> 
> Isn't mesh2 converted to mesh internally?
> If so, does what you said still apply?
> 

Actually, the syntax of mesh2 more closely resembles the internal
representation of the mesh object (in fact, it is almost exactly the same
as the internal representaion).  And as was mentioned, the reason the
number of elements is required is for parsing reasons.  One other option
is for the parser to read the mesh twice, only counting items the first
time.  But, obviously, that would cause parse times to increase.  Another
option would be to allocate space, then re-allocate if the first guess
was too big.  Of course, you'd always have some extra allocated because
you probably wouldn't guess the exact amount.  You could then re-allocate
an array of the exact size and copy the data, but that means having two
copies of the data in memory at parse time, which is not a good idea for
large meshes.

Finally, mesh2 (as indicated by Ron) was designed to be generated by
comptuters.  Humans should probably still write using the original
mesh syntax.

P.S. Sorry I took so long to reply.  I just moved to a new apartment and
the phone company took their time getting the phone working.

-Nathan


Post a reply to this message

From: Margus Ramst
Subject: Re: mesh2 question
Date: 12 Aug 1999 13:36:09
Message: <37B3060A.D485E0E7@peak.edu.ee>
I see. Well, reading the number of elements is easy enough in POV script too,
although it's slow. I really wish POV had dynamic arrays. But that's another
story.
So, Ron, how's that update coming along? Or have you posted a version that fixes
the malloc bug?

Margus

Nathan Kopp wrote:
> 
> Actually, the syntax of mesh2 more closely resembles the internal
> representation of the mesh object (in fact, it is almost exactly the same
> as the internal representaion).  And as was mentioned, the reason the
> number of elements is required is for parsing reasons.  One other option
> is for the parser to read the mesh twice, only counting items the first
> time.  But, obviously, that would cause parse times to increase.  Another
> option would be to allocate space, then re-allocate if the first guess
> was too big.  Of course, you'd always have some extra allocated because
> you probably wouldn't guess the exact amount.  You could then re-allocate
> an array of the exact size and copy the data, but that means having two
> copies of the data in memory at parse time, which is not a good idea for
> large meshes.
> 
> Finally, mesh2 (as indicated by Ron) was designed to be generated by
> comptuters.  Humans should probably still write using the original
> mesh syntax.
> 
> P.S. Sorry I took so long to reply.  I just moved to a new apartment and
> the phone company took their time getting the phone working.
> 
> -Nathan


Post a reply to this message

From: Mick Hazelgrove
Subject: Re: mesh2 question
Date: 12 Aug 1999 13:43:46
Message: <37b307d2@news.povray.org>
Margus Ramst <mar### [at] peakeduee> wrote in message
> So, Ron, how's that update coming along? Or have you posted a version that
fixes
> the malloc bug?


We're all lined up in a nice orderly queue, with our tongues out and
panting!

Mick


Post a reply to this message

From: Gilles Tran
Subject: Re: mesh2 question
Date: 13 Aug 1999 09:40:52
Message: <37B42103.2B394D96@inapg.inra.fr>
On the "plus" side, the malloc bug prompted me to explore the mesh2 syntax and
now the Poser 4->3DS2pov->mesh2 combination has become a favourite of mine,
particularly because mesh2 meshes are smaller and parse much faster than the
other meshes, which is very convenient when you have several of them in a scene.

Gilles

Mick Hazelgrove wrote:

> Margus Ramst <mar### [at] peakeduee> wrote in message
> > So, Ron, how's that update coming along? Or have you posted a version that
> fixes
> > the malloc bug?
>
> We're all lined up in a nice orderly queue, with our tongues out and
> panting!
>
> Mick


Post a reply to this message

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