Ejemplo n.º 1
0
def srf_nrml_facing_solid_inward(occ_face, occ_solid):
    #move the face in the direction of the normal
    #first offset the face so that vert will be within the solid
    o_wire = Construct.make_offset(occ_face, 0.0001)
    o_face = BRepBuilderAPI_MakeFace(o_wire).Face()

    wire_list = list(Topology.Topo(o_face).wires())
    occpt_list = []
    for wire in wire_list:
        occpts = Topology.WireExplorer(wire).ordered_vertices()
        occpt_list.extend(occpts)

    pt = BRep_Tool.Pnt(occpt_list[0])  #a point that is on the edge of the face
    normal = face_normal(occ_face)

    gp_direction2move = gp_Vec(normal[0], normal[1], normal[2])
    gp_moved_pt = pt.Translated(gp_direction2move.Multiplied(0.001))
    mv_pt = (gp_moved_pt.X(), gp_moved_pt.Y(), gp_moved_pt.Z())

    in_solid = point_in_solid(occ_solid, mv_pt)

    if in_solid:
        return True
    else:
        return False
Ejemplo n.º 2
0
def trim_wire(occwire, pypt1, pypt2, is_periodic=False):
    """
    This function trims the wire.
 
    Parameters
    ----------        
    occwire : OCCwire
        The OCCwire to be fixed.
        
    pypt1 : tuple of floats
        The starting point of the trim. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
        
    pypt2 : tuple of floats
        The ending point of the trim. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
        
    is_periodic : bool, optional
        Indicates if the wire is open or close, True for close, False for open, Default = False.

    Returns
    -------
    trimmed wire : OCCwire
        The trimmed OCCwire.
    """
    gppnt1 = construct.make_gppnt(pypt1)
    gppnt2 = construct.make_gppnt(pypt2)
    trimmed = Construct.trim_wire(occwire,
                                  gppnt1,
                                  gppnt2,
                                  periodic=is_periodic)
    return trimmed
Ejemplo n.º 3
0
def trim_wire(occwire, pypt1, pypt2, is_periodic=False):
    """
    This function trims the wire.
 
    Parameters
    ----------        
    occwire : OCCwire
        The OCCwire to be fixed.
        
    pypt1 : tuple of floats
        The starting point of the trim. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
        
    pypt2 : tuple of floats
        The ending point of the trim. A pypt is a tuple that documents the xyz coordinates of a pt e.g. (x,y,z)
        
    is_periodic : bool, optional
        Indicates if the wire is open or close, True for close, False for open, Default = False.

    Returns
    -------
    trimmed wire : OCCwire
        The trimmed OCCwire.
    """
    gppnt1 = construct.make_gppnt(pypt1)
    gppnt2 = construct.make_gppnt(pypt2)
    trimmed = Construct.trim_wire(occwire, gppnt1, gppnt2, periodic= is_periodic )
    return trimmed
Ejemplo n.º 4
0
def make_loft(occ_face_list, rule_face=True):
    #get the wires from the face_list
    wire_list = []
    for f in occ_face_list:
        wires = fetch.wires_frm_face(f)
        wire_list.extend(wires)

    loft = Construct.make_loft(wire_list, ruled=rule_face)
    return loft
Ejemplo n.º 5
0
def fix_shape(occtopology):
    """
    This function fixes an OCCtopology.
 
    Parameters
    ----------        
    occtopology : OCCtopology
        The OCCtopology to be fixed.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    Returns
    -------
    fixed topology : OCCtopology (OCCshape)
        The fixed OCCtopology.
    """
    fixed_shape = Construct.fix_shape(occtopology)
    return fixed_shape
Ejemplo n.º 6
0
def fix_shape(occtopology):
    """
    This function fixes an OCCtopology.
 
    Parameters
    ----------        
    occtopology : OCCtopology
        The OCCtopology to be fixed.
        OCCtopology includes: OCCshape, OCCcompound, OCCcompsolid, OCCsolid, OCCshell, OCCface, OCCwire, OCCedge, OCCvertex 
        
    Returns
    -------
    fixed topology : OCCtopology (OCCshape)
        The fixed OCCtopology.
    """
    fixed_shape = Construct.fix_shape(occtopology)
    return fixed_shape
Ejemplo n.º 7
0
def srf_nrml_facing_solid_inward(occface, occsolid):
    """
    This function checks if the OCCface is facing the inside of the OCCsolid.
 
    Parameters
    ----------
    occface : OCCface
        The OCCface to be checked.
        
    occsolid : OCCsolid
        The OCCsolid.
        
    Returns
    -------
    True or False : bool
        If True the face is facing the inside of the solid, if False the face is not facing inwards.
    """
    #move the face in the direction of the normal
    #first offset the face so that vert will be within the solid 
    o_wire = Construct.make_offset(occface, 0.0001)
    o_face = BRepBuilderAPI_MakeFace(o_wire).Face()
    
    wire_list =  list(Topology.Topo(o_face).wires())
    occpt_list = []
    for wire in wire_list:
        occpts = Topology.WireExplorer(wire).ordered_vertices()
        occpt_list.extend(occpts)
        
        
    pt = BRep_Tool.Pnt(occpt_list[0]) #a point that is on the edge of the face 
    normal = face_normal(occface)
    
    gp_direction2move = gp_Vec(normal[0], normal[1], normal[2])
    gp_moved_pt = pt.Translated(gp_direction2move.Multiplied(0.001))
    mv_pt = (gp_moved_pt.X(), gp_moved_pt.Y(), gp_moved_pt.Z())
    
    in_solid = point_in_solid(occsolid, mv_pt)
    
    if in_solid:
        return True
    else:
        return False
Ejemplo n.º 8
0
def trim_wire(occ_wire, shapeLimit1, shapeLimit2, is_periodic=False):
    '''
    occwire: wire to be trimmed
    type: occwire
    
    shapeLimit1: the 1st point where to cut the wire
    type: tuple, e.g. (0,1,2.5)
    
    shapeLimit1: the 2nd point where to cut the wire
    type: tuple, e.g. (0,1,2.5)
    
    is_periodic: indicate if the wire is open or close, true for close, false for open
    type: bool, e.g. True or False
    '''

    trimmed = Construct.trim_wire(occ_wire,
                                  shapeLimit1,
                                  shapeLimit2,
                                  periodic=is_periodic)
    return trimmed
Ejemplo n.º 9
0
def srf_nrml_facing_solid_inward(occface, occsolid):
    """
    This function checks if the OCCface is facing the inside of the OCCsolid.
 
    Parameters
    ----------
    occface : OCCface
        The OCCface to be checked.
        
    occsolid : OCCsolid
        The OCCsolid.
        
    Returns
    -------
    True or False : bool
        If True the face is facing the inside of the solid, if False the face is not facing inwards.
    """
    #move the face in the direction of the normal
    #first offset the face so that vert will be within the solid
    o_wire = Construct.make_offset(occface, 0.0001)
    o_face = BRepBuilderAPI_MakeFace(o_wire).Face()

    wire_list = list(Topology.Topo(o_face).wires())
    occpt_list = []
    for wire in wire_list:
        occpts = Topology.WireExplorer(wire).ordered_vertices()
        occpt_list.extend(occpts)

    pt = BRep_Tool.Pnt(occpt_list[0])  #a point that is on the edge of the face
    normal = face_normal(occface)

    gp_direction2move = gp_Vec(normal[0], normal[1], normal[2])
    gp_moved_pt = pt.Translated(gp_direction2move.Multiplied(0.001))
    mv_pt = (gp_moved_pt.X(), gp_moved_pt.Y(), gp_moved_pt.Z())

    in_solid = point_in_solid(occsolid, mv_pt)

    if in_solid:
        return True
    else:
        return False
Ejemplo n.º 10
0
def make_wire_frm_edges(occ_edge_list):
    wire = Construct.make_wire(occ_edge_list)
    return wire
Ejemplo n.º 11
0
def rotate(shape, rot_pt, axis, degree):
    gp_ax3 = gp_Ax1(gp_Pnt(rot_pt[0], rot_pt[1], rot_pt[2]),
                    gp_Dir(axis[0], axis[1], axis[2]))
    rot_shape = Construct.rotate(shape, gp_ax3, degree, copy=False)
    return rot_shape
Ejemplo n.º 12
0
def fix_face(occ_face):
    fixed_face = Construct.fix_face(occ_face)
    return fixed_face
Ejemplo n.º 13
0
def fix_shape(occ_shape):
    fixed_shape = Construct.fix_shape(occ_shape)
    return fixed_shape
Ejemplo n.º 14
0
def make_offset_face2wire(occ_face, offset_value):
    o_wire = Construct.make_offset(occ_face, offset_value)
    return fetch.shape2shapetype(o_wire)
Ejemplo n.º 15
0
def make_offset(occ_face, offset_value):
    o_wire = Construct.make_offset(occ_face, offset_value)
    occface = BRepBuilderAPI_MakeFace(o_wire)
    return occface.Face()
Ejemplo n.º 16
0
def make_compound(topo):
    return Construct.compound(topo)
Ejemplo n.º 17
0
def make_plane_w_dir(centre_pypt, normal_pydir):
    plane_face = Construct.make_plane(
        center=gp_Pnt(centre_pypt[0], centre_pypt[1], centre_pypt[2]),
        vec_normal=gp_Vec(normal_pydir[0], normal_pydir[1], normal_pydir[2]))
    return plane_face
Ejemplo n.º 18
0
def make_vertex(pypt):
    gppt = make_gppnt(pypt)
    vert = Construct.make_vertex(gppt)
    return vert
Ejemplo n.º 19
0
def boolean_difference(occshape2cutfrm, occ_cuttingshape):
    difference = Construct.boolean_cut(occshape2cutfrm, occ_cuttingshape)
    compound = fetch.shape2shapetype(difference)
    return compound
Ejemplo n.º 20
0
def boolean_fuse(occshape1, occshape2):
    fused = Construct.boolean_fuse(occshape1, occshape2)
    compound = fetch.shape2shapetype(fused)
    return compound
Ejemplo n.º 21
0
    'upper': upper_curve,
    'outer': outer_curve,
    'lower': lower_curve,
    'inner': inner_curve
}

TF = {}
for part in TFprofile:
    segments = []
    for curve in TFprofile[part]:
        pipe = BRepFill_PipeShell(TFcurve[curve].Wire())
        for profile in TFprofile[part][curve]:
            pipe.Add(profile)
        pipe.Build()
        segments.append(pipe.Shape())
    quilt = Construct.sew_shapes(segments)
    TF[part] = Construct.make_solid(quilt)

# outer inter-coil supports
OISloop = [[] for i in range(2)]
pnt = [[] for i in range(2)]
OISface = [[] for i in range(2)]
yo = depth / 2 + side  # coil half thickness
ro = yo / np.arctan(theta)  # radial offset

for name in OISsupport:
    OISloop[0] = BRepBuilderAPI_MakePolygon()  # inter-coil support
    for node in OISsupport[name]:
        pnt[0] = gp_Pnt(node[0], yo, node[1])
        OISloop[0].Add(pnt[0])
    OISloop[0].Close()
Ejemplo n.º 22
0
def make_loft_with_wires(occ_wire_list):
    loft = Construct.make_loft(occ_wire_list, ruled=False)
    return loft