예제 #1
0
 def recSplit(self, iniPts, counter=0):
     p=iniPts
     vertical=False
     if(rs.Distance(p[0],p[1])>rs.Distance(p[0],p[3])):
         vertical=True
     if(vertical==True):
         p0,p1=self.verSplit(iniPts)
     else:
         p0,p1=self.horSplit(iniPts)
     poly0=rs.AddPolyline(p0)
     poly1=rs.AddPolyline(p1)
     counter+=1
     if(counter<3):
         pts0=self.getIntxCrv(poly0)
         pts1=self.getIntxCrv(poly1)
         rs.DeleteObjects([poly0,poly1])
         self.recSplit(pts0,counter)
         self.recSplit(pts1,counter)
     else:
         intxCrv0=rs.CurveBooleanIntersection(self.SITECRV,poly0)
         intxCrv1=rs.CurveBooleanIntersection(self.SITECRV,poly1)
         for i in intxCrv0:
             self.FPOLY.append(i)
         for i in intxCrv1:
             self.FPOLY.append(i)            
         rs.DeleteObjects([poly0,poly1])
     rs.DeleteObject(self.crv)
예제 #2
0
def genHalfPlanes(site_crv, int_crv):
    B = rs.BoundingBox(site_crv)
    polyBB = rs.AddPolyline([B[0], B[1], B[2], B[3], B[0]])
    diagB = 2 * rs.Distance(B[0], B[2])
    rays = []
    int_pts = rs.CurvePoints(int_crv)
    bsp_tree = []
    bsp_tree.append(site_crv)
    for i in range(len(int_pts) - 1):
        a = int_pts[i]
        b = int_pts[i + 1]
        m = [(a[0] + b[0]) / 2, (a[1] + b[1]) / 2, 0]
        p = [
            m[0] + (a[0] - m[0]) * diagB / (rs.Distance(a, m)),
            m[1] + (a[1] - m[1]) * diagB / (rs.Distance(a, m)), 0
        ]
        q = [
            m[0] + (b[0] - m[0]) * diagB / (rs.Distance(b, m)),
            m[1] + (b[1] - m[1]) * diagB / (rs.Distance(b, m)), 0
        ]
        u = [q[0] - p[0], q[1] - p[1], 0]
        v = [-u[1], u[0], 0]
        r = [p[0] + v[0], p[1] + v[1], 0]
        s = [q[0] + v[0], q[1] + v[1], 0]
        w = [u[1], -u[0], 0]
        R = [p[0] + w[0], p[1] + w[1], 0]
        S = [q[0] + w[0], q[1] + w[1], 0]
        polyA = rs.AddPolyline([p, q, s, r, p])
        polyB = rs.AddPolyline([p, q, S, R, p])

        used_crv = []
        new_crv = []
        for bsp_crv in bsp_tree:
            sum = 0
            try:
                crvA = rs.CurveBooleanIntersection(bsp_crv, polyA)
                new_crv.append(crvA)
                sum += 1
            except:
                pass
            try:
                crvB = rs.CurveBooleanIntersection(bsp_crv, polyB)
                new_crv.append(crvB)
                sum += 1
            except:
                pass
            if (sum > 0):
                used_crv.append(bsp_crv)

        for crv in new_crv:
            bsp_tree.append(crv)
        for crv in used_crv:
            bsp_tree.remove(crv)
            rs.DeleteObject(crv)

        rs.DeleteObject(polyA)
        rs.DeleteObject(polyB)

    rs.DeleteObject(polyBB)
    return bsp_tree
예제 #3
0
파일: bsp.py 프로젝트: digitecture/Dots
 def getIntxCrv(self, poly):
     intxCrv=rs.CurveBooleanIntersection(self.SITECRV,poly)
     if(len(intxCrv)>0):
         maxCrv=intxCrv[0]
         maxAr=0.0
         for i in intxCrv: 
             ar=rs.CurveArea(i)[0]
             if(ar>maxAr):
                 maxAr=ar
                 maxCrv=i
         crvpts=rs.CurvePoints(maxCrv)
         rs.DeleteObjects(intxCrv)
         for i in intxCrv:
             try:
                 rs.DeleteObject(i)
                 pass
             except:
                 print("#1. curve not deleted")
         return crvpts
     else:
         for i in intxCrv:
             try:
                 rs.DeleteObject(i)
             except:
                 print("#2. curve not deleted")
         return
예제 #4
0
import rhinoscriptsyntax as rs

curveA = rs.GetObject("Select first curve", 4)
curveB = rs.GetObject("Select second curve", 4)
result = rs.CurveBooleanIntersection(curveA, curveB)


if result:
    rs.DeleteObject(curveA)
    rs.DeleteObject(curveB)