void cpBBTreeSetVelocityFunc(cpSpatialIndex *index, cpBBTreeVelocityFunc func) { if(index->klass != Klass()){ cpAssertWarn(cpFalse, "Ignoring cpBBTreeSetVelocityFunc() call to non-tree spatial index."); return; } ((cpBBTree *)index)->velocityFunc = func; }
cpSpatialIndex * cpSweep1DInit(cpSweep1D *sweep, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) { cpSpatialIndexInit((cpSpatialIndex *)sweep, Klass(), bbfunc, staticIndex); sweep->num = 0; ResizeTable(sweep, 32); return (cpSpatialIndex *)sweep; }
void cpSpaceHashResize(cpSpaceHash *hash, cpFloat celldim, int numcells) { if(hash->spatialIndex.klass != Klass()){ cpAssertWarn(cpFalse, "Ignoring cpSpaceHashResize() call to non-cpSpaceHash spatial index."); return; } clearTable(hash); hash->celldim = celldim; cpSpaceHashAllocTable(hash, next_prime(numcells)); }
void run(Factory *f) { ontology::Ontology ontology(f, verbose); // Starting code Generation std::set<std::string> cppNameSpaces; for ( auto const& klassMapItem: ontology.classUri2Ptr()) { // created directory if needed createDirectory(Klass(*klassMapItem.second).genCppNameSpaceInclusionPath()); cppNameSpaces.insert(Klass(*klassMapItem.second).genCppNameSpace()); Klass(*klassMapItem.second).generateInterfaceDeclaration(); Klass(*klassMapItem.second).generateInterfaceDefinition(); Klass(*klassMapItem.second).generateDeclaration(); Klass(*klassMapItem.second).generateDefinition(); } // Generate all TypesInfo generateRdfTypeInfo(ontology); // Generate all inclusions files for ( const std::string& cppNameSpace : cppNameSpaces ) { std::ofstream ofs; createFile(Klass::outdir + "/" + cppNameSpace + "/" + cppNameSpace + ".h", &ofs); generateCodeProtectorBegin(ofs, cppNameSpace, cppNameSpace); for ( auto const& klassMapItem: ontology.classUri2Ptr()) { if ( Klass(*klassMapItem.second).genCppNameSpace() == cppNameSpace ) { const Klass& cls = *klassMapItem.second; ofs << "#include <" << cls.genCppNameSpaceInclusionPath() << "/" << klassMapItem.second->prettyIRIName() << ".h" << ">" << std::endl; } } ofs << std::endl; generateCodeProtectorEnd(ofs, cppNameSpace, cppNameSpace); } // Generate all in one cpp file if ( generateAllInOne ) { std::ofstream ofs; createFile(RdfsEntity::outdir + "/AllInOne.cpp", &ofs); addBoilerPlate(ofs); ofs << std::endl; ofs << "#include \"RdfTypeInfo.cpp\"" << std::endl; for ( auto const& klassMapItem: ontology.classUri2Ptr()) { const Klass& cls = *klassMapItem.second; ofs << "#include \"" << cls.genCppNameSpaceInclusionPath() << "/I" << klassMapItem.second->prettyIRIName() << ".cpp" << "\"" << std::endl; ofs << "#include \"" << cls.genCppNameSpaceInclusionPath() << "/" << klassMapItem.second->prettyIRIName() << ".cpp" << "\"" << std::endl; } ofs << std::endl; } }
static void cpBBTreeReindexQuery(cpBBTree *tree, cpSpatialIndexQueryFunc func, void *data) { if(!tree->root) return; // LeafUpdate() may modify tree->root. Don't cache it. cpHashSetEach(tree->leaves, (cpHashSetIteratorFunc)LeafUpdate, tree); cpSpatialIndex *staticIndex = tree->spatialIndex.staticIndex; Node *staticRoot = (staticIndex && staticIndex->klass == Klass() ? ((cpBBTree *)staticIndex)->root : NULL); MarkContext context = {tree, staticRoot, func, data}; MarkSubtree(tree->root, &context); if(staticIndex && !staticRoot) cpSpatialIndexCollideStatic((cpSpatialIndex *)tree, staticIndex, func, data); IncrementStamp(tree); }
cpSpatialIndex * cpBBTreeInit(cpBBTree *tree, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) { cpSpatialIndexInit((cpSpatialIndex *)tree, Klass(), bbfunc, staticIndex); tree->velocityFunc = NULL; tree->leaves = cpHashSetNew(0, (cpHashSetEqlFunc)leafSetEql); tree->root = NULL; tree->pooledNodes = NULL; tree->allocatedBuffers = cpArrayNew(0); tree->stamp = 0; return (cpSpatialIndex *)tree; }
cpSpatialIndex * cpSpaceHashInit(cpSpaceHash *hash, cpFloat celldim, int numcells, cpSpatialIndexBBFunc bbfunc, cpSpatialIndex *staticIndex) { cpSpatialIndexInit((cpSpatialIndex *)hash, Klass(), bbfunc, staticIndex); cpSpaceHashAllocTable(hash, next_prime(numcells)); hash->celldim = celldim; hash->handleSet = cpHashSetNew(0, (cpHashSetEqlFunc)handleSetEql); hash->pooledHandles = cpArrayNew(0); hash->pooledBins = NULL; hash->allocatedBuffers = cpArrayNew(0); hash->stamp = 1; return (cpSpatialIndex *)hash; }
static inline cpBBTree * GetTree(cpSpatialIndex *index) { return (index && index->klass == Klass() ? (cpBBTree *)index : NULL); }
static inline Node * GetRootIfTree(cpSpatialIndex *index){ return (index && index->klass == Klass() ? ((cpBBTree *)index)->root : NULL); }