From 8671021f4299169503be6c070fc59f0a75d4e522 Mon Sep 17 00:00:00 2001 From: WandererFan Date: Sat, 15 Jul 2017 20:37:38 -0400 Subject: [PATCH] Fix upside down GeomHatch on asymmetric faces --- src/Mod/TechDraw/App/DrawGeomHatch.cpp | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/Mod/TechDraw/App/DrawGeomHatch.cpp b/src/Mod/TechDraw/App/DrawGeomHatch.cpp index 0d71cebbcd..93d21db004 100644 --- a/src/Mod/TechDraw/App/DrawGeomHatch.cpp +++ b/src/Mod/TechDraw/App/DrawGeomHatch.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include #include @@ -198,7 +199,7 @@ std::vector DrawGeomHatch::getTrimmedLines(int i) //get the trimmed DrawViewPart* source = getSourceView(); if (!source || !source->hasGeometry()) { - Base::Console().Message("TRACE - DGH::getTrimmedLines - no source geometry\n"); + Base::Console().Log("DGH::getTrimmedLines - no source geometry\n"); return result; } return getTrimmedLines(source, m_lineSets,i, ScalePattern.getValue()); @@ -216,7 +217,6 @@ std::vector DrawGeomHatch::getTrimmedLines(DrawViewPart* source, std::v } TopoDS_Face face = extractFace(source,iface); - Bnd_Box bBox; BRepBndLib::Add(face, bBox); @@ -242,12 +242,13 @@ std::vector DrawGeomHatch::getTrimmedLines(DrawViewPart* source, std::v return result; } TopoDS_Shape common = mkCommon.Shape(); + + //save the boundingBox of hatch pattern Bnd_Box overlayBox; overlayBox.SetGap(0.0); BRepBndLib::Add(common, overlayBox); ls.setBBox(overlayBox); - //get resulting edges std::vector resultEdges; TopTools_IndexedMapOfShape mapOfEdges; @@ -396,7 +397,7 @@ std::vector DrawGeomHatch::getFaceOverlay(int fdx) DrawViewPart* source = getSourceView(); if (!source || !source->hasGeometry()) { - Base::Console().Message("TRACE - DGH::getFaceOverlay - no source geometry\n"); + Base::Console().Log("DGH::getFaceOverlay - no source geometry\n"); return result; } @@ -462,9 +463,24 @@ TopoDS_Face DrawGeomHatch::extractFace(DrawViewPart* source, int iface ) Base::Console().Log("INFO - DGH::extractFace - face creation failed\n"); return result; } - result = mkFace.Face(); + TopoDS_Face face = mkFace.Face(); + + TopoDS_Shape temp; + try { + // mirror about the Y axis + gp_Trsf mirrorTransform; + mirrorTransform.SetMirror( gp_Ax2(gp_Pnt(0.0,0.0,0.0), gp_Dir(0, 1, 0)) ); + BRepBuilderAPI_Transform mkTrf(face, mirrorTransform); + temp = mkTrf.Shape(); + } + catch (...) { + Base::Console().Log("DGH::extractFace - mirror failed.\n"); + return result; + } + result = TopoDS::Face(temp); return result; } + void DrawGeomHatch::getParameters(void) { Base::Reference hGrp = App::GetApplication().GetUserParameter()