use segmentindex as index for mesh.segments array

This commit is contained in:
Christopher Lackner 2020-11-17 15:24:44 +01:00
parent 22d6303c5c
commit ee430a6e1e
3 changed files with 8 additions and 4 deletions

View File

@ -38,7 +38,7 @@ namespace netgen
NgMPI_Comm comm;
/// line-segments at edges
Array<Segment> segments;
Array<Segment, SegmentIndex> segments;
/// surface elements, 2d-inner elements
Array<Element2d, SurfaceElementIndex> surfelements;
/// volume elements

View File

@ -306,13 +306,17 @@ namespace netgen
SegmentIndex & operator= (const SegmentIndex & ai)
{ i = ai.i; return *this; }
SegmentIndex & operator= (int ai) { i = ai; return *this; }
operator int () const { return i; }
constexpr operator int () const { return i; }
SegmentIndex& operator++ () { ++i; return *this; }
SegmentIndex& operator-- () { --i; return *this; }
SegmentIndex operator++ (int) { return i++; }
SegmentIndex operator-- (int) { return i--; }
};
inline void SetInvalid (SegmentIndex & id) { id = -1; }
inline bool IsInvalid (SegmentIndex & id) { return id == -1; }
inline istream & operator>> (istream & ist, SegmentIndex & pi)
{
int i; ist >> i; pi = i; return ist;

View File

@ -603,7 +603,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
ExportArray<Element,size_t>(m);
ExportArray<Element2d,SurfaceElementIndex>(m);
ExportArray<Segment,size_t>(m);
ExportArray<Segment,SegmentIndex>(m);
ExportArray<Element0d>(m);
ExportArray<MeshPoint,PointIndex>(m);
ExportArray<FaceDescriptor>(m);
@ -823,7 +823,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
py::return_value_policy::reference)
.def("Elements1D",
static_cast<Array<Segment>&(Mesh::*)()> (&Mesh::LineSegments),
static_cast<Array<Segment, SegmentIndex>&(Mesh::*)()> (&Mesh::LineSegments),
py::return_value_policy::reference)
.def("Elements0D", FunctionPointer([] (Mesh & self) -> Array<Element0d>&