예제 #1
0
    def fixSegment(self, segment, slab_poly):
        e1, e2 = segment.End1.PntCoord, segment.End2.PntCoord
        pnt1 = Pnt(e1.x, e1.y)
        pnt2 = Pnt(e2.x, e2.y)
        end1 = pnt1.copy()
        end2 = pnt2.copy()
        if not pnt1.isInPolygon(slab_poly):
            end1 = self.get_closest_intersection(pnt1, pnt2, slab_poly)

        if not pnt2.isInPolygon(slab_poly):
            end2 = self.get_closest_intersection(pnt2, pnt1, slab_poly)

        if end1 is not None and end2 is None:
            print((e1.x, e1.y, e2.x, e2.y))
            print("polygon")
            for pnt in slab_poly.points:
                print((pnt.x(), pnt.y()))
            raise Exception

        if end1 is None and end2 is not None:
            print((e1.x, e1.y, e2.x, e2.y))
            print("polygon")
            for pnt in slab_poly.points:
                print((pnt.x(), pnt.y()))
            raise Exception

        # start
        # for poly
        #     ('(-1.82486794037,-1.03558377118)', '(-5.12486794037,-1.03558377118)')
        # ('(-9.12486794037,-5.63558377118)', '(-9.12486794037,-0.960583771182)')
        # ('result', '(-9.12486794037,-1.03558377118)')
        # ('outcome', None)
        # ('(-1.82486794037,-1.03558377118)', '(-5.12486794037,-1.03558377118)')
        # ('(-9.12486794037,-0.960583771182)', '(-4.94986794037,-0.960583771182)')
        # ('result', 'None')
        # ('outcome', None)
        # ('(-1.82486794037,-1.03558377118)', '(-5.12486794037,-1.03558377118)')
        # ('(-4.94986794037,-0.960583771182)', '(-4.94986794037,-5.63558377118)')
        # ('result', '(-4.94986794037,-1.03558377118)')
        # ('outcome', None)
        # ('(-1.82486794037,-1.03558377118)', '(-5.12486794037,-1.03558377118)')
        # ('(-4.94986794037,-5.63558377118)', '(-9.12486794037,-5.63558377118)')
        # ('result', 'None')
        # ('outcome', None)
        # (-5.124867940372748, -1.0355837711820652, -1.824867940372748, -1.0355837711820652)
        # polygon
        # (-9.12486794037277, -5.63558377118204)
        # (-9.12486794037277, -0.9605837711820402)
        # (-4.949867940372769, -0.9605837711820402)
        # (-4.949867940372769, -5.63558377118204)
        if end1 is None or end1.minus(end2).magn() == 0:
            return None
        return Segment(EndOfSegment(end1.pnt), EndOfSegment(end2.pnt),
                       segment.Open)
예제 #2
0
    def getSurrondingBoxes(self, selected=None):
        if self.surrondingBoxes:
            return self.surrondingBoxes
        if selected is None:
            selected = [1, 1, 1, 1]
        distance = 4
        distance2 = 1
        wid = Pnt(self.vecLength.y(), -self.vecLength.x())
        wid2 = wid.copy().resize(distance2) * 2 + wid.copy().resize(
            self.vecWidth.magn())
        wid1 = wid.copy().resize(distance) * 2 + wid.copy().resize(
            self.vecWidth.magn())
        # leng = self.vecLength.copy().resize(distance)*2 + self.vecLength
        leng = self.vecLength
        center = self.topLeftPnt + self.vecLength / 2 + self.vecWidth / 2

        if selected[0]:
            wid = wid1
        else:
            wid = wid2
        pnt1 = center - leng / 2 - wid / 2
        pnts = [pnt1, pnt1 + leng, pnt1 + leng + wid / 2, pnt1 + wid / 2]
        polygon = Polygon([[pnt.x(), pnt.y()] for pnt in pnts])

        if selected[1]:
            wid = wid1
        else:
            wid = wid2
        pnt1 = center - leng / 2 + wid / 2
        pnts = [pnt1, pnt1 + leng, pnt1 + leng - wid / 2, pnt1 - wid / 2]
        polygon2 = Polygon([[pnt.x(), pnt.y()] for pnt in pnts])

        if selected[2]:
            d = distance
        else:
            d = distance2
        p = center - leng / 2
        p = Point(p.x(), p.y())
        circle = p.buffer(d + self.vecWidth.magn() / 2)

        if selected[3]:
            d = distance
        else:
            d = distance2
        p2 = center + leng / 2
        p2 = Point(p2.x(), p2.y())
        circle2 = p2.buffer(d + self.vecWidth.magn() / 2)

        result = [polygon, polygon2, circle, circle2]
        self.surrondingBoxes = result
        return result
예제 #3
0
 def getSurrondingBox(self, d_ratio):
     if self.surrondingBox:
         return self.surrondingBox
     distance = 4 * d_ratio
     wid = Pnt(self.vecLength.y(), -self.vecLength.x())
     wid = wid.copy().resize(distance) * 2 + wid.copy().resize(
         self.vecWidth.magn())
     # leng = self.vecLength.copy().resize(distance)*2 + self.vecLength
     leng = self.vecLength
     center = self.topLeftPnt + self.vecLength / 2 + self.vecWidth / 2
     pnt1 = center - leng / 2 - wid / 2
     pnts = [pnt1, pnt1 + leng, pnt1 + leng + wid, pnt1 + wid]
     polyPnts = [[pnt.x(), pnt.y()] for pnt in pnts]
     polygon = Polygon(polyPnts)
     p = center - leng / 2
     p = Point(p.x(), p.y())
     p2 = center + leng / 2
     p2 = Point(p2.x(), p2.y())
     circle = p.buffer(distance + self.vecWidth.magn() / 2)
     circle2 = p2.buffer(distance + self.vecWidth.magn() / 2)
     result = polygon.union(circle).union(circle2)
     self.surrondingBox = result
     return result
예제 #4
0
파일: Plotter.py 프로젝트: mag420/ArchToCE
        xs, ys = shape.exterior.xy
        ax.fill(xs, ys, alpha=a, fc=c, ec=[0, 0, 0])


if __name__ == "__main__":
    # poly1 = Poly([Pnt(0, 1), Pnt(1, 0), Pnt(6, 5), Pnt(5, 6)])
    # polys = [poly1]
    # plotPolys(polys,1)
    # poly2 = Poly([Pnt(1, 2), Pnt(2, 1), Pnt(7, 6), Pnt(6, 7)])
    # polys = [poly2]
    # plotPolys(polys, 2)
    distance = 2
    center = Pnt(1, 1)
    vecLength = Pnt(10, 1)
    wid = Pnt(vecLength.y(), -vecLength.x())
    wid = wid.copy().resize(distance) * 2 + wid.copy().resize(1)
    # leng = self.vecLength.copy().resize(distance)*2 + self.vecLength
    leng = vecLength
    pnts = []
    pnts.append(center - leng / 2 - wid / 2)
    pnts.append(pnts[0] + leng)
    pnts.append(pnts[1] + wid)
    pnts.append(pnts[0] + wid)
    polyPnts = [[pnt.x(), pnt.y()] for pnt in pnts]
    polygon = Polygon(polyPnts)
    p = center - leng / 2
    p = Point(p.x(), p.y())
    p2 = center + leng / 2
    p2 = Point(p2.x(), p2.y())
    circle = p.buffer(distance + 0.5)
    circle2 = p2.buffer(distance + 0.5)