示例#1
0
def falling_pump(event=None):
    def load_brep(filename):
    # Load the shape from a file
        aShape = TopoDS_Shape()
        builder = BRep_Builder()
        BRepTools_Read(aShape,str(filename),builder)
        return aShape

    # Just a copy/paste of the torus code
    display.EraseAll()
    dyn_context = DynamicSimulationContext()
    dyn_context.set_display(display, safe_yield)
    dyn_context.enable_collision_detection()
    dyn_context.enable_gravity()

    _pth = os.path.abspath(
                            os.path.join( os.path.split(os.path.abspath(__file__))[0],
                             '../data/brep/Pump_Bottom.brep')
    )
    s1 = file_to_shape(_pth)

    d = dyn_context.register_shape(s1,enable_collision_detection=True,use_trimesh=True)
 
    # The plane (note: this plane is not a dynamic shape, it's just displayed)
    P1 = gp_Pnt(0,0,-1000)
    V1 = gp_Vec(0,0,1)
    face = make_plane(P1,V1, -1000., 1000., -600., 600.)
    # Then create a geom for this plane
    # Create a plane geom which prevent the objects from falling forever
    floor = ode.GeomPlane(dyn_context._space, (0,0,1), -1000)
    display.DisplayColoredShape(face,'RED')
    display.FitAll()
    #Starts the simulation
    dyn_context.set_simulation_duration(30) #1s forthe simulation
    dyn_context.set_time_step(0.001)
    dyn_context.start_open_loop()
    del dyn_context
示例#2
0
def get_brep():
    from OCC.DataExchange.utils import file_to_shape
    pth = os.path.split(os.path.abspath(__file__))[0]
    pth = os.path.abspath( os.path.join(pth, '../../../data/_3dmodels/Pump_Bottom.brep') )
    return file_to_shape(pth)
示例#3
0
def get_brep():
    from OCC.DataExchange.utils import file_to_shape
    pth = os.path.split(os.path.abspath(__file__))[0]
    pth = os.path.abspath(
        os.path.join(pth, '../../../data/_3dmodels/Pump_Bottom.brep'))
    return file_to_shape(pth)