1 #include <boost/foreach.hpp> 18 bool check_same_point(
const vector<Vector2D>& vertices,
22 BOOST_FOREACH(
const Vector2D& v, vertices)
34 const double eps=1e-30;
35 vector<Vector2D> points;
41 for(
size_t i=1;i<edge_index.size();++i)
46 if(!check_same_point(points,edge.
vertices.first,eps*pow(R,2)))
47 points.push_back(edge.
vertices.first);
48 if(!check_same_point(points,edge.
vertices.second,eps*pow(R,2)))
49 points.push_back(edge.
vertices.second);
55 size_t n=points.size();
56 vector<double> angles(n);
57 for(
size_t i=0;i<n;++i)
58 angles.at(i)=atan2(points.at(i).y-cm.
y,points.at(i).x-cm.
x);
59 const vector<size_t> indeces =
sort_index(angles);
66 size_t Nedges = edge_index.size();
69 for (
size_t i = 0; i < Nedges; ++i)
72 std::vector<int> good_edges;
73 for (
size_t i = 0; i < Nedges; ++i)
75 good_edges.push_back(edge_index[i]);
76 Nedges = good_edges.size();
77 std::vector<double> angles(Nedges);
80 for (
size_t i = 0; i < Nedges; ++i)
83 angles[i] = atan2(midpoint.
y, midpoint.
x);
85 const vector<size_t> indeces =
sort_index(angles);
86 result.resize(Nedges);
87 for (
size_t i = 0; i < Nedges; ++i)
89 Edge const& edge = tess.
GetEdge(good_edges[indeces[i]]);
92 result[i] = std::pair<Vector2D, Vector2D>(edge.
vertices.first, edge.
vertices.second);
94 result[i] = std::pair<Vector2D, Vector2D>(edge.
vertices.second, edge.
vertices.first);
102 int nedges=
static_cast<int>(edges.size());
103 result.resize(static_cast<size_t>(nedges));
104 vector<double> angles(static_cast<size_t>(nedges));
105 for(
int i=0;i<nedges;++i)
107 Edge const& edge=tess.
GetEdge(edges[static_cast<size_t>(i)]);
110 angles[
static_cast<size_t>(i)]=atan2(otherpoint.y-mypoint.
y,otherpoint.x-mypoint.
x);
114 for(
size_t i=0;i<static_cast<size_t>(nedges);++i)
115 result[i]=edges[static_cast<size_t>(temp[i])];
vector< T > VectorValues(vector< T > const &v, vector< int > const &index)
Returns only the values with indeces in index.
Various checks for geometric data.
void sort_index(const vector< T > &arr, vector< int > &res)
Returns the indeces of a sort.
Vector2D Parallel(Edge const &edge)
Calculates a unit vector parallel to an edge.
Abstract class for tessellation.
virtual Vector2D const & GetCellCM(int index) const =0
Returns Position of Cell's CM.
Interface between two cells.
virtual Vector2D GetMeshPoint(int index) const =0
Returns Position of mesh generating point.
double max(vector< double > const &v)
returns the maximal term in a vector
double y
Component in the y direction.
A collection of three identical references.
virtual Edge const & GetEdge(int index) const =0
Returns edge (interface between cells)
void ConvexHull(vector< Vector2D > &result, Tessellation const &tess, int index)
Returns the ConvexHull for a set of points.
double ScalarProd(Vector3D const &v1, Vector3D const &v2)
Scalar product of two vectors.
std::pair< Vector2D, Vector2D > vertices
Points at the ends of the edge.
virtual double GetWidth(int index) const =0
Returns the effective width of a cell.
Vector2D normalize(const Vector2D &v)
Normalized a vector.
Calculates the convex hull from a set of points.
std::pair< int, int > neighbors
Neighboring cells.
virtual vector< int > const & GetCellEdges(int index) const =0
Returns the indexes of a cell's edges.
double GetLength(void) const
Returns the length of the edge.
double orient2d(const TripleConstRef< Vector2D > &points)
Checks whether 3 given points are on a counterclockwise circle, clockwise circle or colinear...
void ConvexEdges(vector< int > &result, Tessellation const &tess, int index)
Returns the ConvexHull of the edges of a cell.
double x
Component in the x direction.
double dist_sqr(const Vector2D &v)
Calculates the square of the distance. This is computationaly cheaper then actually calculating the d...