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)
foo = gem.getLoop(myBRep, iloop) face = foo[0] ;print ". . face ->", face type = foo[1] ;print ". . type ->", type edges = foo[2] ;print ". . edges ->", edges nattr = foo[3] for iattr in range(1, nattr+1): dum = 0 ;print ". . iattr ->", iattr foo = gem.getAttribute(myBRep, "LOOP", iloop, iattr) aname = foo[0] ;print ". . . aname ->", aname values = foo[1] ;print ". . . values->", values # get information about each of the Faces for iface in range(1, nface+1): dum = 0 ;print ". iface ->", iface foo = gem.getFace(myBRep, iface) ID = foo[0] ;print ". . ID ->", ID uvbox = foo[1] ;print ". . uvbox ->", uvbox norm = foo[2] ;print ". . norm ->", norm 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