mirror of
https://github.com/NGSolve/netgen.git
synced 2025-02-28 15:05:39 +05:00
Merge branch 'fix_occ_identified_edge_orientation' into 'master'
Keep consistent vertex numbering for identified edges See merge request ngsolve/netgen!547
This commit is contained in:
commit
2f4e52594e
@ -637,25 +637,44 @@ namespace netgen
|
||||
edge_params[i] = gi.dist;
|
||||
}
|
||||
|
||||
// reverse entries if we have decreasing parameters
|
||||
if(edge_params.Size()>=2 && edge_params[0] > edge_params.Last())
|
||||
for(auto i : Range((np-2)/2))
|
||||
{
|
||||
swap(edge_points[i], edge_points[np-3-i]);
|
||||
swap(edge_params[i], edge_params[np-3-i]);
|
||||
}
|
||||
|
||||
params.SetSize(edge_params.Size()+2);
|
||||
params[0] = 0.;
|
||||
params.Last() = 1.;
|
||||
|
||||
for(auto i : Range(edge_params))
|
||||
params[i+1] = edge_params[i];
|
||||
|
||||
if(edge_params.Size()>1)
|
||||
{
|
||||
// Just projecting (code below) does not work for closed edges (startp == endp)
|
||||
// In this case, there are at least 2 inner points which we use to check edge orientation
|
||||
bool reversed = edge_params[1] < edge_params[0];
|
||||
if(reversed)
|
||||
{
|
||||
params[0] = 1.0;
|
||||
params.Last() = 0.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
params.Last() = 1.0;
|
||||
params[0] = 0.0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for(size_t i : std::vector{0UL, pnums_primary.Size()-1})
|
||||
{
|
||||
auto p_mapped = trafo(mesh[pnums_primary[i]]);
|
||||
EdgePointGeomInfo gi;
|
||||
edge->ProjectPoint(p_mapped, &gi);
|
||||
params[i] = gi.dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pnums.SetSize(edge_points.Size() + 2);
|
||||
pnums[0] = startp;
|
||||
pnums.Last() = endp;
|
||||
|
||||
bool is_reversed = params.Last() < params[0];
|
||||
pnums[0] = is_reversed ? endp : startp;
|
||||
pnums.Last() = is_reversed ? startp : endp;
|
||||
|
||||
|
||||
for(auto i : Range(edge_points))
|
||||
@ -1034,7 +1053,7 @@ namespace netgen
|
||||
if(do_invert.IsMaybe())
|
||||
{
|
||||
auto n_src = src.GetNormal(mesh[sel[0]]);
|
||||
auto n_dist = dst.GetNormal(mesh[sel[0]]);
|
||||
auto n_dist = dst.GetNormal(trafo(mesh[sel[0]]));
|
||||
Mat<3> normal_matrix;
|
||||
CalcInverse(Trans(trafo.GetMatrix()), normal_matrix);
|
||||
do_invert = n_src * (normal_matrix * n_dist) < 0.0;
|
||||
|
@ -116,7 +116,11 @@ namespace netgen
|
||||
seg.epgeominfo[i].v = uv.Y();
|
||||
}
|
||||
|
||||
if(ORIENTATION == REVERSED)
|
||||
bool do_swap = ORIENTATION == REVERSED;
|
||||
if(seg.epgeominfo[1].dist < seg.epgeominfo[0].dist)
|
||||
do_swap = !do_swap;
|
||||
|
||||
if(do_swap)
|
||||
{
|
||||
swap(seg[0], seg[1]);
|
||||
swap(seg.epgeominfo[0].dist, seg.epgeominfo[1].dist);
|
||||
|
Loading…
Reference in New Issue
Block a user