Skip to content
Snippets Groups Projects
Commit 89260424 authored by pjil27's avatar pjil27
Browse files

including DecorationPort.py

parent b15bf7e9
Branches
No related merge requests found
Pipeline #72 failed with stage
in 2 minutes and 13 seconds
from rocolib.api.ports import Port, FacePort
from rocolib.utils.utils import decorateGraph
import numpy as np
class DecorationPort(Port):
def __init__(self, parent, decoration):
Port.__init__(self, parent, {})
self.decoration = decoration
def getDecoration(self):
return self.decoration
def toString(self):
return str(self.decoration)
def canMate(self, otherPort):
return (otherPort.getFaceName() is not None)
def attachFrom(self, fromPort, graph, **kwargs):
# If from face to decoration, we can decorate the face
if isinstance(fromPort, FacePort):
face = graph.getFace(fromPort.getFaceName())
deco = self.getDecoration()
if face is not None:
decorateGraph(face, decoration=deco, **kwargs)
class AnchorPort(FacePort):
def __init__(self, parent, graph, face, transform):
FacePort.__init__(self, parent, graph, face)
self.transform = transform
def getTransform(self):
return self.transform
def canMate(self, otherPort):
return False
def attachFrom(self, fromPort, graph, **kwargs):
if isinstance(fromPort, DecorationPort):
deco = fromPort.getDecoration().faces[0]
face = self.getFaceName()
graph.mergeFace(deco.joinedFaces[0][0].name, face, np.dot(self.getTransform(), deco.transform2D))
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment