Re: Inheritance off pfObjects.

New Message Reply Date view Thread view Subject view Author view

Bernard Leclerc (bleclerc++at++cae.ca)
Thu, 18 Apr 1996 09:36:36 -0400


On Apr 15, 3:31pm, Thomas M. Miller wrote:

> Are there problems with inheritance off performer objects?

No. The Performer Programmer's Guide, chapter 14 explains how it should be
done.

> For example if I was to implement a class in the following manner would
> it cause any problems?
>
> class DCS_ListElm : public pfDCS
> {
> public:
> DCS_ListElm *next, *prev;
>
> DCS_ListElm( void ) : pfDCS()
> {
> next = prev = NULL;
> }
>
> ~DCS_ListElm( void )
> {
> if( next )
> next->prev = prev;
> if( prev )
> prev->next = next;
> }
> };
>
> Please forgive the crudness of my example class.
>
> Would there be mal effects upon the deletion of an object of this class?
>
> In what manner should an object of this class be delete anyway,
> using the delete operator or pfDelete?
>

I've attached a modified version of simple.C illustrating how a derived DCS
could be implemented. See by yourself...

Bernard.

--
      ___/      |        ___/	Bernard Leclerc		e-mail: bleclerc++at++cae.ca
     /        / |       /	Systems Engineer	voice: +1 514 341 2000
    /        /  |      __/	CAE Electronics Ltd.		extension 2275
   /        /   |     /		8585 Cote De Liesse	fax:   +1 514 340 5496
  /        ____ |    /		P.O. Box 1800
_____/   _/    _|  _____/	Saint-Laurent, Quebec, Canada, H4L-4X4

// // Copyright 1995, Silicon Graphics, Inc. // ALL RIGHTS RESERVED // // UNPUBLISHED -- Rights reserved under the copyright laws of the United // States. Use of a copyright notice is precautionary only and does not // imply publication or disclosure. // // U.S. GOVERNMENT RESTRICTED RIGHTS LEGEND: // Use, duplication or disclosure by the Government is subject to restrictions // as set forth in FAR 52.227.19(c)(2) or subparagraph (c)(1)(ii) of the Rights // in Technical Data and Computer Software clause at DFARS 252.227-7013 and/or // in similar or successor clauses in the FAR, or the DOD or NASA FAR // Supplement. Contractor/manufacturer is Silicon Graphics, Inc., // 2011 N. Shoreline Blvd. Mountain View, CA 94039-7311. // // Permission to use, copy, modify, distribute, and sell this software // and its documentation for any purpose is hereby granted without // fee, provided that (i) the above copyright notices and this // permission notice appear in all copies of the software and related // documentation, and (ii) the name of Silicon Graphics may not be // used in any advertising or publicity relating to the software // without the specific, prior written permission of Silicon Graphics. // // THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, // EXPRESS, IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY // WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. // // IN NO EVENT SHALL SILICON GRAPHICS BE LIABLE FOR ANY SPECIAL, // INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY // DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, // WHETHER OR NOT ADVISED OF THE POSSIBILITY OF DAMAGE, AND ON ANY // THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE USE // OR PERFORMANCE OF THIS SOFTWARE. // // // simpleC.C: simple Performer program for programmer's guide // // $Revision: 1.10 $ // $Date: 1995/11/22 14:35:21 $ //

#include <stdlib.h> #include <stdio.h>

#include <Performer/pf/pfChannel.h> #include <Performer/pf/pfLightSource.h> #include <Performer/pf/pfNode.h> #include <Performer/pf/pfScene.h> #include <Performer/pf/pfDCS.h> #include <Performer/pf/pfTraverser.h>

#include <Performer/pfutil.h> #include <Performer/pfdu.h>

// application specific class derived from a Performer DCS node. // // The virtual function app() simply counts the number of time // the function is called. class appDCS : public pfDCS {

public: int count;

appDCS() {count = 0;}

virtual int app(pfTraverser* trav) { count++; return pfDCS::app(trav); }

virtual int needsApp() { return TRUE; }

static void init();

static pfType* getClassType() { return classType; }

private:

static pfType* classType;

};

pfType *appDCS::classType = NULL;

void appDCS::init() { if (classType == NULL) { pfDCS::init(); classType = new pfType ( pfDCS::getClassType(), "appDCS"); } }

// // Usage() -- print usage advice and exit. This // procedure is executed in the application process. // static void Usage (void) { pfNotify(PFNFY_FATAL, PFNFY_USAGE, "Usage: simpleC file.ext ...\n"); exit(1); }

// // Application Callback used by channel groups // static void AppCallback( pfChannel *, void * ) { pfApp(); }

// // Main program // int main (int argc, char *argv[]) { float t = 0.0f; if (argc < 2) Usage(); // Initialize Performer pfInit();

// Initialize derived classes appDCS::init(); // Use default multiprocessing mode based on number of // processors. // pfMultiprocess( PFMP_DEFAULT ); // Load all loader DSO's before pfConfig() forks pfdInitConverter(argv[1]);

// initiate multi-processing mode set in pfMultiprocess call // FORKs for Performer processes, CULL and DRAW, etc. happen here. // pfConfig(); // Append to Performer search path, PFPATH, files in // /usr/share/Performer/data */ pfFilePath(".:/usr/share/Performer/data"); pfNode *root = pfdLoadFile(argv[1]); if (root == NULL) { pfExit(); exit(-1); }

// Attach the loaded file to a new appDCS appDCS* dcs = new appDCS; dcs->addChild(root);

// Attach the appDCS to a new pfScene pfScene *scene = new pfScene; scene->addChild(dcs); // Create a pfLightSource and attach it to scene scene->addChild(new pfLightSource); // Configure and open GL window pfPipe *p = pfGetPipe(0); pfPipeWindow *pw = new pfPipeWindow(p); pw->setWinType(PFPWIN_TYPE_X); pw->setName("IRIS Performer"); pw->setOriginSize(0,0,640,480); pw->open(); // Create and configure 2 channels. pfChannel *chan1 = new pfChannel(p); pfChannel *chan2 = new pfChannel(p); chan1->attach(chan2); chan1->setScene(scene); chan1->setFOV(45.0f, 0.0f); chan2->setViewport(0.333333f,0.666666f,0.7f,0.9f); chan1->setTravFunc( PFTRAV_APP, AppCallback );

// determine extent of scene's geometry pfSphere bsphere; root->getBound(&bsphere); chan1->setNearFar(1.0f, 10.0f * bsphere.radius);

// Simulate for twenty seconds. int frames;

while (t < 20.0f) {

pfCoord view; float s, c; // Go to sleep until next frame time. pfSync(); // Initiate cull/draw for this frame. frames = pfFrame(); // Compute new view position. t = pfGetTime(); pfSinCos(45.0f*t, &s, &c); view.hpr.set(45.0f*t, -10.0f, 0); view.xyz.set(2.0f * bsphere.radius * s, -2.0f * bsphere.radius *c, 0.5f * bsphere.radius); chan1->setView(view.xyz, view.hpr); }

printf("num frames: %d\n", frames); printf("appDCS count: %d\n", dcs->count);

// Terminate parallel processes and exit pfExit(); return 0; }


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:52:44 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.