Skip to content

Implemented preliminary CLI command in the generator #1

Merged
merged 3 commits into from
Oct 16, 2017
Merged
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,6 @@ target/

#IntelliJ Files
*.idea

#Subdivision Log Generator log file
logs/*
Empty file added __init__.py
Empty file.
60 changes: 60 additions & 0 deletions cli_application.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
#!/usr/bin/env python
"""
@author Peter Zaffetti 2017
"""
import argparse
import cmd
import os
import sys

from user_interface.curve_parser import parse_curve_file
from logger import get_logger


class CliApplication(cmd.Cmd):

def __init__(self, application_path=None, application_name="generator", args=None):
self.logger = get_logger(__name__)
self.curve_paths = os.path.join(application_path, "curves")
self.arguments = args
self.parse_cmd_args(self.arguments)
sys.exit(1)

def parse_cmd_args(self, args):
if args is not None:
if args.generate_m_value:
if os.path.exists(args.generate_m_value):
self.generate_m_value(args.generate_m_value)
else:
curve_path = os.path.join(self.curve_paths, args.generate_m_value)
if os.path.exists(curve_path):
self.generate_m_value(curve_path)
else:
self.logger.info("The curve file doesn't exist. Please choose an appropriate file.")
else:
raise Exception("There were no arguments when running the application")

def generate_m_value(self, curve_file="test.curve"):
knot_curve = parse_curve_file(curve_file)

pass


def main():
"""The main function that runs the Subdivision Generator application"""

application_path = os.path.dirname(os.path.abspath(__file__))
application_name = os.path.splitext(os.path.basename(__file__))[0]

argument_parser = argparse.ArgumentParser(
description='Generates the required number of subdivisions for a Bezier curve to match the stick knot it was created from')
argument_parser.add_argument("-g", "--generate_m_value", help="generates the minimum number of iterations needed for the supplied \
stick knot's Bezier cure to match the stick knot", default=None, action="store")
arguments = argument_parser.parse_args()

get_logger().debug("Subdivision-Generator Starting Up")
application = CliApplication(application_path, application_name, arguments)


if __name__ == "__main__":
main()
Empty file added curve_data_objects/__init__.py
Empty file.
10 changes: 10 additions & 0 deletions curve_data_objects/straight_curve.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/usr/bin/env python
"""
@author Peter Zaffetti 2017
"""

class StraightCurve:

def __init__(self, curve_points):
pass

33 changes: 33 additions & 0 deletions curves/TJP-4_1_stick-unknot-halved-1.curve
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
1.307600000000000, -3.332000000000000, -2.507200000000000

-0.0765185, 0.67527525, -0.7968295

-1.384118500000000, 4.682550500000000, 0.913541000000000
-1.44393425, 4.40945025, 0.9689405


-1.50375, 4.13635, 1.02434
-2.40102875, 0.03983375, 1.8552645


-3.2983075,-4.0566825,2.686189
-1.7108035, -0.64421425, 0.1113025


-0.1232995,2.768254,-2.463584
1.892346, -0.8825515, -0.61860675


3.9079915,-4.533357,1.2263705
-0.01399575, -2.4858145, 0.12150275


-3.935983,-0.438272,-0.983365
-0.3589045, 1.9289255, 0.56454725


3.218174000000000, 4.296123000000000, 2.112459500000000
2.262887, 0.4820615, -0.19737025


1.307600000000000, -3.332000000000000, -2.507200000000000
65 changes: 65 additions & 0 deletions curves/TJP-4_1_stick-unknot-halved-2.curve
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
1.307600000000000, -3.332000000000000, -2.507200000000000

0.634670375,-1.328362375,-1.65201475

-0.03825925,0.67527525,-0.7968295
-0.711188875,2.678912875,0.05835575


-1.384118500000000, 4.682550500000000, 0.913541000000000
-1.414026375,4.546000375,0.94124075


-1.44393425,4.40945025,0.9689405
-1.473842125,4.272900125,0.99664025


-1.50375,4.13635,1.02434
-1.952389375,2.088091875,1.43980225


-2.40102875,0.03983375,1.8552645
-2.849668125,-2.008424375,2.27072675


-3.2983075,-4.0566825,2.686189
-2.5045555,-2.350448375,1.39874575


-1.7108035,-0.64421425,0.1113025
-0.9170515,1.062019875,-1.17614075


-0.1232995,2.768254,-2.463584
0.88452325,0.94285125,-1.541095375


1.892346,-0.8825515,-0.61860675
2.90016875,-2.70795425,0.303881875


3.9079915,-4.533357,1.2263705
1.946997875,-3.50958575,0.673936625


-0.01399575,-2.4858145,0.12150275
-1.974989375,-1.46204325,-0.430931125


-3.935983,-0.438272,-0.983365
-2.14744375,0.74532675,-0.209408875


-0.3589045,1.9289255,0.56454725
1.42963475,3.11252425,1.338503375


3.218174000000000, 4.296123000000000, 2.112459500000000
2.7405305,2.38909225,0.957544625


2.262887,0.4820615,-0.19737025
1.7852435,-1.42496925,-1.352285125


1.307600000000000, -3.332000000000000, -2.507200000000000
130 changes: 130 additions & 0 deletions curves/TJP-4_1_stick-unknot-halved-3.curve
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
1.307600000000000, -3.332000000000000, -2.507200000000000

0.9711351875,-2.3301811875,-2.079607375

0.634670375,-1.328362375,-1.65201475
0.2982055625,-0.3265435625,-1.224422125


-0.03825925,0.67527525,-0.7968295
-0.3747240625,1.6770940625,-0.369236875


-0.711188875,2.678912875,0.05835575
-1.0476536875,3.6807316875,0.485948375


-1.384118500000000, 4.682550500000000, 0.913541000000000
-1.3990724375,4.6142754375,0.927390875


-1.414026375,4.546000375,0.94124075
-1.4289803125,4.4777253125,0.955090625


-1.44393425,4.40945025,0.9689405
-1.4588881875,4.3411751875,0.982790375


-1.473842125,4.272900125,0.99664025
-1.4887960625,4.2046250625,1.010490125


-1.50375,4.13635,1.02434
-1.7280696875,3.1122209375,1.232071125


-1.952389375,2.088091875,1.43980225
-2.1767090625,1.0639628125,1.647533375


-2.40102875,0.03983375,1.8552645
-2.6253484375,-0.9842953125,2.062995625


-2.849668125,-2.008424375,2.27072675
-3.0739878125,-3.0325534375,2.478457875


-3.2983075,-4.0566825,2.686189
-2.9014315,-3.2035654375,2.042467375


-2.5045555,-2.350448375,1.39874575
-2.1076795,-1.4973313125,0.755024125


-1.7108035,-0.64421425,0.1113025
-1.3139275,0.2089028125,-0.532419125


-0.9170515,1.062019875,-1.17614075
-0.5201755,1.9151369375,-1.819862375


-0.1232995,2.768254,-2.463584
0.380611875,1.855552625,-2.0023396875


0.88452325,0.94285125,-1.541095375
1.388434625,0.030149875,-1.0798510625


1.892346,-0.8825515,-0.61860675
2.396257375,-1.795252875,-0.1573624375


2.90016875,-2.70795425,0.303881875
3.404080125,-3.620655625,0.7651261875


3.9079915,-4.533357,1.2263705
2.9274946875,-4.021471375,0.9501535625


1.946997875,-3.50958575,0.673936625
0.9665010625,-2.997700125,0.3977196875


-0.01399575,-2.4858145,0.12150275
-0.9944925625,-1.973928875,-0.1547141875


-1.974989375,-1.46204325,-0.430931125
-2.9554861875,-0.950157625,-0.7071480625


-3.935983,-0.438272,-0.983365
-3.041713375,0.153527375,-0.5963869375


-2.14744375,0.74532675,-0.209408875
-1.253174125,1.337126125,0.1775691875


-0.3589045,1.9289255,0.56454725
0.535365125,2.520724875,0.9515253125


1.42963475,3.11252425,1.338503375
2.323904375,3.704323625,1.7254814375


3.218174000000000, 4.296123000000000, 2.112459500000000
2.97935225,3.342607625,1.5350020625


2.7405305,2.38909225,0.957544625
2.50170875,1.435576875,0.3800871875


2.262887,0.4820615,-0.19737025
2.02406525,-0.471453875,-0.7748276875


1.7852435,-1.42496925,-1.352285125
1.54642175,-2.378484625,-1.9297425625


1.307600000000000, -3.332000000000000, -2.507200000000000

16 changes: 16 additions & 0 deletions curves/TJP-4_1_stick-unknot.curve
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%ignore me
1.307600000000000, -3.332000000000000, -2.507200000000000
-1.384118500000000, 4.682550500000000, 0.913541000000000



-3.2983075,-4.0566825,2.686189

-0.1232995,2.768254,-2.463584

3.9079915,-4.533357,1.2263705

-3.935983,-0.438272,-0.983365

3.218174000000000, 4.296123000000000, 2.112459500000000

28 changes: 28 additions & 0 deletions curves/TJP-4_1_stick-unknot_TEST.curve
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
1.3076, -3.332, -2.5072

-0.038259268, 0.6752752, -0.79682946

-1.3841186, 4.6825504, 0.913541

-2.341213, 0.31293392, 1.799865

-3.2983074, -4.0566826, 2.686189

-1.7108035, -0.6442143, 0.111302495

-0.1232995, 2.768254, -2.463584

1.8923459, -0.88255155, -0.61860675

3.9079914, -4.533357, 1.2263705

-0.013995767, -2.4858146, 0.12150273

-3.935983, -0.438272, -0.983365

-0.35890448, 1.9289255, 0.5645472

3.218174, 4.296123, 2.1124594

2.262887, 0.4820615, -0.19737029

Loading