Example #1
0
def constructOrientedSurface(skelcontext, faces, direction):
    # orientFaces() returns an OrientedSurface object, but its
    # orientation may not be correct.
    ofaces = cskeletonface.orientFaces(skelcontext.getObject(), faces, None)
    if not ofaces:
        raise ooferror.ErrUserError(
            "Failed to construct an orientable surface")

    if ofaces.closed():
        if direction.string() not in director.closedSurfaceDirections:
            raise ooferror.ErrUserError("Direction must be one of " +
                                        ` director.closedSurfaceDirections `)
        vol = ofaces.volume()
        if (vol > 0 and direction == "Inward"
                or vol < 0 and direction == "Outward"):
            ofaces.reverse()
    else:  # not a closed surface
        if direction.string() not in director.unclosedDirections:
            raise ooferror.ErrUserError("Direction must be one of " +
                                        ` director.unclosedDirections `)
        normal = ofaces.normal()
        if ((direction == '-X to +X' and normal[0] < 0)
                or (direction == '+X to -X' and normal[0] > 0)
                or (direction == '-Y to +Y' and normal[1] < 0)
                or (direction == '+Y to -Y' and normal[1] > 0)
                or (direction == '-Z to +Z' and normal[2] < 0)
                or (direction == '+Z to -Z' and normal[2] > 0)):
            ofaces.reverse()
    return ofaces
Example #2
0
 def closedCheck(self):
     getfaces = skeletongroupwidgets.faceExtractor[self.aggwidget.__class__]
     faces = getfaces(self.skelcontext, self.aggwidget.get_value())
     ofaces = cskeletonface.orientFaces(self.skelcontext.getObject(), faces,
                                        None)
     if not ofaces:
         return None
     if ofaces.closed():
         return "closed"
     return "open"
Example #3
0
def _loadFaceBoundary(menuitem, skeleton, name, faces, exterior):
    # "faces" is a list of triples of integer indices into skeleton.nodes
    skelcontext = skeletoncontext.skeletonContexts[skeleton]
    skeleton = skelcontext.getObject()
    facelist = [
        skeleton.findExistingFace(*[skeleton.getNode(i) for i in f])
        for f in faces
    ]
    # The first face determines the orientation of the whole surface.
    face0 = skeleton.createOrientedFace(
        *[skeleton.getNode(i) for i in faces[0]])
    ofaces = cskeletonface.orientFaces(skeleton, facelist, face0)
    # autoselect=0 prevents the boundary from being selected in the
    # skelcontext. Selection shouldn't happen except by explicit user
    # action.
    skelcontext.createFaceBoundary(name, ofaces, exterior, autoselect=0)