2014-01-07 16:42:39 +06:00
|
|
|
NGX_INLINE DLL_HEADER Ng_Point Ngx_Mesh :: GetPoint (int nr) const
|
|
|
|
{
|
2016-12-11 16:12:05 +05:00
|
|
|
return Ng_Point (&mesh->Point(PointIndex(nr+PointIndex::BASE))(0));
|
2014-01-07 16:42:39 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-10 19:48:49 +05:00
|
|
|
template <>
|
|
|
|
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<0> (int nr) const
|
|
|
|
{
|
2015-11-11 22:46:18 +05:00
|
|
|
return (*mesh).pointelements[nr].index;
|
2015-01-10 19:48:49 +05:00
|
|
|
}
|
|
|
|
|
2014-01-07 16:42:39 +06:00
|
|
|
template <>
|
|
|
|
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<1> (int nr) const
|
|
|
|
{
|
2016-10-05 22:48:18 +05:00
|
|
|
if(mesh->GetDimension()==3)
|
2016-10-11 17:10:36 +05:00
|
|
|
return (*mesh)[SegmentIndex(nr)].edgenr;
|
2016-10-05 22:48:18 +05:00
|
|
|
else
|
|
|
|
return (*mesh)[SegmentIndex(nr)].si;
|
2014-01-07 16:42:39 +06:00
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<2> (int nr) const
|
|
|
|
{
|
|
|
|
int ind = (*mesh)[SurfaceElementIndex(nr)].GetIndex();
|
|
|
|
return mesh->GetFaceDescriptor(ind).BCProperty();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetElementIndex<3> (int nr) const
|
|
|
|
{
|
|
|
|
return (*mesh)[ElementIndex(nr)].GetIndex();
|
|
|
|
}
|
|
|
|
|
2015-11-11 22:46:18 +05:00
|
|
|
|
|
|
|
template <>
|
|
|
|
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<0> (int nr) const
|
|
|
|
{
|
|
|
|
const Element0d & el = mesh->pointelements[nr];
|
|
|
|
|
|
|
|
Ng_Element ret;
|
|
|
|
ret.type = NG_PNT;
|
|
|
|
ret.index = el.index;
|
|
|
|
|
|
|
|
ret.points.num = 1;
|
|
|
|
ret.points.ptr = (int*)&el.pnum;
|
|
|
|
|
|
|
|
ret.vertices.num = 1;
|
|
|
|
ret.vertices.ptr = (int*)&el.pnum;
|
|
|
|
|
|
|
|
ret.edges.num = 0;
|
|
|
|
ret.edges.ptr = NULL;
|
|
|
|
|
|
|
|
ret.faces.num = 0;
|
|
|
|
ret.faces.ptr = NULL;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-01-07 16:42:39 +06:00
|
|
|
template <>
|
|
|
|
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<1> (int nr) const
|
|
|
|
{
|
|
|
|
const Segment & el = mesh->LineSegment (SegmentIndex(nr));
|
|
|
|
|
|
|
|
Ng_Element ret;
|
|
|
|
ret.type = NG_ELEMENT_TYPE(el.GetType());
|
2016-11-17 21:03:58 +05:00
|
|
|
if(mesh->GetDimension()==3)
|
2016-10-05 22:48:18 +05:00
|
|
|
ret.index = el.edgenr;
|
2016-11-17 21:03:58 +05:00
|
|
|
else
|
|
|
|
ret.index = el.si;
|
2016-10-10 22:58:14 +05:00
|
|
|
if (mesh->GetDimension() == 2)
|
|
|
|
ret.mat = mesh->GetBCNamePtr(el.si-1);
|
|
|
|
else
|
|
|
|
ret.mat = nullptr;
|
2014-01-07 16:42:39 +06:00
|
|
|
ret.points.num = el.GetNP();
|
|
|
|
ret.points.ptr = (int*)&(el[0]);
|
|
|
|
|
|
|
|
ret.vertices.num = 2;
|
|
|
|
ret.vertices.ptr = (int*)&(el[0]);
|
|
|
|
|
|
|
|
ret.edges.num = 1;
|
|
|
|
ret.edges.ptr = (T_EDGE2*)mesh->GetTopology().GetSegmentElementEdgesPtr (nr);
|
|
|
|
|
|
|
|
ret.faces.num = 0;
|
|
|
|
ret.faces.ptr = NULL;
|
|
|
|
|
2016-12-10 23:02:00 +05:00
|
|
|
if (mesh->GetDimension() == 2)
|
|
|
|
{
|
|
|
|
ret.facets.num = 1;
|
|
|
|
ret.facets.ptr = (int*)ret.edges.ptr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret.facets.num = 0;
|
|
|
|
ret.facets.ptr = nullptr;
|
|
|
|
// not working as long as vertices are 1-based
|
|
|
|
// ret.facets.num = 2;
|
|
|
|
// ret.facets.ptr = (int*)&(el[0]);
|
|
|
|
}
|
|
|
|
|
2015-06-12 16:45:42 +05:00
|
|
|
// ret.is_curved = mesh->GetCurvedElements().IsSegmentCurved(nr);
|
|
|
|
ret.is_curved = el.IsCurved();
|
2015-04-27 14:18:22 +05:00
|
|
|
|
2014-01-07 16:42:39 +06:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<2> (int nr) const
|
|
|
|
{
|
|
|
|
const Element2d & el = mesh->SurfaceElement (SurfaceElementIndex (nr));
|
|
|
|
|
|
|
|
Ng_Element ret;
|
|
|
|
ret.type = NG_ELEMENT_TYPE(el.GetType());
|
2016-02-27 00:30:40 +05:00
|
|
|
const FaceDescriptor & fd = mesh->GetFaceDescriptor(el.GetIndex());
|
|
|
|
ret.index = fd.BCProperty();
|
|
|
|
if (mesh->GetDimension() == 3)
|
|
|
|
ret.mat = &fd.GetBCName();
|
|
|
|
else
|
|
|
|
ret.mat = mesh -> GetMaterialPtr(ret.index);
|
2014-01-07 16:42:39 +06:00
|
|
|
ret.points.num = el.GetNP();
|
|
|
|
ret.points.ptr = (int*)&el[0];
|
|
|
|
|
|
|
|
ret.vertices.num = el.GetNV();
|
|
|
|
ret.vertices.ptr = (int*)&(el[0]);
|
|
|
|
|
|
|
|
ret.edges.num = MeshTopology::GetNEdges (el.GetType());
|
|
|
|
ret.edges.ptr = (T_EDGE2*)mesh->GetTopology().GetSurfaceElementEdgesPtr (nr);
|
|
|
|
|
|
|
|
ret.faces.num = MeshTopology::GetNFaces (el.GetType());
|
|
|
|
ret.faces.ptr = (T_FACE2*)mesh->GetTopology().GetSurfaceElementFacesPtr (nr);
|
|
|
|
|
2016-12-10 23:02:00 +05:00
|
|
|
if (mesh->GetDimension() == 3)
|
|
|
|
{
|
|
|
|
ret.facets.num = ret.faces.num;
|
|
|
|
ret.facets.ptr = (int*)ret.faces.ptr;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret.facets.num = ret.edges.num;
|
|
|
|
ret.facets.ptr = (int*)ret.edges.ptr;
|
|
|
|
}
|
2015-04-27 14:18:22 +05:00
|
|
|
ret.is_curved = el.IsCurved();
|
2014-01-07 16:42:39 +06:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <>
|
|
|
|
NGX_INLINE DLL_HEADER Ng_Element Ngx_Mesh :: GetElement<3> (int nr) const
|
|
|
|
{
|
|
|
|
const Element & el = mesh->VolumeElement (ElementIndex (nr));
|
|
|
|
|
|
|
|
Ng_Element ret;
|
|
|
|
ret.type = NG_ELEMENT_TYPE(el.GetType());
|
2014-12-04 17:39:12 +05:00
|
|
|
ret.index = el.GetIndex();
|
2016-02-27 00:30:40 +05:00
|
|
|
ret.mat = mesh -> GetMaterialPtr(ret.index);
|
2014-01-07 16:42:39 +06:00
|
|
|
ret.points.num = el.GetNP();
|
|
|
|
ret.points.ptr = (int*)&el[0];
|
|
|
|
|
|
|
|
ret.vertices.num = el.GetNV();
|
|
|
|
ret.vertices.ptr = (int*)&(el[0]);
|
|
|
|
|
|
|
|
ret.edges.num = MeshTopology::GetNEdges (el.GetType());
|
|
|
|
ret.edges.ptr = (T_EDGE2*)mesh->GetTopology().GetElementEdgesPtr (nr);
|
|
|
|
|
|
|
|
ret.faces.num = MeshTopology::GetNFaces (el.GetType());
|
|
|
|
ret.faces.ptr = (T_FACE2*)mesh->GetTopology().GetElementFacesPtr (nr);
|
|
|
|
|
2016-12-10 23:02:00 +05:00
|
|
|
ret.facets.num = ret.faces.num;
|
|
|
|
ret.facets.ptr = (int*)ret.faces.ptr;
|
|
|
|
|
2015-06-12 16:45:42 +05:00
|
|
|
ret.is_curved = el.IsCurved();
|
2014-01-07 16:42:39 +06:00
|
|
|
return ret;
|
|
|
|
}
|
2016-03-23 12:17:45 +05:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
template <> NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetNNodes<1> ()
|
|
|
|
{
|
|
|
|
return mesh->GetTopology().GetNEdges();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <> NGX_INLINE DLL_HEADER int Ngx_Mesh :: GetNNodes<2> ()
|
|
|
|
{
|
|
|
|
return mesh->GetTopology().GetNFaces();
|
|
|
|
}
|
|
|
|
|
|
|
|
template <> NGX_INLINE DLL_HEADER const Ng_Node<0> Ngx_Mesh :: GetNode<0> (int vnr) const
|
|
|
|
{
|
|
|
|
Ng_Node<0> node;
|
|
|
|
vnr++;
|
|
|
|
switch (mesh->GetDimension())
|
|
|
|
{
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
FlatArray<ElementIndex> ia = mesh->GetTopology().GetVertexElements(vnr);
|
|
|
|
node.elements.ne = ia.Size();
|
|
|
|
node.elements.ptr = (int*)&ia[0];
|
|
|
|
|
|
|
|
FlatArray<SurfaceElementIndex> bia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
|
|
|
|
node.bnd_elements.ne = bia.Size();
|
|
|
|
node.bnd_elements.ptr = (int*)&bia[0];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
FlatArray<SurfaceElementIndex> ia = mesh->GetTopology().GetVertexSurfaceElements(vnr);
|
|
|
|
node.elements.ne = ia.Size();
|
|
|
|
node.elements.ptr = (int*)&ia[0];
|
|
|
|
|
|
|
|
FlatArray<SegmentIndex> bia = mesh->GetTopology().GetVertexSegments(vnr);
|
|
|
|
node.bnd_elements.ne = bia.Size();
|
|
|
|
node.bnd_elements.ptr = (int*)&bia[0];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
FlatArray<SegmentIndex> ia = mesh->GetTopology().GetVertexSegments(vnr);
|
|
|
|
node.elements.ne = ia.Size();
|
|
|
|
node.elements.ptr = (int*)&ia[0];
|
|
|
|
|
2016-08-17 20:31:37 +05:00
|
|
|
FlatArray<int> bia = mesh->GetTopology().GetVertexPointElements(vnr);
|
|
|
|
node.bnd_elements.ne = bia.Size();
|
|
|
|
node.bnd_elements.ptr = (int*)&bia[0];
|
2016-03-23 12:17:45 +05:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
;
|
|
|
|
}
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <> NGX_INLINE DLL_HEADER const Ng_Node<1> Ngx_Mesh :: GetNode<1> (int nr) const
|
|
|
|
{
|
|
|
|
Ng_Node<1> node;
|
|
|
|
node.vertices.ptr = mesh->GetTopology().GetEdgeVerticesPtr(nr);
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
template <> NGX_INLINE DLL_HEADER const Ng_Node<2> Ngx_Mesh :: GetNode<2> (int nr) const
|
|
|
|
{
|
|
|
|
Ng_Node<2> node;
|
|
|
|
node.vertices.ptr = mesh->GetTopology().GetFaceVerticesPtr(nr);
|
|
|
|
node.vertices.nv = (node.vertices.ptr[3] == 0) ? 3 : 4;
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|