Пример #1
0
    def test_BRep(self):
        myContext = gem.initialize()
        gem.setAttribute(myContext, "CONTEXT", 0, "Modeler", "OpenCASCADE")
        myModel = gem.loadModel(myContext, sample_file)

        server, filename, modeler, uptodate, myBReps, nparam, nbranch, nattr = gem.getModel(myModel)
        self.assertEqual(nattr, 0)

        for myBRep in myBReps:
            box, type, nnode, nedge, nloop, nface, nshell, nattr = gem.getBRepInfo(myBRep)

            # check that all nodes are in box
            for inode in range(1, nnode + 1):
                xyz, nattr = gem.getNode(myBRep, inode)
                self.assertEqual(nattr, 0)

                self.assertTrue(xyz[0] >= box[0], "x[%d] < box[0]" % inode)
                self.assertTrue(xyz[1] >= box[1], "y[%d] < box[1]" % inode)
                self.assertTrue(xyz[2] >= box[2], "z[%d] < box[2]" % inode)
                self.assertTrue(xyz[0] <= box[3], "x[%d] > box[3]" % inode)
                self.assertTrue(xyz[1] <= box[4], "y[%d] > box[4]" % inode)
                self.assertTrue(xyz[2] <= box[5], "z[%d] > box[5]" % inode)

            # check consistency of all loops
            for iloop in range(1, nloop + 1):
                iface, type, edges, nattr = gem.getLoop(myBRep, iloop)
                self.assertEqual(nattr, 0, "iloop=%d" % iloop)

                # loop and face point to each other
                ID, uvbox, norm, loops, nattr = gem.getFace(myBRep, iface)
                self.assertTrue(iloop in loops, "iloop=%d, iface=%d" % (iloop, iface))

                # edge and face point to each other
                for i in range(len(edges)):
                    tlimit, nodes, faces, nattr = gem.getEdge(myBRep, edges[i])
                    self.assertTrue(iface in faces, "iloop-%d, i=%d" % (iloop, i))

                # edges link end-to-end in loop
                tlimit, nodes, faces, nattr = gem.getEdge(myBRep, edges[0])
                iend = nodes[1]

                for i in range(1, len(edges)):
                    tlimit, nodes, faces, nattr = gem.getEdge(myBRep, edges[i])
                    self.assertEqual(iend, nodes[0], "iloop=%d, i=%d" % (iloop, i))
                    iend = nodes[1]

            # check consistency of all shells
            for ishell in range(1, nshell + 1):
                type, faces, nattr = gem.getShell(myBRep, ishell)
                self.assertEqual(nattr, 0)

        gem.releaseModel(myModel)
        gem.terminate(myContext)
Пример #2
0
    for inode in range(1, nnode+1):
        dum    = 0                                ;print ".  inode       ->", inode
        foo    = gem.getNode(myBRep, inode)
        xyz    = foo[0]                           ;print ".  .  xyz      ->", xyz
        nattr  = foo[1]

        for iattr in range(1, nattr+1):
            dum    = 0                            ;print ".  .  iattr    ->", iattr
            foo    = gem.getAttribute(myBRep, "NODE", inode, iattr)
            aname  = foo[0]                       ;print ".  .  .  aname ->", aname
            values = foo[1]                       ;print ".  .  .  values->", values

    # get information about each of the Edges
    for iedge in range(1, nedge+1):
        dum    = 0                                ;print ".  iedge       ->", iedge
        foo    = gem.getEdge(myBRep, iedge)
        tlimit = foo[0]                           ;print ".  .  tlimit   ->", tlimit
        nodes  = foo[1]                           ;print ".  .  nodes    ->", nodes
        faces  = foo[2]                           ;print ".  .  faces    ->", faces
        nattr  = foo[3]

        for iattr in range(1, nattr+1):
            dum    = 0                            ;print ".  .  iattr    ->", iattr
            foo    = gem.getAttribute(myBRep, "EDGE", iedge, iattr)
            aname  = foo[0]                       ;print ".  .  .  aname ->", aname
            values = foo[1]                       ;print ".  .  .  values->", values

    # get information about each of the Loops
    for iloop in range(1, nloop+1):
        dum    = 0                                ;print ".  iloop       ->", iloop
        foo    = gem.getLoop(myBRep, iloop)