File indexing completed on 2026-04-09 07:48:52
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021 """
0022
0023 run tgltf_gdml.py
0024
0025 In [22]: tree.root.lv.solid.as_ncsg().transform
0026 [2017-05-19 13:25:49,429] p94731 {/Users/blyth/opticks/analytic/glm.py:175} WARNING - supressing identity transform
0027
0028 In [29]: tree.get(1).lv.solid.as_ncsg()
0029 Out[29]: un(in(in(sp,sp),sp),cy)
0030
0031 In [30]: cn = tree.get(1).lv.solid.as_ncsg()
0032
0033 In [31]: cn.analyse()
0034
0035 In [32]: cn.txt
0036 Out[32]: <opticks.analytic.textgrid.TextGrid at 0x10d01c450>
0037
0038 In [33]: print cn.txt union (of 3-sphere intersection and cylinder)
0039 un
0040 in cy
0041 in sp
0042 sp sp
0043
0044
0045 Better way, use the prexisting::
0046
0047 In [13]: sc.get_node(1).mesh
0048 Out[13]: Mh 0 : pmt-hemi0xc0fed90 /dd/Geometry/PMT/lvPmtHemi0xc133740
0049
0050 In [14]: sc.get_node(1).mesh.csg
0051 Out[14]: un(in(in(sp,sp),sp),cy)height:3 totnodes:15
0052
0053 In [15]: print sc.get_node(1).mesh.csg.txt
0054 un
0055 in cy
0056 in sp
0057 sp sp
0058
0059
0060
0061
0062
0063 """
0064 import os, logging, sys, numpy as np
0065
0066 log = logging.getLogger(__name__)
0067
0068 from opticks.ana.base import opticks_main
0069 from opticks.analytic.treebase import Tree, Node
0070 from opticks.analytic.gdml import GDML
0071 from opticks.analytic.gdml_builder import make_gdml, tostring_
0072 from opticks.analytic.sc import Sc, Nd
0073
0074
0075 if __name__ == '__main__':
0076
0077 args = opticks_main()
0078
0079 pmt = "/dd/Geometry/PMT/lvPmtHemi0xc133740"
0080 oil = "/dd/Geometry/AD/lvOIL0xbf5e0b8"
0081
0082 skey = "pmt1"
0083
0084
0085
0086
0087
0088 gg = make_gdml(worldref=oil, structure_key=skey )
0089 wgg = GDML.wrap(gg)
0090
0091 tree = Tree(wgg.world)
0092 assert type(tree.root) is Node
0093
0094 sc = Sc()
0095 sc.extras["verbosity"] = 3
0096 tg = sc.add_tree_gdml( tree.root, maxdepth=0 )
0097 assert type(tg) is Nd
0098
0099
0100 path = "$TMP/tgltf/%s.gltf" % (os.path.basename(sys.argv[0]))
0101 gltf = sc.save(path)