コード例 #1
0
def test_stl_importer_happy_topology():
    r"""import iges file containing a box and test topology"""

    # binary STL
    importer = StlImporter(path_from_file(__file__, "./models_in/box_binary.stl"))
    topo = Topo(importer.shape)
    # assert len(topo.solids()) == 1
    assert len([i for i in topo.shells()]) == 1
    assert next(topo.shells()).Closed() is True  # direct method on TopoDS_Shell
    assert len([i for i in topo.faces()]) == 108
    assert len([i for i in topo.edges()]) == 162

    # ascii STL
    importer = StlImporter(path_from_file(__file__, "./models_in/box_ascii.stl"))
    topo = Topo(importer.shape)
    # assert len(topo.solids) == 1
    assert len([i for i in topo.shells()]) == 1
    assert next(topo.shells()).Closed() is True
    assert len([i for i in topo.faces()]) == 108
    assert len([i for i in topo.edges()]) == 162
コード例 #2
0
def build_curve_network(event=None):
    '''
    mimic the curve network surfacing command from rhino
    '''
    print('Importing IGES file...', end='')
    iges = IGESImporter('./curve_geom_plate.igs')
    iges.read_file()
    iges_cpd = iges.get_compound()
    print('done.')

    print('Building geomplate...', end='')
    topo = Topo(iges_cpd)
    edges_list = list(topo.edges())
    face = build_geom_plate(edges_list)
    print('done.')
    display.EraseAll()
    display.DisplayShape(edges_list)
    display.DisplayShape(face)
    display.FitAll()
    print('Cutting out of edges...')
コード例 #3
0
def build_curve_network(event=None):
    '''
    mimic the curve network surfacing command from rhino
    '''
    print('Importing IGES file...', end='')
    iges = IGESImporter('./curve_geom_plate.igs')
    iges.read_file()
    iges_cpd = iges.get_compound()
    print('done.')

    print('Building geomplate...', end='')
    topo = Topo(iges_cpd)
    edges_list = list(topo.edges())
    face = build_geom_plate(edges_list)
    print('done.')
    display.EraseAll()
    display.DisplayShape(edges_list)
    display.DisplayShape(face)
    display.FitAll()
    print('Cutting out of edges...')
コード例 #4
0
ファイル: simple.py プロジェクト: guifon1000/GreatATuin
def corners(house):
    d = {}
    iface = -1
    topo = Topo(house['volume'])
    house['boundaries'] = {'walls': [], 'windows': [], 'heats': []}
    house['faces'] = []
    for f in topo.wires():
        iface += 1
        key = 'face' + str(iface)
        print 'new_face'
        edges = []
        d[key] = []
        topof = Topo(f)
        for e in topof.edges():
            vts = Topo(e)
            print 'edge'
            edge = []
            for i, v in enumerate(vts.vertices()):
                brt = BRep_Tool()
                pnt = brt.Pnt(topods_Vertex(v))
                edge.append([pnt.X(), pnt.Y(), pnt.Z()])
            edges.append(edge)
        print len(edges)
        first_edge = edges.pop(0)
        point_array = [first_edge[0], first_edge[1]]
        print 'edges   :'
        for e in edges:
            print e
        print '-------'
        while len(edges) > 0:
            for i, e in enumerate(edges):
                if point_array[-1] in e:
                    ed = edges.pop(i)
                    print point_array[-1]
                    if ed[0] == point_array[-1]: point_array.append(ed[1])
                    elif ed[1] == point_array[-1]: point_array.append(ed[0])
                    break
        d[key] = point_array
        house['faces'].append(point_array)
    return d
コード例 #5
0
ファイル: edge.py プロジェクト: tpaviot/pythonocc-utils
        """
        sae = ShapeAnalysis_Edge()
        return sae.IsSeam(self, face)

    def is_edge_on_face(self, face):
        '''checks whether curve lies on a surface or a face
        '''
        return ShapeAnalysis_Edge().HasPCurve(self, face)

#===========================================================================
#    Curve.graphic
#===========================================================================
    def show(self):
        '''
        poles, knots, should render all slightly different.
        here's how...

        http://www.opencascade.org/org/forum/thread_1125/
        '''
        super(Edge, self).show()


if __name__ == '__main__':
    from OCC.BRepPrimAPI import BRepPrimAPI_MakeBox
    from OCCUtils.Topology import Topo
    b = BRepPrimAPI_MakeBox(10, 20, 30).Shape()
    t = Topo(b)
    ed = next(t.edges())
    my_e = Edge(ed)
    print(my_e.tolerance)
コード例 #6
0
        """
        sae = ShapeAnalysis_Edge()
        return sae.IsSeam(self, face)

    def is_edge_on_face(self, face):
        '''checks whether curve lies on a surface or a face
        '''
        return ShapeAnalysis_Edge().HasPCurve(self, face)

#===========================================================================
#    Curve.graphic
#===========================================================================
    def show(self):
        '''
        poles, knots, should render all slightly different.
        here's how...

        http://www.opencascade.org/org/forum/thread_1125/
        '''
        super(Edge, self).show()


if __name__ == '__main__':
    from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox
    from OCCUtils.Topology import Topo
    b = BRepPrimAPI_MakeBox(10, 20, 30).Shape()
    t = Topo(b)
    ed = next(t.edges())
    my_e = Edge(ed)
    print(my_e.tolerance)