Esempio n. 1
0
def make_gegede_geom(cfgfile):
    base = os.path.splitext(os.path.basename(cfgfile))[0]
    gdmlfile = base + '.gdml'

    import gegede.main
    geom = gegede.main.generate(cfgfile)

    from gegede.export import Exporter
    exporter = Exporter('gdml')
    exporter.convert(geom)
    exporter.output(gdmlfile)

    tgeo, out, err = capture_stdout(lambda: ROOT.TGeoManager.Import(gdmlfile))
    for line in out.split('\n'):
        assert not 'Not Yet Defined' in line, line

    return tgeo
Esempio n. 2
0
def make_gegede_geom(cfgfile):
    base = os.path.splitext(os.path.basename(cfgfile))[0]
    gdmlfile = base + '.gdml'

    import gegede.main
    geom = gegede.main.generate(cfgfile)

    from gegede.export import Exporter
    exporter = Exporter('gdml')
    exporter.convert(geom)
    exporter.output(gdmlfile)

    tgeo,out,err = capture_stdout(lambda : ROOT.TGeoManager.Import(gdmlfile))
    for line in out.split('\n'):
        assert not 'Not Yet Defined' in line, line

    return tgeo
Esempio n. 3
0
File: main.py Progetto: DUNE/gegede
def main ():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("-w", "--world", default=None,
                        help="World builder name")
    parser.add_argument("-f", "--format", default=None,
                        help = "Export format, guess by extension if not given")
    parser.add_argument("-o", "--output", default=None,
                        help="File to export to")
    parser.add_argument("-V", "--validate", action='store_true',
                        help="Validate geometry using built-in GeGeDe")
    parser.add_argument("-O", "--validate-object", action='store_true',
                        help="Validate exported, in-memory objects")
    parser.add_argument("-F", "--validate-file", action='store_true',
                        help="Validate exported, on-file objects")
    parser.add_argument("config", nargs='+',
                        help="Configuration file(s)")
    args = parser.parse_args()

    if not args.format and '.' not in args.output:
        raise parser.error("Can not guess format.  Need --format or --output with file extension")
    if not args.format:
        args.format = os.path.splitext(args.output)[1][1:]
    if args.output == '-':
        args.output = "/dev/stdout"

    geom = generate(args.config, args.world)
    if args.validate:
        import gegede.validation
        gegede.validation.validate(geom)
    from gegede.export import Exporter
    exporter = Exporter(args.format)
    print 'Converting with module: %s' % exporter.mod

    obj = exporter.convert(geom)
    if args.validate_object:
        exporter.validate_object()

    exporter.output(args.output)

    if args.validate_file:
        exporter.validate_file()
    return
Esempio n. 4
0
def main ():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("-w", "--world", default=None,
                        help="World builder name")
    parser.add_argument("-f", "--format", default=None,
                        help = "Export format, guess by extension if not given")
    parser.add_argument("-o", "--output", default=None,
                        help="File to export to")
    parser.add_argument("-V", "--validate", action='store_true',
                        help="Validate geometry using built-in GeGeDe")
    parser.add_argument("-O", "--validate-object", action='store_true',
                        help="Validate exported, in-memory objects")
    parser.add_argument("-F", "--validate-file", action='store_true',
                        help="Validate exported, on-file objects")
    parser.add_argument("-d", "--dot-file", default=None,
                        help="Produce a GraphViz dot file")
    parser.add_argument("-D", "--dot-hierarchy", default="volume",
                        help="Follow the 'volume' or 'builder' hierarchy if making a dot file")
    parser.add_argument("config", nargs='+',
                        help="Configuration file(s)")
    args = parser.parse_args()

    if not args.format and '.' not in args.output:
        raise parser.error("Can not guess format.  Need --format or --output with file extension")
    if not args.format:
        args.format = os.path.splitext(args.output)[1][1:]
    if args.output == '-':
        args.output = "/dev/stdout"

    cfg = parse_config(args.config)

    if args.dot_file and 'builder' in args.dot_hierarchy.lower():
        import gegede.dot
        gegede.dot.builder_hierarchy(cfg, args.world, args.dot_file)

    wbuilder = make_builder(cfg, args.world)
    configure_builder(cfg, wbuilder)
    geom = generate_geometry(wbuilder)

    if args.dot_file and 'volume' in args.dot_hierarchy.lower():
        import gegede.dot
        gegede.dot.volume_hierarchy(geom, None, args.dot_file)
        #gegede.dot.placement_hierarchy(geom, None, args.dot_file)
        
    if args.validate:
        import gegede.validation
        gegede.validation.validate(geom)
    from gegede.export import Exporter
    exporter = Exporter(args.format)
    print ('Converting with module: %s' % exporter.mod)

    obj = exporter.convert(geom)
    if args.validate_object:
        exporter.validate_object()

    exporter.output(args.output)

    if args.validate_file:
        exporter.validate_file()
    return
Esempio n. 5
0
def main():
    import argparse
    parser = argparse.ArgumentParser()
    parser.add_argument("-w",
                        "--world",
                        default=None,
                        help="World builder name")
    parser.add_argument("-f",
                        "--format",
                        default=None,
                        help="Export format, guess by extension if not given")
    parser.add_argument("-o",
                        "--output",
                        default=None,
                        help="File to export to")
    parser.add_argument("-V",
                        "--validate",
                        action='store_true',
                        help="Validate geometry using built-in GeGeDe")
    parser.add_argument("-O",
                        "--validate-object",
                        action='store_true',
                        help="Validate exported, in-memory objects")
    parser.add_argument("-F",
                        "--validate-file",
                        action='store_true',
                        help="Validate exported, on-file objects")
    parser.add_argument("-d",
                        "--dot-file",
                        default=None,
                        help="Produce a GraphViz dot file")
    parser.add_argument(
        "-D",
        "--dot-hierarchy",
        default="volume",
        help="Follow the 'volume' or 'builder' hierarchy if making a dot file")
    parser.add_argument("config", nargs='+', help="Configuration file(s)")
    args = parser.parse_args()

    if not args.format and '.' not in args.output:
        raise parser.error(
            "Can not guess format.  Need --format or --output with file extension"
        )
    if not args.format:
        args.format = os.path.splitext(args.output)[1][1:]
    if args.output == '-':
        args.output = "/dev/stdout"

    cfg = parse_config(args.config)

    if args.dot_file and 'builder' in args.dot_hierarchy.lower():
        import gegede.dot
        gegede.dot.builder_hierarchy(cfg, args.world, args.dot_file)

    wbuilder = make_builder(cfg, args.world)
    configure_builder(cfg, wbuilder)
    geom = generate_geometry(wbuilder)

    if args.dot_file and 'volume' in args.dot_hierarchy.lower():
        import gegede.dot
        gegede.dot.volume_hierarchy(geom, None, args.dot_file)
        #gegede.dot.placement_hierarchy(geom, None, args.dot_file)

    if args.validate:
        import gegede.validation
        gegede.validation.validate(geom)
    from gegede.export import Exporter
    exporter = Exporter(args.format)
    print('Converting with module: %s' % exporter.mod)

    obj = exporter.convert(geom)
    if args.validate_object:
        exporter.validate_object()

    exporter.output(args.output)

    if args.validate_file:
        exporter.validate_file()
    return