Пример #1
0
void
countPrimitives(SoNode *root, int32_t &numTris, int32_t &numLines, int32_t &numPoints,
		int32_t &numNodes)
//
////////////////////////////////////////////////////////////////////////
{
    numTris = 0;
    numLines = 0;
    numPoints = 0;
    numNodes = 0;
    SoCallbackAction	ca;

    ca.addPointCallback(SoShape::getClassTypeId(),
			   countPointsCB,
			   (void *) &numPoints);
    ca.addLineSegmentCallback(SoShape::getClassTypeId(),
			   countLinesCB,
			   (void *) &numLines);
    ca.addTriangleCallback(SoShape::getClassTypeId(),
			   countTriangleCB,
			   (void *) &numTris);
    ca.addPreCallback( SoNode::getClassTypeId(),
			countNodesCB, (void *)&numNodes
		    );
    ca.apply(root);
}
Пример #2
0
void
IfReporter::reportNodeCount(const char *msg, SoNode *root)
{
    if (! verbose)
	return;

    int nodeCount = 0;

    SoCallbackAction cba;
    cba.addPreCallback(SoNode::getClassTypeId(), countCB, &nodeCount);
    cba.apply(root);

    fprintf(fp, "%s: %d nodes\n", msg, nodeCount);
}
Пример #3
0
OSUInventorScene::OSUInventorScene(char *filename) {

   SoSeparator *root = ReadScene(filename);
   int numNodes = 0;

   SoCallbackAction ca;
   SoSearchAction SA;
   SA.setType(SoLight::getClassTypeId(), TRUE);
   SA.setInterest(SoSearchAction::ALL);
   SA.apply(root);
   SoPathList &paths = SA.getPaths();
#ifdef DEBUG
   cerr << "There are " << paths.getLength() << " lights " << endl;
#endif
   int i;
   for (i = 0; i < paths.getLength(); i++) {
       Lights.append(paths[i]->getTail()->copy());
   }

   SA.setType(SoCamera::getClassTypeId(), TRUE);
   SA.setInterest(SoSearchAction::FIRST);
   SA.apply(root);
   if (SA.getPath()) {
       Camera = (SoCamera *)SA.getPath()->getTail()->copy();
#ifdef DEBUG
       cerr << "Found a camera!\n";
#endif
   } else
       Camera = NULL;

   ca.addPreCallback(SoNode::getClassTypeId(), processNodesCB, (void *)
       &Objects);
   ca.apply(root);
   // Now lets find the lights and camera!
   //

#ifdef DEBUG
   cerr << "There are " << Objects.getLength() << " shape objects left!\n";
#endif
}