From ce9f4f199a4b4df7045a65460dfbb508a06a4644 Mon Sep 17 00:00:00 2001 From: WandererFan Date: Sat, 15 Oct 2016 19:50:42 -0400 Subject: [PATCH] Fix XAxis orientation Remove need for XAxisDirection property --- src/Mod/TechDraw/App/DrawUtil.cpp | 4 ++++ src/Mod/TechDraw/App/DrawUtil.h | 1 + src/Mod/TechDraw/App/GeometryObject.cpp | 24 ++++++++++++++++-------- 3 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawUtil.cpp b/src/Mod/TechDraw/App/DrawUtil.cpp index 4b322e0f1..25a44dd47 100644 --- a/src/Mod/TechDraw/App/DrawUtil.cpp +++ b/src/Mod/TechDraw/App/DrawUtil.cpp @@ -197,4 +197,8 @@ void DrawUtil::dumpEdge(char* label, int i, TopoDS_Edge e) Base::Console().Message("%s edge:%d start:(%.3f,%.3f,%.3f) end:(%.2f,%.3f,%.3f)\n",label,i, vStart.X(),vStart.Y(),vStart.Z(),vEnd.X(),vEnd.Y(),vEnd.Z()); } +const char* DrawUtil::printBool(bool b) +{ + return (b ? "True" : "False"); +} //================================== diff --git a/src/Mod/TechDraw/App/DrawUtil.h b/src/Mod/TechDraw/App/DrawUtil.h index e163426d8..42484925e 100644 --- a/src/Mod/TechDraw/App/DrawUtil.h +++ b/src/Mod/TechDraw/App/DrawUtil.h @@ -49,6 +49,7 @@ class TechDrawExport DrawUtil { static void countFaces(const char* label, const TopoDS_Shape& s); static void countWires(const char* label, const TopoDS_Shape& s); static void countEdges(const char* label, const TopoDS_Shape& s); + static const char* printBool(bool b); }; } //end namespace TechDraw diff --git a/src/Mod/TechDraw/App/GeometryObject.cpp b/src/Mod/TechDraw/App/GeometryObject.cpp index 76b5b1662..752dcd650 100644 --- a/src/Mod/TechDraw/App/GeometryObject.cpp +++ b/src/Mod/TechDraw/App/GeometryObject.cpp @@ -80,8 +80,6 @@ struct EdgePoints { TopoDS_Edge edge; }; -//debugging routine signatures -const char* _printBool(bool b); GeometryObject::GeometryObject(DrawViewPart* parent) : Tolerance(0.05f), @@ -166,6 +164,18 @@ void GeometryObject::projectShape(const TopoDS_Shape& input, const Base::Vector3d& direction, const Base::Vector3d& xAxis) { + Base::Vector3d stdZ(0.0,0.0,1.0); + Base::Vector3d flipDirection(direction.x,-direction.y,direction.z); + Base::Vector3d cross = flipDirection; + //special cases + if (flipDirection == stdZ) { + cross = Base::Vector3d(1.0,0.0,0.0); + } else if (flipDirection == (stdZ * -1.0)) { + cross = Base::Vector3d(1.0,0.0,0.0); + } else { + cross.Normalize(); + cross = cross.Cross(stdZ); + } // Clear previous Geometry clear(); @@ -176,12 +186,11 @@ void GeometryObject::projectShape(const TopoDS_Shape& input, brep_hlr = new HLRBRep_Algo(); brep_hlr->Add(input, m_isoCount); - // Project the shape into view space with the object's centroid - // at the origin. gp_Ax2 viewAxis; viewAxis = gp_Ax2(inputCenter, - gp_Dir(direction.x, direction.y, direction.z), - gp_Dir(xAxis.x, xAxis.y, xAxis.z)); + gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z), +// gp_Dir(xAxis.x, -xAxis.y, xAxis.z)); + gp_Dir(cross.x, cross.y, cross.z)); HLRAlgo_Projector projector( viewAxis ); brep_hlr->Projector(projector); brep_hlr->Update(); @@ -687,7 +696,7 @@ gp_Pnt TechDrawGeometry::findCentroid(const TopoDS_Shape &shape, gp_Ax2 viewAxis; viewAxis = gp_Ax2(gp_Pnt(0, 0, 0), gp_Dir(direction.x, -direction.y, direction.z), - gp_Dir(xAxis.x, -xAxis.y, xAxis.z)); // Y invert warning! + gp_Dir(xAxis.x, -xAxis.y, xAxis.z)); gp_Trsf tempTransform; tempTransform.SetTransformation(viewAxis); @@ -719,7 +728,6 @@ TopoDS_Shape TechDrawGeometry::mirrorShape(const TopoDS_Shape &input, try { // Make tempTransform scale the object around it's centre point and // mirror about the Y axis - // TODO: is this really always Y axis? sb whatever is vertical direction in projection? gp_Trsf tempTransform; tempTransform.SetScale(inputCenter, scale); gp_Trsf mirrorTransform;