Ejemplo 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)
Ejemplo n.º 2
0
    volume = foo[ 0]                              ;print ".  volume      ->", volume
    area   = foo[ 1]                              ;print ".  area        ->", area
    xcg    = foo[ 2]                              ;print ".  xcg         ->", xcg
    ycg    = foo[ 3]                              ;print ".  ycg         ->", ycg
    zcg    = foo[ 4]                              ;print ".  zcg         ->", zcg
    Ixx    = foo[ 5]                              ;print ".  Ixx         ->", Ixx
    Ixy    = foo[ 6]                              ;print ".  Ixy         ->", Ixy
    Ixz    = foo[ 7]                              ;print ".  Ixz         ->", Ixz
    Iyx    = foo[ 8]                              ;print ".  Iyx         ->", Iyx
    Iyy    = foo[ 9]                              ;print ".  Iyy         ->", Iyy
    Iyz    = foo[10]                              ;print ".  Iyz         ->", Iyz
    Izx    = foo[11]                              ;print ".  Izx         ->", Izx
    Izy    = foo[12]                              ;print ".  Izy         ->", Izy
    Izz    = foo[13]                              ;print ".  Izz         ->", Izz

    foo    = gem.getBRepInfo(myBRep)
    box    = foo[0]                               ;print ".  box         ->", box
    type   = foo[1]                               ;print ".  type        ->", type
    nnode  = foo[2]                               ;print ".  nnode       ->", nnode
    nedge  = foo[3]                               ;print ".  nedge       ->", nedge
    nloop  = foo[4]                               ;print ".  nloop       ->", nloop
    nface  = foo[5]                               ;print ".  nface       ->", nface
    nshell = foo[6]                               ;print ".  nshell      ->", nshell
    nattr  = foo[7]

    # get information about each of the Attrs
    for iattr in range(1, nattr+1):
        dum    = 0                                ;print ".  iattr       ->", iattr
        foo    = gem.getAttribute(myBRep, "BREP", 0, iattr)
        aname  = foo[0]                           ;print ".  .  aname    ->", aname
        values = foo[1]                           ;print ".  .  values   ->", values