LibreCAD
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
geobezierbase.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "cad/const.h"
4 #include "geoarea.h"
5 #include "geocoordinate.h"
6 #include "geobase.h"
7 #include <cad/math/lcmath.h>
8 #include <cmath>
9 #include <cstdlib>
10 #include <vector>
11 
12 namespace lc {
13  namespace geo {
14  class BezierBase;
15  using BB_CSPtr = std::shared_ptr<const BezierBase>;
16  using BB_SPtr = std::shared_ptr<BezierBase>;
17 
18  class BezierBase : public Base, virtual public Visitable {
19  public:
20 
22  virtual ~BezierBase() {}
23 
28  virtual const Area boundingBox() const = 0;
29 
35  virtual Coordinate nearestPointOnPath(const Coordinate& coord) const = 0;
36 
42  virtual Coordinate nearestPointOnEntity(const Coordinate& coord) const = 0;
43 
50  virtual Coordinate CasteljauAt(std::vector<Coordinate> points, double t) const = 0;
51 
56  virtual const std::vector<Coordinate> getCP() const = 0;
57 
63  virtual Coordinate DirectValueAt(double t) const = 0;
64 
70  virtual const std::vector<Coordinate> Curve(double precession) = 0;
71 
76  virtual const double length() const = 0;
77 
83  virtual const Coordinate tangent(double t) const = 0;
84 
90  virtual const Coordinate normal(double t) const = 0;
91 
96  virtual std::vector<BB_CSPtr> splitHalf() const = 0;
97 
103  virtual BB_CSPtr splitAtT(double t) const = 0;
104 
110  virtual BB_CSPtr offset(const geo::Coordinate& offset) const = 0;
111 
118  virtual BB_CSPtr rotate(const geo::Coordinate& center, double angle) const = 0;
119 
126  virtual BB_CSPtr scale(const geo::Coordinate& center, const geo::Coordinate& factor) const = 0;
127 
133  virtual BB_CSPtr move(const geo::Coordinate& offset) const = 0;
134 
141  virtual BB_CSPtr mirror(const geo::Coordinate& axis1, const geo::Coordinate& axis2) const = 0;
142 
143  virtual void accept(GeoEntityVisitor &v) const override { v.visit(*this); }
144 
145  virtual std::vector<double> nearestPointTValue(const Coordinate &coord) const = 0;
147  double min_distance, const lc::geo::Coordinate &coord,
148  const Coordinate &ret) const = 0;
149  };
150  }
151 }
std::shared_ptr< BezierBase > BB_SPtr
Definition: geobezierbase.h:16
virtual std::vector< double > nearestPointTValue(const Coordinate &coord) const =0
virtual Coordinate DirectValueAt(double t) const =0
DirectValueAt Coordinate of bezier at time t calculated numerically.
virtual void accept(GeoEntityVisitor &v) const override
virtual const Coordinate tangent(double t) const =0
tangent of the bezeir
virtual BB_CSPtr splitAtT(double t) const =0
splitAtT Splits bezier at specific time.
virtual const std::vector< Coordinate > Curve(double precession)=0
Curve Creates a bezier curve for drawing with some precession value.
virtual const lc::geo::Coordinate returnCasesForNearestPoint(double min_distance, const lc::geo::Coordinate &coord, const Coordinate &ret) const =0
Definition: cadentity.h:12
virtual BB_CSPtr move(const geo::Coordinate &offset) const =0
move the bezeir by some offset
std::shared_ptr< const BezierBase > BB_CSPtr
Definition: geobezierbase.h:15
virtual const Coordinate normal(double t) const =0
normal of the bezier at time t
virtual const Area boundingBox() const =0
boundingBox of the bezier
virtual Coordinate nearestPointOnEntity(const Coordinate &coord) const =0
nearestPointOnEntity of the bezier
virtual BB_CSPtr mirror(const geo::Coordinate &axis1, const geo::Coordinate &axis2) const =0
mirror a bezier around a line
virtual Coordinate nearestPointOnPath(const Coordinate &coord) const =0
nearestPointOnPath of the bezier
virtual Coordinate CasteljauAt(std::vector< Coordinate > points, double t) const =0
CasteljauAt Coordinate of bezier at time t.
virtual BB_CSPtr rotate(const geo::Coordinate &center, double angle) const =0
rotate the bezier at specific center and some angle
virtual const double length() const =0
length of the Bezier
virtual BB_CSPtr scale(const geo::Coordinate &center, const geo::Coordinate &factor) const =0
scale the bezier at specific center by some factor
virtual const std::vector< Coordinate > getCP() const =0
getCP Returns the control points of the bezier
virtual std::vector< BB_CSPtr > splitHalf() const =0
splitHalf Splits the bezier into two halves.
virtual BB_CSPtr offset(const geo::Coordinate &offset) const =0
offset offsets the bezier.