LibreCAD
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
lc::entity::Point Class Reference

#include <point.h>

Inheritance diagram for lc::entity::Point:
Collaboration diagram for lc::entity::Point:

Public Member Functions

 Point (geo::Coordinate const &coord, const Layer_CSPtr layer, const MetaInfo_CSPtr metaInfo=nullptr, const Block_CSPtr block=nullptr)
 Coordinate, Default Coordinate Constructor. More...
 
 Point (const double x, const double y, const Layer_CSPtr layer, const MetaInfo_CSPtr metaInfo=nullptr, const Block_CSPtr block=nullptr)
 Coordinate, Coordinate constructor with metatypes. More...
 
 Point (const Point_CSPtr other, bool sameID=false)
 
virtual CADEntity_CSPtr move (const geo::Coordinate &offset) const override
 move, moves by an offset More...
 
virtual CADEntity_CSPtr copy (const geo::Coordinate &offset) const override
 copy, copies by an offset More...
 
virtual CADEntity_CSPtr rotate (const geo::Coordinate &rotation_center, const double rotation_angle) const override
 rotate, rotate operation More...
 
virtual CADEntity_CSPtr scale (const geo::Coordinate &scale_center, const geo::Coordinate &scale_factor) const override
 scale, scales the entity More...
 
virtual CADEntity_CSPtr mirror (const geo::Coordinate &axis1, const geo::Coordinate &axis2) const override
 
virtual const geo::Area boundingBox () const override
 boundingBox of the entity More...
 
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 information #return new entity with same ID More...
 
virtual void accept (GeoEntityVisitor &v) const override
 
virtual void dispatch (EntityDispatch &ed) const override
 
- Public Member Functions inherited from lc::entity::CADEntity
 CADEntity ()
 
 CADEntity (Layer_CSPtr layer, const MetaInfo_CSPtr metaInfo=nullptr, const Block_CSPtr block=nullptr)
 CADEntity Constructor. More...
 
 CADEntity (CADEntity_CSPtr cadEntity, bool sameID)
 
 CADEntity (CADEntity_CSPtr cadEntity)
 
virtual ~CADEntity ()=default
 
Layer_CSPtr layer () const
 layer return the layer this entity is placed on More...
 
template<typename T >
const std::shared_ptr< const T > metaInfo (std::string metaName) const
 
MetaInfo_CSPtr metaInfo () const
 
Block_CSPtr block () const
 Return the current entity block. More...
 
- Public Member Functions inherited from lc::ID
 ID ()
 Default constructor, provides a new unique ID to each entity. More...
 
 ID (ID_DATATYPE)
 
virtual ~ID ()=default
 
ID_DATATYPE id () const
 returns the ID of the entity More...
 
bool operator== (const ID &id) const
 
void setID (ID_DATATYPE id)
 
- Public Member Functions inherited from lc::Visitable
virtual ~Visitable ()=default
 
- Public Member Functions inherited from lc::geo::Coordinate
 Coordinate ()
 
 Coordinate (double x, double y, double z)
 
 Coordinate (double x, double y)
 
 Coordinate (double angle)
 
 Coordinate (Coordinate &&c) noexcept
 
 Coordinate (const Coordinate &c)
 
double x () const
 Returns x of Coordinate. More...
 
double y () const
 Returns y of Coordinate. More...
 
double z () const
 Returns z of Coordinate. More...
 
Coordinateoperator= (const Coordinate &coord)
 
Coordinate flipXY () const
 flips the x and y of Coordinate More...
 
double angleTo (const Coordinate &v) const
 Returns angle To the coordinate. More...
 
double angleBetween (const Coordinate &v1, const Coordinate &v2) const
 
bool operator== (const Coordinate &coord) const
 checks for the equality of Coordinate More...
 
bool operator!= (const Coordinate &coord) const
 
double distanceTo (const geo::Coordinate &c) const
 
Coordinate operator+ (const Coordinate &coord) const
 
Coordinate operator+ (double d) const
 operator + for offset addition More...
 
Coordinate operator- (double d) const
 operator + for offset addition More...
 
Coordinate operator- () const
 operator - More...
 
Coordinate operator- (const Coordinate &coord) const
 
Coordinate operator* (const Coordinate &coord) const
 
Coordinate operator* (double s) const
 
Coordinate operator/ (double s) const
 
double magnitude () const
 
double angle () const
 
double squared () const
 
double dot (const Coordinate &coord) const
 
double dot (const Coordinate &v1, const Coordinate &v2) const
 
Coordinate rotate (const Coordinate &angleVector) const
 rotate around (0.,0.) with a given angle vector More...
 
Coordinate rotate (const double &angle) const
 rotate around (0.,0.) with a given angle More...
 
Coordinate rotate (const geo::Coordinate &point, const Coordinate &angleVector) const
 rotate around a point with a angle vector More...
 
Coordinate rotate (const geo::Coordinate &point, const double &angle) const
 rotate around a point with a angle More...
 
Coordinate rotateByArcLength (const geo::Coordinate &point, double const length) const
 rotate around a point where the rotation described length is known Example More...
 
Coordinate scale (const double &scale_factor) const
 
Coordinate scale (const Coordinate &scale_factor) const
 
Coordinate scale (const Coordinate &scale_center, const Coordinate &scale_factor) const
 
Coordinate mid (const Coordinate &other) const
 
Coordinate norm () const
 
Coordinate norm (const double f) const
 
Coordinate move (const Coordinate &direction, double d) const
 
Coordinate moveTo (const Coordinate &to, double d) const
 
Coordinate transform2d (double xx, double yx, double xy, double yy, double x0, double y0)
 
Coordinate mirror (const Coordinate &axis1, const Coordinate &axis2) const
 mirror a coordinate More...
 

Private Member Functions

 Point (const builder::PointBuilder &builder)
 

Friends

class builder::PointBuilder
 

Additional Inherited Members

- Static Public Attributes inherited from lc::ID
static std::atomic< ID_DATATYPE__idCounter
 
- Protected Member Functions inherited from lc::entity::CADEntity
 CADEntity (const lc::builder::CADEntityBuilder &builder)
 

Detailed Description

Definition at line 17 of file point.h.

Constructor & Destructor Documentation

Point::Point ( geo::Coordinate const &  coord,
const Layer_CSPtr  layer,
const MetaInfo_CSPtr  metaInfo = nullptr,
const Block_CSPtr  block = nullptr 
)

Coordinate, Default Coordinate Constructor.

Parameters
geo::Coordinatecoord
Layer_CSPtrlayer
MetaTypes_CSPtrmetaTypes

Definition at line 17 of file point.cpp.

18  :
20  geo::Coordinate(coord) {
21 }
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
MetaInfo_CSPtr metaInfo() const
Definition: cadentity.h:123
Block_CSPtr block() const
Return the current entity block.
Definition: cadentity.cpp:33
Point::Point ( const double  x,
const double  y,
const Layer_CSPtr  layer,
const MetaInfo_CSPtr  metaInfo = nullptr,
const Block_CSPtr  block = nullptr 
)

Coordinate, Coordinate constructor with metatypes.

Parameters
doublex
doubley
Layer_CSPtrlayer
MetaTypes_CSPtrmetaTypes

Definition at line 11 of file point.cpp.

12  :
14  geo::Coordinate(x, y) {
15 }
double x() const
Returns x of Coordinate.
Definition: geocoordinate.h:26
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
double y() const
Returns y of Coordinate.
Definition: geocoordinate.h:34
MetaInfo_CSPtr metaInfo() const
Definition: cadentity.h:123
Block_CSPtr block() const
Return the current entity block.
Definition: cadentity.cpp:33
Point::Point ( const Point_CSPtr  other,
bool  sameID = false 
)

Definition at line 23 of file point.cpp.

23  : CADEntity(other, sameID), geo::Coordinate(other->x(), other->y()) {
24 }
Point::Point ( const builder::PointBuilder builder)
private

Definition at line 26 of file point.cpp.

26  :
27  CADEntity(builder),
28  geo::Coordinate(builder.coordinate()) {
29 }
const geo::Coordinate & coordinate() const
Definition: point.cpp:11

Member Function Documentation

virtual void lc::entity::Point::accept ( GeoEntityVisitor v) const
inlineoverridevirtual

Reimplemented from lc::entity::CADEntity.

Definition at line 91 of file point.h.

91 { v.visit(*this); }
const geo::Area Point::boundingBox ( ) const
overridevirtual

boundingBox of the entity

Returns
geo::Area area

Implements lc::entity::CADEntity.

Definition at line 63 of file point.cpp.

63  {
64  return geo::Area(geo::Coordinate(this->x(), this->y()), 0., 0.);
65 }
double x() const
Returns x of Coordinate.
Definition: geocoordinate.h:26
double y() const
Returns y of Coordinate.
Definition: geocoordinate.h:34
CADEntity_CSPtr Point::copy ( const geo::Coordinate offset) const
overridevirtual

copy, copies by an offset

Parameters
geo::Coordinateoffset
Returns
CADEntity_CSPtr copied entity

Implements lc::entity::CADEntity.

Definition at line 37 of file point.cpp.

37  {
38  auto newCoordinate = std::make_shared<Point>(this->x() + offset.x(), this->y() + offset.y(), layer());
39  return newCoordinate;
40 }
double x() const
Returns x of Coordinate.
Definition: geocoordinate.h:26
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
double y() const
Returns y of Coordinate.
Definition: geocoordinate.h:34
virtual void lc::entity::Point::dispatch ( EntityDispatch ed) const
inlineoverridevirtual

Implements lc::entity::CADEntity.

Definition at line 93 of file point.h.

93  {
94  ed.visit(shared_from_this());
95  }
CADEntity_CSPtr Point::mirror ( const geo::Coordinate axis1,
const geo::Coordinate axis2 
) const
overridevirtual

Implements lc::entity::CADEntity.

Definition at line 56 of file point.cpp.

56  {
57  auto rotcord = geo::Coordinate(this->x(), this->y()).rotate(axis1, axis2);
58  auto newCoordinate = std::make_shared<Point>(rotcord.x(), rotcord.y(), layer());
59  newCoordinate->setID(this->id());
60  return newCoordinate;
61 }
double x() const
Returns x of Coordinate.
Definition: geocoordinate.h:26
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
double y() const
Returns y of Coordinate.
Definition: geocoordinate.h:34
Coordinate rotate(const Coordinate &angleVector) const
rotate around (0.,0.) with a given angle vector
CADEntity_CSPtr Point::modify ( Layer_CSPtr  layer,
const MetaInfo_CSPtr  metaInfo,
Block_CSPtr  block 
) const
overridevirtual

modify Return a new entity with the same ID bit with possible modified metainfo and/pr layer information #return new entity with same ID

Implements lc::entity::CADEntity.

Definition at line 67 of file point.cpp.

67  {
68  auto newEntity = std::make_shared<Point>(this->x(), this->y(),
69  layer,
70  metaInfo,
71  block
72  );
73  newEntity->setID(this->id());
74 
75  return newEntity;
76 }
double x() const
Returns x of Coordinate.
Definition: geocoordinate.h:26
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
double y() const
Returns y of Coordinate.
Definition: geocoordinate.h:34
MetaInfo_CSPtr metaInfo() const
Definition: cadentity.h:123
Block_CSPtr block() const
Return the current entity block.
Definition: cadentity.cpp:33
CADEntity_CSPtr Point::move ( const geo::Coordinate offset) const
overridevirtual

move, moves by an offset

Parameters
geo::Coordinateoffset
Returns
CADEntity_CSPtr moved entity

Implements lc::entity::CADEntity.

Definition at line 31 of file point.cpp.

31  {
32  auto newCoordinate = std::make_shared<Point>(this->x() + offset.x(), this->y() + offset.y(), layer());
33  newCoordinate->setID(this->id());
34  return newCoordinate;
35 }
double x() const
Returns x of Coordinate.
Definition: geocoordinate.h:26
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
double y() const
Returns y of Coordinate.
Definition: geocoordinate.h:34
CADEntity_CSPtr Point::rotate ( const geo::Coordinate rotation_center,
const double  rotation_angle 
) const
overridevirtual

rotate, rotate operation

Parameters
geo::Coordinaterotation_center
doublerotation_angle
Returns
CADEntity_CSPtr rotated entity

Implements lc::entity::CADEntity.

Definition at line 42 of file point.cpp.

42  {
43  auto rotcord = geo::Coordinate(this->x(), this->y()).rotate(rotation_center, rotation_angle);
44  auto newCoordinate = std::make_shared<Point>(rotcord.x(), rotcord.y(), layer());
45  newCoordinate->setID(this->id());
46  return newCoordinate;
47 }
double x() const
Returns x of Coordinate.
Definition: geocoordinate.h:26
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
double y() const
Returns y of Coordinate.
Definition: geocoordinate.h:34
Coordinate rotate(const Coordinate &angleVector) const
rotate around (0.,0.) with a given angle vector
CADEntity_CSPtr Point::scale ( const geo::Coordinate scale_center,
const geo::Coordinate scale_factor 
) const
overridevirtual

scale, scales the entity

Parameters
geo::Coordinatescale_center
doublescale_factor
Returns

Implements lc::entity::CADEntity.

Definition at line 49 of file point.cpp.

49  {
50  auto rotcord = geo::Coordinate(this->x(), this->y()).scale(scale_center, scale_factor);
51  auto newCoordinate = std::make_shared<Point>(rotcord.x(), rotcord.y(), layer());
52  newCoordinate->setID(this->id());
53  return newCoordinate;
54 }
double x() const
Returns x of Coordinate.
Definition: geocoordinate.h:26
Layer_CSPtr layer() const
layer return the layer this entity is placed on
Definition: cadentity.cpp:29
double y() const
Returns y of Coordinate.
Definition: geocoordinate.h:34
Coordinate scale(const double &scale_factor) const

Friends And Related Function Documentation

friend class builder::PointBuilder
friend

Definition at line 18 of file point.h.


The documentation for this class was generated from the following files: