materials in 2D

This commit is contained in:
Joachim Schöberl 2015-09-12 15:02:56 +02:00
parent 5e1d9a3c39
commit 105111f5c9
3 changed files with 26 additions and 2 deletions

View File

@ -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) if ( materials.Size() >= domnr)
material = materials[domnr-1]; material = materials[domnr-1];
@ -916,6 +916,24 @@ namespace netgen
material = 0; 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 ) double SplineGeometry2d :: GetDomainMaxh( const int domnr )
{ {

View File

@ -159,7 +159,8 @@ namespace netgen
void CopyEdgeMesh (int from, int to, Mesh & mesh2d, Point3dTree & searchtree); 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 ); double GetDomainMaxh ( const int domnr );
bool GetDomainQuadMeshing ( int domnr ) bool GetDomainQuadMeshing ( int domnr )

View File

@ -123,6 +123,11 @@ DLL_HEADER void ExportGeom2d()
// seg->copyfrom = -1; // seg->copyfrom = -1;
// self.AppendSegment(seg); // 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 ) ) // }))//, (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) .def("PlotData", FunctionPointer([](SplineGeometry2d &self)
{ {
Box<2> box(self.GetBoundingBox()); Box<2> box(self.GetBoundingBox());