Skip to content
Snippets Groups Projects
Commit 75586031 authored by Paul McCarthy's avatar Paul McCarthy
Browse files

ModelOpts bounds were incorrectly ordered - sometimes low bounds could

be > high bounds, causing rendering/bounds calculation problems. Other
minor fixes.
parent 38b29eef
No related branches found
No related tags found
No related merge requests found
...@@ -54,7 +54,6 @@ def loadVTKPolydataFile(infile): ...@@ -54,7 +54,6 @@ def loadVTKPolydataFile(infile):
indexOffset += polygonLengths[i] indexOffset += polygonLengths[i]
return vertices, polygonLengths, indices return vertices, polygonLengths, indices
...@@ -84,6 +83,9 @@ class Model(object): ...@@ -84,6 +83,9 @@ class Model(object):
self.vertices = np.array(data, dtype=np.float32) self.vertices = np.array(data, dtype=np.float32)
self.indices = indices self.indices = indices
self.__loBounds = self.vertices.min(axis=0)
self.__hiBounds = self.vertices.max(axis=0)
log.memory('{}.init ({})'.format(type(self).__name__, id(self))) log.memory('{}.init ({})'.format(type(self).__name__, id(self)))
...@@ -101,5 +103,4 @@ class Model(object): ...@@ -101,5 +103,4 @@ class Model(object):
def getBounds(self): def getBounds(self):
return (self.vertices.min(axis=0), return (self.__loBounds, self.__hiBounds)
self.vertices.max(axis=0))
...@@ -95,10 +95,8 @@ class ModelOpts(fsldisplay.DisplayOpts): ...@@ -95,10 +95,8 @@ class ModelOpts(fsldisplay.DisplayOpts):
def getCoordSpaceTransform(self): def getCoordSpaceTransform(self):
if self.refImage == 'none': if self.refImage == 'none' or \
return None self.coordSpace == self.transform:
if self.coordSpace == self.transform:
return None return None
opts = self.displayCtx.getOpts(self.refImage) opts = self.displayCtx.getOpts(self.refImage)
...@@ -147,7 +145,7 @@ class ModelOpts(fsldisplay.DisplayOpts): ...@@ -147,7 +145,7 @@ class ModelOpts(fsldisplay.DisplayOpts):
if self.refImage != 'none': if self.refImage != 'none':
refOpts = self.displayCtx.getOpts(self.refImage) refOpts = self.displayCtx.getOpts(self.refImage)
newLoc = refOpts.transformDisplayLocation(propName, oldLoc) newLoc = refOpts.transformDisplayLocation(oldLoc)
return newLoc return newLoc
...@@ -167,7 +165,7 @@ class ModelOpts(fsldisplay.DisplayOpts): ...@@ -167,7 +165,7 @@ class ModelOpts(fsldisplay.DisplayOpts):
self.__lastPropChanged = 'refImage' self.__lastPropChanged = 'refImage'
if self.__oldRefImage != 'none' and \ if self.__oldRefImage != 'none' and \
self.__oldRefImage in self._overlayList: self.__oldRefImage in self.overlayList:
opts = self.displayCtx.getOpts(self.__oldRefImage) opts = self.displayCtx.getOpts(self.__oldRefImage)
self.unbindProps('transform', opts) self.unbindProps('transform', opts)
...@@ -192,7 +190,9 @@ class ModelOpts(fsldisplay.DisplayOpts): ...@@ -192,7 +190,9 @@ class ModelOpts(fsldisplay.DisplayOpts):
xform = self.getCoordSpaceTransform() xform = self.getCoordSpaceTransform()
if xform is not None: if xform is not None:
lohi = transform.transform([lo, hi], xform)
lohi = transform.transform([lo, hi], xform)
lohi.sort(axis=0)
lo, hi = lohi[0, :], lohi[1, :] lo, hi = lohi[0, :], lohi[1, :]
self.bounds = [lo[0], hi[0], lo[1], hi[1], lo[2], hi[2]] self.bounds = [lo[0], hi[0], lo[1], hi[1], lo[2], hi[2]]
......
...@@ -184,6 +184,9 @@ class ImageOpts(fsldisplay.DisplayOpts): ...@@ -184,6 +184,9 @@ class ImageOpts(fsldisplay.DisplayOpts):
def transformDisplayLocation(self, oldLoc): def transformDisplayLocation(self, oldLoc):
lastVal = self.getLastValue('transform') lastVal = self.getLastValue('transform')
if lastVal is None:
lastVal = self.transform
# Calculate the image world location using the # Calculate the image world location using the
# old display<-> world transform, then transform # old display<-> world transform, then transform
......
...@@ -229,8 +229,9 @@ class GLModel(globject.GLObject): ...@@ -229,8 +229,9 @@ class GLModel(globject.GLObject):
# the cross-section mask will not be created # the cross-section mask will not be created
# correctly. # correctly.
direction = [gl.GL_INCR, gl.GL_DECR] direction = [gl.GL_INCR, gl.GL_DECR]
if np.any(hi < lo): faceOrder = [gl.GL_FRONT, gl.GL_BACK]
else: faceOrder = [gl.GL_BACK, gl.GL_FRONT] if np.any(np.array(hi) < 0.0): faceOrder = [gl.GL_FRONT, gl.GL_BACK]
else: faceOrder = [gl.GL_BACK, gl.GL_FRONT]
for face, direction in zip(faceOrder, direction): for face, direction in zip(faceOrder, direction):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment