#ifndef MEDUSA_BITS_DOMAINS_HALFLINKSREFINE_FWD_HPP_ #define MEDUSA_BITS_DOMAINS_HALFLINKSREFINE_FWD_HPP_ /** * @file * Declaration of the half-link refinement algorithm. * * @example test/domains/HalfLinksRefine_test.cpp */ #include #include #include "DomainDiscretization_fwd.hpp" namespace mm { template class KDTreeMutable; /** * Refine a region of nodes `region` by connecting every node in `region` to its support * domain and generating new nodes at half distances. The new nodes are filtered to meet a * minimum distance criterion to prevent points that would be too close. * * Usage example: * @snippet domains/HalfLinksRefine_test.cpp Half links usage example * @ingroup domains */ class HalfLinksRefine { Range region_ = {}; ///< Node indexes around which to refine. double fraction_ = 0.4; ///< Minimal distance fraction. public: /** * Set region to refine. The region is a set of indices of the nodes to be refined. * All nodes are refined by default. */ HalfLinksRefine& region(Range region) { region_ = std::move(region); return *this; } /** * Minimal distance criterion around point `p` is that nodes generated at `p` must be at least * `fraction * closest_support_node` away from all nodes. Fraction must be less than `1/2`. * Default value is HalfLinksRefine::fraction_; */ HalfLinksRefine& min_dist(double fraction) { fraction_ = fraction; return *this; } /** * Refines given domain. * @return The indexes of the added nodes in `positions`. */ template Range operator()(DomainDiscretization& domain) const; /** * Refine the domain with already given tree. * @param domain Domain discretization object, which will be refined. * @param tree A mutable KDTree, which contains all domain nodes. New nodes will be inserted. * @return The indexes of the added nodes in `positions`. */ template Range operator()(DomainDiscretization& domain, KDTreeMutable& tree) const; private: /** * Refine implementation with more control over fine grained details. * @param domain Domain to refine. * @param region A list of indices to refine. * @param fraction Minimal distance fraction. * @param domain_tree Tree containing all domain points. * @return List of indices of added nodes. */ template static Range refine_impl( DomainDiscretization& domain, const Range& region, double fraction, KDTreeMutable& domain_tree); }; } // namespace mm #endif // MEDUSA_BITS_DOMAINS_HALFLINKSREFINE_FWD_HPP_