OpenStructure
Loading...
Searching...
No Matches
composite2.hh
Go to the documentation of this file.
1//------------------------------------------------------------------------------
2// This file is part of the OpenStructure project <www.openstructure.org>
3//
4// Copyright (C) 2008-2020 by the OpenStructure authors
5//
6// This library is free software; you can redistribute it and/or modify it under
7// the terms of the GNU Lesser General Public License as published by the Free
8// Software Foundation; either version 3.0 of the License, or (at your option)
9// any later version.
10// This library is distributed in the hope that it will be useful, but WITHOUT
11// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13// details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with this library; if not, write to the Free Software Foundation, Inc.,
17// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18//------------------------------------------------------------------------------
19#ifndef GEOM_COMPOSITE2_HH
20#define GEOM_COMPOSITE2_HH
21
22#include "def.hh"
23
24#include <vector>
25#include <algorithm>
26
27#include "circular_iterator.hh"
28#include "vec2.hh"
29
30namespace geom {
31
34public:
36 Line2(const Vec2& from, const Vec2& to);
37
38 Vec2 At(Real r) const;
39 Vec2 GetOrigin() const;
41private:
42 Vec2 ori_,dir_;
43};
44
46public:
48 Rectangle2(Vec2 topleft, Vec2 bottomright);
49 Real GetWidth() const;
50 Real GetHeight() const;
51 Vec2 GetStart() const;
52 Vec2 GetEnd() const;
53 void SetStart(const Vec2& v);
54 void SetEnd(const Vec2& v);
55 Real GetArea() const;
56 Vec2 operator[] (unsigned index) const;
57 Vec2& operator[] (unsigned index);
58private:
59 Vec2 topleft_;
60 Vec2 bottomright_;
61};
62
65class DLLEXPORT_OST_GEOM Polygon2: public std::vector<Vec2>
66{
67public:
70
72 Polygon2(const Polygon2& p);
73 Polygon2(const std::vector<Vec2>& v);
74 circular_iterator cbegin(){return circular_iterator(begin(),end());}
75 circular_iterator cend(){return circular_iterator(begin(),end(),--end());}
77 const_circular_iterator cend() const {return const_circular_iterator(begin(),end(),--end());}
78 void AddNode(const Vec2& n){push_back(n);};
79 unsigned int GetNodeCount() const {return size();};
80 Vec2 GetNode(unsigned int i) const {return operator[](i);};
81 void SetNode(unsigned int i,const Vec2& v);
82 circular_iterator FindSegment(std::vector<Vec2>::const_iterator start,std::vector<Vec2>::const_iterator end);
83 circular_iterator FindNode(const Vec2& v) {return circular_iterator(begin(),end(),find(begin(),end(),v));}
85 Polygon2 operator+(const Vec2& v) const;
87 Real GetArea() const;
89 void Expand(Real val);
91private:
92 ;
93};
94
96{
97public:
99 Ellipse2(Vec2 ori,Real a,Real b,Real gamma);
100 Vec2 At(Real t) const;
101 Vec2 AtAngle(Real angle_) const;
103 Real GetA() const {return a_;}
104 Real GetB() const {return b_;}
105 Real GetGamma() const {return gamma_;}
106 Real GetArea() const {return a_*b_*M_PI;}
107 Vec2 GetOrigin() const {return origin_;}
108 void SetA(Real a) {a_=a;}
109 void SetB(Real b) {b_=b;}
110 void SetGamma(Real gamma) {gamma_=gamma;}
111 void SetOrigin(Vec2 ori) {origin_=ori;}
112private:
113 Vec2 calc_(Real t) const;
114 Vec2 origin_;
115 Real a_;
116 Real b_;
117 Real gamma_;
118};
119
121{
122public:
124 Hyperbola2(Vec2 ori,Real a,Real b,Real gamma);
125 Vec2 At(Real t, bool righthalf=true) const;
126 Real GetA() const {return a_;}
127 Real GetB() const {return b_;}
128 Real GetGamma() const {return gamma_;}
129 Vec2 GetOrigin() const {return origin_;}
130 void SetA(Real a) {a_=a;}
131 void SetB(Real b) {b_=b;}
132 void SetGamma(Real gamma) {gamma_=gamma;}
133 void SetOrigin(Vec2 ori) {origin_=ori;}
134private:
135 Vec2 origin_;
136 Real a_;
137 Real b_;
138 Real gamma_;
139};
140
142{
143public:
145 Circle2(const Circle2& c);
146 Circle2(const Vec2& center, Real radius);
147 void SetCenter(const Vec2& center);
152 Real GetArea() const;
153protected:
156};
157
158} // ns
159
160#endif
161
172
173
Vec2 GetCenter() const
void SetCenter(const Vec2 &center)
Real GetRadius() const
Circle2(const Circle2 &c)
void SetRadius(Real r)
Real GetCircumference() const
Circle2(const Vec2 &center, Real radius)
Real GetArea() const
void SetOrigin(Vec2 ori)
Vec2 GetOrigin() const
Real GetGamma() const
void SetA(Real a)
Real GetA() const
Rectangle2 GetBoundingBox() const
Vec2 AtAngle(Real angle_) const
Vec2 At(Real t) const
void SetGamma(Real gamma)
Ellipse2(Vec2 ori, Real a, Real b, Real gamma)
Real GetArea() const
Real GetB() const
void SetB(Real b)
void SetOrigin(Vec2 ori)
Vec2 GetOrigin() const
Real GetGamma() const
void SetA(Real a)
Real GetA() const
Hyperbola2(Vec2 ori, Real a, Real b, Real gamma)
void SetGamma(Real gamma)
Vec2 At(Real t, bool righthalf=true) const
Real GetB() const
void SetB(Real b)
Vec2 GetOrigin() const
Vec2 At(Real r) const
Line2(const Vec2 &from, const Vec2 &to)
Vec2 GetDirection() const
void AddNode(const Vec2 &n)
Definition composite2.hh:78
circular_iterator cend()
Definition composite2.hh:75
Polygon2(const Polygon2 &p)
circular_iterator FindSegment(std::vector< Vec2 >::const_iterator start, std::vector< Vec2 >::const_iterator end)
Vec2 GetCentroid() const
void SetNode(unsigned int i, const Vec2 &v)
Vec2 GetNode(unsigned int i) const
Definition composite2.hh:80
circular_iter< Polygon2 > circular_iterator
Definition composite2.hh:69
unsigned int GetNodeCount() const
Definition composite2.hh:79
Rectangle2 GetBoundingBox() const
const_circular_iterator cend() const
Definition composite2.hh:77
void Erase(circular_iterator first, circular_iterator last)
const_circular_iter< Polygon2 > const_circular_iterator
Definition composite2.hh:68
circular_iterator FindNode(const Vec2 &v)
Definition composite2.hh:83
const_circular_iterator cbegin() const
Definition composite2.hh:76
Polygon2 operator+(const Vec2 &v) const
circular_iterator cbegin()
Definition composite2.hh:74
Real GetArea() const
Polygon2 operator*(Real d) const
void Expand(Real val)
Polygon2(const std::vector< Vec2 > &v)
Real GetWidth() const
Vec2 GetStart() const
Rectangle2(Vec2 topleft, Vec2 bottomright)
Real GetHeight() const
Vec2 GetEnd() const
Real GetArea() const
void SetStart(const Vec2 &v)
void SetEnd(const Vec2 &v)
#define DLLEXPORT_OST_GEOM
float Real
Definition base.hh:44