POV-Ray : Newsgroups : povray.programming : Pass a POV object to a class Server Time
28 Jul 2024 16:14:54 EDT (-0400)
  Pass a POV object to a class (Message 5 to 14 of 14)  
<<< Previous 4 Messages Goto Initial 10 Messages
From: Thorsten Froehlich
Subject: Re: Pass a POV object to a class
Date: 14 Mar 2001 10:41:50
Message: <3aaf913e$1@news.povray.org>
In article <7p5uatkfp1lg0lluhftkg2ad9okphd814a@4ax.com> , Peter Popov 
<pet### [at] vipbg>  wrote:

> Lastly, a side question. Are there license-free, public-domain,
> cross-platform examples of polymorphic sorted lists, binary, quad- and
> oct-trees or should I make them myself?

You just use the "polymorphic reference type" - others might call it "a
pointer" :-)

Lets say you have something like this (abbreviated syntax):

  class Base;
  class Building : Base;
  class House : Building;
  class Tower : Building;
  class Garage : Building;

And you want to store all buildings, you just do:

  vector<Building *> buildings;

You can access individual objects in a type safe manner like this:

  House *house = dynamic_cast<House *>(buildings[3]);

If is was a House dynamic_cast returns a valid pointer to a House.  If
not, it return NULL.  Note that dynamic_cast throws exceptions if you
cast references.


     Thorsten


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Thorsten Froehlich
Subject: Re: Pass a POV object to a class
Date: 14 Mar 2001 10:45:01
Message: <3aaf91fd$1@news.povray.org>
In article <7p5uatkfp1lg0lluhftkg2ad9okphd814a@4ax.com> , Peter Popov 
<pet### [at] vipbg>  wrote:

> sorted lists, binary, quad- and
> oct-trees or should I make them myself?

BTW, the STL does provides these in some form or the other.  However, it
depend on exactly what you want to do.


      Thorsten


____________________________________________________
Thorsten Froehlich, Duisburg, Germany
e-mail: tho### [at] trfde

Visit POV-Ray on the web: http://mac.povray.org


Post a reply to this message

From: Roberto Ferrer de Amorim
Subject: Re: Pass a POV object to a class
Date: 14 Mar 2001 12:41:00
Message: <3aafad2c@news.povray.org>
> Lastly, a side question. Are there license-free, public-domain,
> cross-platform examples of polymorphic sorted lists, binary, quad- and
> oct-trees or should I make them myself? Granted, I will eventually do
> so since this is my final year project and I want to have done as much
> as possible myself when I defend it, but until then, it can save me
> some brain cells.

glib is a very good library, but it's in C. AFAIK, it can be polimorphic and
has all sorts of lists and trees, but take a look yourself on it. Here's the
link to download:

ftp://ftp.gtk.org/pub/gtk/v1.2/glib-1.2.9.tar.gz

About 400k. Take a look and see if it fits - however, you can always use the
STL on C++, although I do not recommend you do that. :-)

Wolfox

- I used to program in C++, then I found Java. I used to program in Java,
then I found Python (http://www.python.org/)


Post a reply to this message

From: Sander
Subject: Re: Pass a POV object to a class
Date: 14 Mar 2001 15:17:54
Message: <MPG.1519f05d7ac1416d989709@NEWS.POVRAY.ORG>
In article <lr1vat057106tpcd2cp26m8glphl24i7vf@4ax.com>, David Wilkinson 
says...
> I can't help you with your problems Peter, but I too have fallen for C++ having
> recently installed Borland C++ Builder 4 for free from the PCAnswers magazine
> CD.  This really does simplify developing programs for MS Windows.
> The idea of overloading vector operators to use POV code is an interesting idea
> that I must investigate.   
> ----------------------
> dav### [at] hamiltonitecom
> http://hamiltonite.com/
> 
Welcome to C++Builder, David! I had versions 1,2,3, skipped 4 and now 5. 
Suppose it will last for the time remaining: the upgrades are too 
expensive. I use it for my (as the expression goes in Dutch) "house, 
garden and kitchen programs", since I'm not much of a programmer at 
all... Although I did the Windows frontend for CMPEG with it. :)
-- 
Regards,  Sander


Post a reply to this message

From: Peter Popov
Subject: Re: Pass a POV object to a class
Date: 15 Mar 2001 00:59:38
Message: <igm0btg4p7so8s5adiiuom6bd3972ehqik@4ax.com>
On Wed, 14 Mar 2001 15:14:09 +0100, "Mael" <Mae### [at] hotmailcom>
wrote:

>you can use an OBJECT* and call Inside_Object :
>Inside_Object (VECTOR IPoint, OBJECT *Object)

But isn't OBJECT a struct? I mean, I know it works for classes (that's
how I fit them all in the same list) but I didn't know it worked for
structs.


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Peter Popov
Subject: Re: Pass a POV object to a class
Date: 15 Mar 2001 01:02:50
Message: <3lm0bt0llofncm7ert3i1vgv3d2ua1rlsv@4ax.com>
On Wed, 14 Mar 2001 09:41:48 -0600, "Thorsten Froehlich"
<tho### [at] trfde> wrote:

>You just use the "polymorphic reference type" - others might call it "a
>pointer" :-)

Thorsten, that's what I am doing now :) I just realised that people
have done it before a million times and someone might have chosen to
share his code with newbies, 's all.

I might use the one in STL, the problem is, I don't have any
description of the STL and I don't feel like hacking into libc.a again
:)


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Roberto Ferrer de Amorim
Subject: Re: Pass a POV object to a class
Date: 15 Mar 2001 07:48:33
Message: <3ab0ba21@news.povray.org>
Check http://www.mindview.net/ . There is an online (downloadable) book
there called "Thinking in C++". It has a great section about the STL.

Wolfox

Peter Popov <pet### [at] vipbg> wrote in message
news:3lm0bt0llofncm7ert3i1vgv3d2ua1rlsv@4ax.com...
> On Wed, 14 Mar 2001 09:41:48 -0600, "Thorsten Froehlich"
> <tho### [at] trfde> wrote:
>
> >You just use the "polymorphic reference type" - others might call it "a
> >pointer" :-)
>
> Thorsten, that's what I am doing now :) I just realised that people
> have done it before a million times and someone might have chosen to
> share his code with newbies, 's all.
>
> I might use the one in STL, the problem is, I don't have any
> description of the STL and I don't feel like hacking into libc.a again
> :)
>
>
> Peter Popov ICQ : 15002700
> Personal e-mail : pet### [at] vipbg
> TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Ron Parker
Subject: Re: Pass a POV object to a class
Date: 15 Mar 2001 08:05:20
Message: <slrn9b1fgh.f75.ron.parker@fwi.com>
On Thu, 15 Mar 2001 08:00:50 +0200, Peter Popov wrote:
>On Wed, 14 Mar 2001 15:14:09 +0100, "Mael" <Mae### [at] hotmailcom>
>wrote:
>
>>you can use an OBJECT* and call Inside_Object :
>>Inside_Object (VECTOR IPoint, OBJECT *Object)
>
>But isn't OBJECT a struct? I mean, I know it works for classes (that's
>how I fit them all in the same list) but I didn't know it worked for
>structs.

It is a struct, but one of its members is an array of pointers to functions.
A C++ programmer might call it a vtable.

The first C++ compilers compiled to C, you know.

-- 
Ron Parker   http://www2.fwi.com/~parkerr/traces.html
My opinions.  Mine.  Not anyone else's.


Post a reply to this message

From: Peter Popov
Subject: Re: Pass a POV object to a class
Date: 15 Mar 2001 17:04:51
Message: <u1f2btkmj3omms8hssvieliipj3lv1krop@4ax.com>
On Thu, 15 Mar 2001 09:47:39 -0300, "Roberto Ferrer de Amorim"
<ram### [at] comdescontocombr> wrote:

>Check http://www.mindview.net/ . There is an online (downloadable) book
>there called "Thinking in C++". It has a great section about the STL.

I will gladly RTFM right away! I have that book in three different
formats and even started reading it. Sheesh!

<head up mine>


Peter Popov ICQ : 15002700
Personal e-mail : pet### [at] vipbg
TAG      e-mail : pet### [at] tagpovrayorg


Post a reply to this message

From: Chris Huff
Subject: Re: Pass a POV object to a class
Date: 17 Mar 2001 11:38:36
Message: <chrishuff-9EEDA5.11330417032001@news.povray.org>
In article <7p5uatkfp1lg0lluhftkg2ad9okphd814a@4ax.com>, Peter Popov 
<pet### [at] vipbg> wrote:

> I remember Chris Huff wrote a patch-HOWTO some time ago, some
> up-to-date advice along the same lines would be very appreciated.

Unfortunately, my patch tutorial didn't cover integrating C++ code with 
C, something that I've never done and hope never to do. I vaguely recall 
saving some messages about doing this, though...I could look around and 
see if I still have them, if you want. I'm pretty sure they came from 
this server and this group...

-- 
Christopher James Huff
Personal: chr### [at] maccom, http://homepage.mac.com/chrishuff/
TAG: chr### [at] tagpovrayorg, http://tag.povray.org/

<><


Post a reply to this message

<<< Previous 4 Messages Goto Initial 10 Messages

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