#ifndef LIBNEST2D_H #define LIBNEST2D_H // The type of backend should be set conditionally by the cmake configuriation // for now we set it statically to clipper backend #ifdef LIBNEST2D_BACKEND_CLIPPER #include #endif #ifdef LIBNEST2D_OPTIMIZER_NLOPT // We include the stock optimizers for local and global optimization #include // Local subplex for NfpPlacer #include // Genetic for min. bounding box #endif #include #include #include #include #include #include namespace libnest2d { using Point = PointImpl; using Coord = TCoord; using Box = _Box; using Segment = _Segment; using Circle = _Circle; using Item = _Item; using Rectangle = _Rectangle; using PackGroup = _PackGroup; using FillerSelection = selections::_FillerSelection; using FirstFitSelection = selections::_FirstFitSelection; using DJDHeuristic = selections::_DJDHeuristic; template // Generic placer for arbitrary bin types using _NfpPlacer = placers::_NofitPolyPlacer; // NfpPlacer is with Box bin using NfpPlacer = _NfpPlacer; // This supports only box shaped bins using BottomLeftPlacer = placers::_BottomLeftPlacer; #ifdef LIBNEST2D_STATIC extern template class Nester; extern template class Nester; extern template std::size_t Nester::execute( std::vector::iterator, std::vector::iterator); extern template std::size_t Nester::execute( std::vector::iterator, std::vector::iterator); #endif template struct NestConfig { typename Placer::Config placer_config; typename Selector::Config selector_config; using Placement = typename Placer::Config; using Selection = typename Selector::Config; NestConfig() = default; NestConfig(const typename Placer::Config &cfg) : placer_config{cfg} {} NestConfig(const typename Selector::Config &cfg) : selector_config{cfg} {} NestConfig(const typename Placer::Config & pcfg, const typename Selector::Config &scfg) : placer_config{pcfg}, selector_config{scfg} {} }; struct NestControl { ProgressFunction progressfn; StopCondition stopcond = []{ return false; }; NestControl() = default; NestControl(ProgressFunction pr) : progressfn{std::move(pr)} {} NestControl(StopCondition sc) : stopcond{std::move(sc)} {} NestControl(ProgressFunction pr, StopCondition sc) : progressfn{std::move(pr)}, stopcond{std::move(sc)} {} }; template::iterator> std::size_t nest(Iterator from, Iterator to, const typename Placer::BinType & bin, Coord dist = 0, const NestConfig &cfg = {}, NestControl ctl = {}) { _Nester nester{bin, dist, cfg.placer_config, cfg.selector_config}; if(ctl.progressfn) nester.progressIndicator(ctl.progressfn); if(ctl.stopcond) nester.stopCondition(ctl.stopcond); return nester.execute(from, to); } #ifdef LIBNEST2D_STATIC extern template class Nester; extern template class Nester; extern template std::size_t nest(std::vector::iterator from, std::vector::iterator from to, const Box & bin, Coord dist, const NestConfig &cfg, NestControl ctl); extern template std::size_t nest(std::vector::iterator from, std::vector::iterator from to, const Box & bin, Coord dist, const NestConfig &cfg, NestControl ctl); #endif template> std::size_t nest(Container&& cont, const typename Placer::BinType & bin, Coord dist = 0, const NestConfig &cfg = {}, NestControl ctl = {}) { return nest(cont.begin(), cont.end(), bin, dist, cfg, ctl); } } #endif // LIBNEST2D_H