Example #1
0
 def make_EllipWire(self,
                    rxy=[1.0, 1.0],
                    shft=0.0,
                    skin=None,
                    axs=gp_Ax3()):
     rx, ry = rxy
     if rx > ry:
         major_radi = rx
         minor_radi = ry
         axis = gp_Ax2()
         axis.SetXDirection(axis.XDirection())
     else:
         major_radi = ry
         minor_radi = rx
         axis = gp_Ax2()
         axis.SetXDirection(axis.YDirection())
     axis.Rotate(axis.Axis(), np.deg2rad(shft))
     elip = make_edge(gp_Elips(axis, major_radi, minor_radi))
     poly = make_wire(elip)
     poly.Location(set_loc(gp_Ax3(), axs))
     if skin == None:
         return poly
     else:
         n_sided = BRepFill_Filling()
         for e in Topo(poly).edges():
             n_sided.Add(e, GeomAbs_C0)
         n_sided.Build()
         face = n_sided.Face()
         if skin == 0:
             return face
         else:
             solid = BRepOffset_MakeOffset(face, skin, 1.0E-5,
                                           BRepOffset_Skin, False, True,
                                           GeomAbs_Arc, True, True)
             return solid.Shape()
Example #2
0
    def make_StarWire(self,
                      num=5,
                      radi=[2.0, 1.0],
                      shft=0.0,
                      axs=gp_Ax3(),
                      skin=None):
        lxy = radi
        pnts = []
        angl = 360 / num
        for i in range(num):
            a_thet = np.deg2rad(i * angl) + np.deg2rad(shft)
            ax, ay = radi[0] * np.sin(a_thet), radi[0] * np.cos(a_thet)
            pnts.append(gp_Pnt(ax, ay, 0))
            b_thet = a_thet + np.deg2rad(angl) / 2
            bx, by = radi[1] * np.sin(b_thet), radi[1] * np.cos(b_thet)
            pnts.append(gp_Pnt(bx, by, 0))
        pnts.append(pnts[0])
        poly = make_polygon(pnts)
        poly.Location(set_loc(gp_Ax3(), axs))

        n_sided = BRepFill_Filling()
        for e in Topo(poly).edges():
            n_sided.Add(e, GeomAbs_C0)
        n_sided.Build()
        face = n_sided.Face()
        if skin == None:
            return poly
        elif skin == 0:
            return face
        else:
            solid = BRepOffset_MakeOffset(face, skin, 1.0E-5, BRepOffset_Skin,
                                          False, True, GeomAbs_Arc, True, True)
            return solid.Shape()
Example #3
0
    def __init__(self):
        plotocc.__init__(self)

        print(gxyz.shape)
        for i, xyz in enumerate(gxyz):
            print(i, *xyz)
            self.display.DisplayShape(gp_Pnt(*xyz))

        e_array = []
        for e in xyz_max:
            x, y, z = e
            e = gp_Pnt(float(x), float(y), float(z))
            e_array.append(e)
        e_array.append(e_array[0])
        poly = make_polygon(e_array)

        n_sided = BRepFill_Filling()
        for e in Topo(poly).edges():
            n_sided.Add(e, GeomAbs_C0)
        for pt in gxyz:
            x, y, z = pt
            if (x < xmax) and (x > xmin) and (y < ymax) and (y > ymin) and (
                    z < zmax) and (z > zmin):
                n_sided.Add(gp_Pnt(x, y, z))
        n_sided.Build()
        face = n_sided.Face()

        #face = make_n_sided(edges, p_array)

        # THICKEN SURFACE
        thickness = 0.15
        solid = BRepOffset_MakeOffset(face, thickness, 1.0E-5, BRepOffset_Skin,
                                      False, False, GeomAbs_Intersection, True)
        # The last True is important to make solid
        # solid.MakeOffsetShape()
        # solid.MakeThickSolid()
        #aShape = solid.Shape()

        self.display.DisplayShape(poly)
        self.display.DisplayShape(face)
        #display.DisplayShape(aShape, update=True)
        #write_step_file(aShape, "./tmp/gyroid.stp")

        self.export_stp(solid.Shape())
Example #4
0
from optparse import OptionParser

from OCC.Core.gp import gp_Pnt, gp_Vec, gp_Pnt2d, gp_Pln, gp_Dir
from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakePrism
from OCC.Core.BRepOffset import BRepOffset_MakeOffset, BRepOffset_Skin, BRepOffset_Interval
from OCC.Core.GeomAbs import GeomAbs_C0, GeomAbs_C1, GeomAbs_C2
from OCC.Core.GeomAbs import GeomAbs_G1, GeomAbs_G2
from OCC.Core.GeomAbs import GeomAbs_Intersection, GeomAbs_Arc

sys.path.append(os.path.join('./'))
from src.base import plotocc

obj = plotocc(touch=True)

pts = []
pts.append(gp_Pnt(0, 0, 0))
pts.append(gp_Pnt(0, 1, 0.1))
pts.append(gp_Pnt(1, 1, -0.1))
pts.append(gp_Pnt(1, 0, 0))
pts.append(pts[0])

face = obj.make_FaceByOrder(pts)
#sold = BRepPrimAPI_MakePrism(face, gp_Vec(0, 0, 2)).Shape()
sold = BRepOffset_MakeOffset(face, 1.0, 1.0E-5, BRepOffset_Skin, False, True,
                             GeomAbs_Arc, True, True).Shape()

obj.display.DisplayShape(face, color="red")
obj.display.DisplayShape(sold)
obj.export_stl(sold, linear_deflection=0.01, angular_deflection=0.01)
obj.show()