diff --git a/src/Mod/TechDraw/App/DrawGeomHatch.cpp b/src/Mod/TechDraw/App/DrawGeomHatch.cpp index 5b42cfa659..6d50658a66 100644 --- a/src/Mod/TechDraw/App/DrawGeomHatch.cpp +++ b/src/Mod/TechDraw/App/DrawGeomHatch.cpp @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include @@ -73,7 +74,9 @@ #include "DrawPage.h" #include "DrawViewPart.h" #include "DrawViewSection.h" +#include "DrawViewDetail.h" #include "DrawGeomHatch.h" +#include "GeometryObject.h" #include // generated from DrawGeomHatchPy.xml @@ -229,9 +232,38 @@ std::vector DrawGeomHatch::getTrimmedLines(int i) //get the trimmed } /* static */ +std::vector DrawGeomHatch::getTrimmedLinesSection(DrawViewSection* source, + std::vector lineSets, + TopoDS_Face f, + double scale ) +{ + std::vector result; + TopoDS_Face tFace = f; + tFace = TopoDS::Face(GeometryObject::invertGeometry(tFace)); + result = getTrimmedLines(source, + lineSets, + tFace, + scale ); + return result; +} + //! get hatch lines trimmed to face outline std::vector DrawGeomHatch::getTrimmedLines(DrawViewPart* source, std::vector lineSets, int iface, double scale ) { + TopoDS_Face face = extractFace(source,iface); + std::vector result = getTrimmedLines(source, + lineSets, + face, + scale ); + return result; +} + +std::vector DrawGeomHatch::getTrimmedLines(DrawViewPart* source, + std::vector lineSets, + TopoDS_Face f, + double scale ) +{ + (void)source; std::vector result; if (lineSets.empty()) { @@ -239,7 +271,7 @@ std::vector DrawGeomHatch::getTrimmedLines(DrawViewPart* source, std::v return result; } - TopoDS_Face face = extractFace(source,iface); + TopoDS_Face face = f; Bnd_Box bBox; BRepBndLib::Add(face, bBox); @@ -251,14 +283,14 @@ std::vector DrawGeomHatch::getTrimmedLines(DrawViewPart* source, std::v //make Compound for this linespec BRep_Builder builder; - TopoDS_Compound Comp; - builder.MakeCompound(Comp); + TopoDS_Compound grid; + builder.MakeCompound(grid); for (auto& c: candidates) { - builder.Add(Comp, c); + builder.Add(grid, c); } //Common(Compound,Face) - BRepAlgoAPI_Common mkCommon(face, Comp); + BRepAlgoAPI_Common mkCommon(face, grid); if ((!mkCommon.IsDone()) || (mkCommon.Shape().IsNull()) ) { Base::Console().Log("INFO - DGH::getTrimmedLines - Common creation failed\n"); @@ -302,6 +334,7 @@ std::vector DrawGeomHatch::getTrimmedLines(DrawViewPart* source, std::v } return result; } + /* static */ std::vector DrawGeomHatch::makeEdgeOverlay(PATLineSpec hl, Bnd_Box b, double scale) { @@ -458,19 +491,7 @@ TopoDS_Face DrawGeomHatch::extractFace(DrawViewPart* source, int iface ) { TopoDS_Face result; - //is source a section? - DrawViewSection* section = dynamic_cast(source); - bool usingSection = false; - if (section != nullptr) { - usingSection = true; - } - - std::vector faceWires; - if (usingSection) { - faceWires = section->getWireForFace(iface); - } else { - faceWires = source->getWireForFace(iface); - } + std::vector faceWires = source->getWireForFace(iface); //build face(s) from geometry gp_Pnt gOrg(0.0,0.0,0.0); diff --git a/src/Mod/TechDraw/App/DrawGeomHatch.h b/src/Mod/TechDraw/App/DrawGeomHatch.h index 7945054a8a..630c928619 100644 --- a/src/Mod/TechDraw/App/DrawGeomHatch.h +++ b/src/Mod/TechDraw/App/DrawGeomHatch.h @@ -41,6 +41,7 @@ class BaseGeom; namespace TechDraw { class DrawViewPart; +class DrawViewSection; class PATLineSpec; class LineSet; class DashSet; @@ -74,6 +75,14 @@ public: std::vector getFaceOverlay(int i = 0); std::vector getTrimmedLines(int i = 0); static std::vector getTrimmedLines(DrawViewPart* dvp, std::vector lineSets, int iface, double scale); + static std::vector getTrimmedLines(DrawViewPart* source, + std::vector lineSets, + TopoDS_Face face, + double scale ); + static std::vector getTrimmedLinesSection(DrawViewSection* source, + std::vector lineSets, + TopoDS_Face f, + double scale ); static std::vector makeEdgeOverlay(PATLineSpec hl, Bnd_Box bBox, double scale); static TopoDS_Edge makeLine(Base::Vector3d s, Base::Vector3d e); diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index 3d2bb16efa..ea0f7844f6 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -31,10 +31,12 @@ #include #include //#include +#include #include #include #include #include +#include #include #include #include @@ -353,11 +355,13 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void) void DrawViewSection::sectionExec(TopoDS_Shape baseShape) { +// cut base shape with tool //is SectionOrigin valid? Bnd_Box centerBox; BRepBndLib::Add(baseShape, centerBox); centerBox.SetGap(0.0); +// make tool gp_Pln pln = getSectionPlane(); gp_Dir gpNormal = pln.Axis().Direction(); Base::Vector3d orgPnt = SectionOrigin.getValue(); @@ -381,6 +385,7 @@ void DrawViewSection::sectionExec(TopoDS_Shape baseShape) BRepBuilderAPI_Copy BuilderCopy(baseShape); TopoDS_Shape myShape = BuilderCopy.Shape(); +// perform cut BRep_Builder builder; TopoDS_Compound pieces; builder.MakeCompound(pieces); @@ -399,15 +404,16 @@ void DrawViewSection::sectionExec(TopoDS_Shape baseShape) builder.Add(pieces, cut); outdb++; } - +// pieces contains result of cutting each subshape in baseShape with tool TopoDS_Shape rawShape = pieces; if (debugSection()) { BRepTools::Write(myShape, "DVSCopy.brep"); //debug BRepTools::Write(aProjFace, "DVSFace.brep"); //debug BRepTools::Write(prism, "DVSTool.brep"); //debug - BRepTools::Write(rawShape, "DVSResult.brep"); //debug + BRepTools::Write(pieces, "DVSPieces.brep"); //debug } +// check for error in cut Bnd_Box testBox; BRepBndLib::Add(rawShape, testBox); testBox.SetGap(0.0); @@ -416,6 +422,7 @@ void DrawViewSection::sectionExec(TopoDS_Shape baseShape) return; } +// build display geometry as in DVP, with minor mods gp_Ax2 viewAxis; TopoDS_Shape centeredShape; try { @@ -452,16 +459,18 @@ void DrawViewSection::sectionExec(TopoDS_Shape baseShape) getNameInDocument(),e1.GetMessageString()); return; } +//display geometry for cut shape is in geometryObject as in DVP - try { +// build section face geometry +// try { //sectionFaces = build sectionFaces(rawShape); - TopoDS_Compound sectionCompound = findSectionPlaneIntersections(rawShape); + TopoDS_Compound faceIntersections = findSectionPlaneIntersections(rawShape); Base::Vector3d sectionOrigin = SectionOrigin.getValue(); - TopoDS_Shape centeredShape = TechDraw::moveShape(sectionCompound, + TopoDS_Shape centeredShapeF = TechDraw::moveShape(faceIntersections, sectionOrigin * -1.0); - TopoDS_Shape scaledSection = TechDraw::scaleShape(centeredShape, + TopoDS_Shape scaledSection = TechDraw::scaleShape(centeredShapeF, getScale()); if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) { scaledSection = TechDraw::rotateShape(scaledSection, @@ -471,54 +480,61 @@ void DrawViewSection::sectionExec(TopoDS_Shape baseShape) if (debugSection()) { BRepTools::Write(scaledSection, "DVSScaledFaces.brep"); //debug } - - sectionFaceWires.clear(); - TopoDS_Compound newFaces; - BRep_Builder builder; - builder.MakeCompound(newFaces); - TopExp_Explorer expl(scaledSection, TopAbs_FACE); - int idb = 0; - for (; expl.More(); expl.Next()) { - const TopoDS_Face& face = TopoDS::Face(expl.Current()); - TopoDS_Face pFace = projectFace(face, - viewAxis); - if (!pFace.IsNull()) { - if (debugSection()) { - std::stringstream ss; - ss << "DVSScaledFace" << idb << ".brep" ; - std::string faceName = ss.str(); - BRepTools::Write(pFace, faceName.c_str()); //debug - std::stringstream ss2; - ss2 << "DVSOuter" << idb << ".brep" ; - TopoDS_Wire owdb = ShapeAnalysis::OuterWire(pFace); - std::string wireName = ss2.str(); - BRepTools::Write(owdb, wireName.c_str()); //debug - } - TopoDS_Wire ow = ShapeAnalysis::OuterWire(pFace); - //this check helps prevent "ghost" faces - BRepCheck_Wire chkWire(ow); - TopoDS_Edge e1, e2; - BRepCheck_Status status = chkWire.SelfIntersect(pFace, e1, e2); - if (status == BRepCheck_NoError) { - builder.Add(newFaces,pFace); - sectionFaceWires.push_back(ShapeAnalysis::OuterWire(pFace)); - } - } - idb++; +// scaledSection is compound of TopoDS_Face intersections, but aligned to pln(origin, sectionNormal) +// needs to be aligned to pln (origin, stdZ); + gp_Ax3 R3; + gp_Ax2 projCS = getSectionCS(); + gp_Ax3 proj3 = gp_Ax3(gp_Pnt(0.0, 0.0, 0.0), + projCS.Direction(), + projCS.XDirection()); + gp_Trsf fromR3; + fromR3.SetTransformation(R3, proj3); + BRepBuilderAPI_Transform xformer(fromR3); + xformer.Perform(scaledSection, true); + if (xformer.IsDone()) { + sectionFaces = TopoDS::Compound(xformer.Shape()); +// BRepTools::Write(sectionFaces, "DVSXFaces.brep"); //debug + } else { + Base::Console().Message("DVS::sectionExec - face xform failed\n"); } - //return newFaces; - sectionFaces = newFaces; - } - catch (Standard_Failure& e2) { - Base::Console().Warning("DVS::execute - failed to build section faces for %s - %s **\n", - getNameInDocument(),e2.GetMessageString()); - return; - } + sectionFaces = TopoDS::Compound(GeometryObject::invertGeometry(sectionFaces)); //handle Qt -y + + //turn section faces into something we can draw + tdSectionFaces.clear(); + TopExp_Explorer sectionExpl(sectionFaces, TopAbs_FACE); + int iface = 0; + for (; sectionExpl.More(); sectionExpl.Next()) { + iface++; + const TopoDS_Face& face = TopoDS::Face(sectionExpl.Current()); + TechDraw::Face* sectionFace = new TechDraw::Face(); + TopExp_Explorer expFace(face, TopAbs_WIRE); + int iwire = 0; + for ( ; expFace.More(); expFace.Next()) { + iwire++; + TechDraw::Wire* w = new TechDraw::Wire(); + const TopoDS_Wire& wire = TopoDS::Wire(expFace.Current()); + int iedge = 0; + TopExp_Explorer expWire(wire, TopAbs_EDGE); + for ( ; expWire.More(); expWire.Next()) { + iedge++; + const TopoDS_Edge& edge = TopoDS::Edge(expWire.Current()); + TechDraw::BaseGeom* e = BaseGeom::baseFactory(edge); + if (e != nullptr) { + w->geoms.push_back(e); + } + } + sectionFace->wires.push_back(w); + } + tdSectionFaces.push_back(sectionFace); + } + +// add cosmetic entities to view addCosmeticVertexesToGeom(); addCosmeticEdgesToGeom(); addCenterLinesToGeom(); +// add landmark dim reference points to view addReferencesToGeom(); } @@ -561,123 +577,10 @@ TopoDS_Compound DrawViewSection::findSectionPlaneIntersections(const TopoDS_Shap } } } +// BRepTools::Write(result, "DVSIntersect.brep"); //debug return result; } -//! get display geometry for Section faces -std::vector DrawViewSection::getFaceGeometry() -{ - std::vector result; - TopoDS_Compound c = sectionFaces; - TopExp_Explorer faces(c, TopAbs_FACE); - for (; faces.More(); faces.Next()) { - TechDraw::Face* f = new TechDraw::Face(); - const TopoDS_Face& face = TopoDS::Face(faces.Current()); - TopExp_Explorer wires(face, TopAbs_WIRE); - for (; wires.More(); wires.Next()) { - TechDraw::Wire* w = new TechDraw::Wire(); - const TopoDS_Wire& wire = TopoDS::Wire(wires.Current()); - TopExp_Explorer edges(wire, TopAbs_EDGE); - for (; edges.More(); edges.Next()) { - const TopoDS_Edge& edge = TopoDS::Edge(edges.Current()); - //dumpEdge("edge",edgeCount,edge); - TechDraw::BaseGeom* base = TechDraw::BaseGeom::baseFactory(edge); - w->geoms.push_back(base); - } - f->wires.push_back(w); - } - result.push_back(f); - } - return result; -} - -//! project a single face using HLR - used for section faces -TopoDS_Face DrawViewSection::projectFace(const TopoDS_Shape &face, - const gp_Ax2 CS) -{ -// Base::Console().Message("DVS::projectFace()\n"); - if(face.IsNull()) { - throw Base::ValueError("DrawViewSection::projectFace - input Face is NULL"); - } - - TopoDS_Shape hardEdges = geometryObject->projectFace(face, CS); - - std::vector faceEdges; - TopExp_Explorer expl(hardEdges, TopAbs_EDGE); - int i; - for (i = 1 ; expl.More(); expl.Next(),i++) { - const TopoDS_Edge& edge = TopoDS::Edge(expl.Current()); - if (edge.IsNull()) { - Base::Console().Log("INFO - DVS::projectFace - hard edge: %d is NULL\n",i); - continue; - } - faceEdges.push_back(edge); - } - //TODO: verify that outline edges aren't required - //if edge is both hard & outline, it will be duplicated? are hard edges enough? -// TopExp_Explorer expl2(outEdges, TopAbs_EDGE); -// for (i = 1 ; expl2.More(); expl2.Next(),i++) { -// const TopoDS_Edge& edge = TopoDS::Edge(expl2.Current()); -// if (edge.IsNull()) { -// Base::Console().Log("INFO - GO::projectFace - outline edge: %d is NULL\n",i); -// continue; -// } -// bool addEdge = true; -// //is edge already in faceEdges? maybe need to use explorer for this for IsSame to work? -// for (auto& e:faceEdges) { -// if (e.IsPartner(edge)) { -// addEdge = false; -// Base::Console().Message("TRACE - DVS::projectFace - skipping an edge 1\n"); -// } -// } -// expl.ReInit(); -// for (; expl.More(); expl.Next()){ -// const TopoDS_Edge& eHard = TopoDS::Edge(expl.Current()); -// if (eHard.IsPartner(edge)) { -// addEdge = false; -// Base::Console().Message("TRACE - DVS::projectFace - skipping an edge 2\n"); -// } -// } -// if (addEdge) { -// faceEdges.push_back(edge); -// } -// } - - TopoDS_Face projectedFace; - - if (faceEdges.empty()) { - Base::Console().Log("LOG - DVS::projectFace - no faceEdges\n"); - return projectedFace; - } - - -//recreate the wires for this single face - EdgeWalker ew; - ew.loadEdges(faceEdges); - bool success = ew.perform(); - if (success) { - std::vector fw = ew.getResultNoDups(); - - if (!fw.empty()) { - std::vector sortedWires = ew.sortStrip(fw, true); - if (sortedWires.empty()) { - return projectedFace; - } - - BRepBuilderAPI_MakeFace mkFace(sortedWires.front(),true); //true => only want planes? - std::vector::iterator itWire = ++sortedWires.begin(); //starting with second face - for (; itWire != sortedWires.end(); itWire++) { - mkFace.Add(*itWire); - } - projectedFace = mkFace.Face(); - } - } else { - Base::Console().Warning("DVS::projectFace - input is not planar graph. No face detection\n"); - } - return projectedFace; -} - - //calculate the ends of the section line in BaseView's coords std::pair DrawViewSection::sectionLineEnds(void) { @@ -873,14 +776,22 @@ std::vector DrawViewSection::getDrawableLines(int i) { // Base::Console().Message("DVS::getDrawableLines(%d) - lineSets: %d\n", i, m_lineSets.size()); std::vector result; - result = DrawGeomHatch::getTrimmedLines(this,m_lineSets,i,HatchScale.getValue()); + result = DrawGeomHatch::getTrimmedLinesSection(this,m_lineSets, + getSectionTFace(i), + HatchScale.getValue()); return result; } -std::vector DrawViewSection::getWireForFace(int idx) const +TopoDS_Face DrawViewSection::getSectionTFace(int i) { - std::vector result; - result.push_back(sectionFaceWires.at(idx)); + TopoDS_Face result; + TopExp_Explorer expl(sectionFaces, TopAbs_FACE); + int count = 1; + for (; expl.More(); expl.Next(), count++) { + if (count == i+1) { + result = TopoDS::Face(expl.Current()); + } + } return result; } diff --git a/src/Mod/TechDraw/App/DrawViewSection.h b/src/Mod/TechDraw/App/DrawViewSection.h index 154e829b7a..b42fbf81fe 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.h +++ b/src/Mod/TechDraw/App/DrawViewSection.h @@ -92,7 +92,7 @@ public: void sectionExec(TopoDS_Shape s); - std::vector getFaceGeometry(); + std::vector getTDFaceGeometry() {return tdSectionFaces;} void setCSFromBase(const std::string sectionName); gp_Ax2 getCSFromBase(const std::string sectionName) const; @@ -106,10 +106,9 @@ public: TechDraw::DrawViewPart* getBaseDVP() const; TechDraw::DrawProjGroupItem* getBaseDPGI() const; - virtual std::vector getWireForFace(int idx) const override; TopoDS_Compound getSectionFaces() { return sectionFaces;}; - std::vector getSectionFaceWires(void) { return sectionFaceWires; } - +// std::vector getSectionFaceWires(void) { return sectionFaceWires; } //obs? + TopoDS_Face getSectionTFace(int i); void makeLineSets(void) ; std::vector getDrawableLines(int i = 0); std::vector getDecodedSpecsFromFile(std::string fileSpec, std::string myPattern); @@ -122,15 +121,14 @@ public: std::pair sectionLineEnds(void); protected: - TopoDS_Compound sectionFaces; - std::vector sectionFaceWires; + TopoDS_Compound sectionFaces; //tSectionFaces +// std::vector sectionFaceWires; //obs??? getSectionFaceWires std::vector m_lineSets; + std::vector tdSectionFaces; + gp_Pln getSectionPlane() const; TopoDS_Compound findSectionPlaneIntersections(const TopoDS_Shape& shape); - TopoDS_Face projectFace(const TopoDS_Shape &face, - const gp_Ax2 CS); - void getParameters(void); bool debugSection(void) const; int prefCutSurface(void) const; diff --git a/src/Mod/TechDraw/App/Geometry.cpp b/src/Mod/TechDraw/App/Geometry.cpp index 1e7ab9eb42..5b6e1a9413 100644 --- a/src/Mod/TechDraw/App/Geometry.cpp +++ b/src/Mod/TechDraw/App/Geometry.cpp @@ -27,10 +27,13 @@ #include #include #include +#include #include #include #include #include +#include +#include #include #include #include @@ -96,7 +99,12 @@ Wire::Wire(const TopoDS_Wire &w) TopExp_Explorer edges(w, TopAbs_EDGE); for (; edges.More(); edges.Next()) { const auto edge( TopoDS::Edge(edges.Current()) ); - geoms.push_back( BaseGeom::baseFactory(edge) ); + BaseGeom* bg = BaseGeom::baseFactory(edge); + if (bg != nullptr) { + geoms.push_back( BaseGeom::baseFactory(edge) ); + } else { + Base::Console().Log("G::Wire - baseFactory returned null geom ptr\n"); + } } } @@ -108,6 +116,46 @@ Wire::~Wire() geoms.clear(); } +TopoDS_Wire Wire::toOccWire(void) const +{ + TopoDS_Wire result; + BRepBuilderAPI_MakeWire mkWire; + for (auto& g: geoms) { + TopoDS_Edge e = g->occEdge; + mkWire.Add(e); + } + if (mkWire.IsDone()) { + result = mkWire.Wire(); + } +// BRepTools::Write(result, "toOccWire.brep"); + return result; +} + +void Wire::dump(std::string s) +{ + BRepTools::Write(toOccWire(), s.c_str()); //debug +} + +TopoDS_Face Face::toOccFace(void) const +{ + TopoDS_Face result; + //if (!wires.empty) { + BRepBuilderAPI_MakeFace mkFace(wires.front()->toOccWire(), true); + int limit = wires.size(); + int iwire = 1; + for ( ; iwire < limit; iwire++) { +// w->dump("wireInToFace.brep"); + TopoDS_Wire wOCC = wires.at(iwire)->toOccWire(); + if(!wOCC.IsNull()) { + mkFace.Add(wOCC); + } + } + if (mkFace.IsDone()) { + result = mkFace.Face(); + } + return result; +} + Face::~Face() { for(auto it : wires) { diff --git a/src/Mod/TechDraw/App/Geometry.h b/src/Mod/TechDraw/App/Geometry.h index daf17f576d..d1f587e579 100644 --- a/src/Mod/TechDraw/App/Geometry.h +++ b/src/Mod/TechDraw/App/Geometry.h @@ -36,6 +36,7 @@ #include #include #include +#include namespace TechDraw { @@ -279,6 +280,8 @@ class TechDrawExport Wire Wire(const TopoDS_Wire &w); ~Wire(); + TopoDS_Wire toOccWire(void) const; + void dump(std::string s); std::vector geoms; }; @@ -288,7 +291,7 @@ class TechDrawExport Face public: Face() = default; ~Face(); - + TopoDS_Face toOccFace(void) const; std::vector wires; }; diff --git a/src/Mod/TechDraw/App/GeometryObject.h b/src/Mod/TechDraw/App/GeometryObject.h index a89f9b6ff7..70bf98f5ec 100644 --- a/src/Mod/TechDraw/App/GeometryObject.h +++ b/src/Mod/TechDraw/App/GeometryObject.h @@ -131,7 +131,9 @@ public: void setFocus(double f) { m_focus = f; } double getFocus(void) { return m_focus; } void pruneVertexGeom(Base::Vector3d center, double radius); - TopoDS_Shape invertGeometry(const TopoDS_Shape s); + + //dupl mirrorShape??? + static TopoDS_Shape invertGeometry(const TopoDS_Shape s); TopoDS_Shape getVisHard(void) { return visHard; } TopoDS_Shape getVisOutline(void) { return visOutline; } diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index e217b4b499..ee9aa9eefc 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -718,17 +718,27 @@ QGIFace* QGIViewPart::drawFace(TechDraw::Face* f, int idx) for(std::vector::iterator wire = fWires.begin(); wire != fWires.end(); ++wire) { QPainterPath wirePath; std::vector geoms = (*wire)->geoms; - for(std::vector::iterator edge = (*wire)->geoms.begin(); edge != (*wire)->geoms.end(); ++edge) { - //Save the start Position + TechDraw::BaseGeom* firstGeom = geoms.front(); + //QPointF startPoint(firstGeom->getStartPoint().x, firstGeom->getStartPoint().y); + //wirePath.moveTo(startPoint); + QPainterPath firstSeg = drawPainterPath(firstGeom); + wirePath.connectPath(firstSeg); + for(std::vector::iterator edge = ((*wire)->geoms.begin()) + 1; edge != (*wire)->geoms.end(); ++edge) { QPainterPath edgePath = drawPainterPath(*edge); - // If the current end point matches the shape end point the new edge path needs reversing - // wf: this check isn't good enough. - //if ((*edge)->reversed) { - // path = ??? -// QPointF shapePos = (wirePath.currentPosition()- edgePath.currentPosition()); -// if(sqrt(shapePos.x() * shapePos.x() + shapePos.y()*shapePos.y()) < 0.05) { //magic tolerance -// edgePath = edgePath.toReversed(); -// } + //handle section faces differently + if (idx == -1) { + QPointF wEnd = wirePath.currentPosition(); + auto element = edgePath.elementAt(0); + QPointF eStart(element.x, element.y); + QPointF eEnd = edgePath.currentPosition(); + QPointF sVec = wEnd - eStart; + QPointF eVec = wEnd - eEnd; + double sDist2 = sVec.x() * sVec.x() + sVec.y() * sVec.y(); + double eDist2 = eVec.x() * eVec.x() + eVec.y() * eVec.y(); + if (sDist2 > eDist2) { + edgePath = edgePath.toReversed(); + } + } wirePath.connectPath(edgePath); } // dumpPath("wirePath:",wirePath); diff --git a/src/Mod/TechDraw/Gui/QGIViewSection.cpp b/src/Mod/TechDraw/Gui/QGIViewSection.cpp index 0e8abbebcc..52e6e3c8db 100644 --- a/src/Mod/TechDraw/Gui/QGIViewSection.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewSection.cpp @@ -82,9 +82,7 @@ void QGIViewSection::drawSectionFace() float lineWidth = sectionVp->LineWidth.getValue(); - std::vector sectionWires = section->getSectionFaceWires(); - - auto sectionFaces( section->getFaceGeometry() ); + auto sectionFaces( section->getTDFaceGeometry() ); if (sectionFaces.empty()) { Base::Console(). Log("INFO - QGIViewSection::drawSectionFace - No sectionFaces available. Check Section plane.\n"); @@ -134,11 +132,6 @@ void QGIViewSection::drawSectionFace() if (!lineSets.empty()) { newFace->clearLineSets(); for (auto& ls: lineSets) { - QPainterPath bigPath; - for (auto& g: ls.getGeoms()) { - QPainterPath smallPath = drawPainterPath(g); - bigPath.addPath(smallPath); - } newFace->addLineSet(ls); } } @@ -161,13 +154,8 @@ void QGIViewSection::updateView(bool update) if( viewPart == nullptr ) { return; } - - std::string dbHatch = viewPart->FileHatchPattern.getValue(); - draw(); - QGIView::updateView(update); - } void QGIViewSection::drawSectionLine(TechDraw::DrawViewSection* s, bool b)