MCPcopy Create free account
hub / github.com/BIMCoderLiang/LNLib / GetSurfaceMeshParameterization

Method GetSurfaceMeshParameterization

src/LNLib/Algorithm/Interpolation.cpp:265–346  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

263}
264
265bool LNLib::Interpolation::GetSurfaceMeshParameterization(const std::vector<std::vector<XYZ>>& throughPoints, std::vector<double>& paramsU, std::vector<double>& paramsV)
266{
267 int n = throughPoints.size();
268 int m = throughPoints[0].size();
269
270 std::vector<double> cds(std::max(n, m), 0.0);
271 paramsU.resize(n, 0.0);
272 paramsV.resize(m, 0.0);
273
274 int num = m;
275
276 for (int l = 0; l < m; l++)
277 {
278 double total = 0.0;
279 for (int k = 1; k < n; k++)
280 {
281 cds[k] = throughPoints[k][l].Distance(throughPoints[k - 1][l]);
282 total += cds[k];
283 }
284
285 if (MathUtils::IsAlmostEqualTo(total, 0.0))
286 {
287 num--;
288 }
289 else
290 {
291 double d = 0.0;
292 for (int k = 1; k < n; k++)
293 {
294 d += cds[k];
295 paramsU[k] = paramsU[k] + d / total;
296 }
297 }
298 }
299 if (num == 0)
300 {
301 return false;
302 }
303
304 for (int k = 1; k < n - 1; k++)
305 {
306 paramsU[k] = paramsU[k] / num;
307 }
308 paramsU[n - 1] = 1.0;
309
310 num = n;
311
312 for (int k = 0; k < n; k++)
313 {
314 double total = 0.0;
315 for (int l = 1; l < m; l++)
316 {
317 cds[l] = throughPoints[k][l].Distance(throughPoints[k][l - 1]);
318 total += cds[l];
319 }
320 if (MathUtils::IsAlmostEqualTo(total, 0.0))
321 {
322 num--;

Callers

nothing calls this directly

Calls 1

DistanceMethod · 0.45

Tested by

no test coverage detected