GraphicsDataTest.py

You can view and download this file on Github: GraphicsDataTest.py

 1#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2# This is an EXUDYN example
 3#
 4# Details:  Builds an `ObjectGround` carrying graphics data - a textured background and a rigid body
 5#           assembled from primitives - and checks it without drawing anything. This test can only
 6#           crash, not disagree, so its result is 0 by construction.
 7#
 8# Author:   Johannes Gerstmayr
 9# Date:     2019-11-01, reworked 2026-09-24
10#
11# Copyright:This file is part of Exudyn. Exudyn is free software. You can redistribute it and/or modify it under the terms of the Exudyn license. See 'LICENSE.txt' for more details.
12#
13#+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
14
15import exudyn as exu
16from exudyn.utilities import * #includes itemInterface and rigidBodyUtilities
17import exudyn.graphics as graphics
18
19testIsActive = exu.sys.get('testIsActive', False)
20exu.sys['testTolerance'] = 4e-13 #the tolerance RunAllModelUnitTests used for these ten
21
22SC = exu.SystemContainer()
23mbs = SC.AddSystem()
24
25rect = [-2.5,-2,2.5,1] #xmin,ymin,xmax,ymax
26background0 = {'type':'Line', 'color':[0.1,0.1,0.8,1], 'data':[rect[0],rect[1],0, rect[2],rect[1],0, rect[2],rect[3],0, rect[0],rect[3],0, rect[0],rect[1],0]} #background
27graphicsRigid1 ={'type':'Circle', 'color':[1,0.1,0.8,1], 'position':[1,2,0], 'radius': 1}  
28
29oGround = mbs.AddObject(ObjectGround(referencePosition= [0,0,0], visualization=VObjectGround(graphicsData= [background0,graphicsRigid1])))
30
31mbs.Assemble()
32
33if not testIsActive: 
34    SC.renderer.Start()
35    SC.renderer.DoIdleTasks()
36    SC.renderer.Stop() #safely close rendering window!
37
38testResult = 0 #this test only fails (crashes) but does not give an error value
39exu.Print('solution of GraphicsDataTest=', testResult)
40exu.sys['testResult'] = testResult