2D Geometric Shapes

fort::myrmidon::Shape

class Shape

Base class for geometric Shape.

Base class for geometruc Shape such as Circle, Capsule and Polygon. This class allows to construct heterogenous Shape::List for ZoneDefinition

Subclassed by fort::myrmidon::Capsule, fort::myrmidon::Circle, fort::myrmidon::Polygon

Public Types

enum class Type

The type of a Shape.

Values:

enumerator CAPSULE

A Capsule.

enumerator CIRCLE

A Circle.

enumerator POLYGON

A Polygon.

typedef std::shared_ptr<Shape> Ptr

A pointer to a Shape.

typedef std::vector<Ptr> List

A list of Shape.

Public Functions

virtual ~Shape()

Default destructor.

Type ShapeType() const

Gets the Shape Type.

Returns:

the Type of the Shape

fort::myrmidon::Capsule

class Capsule : public fort::myrmidon::Shape

A capsule.

A Capsule is defined as two circle and the region in between those two circles.

Their main purpose is to define Ant virtual body parts.

Public Types

typedef std::shared_ptr<Capsule> Ptr

A pointer to a Capsule.

Public Functions

Capsule()

An empty Capsule.

Capsule(const Eigen::Vector2d &c1, const Eigen::Vector2d &c2, double r1, double r2)

Public constructor.

Parameters:
  • c1 – the first center

  • c2 – the second center

  • r1 – the radius at c1

  • r2 – the radius at c2

void SetC1(const Eigen::Vector2d &c1)

Sets the first circle’s center.

Parameters:

c1 – the center of the first circle

void SetC2(const Eigen::Vector2d &c2)

Sets the second circle’s center.

Parameters:

c2 – the center of the second circle

inline const Eigen::Vector2d &C1() const

Gets the first circle’s center.

Returns:

the center of the first circle

inline const Eigen::Vector2d &C2() const

Gets the second circle’s center.

Returns:

the center of the second circle

void SetR1(double r1)

Sets the first circle’s radius.

Parameters:

r1 – the radius of the first circle

void SetR2(double r2)

Sets the second circle’s radius.

Parameters:

r2 – the radius of the first circle

inline double R1() const

Gets the first circle’s radius.

Returns:

the radius of the first circle

inline double R2() const

Gets the second circle’s radius.

Returns:

the radius of the second circle

fort::myrmidon::Circle

class Circle : public fort::myrmidon::Shape

Represent a 2D circle.

Public Types

typedef std::shared_ptr<Circle> Ptr

A pointer to a Circle.

Public Functions

Circle(const Eigen::Vector2d &center, double radius)

public constructor

Parameters:
  • center – the center of the circle

  • radius – the radius of the circle

void SetCenter(const Eigen::Vector2d &center)

Sets the center of the circle.

Parameters:

center – the center of the circle

const Eigen::Vector2d &Center() const

Gets the center of the circle.

Returns:

the circle center

void SetRadius(double radius)

Sets the radius of the circle.

Parameters:

radius – the radius of the circle

double Radius() const

Gets the radius of the circle.

Parameters:

radius – the radius of the circle

fort::myrmidon::Polygon

class Polygon : public fort::myrmidon::Shape

A closed polygon.

A polygon is defined by a collection of Vertex(). Polygon in fort-myrmidon are always closed, meaning that there is no need to manually close it by setting Vertex(Size()-1) == Vertex(0).

Note that order matters as {(-1,-1),(1,-1),(1,1),(-1,1)} is a square, and {(-1,-1),(1,-1),(-1,1),(1,1)} is an hourglass.

Public Types

typedef std::shared_ptr<Polygon> Ptr

A pointer to a Polygon.

Public Functions

Polygon(const Vector2dList &vertices)

Public constructor.

Parameters:

vertices – the vertices of the polygon

const Vector2dList &Vertices() const

Gets the Polygon’s vertices.

Returns:

a Vector2dList of the polygon vertices

void SetVertices(const Vector2dList &vertices)

Sets the Polygon’s vertices.

Parameters:

vertices – a Vector2dList of the polygon vertices

size_t Size() const

Gets the number of vertices in the polygon.

Returns:

the number of vertices in the Polygon

const Eigen::Vector2d &Vertex(size_t i) const

Gets a polygon vertex.

Parameters:

i – the index of the wanted vertex in [0;Size()-1]

Throws:

std::out_of_range – if i is >= Size().

Returns:

a const reference to the wanted vertex

void SetVertex(size_t i, const Eigen::Vector2d &v)

Sets a Polygon vertex.

Parameters:
  • i – the index of the wanted vertex in [0;Size()-1]

  • v – the new value for the vertex

Throws:

std::out_of_range – if i is >= Size().

void DeleteVertex(size_t i)

Deletes a Polygon vertex.

Parameters:

i – the index of the wanted vertex in [0;Size()-1]

Throws:

std::out_of_range – if i is >= Size().