Masanori Kakimoto (kaki++at++kaki.nsg.sgi.com)
Thu, 1 May 1997 23:52:29 +0900
Please try making "bbox" and run with an input file while watching
memory consumption with 'gr_osview -a'. If you try big <repeats>,
the shared arena will eventually run out, which should not happen if
these pfDelete's are working.
Could anyone point out what is wrong?
/*
* bbox.C -- Prints bounding box data of a 3D model file.
* Use modified /usr/share/Performer/src/pguide/libpf/C++/Makefile to
* compile.
* Written by Masanori Kakimoto (kaki++at++nsg.sgi.com)
*/
#include <stdio.h>
#include <stdlib.h>
#include <Performer/pf.h>
#include <Performer/pf/pfScene.h>
#include <Performer/pfdu.h>
#include <Performer/pfutil.h>
void PrintBBox(char *fileName, int repeats);
void MyPfDelete(pfMemory *ptr);
int
main(int argc, char *argv[])
{
if (argc != 3) {
fprintf(stderr, "Usage: %s <filename> <repeats>\n", argv[0]);
exit(1);
}
pfInit();
pfuInitUtil();
pfdInitConverter(argv[1]);
pfConfig();
pfFilePath(".:/usr/share/Performer/data");
// Repeat loading and pfDelete'ing.
PrintBBox(argv[1], atoi(argv[2]));
while (1) {
if (getchar() == 'a') {
break;
}
}
}
void
PrintBBox(char *fileName, int repeats)
/* Computes bounding box of the model file and print min[x,y,z] and
max[x,y,z] to standard output.
*/
{
int i;
pfScene *tmpScene = new pfScene;
for (i = 0; i < repeats; i++) {
pfNode *aNode = pfdLoadFile(fileName);
pfBox bbox;
if (aNode != NULL) {
tmpScene->addChild(aNode);
#if 1
pfuTravCalcBBox(aNode, &bbox);
printf("%s (%d) %.1f %.1f %.1f %.1f %.1f %.1f\n",
fileName, i,
bbox.min[0], bbox.min[1], bbox.min[2],
bbox.max[0], bbox.max[1], bbox.max[2]);
#endif
tmpScene->removeChild(aNode);
MyPfDelete(aNode);
}
}
MyPfDelete(tmpScene);
}
void
MyPfDelete(pfMemory *ptr)
{
int deleted;
deleted = pfDelete(ptr);
if (deleted == TRUE) {
fprintf(stderr, "pfDelete succeeded.\n");
} else if (deleted == FALSE) {
fprintf(stderr, "pfDelete failed.\n");
} else if (deleted == -1) {
fprintf(stderr, "pfDelete failed for non-pfMemory.\n");
} else {
fprintf(stderr, "pfDelete returned %d.\n", deleted);
}
}
--
Masanori Kakimoto mailto:kaki++at++nsg.sgi.com
East Asia Technology Network, Tokyo Center
c/o Nihon Silicon Graphics Cray
Tel:81-3-5488-1852 Fax:81-3-5420-2397
Voice mail: (external)81-3-5488-1863-1119 (internal)822-1119
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:55:10 PDT