void SeedListGenerator::convertSeedList(const SeedList& seeds, FeatureMap& features) { features.clear(true); // "true" should really be a default value here... Size counter = 0; for (SeedList::const_iterator seed_it = seeds.begin(); seed_it != seeds.end(); ++seed_it, ++counter) { Feature feature; feature.setRT(seed_it->getX()); feature.setMZ(seed_it->getY()); feature.setUniqueId(counter); features.push_back(feature); } // // assign unique ids: // features.applyMemberFunction(&UniqueIdInterface::setUniqueId); }
void discoverComponents(const CDT & ct, const SeedList& seeds) { if (ct.dimension() != 2) return; // tag all faces inside for(typename CDT::All_faces_iterator fit = ct.all_faces_begin(); fit != ct.all_faces_end(); ++fit) fit->set_in_domain(true); // mark "outside" infinite component of the object discoverInfiniteComponent(ct); // mark "outside" components with a seed for(typename SeedList::const_iterator sit = seeds.begin(); sit != seeds.end(); ++sit) { typename CDT::Face_handle fh_loc = ct.locate(*sit); if(fh_loc == NULL || !fh_loc->is_in_domain()) continue; std::list<typename CDT::Face_handle> queue; queue.push_back(fh_loc); while(!queue.empty()) { typename CDT::Face_handle f = queue.front(); queue.pop_front(); f->set_in_domain(false); for(int i = 0; i < 3; ++i) { typename CDT::Face_handle ni = f->neighbor(i); if(ni->is_in_domain() && !ct.is_constrained(typename CDT::Edge(f,i))) //same component { queue.push_back(ni); } } } } }
bool get_seed( SeedList & seeds, int & seed, SeedList::iterator & sit ) { for ( sit = seeds.begin(); sit != seeds.end(); sit++ ) if ( (*sit).seed == seed ) return true; return false; }
float ScalarImportance ::estimateNormalizationConstant(const boost::shared_ptr<RandomSequence> &r, const boost::shared_ptr<const Scene> &scene, const boost::shared_ptr<ShadingContext> &context, const boost::shared_ptr<PathMutator> &mutator, const size_t n, FunctionAllocator &allocator, PathSampler::HyperPoint &x, Path &xPath) { float result = 0; Spectrum L; // estimate b typedef std::vector<PathSampler::HyperPoint> SeedList; typedef std::vector<PathSampler::Result> ResultList; ResultList resultList; SeedList seeds; std::vector<float> seedImportance; float I; // XXX fix this PathSampler *sampler = const_cast<PathSampler*>(mutator->getSampler()); for(size_t i = 0; i < n; ++i) { PathSampler::constructHyperPoint(*r, x); // create a Path if(sampler->constructPath(*scene, *context, x, xPath)) { // evaluate the Path resultList.clear(); L = mutator->evaluate(xPath, resultList); I = evaluate(x, xPath, resultList); result += I; seeds.push_back(x); seedImportance.push_back(I); } // end if // free all integrands allocated in this sample context->freeAll(); } // end for i // pick a seed AliasTable<PathSampler::HyperPoint> aliasTable; aliasTable.build(seeds.begin(), seeds.end(), seedImportance.begin(), seedImportance.end()); x = aliasTable((*r)()); Path temp; sampler->constructPath(*scene, *context, x, temp); // copy temp to x temp.clone(xPath, allocator); // free all integrands that were allocated in the estimate context->freeAll(); return result / n; } // end ScalarImportance::estimateNormalizationConstant()