From 57ef33c30ba8dcb5cd79ddf99f883ba430fea953 Mon Sep 17 00:00:00 2001 From: Aron Helser Date: Mon, 16 Dec 2019 17:33:56 -0500 Subject: [PATCH] Fix elevateMeshOnStructuredGrid.py, use same data as C++ test --- .gitlab/ci/ctest_exclusions.cmake | 1 - .../python/elevateMeshOnStructuredGrid.py | 48 ++++++++++--------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.gitlab/ci/ctest_exclusions.cmake b/.gitlab/ci/ctest_exclusions.cmake index 95d263823c..7751fad9c3 100644 --- a/.gitlab/ci/ctest_exclusions.cmake +++ b/.gitlab/ci/ctest_exclusions.cmake @@ -1,6 +1,5 @@ set(test_exclusions # Issue #296. - "elevateMeshOnStructuredGridPy" "TestReadWrite" ) string(REPLACE ";" "|" test_exclusions "${test_exclusions}") diff --git a/smtk/mesh/testing/python/elevateMeshOnStructuredGrid.py b/smtk/mesh/testing/python/elevateMeshOnStructuredGrid.py index 2d038ccc64..0ba1072987 100644 --- a/smtk/mesh/testing/python/elevateMeshOnStructuredGrid.py +++ b/smtk/mesh/testing/python/elevateMeshOnStructuredGrid.py @@ -1,4 +1,4 @@ -#============================================================================= +# ============================================================================= # # Copyright (c) Kitware, Inc. # All rights reserved. @@ -8,7 +8,7 @@ # the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR # PURPOSE. See the above copyright notice for more information. # -#============================================================================= +# ============================================================================= import os import sys import unittest @@ -29,9 +29,10 @@ class ValidatePoints(smtk.mesh.PointForEach): Histogram the z-coordinates of the points in the mesh. """ - def __init__(self, nBins, minVal, maxVal): + def __init__(self, nBins, coord, minVal, maxVal): smtk.mesh.PointForEach.__init__(self) self.hist = [0] * nBins + self.coord = coord self.minVal = minVal self.maxVal = maxVal @@ -39,7 +40,7 @@ class ValidatePoints(smtk.mesh.PointForEach): counter = 0 nPts = pointIds.size() for i in range(nPts): - binNo = int((xyz[counter + 2] - self.minVal) / + binNo = int((xyz[counter + self.coord] - self.minVal) / (self.maxVal - self.minVal) * len(self.hist)) if binNo < 0: binNo = 0 @@ -59,7 +60,7 @@ class ElevateMeshOnStructuredGrid(smtk.testing.TestCase): # Set the import operators parameters fname = op.parameters().find('filename') fname.setValue(os.path.join( - smtk.testing.DATA_DIR, 'mesh', '2d', 'atchafalaya_hydraulic_Mesh_18.h5m')) + smtk.testing.DATA_DIR, 'mesh', '2d', 'testSurfaceEdgesSmall.2dm')) # We don't need to construct the BREP hierarchy for this model op.parameters().find('construct hierarchy').setIsEnabled(False) @@ -88,7 +89,7 @@ class ElevateMeshOnStructuredGrid(smtk.testing.TestCase): # Set the location of the auxiliary data file fname = op.parameters().find('url') fname.setValue(os.path.join( - smtk.testing.DATA_DIR, 'dem', 'atchafalaya.dem')) + smtk.testing.DATA_DIR, 'image', 'tiff', 'testSurfaceEdgesSmall.tiff')) # Execute the operator and check its results res = op.operate() @@ -111,21 +112,22 @@ class ElevateMeshOnStructuredGrid(smtk.testing.TestCase): smtk.model.AuxiliaryGeometry(self.auxGeo.modelResource(), self.auxGeo.id()).component()) # Set a threshold range for the input data - inputFilter = op.parameters().find("input filter") - inputFilter.find("min threshold").setIsEnabled(True) - inputFilter.find("min threshold").setValue(-5.) - inputFilter.find("max threshold").setIsEnabled(True) - inputFilter.find("max threshold").setValue(2.) + # inputFilter = op.parameters().find("input filter") + # inputFilter.find("min threshold").setIsEnabled(True) + # inputFilter.find("min threshold").setValue(-5.) + # inputFilter.find("max threshold").setIsEnabled(True) + # inputFilter.find("max threshold").setValue(2.) # Set the interpolation scheme to be radial average op.parameters().find("interpolation scheme").setToDefault() # Set the radial average - op.parameters().find("radius").setValue(100.) + op.parameters().find("radius").setValue(7.) # For points that fall outside of our dataset, do not change their # z-coordinates - op.parameters().find("external point values").setToDefault() + op.parameters().find("external point values").setValue("set to value") + op.parameters().find("external point value").setValue(-1.) # Set the mesh op.parameters().associate(smtk.mesh.Component.create(self.mesh)) @@ -133,9 +135,9 @@ class ElevateMeshOnStructuredGrid(smtk.testing.TestCase): # Clamp the elevation values between -/+ 2 outputFilter = op.parameters().find("output filter") outputFilter.find("min elevation").setIsEnabled(True) - outputFilter.find("min elevation").setValue(-2.) + outputFilter.find("min elevation").setValue(0.) outputFilter.find("max elevation").setIsEnabled(True) - outputFilter.find("max elevation").setValue(2.) + outputFilter.find("max elevation").setValue(250.) # Execute the operator and check its results res = op.operate() @@ -145,20 +147,22 @@ class ElevateMeshOnStructuredGrid(smtk.testing.TestCase): # check the z bounds of the mesh to confirm that clamping was # successful extent = smtk.mesh.extent(self.mesh) - if extent[4] < -2. or extent[5] > 2.: + if extent[4] < -1. or extent[5] > 250.: + print('unexpected mesh extent', extent) raise RuntimeError + validatePointsX = ValidatePoints(10, 0, 0., 250.) + smtk.mesh.for_each(self.mesh.points(), validatePointsX) + # Construct a histogram of the z-coordinates of the mesh points and # compare it to an expected set of values - validatePoints = ValidatePoints(20, -2., 2.) + validatePoints = ValidatePoints(10, 2, 190., 250.) smtk.mesh.for_each(self.mesh.points(), validatePoints) + # print(validatePoints.hist) - expected = [0, 0, 0, 0, 0, - 5115, 2236, 1993, 2694, 2694, - 4105, 1746, 523, 176, 57, - 10, 4, 4, 1, 0] + expected = [127, 13, 8, 17, 27, 18, 24, 12, 24, 524] - for i in range(20): + for i in range(10): if validatePoints.hist[i] != expected[i]: print('Expected {:1} but got {:2} at {:3}.'.format( expected[i], validatePoints.hist[i], i)) -- GitLab