Skip to content

Commit

Permalink
Removed Dimension class and also subclasses
Browse files Browse the repository at this point in the history
  • Loading branch information
mlauer154 committed Feb 14, 2024
1 parent 2473e28 commit ec9db6f
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 521 deletions.
179 changes: 0 additions & 179 deletions pymead/core/dimensions.py

This file was deleted.

72 changes: 2 additions & 70 deletions pymead/core/geometry_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
from pymead.core.bezier import Bezier
from pymead.core.constraints import *
from pymead.core.gcs import GCS
from pymead.core.dimensions import LengthDimension, AngleDimension, Dimension
from pymead.core.mea import MEA
from pymead.core.pymead_obj import DualRep, PymeadObj
from pymead.core.line import LineSegment
Expand Down Expand Up @@ -431,23 +430,6 @@ def remove_pymead_obj(self, pymead_obj: PymeadObj, promotion_demotion: bool = Fa

self.gcs._remove_point(pymead_obj)

elif isinstance(pymead_obj, Dimension):
# Remove the dimension references from the points
if isinstance(pymead_obj.target(), Point):
pymead_obj.target().dims.remove(pymead_obj)
elif isinstance(pymead_obj.target(), PointSequence):
for pt in pymead_obj.target().points():
pt.dims.remove(pymead_obj)

if isinstance(pymead_obj.tool(), Point):
pymead_obj.tool().dims.remove(pymead_obj)
elif isinstance(pymead_obj.tool(), PointSequence):
for pt in pymead_obj.tool().points():
pt.dims.remove(pymead_obj)

# Remove the parameter associated with the dimension
self.remove_pymead_obj(pymead_obj.param())

elif isinstance(pymead_obj, GeoCon):
# First, remove the parameter associated with the constraint if necessary (i.e., if that parameter is not
# tied to any other constraints
Expand Down Expand Up @@ -813,31 +795,12 @@ def add_mea(self, airfoils: typing.List[Airfoil], name: str or None = None, assi

return self.add_pymead_obj_by_ref(mea, assign_unique_name=assign_unique_name)

def add_length_dimension(self, tool_point: Point, target_point: Point, length_param: LengthParam or None = None,
name: str or None = None, assign_unique_name: bool = True):
length_dim = LengthDimension(tool_point=tool_point, target_point=target_point, length_param=length_param,
name=name)

if length_dim.param().geo_col is None:
self.add_pymead_obj_by_ref(pymead_obj=length_dim.param(), assign_unique_name=assign_unique_name)

return self.add_pymead_obj_by_ref(length_dim, assign_unique_name=assign_unique_name)

def add_angle_dimension(self, tool_point: Point, target_point: Point, angle_param: AngleDimension or None = None,
name: str or None = None, assign_unique_name: bool = True):
angle_dim = AngleDimension(tool_point=tool_point, target_point=target_point, angle_param=angle_param,
name=name)

if angle_dim.param().geo_col is None:
self.add_pymead_obj_by_ref(pymead_obj=angle_dim.param(), assign_unique_name=assign_unique_name)

return self.add_pymead_obj_by_ref(angle_dim, assign_unique_name=assign_unique_name)

def add_constraint(self, constraint: GeoCon, assign_unique_name: bool = True, **constraint_kwargs):
self.add_pymead_obj_by_ref(constraint, assign_unique_name=assign_unique_name)
try:
self.gcs.add_constraint(constraint)
if isinstance(constraint, AntiParallel3Constraint) or isinstance(constraint, Perp3Constraint):
if (isinstance(constraint, AntiParallel3Constraint) or isinstance(constraint, Perp3Constraint) or
isinstance(constraint, RelAngle3Constraint) or isinstance(constraint, DistanceConstraint)):
points_solved = self.gcs.solve(constraint)
self.gcs.update_canvas_items(points_solved)
except ValueError as e:
Expand Down Expand Up @@ -911,37 +874,6 @@ def set_from_dict_rep(cls, d: dict, canvas=None, tree=None, gui_obj=None):
geo_col.add_constraint(constraint=constraint, assign_unique_name=False, compile=False,
solve_and_update=False)
constraints_added.append(constraint)

# geo_col.gcs.compile_and_solve_first_constraint_of_all_clusters(constraint_list=constraints_added)

for name, dim_dict in d["dims"].items():
if "length_param" in dim_dict.keys():
if dim_dict["length_param"] in geo_col.container()["desvar"].keys():
param = geo_col.container()["desvar"][dim_dict["length_param"]]
elif dim_dict["length_param"] in geo_col.container()["params"].keys():
param = geo_col.container()["params"][dim_dict["length_param"]]
else:
raise ValueError(f"Could not find length_param named {dim_dict['length_param']} in either the "
f"desvar or params sub-containers")
geo_col.add_length_dimension(tool_point=geo_col.container()["points"][dim_dict["tool_point"]],
target_point=geo_col.container()["points"][dim_dict["target_point"]],
length_param=param,
name=name)
elif "angle_param" in dim_dict.keys():
if dim_dict["angle_param"] in geo_col.container()["desvar"].keys():
param = geo_col.container()["desvar"][dim_dict["angle_param"]]
elif dim_dict["angle_param"] in geo_col.container()["params"].keys():
param = geo_col.container()["params"][dim_dict["angle_param"]]
else:
raise ValueError(f"Could not find angle_param named {dim_dict['angle_param']} in either the "
f"desvar or params sub-containers")
geo_col.add_angle_dimension(tool_point=geo_col.container()["points"][dim_dict["tool_point"]],
target_point=geo_col.container()["points"][dim_dict["target_point"]],
angle_param=param,
name=name)
else:
raise ValueError("Current valid load/save dimensions are LengthDimension and AngleDimension. Could "
"not find either length_param or angle_param in saved dictionary.")
for name, airfoil_dict in d["airfoils"].items():
geo_col.add_airfoil(leading_edge=geo_col.container()["points"][airfoil_dict["leading_edge"]],
trailing_edge=geo_col.container()["points"][airfoil_dict["trailing_edge"]],
Expand Down
40 changes: 0 additions & 40 deletions pymead/gui/airfoil_canvas.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,20 +331,6 @@ def generateMEA(self):

self.geo_col.add_mea(airfoils=self.geo_col.selected_objects["airfoils"].copy())

@runSelectionEventLoop(drawing_object="LengthDimension", starting_message="Select the tool point")
def addLengthDimension(self):
if len(self.geo_col.selected_objects["points"]) not in [2, 3]:
self.sigStatusBarUpdate.emit("Choose either 2 points (no length parameter) or 3 points "
"(specified length parameter)"
" to add a length dimension", 4000)
return

tool_point = self.geo_col.selected_objects["points"][0]
target_point = self.geo_col.selected_objects["points"][1]
length_param = None if len(self.geo_col.selected_objects["points"]) <= 2 else self.geo_col.selected_objects["points"][2]

self.geo_col.add_length_dimension(tool_point=tool_point, target_point=target_point, length_param=length_param)

@runSelectionEventLoop(drawing_object="DistanceConstraint", starting_message="Select the first point")
def addDistanceConstraint(self):
if len(self.geo_col.selected_objects["points"]) != 2:
Expand Down Expand Up @@ -520,26 +506,6 @@ def pointClicked(self, scatter_item, spot, ev, point_item):
self.sigStatusBarUpdate.emit("Now, select the lower surface endpoint.", 0)
elif len(self.geo_col.selected_objects["points"]) == 4:
self.sigEnterPressed.emit()
elif self.drawing_object == "LengthDimension":
self.geo_col.select_object(point_item.point)
if len(self.geo_col.selected_objects["points"]) == 1:
self.sigStatusBarUpdate.emit("Now, choose the target point.", 0)
elif len(self.geo_col.selected_objects["points"]) == 2:
# TODO: implement the ability to select a parameter from the tree here
self.sigEnterPressed.emit()
elif len(self.geo_col.selected_objects["points"]) == 3:
# TODO: this currently will not be called until the above TODO is implemented
self.sigEnterPressed.emit()
elif self.drawing_object == "AngleDimension":
self.geo_col.select_object(point_item.point)
if len(self.geo_col.selected_objects["points"]) == 1:
self.sigStatusBarUpdate.emit("Now, choose the target point.", 0)
elif len(self.geo_col.selected_objects["points"]) == 2:
# TODO: implement the ability to select a parameter from the tree here
self.sigEnterPressed.emit()
elif len(self.geo_col.selected_objects["points"]) == 3:
# TODO: this currently will not be called until the above TODO is implemented
self.sigEnterPressed.emit()
elif self.drawing_object == "DistanceConstraint":
self.geo_col.select_object(point_item.point)
if len(self.geo_col.selected_objects["points"]) == 1:
Expand Down Expand Up @@ -778,8 +744,6 @@ def contextMenuEvent(self, event):
addAntiParallel3ConstraintAction = add_constraint_menu.addAction("Add Anti-Parallel 3 Constraint")
addSymmetryConstraintAction = add_constraint_menu.addAction("Add Symmetry Constraint")
addROCurvatureConstraintAction = add_constraint_menu.addAction("Add Radius of Curvature Constraint")
addLengthDimensionAction = add_constraint_menu.addAction("Add Length Dimension")
addAngleDimensionAction = add_constraint_menu.addAction("Add Angle Dimension")
addDistanceConstraintAction = add_constraint_menu.addAction("Add Distance Constraint")
exportPlotAction = menu.addAction("Export Plot")
view_pos = self.getPlotItem().getViewBox().mapSceneToView(event.pos())
Expand All @@ -804,10 +768,6 @@ def contextMenuEvent(self, event):
self.addSymmetryConstraint()
elif res == addROCurvatureConstraintAction:
self.addROCurvatureConstraint()
elif res == addLengthDimensionAction:
self.addLengthDimension()
elif res == addAngleDimensionAction:
self.addAngleDimension()
elif res == addDistanceConstraintAction:
self.addDistanceConstraint()
elif res == removeCurveAction and curve_item is not None:
Expand Down
Loading

0 comments on commit ec9db6f

Please sign in to comment.