Skip to content
Snippets Groups Projects

Face2face

Merged mehtank requested to merge mehtank/rocolib:face2face into v0.3
Compare and
10 files
+ 86
80
Compare changes
  • Side-by-side
  • Inline
Files
10
@@ -221,10 +221,7 @@ class Face(object):
self.decorations.append(pts)
def addFace(self, face, transform, copyDecorations=False):
self.joinedFaces.append((face, transform))
if copyDecorations:
for d in self.decorations:
face.addDecoration(d)
self.joinedFaces.append(dict(face=face, transform=transform, copyDecorations=copyDecorations))
def preTransform(self, edge):
index = self.edges.index(edge)
@@ -332,16 +329,38 @@ class Face(object):
e.remove(self)
# now place attached faces
for (f, t) in self.joinedFaces:
for jf in self.joinedFaces:
if jf["transform"] is False:
continue
if self.inverted:
t3d = np.dot(MirrorZ(), t)
t3d = np.dot(MirrorZ(), jf["transform"])
else:
t3d = t
t3d = jf["transform"]
t3d = np.dot(self.transform3D, t3d)
f.place(None, None, t3d, facelists)
jf["face"].place(None, None, t3d, facelists)
self.placeagain()
def copyDecorations(self):
for jf in self.joinedFaces:
if jf["copyDecorations"]:
thisdeco = self.transformDecorations(np.inv(jf["face"].transform3D))
thatdeco = jf["face"].transformDecorations(np.inv(self.transform3D))
self.decorations += thatdeco
jf["face"].decorations += thisdeco
jf["copyDecorations"] = False
def transformDecorations(self, t2=None):
if self.transform3D is None:
return
t = self.transform3D
if t2 is not None:
t = np.dot(t2, t)
decorations = []
for e in self.decorations:
decorations.append(([ np.dot(t, np.array(list(pt) + [0,1]))[0:2] for pt in e[0] ], e[1]))
return decorations
def polygon(self):
from collections import namedtuple
from shapely.geometry import Polygon