From ae601873226fda93de6cc40834387a3baf833895 Mon Sep 17 00:00:00 2001 From: EvilSpirit Date: Sat, 7 May 2016 16:30:26 +0600 Subject: [PATCH] DXF: export the right supplementary angle. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this commit, e.g. a 120° angle could be exported as its supplementary 60° angle but it would still say 120° in the label. After this commit, the right angle is selected in DXF-based software. Similarly, it roundtrips through SolveSpace correctly. --- src/exportvector.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/exportvector.cpp b/src/exportvector.cpp index dc450db..9ed8817 100644 --- a/src/exportvector.cpp +++ b/src/exportvector.cpp @@ -385,6 +385,33 @@ public: &skew); if(!skew) ref = pi.Plus(c->disp.offset); + Vector norm = da.Cross(db); + Vector dna = norm.Cross(da).WithMagnitude(1.0); + + double thetaf = acos(da.DirectionCosineWith(db)); + + // Calculate median + Vector m = da.WithMagnitude(1.0).ScaledBy(cos(thetaf/2)).Plus( + dna.ScaledBy(sin(thetaf/2))); + Vector rm = ref.Minus(pi); + + // Test which side we have to place an arc + if(m.Dot(rm) < 0) { + da = da.ScaledBy(-1); dna = dna.ScaledBy(-1); + db = db.ScaledBy(-1); + } + + Vector bisect = da.WithMagnitude(1.0).ScaledBy(cos(thetaf / 2.0)).Plus( + dna.ScaledBy(sin(thetaf / 2.0))); + + ref = pi.Plus(bisect.WithMagnitude(c->disp.offset.Magnitude())); + + // Get lines agian to write exact line. + a0 = a->VectorGetStartPoint(); + b0 = b->VectorGetStartPoint(); + da = a->VectorGetNum(); + db = b->VectorGetNum(); + writeAngularDimension( xfrm(a0), xfrm(a0.Plus(da)), xfrm(b0), xfrm(b0.Plus(db)), xfrm(ref), xfrm(ref), c->Label(), c->GetStyle(), c->valA);