Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding check for splines #210

Closed
wants to merge 7 commits into from
Closed
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
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ tests_outputs/

# debug output folders
fuzzySurfaces
Suspicious_solids/
suspicious_solids/
Warning_Solids_definition.txt

.vscode
Expand Down
2 changes: 1 addition & 1 deletion src/geouned/GEOUNED/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ def load_step_file(
EnclosureChunk = []
for step_file in tqdm(step_files, desc="Loading CAD files"):
logger.info(f"read step file : {step_file}")
Meta, Enclosure = Load.load_cad(step_file, self.settings, self.options)
Meta, Enclosure = Load.load_cad(step_file, self.settings, self.options, skip_solids)
MetaChunk.append(Meta)
EnclosureChunk.append(Enclosure)
self.meta_list = join_meta_lists(MetaChunk)
Expand Down
33 changes: 32 additions & 1 deletion src/geouned/GEOUNED/loadfile/load_step.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,35 @@ def extract_materials(filename):
return m_dict


def load_cad(filename, settings, options):
def check_solids_for_splines(solids, filename, skip_solids) -> bool:
solid_ids_with_splines = []
for i, solid in enumerate(solids):
if i not in skip_solids:
for edge in solid.Edges:
try:
if edge.Curve.__class__.__name__ == "BSplineCurve":
solid_ids_with_splines.append(i)
# catching type errors as sometimes edges fail with "TypeError: undefined curve type"
except TypeError:
pass

if solid_ids_with_splines:
divider = "', '"
no_repetitions = list(set(solid_ids_with_splines))
logger.warning(
f"The solids {no_repetitions} contain splines in the CAD geometry {filename}\n"
"These splines might be used by the CAD geometry so this might not be an issue.\n"
"However if spines are used in the geometry then these are not directly convertible to Constructive Solid Geometry (CSG).\n"
f"You can use CadToCsg.load_cad(skip_solids=['{divider.join(str(s_id) for s_id in no_repetitions)}']) to exclude this solid from the conversion.\n"
"Or you could remove the volume from the CAD file manually.\n"
"Or you could replace the splines with polylines or arcs in the CAD file.\n"
)
return True
else:
return False


def load_cad(filename, settings, options, skip_solids):

# Set document solid tree options when opening CAD differing from version 0.18
if int(FreeCAD.Version()[1]) > 18:
Expand All @@ -53,6 +81,9 @@ def load_cad(filename, settings, options):
s.read(filename)
Solids = s.Solids
meta_list = []

check_solids_for_splines(Solids, filename, skip_solids)

for i, s in enumerate(Solids):
meta_list.append(UF.GeounedSolid(i + 1, s))

Expand Down
Loading