void Sketch::finnish() { root->finnish(); processElements(root); tree = new QuadTree(&boundedObjects, 100); }
void Sketch::processElements(Group *group) { /* For all sketch elements in this group. */ for(int i = 0; i < group->getNumberOfSketchElements(); i++) { SketchElement *element = group->getSketchElement(i); /* Set the id. */ ids[element->getId()] = element; /* Add to the objects list. */ if(element->getType() == SKETCHELEMENTTYPE_PATH) boundedObjects.push_back((Path*) element); /* Recurse if we are dealing with a group. */ if(element->getType() == SKETCHELEMENTTYPE_GROUP) processElements((Group*) element); } }
// --------------------------------------------------------------------------- // Program entry point // --------------------------------------------------------------------------- int main(int argC, char* argV[]) { // Check command line and extract arguments. if (argC < 2) { usage(); return 1; } // cannot return out of catch-blocks lest exception-destruction // result in calls to destroyed memory handler! int errorCode = 0; try { XMLPlatformUtils::Initialize(); } catch (const XMLException& toCatch) { XERCES_STD_QUALIFIER cerr << "Error during initialization! Message:\n" << StrX(toCatch.getMessage()) << XERCES_STD_QUALIFIER endl; errorCode = 2; } if(errorCode) { XMLPlatformUtils::Terminate(); return errorCode; } bool doList = false; bool schemaFullChecking = false; const char* xsdFile = 0; int argInd; for (argInd = 1; argInd < argC; argInd++) { // Break out on first parm not starting with a dash if (argV[argInd][0] != '-') break; // Watch for special case help request if (!strcmp(argV[argInd], "-?")) { usage(); return 1; } else if (!strcmp(argV[argInd], "-l") || !strcmp(argV[argInd], "-L")) { doList = true; } else if (!strcmp(argV[argInd], "-f") || !strcmp(argV[argInd], "-F")) { schemaFullChecking = true; } else { XERCES_STD_QUALIFIER cerr << "Unknown option '" << argV[argInd] << "', ignoring it\n" << XERCES_STD_QUALIFIER endl; } } // // There should be only one and only one parameter left, and that // should be the file name. // if (argInd != argC - 1) { usage(); return 1; } XMLGrammarPool *grammarPool; SAX2XMLReader* parser; try { grammarPool = new XMLGrammarPoolImpl(XMLPlatformUtils::fgMemoryManager); parser = XMLReaderFactory::createXMLReader(XMLPlatformUtils::fgMemoryManager, grammarPool); parser->setFeature(XMLUni::fgSAX2CoreNameSpaces, true); parser->setFeature(XMLUni::fgXercesSchema, true); parser->setFeature(XMLUni::fgXercesSchemaFullChecking, schemaFullChecking); parser->setFeature(XMLUni::fgSAX2CoreNameSpacePrefixes, false); parser->setFeature(XMLUni::fgSAX2CoreValidation, true); parser->setFeature(XMLUni::fgXercesDynamic, true); parser->setProperty(XMLUni::fgXercesScannerName, (void *)XMLUni::fgSGXMLScanner); SCMPrintHandler handler; parser->setErrorHandler(&handler); bool more = true; bool parsedOneSchemaOkay = false; XERCES_STD_QUALIFIER ifstream fin; // the input is a list file if (doList) fin.open(argV[argInd]); if (fin.fail()) { XERCES_STD_QUALIFIER cerr <<"Cannot open the list file: " << argV[argInd] << XERCES_STD_QUALIFIER endl; return 3; } while (more) { char fURI[1000]; //initialize the array to zeros memset(fURI,0,sizeof(fURI)); if (doList) { if (! fin.eof() ) { fin.getline (fURI, sizeof(fURI)); if (!*fURI) continue; else { xsdFile = fURI; XERCES_STD_QUALIFIER cerr << "==Parsing== " << xsdFile << XERCES_STD_QUALIFIER endl; } } else break; } else { xsdFile = argV[argInd]; more = false; } parser->loadGrammar(xsdFile, Grammar::SchemaGrammarType, true); if (handler.getSawErrors()) { handler.resetErrors(); } else { parsedOneSchemaOkay = true; } } if (parsedOneSchemaOkay) { XERCES_STD_QUALIFIER cout << "********** Printing out information from Schema **********" << "\n\n"; bool updatedXSModel; XSModel *xsModel = grammarPool->getXSModel(updatedXSModel); if (xsModel) { StringList *namespaces = xsModel->getNamespaces(); for (unsigned i = 0; i < namespaces->size(); i++) { XERCES_STD_QUALIFIER cout << "Processing Namespace: "; const XMLCh *nameSpace = namespaces->elementAt(i); if (nameSpace && *nameSpace) XERCES_STD_QUALIFIER cout << StrX(nameSpace); XERCES_STD_QUALIFIER cout << "\n============================================" << XERCES_STD_QUALIFIER endl << XERCES_STD_QUALIFIER endl; processElements(xsModel->getComponentsByNamespace(XSConstants::ELEMENT_DECLARATION, nameSpace)); processTypeDefinitions(xsModel->getComponentsByNamespace(XSConstants::TYPE_DEFINITION, nameSpace)); } } else { XERCES_STD_QUALIFIER cout << "No XSModel to print" << "\n\n"; } } else { XERCES_STD_QUALIFIER cout << "Did not parse a schema document cleanly so not printing Schema for Schema XSModel information"; } XERCES_STD_QUALIFIER cout << XERCES_STD_QUALIFIER endl; } catch (const OutOfMemoryException&) { XERCES_STD_QUALIFIER cerr << "OutOfMemoryException during parsing: '" << xsdFile << "'\n" << XERCES_STD_QUALIFIER endl; errorCode = 6; } catch (const XMLException& e) { XERCES_STD_QUALIFIER cerr << "\nError during parsing: '" << xsdFile << "'\n" << "Exception message is: \n" << StrX(e.getMessage()) << XERCES_STD_QUALIFIER endl; errorCode = 4; } catch (...) { XERCES_STD_QUALIFIER cerr << "\nUnexpected exception during parsing: '" << xsdFile << "'\n" << XERCES_STD_QUALIFIER endl; errorCode = 5; } delete parser; delete grammarPool; XMLPlatformUtils::Terminate(); return errorCode; }