From: Steve Satterfield (steve++at++nist.gov)
Date: 02/13/2003 14:46:22
On Tue, 11 Feb 2003, Paolo Farinelli wrote:
>
> For the moment, I guess Steve could work around this by creating a
> pfGroup and
> adding the loaded node (which can be a pfGroup or a pfGeode) to this
> group, then
> assigning a name to this group.. He will then be able to find it through
> either
> pfLookupNode( nodeName, pfGetNodeClassType() ) or
> pfLookupNode( nodeName, pfGetGroupClassType() ),
>
>
> Hope this helps,
> ciao,
> Paolo
>
Hi,
A very big thank you to everyone that answered my question so quickly. I
implemented the suggested work around and it solves the problem in my test
case. I am sure this will also solve the problem in my actual loader I am
working on.
Thanks again,
Steve
PS. In case anyone is interested, here is the working test case.
/*
* pftiv.c - contrive an example ".tiv" loader to test my problem
* with indirect loading of Inventor files.
*
* Steve Satterfield <steve++at++nist.gov>
*
* The .tiv file contains the name of an Inventor file to load.
* The loader will load it and add a second reference translated
* a short distance.
*/
#define VERSION "2/13/2003"
#include <Performer/pfdu.h>
extern pfNode *
pfdLoadFile_tiv (char *filename)
{
float tx=10.0, ty=0.0, tz=0.0;
FILE *fp;
char objfilename[80], *objname="ivobjname";
pfGroup *group, *subgroup;
pfSCS *trans_scs;
pfNode *object;
pfMatrix m;
fp = fopen(filename, "r");
group=pfNewGroup();
subgroup=pfNewGroup();
/* Read file name from the input file */
if (fscanf(fp, "%s",objfilename) == EOF) {
pfNotify(PFNFY_NOTICE, PFNFY_PRINT,
" pfdLoadFile_tiv: Warning file '%s' not found", objfilename);
return((pfNode*)NULL);
}
if (!pfdInitConverter(objfilename)) {
pfNotify(PFNFY_NOTICE, PFNFY_PRINT,
" pfdLoadFile_tiv: Warning loader for '%s' not found", objfilename);
return((pfNode*)NULL);
}
/* Load and add the initial object to the group */
object = pfdLoadFile(objfilename);
pfAddChild(subgroup, object);
pfAddChild(group, object);
/* Store a name for the object */
fprintf(stderr,"Set objectname to '%s' \n",objname);
if (pfNodeName(subgroup, objname) == 0) {
pfNotify(PFNFY_NOTICE, PFNFY_PRINT,
" pfdLoadFile_tiv: Warning objectname '%s' is not unique", objname);
}
fprintf(stderr,"Stored object name is '%s'\n", pfGetNodeName(subgroup));
/* Find the object based on its stored name */
fprintf(stderr,"Look up name '%s'\n",objname);
object = (pfNode*) pfLookupNode(objname, pfGetNodeClassType());
if (object == NULL) {
pfNotify(PFNFY_NOTICE, PFNFY_PRINT,
" pfdLoadFile_tiv: Warning objectname '%s' not found", objname);
}
fprintf(stderr,"Stored node name = '%s'\n", pfGetNodeName(subgroup));
/* Create a translated instance and add that to the group */
fprintf(stderr,"Add instance translated by %g %g %g\n",tx,ty,tz);
pfMakeTransMat(m, tx,ty,tz);
trans_scs=pfNewSCS(m);
pfAddChild(trans_scs, object);
pfAddChild(group, trans_scs);
fclose(fp);
pfNotify(PFNFY_NOTICE, PFNFY_PRINT,
" pfdLoadFile_tiv (%s): %s completed",VERSION,filename);
return((pfNode*)group);
}
This archive was generated by hypermail 2b29 : Thu Feb 13 2003 - 14:48:14 PST