Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 20 additions & 11 deletions Packages/vcs/Lib/vcs2vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -1182,29 +1182,38 @@ def prepMarker(renWin,marker,cmap=None):
return actors

def prepLine(renWin,line,cmap=None):
n = prepPrimitive(line)
if n==0:
number_lines = prepPrimitive(line)

if number_lines == 0:
return

actors = []
for i in range(n):

for i in range(number_lines):
l = vtk.vtkLine()
lines = vtk.vtkCellArray()
x = line.x[i]
y=line.y[i]
c=line.color[i]
w=line.width[i]
t=line.type[i]
N = max(len(x),len(y))
y = line.y[i]
c = line.color[i]
w = line.width[i]
t = line.type[i]
number_points = max(len(x),len(y))

# Extend x or y to the length of the other by duplicating the last coord.
for a in [x,y]:
while len(a)<n:
while len(a)<number_points:
a.append(a[-1])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@doutriaux1 This looks like the same issue we had in 46105aa. Can you check the similar functions in this file and make sure they're treating both n and N correctly?

I think this while len(a) < number_points: a.append(a[-1]) bit should just be assert(len(a) == number_points)(or similar failure) here, too, unless this is an expected feature. Otherwise it would likely just mask user mistakes and give unexpected incorrect results.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well I'm open to this, but historically it would pad it for the user with the last value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gotcha. As long as it's doing what they'd expect it to!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops, and I'd linked the wrong commit earlier -- I meant to point at this one: d8f725a


pts = vtk.vtkPoints()
for j in range(N):

for j in range(number_points):
pts.InsertNextPoint(x[j],y[j],0.)
for j in range(N-1):

for j in range(number_points - 1):
l.GetPointIds().SetId(0,j)
l.GetPointIds().SetId(1,j+1)
lines.InsertNextCell(l)

linesPoly = vtk.vtkPolyData()
geo,pts=project(pts,line.projection,line.worldcoordinate)
linesPoly.SetPoints(pts)
Expand Down
23 changes: 23 additions & 0 deletions testing/vcs/test_vcs_line_point_extension.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import vcs, os, sys

x = vcs.init()

line = x.createline()
line.x = [[0, .1], [.2, .3], [.4, .5], [.6, .7]]
line.y = [[0, .1], [.2, .3, .4], [.5], [.6, .7]]

x.plot(line, bg=1)

if line.x[0] != [0, .1]:
print "line.x[0] should be [0, .1]; is %s" % line.x[0]
sys.exit(-1)

if line.x[1] != [.2, .3, .3]:
print 'line.x[1] should be [.2, .3]; is %s' % line.x[1]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chaosphere2112 should'nt that line say:

+  print 'line.x[1] should be [.2, .3,.3]; is %s' % line.x[1]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yeah, good catch. I'll update that.

sys.exit(-1)

if line.y[2] != [.5, .5]:
print "line.y[2] should be [.5, .5]; is %s" % line.y[2]
sys.exit(-1)

sys.exit(0)