当前位置: 首页>>代码示例>>Python>>正文


Python Topo.faces方法代码示例

本文整理汇总了Python中OCC.Utils.Topology.Topo.faces方法的典型用法代码示例。如果您正苦于以下问题:Python Topo.faces方法的具体用法?Python Topo.faces怎么用?Python Topo.faces使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OCC.Utils.Topology.Topo的用法示例。


在下文中一共展示了Topo.faces方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: offset_cube

# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import faces [as 别名]
def offset_cube(event=None):
    # smoothed
#    S1 = BRepPrimAPI_MakeBox(150,200,110).Shape()    
#    offsetA = BRepOffsetAPI_MakeOffsetShape(S1,60,0.01)    
#    display.EraseAll()
#    display.Context
#    display.DisplayColoredShape(S1, 'BLUE')
#    offA = display.DisplayColoredShape(offsetA.Shape(), 'GREEN')
#    display.Context.SetTransparency( offA, 0.3 )

    # sharp
    S2 = BRepPrimAPI_MakeBox(gp_Pnt(300,0,0),220,140,180).Shape()    
    offsetB = BRepOffsetAPI_MakeOffsetShape(S2,-20,0.01,BRepOffset_Skin,False,False,GeomAbs_Arc)    
    offB = display.DisplayColoredShape(S2, 'BLUE')
    display.Context.SetTransparency( offB, 0.3 )
    display.DisplayColoredShape(offsetB.Shape(), 'GREEN')
    
    from OCC.TCollection import TCollection_ExtendedString
    topo = Topo(S2)
    faces = topo.faces()
#    faceA, faceB = topo.faces_from_edge(topo.edges().next())
    faceA = faces.next()
    faces.next();faces.next(); faces.next()
    faceB = faces.next()
    
    dim = AIS_LengthDimension(faceA, faceB, 120, TCollection_ExtendedString('jelle'))
    dim.SetValue(30)
    display.Context.Display(dim.GetHandle())
    
    display.FitAll()
开发者ID:dbarbier,项目名称:pythonocc,代码行数:32,代码来源:topology_local_operations.py

示例2: update_naming

# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import faces [as 别名]
 def update_naming(self, make_shape):
     label = self.label
     shape = make_shape.Shape()
     
     input_shape = make_shape.Shape()
     
     builder = TNaming.TNaming_Builder(label)
     builder.Generated(input_shape, shape)
     
     #FindChild creates a new label, if one doesn't exist.
     #Label entry numbers are not necessarily incremental.
     #They are more like dictionary keys.
     gen_label = label.FindChild(1)
     mod_label = label.FindChild(2)
     del_label = label.FindChild(3)
     
     gen_builder = TNaming.TNaming_Builder(gen_label)
     mod_builder = TNaming.TNaming_Builder(mod_label)
     del_builder = TNaming.TNaming_Builder(del_label)
     
     topo = Topo(input_shape)
     
     for face in topo.faces():
         gen_shapes = make_shape.Generated(face)
         itr = TopTools.TopTools_ListIteratorOfListOfShape(gen_shapes)
         while itr.More():
             this = itr.Value()
             gen_builder.Generated(face, this)
             print "generated", face, this
             itr.Next()
                     
     for face in topo.faces():
         mod_shapes = make_shape.Modified(face)
         itr = TopTools.TopTools_ListIteratorOfListOfShape(mod_shapes)
         while itr.More():
             this = itr.Value()
             mod_builder.Modified(face, this)
             print "modified", face, this
             itr.Next()
                     
     for face in topo.faces():
         if make_shape.IsDeleted(face):
             del_builder.Delete(face)
开发者ID:mortbauer,项目名称:pythonocc,代码行数:45,代码来源:occ_model.py

示例3: test_draft_angle

# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import faces [as 别名]
 def test_draft_angle(self):
     print 'Test: draft angle'
     S = BRepPrimAPI_MakeBox(200.,300.,150.).Shape()
     adraft = BRepOffsetAPI_DraftAngle(S)
     
     topo = Topo(S)
     for f in topo.faces():
         surf = Handle_Geom_Plane_DownCast(BRep_Tool_Surface(f)).GetObject()
         dirf = surf.Pln().Axis().Direction()
         print 'direction',dirf.Coord()
         ddd = gp_Dir(0,0,1)
         if dirf.IsNormal(ddd, Precision_Angular()):
             adraft.Add(f, ddd, math.radians(15), gp_Pln(gp_Ax3(gp_XOY())))         
     adraft.Build()
     self.assertTrue(adraft.IsDone())
开发者ID:dbarbier,项目名称:pythonocc,代码行数:17,代码来源:topology_building_unittest.py

示例4: draft_angle

# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import faces [as 别名]
def draft_angle(event=None):
    S = BRepPrimAPI_MakeBox(200.,300.,150.).Shape()
    adraft = BRepOffsetAPI_DraftAngle(S)
    
    topo = Topo(S)
    for f in topo.faces():
        surf = Handle_Geom_Plane_DownCast(BRep_Tool_Surface(f)).GetObject()
        dirf = surf.Pln().Axis().Direction()
        print 'direction',dirf.Coord()
        ddd = gp_Dir(0,0,1)
        if dirf.IsNormal(ddd, Precision_Angular()):
            adraft.Add(f, ddd, math.radians(15), gp_Pln(gp_Ax3(gp_XOY())))
            
    adraft.Build()
    display.EraseAll()
    display.DisplayShape(adraft.Shape())
开发者ID:dbarbier,项目名称:pythonocc,代码行数:18,代码来源:topology_building.py

示例5: testRemovedByRefFeature

# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import faces [as 别名]
    def testRemovedByRefFeature(self):
        """ test that arguments returned by ref transormation is ok
        """
        from OCC.BRepPrimAPI import BRepPrimAPI_MakeSphere
        from OCC.BRep import BRep_Tool_Surface
        from OCC.GeomLProp import GeomLProp_SLProps
        from OCC.gp import gp_Pnt

        sphere_shape = BRepPrimAPI_MakeSphere(40.0).Shape()
        # build a surface from this sphere
        from OCC.Utils.Topology import Topo

        t = Topo(sphere_shape)
        for f in t.faces():
            face = f

        surf = BRep_Tool_Surface(face)
        lprop = GeomLProp_SLProps(0, 1e-12)
        lprop.SetSurface(surf)

        # evaluate_uv_coordinates
        coords = []
        p = 0.0
        # first point
        u, v = [0, 0]
        lprop.SetParameters(u, v)
        pnt = lprop.Value()
        print "First point coords : ", pnt.Coord()
        print surf.GetObject().Value(u, v).Coord()
        # This one is [40.0,0.,0.]
        self.assertEqual(str(pnt.Coord()), "(40.0, 0.0, 0.0)")
        coords.append(pnt)
        # second point
        u, v = [0.5, 0.5]
        lprop.SetParameters(u, v)
        pnt2 = lprop.Value()
        # check then that the value has not changed (it does if returned by ref)
        self.assertEqual(str(pnt.Coord()), "(40.0, 0.0, 0.0)")
开发者ID:jappa,项目名称:pythonocc,代码行数:40,代码来源:wrapper_features_unittest.py

示例6: Topo

# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import faces [as 别名]
                                         )

        aMesh.AddGroup( group_load.GetType(),
                        groupName,
                        group_load.GetShape()
                        )
        self.indx += 1
        return True

from OCC.KBE.Level2API import *
from OCC.Utils.Topology import Topo

# compute and sort faces by area
# use the 2 first faces on which boundary conditions will be set 
topo = Topo(aShape)
faces = [Face(i) for i in topo.faces()]

# create the groups 
# note that groups can only be created when the mesh is computed
# calling group will check if any nodes are present in the mesh
# and assumes that its computed when it finds any nodes
group =  GroupOnGeom()
group(aMesh,faces[0].face,SMDSAbs_Face,'load')
group(aMesh,faces[4].face,SMDSAbs_Face, 'lock')

#===============================================================================
# EXPORT
#===============================================================================

# Export the data
aMesh.ExportDAT("_TEST.DAT")
开发者ID:dbarbier,项目名称:pythonocc,代码行数:33,代码来源:grouping.py

示例7: BRepPrimAPI_MakeBox

# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import faces [as 别名]
    '''
    concrete visualization class, using the vtk
    '''
    raise NotImplementedError
    

#===============================================================================
# Example of usage of the future framework ---
#===============================================================================

from OCC.BRepPrimAPI import *
from OCC.gp import *

shape = BRepPrimAPI_MakeBox(1,1,1).Shape()  # stupid shape for analysis
topo = Topo(shape)                          # for traversing the topology
faces = topo.faces()                        # faces of the box  
face1 = faces.next()                        # face used for loads
face2 = faces.next()                        # face that will be locked

mesh_driver = QuadMeshDriver('nadah')       # set up the mesh driver. when geometry is updated, so will the mesh before solving it
analysis    = LinearElasticityAnalysis()    # set up the problem to be solved
solver      = AbacusSolver()                # configure the solver

FEMSimulation = FEMSimulation(shape)            
FEMSimulation.load(face1, gp_Vec())       
FEMSimulation.lock(face2, x=False, y=False, z=True)
FEMSimulation.analysis = analysis
FEMSimulation.solver = solver
FEMSimulation.mesh_driver = mesh_driver
FEMSimulation.output_dir = '/dev/null/simulation.fem'
FEMSimulation.solve()
开发者ID:NiSchultz,项目名称:pythonocc,代码行数:33,代码来源:FEM.py

示例8: TestTopology

# 需要导入模块: from OCC.Utils.Topology import Topo [as 别名]
# 或者: from OCC.Utils.Topology.Topo import faces [as 别名]
class TestTopology(unittest.TestCase):
    def setUp(self):
        self.topo = Topo(BRepPrimAPI_MakeBox(10., 10., 10).Shape())

    def test_nested_iteration(self):
        '''check nested looping'''
        for f in self.topo.faces():
            for e in self.topo.edges():
                self.assert_(isinstance(f, TopoDS_Face))
                self.assert_(isinstance(e, TopoDS_Edge))

    def test_kept_reference(self):
        '''did we keep a reference after looping several time through a list
        of topological entities?'''
        _tmp = []
        _faces = [i for i in self.topo.faces()]
        for f in _faces:
            _tmp.append(0 == f.IsNull())
        for f in _faces:
            _tmp.append(0 == f.IsNull())
        self.assert_(all(_tmp))

    def test_number_of_topological_entities(self):
        self.assert_(self.topo.number_of_vertices() == 8)
        self.assert_(self.topo.number_of_edges() == 12)
        self.assert_(self.topo.number_of_wires() == 6)
        self.assert_(self.topo.number_of_faces() == 6)
        self.assert_(self.topo.number_of_solids() == 1)
        self.assert_(self.topo.number_of_comp_solids() == 0)
        self.assert_(self.topo.number_of_compounds() == 0)

    def test_edge_face(self):
        edg = self.topo.edges().next()
        face = self.topo.faces().next()
        faces_from_edge = [i for i in self.topo.faces_from_edge(edg)]
        self.assert_(len(faces_from_edge) == self.topo.number_of_faces_from_edge(edg))
        edges_from_face = [i for i in self.topo.edges_from_face(face)]
        self.assert_(len(edges_from_face) == self.topo.number_of_edges_from_face(face))

    def test_edge_wire(self):
        edg = self.topo.edges().next()
        wire = self.topo.wires().next()
        wires_from_edge = [i for i in self.topo.wires_from_edge(edg)]
        self.assert_(len(wires_from_edge) == self.topo.number_of_wires_from_edge(edg))
        edges_from_wire = [i for i in self.topo.edges_from_wire(wire)]
        self.assert_(len(edges_from_wire) == self.topo.number_of_edges_from_wire(wire))

    def test_vertex_edge(self):
        vert = self.topo.vertices().next()
        verts_from_edge = [i for i in self.topo.vertices_from_edge(vert)]
        self.assert_(len(verts_from_edge) == self.topo.number_of_vertices_from_edge(vert))
        edges_from_vert = [ i for i in self.topo.edges_from_vertex(vert)]
        self.assert_(len(edges_from_vert) == self.topo.number_of_edges_from_vertex(vert))

    def test_vertex_face(self):
        vert = self.topo.vertices().next()
        face = self.topo.faces().next()
        faces_from_vertex = [i for i in self.topo.faces_from_vertex(vert)]
        self.assert_(len(faces_from_vertex) == self.topo.number_of_faces_from_vertex(vert))
        verts_from_face = [i for i in self.topo.vertices_from_face(face)]
        self.assert_(len(verts_from_face) == self.topo.number_of_vertices_from_face(face))

    def test_face_solid(self):
        face = self.topo.faces().next()
        solid = self.topo.solids().next()
        faces_from_solid = [i for i in self.topo.faces_from_solids(solid)]
        self.assert_(len(faces_from_solid) == self.topo.number_of_faces_from_solids(solid))
        solids_from_face = [i for i in self.topo.solids_from_face(face)]
        self.assert_(len(solids_from_face) == self.topo.number_of_solids_from_face(face))

    def test_wire_face(self):
        wire = self.topo.wires().next()
        face = self.topo.faces().next()
        faces_from_wire = [i for i in self.topo.faces_from_wire(wire)]
        self.assert_(len(faces_from_wire) == self.topo.number_of_faces_from_wires(wire))
        wires_from_face = [i for i in self.topo.wires_from_face(face)]
        self.assert_(len(wires_from_face) == self.topo.number_of_wires_from_face(face))

    def test_edges_out_of_scope(self):
        face = self.topo.faces().next()
        _edges = []
        for edg in Topo(face).edges():
            _edges.append(edg)
        for edg in _edges:
            self.assert_(edg.IsNull() == False)

    def test_wires_out_of_scope(self):
        face = self.topo.wires().next()
        _edges = []
        for edg in WireExplorer(face).ordered_edges():
            _edges.append(edg)
        for edg in _edges:
            self.assert_(edg.IsNull() == False)
开发者ID:imclab,项目名称:pythonocc,代码行数:95,代码来源:topology_unittest.py


注:本文中的OCC.Utils.Topology.Topo.faces方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。