コード例 #1
0
ファイル: test_gem.py プロジェクト: naylor-b/pygem
    def test_StaticModel(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)

        newModel = gem.staticModel(myContext)
        gem.add2Model(newModel, myBReps[0])
        gem.add2Model(newModel, myBReps[0], (0.5, 0, 0, 2, 0, 0.5, 0, 0, 0, 0, 0.5, 0))

        server, filename, modeler, uptodate, myBReps, nparam, nbranch, nattr = gem.getModel(newModel)

        massProps1 = gem.getMassProps(myBReps[0], "BREP", 0)
        massProps2 = gem.getMassProps(myBReps[1], "BREP", 0)

        self.assertAlmostEqual(massProps1[0], 8 * massProps2[0])  # volume
        self.assertAlmostEqual(massProps1[1], 4 * massProps2[1])  # surface area
        self.assertAlmostEqual(massProps1[2], 2 * massProps2[2] - 4)  # xcg
        self.assertAlmostEqual(massProps1[3], 2 * massProps2[3])  # ycg
        self.assertAlmostEqual(massProps1[4], 2 * massProps2[4])  # zcg
        self.assertAlmostEqual(massProps1[5], 32 * massProps2[5])  # Ixx
        self.assertAlmostEqual(massProps1[6], 32 * massProps2[6])  # Ixy
        self.assertAlmostEqual(massProps1[7], 32 * massProps2[7])  # Ixz
        self.assertAlmostEqual(massProps1[8], 32 * massProps2[8])  # Iyx
        self.assertAlmostEqual(massProps1[9], 32 * massProps2[9])  # Iyy
        self.assertAlmostEqual(massProps1[10], 32 * massProps2[10])  # Iyz
        self.assertAlmostEqual(massProps1[11], 32 * massProps2[11])  # Izx
        self.assertAlmostEqual(massProps1[12], 32 * massProps2[12])  # Izy
        self.assertAlmostEqual(massProps1[13], 32 * massProps2[13])  # Izz

        gem.releaseModel(newModel)
        gem.releaseModel(myModel)
        gem.terminate(myContext)
コード例 #2
0
ファイル: demo_gem.py プロジェクト: Kenneth-T-Moore/pygem
    uv   = foo[1]                                 ;print ".  .  uv     --->\n", uv
    conn = foo[2]                                 ;print ".  .  conn   --->\n", conn

# plot the DRep
print "plotting myDRep..."
gem.plotDRep(myDRep);

# destroy the DRep
print "destroying myDRep"
gem.destroyDRep(myDRep)

# create a static model and add myBrep into it twice
newModel = gem.staticModel(myContext)             ;print "newModel       ->", newModel

print "adding myBRep to newModel twice"
gem.add2Model(newModel, myBRep)
gem.add2Model(newModel, myBRep, (0.5, 0, 0, 2,   0, 0.5, 0, 0,  0, 0, 0.5, 0))

foo      = gem.getModel(newModel)
server   = foo[0]                                 ;print "server         ->", server
filename = foo[1]                                 ;print "filename       ->", filename
modeler  = foo[2]                                 ;print "modeler        ->", modeler
uptodate = foo[3]                                 ;print "uptodate       ->", uptodate
myBReps  = foo[4]                                 ;print "myBReps        ->", myBReps
nparam   = foo[5]                                 ;print "nparam         ->", nparam
nbranch  = foo[6]                                 ;print "nbranch        ->", nbranch
nattr    = foo[7]

for iattr in range(1, nattr+1):
    dum    = 0                                    ;print "iattr          ->", iattr
    foo    = gem.getAttribute(newModel, "MODEL", 0, iattr)