mirror of
https://github.com/NGSolve/netgen.git
synced 2024-11-11 16:49:16 +05:00
load geometries from command line with python netgen executable
This commit is contained in:
parent
bac314a666
commit
6b36a2d9d8
@ -209,6 +209,12 @@ NGCORE_API_EXPORT void ExportSTL(py::module & m)
|
|||||||
}, py::arg("mp") = nullptr,
|
}, py::arg("mp") = nullptr,
|
||||||
py::call_guard<py::gil_scoped_release>(),
|
py::call_guard<py::gil_scoped_release>(),
|
||||||
(meshingparameter_description + stlparameter_description).c_str())
|
(meshingparameter_description + stlparameter_description).c_str())
|
||||||
|
.def("Draw", FunctionPointer
|
||||||
|
([] (shared_ptr<STLGeometry> self)
|
||||||
|
{
|
||||||
|
ng_geometry = self;
|
||||||
|
})
|
||||||
|
)
|
||||||
;
|
;
|
||||||
m.def("LoadSTLGeometry", [] (const string & filename)
|
m.def("LoadSTLGeometry", [] (const string & filename)
|
||||||
{
|
{
|
||||||
|
@ -1,11 +1,41 @@
|
|||||||
import imp, threading, sys
|
import imp, threading, sys
|
||||||
|
|
||||||
|
def _py_handler(f):
|
||||||
|
with open(f) as pyfile:
|
||||||
|
imp.load_module('__main__', pyfile, f, (".py", "r", imp.PY_SOURCE))
|
||||||
|
|
||||||
|
def _geo_handler(f):
|
||||||
|
from netgen.csg import CSGeometry
|
||||||
|
print("load", f)
|
||||||
|
geo = CSGeometry(f)
|
||||||
|
geo.Draw()
|
||||||
|
|
||||||
|
def _step_handler(f):
|
||||||
|
from netgen.occ import OCCGeometry
|
||||||
|
print("load", f)
|
||||||
|
geo = OCCGeometry(f)
|
||||||
|
geo.Draw()
|
||||||
|
|
||||||
|
def _stl_handler(f):
|
||||||
|
from netgen.stl import STLGeometry
|
||||||
|
print("load", f)
|
||||||
|
geo = STLGeometry(f)
|
||||||
|
geo.Draw()
|
||||||
|
|
||||||
|
_file_handler = {}
|
||||||
|
_file_handler['.py'] = _py_handler
|
||||||
|
_file_handler['.geo'] = _geo_handler
|
||||||
|
_file_handler['.step'] = _step_handler
|
||||||
|
_file_handler['.stl'] = _stl_handler
|
||||||
|
|
||||||
def handle_arguments():
|
def handle_arguments():
|
||||||
import __main__
|
import __main__
|
||||||
|
import os.path
|
||||||
argv = sys.argv
|
argv = sys.argv
|
||||||
if len(argv)>1 and argv[1].endswith(".py"):
|
if len(argv)>1:
|
||||||
with open(argv[1]) as pyfile:
|
_, ext = os.path.splitext(argv[1])
|
||||||
imp.load_module('__main__', pyfile, argv[1], (".py", "r", imp.PY_SOURCE))
|
if ext in _file_handler:
|
||||||
|
_file_handler[ext](argv[1])
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
import netgen
|
import netgen
|
||||||
|
Loading…
Reference in New Issue
Block a user