[TD]Improve section face display

This commit is contained in:
WandererFan
2020-05-30 22:08:50 -04:00
committed by wandererfan
parent 7fffe88433
commit 2db99798f6
9 changed files with 209 additions and 219 deletions

View File

@@ -43,6 +43,7 @@
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepBuilderAPI_Transform.hxx>
#include <BRepTools.hxx>
#include <Standard_PrimitiveTypes.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Wire.hxx>
@@ -73,7 +74,9 @@
#include "DrawPage.h"
#include "DrawViewPart.h"
#include "DrawViewSection.h"
#include "DrawViewDetail.h"
#include "DrawGeomHatch.h"
#include "GeometryObject.h"
#include <Mod/TechDraw/App/DrawGeomHatchPy.h> // generated from DrawGeomHatchPy.xml
@@ -229,9 +232,38 @@ std::vector<LineSet> DrawGeomHatch::getTrimmedLines(int i) //get the trimmed
}
/* static */
std::vector<LineSet> DrawGeomHatch::getTrimmedLinesSection(DrawViewSection* source,
std::vector<LineSet> lineSets,
TopoDS_Face f,
double scale )
{
std::vector<LineSet> 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<LineSet> DrawGeomHatch::getTrimmedLines(DrawViewPart* source, std::vector<LineSet> lineSets, int iface, double scale )
{
TopoDS_Face face = extractFace(source,iface);
std::vector<LineSet> result = getTrimmedLines(source,
lineSets,
face,
scale );
return result;
}
std::vector<LineSet> DrawGeomHatch::getTrimmedLines(DrawViewPart* source,
std::vector<LineSet> lineSets,
TopoDS_Face f,
double scale )
{
(void)source;
std::vector<LineSet> result;
if (lineSets.empty()) {
@@ -239,7 +271,7 @@ std::vector<LineSet> 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<LineSet> 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<LineSet> DrawGeomHatch::getTrimmedLines(DrawViewPart* source, std::v
}
return result;
}
/* static */
std::vector<TopoDS_Edge> 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<DrawViewSection*>(source);
bool usingSection = false;
if (section != nullptr) {
usingSection = true;
}
std::vector<TopoDS_Wire> faceWires;
if (usingSection) {
faceWires = section->getWireForFace(iface);
} else {
faceWires = source->getWireForFace(iface);
}
std::vector<TopoDS_Wire> faceWires = source->getWireForFace(iface);
//build face(s) from geometry
gp_Pnt gOrg(0.0,0.0,0.0);

View File

@@ -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<LineSet> getFaceOverlay(int i = 0);
std::vector<LineSet> getTrimmedLines(int i = 0);
static std::vector<LineSet> getTrimmedLines(DrawViewPart* dvp, std::vector<LineSet> lineSets, int iface, double scale);
static std::vector<LineSet> getTrimmedLines(DrawViewPart* source,
std::vector<LineSet> lineSets,
TopoDS_Face face,
double scale );
static std::vector<LineSet> getTrimmedLinesSection(DrawViewSection* source,
std::vector<LineSet> lineSets,
TopoDS_Face f,
double scale );
static std::vector<TopoDS_Edge> makeEdgeOverlay(PATLineSpec hl, Bnd_Box bBox, double scale);
static TopoDS_Edge makeLine(Base::Vector3d s, Base::Vector3d e);

View File

@@ -31,10 +31,12 @@
#include <Bnd_Box.hxx>
#include <BRepBndLib.hxx>
//#include <BRepBuilderAPI_MakePolygon.hxx>
#include <BRepBuilderAPI_Transform.hxx>
#include <BRepBuilderAPI_Copy.hxx>
#include <BRepAlgoAPI_Cut.hxx>
#include <BRepPrimAPI_MakePrism.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepAlgoAPI_Section.hxx>
#include <BRepAdaptor_Surface.hxx>
#include <BRep_Builder.hxx>
#include <BRepTools.hxx>
@@ -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<TechDraw::Face*> DrawViewSection::getFaceGeometry()
{
std::vector<TechDraw::Face*> 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<TopoDS_Edge> 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<TopoDS_Wire> fw = ew.getResultNoDups();
if (!fw.empty()) {
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(fw, true);
if (sortedWires.empty()) {
return projectedFace;
}
BRepBuilderAPI_MakeFace mkFace(sortedWires.front(),true); //true => only want planes?
std::vector<TopoDS_Wire>::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<Base::Vector3d, Base::Vector3d> DrawViewSection::sectionLineEnds(void)
{
@@ -873,14 +776,22 @@ std::vector<LineSet> DrawViewSection::getDrawableLines(int i)
{
// Base::Console().Message("DVS::getDrawableLines(%d) - lineSets: %d\n", i, m_lineSets.size());
std::vector<LineSet> result;
result = DrawGeomHatch::getTrimmedLines(this,m_lineSets,i,HatchScale.getValue());
result = DrawGeomHatch::getTrimmedLinesSection(this,m_lineSets,
getSectionTFace(i),
HatchScale.getValue());
return result;
}
std::vector<TopoDS_Wire> DrawViewSection::getWireForFace(int idx) const
TopoDS_Face DrawViewSection::getSectionTFace(int i)
{
std::vector<TopoDS_Wire> 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;
}

View File

@@ -92,7 +92,7 @@ public:
void sectionExec(TopoDS_Shape s);
std::vector<TechDraw::Face*> getFaceGeometry();
std::vector<TechDraw::Face*> 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<TopoDS_Wire> getWireForFace(int idx) const override;
TopoDS_Compound getSectionFaces() { return sectionFaces;};
std::vector<TopoDS_Wire> getSectionFaceWires(void) { return sectionFaceWires; }
// std::vector<TopoDS_Wire> getSectionFaceWires(void) { return sectionFaceWires; } //obs?
TopoDS_Face getSectionTFace(int i);
void makeLineSets(void) ;
std::vector<LineSet> getDrawableLines(int i = 0);
std::vector<PATLineSpec> getDecodedSpecsFromFile(std::string fileSpec, std::string myPattern);
@@ -122,15 +121,14 @@ public:
std::pair<Base::Vector3d, Base::Vector3d> sectionLineEnds(void);
protected:
TopoDS_Compound sectionFaces;
std::vector<TopoDS_Wire> sectionFaceWires;
TopoDS_Compound sectionFaces; //tSectionFaces
// std::vector<TopoDS_Wire> sectionFaceWires; //obs??? getSectionFaceWires
std::vector<LineSet> m_lineSets;
std::vector<TechDraw::Face*> 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;

View File

@@ -27,10 +27,13 @@
#include <BRepBndLib.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRep_Tool.hxx>
#include <BRepTools.hxx>
#include <BRepAdaptor_HCurve.hxx>
#include <BRepLib.hxx>
#include <BRepBuilderAPI_MakeVertex.hxx>
#include <BRepBuilderAPI_MakeEdge.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <BRepExtrema_DistShapeShape.hxx>
#include <Precision.hxx>
#include <GCPnts_AbscissaPoint.hxx>
@@ -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) {

View File

@@ -36,6 +36,7 @@
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Face.hxx>
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<BaseGeom *> geoms;
};
@@ -288,7 +291,7 @@ class TechDrawExport Face
public:
Face() = default;
~Face();
TopoDS_Face toOccFace(void) const;
std::vector<Wire *> wires;
};

View File

@@ -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; }

View File

@@ -718,17 +718,27 @@ QGIFace* QGIViewPart::drawFace(TechDraw::Face* f, int idx)
for(std::vector<TechDraw::Wire *>::iterator wire = fWires.begin(); wire != fWires.end(); ++wire) {
QPainterPath wirePath;
std::vector<TechDraw::BaseGeom*> geoms = (*wire)->geoms;
for(std::vector<TechDraw::BaseGeom *>::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<TechDraw::BaseGeom *>::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);

View File

@@ -82,9 +82,7 @@ void QGIViewSection::drawSectionFace()
float lineWidth = sectionVp->LineWidth.getValue();
std::vector<TopoDS_Wire> 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)