17 _name(name), _description(description), _path(path), _length(length) {
23 _name(builder.name()),
24 _description(builder.description()),
25 _path(builder.path()),
26 _length(calculatePathLength(builder.path())) {
31 return std::fabs(std::accumulate(_path.begin(), _path.end(), 0.));
43 std::vector<double> dxfPat;
45 if (dxfPattern.size() == 0) {
49 double last = dxfPattern.at(0);
51 for (
auto d : dxfPattern) {
54 dxfPat.push_back(lineWidth);
57 dxfPat.push_back(lineWidth);
64 dxfPat.push_back(std::fabs(d));
67 dxfPat.push_back(std::fabs(d));
78 last = last + std::fabs(d);
83 double mul = length / last;
84 for (
unsigned int i = 0; i < dxfPat.size(); i++) {
85 dxfPat[i] = dxfPat[i] * mul;
95 catch (std::out_of_range &e) {
static double calculatePathLength(const std::vector< double > &_path)
virtual std::string description() const
const std::vector< double > lcPattern(double lineWidth=1) const
Get cached LibreCAD compatible pattern.
const std::vector< double > & path() const
const std::string name() const override
std::map< double, std::vector< double > > _lcPatterns
std::string description() const override
virtual const std::string name() const override
std::vector< double > _path
std::vector< double > generatePattern(const std::vector< double > &dxfPattern, const double length, const double lineWidth) const
Generate new LibreCAD compatible pattern.
static bool isBlank(const std::string str)