Skip to content

Commit

Permalink
Just one check for outward faces seems best
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswmackey committed Jun 4, 2019
1 parent 311f2c2 commit 36df671
Showing 1 changed file with 9 additions and 19 deletions.
28 changes: 9 additions & 19 deletions ladybug_geometry/geometry3d/polyface.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,7 @@ def from_faces(cls, faces):
face_indices.append(ind)

# get the polyface object and assign correct faces to it
_polyface = cls(vertices, face_indices)
if _polyface._is_solid:
_polyface._faces = cls.get_outward_faces(_faces)
else:
_polyface._faces = faces
return _polyface
return cls(vertices, face_indices)

@classmethod
def from_faces_tolerance(cls, faces, tolerance):
Expand Down Expand Up @@ -209,12 +204,7 @@ def from_faces_tolerance(cls, faces, tolerance):
face_indices.append(tuple(ind))

# get the polyface object and assign correct faces to it
_polyface = cls(vertices, face_indices)
if _polyface._is_solid:
_polyface._faces = cls.get_outward_faces(faces, tolerance)
else:
_polyface._faces = faces
return _polyface
return cls(vertices, face_indices)

@classmethod
def from_box(cls, length, width, height, base_plane=None):
Expand Down Expand Up @@ -300,7 +290,8 @@ def from_offset_face(cls, face, offset):
if not face.has_holes:
len_faces = len(cclock_verts)
face_ind_bottom = [tuple(reversed(xrange(len_faces)))]
face_ind_top = [tuple(reversed(xrange(len_faces * 2 - 1, len_faces - 1, -1)))]
face_ind_top = [tuple(
reversed(xrange(len_faces * 2 - 1, len_faces - 1, -1)))]
else:
if face.is_clockwise:
face_verts_bottom = [face.boundary] + list(face.holes)
Expand Down Expand Up @@ -356,8 +347,9 @@ def faces(self):
holes = tuple(tuple(self.vertices[i] for i in f) for f in face[1:])
faces.append(Face3D(boundary=boundary, holes=holes))
if self._is_solid:
faces = Polyface3D.get_outward_faces(faces)
self._faces = faces
self._faces = Polyface3D.get_outward_faces(faces)
else:
self._faces = tuple(faces)
return self._faces

@property
Expand Down Expand Up @@ -563,8 +555,6 @@ def merge_overlapping_edges(self, tolerance, angle_tolerance):
_new_polyface = Polyface3D(self._vertices, self._face_indices,
{'edge_indices': new_edge_indices,
'edge_types': new_edge_types})
_new_polyface._tolerance = tolerance
_new_polyface._angle_tolerance = angle_tolerance
return _new_polyface

def move(self, moving_vec):
Expand Down Expand Up @@ -754,7 +744,7 @@ def get_outward_faces(faces, tolerance=0):
v2 = face.boundary[1] - face.boundary[0]
move_vec = Vector3D(
(v1.x + v2.x / 2), (v1.y + v2.y / 2), (v1.z + v2.z / 2)).normalize()
move_vec = move_vec * (tolerance + 0.00000001)
move_vec = move_vec * (tolerance + 0.00001)
point_on_face = face.boundary[0] + move_vec
test_ray = Ray3D(point_on_face, face.normal)

Expand All @@ -770,7 +760,7 @@ def get_outward_faces(faces, tolerance=0):
outward_faces.append(face)
else:
outward_faces.append(face.flip())
return tuple(outward_faces)
return outward_faces

def to_dict(self):
"""Get Polyface3D as a dictionary."""
Expand Down

0 comments on commit 36df671

Please sign in to comment.