7 using namespace entity;
15 const Layer_CSPtr layer,
16 const MetaInfo_CSPtr metaInfo,
17 const Block_CSPtr block) :
19 geo::
Ellipse(center, majorP, minorRadius, startAngle, endAngle, reversed) {
24 geo::
Ellipse(other->center(), other->majorP(), other->minorRadius(), other->startAngle(), other->endAngle(),
25 other->isReversed()) {
30 auto newellipse = std::make_shared<Ellipse>(this->
center() + offset,
38 newellipse->setID(this->
id());
43 auto newEllipse = std::make_shared<Ellipse>(this->
center() + offset,
55 auto rotated = this->
georotate(rotation_center, rotation_angle);
56 auto newEllipse = std::make_shared<Ellipse>(rotated.center(),
58 rotated.minorRadius(),
66 newEllipse->setID(this->
id());
71 auto scaled = this->
geoscale(scale_center, scale_factor);
72 auto newEllipse = std::make_shared<Ellipse>(scaled.center(),
83 newEllipse->setID(this->
id());
90 auto majP = maj - cen;
98 auto newEllipse = std::make_shared<Ellipse>(cen, majP,
107 newEllipse->setID(this->
id());
114 double minX, minY, maxX, maxY;
116 minX = points[0].x();
117 maxX = points[0].x();
118 minY = points[0].y();
119 maxY = points[0].y();
122 if (point.x() < minX)
124 if (point.x() > maxX)
126 if (point.y() < minY)
128 if (point.y() > maxY)
132 for (
const auto& point : points)
139 CADEntity_CSPtr
Ellipse::modify(Layer_CSPtr layer,
const MetaInfo_CSPtr metaInfo, Block_CSPtr block)
const {
140 auto newEntity = std::make_shared<Ellipse>(
152 newEntity->setID(this->
id());
159 std::vector<lc::geo::Coordinate> resPoints;
162 const double angle = this->
getAngle();
166 if (sin(angle) == 0) {
175 if (cos(angle) == 0) {
185 double tanAngle = std::tan(-this->
getAngle());
187 auto getY = [&](
double x) {
188 return -b * b * x / (a * a * tanAngle);
191 double x = a * a * tanAngle / (sqrt(a * a * tanAngle * tanAngle + b * b));
195 tanAngle = -1 / tanAngle;
196 x = a * a * tanAngle / (sqrt(a * a * tanAngle * tanAngle + b * b));
213 resPoints.push_back(cord);
225 std::vector<EntityCoordinate>
227 int maxNumberOfSnapPoints)
const {
229 std::vector<EntityCoordinate> resPoints;
235 resPoints.emplace_back(this->
center(), ind++);
239 resPoints.emplace_back(p, ind++);
242 minorP = minorP.
rotate(M_PI_2);
249 resPoints.emplace_back(tmp, ind++);
253 resPoints.emplace_back(tmp, ind++);
257 resPoints.emplace_back(tmp, ind++);
261 resPoints.emplace_back(tmp, ind++);
268 resPoints.emplace_back(nearestPoint, ind++);
274 resPoints.emplace_back(nearestPoint, ind++);
virtual std::vector< EntityCoordinate > snapPoints(const geo::Coordinate &coord, const SimpleSnapConstrain &constrain, double minDistanceToSnap, int maxNumberOfSnapPoints) const override
see interface Snapable
Coordinate mirror(const Coordinate &axis1, const Coordinate &axis2) const
mirror a coordinate
virtual CADEntity_CSPtr rotate(const geo::Coordinate &rotation_center, const double rotation_angle) const override
rotate, rotate operation
double startAngle() const
startAngle, Returns Start elliptic!! angle of ellipse
virtual CADEntity_CSPtr copy(const geo::Coordinate &offset) const override
copy, copies by an offset
virtual geo::Coordinate nearestPointOnPath(const geo::Coordinate &coord) const override
Find the nearest point on the path for this entity for the coordinate coord The path of a entity that...
std::vector< lc::geo::Coordinate > findBoxPoints() const
static const uint16_t LOGICAL
Coordinate startPoint() const
startPoint, start point of ellipse
virtual CADEntity_CSPtr modify(Layer_CSPtr layer, const MetaInfo_CSPtr metaInfo, Block_CSPtr block) const override
modify Return a new entity with the same ID bit with possible modified metainfo and/pr layer informat...
double getEllipseAngle(const Coordinate &coord) const
getEllipseAngle
static const uint16_t ON_ENTITYPATH
Ellipse geoscale(const Coordinate ¢er, const Coordinate &factor) const
scale an ellipse at some center by some factor
Layer_CSPtr layer() const
layer return the layer this entity is placed on
virtual CADEntity_CSPtr mirror(const geo::Coordinate &axis1, const geo::Coordinate &axis2) const override
MetaInfo_CSPtr metaInfo() const
static const uint16_t ON_ENTITY
Coordinate nearestPointOnPath(const Coordinate &coord) const
nearestPointOnPath, (ignore if it arc)
Coordinate rotate(const Coordinate &angleVector) const
rotate around (0.,0.) with a given angle vector
static void snapPointsCleanup(std::vector< EntityCoordinate > &points, const geo::Coordinate &reference, const unsigned int maxNumberOfSnapPoints, const double minDistanceToSnap)
Ellipse georotate(const Coordinate ¢er, const double rotation_angle) const
rotate an ellipse at a center by an angle
A ellipse that can be put in a drawing.
Block_CSPtr block() const
Return the current entity block.
virtual const geo::Area boundingBox() const override
boundingBox of the entity
virtual CADEntity_CSPtr scale(const geo::Coordinate &scale_center, const geo::Coordinate &scale_factor) const override
scale, scales the entity
double getAngle() const
getAngle of MajorP
double endAngle() const
endAngle, Return the end elliptic!! angle of ellipse
Coordinate endPoint() const
endPoint, end point of ellipse
const uint16_t constrain() const
virtual CADEntity_CSPtr move(const geo::Coordinate &offset) const override
move, moves by an offset
Ellipse(const geo::Coordinate ¢er, const geo::Coordinate &majorP, double minorRadius, double startAngle, double endAngle, bool reversed, const Layer_CSPtr layer, const MetaInfo_CSPtr metaInfo=nullptr, const Block_CSPtr block=nullptr)
Create ellipse.
const Coordinate center() const
center, Returns Center point of Ellipse
double minorRadius() const
minorRadius, Returns the minor radius of ellipse
Coordinate nearestPointOnEntity(const Coordinate &coord) const
nearestPointOnEntity, ( not ignore arc)
const Coordinate majorP() const
majorP, Returns major point of the ellipse, relative to center
bool isAngleBetween(double angle) const