This commit is contained in:
Joachim Schoeberl 2014-10-06 14:44:06 +00:00
parent c216e3f3ed
commit f2f7a27d86
3 changed files with 68 additions and 9 deletions

View File

@ -44,6 +44,7 @@ namespace netgen
void VisualSceneGeometry :: DrawScene () void VisualSceneGeometry :: DrawScene ()
{ {
cout << "vs-csg::Draw" << endl;
if (changeval != geometry->GetChangeVal()) if (changeval != geometry->GetChangeVal())
BuildScene(); BuildScene();
changeval = geometry->GetChangeVal(); changeval = geometry->GetChangeVal();
@ -127,6 +128,7 @@ namespace netgen
void VisualSceneGeometry :: BuildScene (int zoomall) void VisualSceneGeometry :: BuildScene (int zoomall)
{ {
cout << "vs-csg::Build" << endl;
Box<3> box; Box<3> box;
int hasp = 0; int hasp = 0;
for (int i = 0; i < geometry->GetNTopLevelObjects(); i++) for (int i = 0; i < geometry->GetNTopLevelObjects(); i++)
@ -486,6 +488,46 @@ namespace netgen
} }
//////////////////////////////////////////////////////////////////////
// Lambda to function pointer conversion
template <typename Function>
struct function_traits
: public function_traits<decltype(&Function::operator())> {};
template <typename ClassType, typename ReturnType, typename... Args>
struct function_traits<ReturnType(ClassType::*)(Args...) const> {
typedef ReturnType (*pointer)(Args...);
typedef ReturnType return_type;
};
template <typename Function>
typename function_traits<Function>::pointer
FunctionPointer (const Function& lambda) {
return static_cast<typename function_traits<Function>::pointer>(lambda);
}
template <class T>
inline string ToString (const T& t)
{
stringstream ss;
ss << t;
return ss.str();
}
void Hi () { cout << "hi from csgvis" << endl; } void Hi () { cout << "hi from csgvis" << endl; }
#ifdef NG_PYTHON #ifdef NG_PYTHON
@ -494,8 +536,26 @@ namespace bp = boost::python;
BOOST_PYTHON_MODULE(libcsgvis) BOOST_PYTHON_MODULE(libcsgvis)
{ {
using namespace netgen;
cout << "exporting csg-vis " << endl; cout << "exporting csg-vis " << endl;
bp::def("hi", &Hi); bp::def("hi", &Hi);
bp::class_<VisualSceneGeometry, shared_ptr<VisualSceneGeometry>>
("VisualSceneGeometry", bp::no_init)
.def ("Draw", &VisualSceneGeometry::DrawScene)
;
bp::def ("VS", FunctionPointer
([] (const CSGeometry & geom)
// ([] (shared_ptr<CSGeometry> geom)
{
auto vs = make_shared<VisualSceneGeometry>();
vs->SetGeometry(const_cast<CSGeometry*>(&geom));
// vs->SetGeometry(geom.get());
return vs;
}));
} }
#endif #endif

View File

@ -230,6 +230,7 @@ namespace netgen
// ifstream infile(filename.c_str()); // ifstream infile(filename.c_str());
mesh -> Load(*infile); mesh -> Load(*infile);
vsmesh.SetMesh (mesh);
#ifdef PARALLEL #ifdef PARALLEL
MyMPI_SendCmd ("mesh"); MyMPI_SendCmd ("mesh");

View File

@ -1,8 +1,5 @@
import sys from netgen.csg import *
sys.path.append("/opt/netgen/lib") import netgen.meshing as meshing
from libcsg.csg import *
from libmesh.meshing import *
sp1 = Sphere (Point3d(1,0,0), 1) sp1 = Sphere (Point3d(1,0,0), 1)
@ -16,9 +13,10 @@ geom = CSGeometry()
geom.Add (all) geom.Add (all)
vis = VS(geom)
vis.Draw()
param = MeshingParameters()
param.maxh = 0.2
mesh = GenerateMesh (geom, param)
mesh.Save ("test.vol") # param = meshing.MeshingParameters(maxh=0.2)
# mesh = GenerateMesh (geom, param)
# mesh.Save ("test.vol")