From 52f65188e8618a12be04a70634c9d148d91741bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joachim=20Sch=C3=B6berl?= Date: Tue, 1 Sep 2015 10:50:15 +0200 Subject: [PATCH] bcnames for python - facedescriptor --- libsrc/meshing/meshclass.cpp | 14 +++++++++++++- libsrc/meshing/python_mesh.cpp | 11 +++++++++-- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/libsrc/meshing/meshclass.cpp b/libsrc/meshing/meshclass.cpp index efb6b2c2..1dbd1b2d 100644 --- a/libsrc/meshing/meshclass.cpp +++ b/libsrc/meshing/meshclass.cpp @@ -5570,11 +5570,23 @@ namespace netgen void Mesh ::SetBCName ( int bcnr, const string & abcname ) { + if (bcnr >= bcnames.Size()) + { + int oldsize = bcnames.Size(); + bcnames.SetSize (bcnr+1); // keeps contents + for (int i = oldsize; i <= bcnr; i++) + bcnames[i] = nullptr; + } + if ( bcnames[bcnr] ) delete bcnames[bcnr]; if ( abcname != "default" ) bcnames[bcnr] = new string ( abcname ); else - bcnames[bcnr] = 0; + bcnames[bcnr] = nullptr; + + for (auto & fd : facedecoding) + if (fd.BCProperty() < bcnames.Size()) + fd.SetBCName (bcnames[fd.BCProperty()]); } const string & Mesh ::GetBCName ( int bcnr ) const diff --git a/libsrc/meshing/python_mesh.cpp b/libsrc/meshing/python_mesh.cpp index 22e24f84..11c82c2b 100644 --- a/libsrc/meshing/python_mesh.cpp +++ b/libsrc/meshing/python_mesh.cpp @@ -203,24 +203,29 @@ DLL_HEADER void ExportNetgenMeshing() bp::class_("FaceDescriptor") .def(bp::init()) .def("__init__", bp::make_constructor - (FunctionPointer ([](int surfnr, int domin, int domout) + (FunctionPointer ([](int surfnr, int domin, int domout, int bc) { auto fd = new FaceDescriptor(); fd->SetSurfNr(surfnr); fd->SetDomainIn(domin); fd->SetDomainOut(domout); + fd->SetBCProperty(bc); return fd; }), bp::default_call_policies(), // need it to use arguments (bp::arg("surfnr")=1, bp::arg("domin")=1, - bp::arg("domout")=0)), + bp::arg("domout")=0, + bp::arg("bc")=0 + )), "create facedescriptor") .def("__str__", &ToString) .def("__repr__", &ToString) .add_property("surfnr", &FaceDescriptor::SurfNr, &FaceDescriptor::SetSurfNr) .add_property("domin", &FaceDescriptor::DomainIn, &FaceDescriptor::SetDomainIn) .add_property("domout", &FaceDescriptor::DomainOut, &FaceDescriptor::SetDomainOut) + .add_property("bc", &FaceDescriptor::BCProperty, &FaceDescriptor::SetBCProperty) + .add_property("bcname", FunctionPointer ([](FaceDescriptor & self) -> string { return self.GetBCName(); })) ; @@ -311,6 +316,8 @@ DLL_HEADER void ExportNetgenMeshing() return self.AddFaceDescriptor (fd); })) + .def ("SetBCName", &Mesh::SetBCName) + .def ("GenerateVolumeMesh", FunctionPointer ([](Mesh & self) {