Skip to content

Commit

Permalink
Merge branch 'dev' into topology_healing
Browse files Browse the repository at this point in the history
  • Loading branch information
GabrielJMS authored Sep 28, 2023
2 parents f9da7e6 + 10547fd commit a3f5061
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 37 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- BSplineSurface3D: from_points_interpolation, from_points_approximation.
- ConicalFace3D: point_belongs
- nurbs.core: find_multiplicity, evaluate_curve.
- Step.read_lines: handles name with # character in name.
- BSplineCurve: direction_vector, point_at_abscissa, abscissa, trim.
- ConicalSurface3D and RevolutionSurface3D: bsplinecurve3d_to_2d when start or and points are at surface singularity


### Refactor
- TriangleShell3D: various improvement such as get_bounding_box, to_mesh_data, from_mesh_data, to_dict, dict_to_object
Expand Down
2 changes: 1 addition & 1 deletion code_pylint.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
'inconsistent-return-statements': 4,
'unused-variable': 22,
'arguments-differ': 64,
'too-many-locals': 86,
'too-many-locals': 87,
'unused-argument': 8,
'too-many-arguments': 26,
'line-too-long': 12,
Expand Down
1 change: 0 additions & 1 deletion volmdlr/models/contours.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@
volmdlr.Point3D(-3, 4, 1)]
knots = [0.0, 1.0]
knot_multiplicities = [6, 6]
# weights = None # [1, 2, 1, 2, 1, 2]
bspline_curve3d = edges.BSplineCurve3D(degree=5, control_points=control_points,
knot_multiplicities=knot_multiplicities,
knots=knots,
Expand Down
90 changes: 55 additions & 35 deletions volmdlr/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class Step(dc.DessiaObject):
_standalone_in_db = True

def __init__(self, lines: List[str], name: str = ''):
self.functions, self.all_connections, self.connections = self.read_lines(lines)
self.functions, self.connections = self.read_lines(lines)
self._graph = None
self.global_uncertainty = 1e-6
self.length_conversion_factor = 1
Expand All @@ -82,6 +82,15 @@ def __init__(self, lines: List[str], name: str = ''):

dc.DessiaObject.__init__(self, name=name)

@property
def all_connections(self):
"""Returns all pairs of connections."""
list_connections = []
for key, values in self.connections.items():
for value in values:
list_connections.append((key, value))
return list_connections

@property
def root_nodes(self):
"""Returns a dictionary containing the nodes of the step file function that are used as start points."""
Expand Down Expand Up @@ -117,11 +126,9 @@ def from_file(cls, filepath: str = None, name: str = ''):

def read_lines(self, lines):
"""Translate the step file into step functions objects."""
all_connections = []
dict_connections = {}
previous_line = ""
functions = {}

for line in lines:
# line = line.replace(" ", "")
line = line.replace("\n", "")
Expand All @@ -146,49 +153,62 @@ def read_lines(self, lines):
function_id = int(function[0][1:].strip())
function_name_arg = function[1].split("(", 1)
function_name = function_name_arg[0].replace(" ", "")
function_arg = function_name_arg[1].split("#")
function_connections = []
start_index_name = function_name_arg[1].find("'")
if start_index_name != -1:
end_index_name = function_name_arg[1].find("'", start_index_name + 1)
if end_index_name != -1:
function_arg_string = function_name_arg[1][end_index_name + 1:]
else:
function_arg_string = function_name_arg[1]
else:
function_arg_string = function_name_arg[1]
function_arg = function_arg_string.split("#")
connections = []
for connec in function_arg[1:]:
connec = connec.split(",")
connec = connec[0].split(")")
if connec[0][-1] != "'":
function_connection = int(connec[0])
connections.append(function_connection)
function_connections.append(
(function_id, function_connection))
dict_connections[function_id] = connections
all_connections.extend(function_connections)

previous_line = str()

# FUNCTION ARGUMENTS
function_arg = function_name_arg[1]
arguments = step_reader.step_split_arguments(function_arg)
new_name = ''
new_arguments = []
if function_name == "":
name_arg = self.step_subfunctions(arguments)
for name, arg in name_arg:
new_name += name + ', '
new_arguments.extend(arg)
new_name = new_name[:-2]
function_name = new_name
arguments = new_arguments
for arg in arguments:
if arg[0] == '#':
function_connections.append(
(function_id, int(arg[1:])))

for i, argument in enumerate(arguments):
if argument[:2] == '(#' and argument[-1] == ')':
arg_list = step_reader.set_to_list(argument)
arguments[i] = arg_list

function = StepFunction(function_id, function_name, arguments)
functions[function_id] = function

return functions, all_connections, dict_connections
functions, connections = self._helper_intantiate_step_functions(functions, connections,
[function_id, function_name,
function_name_arg])

dict_connections[function_id] = connections

return functions, dict_connections

def _helper_intantiate_step_functions(self, functions, connections, function_parameters):
"""Helper function to read_lines."""
function_id, function_name, function_name_arg = function_parameters
function_arg = function_name_arg[1]
arguments = step_reader.step_split_arguments(function_arg)
new_name = ''
new_arguments = []
if function_name == "":
name_arg = self.step_subfunctions(arguments)
for name, arg in name_arg:
new_name += name + ', '
new_arguments.extend(arg)
new_name = new_name[:-2]
function_name = new_name
arguments = new_arguments
for arg in arguments:
if arg[0] == '#':
connections.append(int(arg[1:]))

for i, argument in enumerate(arguments):
if argument[:2] == '(#' and argument[-1] == ')':
arg_list = step_reader.set_to_list(argument)
arguments[i] = arg_list

function = StepFunction(function_id, function_name, arguments)
functions[function_id] = function
return functions, connections

def not_implemented(self):
not_implemented = []
Expand Down

0 comments on commit a3f5061

Please sign in to comment.