diff --git a/libsrc/geom2d/geometry2d.cpp b/libsrc/geom2d/geometry2d.cpp index 5c7754cf..6d89b182 100644 --- a/libsrc/geom2d/geometry2d.cpp +++ b/libsrc/geom2d/geometry2d.cpp @@ -908,7 +908,7 @@ namespace netgen - void SplineGeometry2d :: GetMaterial( const int domnr, char* & material ) + void SplineGeometry2d :: GetMaterial (int domnr, char* & material ) { if ( materials.Size() >= domnr) material = materials[domnr-1]; @@ -916,6 +916,24 @@ namespace netgen material = 0; } + void SplineGeometry2d :: SetMaterial (int domnr, const string & material) + { + int oldsize = materials.Size(); + if (domnr > materials.Size()) materials.SetSize (domnr); + for (int i = oldsize; i < domnr; i++) + materials[i] = nullptr; + + if (domnr >= 1) // && domnr <= materials.Size()) + { + delete materials[domnr-1]; + materials[domnr-1] = new char[material.size()+1]; + strcpy(materials[domnr-1], material.c_str()); + } + else + throw NgException ("material index out of range"); + } + + double SplineGeometry2d :: GetDomainMaxh( const int domnr ) { diff --git a/libsrc/geom2d/geometry2d.hpp b/libsrc/geom2d/geometry2d.hpp index a8d9e97a..7f435025 100644 --- a/libsrc/geom2d/geometry2d.hpp +++ b/libsrc/geom2d/geometry2d.hpp @@ -159,7 +159,8 @@ namespace netgen void CopyEdgeMesh (int from, int to, Mesh & mesh2d, Point3dTree & searchtree); - void GetMaterial( const int domnr, char* & material ); + void GetMaterial (int domnr, char* & material ); + void SetMaterial (int domnr, const string & material); double GetDomainMaxh ( const int domnr ); bool GetDomainQuadMeshing ( int domnr ) diff --git a/libsrc/geom2d/python_geom2d.cpp b/libsrc/geom2d/python_geom2d.cpp index 700268e9..c0feb026 100644 --- a/libsrc/geom2d/python_geom2d.cpp +++ b/libsrc/geom2d/python_geom2d.cpp @@ -123,6 +123,11 @@ DLL_HEADER void ExportGeom2d() // seg->copyfrom = -1; // self.AppendSegment(seg); // }))//, (bp::arg("self"), bp::arg("point_index1"), bp::arg("point_index2"), bp::arg("point_index3"), bp::arg("leftdomain") = 1, bp::arg("rightdomain") = 0 ) ) + + + .def("SetMaterial", &SplineGeometry2d::SetMaterial) + + .def("PlotData", FunctionPointer([](SplineGeometry2d &self) { Box<2> box(self.GetBoundingBox());