Flow123d  release_2.2.0-914-gf1a3a4f
polygon.h
Go to the documentation of this file.
1 /*!
2  *
3  * Copyright (C) 2015 Technical University of Liberec. All rights reserved.
4  *
5  * This program is free software; you can redistribute it and/or modify it under
6  * the terms of the GNU General Public License version 3 as published by the
7  * Free Software Foundation. (http://www.gnu.org/licenses/gpl-3.0.en.html)
8  *
9  * This program is distributed in the hope that it will be useful, but WITHOUT
10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
12  *
13  *
14  * @file polygon.h
15  * @brief
16  */
17 
18 #ifndef polygonH
19 #define polygonH
20 
21 #include "vertex.h"
22 #include "triangle.h"
23 #include <vector>
24 
25 namespace ngh {
26 
27 #define FOR_POL_VERTECES(i,j) \
28  for((j)=(i)->verteces.begin();(j)!=(i)->verteces.end();(j)++)
29 
30 class TPolygon {
31 private:
32  static int numberInstance;
33  int id;
34 
35  double area;
40 
42 
43  int generateId();
44 
45  void ComputeCenter();
46  void ComputeArea();
47 
48  /**
49  * Find position of new vertex
50  *
51  * @param Vx New vertex
52  * @return position of new vertex
53  */
54  int InsertPosition(const TVertex& Vx);
55 
56 public:
57  TPolygon();
58  ~TPolygon();
59 
60  friend std::ostream & operator <<(std::ostream&, const TPolygon&);
61 
62  void Add(const TPoint&);
63  double GetArea();
64  TPoint GetCenter();
65 
66  /**
67  * Get count of vertexes
68  */
70  return verteces.size();
71  }
72 
73  static int getNumInstances() {
75  }
76 };
77 
78 } // namespace ngh
79 
80 #endif
81 
TVector normal_vector
Definition: polygon.h:37
Definition: abscissa.h:25
static int numberInstance
Definition: polygon.h:32
void Add(const TPoint &)
Definition: polygon.cpp:70
void ComputeArea()
Definition: polygon.cpp:160
TPoint center
Definition: polygon.h:36
TPoint GetCenter()
Definition: polygon.cpp:114
std::vector< TVertex * > verteces
Definition: polygon.h:41
bool area_is_actual
Definition: polygon.h:38
double GetArea()
Definition: polygon.cpp:85
void ComputeCenter()
Definition: polygon.cpp:94
double area
Definition: polygon.h:35
bool center_is_actual
Definition: polygon.h:39
friend std::ostream & operator<<(std::ostream &, const TPolygon &)
Definition: polygon.cpp:55
int InsertPosition(const TVertex &Vx)
Definition: polygon.cpp:121
int generateId()
Definition: polygon.cpp:32
int vertexes_count()
Definition: polygon.h:69
static int getNumInstances()
Definition: polygon.h:73