Skip to content

Commit b2ba705

Browse files
author
Erik B Knudsen
committed
improve hash-code collision protection
and cleanup
1 parent 2a54b3c commit b2ba705

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/CAD_to_OpenMC/assembly.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,10 @@ def run(
239239
):
240240
"""convenience function that assumes the stp_files field is set, etc and simply runs the mesher with the set options"""
241241
self.import_stp_files(**kwargs)
242+
if imprint:
243+
self.imprint_all()
242244
if merge:
243245
self.merge_all()
244-
elif imprint:
245-
self.imprint_all()
246246
self.solids_to_h5m(backend=backend, h5m_filename=h5m_filename, **kwargs)
247247

248248
def import_stp_files(
@@ -969,7 +969,7 @@ def _merge_solids_full(self, solids, fuzzy_value=1e-6):
969969
"""
970970
adds all solids on the solids-vector to the algorithm and
971971
merges them as arguments. This is stabler, but more resource
972-
intesive
972+
intensive
973973
"""
974974
bldr = OCP.BOPAlgo.BOPAlgo_MakeConnected()
975975
for shape in solids:

src/CAD_to_OpenMC/assemblymesher_cq2.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,9 @@ def generate_stls(self):
8080

8181
@classmethod
8282
def surface_hash(self,surface):
83-
part1=hash(surface)
84-
part2=abs(hash(surface.Center().toTuple()))
85-
return int(str(part1)+str(part2))
83+
part1=surface
84+
part2=surface.Center().toTuple()
85+
return hash( (part1,part2) )
8686

8787
def _mesh_surfaces(self):
8888
# loop over all surfaces in all entities
@@ -127,7 +127,7 @@ def _mesh_surfaces(self):
127127
return stls
128128

129129
def _triangulate_solid(self, solid, tol: float = 1e-3, atol: float = 1e-1):
130-
""" create a mesh /by means of the underlying OCCT IncrementalMesh
130+
""" create a mesh by means of the underlying OCCT IncrementalMesh
131131
on a single solid. This will later be split into surfaces.
132132
This has to be done since otherwise a single solid can get leaky
133133
when surfaces do not connect

0 commit comments

Comments
 (0)