21 #include <xmscore/misc/XmLog.h> 24 #include <xmsgrid/ugrid/XmUGrid.h> 25 #include <xmsgrid/geometry/GmMultiPolyIntersector.h> 26 #include <xmsgrid/geometry/GmMultiPolyIntersectionSorterTerse.h> 54 XmUGrid2dPolylineDataExtractorImpl(std::shared_ptr<XmUGrid> a_ugrid,
59 virtual BSHP<XmUGrid2dDataExtractor> GetDataExtractor()
const override {
return m_extractor; }
60 virtual void SetGridScalars(
const VecFlt& a_pointScalars,
61 const DynBitset& a_activity,
64 virtual void SetPolyline(
const VecPt3d& a_polyline)
override;
65 virtual void ExtractData(VecFlt& a_extractedData)
override;
67 virtual void ComputeLocationsAndExtractData(
const VecPt3d& a_polyline,
68 VecFlt& a_extractedData,
69 VecPt3d& a_extractedLocations)
override;
71 virtual void SetUseIdwForPointData(
bool a_useIdw)
override;
72 virtual void SetNoDataValue(
float a_noDataValue)
override;
76 virtual const VecFlt& GetScalars()
const override {
return m_extractor->GetScalars(); }
83 virtual const VecPt3d& GetExtractLocations()
const override;
86 virtual const VecInt& GetCellIndexes()
const {
return m_extractor->GetCellIndexes(); }
89 virtual bool GetUseIdwForPointData()
const override 95 virtual float GetNoDataValue()
const override {
return m_extractor->GetNoDataValue(); }
98 void ComputeExtractLocations(
const VecPt3d& a_polyline, VecPt3d& a_locations);
101 mutable BSHP<GmMultiPolyIntersector>
117 XmUGrid2dPolylineDataExtractorImpl::XmUGrid2dPolylineDataExtractorImpl(
118 std::shared_ptr<XmUGrid> a_ugrid,
122 if (a_scalarLocation == LOC_UNKNOWN)
124 XM_LOG(xmlog::error,
"Scalar locations are unknown in polyline extractor.");
125 a_scalarLocation = LOC_POINTS;
128 if (a_scalarLocation == LOC_POINTS)
130 VecFlt v(a_ugrid->GetPointCount(), 0.0);
132 m_extractor->SetGridPointScalars(v, act, LOC_POINTS);
134 else if (a_scalarLocation == LOC_CELLS)
136 VecFlt v(a_ugrid->GetCellCount(), 0.0);
138 m_extractor->SetGridCellScalars(v, act, LOC_CELLS);
147 void XmUGrid2dPolylineDataExtractorImpl::SetGridScalars(
const VecFlt& a_scalars,
148 const DynBitset& a_activity,
151 if (
m_extractor->GetScalarLocation() == LOC_POINTS)
152 m_extractor->SetGridPointScalars(a_scalars, a_activity, a_activityLocation);
153 else if (
m_extractor->GetScalarLocation() == LOC_CELLS)
154 m_extractor->SetGridCellScalars(a_scalars, a_activity, a_activityLocation);
161 void XmUGrid2dPolylineDataExtractorImpl::SetPolyline(
const VecPt3d& a_polyline)
165 ComputeExtractLocations(a_polyline, locations);
173 const VecPt3d& XmUGrid2dPolylineDataExtractorImpl::GetExtractLocations()
const 183 void XmUGrid2dPolylineDataExtractorImpl::ExtractData(VecFlt& a_extractedData)
195 void XmUGrid2dPolylineDataExtractorImpl::ComputeLocationsAndExtractData(
196 const VecPt3d& a_polyline,
197 VecFlt& a_extractedData,
198 VecPt3d& a_extractedLocations)
200 SetPolyline(a_polyline);
201 ExtractData(a_extractedData);
202 a_extractedLocations = GetExtractLocations();
208 void XmUGrid2dPolylineDataExtractorImpl::SetUseIdwForPointData(
bool a_useIdw)
217 void XmUGrid2dPolylineDataExtractorImpl::SetNoDataValue(
float a_value)
226 void XmUGrid2dPolylineDataExtractorImpl::ComputeExtractLocations(
const VecPt3d& a_polyline,
227 VecPt3d& a_locations)
230 if (a_polyline.empty())
232 XM_LOG(xmlog::error,
"Attempting to extract polyline profile with empty polyline.");
238 XM_LOG(xmlog::error,
"Attempting to extract polyline profile without setting scalars.");
244 const VecPt3d& points =
m_extractor->GetUGridTriangles()->GetPoints();
245 const VecInt& triangles =
m_extractor->GetUGridTriangles()->GetTriangles();
248 for (
size_t triangleIdx = 0; triangleIdx < triangles.size(); triangleIdx += 3)
250 triangle = {triangles[triangleIdx], triangles[triangleIdx + 1], triangles[triangleIdx + 2]};
251 polygons.push_back(triangle);
254 BSHP<GmMultiPolyIntersectionSorter> sorter(
new GmMultiPolyIntersectionSorterTerse());
259 Pt3d lastPoint = a_polyline[0];
260 a_locations.push_back(lastPoint);
262 for (
size_t polyIdx = 1; polyIdx < a_polyline.size(); ++polyIdx)
264 Pt3d pt1 = a_polyline[polyIdx - 1];
265 Pt3d pt2 = a_polyline[polyIdx];
266 VecInt intersectIdxs;
267 VecPt3d intersectPts;
272 if (intersectIdxs.size() != intersectPts.size())
274 XM_LOG(xmlog::error,
"Internal error when extracting polyline profile.");
278 for (
size_t i = 0; i < intersectIdxs.size(); ++i)
280 const Pt3d& currPoint = intersectPts[i];
281 if (lastPoint != currPoint)
283 if (i != 0 && intersectIdxs[i - 1] == -1)
285 a_locations.push_back((currPoint + lastPoint) / 2.0);
287 a_locations.push_back(currPoint);
288 lastPoint = currPoint;
292 if (pt2 != a_locations.back())
294 a_locations.push_back(pt2);
313 BSHP<XmUGrid2dPolylineDataExtractor> XmUGrid2dPolylineDataExtractor::New(
314 std::shared_ptr<XmUGrid> a_ugrid,
317 BSHP<XmUGrid2dPolylineDataExtractor> extractor(
318 new XmUGrid2dPolylineDataExtractorImpl(a_ugrid, a_scalarLocation));
343 #include <xmscore/misc/xmstype.h> 344 #include <xmscore/testing/TestTools.h> 345 #include <xmsgrid/geometry/geoms.h> 364 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
365 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3};
366 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
367 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
370 VecFlt pointScalars = {0, 2, 3, 1};
371 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
373 VecFlt extractedData;
374 VecPt3d extractedLocations;
375 VecPt3d polyline = {{-1, 0.5, 0}, {2, 0.5, 0}};
376 extractor->SetPolyline(polyline);
377 extractedLocations = extractor->GetExtractLocations();
378 extractor->ExtractData(extractedData);
380 VecFlt expectedData = {XM_NODATA, 0.5, 1.5, 2.5, XM_NODATA};
381 TS_ASSERT_EQUALS(expectedData, extractedData);
382 VecPt3d expectedLocations = {
383 {-1, 0.5, 0}, {0.0, 0.5, 0.0}, {0.5, 0.5, 0.0}, {1.0, 0.5, 0.0}, {2, 0.5, 0}};
384 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
399 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
400 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3};
401 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
402 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
405 VecFlt pointScalars = {0, 2, 3, 1};
406 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
408 VecFlt extractedData;
409 VecPt3d extractedLocations;
410 VecPt3d polyline = {{0.25, 0.50, 0.0}, {0.75, 0.50, 0.0}};
411 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
413 VecFlt expectedData = {1.0, 1.5, 2.0};
414 TS_ASSERT_EQUALS(expectedData, extractedData);
415 VecPt3d expectedLocations = {{0.25, 0.5, 0.0}, {0.5, 0.5, 0.0}, {0.75, 0.5, 0.0}};
416 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
431 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
432 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3};
433 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
434 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
437 VecFlt pointScalars = {0, 2, 3, 1};
438 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
440 VecFlt extractedData;
441 VecPt3d extractedLocations;
442 VecPt3d polyline = {{-0.5, 1.0, 0.0}, {1.55, 1.0, 0.0}};
443 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
445 VecFlt expectedData = {XM_NODATA, 1.0, 3.0, XM_NODATA};
446 TS_ASSERT_EQUALS(expectedData, extractedData);
447 VecPt3d expectedLocations = {
448 {-0.5, 1.0, 0.0}, {0.0, 1.0, 0.0}, {1.0, 1.0, 0.0}, {1.55, 1.0, 0.0}};
449 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
464 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
465 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3};
466 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
467 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
470 VecFlt pointScalars = {0, 2, 3, 1};
471 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
473 VecFlt extractedData;
474 VecPt3d extractedLocations;
475 VecPt3d polyline = {{-0.5, 0.5, 0.0}, {-0.25, 0.5, 0.0}};
476 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
478 VecFlt expectedData = {XM_NODATA, XM_NODATA};
479 TS_ASSERT_EQUALS(expectedData, extractedData);
480 VecPt3d expectedLocations = {{-0.5, 0.5, 0.0}, {-0.25, 0.5, 0.0}};
481 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
496 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
497 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3};
498 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
499 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
502 VecFlt pointScalars = {0, 2, 3, 1};
503 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
505 VecFlt extractedData;
506 VecPt3d extractedLocations;
507 VecPt3d polyline = {{-0.5, 0.5, 0.0}, {0.0, 0.5, 0.0}};
508 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
510 VecFlt expectedData = {XM_NODATA, 0.5};
511 TS_ASSERT_EQUALS(expectedData, extractedData);
512 VecPt3d expectedLocations = {{-0.5, 0.5, 0.0}, {0.0, 0.5, 0.0}};
513 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
528 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
529 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3};
530 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
531 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
534 VecFlt pointScalars = {0, 2, 3, 1};
535 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
537 VecFlt extractedData;
538 VecPt3d extractedLocations;
539 VecPt3d polyline = {{1.0, 0.5, 0.0}, {1.5, 0.5, 0.0}};
540 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
542 VecFlt expectedData = {2.5, XM_NODATA};
543 TS_ASSERT_EQUALS(expectedData, extractedData);
544 VecPt3d expectedLocations = {{1.0, 0.5, 0.0}, {1.5, 0.5, 0.0}};
545 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
562 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
563 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3};
564 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
565 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
568 VecFlt pointScalars = {0, 2, 3, 1};
569 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
571 VecFlt extractedData;
572 VecPt3d extractedLocations;
573 VecPt3d polyline = {{-0.5, 0.5, 0.0}, {0.0, 1.0, 0.0}, {0.5, 1.5, 0.0}};
574 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
576 VecFlt expectedData = {XM_NODATA, 1.0, XM_NODATA};
577 TS_ASSERT_EQUALS(expectedData, extractedData);
578 VecPt3d expectedLocations = {{-0.5, 0.5, 0.0}, {0.0, 1.0, 0.0}, {0.5, 1.5, 0.0}};
579 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
594 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {2, 0, 0}, {2, 1, 0}};
595 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3, XMU_QUAD, 4, 1, 4, 5, 2};
596 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
597 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
600 VecFlt pointScalars = {0, 2, 3, 1, 4, 5};
601 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
603 VecFlt extractedData;
604 VecPt3d extractedLocations;
605 VecPt3d polyline = {{-0.5, 0.5, 0.0}, {1.5, 0.5, 0.0}};
606 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
608 VecFlt expectedData = {XM_NODATA, 0.5, 1.5, 2.5, 3.5};
609 TS_ASSERT_EQUALS(expectedData, extractedData);
610 VecPt3d expectedLocations = {
611 {-0.5, 0.5, 0.0}, {0.0, 0.5, 0.0}, {0.5, 0.5, 0.0}, {1.0, 0.5, 0.0}, {1.5, 0.5, 0.0}};
612 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
627 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0},
628 {2, 0, 0}, {3, 0, 0}, {3, 1, 0}, {2, 1, 0}};
629 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3, XMU_QUAD, 4, 4, 5, 6, 7};
630 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
631 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
634 VecFlt pointScalars = {0, 2, 3, 1, 4, 6, 7, 5};
635 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
637 VecFlt extractedData;
638 VecPt3d extractedLocations;
639 VecPt3d polyline = {{-1, 0.5, 0}, {2.5, 0.5, 0}};
640 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
642 VecFlt expectedData = {XM_NODATA, 0.5, 1.5, 2.5, XM_NODATA, 4.5, 5.5};
643 TS_ASSERT_EQUALS(expectedData, extractedData);
644 VecPt3d expectedLocations = {{-1.0, 0.5, 0.0}, {0.0, 0.5, 0.0}, {0.5, 0.5, 0.0}, {1.0, 0.5, 0.0},
645 {1.5, 0.5, 0.0}, {2.0, 0.5, 0.0}, {2.5, 0.5, 0.0}};
646 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
661 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
662 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3};
663 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
664 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
667 VecFlt pointScalars = {0, 2, 3, 1};
668 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
670 VecFlt extractedData;
671 VecPt3d extractedLocations;
672 VecPt3d polyline = {{-1, 0.5, 0}, {0.5, 0.5, 0.0}, {2, 0.5, 0}};
673 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
675 VecFlt expectedData = {XM_NODATA, 0.5, 1.5, 2.5, XM_NODATA};
676 TS_ASSERT_EQUALS(expectedData, extractedData);
677 VecPt3d expectedLocations = {
678 {-1.0, 0.5, 0.0}, {0.0, 0.5, 0.0}, {0.5, 0.5, 0.0}, {1.0, 0.5, 0.0}, {2.0, 0.5, 0.0}};
679 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
694 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
695 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3};
696 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
697 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
700 VecFlt pointScalars = {0, 2, 3, 1};
701 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
703 VecFlt extractedData;
704 VecPt3d extractedLocations;
705 VecPt3d polyline = {{2.0, 0.5, 0}, {3.0, 0.5, 0.0}, {4.0, 0.5, 0.0}};
706 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
708 VecFlt expectedData = {XM_NODATA, XM_NODATA, XM_NODATA};
709 TS_ASSERT_EQUALS(expectedData, extractedData);
710 VecPt3d expectedLocations = {{2.0, 0.5, 0}, {3.0, 0.5, 0.0}, {4.0, 0.5, 0.0}};
711 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
726 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
727 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3};
728 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
729 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
732 VecFlt pointScalars = {0, 2, 3, 1};
733 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
735 VecFlt extractedData;
736 VecPt3d extractedLocations;
737 VecPt3d polyline = {{0.5, 0.5, 0}, {3.0, 0.5, 0.0}, {4.0, 0.5, 0.0}};
738 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
740 VecFlt expectedData = {1.5, 2.5, XM_NODATA, XM_NODATA};
741 TS_ASSERT_EQUALS(expectedData, extractedData);
742 VecPt3d expectedLocations = {{0.5, 0.5, 0}, {1.0, 0.5, 0}, {3.0, 0.5, 0.0}, {4.0, 0.5, 0.0}};
743 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
758 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {2, 0, 0}, {2, 1, 0}};
759 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3, XMU_QUAD, 4, 1, 4, 5, 2};
760 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
761 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
764 VecFlt pointScalars = {0, 2, 3, 1, 4, 5};
765 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
767 VecFlt extractedData;
768 VecPt3d extractedLocations;
769 VecPt3d polyline = {{0.5, 0.5, 0.0}, {1.5, 0.5, 0.0}, {2.5, 0.5, 0.0}};
770 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
772 VecFlt expectedData = {1.5, 2.5, 3.5, 4.5, XM_NODATA};
773 TS_ASSERT_EQUALS(expectedData, extractedData);
774 VecPt3d expectedLocations = {
775 {0.5, 0.5, 0.0}, {1.0, 0.5, 0.0}, {1.5, 0.5, 0.0}, {2.0, 0.5, 0.0}, {2.5, 0.5, 0.0}};
776 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
791 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {2, 0, 0}, {2, 1, 0}};
792 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3, XMU_QUAD, 4, 1, 4, 5, 2};
793 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
794 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
797 VecFlt pointScalars = {0, 2, 3, 1, 4, 5};
798 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
800 VecFlt extractedData;
801 VecPt3d extractedLocations;
802 VecPt3d polyline = {{0.5, 0.5, 0.0}, {1.0, 0.5, 0.0}, {2.5, 0.5, 0.0}};
803 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
805 VecFlt expectedData = {1.5, 2.5, 3.5, 4.5, XM_NODATA};
806 TS_ASSERT_EQUALS(expectedData, extractedData);
807 VecPt3d expectedLocations = {
808 {0.5, 0.5, 0.0}, {1.0, 0.5, 0.0}, {1.5, 0.5, 0.0}, {2.0, 0.5, 0.0}, {2.5, 0.5, 0.0}};
809 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
824 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}};
825 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3};
826 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
827 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
830 VecFlt pointScalars = {0, 2, 3, 1};
831 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_POINTS);
833 VecFlt extractedData;
834 VecPt3d extractedLocations;
835 VecPt3d polyline = {{0.5, 0.5, 0}, {1.5, 0.5, 0.0}, {1.5, 0.0, 0.0}, {0.5, 1.0, 0.0}};
836 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
838 VecFlt expectedData = {1.5, 2.5, XM_NODATA, XM_NODATA, 2.5, 2.25, 2.0};
839 TS_ASSERT_EQUALS(expectedData, extractedData);
840 VecPt3d expectedLocations = {{0.5, 0.5, 0}, {1.0, 0.5, 0}, {1.5, 0.5, 0.0}, {1.5, 0.0, 0.0},
841 {1.0, 0.5, 0}, {0.75, 0.75, 0.0}, {0.5, 1.0, 0.0}};
842 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
857 VecPt3d points = {{0, 0, 0}, {1, 0, 0}, {1, 1, 0}, {0, 1, 0}, {2, 0, 0}, {2, 1, 0}};
858 VecInt cells = {XMU_QUAD, 4, 0, 1, 2, 3, XMU_QUAD, 4, 1, 4, 5, 2};
859 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
860 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
863 VecFlt cellScalars = {1, 2};
864 extractor->SetGridScalars(cellScalars, DynBitset(), LOC_CELLS);
866 VecFlt extractedData;
867 VecPt3d extractedLocations;
868 VecPt3d polyline = {{-0.5, 0.75, 0.0}, {1.5, 0.75, 0.0}};
869 extractor->ComputeLocationsAndExtractData(polyline, extractedData, extractedLocations);
871 VecFlt expectedData = {XM_NODATA, 1.0, 1.0, 1.25, 1.5, 1.75, 1.875};
872 TS_ASSERT_EQUALS(expectedData, extractedData);
873 VecPt3d expectedLocations = {{-0.5, 0.75, 0.0}, {0.0, 0.75, 0.0}, {0.25, 0.75, 0.0},
874 {0.75, 0.75, 0.0}, {1., 0.75, 0.0}, {1.25, 0.75, 0.0},
876 TS_ASSERT_EQUALS(expectedLocations, extractedLocations);
885 VecPt3d points = {{288050, 3907770, 0}, {294050, 3907770, 0}, {300050, 3907770, 0},
886 {306050, 3907770, 0}, {288050, 3901770, 0}, {294050, 3901770, 0},
887 {300050, 3901770, 0}, {306050, 3901770, 0}, {288050, 3895770, 0},
888 {294050, 3895770, 0}, {300050, 3895770, 0}, {306050, 3895770, 0}};
889 VecInt cells = {XMU_QUAD, 4, 0, 4, 5, 1, XMU_QUAD, 4, 1, 5, 6, 2, XMU_QUAD, 4, 2, 6, 7, 3,
890 XMU_QUAD, 4, 4, 8, 9, 5, XMU_QUAD, 4, 5, 9, 10, 6, XMU_QUAD, 4, 6, 10, 11, 7};
891 std::shared_ptr<XmUGrid> ugrid = XmUGrid::New(points, cells);
893 BSHP<XmUGrid2dPolylineDataExtractor> extractor =
897 extractor->SetNoDataValue(-999.0);
900 VecPt3d extractedLocations;
902 {290764, 3895106, 0}, {291122, 3909108, 0}, {302772, 3909130, 0}, {302794, 3895775, 0}};
903 extractor->SetPolyline(polyline);
906 extractedLocations = extractor->GetExtractLocations();
907 VecPt3d expectedLocations = {
908 {290764.0, 3895106.0, 0.0}, {290780.9, 3895770.0, 0.0}, {290862.4, 3898957.5, 0.0},
909 {290934.3, 3901770.0, 0.0}, {291012.0, 3904807.9, 0.0}, {291087.7, 3907770.0, 0.0},
910 {291122.0, 3909108.0, 0.0}, {302772.0, 3909130.0, 0.0}, {302774.2, 3907770.0, 0.0},
911 {302778.7, 3905041.2, 0.0}, {302784.1, 3901770.0, 0.0}, {302788.6, 3899031.3, 0.0},
912 {302794.0, 3895775.0, 0.0},
914 TS_ASSERT_DELTA_VECPT3D(expectedLocations, extractedLocations, 0.15);
916 VecFlt extractedData;
920 VecFlt pointScalars = {730.787f, 1214.54f, 1057.145f, 629.2069f, 351.1153f, 631.6649f,
921 1244.366f, 449.9133f, 64.04247f, 240.9716f, 680.0491f, 294.9547f};
922 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_CELLS);
924 extractor->ExtractData(extractedData);
925 VecFlt expectedData = {-999.0f, 144.5f, 299.4f, 485.9f, 681.8f, 975.7f, -999.0f,
926 -999.0f, 862.8f, 780.9f, 882.3f, 811.0f, 504.4f};
927 TS_ASSERT_DELTA_VEC(expectedData, extractedData, 0.2);
931 pointScalars = {-999.0f, 1220.5f, 1057.1f, 613.2f, 380.1f, 625.6f,
932 722.2f, 449.9f, 51.0f, 240.9f, 609.0f, 294.9f};
933 extractor->SetGridScalars(pointScalars, DynBitset(), LOC_CELLS);
934 extractor->ExtractData(extractedData);
935 expectedData = {-999.0f, 137.4f, 314.8f, 498.1f, -196.9f, 124.7f, -999.0f,
936 -999.0f, 855.5f, 780.9f, 598.1f, 527.1f, 465.4f};
937 TS_ASSERT_DELTA_VEC(expectedData, extractedData, 0.2);
DataLocationEnum
The location at which the data will be stored.
Contains the XmUGrid Class and supporting data types.