Skip to content

Commit

Permalink
boolregion modif
Browse files Browse the repository at this point in the history
  • Loading branch information
psauvan committed Jan 8, 2025
1 parent c170590 commit e12d468
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 6 deletions.
11 changes: 10 additions & 1 deletion src/geouned/GEOUNED/conversion/cell_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
gen_plane_sphere,
gen_plane_cylinder,
gen_plane_cone,
omit_multiplane_repeated_planes,
)

logger = logging.getLogger("general_logger")
Expand Down Expand Up @@ -48,13 +49,15 @@ def simple_solid_definition(solid, Surfaces, meta_surfaces=True):
for mp in multiplanes:
mp_region = Surfaces.add_multiPlane(mp)
component_definition.append(mp_region)
planeset = omit_multiplane_repeated_planes(mp_region, Surfaces, solid_gu.Faces)
omitFaces.update(planeset)

revereCan = get_reverseCan(solid_gu, omitFaces)
for cs in revereCan:
cs_region = Surfaces.add_reverseCan(cs)
component_definition.append(cs_region)
else:
omitFaces =set()
omitFaces = set()

for iface, face in enumerate(solid_gu.Faces):
if iface in omitFaces:
Expand Down Expand Up @@ -143,4 +146,10 @@ def simple_solid_definition(solid, Surfaces, meta_surfaces=True):
component_definition.append(torus_region)
else:
logger.info("Only Torus with axis along X, Y, Z axis can be reproduced")

#solid.exportStep('solid.stp')
#for k in Surfaces.keys():
# for i,m in enumerate(Surfaces[k]):
# m.build_surface(solid.BoundBox)
# m.shape.exportStep(f'{k}_{i}.stp')
return component_definition
15 changes: 14 additions & 1 deletion src/geouned/GEOUNED/conversion/cell_definition_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
is_parallel,
is_same_value,
)
from ..utils.basic_functions_part2 import is_same_plane
from ..utils.boolean_function import BoolRegion
from ..utils.geouned_classes import GeounedSurface
from ..utils.geometry_gu import FaceGu, CylinderGu
from ..utils.geometry_gu import PlaneGu

logger = logging.getLogger("general_logger")

Expand Down Expand Up @@ -446,3 +447,15 @@ def get_intervals(u_nodes):
closed_range.append(index)

return closed_ranges

def omit_multiplane_repeated_planes(mp_region,Surfaces,Faces):
repeated_planes = set()
planes = mp_region.definition.get_surfaces_numbers()
for p in planes :
pg = Surfaces.primitive_surfaces.get_surface(p)
for face in Faces:
if not isinstance(face,PlaneGu):
continue
if is_same_plane(face.Surface, pg.Surf, Surfaces.options, Surfaces.tolerances, Surfaces.numeric_format):
repeated_planes.add(face.Index)
return repeated_planes
6 changes: 4 additions & 2 deletions src/geouned/GEOUNED/decompose/decom_utils_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -460,8 +460,9 @@ def external_plane(plane, Faces):
Edges = plane.Edges
for e in Edges:
adjacent_face = other_face_edge(e, plane, Faces)
if region_sign(plane, adjacent_face) == "OR":
return False
if isinstance(adjacent_face,PlaneGu): # if not plane not sure current plane will not cut other part of the solid
if region_sign(plane, adjacent_face) == "OR":
return False
return True


Expand All @@ -477,6 +478,7 @@ def exclude_no_cutting_planes(Faces, omit=None):
if isinstance(f.Surface, PlaneGu):
if external_plane(f, Faces):
omit.add(f.Index)

return omit if return_set else None

def cutting_face_number(f, Faces, omitfaces):
Expand Down
5 changes: 3 additions & 2 deletions src/geouned/GEOUNED/utils/meta_surfaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,12 +273,13 @@ def get_adjacent_cylplane(cyl, Faces, cornerPlanes = True):
if isinstance(otherface.Surface, PlaneGu):
planes.append(otherface)

delindex = []
delindex = set()
for i, p1 in enumerate(planes):
for j, p2 in enumerate(planes[i + 1 :]):
if p1.isSame(p2):
delindex.append(j + i + 1)
delindex.add(j + i + 1)

delindex = list(delindex)
delindex.sort()
delindex.reverse()
for i in delindex:
Expand Down

0 comments on commit e12d468

Please sign in to comment.