def __init__(self, surface, label, point, ring = None, limit=None): self._s = surface if ring is None: self._ring = surface.base_ring() else: self._ring = ring p = surface.polygon(label) point = VectorSpace(self._ring,2)(point) point.set_immutable() pos = p.get_point_position(point) assert pos.is_inside(), \ "Point must be positioned within the polygon with the given label." # This is the correct thing if point lies in the interior of the polygon with the given label. self._coordinate_dict = {label: {point}} if pos.is_in_edge_interior(): label2,e2 = surface.opposite_edge(label, pos.get_edge()) point2 = surface.edge_transformation(label, pos.get_edge())(point) point2.set_immutable() if label2 in self._coordinate_dict: self._coordinate_dict[label2].add(point2) else: self._coordinate_dict[label2]={point2} if pos.is_vertex(): self._coordinate_dict = {} sing = surface.singularity(label, pos.get_vertex(), limit=limit) for l,v in sing.vertex_set(): new_point = surface.polygon(l).vertex(v) new_point.set_immutable() if l in self._coordinate_dict: self._coordinate_dict[l].add(new_point) else: self._coordinate_dict[l] = {new_point} # Freeze the sets. for label,point_set in self._coordinate_dict.iteritems(): self._coordinate_dict[label] = frozenset(point_set)
def __init__(self, surface, label, point, ring=None, limit=None): self._s = surface if ring is None: self._ring = surface.base_ring() else: self._ring = ring p = surface.polygon(label) point = VectorSpace(self._ring, 2)(point) point.set_immutable() pos = p.get_point_position(point) assert pos.is_inside(), \ "Point must be positioned within the polygon with the given label." # This is the correct thing if point lies in the interior of the polygon with the given label. self._coordinate_dict = {label: {point}} if pos.is_in_edge_interior(): label2, e2 = surface.opposite_edge(label, pos.get_edge()) point2 = surface.edge_transformation(label, pos.get_edge())(point) point2.set_immutable() if label2 in self._coordinate_dict: self._coordinate_dict[label2].add(point2) else: self._coordinate_dict[label2] = {point2} if pos.is_vertex(): self._coordinate_dict = {} sing = surface.singularity(label, pos.get_vertex(), limit=limit) for l, v in sing.vertex_set(): new_point = surface.polygon(l).vertex(v) new_point.set_immutable() if l in self._coordinate_dict: self._coordinate_dict[l].add(new_point) else: self._coordinate_dict[l] = {new_point} # Freeze the sets. for label, point_set in iteritems(self._coordinate_dict): self._coordinate_dict[label] = frozenset(point_set)