diff --git a/Packages/vcs/Lib/vcs2vtk.py b/Packages/vcs/Lib/vcs2vtk.py index cac6ddad50..1022dcad7d 100644 --- a/Packages/vcs/Lib/vcs2vtk.py +++ b/Packages/vcs/Lib/vcs2vtk.py @@ -858,6 +858,31 @@ def prepFillarea(renWin,ren,farea,cmap=None): n = prepPrimitive(farea) if n==0: return + + # Find color map: + if cmap is None: + if farea.colormap is not None: + cmap = farea.colormap + else: + cmap = 'default' + if isinstance(cmap,str): + cmap = vcs.elements["colormap"][cmap] + + # Create data structures: + pts = vtk.vtkPoints() + polygons = vtk.vtkCellArray() + colors = vtk.vtkUnsignedCharArray() + colors.SetNumberOfComponents(3) + colors.SetNumberOfTuples(n) + polygonPolyData = vtk.vtkPolyData() + polygonPolyData.SetPoints(pts) + polygonPolyData.SetPolys(polygons) + polygonPolyData.GetCellData().SetScalars(colors) + + # Reuse this temporary container to avoid reallocating repeatedly: + polygon = vtk.vtkPolygon() + + # Iterate through polygons: for i in range(n): x = farea.x[i] y = farea.y[i] @@ -865,44 +890,32 @@ def prepFillarea(renWin,ren,farea,cmap=None): st = farea.style[i] idx = farea.index[i] N = max(len(x),len(y)) + for a in [x,y]: - while len(a)