def saddle_connections(self, connections):
     from ipyvue_flatsurf.encoding.saddle_connection_encoding import encode_saddle_connection
     self._saddle_connections = connections
     self.saddle_connections_prop = [
         VueFlatsurfWidget._to_yaml(encode_saddle_connection(connection))
         for connection in connections
     ]
Пример #2
0
    def encoded(self):
        r"""
        Return an encoded version of this flow component.
        """
        start, end = self.in_component

        inside = [
            halfEdge for halfEdge in self.surface.halfEdges()
            if start[halfEdge] and end[halfEdge] and not any(
                isinstance(touch, Crossing)
                for touch in self.touches[halfEdge])
        ]

        touches = {
            halfEdge: [(touch.step, touch.n, i)
                       for (i, touch) in enumerate(self.touches[halfEdge])]
            for halfEdge in self.touches
        }

        touches = {
            step: sorted([(touch[1], halfEdge.id(), touch[2])
                          for halfEdge in touches
                          for touch in touches[halfEdge] if touch[0] == step])
            for connection in self.perimeter
            for step in self.pullback(connection.saddleConnection())
        }

        from ipyvue_flatsurf.encoding.saddle_connection_encoding import encode_saddle_connection

        return {
            "cylinder":
            bool(self.component.cylinder()),
            "perimeter": [
                dict(
                    vertical=connection.vertical(),
                    boundary=connection.boundary(),
                    touches=[{
                        "halfEdge": touch[1],
                        "index": touch[2],
                    } for touch in touches[step]],
                    **encode_saddle_connection(step),
                ) for connection in self.perimeter
                for step in self.pullback(connection.saddleConnection())
            ],
            "inside": [halfEdge.id() for halfEdge in inside],
        }
Пример #3
0
def encode_path(path):
    r"""
    Return the path encoded as a primitive type.

    EXAMPLES::

        >>> from flatsurf import translation_surfaces, GL2ROrbitClosure
        >>> S = translation_surfaces.square_torus()
        >>> O = GL2ROrbitClosure(S)
        >>> D = next(O.decompositions(bound=64))
        >>> component = D.decomposition.components()[0]
        >>> perimeter = component.perimeter()

        >>> from pyflatsurf import flatsurf
        >>> from flatsurf.geometry.pyflatsurf_conversion import to_pyflatsurf
        >>> path = flatsurf.Path[type(to_pyflatsurf(S))]([connection.saddleConnection() for connection in perimeter])
        >>> encode_path(path)
        {'connections': ...}

    """
    return {
        'connections': [encode_saddle_connection(connection) for connection in path]
    }