Beispiel #1
0
    def curvature(self, points=None):
        """"""
        if not points:
            points = self.heightfield()

        curvature = []

        if rs.IsPolysurface(self.guid):
            rs.EnableRedraw(False)
            faces = {}
            for point in points:
                bcp = rs.BrepClosestPoint(self.guid, point)
                uv = bcp[1]
                index = bcp[2][1]
                try:
                    face = faces[index]
                except (TypeError, IndexError):
                    face = rs.ExtractSurface(self.guid, index, True)
                    faces[index] = face
                props = rs.SurfaceCurvature(face, uv)
                curvature.append((point, (props[1], props[3], props[5])))
            rs.DeleteObjects(faces.values())
            rs.EnableRedraw(False)
        elif rs.IsSurface(self.guid):
            for point in points:
                bcp = rs.BrepClosestPoint(self.guid, point)
                uv = bcp[1]
                props = rs.SurfaceCurvature(self.guid, uv)
                curvature.append((point, (props[1], props[3], props[5])))
        else:
            raise RhinoSurfaceError('object is not a surface')

        return curvature
Beispiel #2
0
def _point_in_surface(id):
    v = rh.BrepClosestPoint(id, rawu0)
    if v:
        return fromPt(v[0])
    else:
        u, v = rh.SurfaceDomain(id, 0), rh.SurfaceDomain(id, 1)
        return rh.EvaluateSurface(id, u[0], v[0])
Beispiel #3
0
def projectPolyline(vertices, surface):
    #new list for new polyline vertices
    polyline = []
    
    #step through list and get the closest on the BREP (will work for trimmed srf)
    for vertex in vertices:
        pt = rs.BrepClosestPoint(surface, vertex)
        #if we have a closest point, append to the new list, if not just move on
        if pt:
            polyline.append(pt[0])
    return polyline
Beispiel #4
0
    def descent(self, points=None):
        """"""
        if not points:
            points = self.heightfield()

        tol = rs.UnitAbsoluteTolerance()

        descent = []

        if rs.IsPolysurface(self.guid):
            rs.EnableRedraw(False)
            faces = {}
            for p0 in points:
                p = p0[:]
                p[2] -= 2 * tol
                bcp = rs.BrepClosestPoint(self.guid, p)
                uv = bcp[1]
                index = bcp[2][1]
                try:
                    face = faces[index]
                except (TypeError, IndexError):
                    face = rs.ExtractSurface(self.guid, index, True)
                    faces[index] = face
                p1 = rs.EvaluateSurface(face, uv[0], uv[1])
                vector = [p1[_] - p0[_] for _ in range(3)]
                descent.append((p0, vector))
            rs.DeleteObjects(faces.values())
            rs.EnableRedraw(True)
        elif rs.IsSurface(self.guid):
            for p0 in points:
                p = p0[:]
                p[2] -= 2 * tol
                bcp = rs.BrepClosestPoint(self.guid, p)
                uv = bcp[1]
                p1 = rs.EvaluateSurface(self.guid, uv[0], uv[1])
                vector = [p1[_] - p0[_] for _ in range(3)]
                descent.append((p0, vector))
        else:
            raise RhinoSurfaceError('object is not a surface')

        return descent
Beispiel #5
0
def callback(k, args):
    if k%10 == 0:
        rs.Prompt(str(k))
    
    # constrain all non-fixed to a surface
    for key, attr in mesh.vertices(data=True):
        if key in fixed:
            continue
        srf = attr['srf']
        x, y, z = rs.BrepClosestPoint(srf,mesh.vertex_coordinates(key))[0]
        attr['x'] = x
        attr['y'] = y
        attr['z'] = z
        
    conduit.redraw()
Beispiel #6
0
def convert_to_uv_space(srf,pts):
    
    tol = rs.UnitAbsoluteTolerance()
    uv_pts = []
    for pt in pts:
        #need for issues in cases points lie on a seam
        if not rs.IsPointOnSurface (srf, pt):
            pts_dis = []
            pts_dis.append((pt[0]+tol,pt[1],pt[2]))
            pts_dis.append((pt[0]-tol,pt[1],pt[2]))
            pts_dis.append((pt[0],pt[1]+tol,pt[2]))
            pts_dis.append((pt[0],pt[1]-tol,pt[2]))
            pts_dis.append((pt[0],pt[1],pt[2]+tol))
            pts_dis.append((pt[0],pt[1],pt[2]-tol))    
            for pt_dis in pts_dis:
                data= rs.BrepClosestPoint(srf,pt_dis)
                if rs.IsPointOnSurface(srf,data[0]):
                    pt = data[0]
                    break
        u,v = rs.SurfaceClosestPoint(srf,pt)             
        uv_pts.append((u,v,0))
        
        #rs.AddTextDot(str(data[2] ) + " / " + str(rs.IsPointOnSurface (srf, pt)) + " / " + str(u) + " / " + str(v),pt)
    return uv_pts
def callback(k, args):
    if k % 10 == 0:
        rs.Prompt(str(k))

    # constrain all non-fixed to a surface or guide curves
    for key, attr in mesh.vertices(data=True):
        if attr['fixed']:
            continue

        if attr['srf']:
            srf = attr['srf']
            x, y, z = rs.BrepClosestPoint(srf, mesh.vertex_coordinates(key))[0]
            attr['x'] = x
            attr['y'] = y
            attr['z'] = z
        elif attr['crv']:
            crv = attr['crv']
            x, y, z = rs.PointClosestObject(mesh.vertex_coordinates(key),
                                            [crv])[1]
            attr['x'] = x
            attr['y'] = y
            attr['z'] = z

    conduit.redraw()
Beispiel #8
0
def WhoFramedTheSurface():
    surface_id = rs.GetObject("Surface to frame", 8, True, True)
    if not surface_id: return

    count = rs.GetInteger("Number of iterations per direction", 20, 2)
    if not count: return

    udomain = rs.SurfaceDomain(surface_id, 0)
    vdomain = rs.SurfaceDomain(surface_id, 1)
    ustep = (udomain[1] - udomain[0]) / count
    vstep = (vdomain[1] - vdomain[0]) / count

    rs.EnableRedraw(False)
    u = udomain[0]
    while u <= udomain[1]:
        v = vdomain[0]
        while v <= vdomain[1]:
            pt = rs.EvaluateSurface(surface_id, u, v)
            if rs.Distance(pt, rs.BrepClosestPoint(surface_id, pt)[0]) < 0.1:
                srf_frame = rs.SurfaceFrame(surface_id, [u, v])
                rs.AddPlaneSurface(srf_frame, 1.0, 1.0)
            v += vstep
        u += ustep
    rs.EnableRedraw(True)
Beispiel #9
0
def projectpolyline(vertices, surface_id):
    polyline = []
    for vertex in vertices:
        pt = rs.BrepClosestPoint(surface_id, vertex)
        if pt: polyline.append(pt[0])
    return polyline
Beispiel #10
0
def ProjectCurvesToTIN():
    try:
        crvs = rs.GetObjects(message="Select curves to project",
                             filter=4,
                             group=True,
                             preselect=False,
                             select=False,
                             objects=None,
                             minimum_count=1,
                             maximum_count=0,
                             custom_filter=None)
        if not crvs:
            return
        obj = rs.GetObject("Select the TIN to project onto", 8 | 16 | 32)
        if not obj:
            return
        isMesh = rs.IsMesh(obj)
        zUpList = []
        zDownList = []

        rs.EnableRedraw(False)

        # Convert Mesh to Nurbs for ShootRay compatibility
        if isMesh == True:
            srf = rs.MeshToNurb(obj)
        if isMesh == False:
            srf = obj

        # Shoot ray from each grip point and move grips to reflection point
        for crv in crvs:
            rs.EnableObjectGrips(crv)
            grips = rs.ObjectGripLocations(crv)
            for grip in grips:

                zUp = rs.ShootRay(srf, grip, (0, 0, 1), 1)
                # if zUp != None:
                if zUp == None:
                    zUpList.append(False)
                else:
                    zUpList.append(zUp[1])

                zDown = rs.ShootRay(srf, grip, (0, 0, -1), 1)
                # if zDown != None:
                if zDown == None:
                    zDownList.append(False)
                else:
                    zDownList.append(zDown[1])

            rs.CopyObject(crv)  # Copy Existing curve

            # Find the right list to iterate over and insert existing points for any falses
            if all(x is False for x in zUpList):
                falseindex = [i for i, val in enumerate(zDownList) if not val]
                for i in falseindex:
                    # Replace False with existing grip location and closest Z value
                    closestPt = rs.BrepClosestPoint(srf, grips[i])
                    zDownList[i] = (grips[i].X, grips[i].Y, closestPt[0].Z)
                rs.ObjectGripLocations(crv, zDownList)
            else:
                falseindex = [i for i, val in enumerate(zUpList) if not val]
                for i in falseindex:
                    # Replace False with existing grip location and closest Z value
                    closestPt = rs.BrepClosestPoint(srf, grips[i])
                    zUpList[i] = (grips[i].X, grips[i].Y, closestPt[0].Z)
                rs.ObjectGripLocations(crv, zUpList)

            del zDownList[:]
            del zUpList[:]
            rs.EnableObjectGrips(crv, False)

        if isMesh == True:
            rs.DeleteObject(srf)

        rs.EnableRedraw(True)

    except:
        rs.EnableObjectGrips(crv, False)
        rs.DeleteObject(crv)
        rs.EnableRedraw(True)
        print("Failed to project curves")
        return
Beispiel #11
0
def remesh_ani(srf,mesh,trg_len_min,trg_len_max,gauss_min,gauss_max,
           tol=0.1, divergence=0.01, kmax=100,
           target_start=None, kmax_approach=None,
           verbose=False, allow_boundary=False,
           ufunc=None):
    """Remesh until all edges have a specified target length.

    This involves three operations:

        * split edges that are shorter than a minimum length,
        * collapse edges that are longer than a maximum length,
        * swap edges if this improves the valency error.

    The minimum and maximum lengths are calculated based on a desired target
    length:

    Parameters:
        target (float): The target length.
        tol (float): Length deviation tolerance. Defaults to `0.1`
        kmax (int): The number of iterations.
        verbose (bool): Print feedback messages, if True.

    Returns:
        None
    """
    if verbose:
        print
        print target
        
        
    reduce = 0.63
    max_dis = 0.03   
    min_dis = 0.03
    
    boundary = set(mesh.vertices_on_boundary())
    count = 0
    
  
    kmax_approach = float(kmax_approach)
    for k in xrange(kmax):
        

        
        
        if verbose:
            print
            print k
        count += 1
        # split
        
        
        if count == 1:
            
            
            visited = set()
            for u, v in mesh.edges():
                
                

                
                # is this correct?
                if u in visited or v in visited:
                    continue
                
#                 pt = mesh.edge_midpoint(u,v)
#                 para = rs.SurfaceClosestPoint(srf,pt)
#                 data = rs.SurfaceCurvature(srf,para)
#                 
#                 gauss = abs(data[7]+0.000000000000000000001)
#                 if gauss == 0.0:
#                     gauss = 0.00000000000001
#                 elif gauss > 1.0:
#                     gauss = 1
#                 trg_len = (1-(gauss/1)) * (trg_len_max - trg_len_min) + trg_len_min
#                 
#                 
#                 lmin = (1 - tol) * (4.0 / 5.0) * trg_len
#                 lmax = (1 + tol) * (4.0 / 3.0) * trg_len
#                 fac = float(target_start/trg_len)
#                 
#                 if k <= kmax_approach and 1==1:
#                     scale_val = fac*(1.0-k/kmax_approach)
#                     dlmin = lmin*scale_val
#                     dlmax = lmax*scale_val 
#                 else:
#                     dlmin = 0
#                     dlmax = 0                
                
#                 
#                 if k>200:
#                     rs.AddTextDot(round(gauss,3),pt)
                
                
                l = mesh.edge_length(u, v)
                
                pt = mesh.edge_midpoint(u,v)
                pt2 = rs.BrepClosestPoint (srf, pt)[0]
                dis = distance(pt,pt2)
                
                if dis > max_dis:
                    trg_len = l * reduce  
                else:
                    trg_len = l
                lmin = (1 - tol) * (4.0 / 5.0) * trg_len
                lmax = (1 + tol) * (4.0 / 3.0) * trg_len
                fac = float(target_start/trg_len)
                if k <= kmax_approach and 1==1:
                    scale_val = fac*(1.0-k/kmax_approach)
                    dlmin = lmin*scale_val
                    dlmax = lmax*scale_val 
                else:
                    dlmin = 0
                    dlmax = 0 

                    
#                 if l <= lmax:
#                     continue
                if l <= lmax+dlmax:
                
                    continue
                if verbose:
                    print 'split edge: {0} - {1}'.format(u, v)
                split_edge(mesh, u, v, allow_boundary=allow_boundary)
                visited.add(u)
                visited.add(v)
        # collapse
        elif count == 2:
            visited = set()
            for u, v in mesh.edges():
                
          
                
                # is this correct?
                if u in visited or v in visited:
                    continue
                
  
#                 pt = mesh.edge_midpoint(u,v)
#                 para = rs.SurfaceClosestPoint(srf,pt)
#                 data = rs.SurfaceCurvature(srf,para)
#                 
#                 gauss = abs(data[7]+0.000000000000000000001)
#                 if gauss == 0.0:
#                     gauss = 0.00000000000001
#                 elif gauss > 1.0:
#                     gauss = 1
#                 trg_len = (1-(gauss/1)) * (trg_len_max - trg_len_min) + trg_len_min
#                 
#                 
#                 lmin = (1 - tol) * (4.0 / 5.0) * trg_len
#                 lmax = (1 + tol) * (4.0 / 3.0) * trg_len
#                 fac = float(target_start/trg_len)
#                 
#                 if k <= kmax_approach and 1==1:
#                     scale_val = fac*(1.0-k/kmax_approach)
#                     dlmin = lmin*scale_val
#                     dlmax = lmax*scale_val 
#                 else:
#                     dlmin = 0
#                     dlmax = 0                
#                 
#                 
#                 if k>200:
#                     rs.AddTextDot(round(gauss,3),pt)
                
                l = mesh.edge_length(u, v)

                pt = mesh.edge_midpoint(u,v)
                pt2 = rs.BrepClosestPoint (srf, pt)[0]
                dis = distance(pt,pt2)
                
                if dis < min_dis:
                    trg_len = l 
                else:
                    trg_len = l
                lmin = (1 - tol) * (4.0 / 5.0) * trg_len
                lmax = (1 + tol) * (4.0 / 3.0) * trg_len
                fac = float(target_start/trg_len)
                if k <= kmax_approach and 1==1:
                    scale_val = fac*(1.0-k/kmax_approach)
                    dlmin = lmin*scale_val
                    dlmax = lmax*scale_val 
                else:
                    dlmin = 0
                    dlmax = 0               
                         
                
#                 if l >= lmin:
#                     continue
                if l >= lmin-dlmin:
                    continue
                if verbose:
                    print 'collapse edge: {0} - {1}'.format(u, v)
                collapse_edge(mesh, u, v)
                visited.add(u)
                visited.add(v)
                for nbr in mesh.halfedge[u]:
                    visited.add(nbr)
        # swap
        elif count == 3:
            visited = set()
            for u, v in mesh.edges():
                if u in visited or v in visited:
                    continue
                f1 = mesh.halfedge[u][v]
                f2 = mesh.halfedge[v][u]
                if f1 is None or f2 is None:
                    continue
                v1 = mesh.face[f1][v]
                v2 = mesh.face[f2][u]
                valency1 = mesh.vertex_degree(u)
                valency2 = mesh.vertex_degree(v)
                valency3 = mesh.vertex_degree(v1)
                valency4 = mesh.vertex_degree(v2)
                if u in boundary:
                    valency1 += 2
                if v in boundary:
                    valency2 += 2
                if v1 in boundary:
                    valency3 += 2
                if v2 in boundary:
                    valency4 += 2
                current_error = abs(valency1 - 6) + abs(valency2 - 6) + abs(valency3 - 6) + abs(valency4 - 6)
                flipped_error = abs(valency1 - 7) + abs(valency2 - 7) + abs(valency3 - 5) + abs(valency4 - 5)
                if current_error <= flipped_error:
                    continue
                if verbose:
                    print 'swap edge: {0} - {1}'.format(u, v)
                swap_edge(mesh, u, v)
                visited.add(u)
                visited.add(v)
        # count
        else:
            count = 0
            
        
#             if not has_split and not has_collapsed and not has_swapped and dlmin == 0:
#                 termin += 1
#                 if  termin > 10:
#                     print "break asdddddddddddddddddddddddddddddddddddddddddddddddddddddddd"
#                     break
#             else:
#                 termin = 0
            
        # smoothen
        mesh_smooth_on_local_plane(mesh,k=1,d=0.2,fixed=boundary)  
        if ufunc:
            ufunc(mesh,k)
Beispiel #12
0
        def main():
            atr = []
            ManV = []
            totrev = []
            rdm = []
            for iS in range(len(Sources)):
                Closest_pt_on_sphere = (rs.BrepClosestPoint((rs.AddSphere(
                    (Sources[iS])[1], (Sources[iS])[2])), Lp))
                Si.append("S_{}".format(iS + 1))
                Distance = (rs.Distance(Lp, (Closest_pt_on_sphere[0])))
                SDi.append(DecDist(Lh, Distance))
                spthi = (Sources[iS][0]).replace('\\', '/')
                PathList = (spthi).split()
                PercentS = ("\ ").join(PathList)
                SPa.append(PercentS)
                if Lock == True:
                    SPa[iS] = '/i/NoSource_LOCKED'
                    self.AddRuntimeMessage(
                        rem,
                        'Your Sketch is locked, no sound until you unlock ;)')
                    self.Message = "EsquisSons is locked"
                SPan.append(pan(Listener, (Sources[iS])[1]))
                Sint.append(inter_S_B((Sources[iS]), 3, Listener, Geometry))
                if Reverb_on == True:
                    Srev = (rev(Geometry, Listener, (Sources[iS]), 50))
                    Srev1.append((Srev)[0] * Factor)
                    Srev2.append((Srev)[1] * Factor)
                    Str.append((Srev)[2])
                    atr.append((Srev)[2])
                    totrev.append(Srev[0] + Srev[1])
                ManV.append(volm(Sources[iS]))
                rdm.append(Sources[iS][4])
            if Reverb_on is True:
                for i in range(0, len(atr)):
                    RTsource.append(round(atr[i] / 1000, 1))
                    Revinfo.append(
                        str(round(atr[i] / 1000, 1)) + 'sec // mix : ' +
                        str(totrev[i] * Factor) + '%')
            else:
                RTsource.append('No RT: Reverb is disabled')
                Revinfo.append('No infos: Reverb is disabled')
            io = int((len(Sources) - 1))
            i_msg = []
            iosc = []
            for i in range(10):
                try:
                    pathold = oldpath[i]
                except IndexError:
                    oldpath.insert(i, ["empty"])
                except NameError:
                    oldpath = []
                    oldpath.append(["empty"])
                iport = (57100 + i)
                iosc.append(OSC.OSCClient())
                iosc[i].connect(("127.0.0.1", iport))
                i_msg.append(OSC.OSCMessage())
                if i <= io:
                    i_msg[i].append(SDi[i][0])
                    i_msg[i].append(SDi[i][1])
                    i_msg[i].append(SPa[i])
                    i_msg[i].append(SPan[i])
                    if Lock is True:
                        i_msg[i].append(0)
                    else:
                        if ((i_msg[i])[2]) != (oldpath[i]):
                            i_msg[i].append(1)
                        else:
                            i_msg[i].append(2)
                        i_msg[i].append(Sint[i])

                    try:
                        i_msg[i].append(Srev1[i])
                        i_msg[i].append(Srev2[i])
                        i_msg[i].append(Str[i])
                    except:
                        i_msg[i].append(0)
                        i_msg[i].append(0)
                        i_msg[i].append(0)
                    i_msg[i].append(ManV[i])
                    i_msg[i].append(rdm[i])
                    iosc[i].send(i_msg[i])
                    oldpath[i] = SPa[i]

                else:
                    i_msg[i].append(-127)
                    i_msg[i].append(0)
                    i_msg[i].append('/i/NoSource')
                    i_msg[i].append(0)
                    i_msg[i].append(0)
                    i_msg[i].append(0)
                    i_msg[i].append(0)
                    i_msg[i].append(0)
                    i_msg[i].append(0)
                    i_msg[i].append(0)
                    i_msg[i].append(0)

                try:
                    iosc[i].send(i_msg[i])
                except:
                    self.AddRuntimeMessage(
                        ero,
                        'Connexion Failed, please ensure APP is open (use launcher) then reset the engine (with lock/unlock)'
                    )
                    self.Message = 'Connexion Failure'
                print "message, source {} : {}".format(i, i_msg[i])
Beispiel #13
0
 def rev(Ge, Lis, Src, div):
     udiv = div
     vdiv = div
     Pt_L = Lis[0][0]
     srf = []
     FirstRay = []
     SecondRay = []
     First_RefPoint = []
     drawray = []
     Reverb = []
     for i in Ge:
         srf.append(i[0])
     sph = (rs.AddSphere(Src[1], Src[2]))
     Src_pt = (Src[1])
     u = rs.SurfaceDomain(sph, 0)
     v = rs.SurfaceDomain(sph, 1)
     pts = []
     for i in range(0, udiv + 1, 1):
         for j in range(0, vdiv + 1, 1):
             pt = (i / udiv, j / vdiv, 0)
             sphP = rs.SurfaceParameter(sph, pt)
             newpt = rs.EvaluateSurface(sph, sphP[0], sphP[1])
             pts.append(rs.AddPoint(newpt))
     Dir = []
     for p in pts:
         Dir.append(rs.VectorCreate(p, Src_pt))
     Reflexion = []
     for d in Dir:
         Reflexion.append(rs.ShootRay(srf, Src_pt, d, reflections=4))
     Project = []
     for v in Reflexion:
         Cl_Pt = []
         Ray_v = []
         try:
             Project.append(v[1])
             Ray_v.append(rs.AddPolyline(v))
         except:
             pass
         for u in Ray_v:
             pt_on = rs.CurveClosestPoint(u, Pt_L)
             cl = rs.EvaluateCurve(u, pt_on)
             Dicl = (rs.Distance(Pt_L, cl))
             if Dicl <= ((Lis[0])[3]):
                 try:
                     First_RefPoint = rs.CurveClosestPoint(u, v[1])
                     Second_RefPoint = rs.CurveClosestPoint(u, v[2])
                     endc = ((rs.CurveClosestPoint(
                         u, (rs.CurveEndPoint(u)))))
                     if pt_on > Second_RefPoint:
                         SecondRay.append(pt_on / endc *
                                          (rs.CurveLength(u)))
                         drawray.append(u)
                     elif pt_on > First_RefPoint:
                         FirstRay.append(pt_on / endc *
                                         (rs.CurveLength(u)))
                 except:
                     pass
     box = rs.AddBox(rs.BoundingBox(Project))
     boxarea = round((rs.SurfaceArea(box)[0]), 2)
     Cube = []
     Cube.append(box)
     surfacetorev = []
     for s in srf:
         ptons = []
         for p in Project:
             if rs.Distance((rs.BrepClosestPoint(s, p)[0]), p) < 0.1:
                 ptons.append(p)
         if len(ptons) > 0:
             surfacetorev.append(s)
     surfaceab = []
     for x in Ge:
         if x[0] in surfacetorev:
             surfaceab.append(x[2])
     SrfandAb = [(surfacetorev[i], surfaceab[i])
                 for i in range(0, len(surfacetorev))]
     bbox = box
     box = round(((rs.SurfaceVolume(box))[0]), 1)
     srfvol = []
     srfvolex = []
     absvol = []
     srfarea = []
     srfrev = []
     areaabs = []
     surfacecenter = []
     absidx = []
     absvoltot = []
     for i in SrfandAb:
         if rs.SurfaceVolume(i[0]) > 0:
             srfvol.append(i[0])
             absvol.append(i[1])
         else:
             srfarea.append((rs.SurfaceArea(i[0]))[0])
             absvoltot.append(i[1])
     srfvolex = rs.ExplodePolysurfaces(srfvol)
     for i in srfvolex:
         ptonsrf = []
         usefulsrf = []
         for p in Project:
             if rs.Distance((rs.BrepClosestPoint(i, p)[0]), p) < 0.01:
                 ptonsrf.append(p)
                 usefulsrf.append(i)
         if len(ptonsrf) > 0:
             srfarea.append(rs.SurfaceArea(i)[0])
             srfrev.append(i)
     for i in srfrev:
         surfacecenter.append(rs.SurfaceAreaCentroid(i)[0])
     for b in srfvol:
         for i in surfacecenter:
             if rs.Distance((rs.BrepClosestPoint(b, i)[0]), i) < 0.01:
                 absidx.append(srfvol.index(b))
     for i in absidx:
         absvoltot.append(absvol[i])
     try:
         areaabs = [
             srfarea[i] * (absvoltot[i])
             for i in range(0, len(absvoltot))
         ]
     except:
         raise Exception(
             'One source must be too deep inside a geometry, try to get it out or to move it a little bit !'
         )
     Builtareaabs = 0
     for i in areaabs:
         Builtareaabs += i
     BuiltArea = 0
     for i in srfarea:
         BuiltArea += i
     BuiltArea = round(BuiltArea, 2)
     EmptyArea = 2 * (round(boxarea - BuiltArea, 2))
     if EmptyArea < 0:
         EmptyArea = 0
     TR = 1000 * (0.16 * box) / (Builtareaabs + (EmptyArea * 1))
     FRValue = 0
     for f in FirstRay:
         FV = ((((Lis[0])[3]) * 15) / f)
         FRValue += FV
     if FRValue >= 125:
         FRValue = 125
     SRValue = 0
     for s in SecondRay:
         SV = ((((Lis[0])[3]) * 20) / s)
         SRValue += SV
     if SRValue > 125:
         SRValue = 125
     Reverb.append(round(FRValue))
     Reverb.append(round(SRValue))
     Reverb.append(round(TR, 2))
     return Reverb
Beispiel #14
0
uDomain = rs.SurfaceDomain(idSurface, 0)
vDomain = rs.SurfaceDomain(idSurface, 1)

# get size int from domain & / by intended count = increment between surfaces
uStep = (uDomain[1] - uDomain[0]) / intCount
vStep = (vDomain[1] - vDomain[0]) / intCount

#print uStep
#print vStep

rs.EnableRedraw(False)

# loop through size of surface by step increment in both u & v directions
for u in rs.frange(uDomain[0], uDomain[1], uStep):
    for v in rs.frange(vDomain[0], vDomain[1], vStep):
        pt = rs.EvaluateSurface(idSurface, u,
                                v)  # get points at each domain step
        if rs.Distance(pt, rs.BrepClosestPoint(idSurface, pt)[0]) < 0.1:
            srfFrame = rs.SurfaceFrame(
                idSurface, [u, v])  # create ref plane at each division point
            newPlane = rs.AddPlaneSurface(
                srfFrame, 1.0, 1.0)  # create surface at each ref plane
            # add height guideline from plane's origin to "ceiling"
            centerPt = rs.SurfaceAreaCentroid(
                newPlane)  # locate center of each new plane
            limit = 10  # set "ceiling"
            endPt = limit - centerPt[0][
                2]  # access z coordinate with the tuple
            rs.AddLine(centerPt[0], rs.PointAdd(centerPt[0], (0, 0, endPt)))

rs.EnableRedraw(True)  # refresh viewport at one time only
 def DistanceTo(pt, id):
     ptCP = rs.BrepClosestPoint(id,pt)
     if ptCP:
         d = rs.Distance(pt, ptCP[0])
         return math.log(d+1)
Beispiel #16
0
 if len(subcrvs) > 1:
     subcurve = rs.JoinCurves(subcrvs)
     assert len(subcurve) == 1
     subcurve = subcurve[0]
 else:
     subcurve = subcrvs[0]
 newpts = []
 """Need to specify num_of_seg"""
 divparams = rs.DivideCurve(subcurve,
                            num_of_seg,
                            create_points=True,
                            return_points=False)
 print(divparams)
 for j in range(len(divparams)):
     divpt = rs.EvaluateCurve(main_curve, divparams[j])
     normal = rs.BrepClosestPoint(surface, divpt)[3]
     """Need to specify tangent"""
     tangent = rs.CurveTangent(main_curve, divparams[j], segment_index=-1)
     pushoff = rs.VectorCrossProduct(tangent, normal)
     dist = eps * (len(divparams) / 2 - abs(len(divparams) / 2 - j - 1))
     newpt = rs.PointAdd(divpt, rs.VectorScale(pushoff, dist))
     newpt = rs.BrepClosestPoint(surface, newpt)[0]
     newpts.append(newpt)
 newcrv = rs.AddInterpCurve(newpts)
 newcurves.append(newcrv)
 t1paramnew = []
 t2paramnew = []
 if t1param < t2param:
     t1paramnew.append(t2param)
     t1paramnew.append(0)
     t2paramnew.append(1)