From 0aea5fb69ae000db5e3a910e467b8f48adc48e9e Mon Sep 17 00:00:00 2001 From: Dan Lipsa Date: Mon, 26 Feb 2018 15:51:11 -0500 Subject: [PATCH] Test for fillarea concave. (#319) * Support concave polygons for fillarea. * Test for fillarea concave. * Don't make doctest to avoid timeout. --- .travis.yml | 3 --- tests/test_vcs_fillarea_concave.py | 19 +++++++++++++++++++ vcs/vcs2vtk.py | 6 +++++- 3 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 tests/test_vcs_fillarea_concave.py diff --git a/.travis.yml b/.travis.yml index b79ac683a..e3d75b7ae 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,8 +28,5 @@ script: - rm -rf build - python setup.py install --old-and-unmanageable - python run_tests.py -n2 -g --no-vtk-ui - #- cd docs - #- make doctest - #- cd .. after_success: - if [ "$TRAVIS_BRANCH" == "master" -a "$TRAVIS_PULL_REQUEST" == "false" ]; then conda install -n root conda-build anaconda-client && bash ci-support/conda_upload.sh ; fi diff --git a/tests/test_vcs_fillarea_concave.py b/tests/test_vcs_fillarea_concave.py new file mode 100644 index 000000000..ffee4a95f --- /dev/null +++ b/tests/test_vcs_fillarea_concave.py @@ -0,0 +1,19 @@ +import basevcstest + + +class TestVCSFillareaConcave(basevcstest.VCSBaseTest): + def test(self): + o = self.x.createfillarea() + xs = [-70.0, -66.0, -62.0, -58.0, -54.0, -50.0, + -46.0, -46.0, -50.0, -54.0, -58.0, -62.0, + -66.0, -70.0] + ys = [97.40004179212772, 99.24051369561087, 99.64501380920407, + 99.50791666242807, 99.25809764862053, 98.72724999321828, + 97.86243057250978, 66.1760279867384, 78.08891693751016, + 84.6064443588257, 75.83586128552756, 54.88270839055378, + 33.08841943740845, 32.207757042513954] + o.x = xs + o.y = ys + o.worldcoordinate = [-70,-35,30,100] + self.x.plot(o) + self.checkImage("test_vcs_fillarea_concave.png") diff --git a/vcs/vcs2vtk.py b/vcs/vcs2vtk.py index 9fc53e064..652a78b59 100644 --- a/vcs/vcs2vtk.py +++ b/vcs/vcs2vtk.py @@ -1437,9 +1437,13 @@ def prepFillarea(context, renWin, farea, cmap=None): # Transform points geo, pts = project(pts, farea.projection, farea.worldcoordinate) polygonPolyData.SetPoints(pts) + # for concave polygons + tris = vtk.vtkTriangleFilter() + tris.SetInputData(polygonPolyData) + # Setup rendering m = vtk.vtkPolyDataMapper() - m.SetInputData(polygonPolyData) + m.SetInputConnection(tris.GetOutputPort()) a = vtk.vtkActor() a.SetMapper(m) ren, xscale, yscale = context.fitToViewport(a,