Exemple #1
0
def _sphere(r, yaw=None, pitch=None):
    if yaw is None and pitch is None:
        raw = OCC.Core.BRepPrimAPI.BRepPrimAPI_MakeSphere(r).Shape()
    elif yaw is None and pitch is not None:
        pitch = angle_pair(pitch)
        raw = OCC.Core.BRepPrimAPI.BRepPrimAPI_MakeSphere(
            r, pitch[0], pitch[1]).Shape()
    elif yaw is not None and pitch is None:
        raw = OCC.Core.BRepPrimAPI.BRepPrimAPI_MakeSphere(r, yaw).Shape()
    else:
        pitch = angle_pair(pitch)
        raw = OCC.Core.BRepPrimAPI.BRepPrimAPI_MakeSphere(
            r, pitch[0], pitch[1], yaw).Shape()

    return Shape(raw)
Exemple #2
0
def _torus(r1, r2, yaw=None, pitch=None):
    if yaw is None and pitch is None:
        raw = OCC.Core.BRepPrimAPI.BRepPrimAPI_MakeTorus(r1, r2).Shape()
    elif yaw is None and pitch is not None:
        pitch = angle_pair(pitch)
        raw = OCC.Core.BRepPrimAPI.BRepPrimAPI_MakeTorus(
            r1, r2, pitch[0], pitch[1]).Shape()
    elif yaw is not None and pitch is None:
        raw = OCC.Core.BRepPrimAPI.BRepPrimAPI_MakeTorus(r1, r2, yaw).Shape()
    else:
        pitch = angle_pair(pitch)
        raw = OCC.Core.BRepPrimAPI.BRepPrimAPI_MakeTorus(
            r1, r2, pitch[0], pitch[1], yaw).Shape()

    return Shape(raw)
Exemple #3
0
def ellipse(r1, r2, angle=None, wire=False):
    if angle is not None:
        ap = angle_pair(angle)

    if angle is not None:
        return pyservoce.ellipse(r1, r2, ap[0], ap[1], wire=wire)
    else:
        return pyservoce.ellipse(r1, r2, wire=wire)
Exemple #4
0
def circle(r, angle=None, wire=False):
    if angle is not None:
        ap = angle_pair(angle)

    if angle is not None:
        return pyservoce.circle(r, ap[0], ap[1], wire=wire)
    else:
        return pyservoce.circle(r, wire=wire)
Exemple #5
0
def ellipse(r1, r2, angle=None, wire=False):
    if wire:
        foo = pyservoce.ellipse_edge
    else:
        foo = pyservoce.ellipse

    if r1 < r2:
        if angle is not None:
            angle = angle_pair(angle)
            angle = (angle[0] - math.pi / 2, angle[1] - math.pi / 2)
        return ellipse(r2, r1, angle, wire).rotateZ(math.pi / 2)
        #raise ValueError("In ellipse r1 must be greater then r2")

    if angle is not None:
        angle = angle_pair(angle)
        return foo(r1, r2, angle[0], angle[1])
    else:
        return foo(r1, r2)
Exemple #6
0
def ellipse(r1, r2, angle=None, wire=False):
    if r1 < r2:
        raise ValueError("In ellipse r1 must be greater then r2")

    if angle is not None:
        angle = angle_pair(angle)
        return pyservoce.ellipse(r1, r2, angle[0], angle[1], wire=wire)
    else:
        return pyservoce.ellipse(r1, r2, wire=wire)
Exemple #7
0
def circle(r, angle=None, wire=False):
    if wire:
        foo = pyservoce.circle_edge
    else:
        foo = pyservoce.circle

    if angle is not None:
        angle = angle_pair(angle)
        return foo(r, angle[0], angle[1])
    else:
        return foo(r)
Exemple #8
0
def sphere(r, yaw=None, pitch=None, shell=False):
    if yaw is not None:
        if yaw > deg(360):
            raise Exception("Wrong parametr `yaw`. yaw defined in [0, 2*pi]")

    if pitch is not None:
        pitch = angle_pair(pitch)

        if pitch[0] > pitch[1]:
            raise Exception(
                "Wrong parametr `pitch`. pitch[0] should be less then pitch[1]"
            )

        if pitch[0] > pitch[1]:
            raise Exception(
                "Wrong parametr `pitch`. pitch[0] should be less then pitch[1]"
            )

        if (
            pitch[0] > deg(90)
            or pitch[1] > deg(90)
            or pitch[0] < -deg(90)
            or pitch[1] < -deg(90)
        ):
            raise Exception(
                "Wrong parametr `pitch`. pitch[0] and pitch[1] defined in [-pi/2, pi/2]"
            )

    if yaw is not None:
        if pitch is not None:
            m = pyservoce.sphere(r=r, pitch0=pitch[0], pitch1=pitch[1], yaw=yaw)
        else:
            m = pyservoce.sphere(r=r, yaw=yaw)

    else:
        if pitch is not None:
            m = pyservoce.sphere(r=r, pitch0=pitch[0], pitch1=pitch[1])
        else:
            m = pyservoce.sphere(r=r)

    if shell:
        return m.shells()[0]
    else:
        return m
Exemple #9
0
def torus(r1, r2, yaw=None, pitch=None, shell=False):
    if pitch is not None:
        pitch = angle_pair(pitch)
        if yaw is not None:
            m = pyservoce.torus(
                r1=r1, r2=r2, pitch0=pitch[0], pitch1=pitch[1], yaw=yaw
            )
        else:
            m = pyservoce.torus(r1=r1, r2=r2, pitch0=pitch[0], pitch1=pitch[1])
    else:
        if yaw is not None:
            m = pyservoce.torus(r1=r1, r2=r2, yaw=yaw)
        else:
            #return pyservoce.torus(r1=r1, r2=r2)
            m = (pyservoce.torus(r1=r1, r2=r2, yaw=deg(180)) 
                + pyservoce.torus(r1=r1, r2=r2, yaw=deg(180)).rotateZ(deg(180)))

    if shell:
        return m.shells()[0]
    else:
        return m
Exemple #10
0
def torus(r1, r2, yaw=None, pitch=None):
    if pitch is not None:
        pitch = angle_pair(pitch)
        if yaw is not None:
            return pyservoce.torus(r1=r1,
                                   r2=r2,
                                   pitch0=pitch[0],
                                   pitch1=pitch[1],
                                   yaw=yaw)
        else:
            return pyservoce.torus(r1=r1,
                                   r2=r2,
                                   pitch0=pitch[0],
                                   pitch1=pitch[1])
    else:
        if yaw is not None:
            return pyservoce.torus(r1=r1, r2=r2, yaw=yaw)
        else:
            #return pyservoce.torus(r1=r1, r2=r2)
            return (
                pyservoce.torus(r1=r1, r2=r2, yaw=deg(180)) +
                pyservoce.torus(r1=r1, r2=r2, yaw=deg(180)).rotateZ(deg(180)))