Exemplo n.º 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)
Exemplo n.º 2
0
        loops  = foo[3]                           ;print ".  .  loops    ->", loops
        nattr  = foo[4]

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

        foo    = gem.getMassProps(myBRep, "FACE", iface)
        area   = foo[ 1]                          ;print ".  .  area     ->", area

    # get information about each of the Shells
    for ishell in range(1, nshell+1):
        dum    = 0                                ;print ".  ishell      ->", ishell
        foo    = gem.getShell(myBRep, ishell)
        type   = foo[0]                           ;print ".  .  type     ->", type
        faces  = foo[1]                           ;print ".  .  faces    ->", faces
        nattr  = foo[2]

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

        foo    = gem.getMassProps(myBRep, "SHELL", ishell)
        area   = foo[ 1]                          ;print ".  .  area     ->", area

# set up a DRep for myModel
myDRep = gem.newDRep(myModel)                     ;print "myDRep         ->", myDRep