Commit 7b3a7227 authored by Stephen Thompson's avatar Stephen Thompson

Issue #2 added ui files

parent eb306911
Pipeline #2181 passed with stages
in 14 minutes and 22 seconds
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -4,3 +4,5 @@
# doc/requirements.rst
numpy
scipy
vtk
scikit-surgeryvtk
......@@ -11,26 +11,20 @@ from sksurgeryspherefitting.ui.sksurgeryspherefitting_demo import run_demo
def main(args=None):
"""Entry point for scikit-surgery-sphere-fitting application"""
parser = argparse.ArgumentParser(description='scikit-surgery-sphere-fitting')
parser = argparse.ArgumentParser(
description='scikit-surgery-sphere-fitting')
## ADD POSITIONAL ARGUMENTS
parser.add_argument("x",
type=int,
help="1st number")
parser.add_argument("y",
type=int,
help="2nd number")
parser.add_argument("model",
type=str,
help="Filename for vtk surface model")
# ADD OPTINAL ARGUMENTS
parser.add_argument("-m", "--multiply",
action="store_true",
help="Enable multiplication of inputs."
)
parser.add_argument("-v", "--verbose",
action="store_true",
help="Enable verbose output",
parser.add_argument("-o", "--output",
required=False,
type=str,
default="",
help="Write the fitted sphere to file"
)
version_string = __version__
......@@ -38,8 +32,10 @@ def main(args=None):
parser.add_argument(
"--version",
action='version',
version='scikit-surgery-sphere-fitting version ' + friendly_version_string)
version='scikit-surgery-sphere-fitting version '
+ friendly_version_string
)
args = parser.parse_args(args)
run_demo(args.x, args.y, args.multiply, args.verbose)
run_demo(args.model, args.output)
# coding=utf-8
"""Hello world demo module"""
from sksurgeryspherefitting.algorithms import addition, multiplication
"""Uses sphere fitting to fit to vtk model"""
import vtk
from sksurgeryvtk.models.vtk_surface_model import VTKSurfaceModel
from sksurgeryspherefitting.algorithms import sphere_fitting
def run_demo(input_x, input_y, multiply, verbose):
def run_demo(model_file_name, output=""):
""" Run the application """
model = VTKSurfaceModel(model_file_name, [1., 0., 0.])
x_values = model.get_points_as_numpy()[:, 0]
y_values = model.get_points_as_numpy()[:, 1]
z_values = model.get_points_as_numpy()[:, 2]
if multiply:
result = multiplication.multiply_two_numbers(input_x, input_y)
initial_parameters = [0.0, 0.0, 0.0, 0.0]
result = sphere_fitting.fit_sphere_least_squares(x_values,
y_values,
z_values,
initial_parameters)
else:
result = addition.add_two_numbers(input_x, input_y)
if verbose:
if multiply:
print("Calculating {} * {}".format(input_x, input_y))
print("Result is {}".format(result))
else:
print("Calculating {} + {}".format(input_x, input_y))
if output != "":
print("Result is {}".format(result))
sphere = vtk.vtkSphereSource()
sphere.SetCenter(result[0][0], result[0][1], result[0][2])
sphere.SetRadius(result[0][3])
sphere.SetThetaResolution(60)
sphere.SetPhiResolution(60)
return result
writer = vtk.vtkXMLPolyDataWriter()
writer.SetFileName(output)
writer.SetInputData(sphere.GetOutput())
sphere.Update()
writer.Write()
......@@ -9,7 +9,7 @@
# Add files or directories to the blacklist. They should be base names, not
# paths.
ignore=CVS, ui
ignore=CVS
# Add files or directories matching the regex patterns to the blacklist. The
# regex matches against base names, not paths.
......@@ -32,7 +32,7 @@ unsafe-load-any-extension=no
# A comma-separated list of package or module names from where C extensions may
# be loaded. Extensions are loading into the active Python interpreter and may
# run arbitrary code
extension-pkg-whitelist=numpy
extension-pkg-whitelist=numpy, vtk
# Allow optimization of some AST trees. This will activate a peephole AST
# optimizer, which will apply various small optimizations. For instance, it can
......
# content of: tox.ini , put in same dir as setup.py
[tox]
envlist = py27,py36,lint
envlist = py36,lint
skipsdist = True
[travis]
python =
2.7: py27
3.6: py36, docs, lint
[testenv]
......@@ -31,13 +30,6 @@ commands = sphinx-build -M html . build
basepython=python3.6
commands=pyinstaller --onefile sksurgeryspherefitting.py --noconfirm --windowed
[testenv:pip2]
basepython=python2.7
changedir=pip_test
skip_install=True
commands = pip install {posargs}
sksurgeryspherefitting --help
[testenv:pip3]
basepython=python3.6
changedir=pip_test
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment