mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
vs-csg
This commit is contained in:
parent
c216e3f3ed
commit
f2f7a27d86
@ -44,6 +44,7 @@ namespace netgen
|
||||
|
||||
void VisualSceneGeometry :: DrawScene ()
|
||||
{
|
||||
cout << "vs-csg::Draw" << endl;
|
||||
if (changeval != geometry->GetChangeVal())
|
||||
BuildScene();
|
||||
changeval = geometry->GetChangeVal();
|
||||
@ -127,6 +128,7 @@ namespace netgen
|
||||
|
||||
void VisualSceneGeometry :: BuildScene (int zoomall)
|
||||
{
|
||||
cout << "vs-csg::Build" << endl;
|
||||
Box<3> box;
|
||||
int hasp = 0;
|
||||
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; }
|
||||
|
||||
#ifdef NG_PYTHON
|
||||
@ -494,8 +536,26 @@ namespace bp = boost::python;
|
||||
|
||||
BOOST_PYTHON_MODULE(libcsgvis)
|
||||
{
|
||||
using namespace netgen;
|
||||
|
||||
cout << "exporting csg-vis " << endl;
|
||||
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
|
||||
|
||||
|
@ -230,6 +230,7 @@ namespace netgen
|
||||
|
||||
// ifstream infile(filename.c_str());
|
||||
mesh -> Load(*infile);
|
||||
vsmesh.SetMesh (mesh);
|
||||
|
||||
#ifdef PARALLEL
|
||||
MyMPI_SendCmd ("mesh");
|
||||
|
@ -1,8 +1,5 @@
|
||||
import sys
|
||||
sys.path.append("/opt/netgen/lib")
|
||||
|
||||
from libcsg.csg import *
|
||||
from libmesh.meshing import *
|
||||
from netgen.csg import *
|
||||
import netgen.meshing as meshing
|
||||
|
||||
|
||||
sp1 = Sphere (Point3d(1,0,0), 1)
|
||||
@ -16,9 +13,10 @@ geom = CSGeometry()
|
||||
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")
|
||||
|
Loading…
Reference in New Issue
Block a user