mirror of
https://github.com/NGSolve/netgen.git
synced 2024-12-24 21:10:33 +05:00
csg2d - fix CleanupResult
Check for more edge properties (maxh, bc etc.) before removing "intermediate" and unnecessary vertices
This commit is contained in:
parent
b855b419da
commit
45059fa7af
@ -1292,21 +1292,39 @@ void CreateResult(Solid2d & sp, Solid2d & sr, bool UNION)
|
||||
}
|
||||
}
|
||||
|
||||
// Check if vertex v is not necessary (i.e. is on the line v->prev, v->next and has same info as v->prev and no pinfo
|
||||
bool canRemoveVertex( Vertex * v )
|
||||
{
|
||||
return false;
|
||||
if(v->spline)
|
||||
return false;
|
||||
if(v->pinfo.name != POINT_NAME_DEFAULT)
|
||||
return false;
|
||||
if(v->pinfo.maxh != MAXH_DEFAULT)
|
||||
return false;
|
||||
|
||||
if(v->info.bc != v->prev->info.bc || v->info.maxh != v->prev->info.maxh )
|
||||
return false;
|
||||
|
||||
if(fabs(Area(*v->prev,*v,*v->next)) >= EPSILON)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void CleanUpResult(Solid2d & sr)
|
||||
{
|
||||
auto & RR = sr.polys;
|
||||
for (Loop& R : RR)
|
||||
{
|
||||
while ( (R.first.get() != NULL) && (fabs(Area(*R.first->prev,*R.first,*R.first->next)) < EPSILON) )
|
||||
while ( (R.first.get() != NULL) && canRemoveVertex(R.first.get()))
|
||||
R.Remove(R.first.get());
|
||||
|
||||
if (R.first.get() != NULL)
|
||||
for (Vertex* V : R.Vertices(ALL))
|
||||
if (!V->spline && !V->prev->spline && fabs(Area(*V->prev,*V,*V->next)) < EPSILON)
|
||||
{
|
||||
if (canRemoveVertex(V))
|
||||
R.Remove(V);
|
||||
}
|
||||
}
|
||||
for (int i = RR.Size()-1; i>=0; i--)
|
||||
if(RR[i].Size()==0)
|
||||
RR.RemoveElement(i);
|
||||
|
Loading…
Reference in New Issue
Block a user