/*private*/ void MCIndexSegmentSetMutualIntersector::addToIndex(SegmentString* segStr) { MonoChains segChains; MonotoneChainBuilder::getChains(segStr->getCoordinates(), segStr, segChains); MonoChains::size_type n = segChains.size(); chainStore.reserve(chainStore.size() + n); for (MonoChains::size_type i = 0; i < n; i++) { MonotoneChain * mc = segChains[i]; mc->setId(indexCounter++); index->insert(&(mc->getEnvelope()), mc); chainStore.push_back(mc); } }
/*private*/ void MCIndexNoder::intersectChains() { assert(segInt); SegmentOverlapAction overlapAction(*segInt); for (vector<MonotoneChain*>::iterator i=monoChains.begin(), iEnd=monoChains.end(); i != iEnd; ++i) { GEOS_CHECK_FOR_INTERRUPTS(); MonotoneChain* queryChain = *i; assert(queryChain); vector<void*> overlapChains; index.query(&(queryChain->getEnvelope()), overlapChains); for (vector<void*>::iterator j=overlapChains.begin(), jEnd=overlapChains.end(); j != jEnd; ++j) { MonotoneChain* testChain = static_cast<MonotoneChain*>(*j); assert(testChain); /** * following test makes sure we only compare each * pair of chains once and that we don't compare a * chain to itself */ if (testChain->getId() > queryChain->getId()) { queryChain->computeOverlaps(testChain, &overlapAction); nOverlaps++; } // short-circuit if possible if (segInt->isDone()) return; } } }
/*private*/ void MCIndexNoder::add(SegmentString* segStr) { vector<MonotoneChain*> segChains; // segChains will contain nelwy allocated MonotoneChain objects MonotoneChainBuilder::getChains(segStr->getCoordinates(), segStr, segChains); for(vector<MonotoneChain*>::iterator it=segChains.begin(), iEnd=segChains.end(); it!=iEnd; ++it) { MonotoneChain* mc = *it; assert(mc); mc->setId(idCounter++); index.insert(&(mc->getEnvelope()), mc); // MonotoneChain objects deletion delegated to destructor monoChains.push_back(mc); } }
/*private*/ void MCIndexSegmentSetMutualIntersector::intersectChains() { MCIndexSegmentSetMutualIntersector::SegmentOverlapAction overlapAction( *segInt); for (MonoChains::size_type i = 0, ni = monoChains.size(); i < ni; ++i) { MonotoneChain * queryChain = (MonotoneChain *)monoChains[i]; std::vector<void*> overlapChains; index->query( &(queryChain->getEnvelope()), overlapChains); for (std::size_t j = 0, nj = overlapChains.size(); j < nj; j++) { MonotoneChain * testChain = (MonotoneChain *)(overlapChains[j]); queryChain->computeOverlaps( testChain, &overlapAction); nOverlaps++; if (segInt->isDone()) return; } } }