mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-25 21:40:33 +05:00
Segment array with size_t indexing
This commit is contained in:
parent
8f11b84911
commit
712e2c3fb4
@ -13,10 +13,16 @@ NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<0> (size_t nr) const
|
||||
template <>
|
||||
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<1> (size_t nr) const
|
||||
{
|
||||
/*
|
||||
if(mesh->GetDimension()==3)
|
||||
return (*mesh)[SegmentIndex(nr)].edgenr;
|
||||
else
|
||||
return (*mesh)[SegmentIndex(nr)].si;
|
||||
*/
|
||||
if(mesh->GetDimension()==3)
|
||||
return mesh->LineSegments()[nr].edgenr;
|
||||
else
|
||||
return mesh->LineSegments()[nr].si;
|
||||
}
|
||||
|
||||
template <>
|
||||
@ -66,7 +72,8 @@ NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<0> (size_t nr) const
|
||||
template <>
|
||||
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (size_t nr) const
|
||||
{
|
||||
const Segment & el = mesh->LineSegment (SegmentIndex(nr));
|
||||
// const Segment & el = mesh->LineSegment (SegmentIndex(nr));
|
||||
const Segment & el = mesh->LineSegments()[nr];
|
||||
|
||||
Ng_Element ret;
|
||||
ret.type = NG_ELEMENT_TYPE(el.GetType());
|
||||
|
@ -33,7 +33,7 @@ namespace netgen
|
||||
T_POINTS points;
|
||||
|
||||
/// line-segments at edges
|
||||
Array<Segment> segments;
|
||||
Array<Segment, 0, size_t> segments;
|
||||
/// surface elements, 2d-inner elements
|
||||
T_SURFELEMENTS surfelements;
|
||||
/// volume elements
|
||||
@ -255,8 +255,12 @@ namespace netgen
|
||||
const Segment & operator[] (SegmentIndex si) const { return segments[si]; }
|
||||
Segment & operator[] (SegmentIndex si) { return segments[si]; }
|
||||
|
||||
/*
|
||||
const Array<Segment> & LineSegments() const { return segments; }
|
||||
Array<Segment> & LineSegments() { return segments; }
|
||||
*/
|
||||
const auto & LineSegments() const { return segments; }
|
||||
auto & LineSegments() { return segments; }
|
||||
|
||||
Array<Element0d> pointelements; // only via python interface
|
||||
|
||||
|
@ -425,7 +425,7 @@ DLL_HEADER void ExportNetgenMeshing(py::module &m)
|
||||
|
||||
ExportArray<Element,0,size_t>(m);
|
||||
ExportArray<Element2d,0,size_t>(m);
|
||||
ExportArray<Segment>(m);
|
||||
ExportArray<Segment,0,size_t>(m);
|
||||
ExportArray<Element0d>(m);
|
||||
ExportArray<MeshPoint,PointIndex::BASE,PointIndex>(m);
|
||||
ExportArray<FaceDescriptor>(m);
|
||||
@ -553,7 +553,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,0,size_t>&(Mesh::*)()> (&Mesh::LineSegments),
|
||||
py::return_value_policy::reference)
|
||||
|
||||
.def("Elements0D", FunctionPointer([] (Mesh & self) -> Array<Element0d>&
|
||||
|
Loading…
Reference in New Issue
Block a user