2017-05-31 22:38:17 +05:00
# ifdef NG_PYTHON
# ifdef OCCGEOMETRY
# include <../general/ngpython.hpp>
# include <meshing.hpp>
# include <occgeom.hpp>
using namespace netgen ;
namespace netgen
{
extern std : : shared_ptr < NetgenGeometry > ng_geometry ;
}
DLL_HEADER void ExportNgOCC ( py : : module & m )
{
2018-04-17 22:37:29 +05:00
py : : class_ < OCCGeometry , shared_ptr < OCCGeometry > , NetgenGeometry > ( m , " OCCGeometry " , R " raw_string(Use LoadOCCGeometry to load the geometry from a *.step file.)raw_string " )
2017-05-31 22:38:17 +05:00
. def ( py : : init < > ( ) )
2017-11-03 21:44:01 +05:00
. def ( " Heal " , [ ] ( OCCGeometry & self , double tolerance , bool fixsmalledges , bool fixspotstripfaces , bool sewfaces , bool makesolids , bool splitpartitions )
{
self . tolerance = tolerance ;
self . fixsmalledges = fixsmalledges ;
self . fixspotstripfaces = fixspotstripfaces ;
self . sewfaces = sewfaces ;
self . makesolids = makesolids ;
self . splitpartitions = splitpartitions ;
self . HealGeometry ( ) ;
self . BuildFMap ( ) ;
2018-03-13 02:38:21 +05:00
} , py : : arg ( " tolerance " ) = 1e-3 , py : : arg ( " fixsmalledges " ) = true , py : : arg ( " fixspotstripfaces " ) = true , py : : arg ( " sewfaces " ) = true , py : : arg ( " makesolids " ) = true , py : : arg ( " splitpartitions " ) = false , R " raw_string(Heal the OCCGeometry.)raw_string " , py : : call_guard < py : : gil_scoped_release > ( ) )
2017-05-31 22:38:17 +05:00
;
m . def ( " LoadOCCGeometry " , FunctionPointer ( [ ] ( const string & filename )
{
cout < < " load OCC geometry " ;
ifstream ist ( filename ) ;
OCCGeometry * instance = new OCCGeometry ( ) ;
instance = LoadOCC_STEP ( filename . c_str ( ) ) ;
return shared_ptr < OCCGeometry > ( instance , NOOP_Deleter ) ;
2018-03-13 02:38:21 +05:00
} ) , py : : call_guard < py : : gil_scoped_release > ( ) ) ;
2017-05-31 22:38:17 +05:00
m . def ( " GenerateMesh " , FunctionPointer ( [ ] ( shared_ptr < OCCGeometry > geo , MeshingParameters & param )
{
auto mesh = make_shared < Mesh > ( ) ;
SetGlobalMesh ( mesh ) ;
mesh - > SetGeometry ( geo ) ;
ng_geometry = geo ;
2017-10-20 19:39:37 +05:00
2017-05-31 22:38:17 +05:00
try
{
geo - > GenerateMesh ( mesh , param ) ;
}
catch ( NgException ex )
{
cout < < " Caught NgException: " < < ex . What ( ) < < endl ;
}
return mesh ;
2018-03-13 02:38:21 +05:00
} ) , py : : call_guard < py : : gil_scoped_release > ( ) )
2017-05-31 22:38:17 +05:00
;
}
2017-09-01 12:33:57 +05:00
PYBIND11_MODULE ( libNgOCC , m ) {
2017-05-31 22:38:17 +05:00
ExportNgOCC ( m ) ;
}
# endif // OCCGEOMETRY
# endif // NG_PYTHON