diff --git a/libsrc/geom2d/csg2d.cpp b/libsrc/geom2d/csg2d.cpp index dd8cf21a..dfee7fba 100644 --- a/libsrc/geom2d/csg2d.cpp +++ b/libsrc/geom2d/csg2d.cpp @@ -2183,7 +2183,11 @@ shared_ptr CSG2d :: GenerateSplineGeometry() } } if(!is_solid_degenerated) + { geo->SetMaterial(dom, s.name); + if(s.layer != 1) + geo->SetDomainLayer(dom, s.layer); + } else dom--; // degenerated solid, use same domain index again } diff --git a/libsrc/geom2d/csg2d.hpp b/libsrc/geom2d/csg2d.hpp index afc1e654..fbe705a9 100644 --- a/libsrc/geom2d/csg2d.hpp +++ b/libsrc/geom2d/csg2d.hpp @@ -630,6 +630,7 @@ struct Solid2d { Array polys; + int layer = 1; string name = MAT_DEFAULT; Solid2d() = default; @@ -708,6 +709,12 @@ struct Solid2d return *this; } + Solid2d & Layer(int layer_) + { + layer = layer_; + return *this; + } + Box<2> GetBoundingBox() const; }; diff --git a/libsrc/geom2d/geometry2d.hpp b/libsrc/geom2d/geometry2d.hpp index daab8d12..08c3fc9d 100644 --- a/libsrc/geom2d/geometry2d.hpp +++ b/libsrc/geom2d/geometry2d.hpp @@ -250,7 +250,17 @@ namespace netgen if ( layer.Size() ) return layer[domnr-1]; else return 1; } - + void SetDomainLayer (int domnr, int layernr) + { + auto old_size = layer.Size(); + if(domnr > old_size) + { + layer.SetSize(domnr); + for(size_t i = old_size; i < domnr; i++) + layer[i] = 1; + } + layer[domnr-1] = layernr; + } string GetBCName (int bcnr) const; void SetBCName (int bcnr, string name); diff --git a/libsrc/geom2d/python_geom2d.cpp b/libsrc/geom2d/python_geom2d.cpp index 2b01e566..dc14bd67 100644 --- a/libsrc/geom2d/python_geom2d.cpp +++ b/libsrc/geom2d/python_geom2d.cpp @@ -49,6 +49,7 @@ NGCORE_API_EXPORT void ExportGeom2d(py::module &m) })) .def(NGSPickle()) .def("Load",&SplineGeometry2d::Load) + .def("SetDomainLayer", &SplineGeometry2d::SetDomainLayer) .def("AppendPoint", FunctionPointer ([](SplineGeometry2d &self, double px, double py, double maxh, double hpref, string name) { @@ -432,6 +433,7 @@ NGCORE_API_EXPORT void ExportGeom2d(py::module &m) .def("Mat", &Solid2d::Mat) .def("BC", &Solid2d::BC) .def("Maxh", &Solid2d::Maxh) + .def("Layer", &Solid2d::Layer) .def("Copy", [](Solid2d & self) -> Solid2d { return self; }) .def("Move", &Solid2d::Move)