From 7d77059339edff77aa21f5a5757d9a2b9d34843a Mon Sep 17 00:00:00 2001 From: Steven Walton Date: Mon, 6 May 2019 17:48:07 -0700 Subject: [PATCH] Getting there with ES --- vtkm/worklet/ExtractStructured.h | 134 +++++------------- .../testing/UnitTestExtractStructured.cxx | 18 ++- 2 files changed, 40 insertions(+), 112 deletions(-) diff --git a/vtkm/worklet/ExtractStructured.h b/vtkm/worklet/ExtractStructured.h index 5aa7ef331..a3784d014 100644 --- a/vtkm/worklet/ExtractStructured.h +++ b/vtkm/worklet/ExtractStructured.h @@ -219,96 +219,7 @@ public: // Verify input parameters vtkm::Vec ptdim(cellset.GetPointDimensions()); vtkm::Vec offset_vec; - vtkm::Vec voiSubset; - //if(includeOffset) - //{ - // offset_vec = cellset.GetGlobalPointIndexStart(); - // //ptdim[0] += offset_vec[0]; - // //ptdim[1] += offset_vec[1]; - // //if(Dimensionality == 3) - // // ptdim[2] += offset_vec[2]; - //} - voiSubset[0] = vtkm::Max(vtkm::Id(0), voi.X.Min); - voiSubset[1] = vtkm::Min(this->InputDimensions[0], voi.X.Max); - if (includeOffset) - { - offset_vec = cellset.GetGlobalPointIndexStart(); - if (voi.X.Min < offset_vec[0]) - { - voiSubset[0] = offset_vec[0]; - } - else if (voi.X.Min > offset_vec[0] && voi.X.Min < offset_vec[0] + ptdim[0]) - { - voiSubset[0] = voi.X.Min; - } - if (voi.X.Max < offset_vec[0]) - { - voiSubset[1] = offset_vec[0]; - } - else if (voi.X.Max > offset_vec[0]) - { - if (voi.X.Max > offset_vec[0] + ptdim[0]) - { - voiSubset[1] = offset_vec[0] + ptdim[0]; - } - else - { - voiSubset[1] = voi.X.Max - offset_vec[0]; - } - } - if (Dimensionality >= 2) - { - if (voi.Y.Min < offset_vec[2]) - { - voiSubset[2] = offset_vec[2]; - } - else if (voi.Y.Min > offset_vec[2] && voi.Y.Min < offset_vec[2] + ptdim[1]) - { - voiSubset[2] = voi.Y.Min; - } - if (voi.Y.Max < offset_vec[2]) - { - voiSubset[3] = offset_vec[2]; - } - else if (voi.Y.Max > offset_vec[2]) - { - if (voi.Y.Max > offset_vec[2] + ptdim[1]) - { - voiSubset[3] = offset_vec[2] + ptdim[1]; - } - else - { - voiSubset[3] = voi.Y.Max - offset_vec[2]; - } - } - } - if (Dimensionality >= 3) - { - if (voi.Y.Min < offset_vec[4]) - { - voiSubset[4] = offset_vec[4]; - } - else if (voi.Y.Min > offset_vec[4] && voi.Y.Min < offset_vec[4] + ptdim[2]) - { - voiSubset[4] = voi.Y.Min; - } - if (voi.Y.Max < offset_vec[4]) - { - voiSubset[5] = offset_vec[4]; - } - else if (voi.Y.Max > offset_vec[4]) - { - if (voi.Y.Max > offset_vec[4] + ptdim[2]) - { - voiSubset[5] = offset_vec[4] + ptdim[2]; - } - else - { - voiSubset[5] = voi.Y.Max - offset_vec[4]; - } - } - } - } + this->SampleRate = vtkm::Id3(sampleRate[0], 1, 1); this->InputDimensions = vtkm::Id3(ptdim[0], 1, 1); @@ -348,18 +259,37 @@ public: this->InputDimensionality = Dimensionality; // intersect VOI - //this->VOI.X.Min = vtkm::Max(vtkm::Id(0), voi.X.Min); - //this->VOI.X.Max = vtkm::Min(this->InputDimensions[0], voi.X.Max); - this->VOI.X.Min = voiSubset[0]; - this->VOI.X.Max = voiSubset[1]; - this->VOI.Y.Min = voiSubset[2]; - this->VOI.Y.Max = voiSubset[3]; - this->VOI.Z.Min = voiSubset[4]; - this->VOI.Z.Max = voiSubset[5]; - //this->VOI.Y.Min = vtkm::Max(vtkm::Id(0), voi.Y.Min); - //this->VOI.Y.Max = vtkm::Min(this->InputDimensions[1], voi.Y.Max); - //this->VOI.Z.Min = vtkm::Max(vtkm::Id(0), voi.Z.Min); - //this->VOI.Z.Max = vtkm::Min(this->InputDimensions[2], voi.Z.Max); + if (includeOffset) + { + offset_vec = cellset.GetGlobalPointIndexStart(); + if (voi.X.Min < offset_vec[0]) + this->VOI.X.Min = vtkm::Max(vtkm::Id(0), offset_vec[0]); + if (voi.X.Max < offset_vec[0]) + this->VOI.X.Max = vtkm::Min(this->InputDimensions[0], offset_vec[0]); + if (Dimensionality >= 2) + { + if (voi.Y.Min < offset_vec[1]) + this->VOI.Y.Min = vtkm::Max(vtkm::Id(0), offset_vec[1]); + if (voi.Y.Max < offset_vec[1]) + this->VOI.Y.Max = vtkm::Min(this->InputDimensions[1], offset_vec[1]); + if (Dimensionality == 3) + { + if (voi.Z.Min < offset_vec[2]) + this->VOI.Z.Min = vtkm::Max(vtkm::Id(0), offset_vec[2]); + if (voi.Z.Max < offset_vec[2]) + this->VOI.Z.Max = vtkm::Min(this->InputDimensions[2], offset_vec[2]); + } + } + } + else // includeOffset = false + { + this->VOI.X.Min = vtkm::Max(vtkm::Id(0), voi.X.Min); + this->VOI.X.Max = vtkm::Min(this->InputDimensions[0], voi.X.Max); + this->VOI.Y.Min = vtkm::Max(vtkm::Id(0), voi.Y.Min); + this->VOI.Y.Max = vtkm::Min(this->InputDimensions[1], voi.Y.Max); + this->VOI.Z.Min = vtkm::Max(vtkm::Id(0), voi.Z.Min); + this->VOI.Z.Max = vtkm::Min(this->InputDimensions[2], voi.Z.Max); + } if (!this->VOI.IsNonEmpty()) // empty VOI { return DynamicCellSetStructured(); diff --git a/vtkm/worklet/testing/UnitTestExtractStructured.cxx b/vtkm/worklet/testing/UnitTestExtractStructured.cxx index 4ec16e971..b05f88395 100644 --- a/vtkm/worklet/testing/UnitTestExtractStructured.cxx +++ b/vtkm/worklet/testing/UnitTestExtractStructured.cxx @@ -43,7 +43,7 @@ public: vtkm::RangeId3 range(1, 4, 1, 4, 0, 1); vtkm::Id3 sample(1, 1, 1); bool includeBoundary = false; - bool includeOffset = true; + bool includeOffset = false; vtkm::worklet::ExtractStructured worklet; auto outCellSet = worklet.Run(cellSet, range, sample, includeBoundary, includeOffset); @@ -71,7 +71,7 @@ public: vtkm::RangeId3 range0(1, 4, 1, 4, 1, 4); vtkm::Id3 sample(1, 1, 1); bool includeBoundary = false; - bool includeOffset = true; + bool includeOffset = false; outCellSet = worklet.Run(cellSet, range0, sample, includeBoundary, includeOffset); VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 27), @@ -137,8 +137,9 @@ public: vtkm::RangeId3 range0(0, 5, 0, 5, 1, 4); vtkm::Id3 sample0(2, 2, 1); bool includeBoundary0 = false; + bool includeOffset = false; - outCellSet = worklet.Run(cellSet, range0, sample0, includeBoundary0, false); + outCellSet = worklet.Run(cellSet, range0, sample0, includeBoundary0, includeOffset); VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 27), "Wrong result for ExtractStructured worklet"); @@ -150,7 +151,7 @@ public: vtkm::Id3 sample1(3, 3, 2); bool includeBoundary1 = false; - outCellSet = worklet.Run(cellSet, range1, sample1, includeBoundary1, false); + outCellSet = worklet.Run(cellSet, range1, sample1, includeBoundary1, includeOffset); VTKM_TEST_ASSERT(test_equal(outCellSet.GetNumberOfPoints(), 8), "Wrong result for ExtractStructured worklet"); @@ -161,7 +162,6 @@ public: vtkm::RangeId3 range2(0, 5, 0, 5, 1, 4); vtkm::Id3 sample2(3, 3, 2); bool includeBoundary2 = true; - bool includeOffset = true; outCellSet = worklet.Run(cellSet, range2, sample2, includeBoundary2, includeOffset); @@ -234,7 +234,6 @@ public: dataSet.GetCellSet(0).CopyTo(cellSet); // RangeID3 and subsample - //vtkm::RangeId3 range(0,2,0,2,0,2); vtkm::RangeId3 range(5, 15, 0, 10, 0, 10); vtkm::Id3 sample(1, 1, 1); vtkm::Id3 test_offset(1, 1, 1); @@ -242,7 +241,7 @@ public: vtkm::Id3 no_offset(0, 0, 0); const vtkm::Int32 Dimensionality = 3; bool includeBoundary = false; - bool includeOffset = true; + bool includeOffset = false; cellSet.SetPointDimensions(vtkm::make_Vec(10, 0, 0)); vtkm::Vec ptdim(cellSet.GetPointDimensions()); @@ -253,11 +252,10 @@ public: VTKM_TEST_ASSERT(test_equal(cellSet.GetGlobalPointIndexStart(), no_offset)); + includeOffset = true; + outCellSet = worklet.Run(cellSet, range, sample, includeBoundary, includeOffset); cellSet.SetGlobalPointIndexStart(test_offset); VTKM_TEST_ASSERT(test_equal(cellSet.GetPointDimensions(), test_offset)); - - //VTKM_TEST_ASSERT(test_equal(worklet.GetIncludeOffset(), includeOffset)); - //VTKM_TEST_ASSERT(test_equal(outCellSet.GetIncludeOffset(), false)); } void operator()() const