63 virtual void SetRefinePoints(
const std::vector<MeRefinePoint>& a_pts,
double a_tol)
override 70 const std::vector<Pt3d>& a_outPoly,
71 const std::vector<std::vector<Pt3d>>& a_inPolys,
72 std::vector<std::vector<Pt3d>>& a_newInPolys,
73 std::vector<Pt3d>& a_refMeshPts,
74 std::vector<Pt3d>& a_refPtsTooClose)
override;
77 const std::vector<std::vector<Pt3d>>& a_inPolys,
78 std::vector<Pt3d>& a_refPtsTooClose);
80 std::vector<Pt3d>& a_refPtsTooClose);
82 std::vector<Pt3d>& a_refMeshPts,
83 std::vector<Pt3d>& a_refPtsProcessed);
91 std::vector<MeRefinePoint>
m_pts;
108 MeRefinePtsToPolys::MeRefinePtsToPolys()
114 MeRefinePtsToPolys::~MeRefinePtsToPolys()
135 const std::vector<Pt3d>& a_outPoly,
136 const std::vector<std::vector<Pt3d>>& a_inPolys,
137 std::vector<std::vector<Pt3d>>& a_newInPolys,
138 std::vector<Pt3d>& a_refMeshPts,
139 std::vector<Pt3d>& a_refPtsProcessed)
143 a_newInPolys.resize(0);
144 a_refMeshPts.resize(0);
145 a_refPtsProcessed.resize(0);
159 const std::vector<std::vector<Pt3d>>& a_inPolys,
160 std::vector<Pt3d>& a_refPtsProcessed)
163 gmPoly->Setup(a_outPoly, a_inPolys);
164 std::multimap<double, size_t> mapSizeIdx;
165 for (
size_t i = 0; i <
m_pts.size(); ++i)
167 if (gmPoly->Within(
m_pts[i].m_pt))
172 double dist = gmPoly->MinDistanceToBoundary(
m_pts[i].m_pt);
173 if (dist <
m_pts[i].m_size)
175 std::stringstream ss, loc;
176 loc <<
"(" <<
m_pts[i].m_pt.x <<
", " <<
m_pts[i].m_pt.y <<
")";
177 ss <<
"Refine point at location: " << loc.str()
178 <<
" is too close to the polygon boundary with specified size: " <<
m_pts[i].m_size
179 <<
". The point was not inserted by the meshing process. Specify a " 181 << dist <<
" for the point to be included by the meshing process.";
182 std::string msg = ss.str();
185 a_refPtsProcessed.push_back(
m_pts[i].m_pt);
188 mapSizeIdx.insert(std::make_pair(
m_pts[i].m_size, i));
205 std::multimap<double, size_t>& a_mapSizeIdx,
206 std::vector<Pt3d>& a_refPtsProcessed)
208 std::vector<int> removePt(a_mapSizeIdx.size(), 0);
209 std::multimap<double, size_t>::iterator it(a_mapSizeIdx.begin()), itEnd(a_mapSizeIdx.end());
210 for (
size_t i = 0; it != itEnd; ++i, ++it)
215 size_t iIdx(it->second);
216 double iSize(
m_pts[iIdx].m_size);
220 std::multimap<double, size_t>::iterator it2(it);
222 for (
size_t j = i; it2 != itEnd; ++j, ++it2)
224 size_t jIdx(it2->second);
226 double jSize(
m_pts[jIdx].m_size);
227 double dist(
Mdist(pi.
x, pi.
y, pj.
x, pj.
y));
228 double totalSize(iSize + jSize);
229 if (dist < totalSize)
231 double target = dist - iSize;
233 std::stringstream ss, loc;
234 loc <<
"(" << pj.
x <<
", " << pj.
y <<
")";
235 ss <<
"Refine point at location: " << loc.str() <<
" with specified size: " << jSize
236 <<
" is too close to another refine point. The point was not " 237 "inserted by the meshing process. Specify a size smaller than " 238 << target <<
" for the point to be included by the meshing process.";
239 std::string msg = ss.str();
242 a_refPtsProcessed.push_back(pj);
258 std::vector<Pt3d>& a_refMeshPts,
259 std::vector<Pt3d>& a_refPtsProcessed)
267 if (
m_pts[idx].m_createMeshPoint)
270 a_refMeshPts.push_back(
m_pts[idx].m_pt);
275 a_refPtsProcessed.push_back(
m_pts[idx].m_pt);
277 a_newInPolys.push_back(p);
279 else if (
m_pts[idx].m_createMeshPoint)
280 a_refMeshPts.push_back(
m_pts[idx].m_pt);
313 double sizeOver2(a_size / 2);
316 std::vector<Pt3d> rval(3, a_pt);
317 rval[0].x -= sizeOver2;
318 rval[0].y -= sizeOver2TimesSqrt3;
319 rval[1].x += sizeOver2;
320 rval[1].y -= sizeOver2TimesSqrt3;
321 rval[2].y += sizeOverSqrt3;
356 double sizeOver2(a_size / 2);
358 std::vector<Pt3d> pts(6, a_pt);
360 pts[1].x += sizeOver2;
361 pts[1].y += sizeTimesSqrtThreeOverTwo;
362 pts[2].x -= sizeOver2;
363 pts[2].y += sizeTimesSqrtThreeOverTwo;
365 pts[4].x -= sizeOver2;
366 pts[4].y -= sizeTimesSqrtThreeOverTwo;
367 pts[5].x += sizeOver2;
368 pts[5].y -= sizeTimesSqrtThreeOverTwo;
409 std::vector<Pt3d> basePts = {{.5, .7113, 0}, {1.5, .7113, 0}, {1, 1.5773, 0}};
420 std::vector<Pt3d> hexPts = {{2, 1, 0}, {1.5, 1.866, 0}, {.5, 1.866, 0},
421 {0, 1, 0}, {.5, .1339, 0}, {1.5, .1339, 0}};
435 std::vector<MeRefinePoint> refPts = {{{4, 4, 0}, 1, 1}, {{8, 8, 0}, 1, 0}};
437 std::vector<Pt3d> outPoly = {{0, 0, 0}, {0, 10, 0}, {10, 10, 0}, {10, 0, 0}};
438 std::vector<Pt3d> refMeshPts, tooClose;
439 std::vector<std::vector<Pt3d>> inPolys, newInPolys;
440 p.
RefPtsAsPolys(-1, outPoly, inPolys, newInPolys, refMeshPts, tooClose);
441 TS_ASSERT_EQUALS(1, refMeshPts.size());
442 TS_ASSERT_EQUALS(2, newInPolys.size());
443 if (2 != newInPolys.size())
446 std::vector<Pt3d> hexPts = {{5, 4, 0}, {4.5, 4.866, 0}, {3.5, 4.866, 0},
447 {3, 4, 0}, {3.5, 3.1339, 0}, {4.5, 3.1339, 0}};
450 std::vector<Pt3d> basePts(18);
454 basePts = {{7.5, 7.71132, 0}, {8.5, 7.71132, 0}, {8, 8.57735, 0}};
465 std::vector<MeRefinePoint> refPts = {{{.5, 4, 0}, 1, 1}, {{9.001, 8, 0}, 1, 0}};
467 std::vector<Pt3d> outPoly = {{0, 0, 0}, {0, 10, 0}, {10, 10, 0}, {10, 0, 0}};
468 std::vector<Pt3d> refMeshPts, tooClose;
469 std::vector<std::vector<Pt3d>> inPolys, newInPolys;
470 p.
RefPtsAsPolys(-1, outPoly, inPolys, newInPolys, refMeshPts, tooClose);
471 TS_ASSERT_EQUALS(0, newInPolys.size());
474 "---Refine point at location: (0.5, 4) is too close to the polygon boundary " 475 "with specified size: 1. The point was not inserted by the meshing " 476 "process. Specify a size smaller than 0.5 for the point to be included " 477 "by the meshing process.\n\n" 478 "---Refine point at location: (9.001, 8) is too close to the polygon " 479 "boundary with specified size: 1. The point was not inserted by the " 480 "meshing process. Specify a size smaller than 0.999 for the point to be " 481 "included by the meshing process.\n\n");
Creates polygons from refine point input.
void CheckRefPtsTooCloseToOtherRefPts(std::multimap< double, size_t > &a_mapSizeIdx, std::vector< Pt3d > &a_refPtsTooClose)
Checks on refine points that are inside of the polygon to make sure that they are not too close to on...
static BSHP< MeRefinePtsToPolys > New()
Creates a new instance of this class.
Utilities related to a VTK unstructured grid (from shared1\UGridUtils.cpp)
void testRefinePtsTooCloseToBoundary()
test refine points that are too close to the polygon boundary
void testTriPolyAtPoint()
tests creating a triangle polygon at the refined point
void testRefPtsAsPolys()
tests multiple refine points to polygons
Creates polygon from refine point information.
virtual void SetRefinePoints(const std::vector< MeRefinePoint > &a_pts, double a_tol) override
Sets the refine points.
double m_SqrtThreeOverTwo
precalculated constant
void testCreateClass()
tests creating the class
static BSHP< GmPolygon > New()
std::vector< Pt3d > HexPolyAtPoint(const Pt3d &a_pt, double a_size)
Creates a hexagon polygon that surrounds a refine point. The refine point itself WILL be included in ...
void meModifyMessageWithPolygonId(int a_polyId, std::string &a_msg)
Prepends the polygon id as part of an error messge.
std::string GetAndClearStackStr()
double m_TwoTimesSqrtThree
precalculated constant
double m_SqrtThree
precalculated constant
void FindPtsInsidePolygon(const std::vector< Pt3d > &a_outPoly, const std::vector< std::vector< Pt3d >> &a_inPolys, std::vector< Pt3d > &a_refPtsTooClose)
Finds the refine points that are inside of the polygon.
int m_polyId
id of the polygon
std::vector< Pt3d > TriPolyAtPoint(const Pt3d &a_pt, double a_size)
Creates a triangle polygon that surrounds a refine point. The refine point itself will NOT be include...
std::vector< MeRefinePoint > m_pts
the refine points
double Mdist(_T x1, _U y1, _V x2, _W y2)
static XmLog & Instance(bool a_delete=false, XmLog *a_new=NULL)
double m_xyTol
tolerance used for geometric comparison
void CreateNewInsidePolygons(std::vector< std::vector< Pt3d >> &a_newInPolys, std::vector< Pt3d > &a_refMeshPts, std::vector< Pt3d > &a_refPtsProcessed)
Creates new inside polygons from the refine points and appends these polygons to the current vector o...
virtual void RefPtsAsPolys(int a_polyId, const std::vector< Pt3d > &a_outPoly, const std::vector< std::vector< Pt3d >> &a_inPolys, std::vector< std::vector< Pt3d >> &a_newInPolys, std::vector< Pt3d > &a_refMeshPts, std::vector< Pt3d > &a_refPtsTooClose) override
Creates new inside polygons from refine points that are inside of the polygon being considered...
std::vector< size_t > m_ptsInsidePoly
void testHexPolyAtPoint()
test creating a hex polygon at the refine point