38 #include <boost/geometry.hpp>
39 #include <boost/geometry/algorithms/assign.hpp>
40 #include <boost/geometry/geometries/point_xy.hpp>
41 #include <boost/geometry/geometries/polygon.hpp>
43 namespace bg = boost::geometry;
44 typedef bg::model::d2::point_xy<double>
point_xy;
50 namespace NekMeshUtils
54 vector<CADSystem::EdgeLoopSharedPtr> &ein)
59 vector<vector<Array<OneD, NekDouble> > > loopt;
60 for (
int i = 0; i < ein.size(); i++)
62 vector<Array<OneD, NekDouble> > loop;
63 for (
int j = 0; j < ein[i]->edges.size(); j++)
66 NekDouble dt = (bnds[1] - bnds[0]) / (np - 1);
69 for (
int k = 0; k < np - 1; k++)
79 for (
int k = np - 1; k > 0; k--)
88 loopt.push_back(loop);
91 vector<bg::model::polygon<point_xy, false, true> > polygons;
93 for (
int i = 0; i < loopt.size(); i++)
95 bg::model::polygon<point_xy, false, true> polygon;
96 vector<point_xy> points;
97 for (
int j = 0; j < loopt[i].size(); j++)
99 points.push_back(
point_xy(loopt[i][j][0], loopt[i][j][1]));
102 points.push_back(
point_xy(loopt[i][0][0], loopt[i][0][1]));
104 bg::assign_points(polygon, points);
111 bg::centroid(polygon, cen);
114 ein[i]->center[0] = cen.x();
115 ein[i]->center[1] = cen.y();
117 polygons.push_back(polygon);
125 for (
int i = 0; i < ein.size() - 1; i++)
127 if (fabs(ein[i]->area) < fabs(ein[i + 1]->area))
130 swap(ein[i], ein[i + 1]);
131 swap(loopt[i], loopt[i + 1]);
132 swap(polygons[i], polygons[i + 1]);
140 for (
int i = 1; i < ein.size(); i++)
142 point_xy p(ein[i]->center[0], ein[i]->center[1]);
144 if (!bg::within(p, polygons[i]))
150 NekDouble mag = sqrt((n1[0] - n2[0]) * (n1[0] - n2[0]) +
151 (n1[1] - n2[1]) * (n1[1] - n2[1]));
153 N[0] = (n2[1] - n1[1]) / mag;
154 N[1] = -1.0 * (n2[0] - n1[0]) / mag;
164 ASSERTL0(boost::geometry::within(p, polygons[i]),
"point is not side loop");
#define ASSERTL0(condition, msg)
bg::model::d2::point_xy< double > point_xy
boost::shared_ptr< CADSurf > CADSurfSharedPtr