Esempio n. 1
0
    def display_assembly(self, assembly, transparency=0.):
        r"""Display an assembly of parts and assemblies

        Parameters
        ----------
        assembly : AssemblyGeometryNode
        transparency : float from 0 to 1

        """
        assembly.build()

        for i, node in enumerate(assembly.nodes()):

            # display a sphere at the barycentre
            from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeSphere
            sphere = BRepPrimAPI_MakeSphere(
                _centre_of_mass(node.node_shape.shape),
                _characteristic_dimension(node.node_shape.shape) / 10.)
            sphere.Build()
            self.display_shape(
                sphere.Shape(),
                # color_=colour_wx_to_occ((randint(0, 255),
                #                          randint(0, 255),
                #                          randint(0, 255))),
                color_=colour_wx_to_occ(color_from_sequence(i, "colors")),
                transparency=transparency)

            # self._display_anchors(assembly.anchors)

        for edge in assembly.edges(data=True):
            start = _centre_of_mass(edge[0].node_shape.shape)  # gp_Pnt
            end = _centre_of_mass(edge[1].node_shape.shape)  # gp_Pnt

            vec = gp_Vec(end.X() - start.X(),
                         end.Y() - start.Y(),
                         end.Z() - start.Z())
            from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeEdge
            e = BRepBuilderAPI_MakeEdge(start, end)

            self.display_shape(e.Shape())

            edge_constraint = assembly.get_edge_data(edge[0],
                                                     edge[1])["object"]

            self.display_message(
                gp_Pnt((start.X() + 2 * end.X()) / 3,
                       (start.Y() + 2 * end.Y()) / 3,
                       (start.Z() + 2 * end.Z()) / 3),
                text_to_write=edge_constraint.__class__.__name__,
                height=13,
                message_color=(0, 0, 0))  # black
        self.viewer_display.FitAll()
Esempio n. 2
0
def test_step_exporter_overwrite(box_shape):
    r"""Happy path with a subclass of TopoDS_Shape"""
    filename = path_from_file(__file__, "./models_out/box.stp")
    exporter = StepExporter(filename)
    solid = shape_to_topology(box_shape)
    assert isinstance(solid, TopoDS_Solid)
    exporter.add_shape(solid)
    exporter.write_file()
    initial_timestamp = os.path.getmtime(filename)
    assert os.path.isfile(filename)

    # read the written box.stp
    importer = StepImporter(filename)
    topo_compound = Topo(importer.compound, return_iter=False)
    assert topo_compound.number_of_faces == 6
    assert len(topo_compound.faces) == 6
    assert topo_compound.number_of_edges == 12

    # add a sphere and write again with same exporter
    sphere = BRepPrimAPI_MakeSphere(10)
    exporter.add_shape(sphere.Shape())
    exporter.write_file()  # this creates a file with a box and a sphere
    intermediate_timestamp = os.path.getmtime(filename)
    assert intermediate_timestamp > initial_timestamp

    # check that the file contains the box and the sphere
    importer = StepImporter(filename)

    # 6 from box + 1 from sphere
    assert len(Topo(importer.compound, return_iter=False).faces) == 7

    assert len(Topo(importer.compound, return_iter=False).solids) == 2

    # create a new exporter and overwrite with a box only
    filename = path_from_file(__file__, "./models_out/box.stp")
    exporter = StepExporter(filename)
    solid = shape_to_topology(box_shape)
    exporter.add_shape(solid)
    exporter.write_file()
    assert os.path.isfile(filename)
    last_timestamp = os.path.getmtime(filename)
    assert last_timestamp > intermediate_timestamp

    # check the file only contains a box
    importer = StepImporter(filename)

    # 6 from box
    assert len(Topo(importer.compound, return_iter=False).faces) == 6

    assert len(Topo(importer.compound, return_iter=False).solids) == 1
Esempio n. 3
0
    def testShape():

        sp1 = BRepPrimAPI_MakeSphere(3).Shape()
        ScShape(sp1, 'stGold')

        sp2 = BRepPrimAPI_MakeSphere(4).Shape()
        ScShape(sp2, 'stFog')

        stCustom1 = ScStyle((100, 35, 24, 100, 3, 3, 'GOLD'))
        sp3 = BRepPrimAPI_MakeSphere(gp_Pnt(3, 6, 2), 2.5).Shape()
        ScShape(sp3, stCustom1)

        stCustom2 = ScStyle((98, 100, 12, 100, 3, 3, 'CHROME'))
        sp4 = BRepPrimAPI_MakeSphere(gp_Pnt(3, 3, 3), 2).Shape()
        ScShape(sp4, stCustom2)
 def dbgSphere(self, pt):
     """
     TODO : know why sphere is appended to the model, if no reason than remove sphere from all the cad files (by Anand Swaroop)
     :param pt: pt of origin for the nut bol placement
     :return: returns the sphere
     """
     return BRepPrimAPI_MakeSphere(getGpPt(pt), 0.1).Shape()
Esempio n. 5
0
def slicer(event=None):
    # Param
    Zmin, Zmax, deltaZ = -100, 100, 5
    # Note: the shape can also come from a shape selected from InteractiveViewer
    if 'display' in dir():
        shape = display.GetSelectedShape()
    else:
        # Create the shape to slice
        shape = BRepPrimAPI_MakeSphere(60.).Shape()
    # Define the direction
    D = gp_Dir(0., 0., 1.)  # the z direction
    # Perform slice
    sections = []
    init_time = time.time()  # for total time computation
    for z in range(Zmin, Zmax, deltaZ):
        # Create Plane defined by a point and the perpendicular direction
        P = gp_Pnt(0, 0, z)
        Pln = gp_Pln(P, D)
        face = BRepBuilderAPI_MakeFace(Pln).Shape()
        # Computes Shape/Plane intersection
        section_shp = BRepAlgoAPI_Section(shape, face)
        if section_shp.IsDone():
            sections.append(section_shp)
    total_time = time.time() - init_time
    print("%.3fs necessary to perform slice." % total_time)

    display.EraseAll()
    display.DisplayShape(shape)
    for section_ in sections:
        display.DisplayShape(section_.Shape())
    display.FitAll()
Esempio n. 6
0
    def getDaoCaseSurface(self):

        r = self.aBaseRadius
        r2 = r * 2
        h = self.aCaseHeight
        h2 = h / 2
        offset = self.aOffset
        gap = self.aCaseGap
        rTop = r + offset + gap

        rSphere = gp_Vec(0, rTop, h2).Magnitude()
        sphere = BRepPrimAPI_MakeSphere(rSphere).Shape()

        limit = BRepPrimAPI_MakeBox(gp_Pnt(-r2, -r2, -h2), gp_Pnt(r2, r2, h2)).Shape()
        step01Surface = BRepAlgoAPI_Common(sphere, limit).Shape()

        step02Surface = getShapeTranslate(step01Surface, 0, 0, -h2)

        cutIngSurface = self.getCached('getDaoIngSurface', offset - gap)
        cutYangSurface = self.getCached('getDaoYangSurface', offset - gap)
        step03Surface = BRepAlgoAPI_Cut(step02Surface, cutIngSurface).Shape()
        step04Surface = BRepAlgoAPI_Cut(step03Surface, cutYangSurface).Shape()

        step05Surface = getShapeTranslate(step04Surface, 0, 0, -h2)

        return step05Surface
Esempio n. 7
0
 def test_export_to_x3d(self):
     """ 3rd test : export a sphere to X3D file format """
     a_sphere = BRepPrimAPI_MakeSphere(10.).Shape()
     tess = Tesselator(a_sphere)
     tess.Compute()
     tess.ExportShapeToX3D(os.path.join("test_io", "sphere.x3d"))
     self.assertTrue(os.path.exists(os.path.join("test_io", "sphere.x3d")))
Esempio n. 8
0
 def test_mesh_sphere_quadrangle(self):
     aShape = BRepPrimAPI_MakeSphere(10.).Shape()
     # Create the Mesh
     aMeshGen = SMESH_Gen()
     aMesh = aMeshGen.CreateMesh(0, True)
     # 1D
     an1DHypothesis = StdMeshers_Arithmetic1D(
         0, 0, aMeshGen)  #discretization of the wire
     an1DHypothesis.SetLength(
         0.1, False)  #the smallest distance between 2 points
     an1DHypothesis.SetLength(0.5,
                              True)  # the longest distance between 2 points
     an1DAlgo = StdMeshers_Regular_1D(1, 0, aMeshGen)  # interpolation
     # 2D
     a2dHypothseis = StdMeshers_TrianglePreference(
         2, 0, aMeshGen)  #define the boundary
     a2dAlgo = StdMeshers_Quadrangle_2D(3, 0, aMeshGen)  # the 2D mesh
     #Calculate mesh
     aMesh.ShapeToMesh(aShape)
     #Assign hyptothesis to mesh
     aMesh.AddHypothesis(aShape, 0)
     aMesh.AddHypothesis(aShape, 1)
     aMesh.AddHypothesis(aShape, 2)
     aMesh.AddHypothesis(aShape, 3)
     #Compute the data
     aMeshGen.Compute(aMesh, aMesh.GetShapeToMesh())
Esempio n. 9
0
 def test_creat_face(self):
     # create a box
     my_face = Face(BRepPrimAPI_MakeSphere(1., 1.).Face())
     assert not my_face.IsNull()
     assert my_face.tolerance == 1e-06
     assert not my_face.is_planar()
     assert my_face.is_trimmed()
Esempio n. 10
0
def New_shp(Xmax, Xmin, Ymax, Ymin, Zmax, Zmin, X, Y, Z):
    Index = random.randint(1, 4)
    position = cal_position(Xmax, Xmin, Ymax, Ymin, Zmax, Zmin)
    A = (X + Y + Z) / 5
    if Index == 1:
        X1 = random.uniform(0.5 * A, A)
        Y1 = random.uniform(0.5 * A, A)
        Z1 = random.uniform(0.5 * A, A)
        nshp = BRepPrimAPI_MakeBox(
            gp_Pnt(-0.5 * X1 + position[0], -0.5 * Y1 + position[1],
                   -0.5 * Z1 + position[2]), X1, Y1, Z1).Shape()
    if Index == 2:

        R = random.uniform(0.25 * A, 0.5 * A)
        nshp = BRepPrimAPI_MakeSphere(
            gp_Pnt(position[0], position[1], position[2]), R).Shape()
    if Index == 3:
        R2 = random.uniform(0.25 * A, 0.5 * A)
        H = random.uniform(0.5 * A, A)
        origin = gp_Ax2(
            gp_Pnt(position[0], position[1], -0.5 * H + position[2]),
            gp_Dir(0.0, 0.0, 1.0))
        nshp = BRepPrimAPI_MakeCone(origin, R2, 0, H).Shape()
    if Index == 4:

        R = random.uniform(0.25 * A, 0.5 * A)
        H = random.uniform(0.5 * A, A)
        cylinder_origin = gp_Ax2(
            gp_Pnt(position[0], position[1], -0.5 * H + position[2]),
            gp_Dir(0.0, 0.0, 1.0))
        nshp = BRepPrimAPI_MakeCylinder(cylinder_origin, R, H).Shape()
    return nshp
Esempio n. 11
0
def gen_ellipsoid(axs=gp_Ax3(), rxyz=[10, 20, 30]):
    sphere = BRepPrimAPI_MakeSphere(gp_Ax2(), 1).Solid()
    loc = set_loc(gp_Ax3(), axs)
    mat = gp_Mat(rxyz[0], 0, 0, 0, rxyz[1], 0, 0, 0, rxyz[2])
    gtrf = gp_GTrsf(mat, gp_XYZ(0, 0, 0))
    ellips = BRepBuilderAPI_GTransform(sphere, gtrf).Shape()
    ellips.Location(loc)
    return ellips
def generate_shape():
    """Create a sphere with faces top and bottom"""
    sphere_radius = 1.0
    sphere_angle = atan(0.5)
    sphere_origin = gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(0, 0, 1))
    sphere = BRepPrimAPI_MakeSphere(sphere_origin, sphere_radius,
                                    -sphere_angle, sphere_angle).Shape()
    return sphere
Esempio n. 13
0
def getDaoCase(r, offset, h):
    r2 = r*2
    h2 = h/2
    rTop = r + offset
    rSphere = gp_Vec(0,rTop,h2).Magnitude()
    sphere = BRepPrimAPI_MakeSphere(rSphere).Shape()
    limit = BRepPrimAPI_MakeBox( gp_Pnt(-r2, -r2, -h2), gp_Pnt(r2, r2, h2) ).Shape()
    case = BRepAlgoAPI_Common(sphere, limit).Shape()
    case = getShapeTranslate(case, 0,0,-h2)
    return case
Esempio n. 14
0
class SphereByRadius(object):
    """
    Create a sphere by a center and radius.

    :param point_like origin: The origin.
    :param float radius: The radius.
    """
    def __init__(self, origin=(0., 0., 0.), radius=1.):
        origin = CheckGeom.to_point(origin)

        self._builder = BRepPrimAPI_MakeSphere(origin, radius)

    @property
    def face(self):
        """
        :return: The sphere as a face.
        :rtype: afem.topology.entities.Face
        """
        return Face(self._builder.Face())

    @property
    def shell(self):
        """
        :return: The sphere as a shell.
        :rtype: afem.topology.entities.Shell
        """
        return Shell(self._builder.Shell())

    @property
    def solid(self):
        """
        :return: The sphere as a solid.
        :rtype: afem.topology.entities.Face
        """
        return Solid(self._builder.Solid())

    @property
    def sphere(self):
        """
        :return: The sphere primitive.
        :rtype: OCC.Core.BRepPrim.BRepPrim_Sphere
        """
        return self._builder.Sphere()
Esempio n. 15
0
def cut(event=None):
    # Create Box
    Box = BRepPrimAPI_MakeBox(200, 60, 60).Shape()
    # Create Sphere
    Sphere = BRepPrimAPI_MakeSphere(gp_Pnt(100, 20, 20), 80).Shape()
    # Cut: the shere is cut 'by' the box
    Cut = BRepAlgoAPI_Cut(Sphere, Box).Shape()
    display.EraseAll()
    ais_box = display.DisplayShape(Box)
    display.Context.SetTransparency(ais_box, 0.8, True)
    display.DisplayShape(Cut)
    display.FitAll()
Esempio n. 16
0
def cut(event=None):
    # Create Box
    Box = BRepPrimAPI_MakeBox(200, 60, 60).Shape()
    # Create Sphere
    Sphere = BRepPrimAPI_MakeSphere(gp_Pnt(100, 20, 20), 80).Shape()
    # Cut: the shere is cut 'by' the box
    Cut = BRepAlgoAPI_Cut(Sphere, Box).Shape()
    
    rnd = JupyterRenderer()
    rnd.DisplayShape(Box, transparency = True, opacity =0.2)
    rnd.DisplayShape(Cut, render_edges=True)
    rnd.Display()
Esempio n. 17
0
 def test_measure_shape_volume(self):
     # first the colume of a box a,b,c should be a*b*c
     a = 10.
     b = 23.
     c = 98.1
     box = BRepPrimAPI_MakeBox(a, b, c).Shape()
     box_volume = measure_shape_volume(box)
     self.assertAlmostEqual(box_volume, a * b * c, places=6)
     # for a sphere of radius r, it should be 4/3.pi.r^3
     r = 9.8775  # a random radius
     sph = BRepPrimAPI_MakeSphere(r).Shape()
     sph_volume = measure_shape_volume(sph)
     self.assertAlmostEqual(sph_volume, 4. / 3. * math.pi * r**3, places=6)
Esempio n. 18
0
def test_stl_exporter_overwrite(box_shape):
    r"""Happy path with a subclass of TopoDS_Shape"""
    filename = path_from_file(__file__, "./models_out/box.stl")
    exporter = StlExporter(filename)
    solid = shape_to_topology(box_shape)
    assert isinstance(solid, TopoDS_Solid)
    exporter.set_shape(solid)
    exporter.write_file()
    assert os.path.isfile(filename)

    # read the written box.stl
    importer = StlImporter(filename)
    topo = Topo(importer.shape)
    assert topo.number_of_shells == 1

    # set a sphere and write again with same exporter
    sphere = BRepPrimAPI_MakeSphere(10)
    exporter.set_shape(sphere.Shape())

    # this creates a file with a sphere only, this is STL specific
    exporter.write_file()

    # check that the file contains the sphere only
    importer = StlImporter(filename)
    topo = Topo(importer.shape)
    assert topo.number_of_shells == 1

    # create a new exporter and overwrite with a box only
    filename = path_from_file(__file__, "./models_out/box.stl")
    exporter = StlExporter(filename)
    solid = shape_to_topology(box_shape)
    exporter.set_shape(solid)
    exporter.write_file()
    assert os.path.isfile(filename)

    # check the file only contains a box
    importer = StlImporter(filename)
    topo = Topo(importer.shape)
    assert topo.number_of_shells == 1
Esempio n. 19
0
def make_sphere(pnt, radius):
    """
    Create a sphere using coordinates (x,y,z) and radius.

    :param pnt: Point
    :param radius: Radius
    """
    from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeSphere
    from OCC.Core.gp import gp_Pnt

    aPnt1 = gp_Pnt(float(pnt[0]), float(pnt[1]), float(pnt[2]))
    Sphere = BRepPrimAPI_MakeSphere(aPnt1, radius).Shape()
    return Sphere
 def test_measure_shape_center_of_gravity(self):
     # we compute the cog of a sphere centered at a point P
     # then the cog must be P
     x, y, z = 10.0, 3.0, -2.44  # random values for point P
     radius = 20.0
     vector = gp_Vec(x, y, z)
     sph = translate_shp(BRepPrimAPI_MakeSphere(radius).Shape(), vector)
     cog, mass, mass_property = measure_shape_mass_center_of_gravity(sph)
     self.assertAlmostEqual(cog.X(), x, places=6)
     self.assertAlmostEqual(cog.Y(), y, places=6)
     self.assertAlmostEqual(cog.Z(), z, places=6)
     self.assertAlmostEqual(mass, 4 / 3 * math.pi * radius**3, places=6)
     self.assertEqual(mass_property, "Volume")
Esempio n. 21
0
def test_iges_exporter_overwrite(box_shape):
    r"""Happy path with a subclass of TopoDS_Shape"""
    filename = path_from_file(__file__, "./models_out/box.igs")
    exporter = IgesExporter(filename)
    solid = shape_to_topology(box_shape)
    assert isinstance(solid, TopoDS_Solid)
    exporter.add_shape(solid)
    exporter.write_file()
    assert os.path.isfile(filename)

    # read the written box.igs
    importer = IgesImporter(filename)
    topo_compound = Topo(importer.compound)
    assert topo_compound.number_of_faces == 6
    assert topo_compound.number_of_edges == 24

    # add a sphere and write again with same exporter
    sphere = BRepPrimAPI_MakeSphere(10)
    exporter.add_shape(sphere.Shape())
    exporter.write_file()  # this creates a file with a box and a sphere

    # check that the file contains the box and the sphere
    importer = IgesImporter(filename)
    topo_compound = Topo(importer.compound)
    assert topo_compound.number_of_faces == 7  # 6 from box + 1 from sphere

    # create a new exporter and overwrite with a box only
    filename = path_from_file(__file__, "./models_out/box.igs")
    exporter = IgesExporter(filename)
    solid = shape_to_topology(box_shape)
    exporter.add_shape(solid)
    exporter.write_file()
    assert os.path.isfile(filename)

    # check the file only contains a box
    importer = IgesImporter(filename)
    topo_compound = Topo(importer.compound)
    assert topo_compound.number_of_faces == 6  # 6 from box
 def test_DumpJsonToString(self):
     """ Since opencascade 7x, some objects can be serialized to json
     """
     # create a sphere with a radius of 10.
     sph= BRepPrimAPI_MakeSphere(10.).Shape()
     # compute the Bnd box for this sphere
     bnd_box = Bnd_Box()
     brepbndlib_Add(sph, bnd_box)
     # check the result
     corner_min = bnd_box.CornerMin()
     self.assertEqual([round(corner_min.X(), 3), round(corner_min.Y(), 3), round(corner_min.Z(), 3)],
                      [-10., -10., -10.])
     # check dump json is working
     json_string = bnd_box.DumpJsonToString()
     expected_output = '"Bnd_Box": {"CornerMin": [-10, -10, -10], "CornerMax": [10, 10, 10], "Gap": 1e-07, "Flags": 0}'
     self.assertEqual(json_string, expected_output)
Esempio n. 23
0
    def from_sphere(cls, sphere: compas.geometry.Sphere) -> 'BRep':
        """Construct a BRep from a COMPAS sphere.

        Parameters
        ----------
        sphere : :class:`~compas.geometry.Sphere`

        Returns
        -------
        :class:`~compas_occ.brep.BRep`

        """
        brep = BRep()
        brep.shape = BRepPrimAPI_MakeSphere(gp_Pnt(*sphere.point),
                                            sphere.radius).Shape()
        return brep
 def test_DumpJsonToString(self) -> None:
     """ Since opencascade 7x, some objects can be serialized to json
     """
     # create a sphere with a radius of 10.
     sph = BRepPrimAPI_MakeSphere(10.).Shape()
     # compute the Bnd box for this sphere
     bnd_box = Bnd_Box()
     brepbndlib_Add(sph, bnd_box)
     # check the result
     corner_min = bnd_box.CornerMin()
     self.assertEqual([round(corner_min.X(), 3), round(corner_min.Y(), 3), round(corner_min.Z(), 3)],
                      [-10., -10., -10.])
     # check dump json export is working
     json_string = bnd_box.DumpJsonToString()
     # try to load the output string
     json_imported_dict = json.loads("{" + json_string + "}")
     self.assertTrue(len(json_imported_dict) > 0)  # at least one entry
Esempio n. 25
0
def section(event=None):
    torus = BRepPrimAPI_MakeTorus(120, 20).Shape()
    radius = 120.0
    sections = []
    for i in range(-3, 4):
        # Create Sphere
        sphere = BRepPrimAPI_MakeSphere(gp_Pnt(26 * 3 * i, 0, 0), radius).Shape()
        # Computes Torus/Sphere section
        section_shp = BRepAlgoAPI_Section(torus, sphere, False)
        section_shp.ComputePCurveOn1(True)
        section_shp.Approximation(True)
        section_shp.Build()
        sections.append(section_shp)

    rnd = JupyterRenderer()
    rnd.DisplayShape(torus)
    rnd.Display()
Esempio n. 26
0
def getDaoCase(r, bevel, decor, h):
    r2 = r * 2
    h2 = h / 2
    rTop = r + 2 * bevel + decor
    rSphere = gp_Vec(0, rTop, h2).Magnitude()
    sphere = BRepPrimAPI_MakeSphere(rSphere).Shape()
    limit = BRepPrimAPI_MakeBox(gp_Pnt(-r2, -r2, -h2), gp_Pnt(r2, r2,
                                                              h2)).Shape()
    case = BRepAlgoAPI_Common(sphere, limit).Shape()
    case = getShapeTranslate(case, 0, 0, -h2)
    cylOut = BRepPrimAPI_MakeCylinder(r + bevel + decor, decor * 2).Shape()
    #SceneDrawShape('out',cylOut)
    cylIn = BRepPrimAPI_MakeCylinder(r + bevel, decor * 3).Shape()
    #SceneDrawShape('in',cylIn)
    bevelTool = BRepAlgoAPI_Cut(cylOut, cylIn).Shape()
    bevelTool = getShapeTranslate(bevelTool, 0, 0, -bevel / 2)
    #SceneDrawShape('tool',bevelTool)
    case = BRepAlgoAPI_Cut(case, bevelTool).Shape()
    return case
Esempio n. 27
0
def simple_mesh():
    #
    # Create the shape
    #
    theBox = BRepPrimAPI_MakeBox(200, 60, 60).Shape()
    theSphere = BRepPrimAPI_MakeSphere(gp_Pnt(100, 20, 20), 80).Shape()
    shape = BRepAlgoAPI_Fuse(theSphere, theBox).Shape()
    #
    # Mesh the shape
    #
    BRepMesh_IncrementalMesh(shape, 0.8)
    builder = BRep_Builder()
    comp = TopoDS_Compound()
    builder.MakeCompound(comp)

    bt = BRep_Tool()
    ex = TopExp_Explorer(shape, TopAbs_FACE)
    while ex.More():
        face = topods_Face(ex.Current())
        location = TopLoc_Location()
        facing = (bt.Triangulation(face, location)).GetObject()
        tab = facing.Nodes()
        tri = facing.Triangles()
        for i in range(1, facing.NbTriangles() + 1):
            trian = tri.Value(i)
            index1, index2, index3 = trian.Get()
            for j in range(1, 4):
                if j == 1:
                    m = index1
                    n = index2
                elif j == 2:
                    n = index3
                elif j == 3:
                    m = index2
                me = BRepBuilderAPI_MakeEdge(tab.Value(m), tab.Value(n))
                if me.IsDone():
                    builder.Add(comp, me.Edge())
        ex.Next()
    display.EraseAll()
    display.DisplayShape(shape)
    display.DisplayShape(comp, update=True)
Esempio n. 28
0
        if hasattr(edg, 'adaptor'):
            return self.project_curve(self, self.adaptor)
        return self.project_curve(self, to_adaptor_3d(edg))

    def iso_curve(self, u_or_v, param):
        """
        get the iso curve from a u,v + parameter
        :param u_or_v:
        :param param:
        :return:
        """
        uv = 0 if u_or_v == 'u' else 1
        iso = Adaptor3d_IsoCurve(self.adaptor_handle.GetHandle(), uv, param)
        return iso

    def edges(self):
        return [Edge(i) for i in WireExplorer(next(self.topo.wires())).ordered_edges()]

    def __repr__(self):
        return self.name

    def __str__(self):
        return self.__repr__()

if __name__ == "__main__":
    from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeSphere
    sph = BRepPrimAPI_MakeSphere(1, 1).Face()
    fc = Face(sph)
    print(fc.is_trimmed())
    print(fc.is_planar())
Esempio n. 29
0
 def dbgSphere(self, pt):
     return BRepPrimAPI_MakeSphere(getGpPt(pt), 0.1).Shape()
 def make_sphere(centre, radius):
     pnt = gp_Pnt(*list(centre))
     sphere = BRepPrimAPI_MakeSphere(pnt, radius).Shape()
     return sphere