Freestyle: Fix for destructive view map modifications during chaining operations.

The view map is mostly treated as a read-only data structure by line stylization
operations (i.e., selection, chaining, splitting, sorting and stroke creation).  The
only exception is the chaining operation in some cases where insertion of extra
FEdge objects is necessary to ensure the continuity of underlying FEdges from
which a chain is constructed.

The present revision addresses the removal of extra FEdges so to keep the view
map clean and suitable for reuse in subsequent render frames.
This commit is contained in:
2014-10-02 15:26:53 +09:00
parent c946a450ed
commit c47682d6ab
5 changed files with 80 additions and 4 deletions

View File

@@ -63,6 +63,30 @@ ViewMap::~ViewMap()
_VEdges.clear();
}
void ViewMap::Clean()
{
vector<FEdge*> tmpEdges;
for (vector<ViewShape*>::iterator vs = _VShapes.begin(), vsend = _VShapes.end(); vs != vsend; vs++) {
vector<FEdge*>& edges = (*vs)->sshape()->getEdgeList();
for (vector<FEdge*>::iterator it = edges.begin(), itend = edges.end(); it != itend; it++) {
if ((*it)->isTemporary()) {
(*it)->setTemporary(false); // avoid being counted multiple times
tmpEdges.push_back(*it);
}
}
}
for (vector<FEdge*>::iterator it = tmpEdges.begin(), itend = tmpEdges.end(); it != itend; it++) {
for (vector<ViewShape*>::iterator vs = _VShapes.begin(), vsend = _VShapes.end(); vs != vsend; vs++) {
(*vs)->sshape()->RemoveEdge(*it);
}
(*it)->vertexA()->RemoveFEdge(*it);
(*it)->vertexB()->RemoveFEdge(*it);
delete (*it);
}
}
ViewShape *ViewMap::viewShape(unsigned id)
{
int index = _shapeIdToIndex[id];