Only export sharp edges of the triangle mesh.
Before this commit, "emphasized edges" were displayed as well as exported. An "emphasized edge" is an edge between triangles that come from different faces. They are helpful in the rendered display because they hint at the locations of faces, but not in the 2d export since they just clutter the drawing. After this commit, "emphasized edges" are displayed but "sharp edges" are exported. A "sharp edge" is an edge between triangles where the two matching vertexes have different normals, indicating a discontiguity in the surface. "Sharp edges" are also displayed while post-viewing the exported geometry.
This commit is contained in:
parent
7e6a11c958
commit
1bf7777815
@ -403,8 +403,17 @@ void Group::GenerateDisplayItems(void) {
|
|||||||
displayEdges.Clear();
|
displayEdges.Clear();
|
||||||
|
|
||||||
if(SS.GW.showEdges) {
|
if(SS.GW.showEdges) {
|
||||||
|
if(runningMesh.l.n > 0) {
|
||||||
|
// Triangle mesh only; no shell or emphasized edges.
|
||||||
|
runningMesh.MakeCertainEdgesInto(&displayEdges, SKdNode::EMPHASIZED_EDGES);
|
||||||
|
} else {
|
||||||
|
if(SS.exportMode) {
|
||||||
|
displayMesh.MakeCertainEdgesInto(&displayEdges, SKdNode::SHARP_EDGES);
|
||||||
|
} else {
|
||||||
runningShell.MakeEdgesInto(&displayEdges);
|
runningShell.MakeEdgesInto(&displayEdges);
|
||||||
runningMesh.MakeEmphasizedEdgesInto(&displayEdges);
|
displayMesh.MakeCertainEdgesInto(&displayEdges, SKdNode::EMPHASIZED_EDGES);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
37
src/mesh.cpp
37
src/mesh.cpp
@ -89,10 +89,9 @@ void SMesh::MakeEdgesInPlaneInto(SEdgeList *sel, Vector n, double d) {
|
|||||||
m.Clear();
|
m.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SMesh::MakeEmphasizedEdgesInto(SEdgeList *sel) {
|
void SMesh::MakeCertainEdgesInto(SEdgeList *sel, int type) {
|
||||||
SKdNode *root = SKdNode::From(this);
|
SKdNode *root = SKdNode::From(this);
|
||||||
root->MakeCertainEdgesInto(sel, SKdNode::EMPHASIZED_EDGES,
|
root->MakeCertainEdgesInto(sel, type, false, NULL, NULL);
|
||||||
false, NULL, NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -828,8 +827,11 @@ void SKdNode::FindEdgeOn(Vector a, Vector b, int cnt, bool coplanarIsInter,
|
|||||||
} else {
|
} else {
|
||||||
info->frontFacing = false;
|
info->frontFacing = false;
|
||||||
}
|
}
|
||||||
// And record the triangle's face
|
// Record the triangle
|
||||||
info->face = tr->meta.face;
|
info->tr = tr;
|
||||||
|
// And record which vertexes a and b correspond to
|
||||||
|
info->ai = a.Equals(tr->a) ? 0 : (a.Equals(tr->b) ? 1 : 2);
|
||||||
|
info->bi = b.Equals(tr->a) ? 0 : (b.Equals(tr->b) ? 1 : 2);
|
||||||
} else if(((a.Equals(tr->a) && b.Equals(tr->b)) ||
|
} else if(((a.Equals(tr->a) && b.Equals(tr->b)) ||
|
||||||
(a.Equals(tr->b) && b.Equals(tr->c)) ||
|
(a.Equals(tr->b) && b.Equals(tr->c)) ||
|
||||||
(a.Equals(tr->c) && b.Equals(tr->a))))
|
(a.Equals(tr->c) && b.Equals(tr->a))))
|
||||||
@ -946,7 +948,7 @@ void SKdNode::MakeCertainEdgesInto(SEdgeList *sel, int how,
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case EMPHASIZED_EDGES:
|
case EMPHASIZED_EDGES:
|
||||||
if(tr->meta.face != info.face && info.count == 1) {
|
if(tr->meta.face != info.tr->meta.face && info.count == 1) {
|
||||||
// The two triangles that join at this edge come from
|
// The two triangles that join at this edge come from
|
||||||
// different faces; either really different faces,
|
// different faces; either really different faces,
|
||||||
// or one is from a face and the other is zero (i.e.,
|
// or one is from a face and the other is zero (i.e.,
|
||||||
@ -955,6 +957,29 @@ void SKdNode::MakeCertainEdgesInto(SEdgeList *sel, int how,
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case SHARP_EDGES:
|
||||||
|
if(info.count == 1) {
|
||||||
|
Vector na0 = (j == 0) ? tr->an :
|
||||||
|
((j == 1) ? tr->bn : tr->cn);
|
||||||
|
Vector nb0 = (j == 0) ? tr->bn :
|
||||||
|
((j == 1) ? tr->cn : tr->an);
|
||||||
|
Vector na1 = (info.ai == 0) ? info.tr->an :
|
||||||
|
((info.ai == 1) ? info.tr->bn : info.tr->cn);
|
||||||
|
Vector nb1 = (info.bi == 0) ? info.tr->an :
|
||||||
|
((info.bi == 1) ? info.tr->bn : info.tr->cn);
|
||||||
|
na0 = na0.WithMagnitude(1.0);
|
||||||
|
nb0 = nb0.WithMagnitude(1.0);
|
||||||
|
na1 = na1.WithMagnitude(1.0);
|
||||||
|
nb1 = nb1.WithMagnitude(1.0);
|
||||||
|
if(!((na0.Equals(na1) && nb0.Equals(nb1)) ||
|
||||||
|
(na0.Equals(nb1) && nb0.Equals(na1)))) {
|
||||||
|
// The two triangles that join at this edge meet at a sharp
|
||||||
|
// angle. This implies they come from different faces.
|
||||||
|
sel->AddEdge(a, b);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default: oops();
|
default: oops();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -249,7 +249,7 @@ public:
|
|||||||
void MakeFromAssemblyOf(SMesh *a, SMesh *b);
|
void MakeFromAssemblyOf(SMesh *a, SMesh *b);
|
||||||
|
|
||||||
void MakeEdgesInPlaneInto(SEdgeList *sel, Vector n, double d);
|
void MakeEdgesInPlaneInto(SEdgeList *sel, Vector n, double d);
|
||||||
void MakeEmphasizedEdgesInto(SEdgeList *sel);
|
void MakeCertainEdgesInto(SEdgeList *sel, int type);
|
||||||
|
|
||||||
bool IsEmpty(void);
|
bool IsEmpty(void);
|
||||||
void RemapFaces(Group *g, int remap);
|
void RemapFaces(Group *g, int remap);
|
||||||
@ -273,7 +273,9 @@ public:
|
|||||||
int count;
|
int count;
|
||||||
bool frontFacing;
|
bool frontFacing;
|
||||||
bool intersectsMesh;
|
bool intersectsMesh;
|
||||||
uint32_t face;
|
STriangle *tr;
|
||||||
|
int ai;
|
||||||
|
int bi;
|
||||||
};
|
};
|
||||||
|
|
||||||
int which; // whether c is x, y, or z
|
int which; // whether c is x, y, or z
|
||||||
@ -297,7 +299,8 @@ public:
|
|||||||
NAKED_OR_SELF_INTER_EDGES = 100,
|
NAKED_OR_SELF_INTER_EDGES = 100,
|
||||||
SELF_INTER_EDGES = 200,
|
SELF_INTER_EDGES = 200,
|
||||||
TURNING_EDGES = 300,
|
TURNING_EDGES = 300,
|
||||||
EMPHASIZED_EDGES = 400
|
EMPHASIZED_EDGES = 400,
|
||||||
|
SHARP_EDGES = 500,
|
||||||
};
|
};
|
||||||
void MakeCertainEdgesInto(SEdgeList *sel, int how, bool coplanarIsInter,
|
void MakeCertainEdgesInto(SEdgeList *sel, int how, bool coplanarIsInter,
|
||||||
bool *inter, bool *leaky);
|
bool *inter, bool *leaky);
|
||||||
|
Loading…
Reference in New Issue
Block a user