def gdml2gltf_main(args): """ main used by bin/gdml2gltf.py """ # envvars are set within opticks_main gdmlpath = os.environ['OPTICKS_GDMLPATH'] gltfpath = os.environ['OPTICKS_GLTFPATH'] #assert gltfpath.startswith("/tmp") if gltfpath.startswith("/tmp"): pass else: assert gdmlpath.replace('.gdml', '.gltf') == gltfpath assert gltfpath.replace('.gltf', '.gdml') == gdmlpath pass log.info(" gdmlpath %s " % gdmlpath) log.info(" gltfpath %s " % gltfpath) #return 1 log.info("start GDML parse") gdml = GDML.parse(gdmlpath) log.info("start treeify") tree = Tree(gdml.world) log.info("start apply_selection") tree.apply_selection(args.query) # sets node.selected "volume mask" log.info("start Sc.ctor") sc = Sc(maxcsgheight=3) sc.extras["verbosity"] = 1 sc.extras[ "targetnode"] = 0 # args.query.query_range[0] # hmm get rid of this ? log.info("start Sc.add_tree_gdml") tg = sc.add_tree_gdml(tree.root, maxdepth=0) log.info("start Sc.add_tree_gdml DONE") #path = args.gltfpath gltf = sc.save(gltfpath) sc.gdml = gdml sc.tree = tree Boolean.SaveBuffer() return sc
from opticks.analytic.polyconfig import PolyConfig from opticks.analytic.csg import CSG from opticks.ana.pmt.ddbase import Dddb from opticks.ana.pmt.ncsgconverter import NCSGConverter if __name__ == '__main__': args = opticks_main() g = Dddb.parse(args.apmtddpath) lvn = "lvPmtHemi" lv = g.logvol_(lvn) tr = Tree(lv) nn = tr.num_nodes() container = CSG("box") container.boundary = args.container container.meta.update(PolyConfig("CONTAINER").meta) objs = [] objs.append(container) ii = range(nn) for i in ii: node = tr.get(i) lv = node.lv
name_cache.add(name) log.info(name_cache) log.info(pv_sd_pmtid) # set(['pAcylic', 'PMT_3inch_log_phys', 'PMT_3inch_cntr_phys', 'PMT_3inch_body_phys', 'lUpperChimney_phys', 'pCentralDetector', 'pExpHall', 'pPoolLining', 'pLowerChimneySteel', 'pUpperChimneyTyvek', 'pMask', 'lSurftube_phys', 'lFasteners_phys', 'lMaskVirtual_phys', 'top', 'PMT_3inch_inner2_phys', 'pvacSurftube', 'PMT_20inch_inner2_phys', 'pOuterWaterPool', 'pInnerWater', 'PMT_3inch_inner1_phys', 'pBtmRock', 'PMT_20inch_body_phys', 'lLowerChimney_phys', 'pTarget', 'lSteel_phys', 'PMT_20inch_log_phys', 'pUpperChimneySteel', 'pLowerChimneyAcrylic', 'pUpperChimneyLS', 'pLowerChimneyTyvek', 'PMT_20inch_inner1_phys', 'pLowerChimneyBlocker', 'pLowerChimneyLS', 'pTopRock']) if __name__ == "__main__": args = opticks_main() log.info(args) gdmlpath = os.environ['OPTICKS_GDMLPATH'] log.info(gdmlpath) log.info("start GDML parse") gdml = GDML.parse(gdmlpath) log.info("start treeify") tree = Tree(gdml.world) # print tree # print dir(tree) # print tree.root # FOR JUNO ONLY pv_sd_name = None pv_sd_pmtid = None if args.j1707: pv_sd_name = ['PMT_20inch_inner1_phys', 'PMT_3inch_inner1_phys'] pv_sd_pmtid = { 'PMT_20inch_inner1_phys': 0, 'PMT_3inch_inner1_phys': 300000 }
) if proceed != "YES": sys.exit(1) pass xmlpath = args.apmtddpath log.info("\n\nparsing %s -> %s " % (xmlpath, os.path.expandvars(xmlpath))) log.info("\n\nDddb.parse xml \n") g = Dddb.parse(xmlpath) log.info("\n\ng.logvol \n") lv = g.logvol_("lvPmtHemi") log.info("\n\nTree(lv) \n") tr = Tree(lv) log.info("\n\nDump Tree \n") tr.dump() log.info( "\n\nPartition Tree into parts list **ddpart.py:ElemPartitioner.parts** IS THE HUB \n" ) parts = tr.parts() log.info("\n\nDump parts : type(parts):%s \n", type(parts)) for pt in parts: print pt assert hasattr(parts, 'gcsg') and len(parts.gcsg) > 0 log.info(
ln = CSG(op, name=en.name + "_split3") ln.left = cls.convert(children[0]) ln.right = cls.convert(children[1]) cn.left = ln cn.right = cls.convert(children[2]) else: assert 0, "CSG operator nodes must have 2 or 3 children" pass return cn if __name__ == '__main__': args = opticks_main(apmtidx=2) g = Dddb.parse(args.apmtddpath) lvn = "lvPmtHemi" #lvn = "lvPmtHemiwPmtHolder" lv = g.logvol_(lvn) tr = Tree(lv) cn = NCSGConverter.ConvertLV(tr.root.lv) cn.dump()
from opticks.analytic.gdml import GDML from opticks.analytic.gdml_builder import make_gdml, tostring_ from opticks.analytic.sc import Sc, Nd if __name__ == '__main__': args = opticks_main() pmt = "/dd/Geometry/PMT/lvPmtHemi0xc133740" oil = "/dd/Geometry/AD/lvOIL0xbf5e0b8" skey = "pmt1" #skey = "pmt2" #skey = "pmt5" #skey = "collar" #skey = "collar2" gg = make_gdml(worldref=oil, structure_key=skey) wgg = GDML.wrap(gg) tree = Tree(wgg.world) assert type(tree.root) is Node sc = Sc() sc.extras["verbosity"] = 3 tg = sc.add_tree_gdml(tree.root, maxdepth=0) assert type(tg) is Nd path = "$TMP/tgltf/%s.gltf" % (os.path.basename(sys.argv[0])) gltf = sc.save(path)
from opticks.analytic.sc import Sc if __name__ == '__main__': args = opticks_main() gsel = args.gsel # string representing target node index integer or lvname gmaxnode = args.gmaxnode # limit subtree node count gmaxdepth = args.gmaxdepth # limit subtree node depth from the target node gidx = args.gidx # target selection index, used when the gsel-ection yields multiple nodes eg when using lvname selection log.info(" gsel:%s gidx:%s gmaxnode:%s gmaxdepth:%s " % (gsel, gidx, gmaxnode, gmaxdepth)) gdml = GDML.parse() tree = Tree(gdml.world) subtree = tree.subtree(gsel, maxdepth=gmaxdepth, maxnode=gmaxnode, idx=gidx) # just a flat list of nodes log.info(" subtree %s nodes " % len(subtree)) cns = [] for i, node in enumerate(subtree): solid = node.lv.solid if i % 100 == 0:
def treepart_manual_mixin(): """ Using manual mixin approach to avoid changing the class hierarchy whilst still splitting base functionality from partitioner methods. """ manual_mixin(Node, NodePartitioner) manual_mixin(Tree, TreePartitioner) if __name__ == '__main__': args = opticks_main() ddpart_manual_mixin() # add methods to Tubs, Sphere, Elem and Primitive treepart_manual_mixin() # add methods to Node and Tree g = Dddb.parse(args.apmtddpath) lv = g.logvol_("lvPmtHemi") tr = Tree(lv) parts = tr.parts() partsbuf = tr.convert(parts) log.warning( "use analytic so save the PMT, this is just for testing tree conversion" )