Commit 98ad17c6 authored by mark's avatar mark
Browse files

BUG: indexing in extendedEdgeMesh::add fails (fixes #448)

- 1st problem arises when there are edges, but edgeNormals is empty.
  The UIndirectList fails (zero elements, non-zero addressing)

- further problem occurs if there is a mismatch in the number of edges
  and edges normals (incorrect indexing on loop).
parent 7e16d36a
......@@ -1260,20 +1260,36 @@ void Foam::extendedEdgeMesh::add(const extendedEdgeMesh& fem)
// ~~~~~~~
// Combine normals
DynamicField<point> newNormals(normals().size()+fem.normals().size());
DynamicField<point> newNormals
(
normals().size()
+ fem.normals().size()
);
newNormals.append(normals());
newNormals.append(fem.normals());
// Combine and re-index into newNormals
labelListList newEdgeNormals(edgeNormals().size()+fem.edgeNormals().size());
UIndirectList<labelList>(newEdgeNormals, reverseEdgeMap) =
edgeNormals();
UIndirectList<labelList>(newEdgeNormals, reverseFemEdgeMap) =
fem.edgeNormals();
forAll(reverseFemEdgeMap, i)
{
label mapI = reverseFemEdgeMap[i];
labelListList newEdgeNormals
(
edgeNormals().size()
+ fem.edgeNormals().size()
);
UIndirectList<labelList>
(
newEdgeNormals,
SubList<label>(reverseEdgeMap, edgeNormals().size())
) = edgeNormals();
UIndirectList<labelList>
(
newEdgeNormals,
SubList<label>(reverseFemEdgeMap, fem.edgeNormals().size())
) = fem.edgeNormals();
forAll(fem.edgeNormals(), i)
{
const label mapI = reverseFemEdgeMap[i];
labelList& en = newEdgeNormals[mapI];
forAll(en, j)
{
......@@ -1300,9 +1316,10 @@ void Foam::extendedEdgeMesh::add(const extendedEdgeMesh& fem)
newFeaturePointNormals,
SubList<label>(reverseFemPointMap, fem.featurePointNormals().size())
) = fem.featurePointNormals();
forAll(fem.featurePointNormals(), i)
{
label mapI = reverseFemPointMap[i];
const label mapI = reverseFemPointMap[i];
labelList& fn = newFeaturePointNormals[mapI];
forAll(fn, j)
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment