Exemplo n.º 1
0
import ghhops_server as hs
import rhino3dm


hops = hs.Hops()


@hops.component(
    "/add",
    name="Add",
    nickname="Add",
    description="Add numbers with CPython",
    category="Maths",
    subcategory="CPython",
    inputs=[
        hs.HopsNumber("A", "A", "First number"),
        hs.HopsNumber("B", "B", "Second number"),
    ],
    outputs=[hs.HopsNumber("Sum", "S", "A + B")],
)
def add(a, b):
    # testing error report
    f = 12 / 0
    return a + b


@hops.component(
    "/pointat",
    name="PointAt",
    nickname="PtAt",
    description="Get point along curve",
Exemplo n.º 2
0
        allindexes.extend(pathIndexes)
        slen.append(pathLen)
        
        g.remove_nodes_from(pathNodes)

    return strips, allindexes, slen



#MST COMPONENT ---------------------
@hops.component(
    "/mst",
    name = "mst",
    inputs=[
        hs.HopsMesh("Input Mesh", "M", "Mesh"),
        hs.HopsNumber("Weigth", "W", "Weight per face", hs.HopsParamAccess.LIST)

    ],
    outputs=[
        #hs.HopsPoint("list of points","P","shortest path points", hs.HopsParamAccess.LIST),
        #hs.HopsInteger("list of faces indexes","F","shortest path face indexes", hs.HopsParamAccess.LIST),
        hs.HopsString("list of faces indexes","F","shortest path face indexes", hs.HopsParamAccess.LIST),
        hs.HopsCurve("lines", "L", "MST Lines", hs.HopsParamAccess.LIST)
    ]
)
def mst( mesh, weights):


    mstGraph = mp.graphFromMesh(mesh) #convert the mesh to a nx graph
    
    #plot = mu.plotGraphSave(mstGraph)
Exemplo n.º 3
0
    return G


def extract_types(G):
    return list(nx.get_edge_attributes(G, 'type').values())


@hops.component(
    "/lines_14",
    name="Lines",
    inputs=[
        hs.HopsCurve("Edges", "E", access=hs.HopsParamAccess.LIST),
        hs.HopsString("EdgesTypes", "ET", access=hs.HopsParamAccess.LIST),
        hs.HopsPoint("AgentsCoordinates", "AC", access=hs.HopsParamAccess.LIST),
        hs.HopsString("AgentsTypes", "AT", access=hs.HopsParamAccess.LIST),
        hs.HopsNumber("Updater", "u"),
    ],
    outputs=[
        hs.HopsString("NewTypes", "NT", access=hs.HopsParamAccess.LIST)
    ]
)
def lines(edges: [Curve], edges_types: [str],
          agents_coordinates: [Point3d], agents_types: [str],
          _):
    G = init_graph(edges, edges_types)
    EdgeType.set_weight(G)
    city_graph = CityGraph(G, geo_graph=False)
    print_edges(G)
    print_nodes(G)
    return extract_types(G)
Exemplo n.º 4
0
Arquivo: app.py Projeto: deKlerk/Hops
app = Flask(__name__)
hops: hs.HopsFlask = hs.Hops(app)

# flask app can be used for other stuff drectly
@app.route("/help")
def help():
    return "Welcome to Grashopper Hops for CPython!"

#-- Point At component --#
@hops.component(
    "/pointat",
    name="PointAt",
    description="Get a point along a curve",
    inputs=[
        hs.HopsCurve("Curve", "C", "Curve to evaluate"),
        hs.HopsNumber("t", "t", "Parameter on Curve to evaluate.")
    ],
    outputs=[
        hs.HopsPoint("P", "P", "Point on Curve at parameter t")
    ]
)
def pointat(curve: rh.Curve, t: float=0):
    pt = curve.PointAt(t)
    return pt


#-- Profile Levels component --#
@hops.component(
    "/plevels",
    name="ProfileLevels",
    description="Creates a series of levels from a profile",
Exemplo n.º 5
0
# System and Rhino can only be loaded after rhinoinside is initialized
import System  # noqa
import Rhino  # noqa

hops = hs.Hops(app=rhinoinside)


@hops.component(
    "/add",
    name="Add",
    nickname="Add",
    description="Add numbers with CPython",
    category="Maths",
    subcategory="CPython",
    inputs=[
        hs.HopsNumber("A", "A", "First number"),
        hs.HopsNumber("B", "B", "Second number"),
    ],
    outputs=[hs.HopsNumber("Sum", "S", "A + B")],
)
def add(a, b):
    # testing error report
    f = 12 / 0
    return a + b


@hops.component(
    "/pointat",
    name="PointAt",
    nickname="PtAt",
    description="Get point along curve",
from PIL import Image
from matplotlib import pyplot as plt

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

app = Flask(__name__)
hops = hs.Hops(app)


@hops.component("/runml",
                name="runml",
                description="Run Machine Learning prediction",
                icon="examples/pointat.png",
                inputs=[
                    hs.HopsCurve("Curve", "C", "Curve to evaluate"),
                    hs.HopsNumber("t", "t", "Parameter on Curve to evaluate"),
                ],
                outputs=[
                    hs.HopsPoint("P", "P", "Point on curve at t"),
                ])
def run_ml():
    new_model = tf.keras.models.load_model(
        "D:\German Profile\Desktop\PREDICTION MODEL\pattern_model.h5")
    new_model.summary()
    print("Model OK")

    #LOAD QUERY
    query_flat = np.loadtxt("query.txt")  #load
    query = np.reshape(query_flat, (128, 128, 3))
    query = query.astype(np.float32)
    query_norm = np.multiply(query, 2)