void BoundsCreator::create() { std::string outpath = m_stack.getSuperpixelBoundsPath(); // Check if it already exists struct stat buf; if (stat(outpath.c_str(), &buf) == 0) { fprintf(stderr, "ERROR: superpixel_bounds.txt already exists\n"); fprintf(stderr, "ERROR: delete first to recreate.\n"); exit(1); } m_outf = fopen(outpath.c_str(), "w"); if (!m_outf) { fprintf(stderr, "Cannot open output file: %s\n", outpath.c_str()); return; } // Write the header fprintf(m_outf, "# superpixel bounding boxes and volumes\n"); fprintf(m_outf, "# plane\tsp\tx y width height volume\n\n"); printf("Rows=%d\n", m_stack.getNumRows(0)); printf("Cols=%d\n", m_stack.getNumCols(0)); int zmin = m_stack.getMetadataValue("zmin"); int zmax = m_stack.getMetadataValue("zmax"); printf("zmin=%d\n", zmin); printf("zmax=%d\n", zmax); for (int z = zmin; z < zmax + 1; ++z) { processPlane(z); } fclose(m_outf); }
bool Parser::processObject() { std::string strType; if(!readBloqueTxt("type", strType)) return false; if(strType == "plane") { if(!processPlane()) return false; } else if(strType == "sphere") { if(!processSphere()) return false; } else if(strType == "cylinder") { if(!processCylinder()) return false; } else if(strType == "box") { if(!processBox()) return false; } else if(strType == "parallelogram") { if(!processParallelogram()) return false; } else if(strType == "triangle") { if(!processTriangle()) return false; } else if(strType == "mesh") { if(!processMesh()) return false; } else // Tipo de objeto desconocido. return false; return true; }
void DotSceneLoader::processNode(rapidxml::xml_node<>* XMLNode, Ogre::SceneNode *pParent) { // Construct the node's name Ogre::String name = m_sPrependNode + getAttrib(XMLNode, "name"); // Create the scene node Ogre::SceneNode *pNode; if (name.empty()) { // Let Ogre choose the name if (pParent) pNode = pParent->createChildSceneNode(); else pNode = mAttachNode->createChildSceneNode(); } else { // Provide the name if (pParent) pNode = pParent->createChildSceneNode(name); else pNode = mAttachNode->createChildSceneNode(name); } // Process other attributes Ogre::String id = getAttrib(XMLNode, "id"); bool isTarget = getAttribBool(XMLNode, "isTarget"); rapidxml::xml_node<>* pElement; // Process position (?) pElement = XMLNode->first_node("position"); if (pElement) { pNode->setPosition(parseVector3(pElement)); pNode->setInitialState(); } // Process rotation (?) pElement = XMLNode->first_node("rotation"); if (pElement) { pNode->setOrientation(parseQuaternion(pElement)); pNode->setInitialState(); } // Process scale (?) pElement = XMLNode->first_node("scale"); if (pElement) { pNode->setScale(parseVector3(pElement)); pNode->setInitialState(); } // Process lookTarget (?) pElement = XMLNode->first_node("lookTarget"); if (pElement) processLookTarget(pElement, pNode); // Process trackTarget (?) pElement = XMLNode->first_node("trackTarget"); if (pElement) processTrackTarget(pElement, pNode); // Process node (*) pElement = XMLNode->first_node("node"); while (pElement) { processNode(pElement, pNode); pElement = pElement->next_sibling("node"); } // Process entity (*) pElement = XMLNode->first_node("entity"); while (pElement) { processEntity(pElement, pNode); pElement = pElement->next_sibling("entity"); } // Process light (*) //pElement = XMLNode->first_node("light"); //while(pElement) //{ // processLight(pElement, pNode); // pElement = pElement->next_sibling("light"); //} // Process camera (*) pElement = XMLNode->first_node("camera"); while (pElement) { processCamera(pElement, pNode); pElement = pElement->next_sibling("camera"); } // Process particleSystem (*) pElement = XMLNode->first_node("particleSystem"); while (pElement) { processParticleSystem(pElement, pNode); pElement = pElement->next_sibling("particleSystem"); } // Process billboardSet (*) pElement = XMLNode->first_node("billboardSet"); while (pElement) { processBillboardSet(pElement, pNode); pElement = pElement->next_sibling("billboardSet"); } // Process plane (*) pElement = XMLNode->first_node("plane"); while (pElement) { processPlane(pElement, pNode); pElement = pElement->next_sibling("plane"); } // Process userDataReference (?) pElement = XMLNode->first_node("userDataReference"); if (pElement) processUserDataReference(pElement, pNode); }
void DotSceneLoader::processNode(TiXmlElement *xmlNode, Node *pParent) { // Construct the node's name std::string name = getAttrib(xmlNode, "name"); // Create the scene node Node *node; if(name.empty()) { // Let Ogre choose the name if(pParent) { node = scene->createNode(); pParent->addChild(node); } else { node = scene->createNode(); rootNode->addChild(node); } } else { // Provide the name if(pParent) { node = scene->createNode(/*name*/); pParent->addChild(node); } else { node = scene->createNode(/*name*/); rootNode->addChild(node); } } // Process other attributes std::string id = getAttrib(xmlNode, "id"); bool isTarget = getAttribBool(xmlNode, "isTarget"); TiXmlElement *element; // Process position (?) element = xmlNode->FirstChildElement("position"); if(element) { node->setPosition(parseVector3(element)); } // Process rotation (?) element = xmlNode->FirstChildElement("rotation"); if(element) { node->setOrientation(parseQuaternion(element)); } // Process scale (?) element = xmlNode->FirstChildElement("scale"); if(element) { node->setScale(parseVector3(element)); } // Process lookTarget (?) element = xmlNode->FirstChildElement("lookTarget"); if(element) processLookTarget(element, node); // Process trackTarget (?) element = xmlNode->FirstChildElement("trackTarget"); if(element) processTrackTarget(element, node); // Process node (*) element = xmlNode->FirstChildElement("node"); while(element) { processNode(element, node); element = element->NextSiblingElement("node"); } // Process entity (*) element = xmlNode->FirstChildElement("entity"); while(element) { processEntity(element, node); element = element->NextSiblingElement("entity"); } // Process light (*) element = xmlNode->FirstChildElement("light"); while(element) { processLight(element, node); element = element->NextSiblingElement("light"); } // Process camera (*) element = xmlNode->FirstChildElement("camera"); while(element) { processCamera(element, node); element = element->NextSiblingElement("camera"); } // Process particleSystem (*) element = xmlNode->FirstChildElement("particleSystem"); while(element) { processParticleSystem(element, node); element = element->NextSiblingElement("particleSystem"); } // Process billboardSet (*) element = xmlNode->FirstChildElement("billboardSet"); while(element) { processBillboardSet(element, node); element = element->NextSiblingElement("billboardSet"); } // Process plane (*) element = xmlNode->FirstChildElement("plane"); while(element) { processPlane(element, node); element = element->NextSiblingElement("plane"); } // Process userDataReference (?) element = xmlNode->FirstChildElement("userDataReference"); if(element) processUserDataReference(element, node); }