Ejemplo n.º 1
0
def make_spherical_lens2(CT1, CT2, diameter, 
                         curvature1, curvature2, 
                        centre, direction, x_axis):
    cax = gp.gp_Ax2(gp.gp_Pnt(0,0,CT1-curvature1),
                    gp.gp_Dir(0,sign(curvature1),0),
                    gp.gp_Dir(1,0,0))
    circ = Geom.Geom_Circle(cax, abs(curvature1))
    h_circ = Geom.Handle_Geom_Circle(circ)
    
    cax2 = gp.gp_Ax2(gp.gp_Pnt(0,0,CT2-curvature2),
                    gp.gp_Dir(0,-sign(curvature2),0),
                    gp.gp_Dir(1,0,0))
    circ2 = Geom.Geom_Circle(cax2, abs(curvature2))
    h_circ2 = Geom.Handle_Geom_Circle(circ2)
    
    r = diameter/2.
    
    h2 = CT1 - curvature1 + numpy.sqrt(curvature1**2 - r**2)*sign(curvature1)
    h3 = CT2 - curvature2 + numpy.sqrt(curvature2**2 - r**2)*sign(curvature2)
    p1 = gp.gp_Pnt(0,0,CT1)
    p2 = gp.gp_Pnt(r,0,h2)
    p3 = gp.gp_Pnt(r,0,h3)
    p4 = gp.gp_Pnt(0,0,CT2)
    
    e1 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(h_circ, p1, p2)    
    e2 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(p2,p3)
    e3 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(h_circ2, p3,p4)
    e4 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(p4,p1)
    
    wire = BRepBuilderAPI.BRepBuilderAPI_MakeWire()
    for e in (e1,e2,e3,e4):
        print(e)
        wire.Add(e.Edge())
    
    face = BRepBuilderAPI.BRepBuilderAPI_MakeFace(wire.Wire())
    
    ax = gp.gp_Ax1(gp.gp_Pnt(0,0,0),
                   gp.gp_Dir(0,0,1))
    solid = BRepPrimAPI.BRepPrimAPI_MakeRevol(face.Shape(), ax)
    
    return position_shape(toshape(solid), centre, direction, x_axis)
Ejemplo n.º 2
0
def make_spherical_lens(CT, diameter, curvature, 
                        centre, direction, x_axis):
    cax = gp.gp_Ax2(gp.gp_Pnt(0,0,CT-curvature),
                    gp.gp_Dir(0,1,0),
                    gp.gp_Dir(1,0,0))
    circ = Geom.Geom_Circle(cax, curvature)
    h_circ = Geom.Handle_Geom_Circle(circ)
    
    r = diameter/2.
    h2 = CT - curvature + numpy.sqrt(curvature**2 - r**2)
    p1 = gp.gp_Pnt(0,0,CT)
    p2 = gp.gp_Pnt(r,0,h2)
    p3 = gp.gp_Pnt(r,0,0)
    p4 = gp.gp_Pnt(0,0,0)
    
    #ps = p1,p2,p3,p4
    #vs = [BRepBuilderAPI.BRepBuilderAPI_MakeVertex(p) for p in ps]
    
    e1 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(h_circ, p1,
                                                p2)    
    e2 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(p2,p3)
    e3 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(p3,p4)
    e4 = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(p4,p1)
    
    wire = BRepBuilderAPI.BRepBuilderAPI_MakeWire()
    for e in (e1,e2,e3,e4):
        print(e)
        wire.Add(e.Edge())
    
    face = BRepBuilderAPI.BRepBuilderAPI_MakeFace(wire.Wire())
    
    ax = gp.gp_Ax1(gp.gp_Pnt(0,0,0),
                   gp.gp_Dir(0,0,1))
    solid = BRepPrimAPI.BRepPrimAPI_MakeRevol(face.Shape(), ax)
    
    return position_shape(toshape(solid), centre, direction, x_axis)
Ejemplo n.º 3
0
from OCC import Geom, BRepBuilderAPI, gp
from viewer import view
import numpy

curvature = 50.0

ax = gp.gp_Ax2(gp.gp_Pnt(0, 0, 0), gp.gp_Dir(0, 1, 0), gp.gp_Dir(1, 0, 0))
circ = Geom.Geom_Circle(ax, curvature)
h_circ = Geom.Handle_Geom_Circle(circ)

angle = 1.3
p1 = gp.gp_Pnt(0, 0, curvature)
p2 = gp.gp_Pnt(curvature, 0, 0)

edge = BRepBuilderAPI.BRepBuilderAPI_MakeEdge(h_circ, p1, p2)

view(edge.Shape())