set uv-params in quads correctly

Just projecting might lead to wrong results if a face contains edges
twice.
This commit is contained in:
Matthias Hochsteger 2022-10-07 18:32:53 +02:00
parent a9234a589a
commit d837d92f0f

View File

@ -817,44 +817,74 @@ namespace netgen
Transformation<3> trafo; Transformation<3> trafo;
if(face.IsConnectingCloseSurfaces()) if(face.IsConnectingCloseSurfaces())
for(const auto &s : segments)
{ {
auto edgenr = s.edgenr-1; Array<ArrayMem<int, 2>, PointIndex> p2seg(mesh.Points().Size());
auto & edge = *edges[edgenr]; for(int si : Range(segments))
ShapeIdentification *edge_mapping;
// have edgenr first time, search for closesurface identification
if(mapped_edges[edgenr] == UNINITIALIZED)
{ {
mapped_edges[edgenr] = NOT_MAPPED; const auto & s = segments[si];
for(auto & edge_ident : edge.identifications) p2seg[s[0]].Append(si);
p2seg[s[1]].Append(si);
}
for(const auto & s : segments)
{
auto edgenr = s.edgenr-1;
auto & edge = *edges[edgenr];
ShapeIdentification *edge_mapping;
// have edgenr first time, search for closesurface identification
if(mapped_edges[edgenr] == UNINITIALIZED)
{ {
if(edge_ident.type == Identifications::CLOSESURFACES && mapped_edges[edgenr] = NOT_MAPPED;
edge_ident.from->nr == edgenr && for(auto & edge_ident : edge.identifications)
relevant_edges.count(edge_ident.to->nr) > 0
)
{ {
trafo = edge_ident.trafo; if(edge_ident.type == Identifications::CLOSESURFACES &&
mapped_edges[edgenr] = edge_ident.to->nr; edge_ident.from->nr == edgenr &&
break; relevant_edges.count(edge_ident.to->nr) > 0
)
{
trafo = edge_ident.trafo;
mapped_edges[edgenr] = edge_ident.to->nr;
break;
}
} }
} }
}
// this edge has a closesurface mapping to another -> make connecting quad // this edge has a closesurface mapping to another -> make connecting quad
if(mapped_edges[edgenr] != NOT_MAPPED) if(mapped_edges[edgenr] != NOT_MAPPED)
{ {
Element2d sel(4); Element2d sel(4);
sel[0] = s[0]; sel[0] = s[0];
sel[1] = s[1]; sel[1] = s[1];
sel[2] = tree.Find(trafo(mesh[s[1]])); sel[2] = tree.Find(trafo(mesh[s[1]]));
sel[3] = tree.Find(trafo(mesh[s[0]])); sel[3] = tree.Find(trafo(mesh[s[0]]));
for(auto i : Range(4)) auto gis = sel.GeomInfo();
sel.GeomInfo()[i] = face.Project(mesh[sel[i]]); for(auto i : Range(2))
{
gis[i].u = s.epgeominfo[i].u;
gis[i].v = s.epgeominfo[i].v;
}
sel.SetIndex(face.nr+1); // find mapped segment to set PointGeomInfo correctly
mesh.AddSurfaceElement(sel); Segment s_other;
for(auto si_other : p2seg[sel[2]])
{
s_other = segments[si_other];
if(s_other[0] == sel[2] && s_other[1] == sel[3])
break;
if(s_other[0] == sel[3] && s_other[1] == sel[2])
break;
}
for(auto i : Range(2))
{
auto i_other = sel[i+2] == s_other[i] ? i : 1-i;
gis[i+2].u = s_other.epgeominfo[i_other].u;
gis[i+2].v = s_other.epgeominfo[i_other].v;
}
sel.SetIndex(face.nr+1);
mesh.AddSurfaceElement(sel);
}
} }
} }
else else