Exemple #1
0
import logging

logging.getLogger('matplotlib').setLevel(logging.ERROR)

from OCC.Core.gp import gp_Pnt, gp_Vec, gp_Dir
from OCC.Core.gp import gp_Ax1, gp_Ax2, gp_Ax3
from OCC.Core.TopoDS import TopoDS_Shape, TopoDS_Compound
from OCC.Core.TopLoc import TopLoc_Location
from OCCUtils.Topology import Topo
from OCCUtils.Construct import make_box, make_line, make_wire, make_edge
from OCCUtils.Construct import make_plane, make_polygon
from OCCUtils.Construct import point_to_vector, vector_to_point
from OCCUtils.Construct import dir_to_vec, vec_to_dir

if __name__ == '__main__':
    argvs = sys.argv
    parser = OptionParser()
    parser.add_option("--dir", dest="dir", default="./")
    parser.add_option("--pxyz",
                      dest="pxyz",
                      default=[0.0, 0.0, 0.0],
                      type="float",
                      nargs=3)
    opt, argc = parser.parse_args(argvs)
    print(opt, argc)

    obj = dispocc(touch=False, disp=False)
    sph = obj.make_torus()
    obj.export_stp(sph)
Exemple #2
0
from OCC.Core.gp import gp_Elips, gp_Elips2d
from OCC.Core.gp import gp_Mat
from OCC.Core.BRep import BRep_Tool_PolygonOnTriangulation
from OCC.Core.BRepAlgoAPI import BRepAlgoAPI_Algo
from OCC.Core.Graphic3d import Graphic3d_ArrayOfPoints
from OCC.Core.AIS import AIS_PointCloud
from OCC.Core.Bnd import Bnd_Box, Bnd_Array1OfSphere


if __name__ == "__main__":
    argvs = sys.argv
    parser = argparse.ArgumentParser()
    opt = parser.parse_args()
    print(opt, argvs)

    obj = dispocc()
    obj.display.DisplayShape(gp_Pnt())

    num = 100000
    pnt_3d = Graphic3d_ArrayOfPoints(num)
    for idx in range(num):
        x = random.uniform(-0.5, 0.5)
        y = random.uniform(-0.5, 0.5)
        z = random.uniform(-0.5, 0.5)
        r = np.sqrt(x**2 + y**2 + z**2)
        ratio = random.uniform(0, 100)
        pnt_3d.AddVertex(x / r * ratio, y / r * ratio, z / r * ratio)

    point_cloud = AIS_PointCloud()
    point_cloud.SetPoints(pnt_3d)
    box = point_cloud.GetBoundingBox()
Exemple #3
0
from OCCUtils.Construct import point_to_vector, vector_to_point
from OCCUtils.Construct import dir_to_vec, vec_to_dir

if __name__ == '__main__':
    argvs = sys.argv
    parser = argparse.ArgumentParser()
    parser.add_argument("--dir", dest="dir", default="./")
    parser.add_argument("--pxyz",
                        dest="pxyz",
                        default=[0.0, 0.0, 0.0],
                        type=float,
                        nargs=3)
    opt = parser.parse_args()
    print(opt, argvs)

    obj = dispocc(touch=True)
    axs = gp_Ax3(gp_Pnt(100, -100, 200), gp_Dir(0, 0.5, 1.0),
                 gp_Dir(0.5, 1.0, 0))
    qp = gp_Quaternion()
    qp.SetRotation(gp_Vec(0, 0, 100), gp_Vec(50, 0, 0))
    print(qp)
    obj.show_axs_pln(axs, scale=50, name="axs0")

    trf = gp_Trsf()
    trf.SetTransformation(qp, gp_Vec(0, 0, 1))
    ax1 = axs.Transformed(trf)
    obj.show_axs_pln(ax1, scale=50, name="axs1")

    ax2 = obj.prop_axs(ax1, scale=50)
    obj.show_axs_pln(ax2, scale=50, name="axs2")