Change fudging when I select edges to generate a section from the

shell. That seems less prone generating stray lines, though it does
sometimes generate gaps.

[git-p4: depot-paths = "//depot/solvespace/": change = 1876]
This commit is contained in:
Jonathan Westhues 2008-09-08 21:19:54 -08:00
parent 816a1ee8b4
commit 69cf8d6484
3 changed files with 12 additions and 10 deletions

2
dsc.h
View File

@ -47,7 +47,7 @@ public:
Vector n2, double d2);
double Element(int i);
bool Equals(Vector v);
bool Equals(Vector v, double tol=LENGTH_EPS);
bool EqualsExactly(Vector v);
Vector Plus(Vector b);
Vector Minus(Vector b);

View File

@ -588,9 +588,9 @@ void SKdNode::FindEdgeOn(Vector a, Vector b, int *n, int *nOther,
if(tr->tag == cnt) continue;
if((a.EqualsExactly(tr->b) && b.EqualsExactly(tr->a)) ||
(a.EqualsExactly(tr->c) && b.EqualsExactly(tr->b)) ||
(a.EqualsExactly(tr->a) && b.EqualsExactly(tr->c)))
if((a.Equals(tr->b, KDTREE_EPS) && b.Equals(tr->a, KDTREE_EPS)) ||
(a.Equals(tr->c, KDTREE_EPS) && b.Equals(tr->b, KDTREE_EPS)) ||
(a.Equals(tr->a, KDTREE_EPS) && b.Equals(tr->c, KDTREE_EPS)))
{
(*n)++;
if(tr->meta.face != m.face) {
@ -643,7 +643,9 @@ void SKdNode::MakeCertainEdgesInto(SEdgeList *sel, bool emphasized) {
FindEdgeOn(a, b, &n, &nOther, tr->meta, cnt++);
if(n != 1) {
if(!emphasized) {
if(n == 0) sel->AddEdge(a, b);
if(n == 0 && (a.Minus(b).Magnitude()) > KDTREE_EPS) {
sel->AddEdge(a, b);
}
} else {
// dbp("hanging: n=%d (%.3f %.3f %.3f) (%.3f %.3f %.3f)",
// n, CO(a), CO(b));

View File

@ -290,13 +290,13 @@ double Vector::Element(int i) {
}
}
bool Vector::Equals(Vector v) {
bool Vector::Equals(Vector v, double tol) {
// Quick axis-aligned tests before going further
double dx = v.x - x; if(dx < -LENGTH_EPS || dx > LENGTH_EPS) return false;
double dy = v.y - y; if(dy < -LENGTH_EPS || dy > LENGTH_EPS) return false;
double dz = v.z - z; if(dz < -LENGTH_EPS || dz > LENGTH_EPS) return false;
double dx = v.x - x; if(dx < -tol || dx > tol) return false;
double dy = v.y - y; if(dy < -tol || dy > tol) return false;
double dz = v.z - z; if(dz < -tol || dz > tol) return false;
return (this->Minus(v)).MagSquared() < LENGTH_EPS*LENGTH_EPS;
return (this->Minus(v)).MagSquared() < tol*tol;
}
bool Vector::EqualsExactly(Vector v) {