63 bool CalcMaxSize(
double a_length,
float a_smoothVal,
double& a_maxSize);
64 double CalcMinSize(
double a_length,
float a_smoothVal,
double a_calcMaxSize);
95 double sizeOneAway = a_length / (
m_scaleFactor * a_smoothVal);
103 a_maxSize = (double)a_smoothVal + a_length *
m_maxSize;
119 minSize = a_smoothVal - (a_calcMaxSize - a_smoothVal);
123 minSize = (double)a_smoothVal - a_length *
m_maxSize;
146 std::multimap<float, int> mapSizeIdx;
147 std::vector<std::multimap<float, int>::iterator> vecIt;
153 for (
int i = 0; i < (int)sz.size(); ++i)
155 vecIt.push_back(mapSizeIdx.insert(std::make_pair(val * sz[i], i)));
164 auto it = mapSizeIdx.begin();
165 auto endIt = mapSizeIdx.end();
166 for (; it != endIt; ++it)
175 const VecInt adjTris(trisAdjToPts[i]);
176 for (
const auto& t : adjTris)
181 triPts[0] = tris[tIdx];
182 triPts[1] = tris[tIdx + 1];
183 triPts[2] = tris[tIdx + 2];
184 for (
int t1 = 0; t1 < 3; ++t1)
194 const Pt3d &p0(pts[i]), &p1(pts[
ix]);
197 double length =
Mdist(p0.x, p0.y, p1.
x, p1.
y);
208 if (maxSize < (
double)smoothSize[
ix])
210 smoothSize[
ix] = (float)maxSize;
211 ptsFlag.set(
ix,
true);
216 ptsFlag.set(
ix,
true);
222 double minSize = a_.
CalcMinSize(length, smoothSize[i], maxSize);
225 if (minSize > (
double)smoothSize[
ix])
227 smoothSize[
ix] = (float)minSize;
228 ptsFlag.set(
ix,
true);
233 ptsFlag.set(
ix,
true);
244 ptsFlag.set(
ix,
false);
245 mapSizeIdx.erase(vecIt[
ix]);
246 vecIt[
ix] = mapSizeIdx.insert(std::make_pair(val * smoothSize[
ix],
ix));
271 double minD = *std::min_element(a_depths.begin(), a_depths.end());
272 double maxD = *std::max_element(a_depths.begin(), a_depths.end());
273 double dDiff = maxD - minD;
275 double sDiff = a_maxSize - a_minSize;
278 a_size.assign(a_depths.size(), a_minSize);
280 for (
auto& d : a_size)
282 d += ((a_depths[i++] - minD) / dDiff) * sDiff;
308 a_smoothSize.resize(0);
314 double percentGrowth = sqrt(1.0 / a_sizeRatio);
316 double logPercentGrowth = log(percentGrowth);
317 double scaleFactor = (percentGrowth - 1.0) / logPercentGrowth;
356 a_smoothElevs.resize(0);
382 std::stringstream ss;
383 ss <<
"Error meshing polygon id: " << a_polyId <<
". ";
384 a_msg = ss.str() + a_msg;
407 xms::VecDbl depths = {0, 5, 10, 20, 25, 5, 0};
409 xms::VecDbl elemSize;
411 double minElem(2), maxElem(102);
413 xms::meSizeFunctionFromDepth(depths, elemSize, minElem, maxElem);
415 xms::VecDbl baseElemSize = {2, 22, 42, 82, 102, 22, 2};
453 BSHP<xms::VecPt3d> pts(
new xms::VecPt3d());
454 *pts = {{0, 0}, {10, 0}, {20, 0}, {30, 0}, {0, 10}, {10, 10},
455 {20, 10}, {30, 10}, {0, 20}, {10, 20}, {20, 20}, {30, 20}};
456 xms::VecFlt sizes(pts->size(), 100);
458 BSHP<xms::VecInt> tris(
new xms::VecInt());
459 BSHP<xms::VecInt2d> adjTris(
new xms::VecInt2d());
463 tin->SetGeometry(pts, tris, adjTris);
466 xms::DynBitset ptFlags;
467 xms::meSmoothSizeFunction(tin, sizes, 0.5, 1.0, 0, ptFlags, vSmooth);
468 xms::VecFlt baseSmooth = {4.46f, 5.90f, 9.36f, 12.83f, 1.0f, 4.46f,
469 7.93f, 11.39f, 4.46f, 7.93f, 11.39f, 14.86f};
508 BSHP<xms::VecPt3d> pts(
new xms::VecPt3d());
509 *pts = {{0, 0}, {10, 0}, {20, 0}, {30, 0}, {0, 10}, {10, 10},
510 {20, 10}, {30, 10}, {0, 20}, {10, 20}, {20, 20}, {30, 20}};
511 xms::VecFlt sizes(pts->size(), 1);
513 BSHP<xms::VecInt> tris(
new xms::VecInt());
514 BSHP<xms::VecInt2d> adjTris(
new xms::VecInt2d());
518 tin->SetGeometry(pts, tris, adjTris);
521 xms::DynBitset ptFlags;
522 xms::meSmoothSizeFunction(tin, sizes, 0.5, 1.0, 1, ptFlags, vSmooth);
523 xms::VecFlt baseSmooth = {96.53f, 95.10f, 91.63f, 88.17f, 100.0f, 96.53f,
524 93.07f, 89.60f, 96.53f, 93.07f, 89.60f, 86.14f};
564 BSHP<xms::VecPt3d> pts(
new xms::VecPt3d());
565 *pts = {{0, 0}, {10, 0}, {20, 0}, {30, 0}, {0, 10}, {10, 10},
566 {20, 10}, {30, 10}, {0, 20}, {10, 20}, {20, 20}, {30, 20}};
567 xms::VecFlt sizes(pts->size(), 100);
569 BSHP<xms::VecInt> tris(
new xms::VecInt());
570 BSHP<xms::VecInt2d> adjTris(
new xms::VecInt2d());
574 tin->SetGeometry(pts, tris, adjTris);
577 xms::DynBitset ptsFlag;
578 xms::meSmoothElevBySlope(tin, sizes, 0.5, 0, ptsFlag, vSmooth);
579 xms::VecFlt baseSmooth = {6.00f, 8.07f, 13.07f, 18.07f, 1.0f, 6.00f,
580 11.00f, 16.00f, 6.00f, 11.00f, 16.00f, 21.00f};
619 BSHP<xms::VecPt3d> pts(
new xms::VecPt3d());
620 *pts = {{0, 0}, {10, 0}, {20, 0}, {30, 0}, {0, 10}, {10, 10},
621 {20, 10}, {30, 10}, {0, 20}, {10, 20}, {20, 20}, {30, 20}};
622 xms::VecFlt sizes(pts->size(), 1);
624 BSHP<xms::VecInt> tris(
new xms::VecInt());
625 BSHP<xms::VecInt2d> adjTris(
new xms::VecInt2d());
629 tin->SetGeometry(pts, tris, adjTris);
632 xms::DynBitset ptsFlag;
633 xms::meSmoothElevBySlope(tin, sizes, 0.5, 1, ptsFlag, vSmooth);
634 xms::VecFlt baseSmooth = {95.00f, 92.92f, 87.92f, 82.92f, 100.0f, 95.00f,
635 90.00f, 85.00f, 95.00f, 90.00f, 85.00f, 80.00f};
std::vector< int > VecInt
Utilities related to a VTK unstructured grid (from shared1\UGridUtils.cpp)
Helper class for size function smoothing.
std::vector< double > VecDbl
std::vector< float > VecFlt
static void meiDoSmooth(SmoothIo &a_)
Smooths a size function. Ensures that the size function transitions over a sufficient distance so tha...
void meSizeFunctionFromDepth(const VecDbl &a_depths, VecDbl &a_size, double a_minSize, double a_maxSize)
Creates a size at each point based on the depth at the point and the min and max sizes the equation i...
void meSmoothSizeFunction(BSHP< TrTin > a_tin, const VecFlt &a_sizes, double a_sizeRatio, double a_minSize, int a_anchorType, const DynBitset &a_ptsFlag, VecFlt &a_smoothSize)
Smooths a size function. Ensures that the size function transitions over a sufficient distance so tha...
double m_maxSize
max size used with elevation smoothing
bool CalcMaxSize(double a_length, float a_smoothVal, double &a_maxSize)
Calculates a max size for use in meiDoSmooth.
void testSizeFuncFromDepth()
Tests creating a size function from depth.
boost::dynamic_bitset< size_t > DynBitset
void testSmoothSizeFunc1()
[snip_MeMeshUtilsTests::testSmoothSizeFunc]
std::vector< VecInt > VecInt2d
void testSmoothSizeFunc3()
[snip_MeMeshUtilsTests::testSmoothSizeFunc2]
void meModifyMessageWithPolygonId(int a_polyId, std::string &a_msg)
Prepends the polygon id as part of an error messge.
static BSHP< TrTin > New()
void testSmoothSizeFunc()
Tests size function smoothing.
bool m_checkMinSize
flag to indicate that the min size should be checked
#define XM_ENSURE_TRUE(...)
double m_sizeRatio
size ratio value
BSHP< TrTin > m_tin
geometry defining connections between points
void testSmoothSizeFunc2()
[snip_MeMeshUtilsTests::testSmoothSizeFunc1]
double m_logPercentGrowth
growth factor
int m_anchorType
anchor to min or max value
double Mdist(_T x1, _U y1, _V x2, _W y2)
VecFlt * m_smoothSize
the output smoothed sizes
double m_scaleFactor
scaling factor
const VecFlt * m_sizes
array of size values
double m_percentGrowth
growth factor
void meSmoothElevBySlope(BSHP< TrTin > a_tin, const VecFlt &a_elevs, double a_maxSlope, int a_anchorType, const DynBitset &a_ptsFlag, VecFlt &a_smoothElevs)
Smooths a elevations based on max specified slope (a_maxSlope) preserving either the min or max based...
double CalcMinSize(double a_length, float a_smoothVal, double a_calcMaxSize)
Calculates a max size for use in meiDoSmooth.
DynBitset m_ptsFlag
flags indicating whether a point should be processed
std::vector< Pt3d > VecPt3d