quad/hex elements

This commit is contained in:
Joachim Schöberl 2015-09-23 15:35:18 -07:00
parent c135897899
commit 3153bc1f0b

View File

@ -108,12 +108,23 @@ DLL_HEADER void ExportNetgenMeshing()
bp::class_<Element>("Element3D") bp::class_<Element>("Element3D")
.def("__init__", bp::make_constructor .def("__init__", bp::make_constructor
(FunctionPointer ([](int index, bp::list vertices) (FunctionPointer ([](int index, bp::list vertices)
{
if (bp::len(vertices) == 4)
{ {
Element * tmp = new Element(TET); Element * tmp = new Element(TET);
for (int i = 0; i < 4; i++) for (int i = 0; i < 4; i++)
(*tmp)[i] = bp::extract<PointIndex>(vertices[i]); (*tmp)[i] = bp::extract<PointIndex>(vertices[i]);
tmp->SetIndex(index); tmp->SetIndex(index);
return tmp; return tmp;
}
if (bp::len(vertices) == 8)
{
Element * tmp = new Element(HEX);
for (int i = 0; i < 8; i++)
(*tmp)[i] = bp::extract<PointIndex>(vertices[i]);
tmp->SetIndex(index);
return tmp;
}
}), }),
bp::default_call_policies(), // need it to use arguments bp::default_call_policies(), // need it to use arguments
(bp::arg("index")=1,bp::arg("vertices"))), (bp::arg("index")=1,bp::arg("vertices"))),
@ -134,12 +145,24 @@ DLL_HEADER void ExportNetgenMeshing()
bp::class_<Element2d>("Element2D") bp::class_<Element2d>("Element2D")
.def("__init__", bp::make_constructor .def("__init__", bp::make_constructor
(FunctionPointer ([](int index, bp::list vertices) (FunctionPointer ([](int index, bp::list vertices)
{
if (bp::len(vertices) == 3)
{ {
Element2d * tmp = new Element2d(TRIG); Element2d * tmp = new Element2d(TRIG);
for (int i = 0; i < 3; i++) for (int i = 0; i < 3; i++)
(*tmp)[i] = bp::extract<PointIndex>(vertices[i]); (*tmp)[i] = bp::extract<PointIndex>(vertices[i]);
tmp->SetIndex(index); tmp->SetIndex(index);
return tmp; return tmp;
}
else
{
Element2d * tmp = new Element2d(QUAD);
for (int i = 0; i < 4; i++)
(*tmp)[i] = bp::extract<PointIndex>(vertices[i]);
tmp->SetIndex(index);
return tmp;
}
}), }),
bp::default_call_policies(), // need it to use arguments bp::default_call_policies(), // need it to use arguments
(bp::arg("index")=1,bp::arg("vertices"))), (bp::arg("index")=1,bp::arg("vertices"))),