Skip to content

Commit c4ab618

Browse files
committed
PEP8 conformace. Set default plane normal to [0, 0, 1].
1 parent 4a2ad07 commit c4ab618

5 files changed

Lines changed: 14 additions & 6 deletions

File tree

mapclientplugins/segmentationstep/maths/algorithms.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from mapclientplugins.segmentationstep.maths.vectorops import add, cross, div, dot, normalize, sub, mult
2424
from mapclientplugins.segmentationstep.misc import checkRange
2525

26+
2627
def boundCoordinatesToCuboid(pt1, pt2, cuboid_dimensions):
2728
'''
2829
Takes two points and a cuboids dimensions, with
@@ -63,6 +64,7 @@ def boundCoordinatesToCuboid(pt1, pt2, cuboid_dimensions):
6364

6465
return bounded_pt
6566

67+
6668
def pointOutsideCuboid(pt, cuboid_dimensions):
6769
'''
6870
Determine if the given point is outside the cuboid and
@@ -86,6 +88,7 @@ def pointOutsideCuboid(pt, cuboid_dimensions):
8688

8789
return outside
8890

91+
8992
def calculateLinePlaneIntersection(pt1, pt2, point_on_plane, plane_normal):
9093
line_direction = sub(pt2, pt1)
9194
d = dot(sub(point_on_plane, pt1), plane_normal) / dot(line_direction, plane_normal)
@@ -95,6 +98,7 @@ def calculateLinePlaneIntersection(pt1, pt2, point_on_plane, plane_normal):
9598

9699
return None
97100

101+
98102
def calculateCentroid(point_on_plane, plane_normal, cuboid_dimensions):
99103
'''
100104
Takes a description of a plane as a point on the plane
@@ -143,6 +147,7 @@ def calculateCentroid(point_on_plane, plane_normal, cuboid_dimensions):
143147
plane_centre = ca.compute()
144148
return plane_centre
145149

150+
146151
class CentroidAlgorithm(object):
147152

148153
def __init__(self, xi):
@@ -227,12 +232,14 @@ def _calculateCxCy(vertices, area):
227232
cy /= 6 * area
228233
return cx, cy
229234

235+
230236
def _calculatePolygonArea(vertices):
231237
area = 0.0
232238
for i in range(len(vertices) - 1):
233239
area += (vertices[i][0] * vertices[i + 1][1] - vertices[i + 1][0] * vertices[i][1])
234240
return 0.5 * area
235241

242+
236243
def _calculateHeading(direction):
237244
'''
238245
Convert a vector based direction into a heading

mapclientplugins/segmentationstep/model/image.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
from mapclientplugins.segmentationstep.zincutils import createFiniteElementField, createFiniteElement
2727
from mapclientplugins.segmentationstep.misc import alphanum_key
2828

29+
2930
class ImageModel(AbstractModel):
3031
'''
3132
A model of the image region containing a
@@ -45,6 +46,7 @@ def __init__(self, context):
4546

4647
def loadImages(self, dataIn):
4748
self._image_field = self._createImageField(dataIn)
49+
self._dimensions_px = self._image_field.getSizeInPixels(3)[1]
4850

4951
def initialize(self):
5052
scale = [1.0, 1.0, 1.0]
@@ -230,15 +232,11 @@ def _createImageField(self, dataIn):
230232
# We are reading in a file from the local disk so our resource is a file.
231233
absolute_filename = os.path.join(directory, filename)
232234
if os.path.isfile(absolute_filename):
233-
# SWIG cannot handle unicode strings or rather the Zinc interface
234-
# files cannot handle unicode strings so we convert them to ascii
235-
# here.
236235
stream_information.createStreamresourceFile(absolute_filename)
237236

238237
# Actually read in the image file into the image field.
239238
image_field.read(stream_information)
240239

241-
self._dimensions_px = image_field.getSizeInPixels(3)[1]
242240
return image_field
243241

244242
def _setImageTextureSize(self, size):

mapclientplugins/segmentationstep/plane.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def getAttitude(self):
9999

100100

101101
def _createNormalField(fieldmodule):
102-
plane_normal_field = fieldmodule.createFieldConstant([1, 0, 0])
102+
plane_normal_field = fieldmodule.createFieldConstant([0, 0, 1])
103103
return plane_normal_field
104104

105105
def _createRotationPointField(fieldmodule):

mapclientplugins/segmentationstep/step.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def execute(self):
9292
self._model.initialize()
9393
self._view = SegmentationWidget(self._model)
9494
self._view.setSerializationLocation(os.path.join(self._location, self.getIdentifier()))
95-
self._view._ui.doneButton.clicked.connect(self._doneExecution)
95+
self._view.registerDoneExecution(self._doneExecution)
9696

9797
self._setCurrentUndoRedoStack(self._model.getUndoRedoStack())
9898
self._setCurrentWidget(self._view)

mapclientplugins/segmentationstep/widgets/segmentationwidget.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ def _setupUi(self):
102102
self._ui._lineEditYOffset.setText(str(offset[1]))
103103
self._ui._lineEditZOffset.setText(str(offset[2]))
104104

105+
def registerDoneExecution(self, callback):
106+
self._ui.doneButton.clicked.connect(callback)
107+
105108
def setSerializationLocation(self, location):
106109
self._serialization_location = location
107110

0 commit comments

Comments
 (0)