示例#1
0
    def test_DRep(self):
        myContext = gem.initialize()
        gem.setAttribute(myContext, "CONTEXT", 0, "Modeler", "OpenCASCADE")
        myModel = gem.loadModel(myContext, sample_file)
        myDRep = gem.newDRep(myModel)
        gem.tesselDRep(myDRep, 0, 0, 0, 0)

        iface = 1
        triArray, xyzArray = gem.getTessel(myDRep, 1, 1)

        npnt = (xyzArray.shape)[0]
        ntri = (triArray.shape)[0]

        # make sure that triangle pointers are consistent
        for itri in range(1, ntri + 1):
            for iside in [0, 1, 2]:
                jtri = triArray[itri - 1, iside]
                if not ((jtri > 0) and (jtri <= npnt)):
                    self.fail("jtri not in (0 to %d)" % npnt)

        gem.destroyDRep(myDRep)
        gem.releaseModel(myModel)
        gem.terminate(myContext)
示例#2
0
        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

maxang = 0;
maxlen = 0;
maxsag = 0;
gem.tesselDRep(myDRep, 0, maxang, maxlen, maxsag);

# get tessellation associated with the first Face of each DRep
for ibrep in range(1, len(myBReps)+1):
    dum   = 0                                     ;print ".  ibrep       ->", ibrep
    iface = 1                                     ;print ".  .  iface    ->", iface

    foo  = gem.getTessel(myDRep, ibrep, iface)
    xyz  = foo[0]                                 ;print ".  .  xyz    --->\n", xyz
    uv   = foo[1]                                 ;print ".  .  uv     --->\n", uv
    conn = foo[2]                                 ;print ".  .  conn   --->\n", conn
示例#3
0
import numpy
from pygem_quartz import gem

# allow printing of entire arrays
numpy.set_printoptions(threshold=100)

# initialize the context, load the model, and get the first BRep
myContext = gem.initialize()
myModel   = gem.loadModel(myContext, "sample.csm")
foo       = gem.getModel(myModel)
myBRep    = foo[4][0]

# plot initial configuration
print "plotting initial configuration..."
myDRep = gem.newDRep(myModel)
gem.tesselDRep(myDRep, 0, 0, 0, 0)
gem.plotDRep(myDRep);
gem.destroyDRep(myDRep)

# "optimization" loop to vary "ymax" to drive the "volume" to a specified value
volume_target = 15
dvoldymax     =  8

for iter in range(100):
    print "---------------------"
    print "iter  =", iter

    # get current design variable
    foo  = gem.getParam(myModel, 4)
    ymax = foo[3][0]