-
Notifications
You must be signed in to change notification settings - Fork 142
/
Copy pathmeshMerge
executable file
·66 lines (50 loc) · 1.92 KB
/
meshMerge
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
This program is part of pygimli
Visit http://www.resistivity.net for further information or the latest version.
"""
import sys
import os
import pygimli as pg
def main(argv):
import argparse
# intialisize parser
parser = argparse.ArgumentParser(description="Merge two meshes")
# define some options (better import from defaultParser)
parser.add_argument("-v", "--verbose", dest="verbose", action="store_true",
help="Be verbose")
parser.add_argument("--debug", dest="debug", action="store_true",
help="debug mode")
parser.add_argument('meshes', type=str, nargs='+',
help='Files to be merge. If there are more than 2 files, '
' e.g., called with wildcard (*.vtk), the file matches '
'the outFileName will be excluded.')
parser.add_argument("-o", dest="outFileName", type=str,
help="Filename for the resulting mesh.",
default='merged')
args = parser.parse_args()
if args.debug:
pg.setDebug(args.debug)
if args.verbose:
print(args)
if len(args.meshes) < 2:
print("Need at least 2 meshes to merge")
sys.exit()
(outfileBody, fileExtension) = os.path.splitext(args.outFileName)
if len(args.meshes) > 2:
args.meshes = list(filter(lambda m: outfileBody not in m, args.meshes))
mesh = pg.meshtools.mergeMeshes(args.meshes, args.verbose)
if args.verbose:
print("Save:")
print(outfileBody, mesh)
if outfileBody.find('.vtk'):
mesh.exportVTK(outfileBody)
if args.verbose:
print("write out: ", outfileBody + ".vtk")
else:
mesh.saveBinaryV2(outfileBody)
if args.verbose:
print("write out: ", outfileBody + ".bms")
if __name__ == "__main__":
main(sys.argv[1:])