The hidden line removal unnecessarily splits our edges, which
bloats the output file size. So reassemble the edges whenever possible. [git-p4: depot-paths = "//depot/solvespace/": change = 1935]
This commit is contained in:
parent
71adc0bf54
commit
22afc5ea15
@ -237,6 +237,8 @@ void SolveSpace::ExportLinesAndMesh(SEdgeList *sel, SMesh *sm,
|
|||||||
// Split the original edge against the mesh
|
// Split the original edge against the mesh
|
||||||
out.AddEdge(se->a, se->b);
|
out.AddEdge(se->a, se->b);
|
||||||
root->OcclusionTestLine(*se, &out, cnt);
|
root->OcclusionTestLine(*se, &out, cnt);
|
||||||
|
// the occlusion test splits unnecessarily; so fix those
|
||||||
|
out.MergeCollinearSegments(se->a, se->b);
|
||||||
cnt++;
|
cnt++;
|
||||||
// And add the results to our output
|
// And add the results to our output
|
||||||
SEdge *sen;
|
SEdge *sen;
|
||||||
|
35
polygon.cpp
35
polygon.cpp
@ -247,6 +247,41 @@ void SEdgeList::CullExtraneousEdges(void) {
|
|||||||
l.RemoveTagged();
|
l.RemoveTagged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// We have an edge list that contains only collinear edges, maybe with more
|
||||||
|
// splits than necessary. Merge any collinear segments that join.
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
static Vector LineStart, LineDirection;
|
||||||
|
static int ByTAlongLine(const void *av, const void *bv)
|
||||||
|
{
|
||||||
|
SEdge *a = (SEdge *)av,
|
||||||
|
*b = (SEdge *)bv;
|
||||||
|
|
||||||
|
double ta = (a->a.Minus(LineStart)).DivPivoting(LineDirection),
|
||||||
|
tb = (b->a.Minus(LineStart)).DivPivoting(LineDirection);
|
||||||
|
|
||||||
|
return (ta > tb) ? 1 : -1;
|
||||||
|
}
|
||||||
|
void SEdgeList::MergeCollinearSegments(Vector a, Vector b) {
|
||||||
|
LineStart = a;
|
||||||
|
LineDirection = b.Minus(a);
|
||||||
|
qsort(l.elem, l.n, sizeof(l.elem[0]), ByTAlongLine);
|
||||||
|
|
||||||
|
l.ClearTags();
|
||||||
|
int i;
|
||||||
|
for(i = 1; i < l.n; i++) {
|
||||||
|
SEdge *prev = &(l.elem[i-1]),
|
||||||
|
*now = &(l.elem[i]);
|
||||||
|
|
||||||
|
if((prev->b).Equals(now->a)) {
|
||||||
|
// The previous segment joins up to us; so merge it into us.
|
||||||
|
prev->tag = 1;
|
||||||
|
now->a = prev->a;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
l.RemoveTagged();
|
||||||
|
}
|
||||||
|
|
||||||
void SContour::AddPoint(Vector p) {
|
void SContour::AddPoint(Vector p) {
|
||||||
SPoint sp;
|
SPoint sp;
|
||||||
sp.tag = 0;
|
sp.tag = 0;
|
||||||
|
@ -27,6 +27,7 @@ public:
|
|||||||
SEdge *errorAt, bool keepDir);
|
SEdge *errorAt, bool keepDir);
|
||||||
int AnyEdgeCrossings(Vector a, Vector b, Vector *pi=NULL);
|
int AnyEdgeCrossings(Vector a, Vector b, Vector *pi=NULL);
|
||||||
void CullExtraneousEdges(void);
|
void CullExtraneousEdges(void);
|
||||||
|
void MergeCollinearSegments(Vector a, Vector b);
|
||||||
};
|
};
|
||||||
|
|
||||||
class SPoint {
|
class SPoint {
|
||||||
|
Loading…
Reference in New Issue
Block a user