bcnames for python - facedescriptor

This commit is contained in:
Joachim Schöberl 2015-09-01 10:50:15 +02:00
parent 570d81c8cb
commit 52f65188e8
2 changed files with 22 additions and 3 deletions

View File

@ -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

View File

@ -203,24 +203,29 @@ DLL_HEADER void ExportNetgenMeshing()
bp::class_<FaceDescriptor>("FaceDescriptor")
.def(bp::init<const FaceDescriptor&>())
.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<FaceDescriptor>)
.def("__repr__", &ToString<FaceDescriptor>)
.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)
{