[TD]correct face detection to avoid ghost faces
This commit is contained in:
@@ -518,9 +518,16 @@ void DrawViewPart::extractFaces()
|
||||
|
||||
std::vector<TopoDS_Wire> sortedWires = ew.sortStrip(fw,true);
|
||||
|
||||
// int idb = 0;
|
||||
std::vector<TopoDS_Wire>::iterator itWire = sortedWires.begin();
|
||||
for (; itWire != sortedWires.end(); itWire++) {
|
||||
//version 1: 1 wire/face - no voids in face
|
||||
//debug
|
||||
// std::stringstream ss;
|
||||
// ss << "DVPSWire" << idb << ".brep";
|
||||
// std::string wireName = ss.str();
|
||||
// BRepTools::Write((*itWire), wireName.c_str()); //debug
|
||||
//debug idb++;
|
||||
TechDraw::Face* f = new TechDraw::Face();
|
||||
const TopoDS_Wire& wire = (*itWire);
|
||||
TechDraw::Wire* w = new TechDraw::Wire(wire);
|
||||
@@ -926,7 +933,7 @@ bool DrawViewPart::checkXDirection(void) const
|
||||
Base::Vector3d origin(0.0,0.0,0.0);
|
||||
Base::Vector3d xDir = getLegacyX(origin,
|
||||
dir);
|
||||
Base::Console().Warning("DVP - %s - XDirection property not set. Trying %s\n",
|
||||
Base::Console().Log("DVP - %s - XDirection property not set. Trying %s\n",
|
||||
getNameInDocument(),
|
||||
DrawUtil::formatVector(xDir).c_str());
|
||||
return false;
|
||||
|
||||
@@ -49,6 +49,7 @@
|
||||
#include <HLRAlgo_Projector.hxx>
|
||||
#include <HLRBRep_HLRToShape.hxx>
|
||||
#include <ShapeAnalysis.hxx>
|
||||
#include <ShapeFix_Wire.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
@@ -371,14 +372,18 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
|
||||
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);
|
||||
// BRepTools::Write(ow, "outerwire.brep"); //debug
|
||||
//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) {
|
||||
if (status == BRepCheck_NoError) {
|
||||
builder.Add(newFaces,pFace);
|
||||
sectionFaceWires.push_back(ShapeAnalysis::OuterWire(pFace));
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ class Bnd_Box;
|
||||
class gp_Pln;
|
||||
class gp_Pnt;
|
||||
class TopoDS_Face;
|
||||
class TopoDS_Wire;
|
||||
class gp_Ax2;
|
||||
|
||||
namespace TechDraw
|
||||
|
||||
@@ -426,6 +426,10 @@ BaseGeom* BaseGeom::baseFactory(TopoDS_Edge edge)
|
||||
Handle(Geom_BezierCurve) bez = adapt.Bezier();
|
||||
//if (bez->Degree() < 4) {
|
||||
result = new BezierSegment(edge);
|
||||
if (edge.Orientation() == TopAbs_REVERSED) {
|
||||
result->reversed = true;
|
||||
}
|
||||
|
||||
//}
|
||||
// OCC is quite happy with Degree > 3 but QtGui handles only 2,3
|
||||
} break;
|
||||
@@ -456,7 +460,7 @@ BaseGeom* BaseGeom::baseFactory(TopoDS_Edge edge)
|
||||
delete bspline;
|
||||
bspline = nullptr;
|
||||
}
|
||||
}else {
|
||||
} else {
|
||||
result = bspline;
|
||||
}
|
||||
}
|
||||
@@ -524,6 +528,9 @@ AOE::AOE(const TopoDS_Edge &e) : Ellipse(e)
|
||||
startPnt = Base::Vector3d(s.X(), s.Y(), s.Z());
|
||||
endPnt = Base::Vector3d(ePt.X(), ePt.Y(), ePt.Z());
|
||||
midPnt = Base::Vector3d(m.X(), m.Y(), m.Z());
|
||||
if (e.Orientation() == TopAbs_REVERSED) {
|
||||
reversed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -634,6 +641,9 @@ AOC::AOC(const TopoDS_Edge &e) : Circle(e)
|
||||
startPnt = Base::Vector3d(s.X(), s.Y(), s.Z());
|
||||
endPnt = Base::Vector3d(ePt.X(), ePt.Y(), s.Z());
|
||||
midPnt = Base::Vector3d(m.X(), m.Y(), s.Z());
|
||||
if (e.Orientation() == TopAbs_REVERSED) {
|
||||
reversed = true;
|
||||
}
|
||||
}
|
||||
|
||||
AOC::AOC(void) : Circle()
|
||||
@@ -837,6 +847,9 @@ Generic::Generic(const TopoDS_Edge &e)
|
||||
p = BRep_Tool::Pnt(TopExp::LastVertex(occEdge));
|
||||
points.emplace_back(p.X(), p.Y(), p.Z());
|
||||
}
|
||||
if (e.Orientation() == TopAbs_REVERSED) {
|
||||
reversed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1040,6 +1053,9 @@ BSpline::BSpline(const TopoDS_Edge &e)
|
||||
}
|
||||
segments.push_back(tempSegment);
|
||||
}
|
||||
if (e.Orientation() == TopAbs_REVERSED) {
|
||||
reversed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1265,6 +1281,7 @@ TopoDS_Edge BSpline::asCircle(bool& arc)
|
||||
result = newEdge;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -1308,6 +1325,9 @@ BezierSegment::BezierSegment(const TopoDS_Edge &e)
|
||||
gp_Pnt controlPoint = bez->Pole(i);
|
||||
pnts.emplace_back(controlPoint.X(), controlPoint.Y(), controlPoint.Z());
|
||||
}
|
||||
if (e.Orientation() == TopAbs_REVERSED) {
|
||||
reversed = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRepTools.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepMesh_IncrementalMesh.hxx>
|
||||
#include <BRepLib.hxx>
|
||||
#include <BRepLProp_CurveTool.hxx>
|
||||
@@ -131,6 +132,16 @@ const std::vector<BaseGeom *> GeometryObject::getVisibleFaceEdges(const bool smo
|
||||
}
|
||||
}
|
||||
}
|
||||
//debug
|
||||
//make compound of edges and save as brep file
|
||||
// BRep_Builder builder;
|
||||
// TopoDS_Compound comp;
|
||||
// builder.MakeCompound(comp);
|
||||
// for (auto& r: result) {
|
||||
// builder.Add(comp, r->occEdge);
|
||||
// }
|
||||
// BRepTools::Write(comp, "GOVizFaceEdges.brep"); //debug
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -149,146 +149,243 @@ QPainterPath QGIViewPart::geomToPainterPath(TechDraw::BaseGeom *baseGeom, double
|
||||
QPainterPath path;
|
||||
|
||||
switch(baseGeom->geomType) {
|
||||
case TechDraw::CIRCLE: {
|
||||
TechDraw::Circle *geom = static_cast<TechDraw::Circle *>(baseGeom);
|
||||
case CIRCLE: {
|
||||
TechDraw::Circle *geom = static_cast<TechDraw::Circle *>(baseGeom);
|
||||
|
||||
double x = geom->center.x - geom->radius;
|
||||
double y = geom->center.y - geom->radius;
|
||||
double x = geom->center.x - geom->radius;
|
||||
double y = geom->center.y - geom->radius;
|
||||
|
||||
path.addEllipse(Rez::guiX(x),
|
||||
Rez::guiX(y),
|
||||
Rez::guiX(geom->radius * 2),
|
||||
Rez::guiX(geom->radius * 2)); //topleft@(x,y) radx,rady
|
||||
} break;
|
||||
case TechDraw::ARCOFCIRCLE: {
|
||||
TechDraw::AOC *geom = static_cast<TechDraw::AOC *>(baseGeom);
|
||||
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->radius),
|
||||
Rez::guiX(geom->radius),
|
||||
0.,
|
||||
geom->largeArc,
|
||||
geom->cw,
|
||||
Rez::guiX(geom->endPnt.x),
|
||||
Rez::guiX(geom->endPnt.y),
|
||||
Rez::guiX(geom->startPnt.x),
|
||||
Rez::guiX(geom->startPnt.y));
|
||||
} break;
|
||||
path.addEllipse(Rez::guiX(x),
|
||||
Rez::guiX(y),
|
||||
Rez::guiX(geom->radius * 2),
|
||||
Rez::guiX(geom->radius * 2)); //topleft@(x,y) radx,rady
|
||||
}
|
||||
break;
|
||||
case ARCOFCIRCLE: {
|
||||
TechDraw::AOC *geom = static_cast<TechDraw::AOC *>(baseGeom);
|
||||
if (baseGeom->reversed) {
|
||||
path.moveTo(Rez::guiX(geom->endPnt.x),
|
||||
Rez::guiX(geom->endPnt.y));
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->radius),
|
||||
Rez::guiX(geom->radius),
|
||||
0.,
|
||||
geom->largeArc,
|
||||
!geom->cw,
|
||||
Rez::guiX(geom->startPnt.x),
|
||||
Rez::guiX(geom->startPnt.y),
|
||||
Rez::guiX(geom->endPnt.x),
|
||||
Rez::guiX(geom->endPnt.y));
|
||||
} else {
|
||||
path.moveTo(Rez::guiX(geom->startPnt.x),
|
||||
Rez::guiX(geom->startPnt.y));
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->radius),
|
||||
Rez::guiX(geom->radius),
|
||||
0.,
|
||||
geom->largeArc,
|
||||
geom->cw,
|
||||
Rez::guiX(geom->endPnt.x),
|
||||
Rez::guiX(geom->endPnt.y),
|
||||
Rez::guiX(geom->startPnt.x),
|
||||
Rez::guiX(geom->startPnt.y));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TechDraw::ELLIPSE: {
|
||||
TechDraw::Ellipse *geom = static_cast<TechDraw::Ellipse *>(baseGeom);
|
||||
TechDraw::Ellipse *geom = static_cast<TechDraw::Ellipse *>(baseGeom);
|
||||
|
||||
// Calculate start and end points as ellipse with theta = 0 and pi
|
||||
double startX = geom->center.x + geom->major * cos(geom->angle),
|
||||
startY = geom->center.y + geom->major * sin(geom->angle),
|
||||
endX = geom->center.x - geom->major * cos(geom->angle),
|
||||
endY = geom->center.y - geom->major * sin(geom->angle);
|
||||
// Calculate start and end points as ellipse with theta = 0 and pi
|
||||
double startX = geom->center.x + geom->major * cos(geom->angle),
|
||||
startY = geom->center.y + geom->major * sin(geom->angle),
|
||||
endX = geom->center.x - geom->major * cos(geom->angle),
|
||||
endY = geom->center.y - geom->major * sin(geom->angle);
|
||||
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->major),
|
||||
Rez::guiX(geom->minor),
|
||||
geom->angle,
|
||||
false,
|
||||
false,
|
||||
Rez::guiX(endX),
|
||||
Rez::guiX(endY),
|
||||
Rez::guiX(startX),
|
||||
Rez::guiX(startY));
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->major),
|
||||
Rez::guiX(geom->minor),
|
||||
geom->angle,
|
||||
false,
|
||||
false,
|
||||
Rez::guiX(endX),
|
||||
Rez::guiX(endY),
|
||||
Rez::guiX(startX),
|
||||
Rez::guiX(startY));
|
||||
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->major),
|
||||
Rez::guiX(geom->minor),
|
||||
geom->angle,
|
||||
false,
|
||||
false,
|
||||
Rez::guiX(startX),
|
||||
Rez::guiX(startY),
|
||||
Rez::guiX(endX),
|
||||
Rez::guiX(endY));
|
||||
|
||||
} break;
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->major),
|
||||
Rez::guiX(geom->minor),
|
||||
geom->angle,
|
||||
false,
|
||||
false,
|
||||
Rez::guiX(startX),
|
||||
Rez::guiX(startY),
|
||||
Rez::guiX(endX),
|
||||
Rez::guiX(endY));
|
||||
}
|
||||
break;
|
||||
case TechDraw::ARCOFELLIPSE: {
|
||||
TechDraw::AOE *geom = static_cast<TechDraw::AOE *>(baseGeom);
|
||||
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->major),
|
||||
Rez::guiX(geom->minor),
|
||||
geom->angle,
|
||||
geom->largeArc,
|
||||
geom->cw,
|
||||
Rez::guiX(geom->endPnt.x),
|
||||
Rez::guiX(geom->endPnt.y),
|
||||
Rez::guiX(geom->startPnt.x),
|
||||
Rez::guiX(geom->startPnt.y));
|
||||
|
||||
} break;
|
||||
TechDraw::AOE *geom = static_cast<TechDraw::AOE *>(baseGeom);
|
||||
if (baseGeom->reversed) {
|
||||
path.moveTo(Rez::guiX(geom->endPnt.x),
|
||||
Rez::guiX(geom->endPnt.y));
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->major),
|
||||
Rez::guiX(geom->minor),
|
||||
geom->angle,
|
||||
geom->largeArc,
|
||||
!geom->cw,
|
||||
Rez::guiX(geom->startPnt.x),
|
||||
Rez::guiX(geom->startPnt.y),
|
||||
Rez::guiX(geom->endPnt.x),
|
||||
Rez::guiX(geom->endPnt.y));
|
||||
} else {
|
||||
path.moveTo(Rez::guiX(geom->startPnt.x),
|
||||
Rez::guiX(geom->startPnt.y));
|
||||
pathArc(path,
|
||||
Rez::guiX(geom->major),
|
||||
Rez::guiX(geom->minor),
|
||||
geom->angle,
|
||||
geom->largeArc,
|
||||
geom->cw,
|
||||
Rez::guiX(geom->endPnt.x),
|
||||
Rez::guiX(geom->endPnt.y),
|
||||
Rez::guiX(geom->startPnt.x),
|
||||
Rez::guiX(geom->startPnt.y));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TechDraw::BEZIER: {
|
||||
TechDraw::BezierSegment *geom = static_cast<TechDraw::BezierSegment *>(baseGeom);
|
||||
TechDraw::BezierSegment *geom = static_cast<TechDraw::BezierSegment *>(baseGeom);
|
||||
if (baseGeom->reversed) {
|
||||
if (!geom->pnts.empty()) {
|
||||
Base::Vector3d rStart = geom->pnts.back();
|
||||
path.moveTo(Rez::guiX(rStart.x), Rez::guiX(rStart.y));
|
||||
}
|
||||
if ( geom->poles == 2 ) {
|
||||
// Degree 1 bezier = straight line...
|
||||
path.lineTo(Rez::guiX(geom->pnts[0].x), Rez::guiX(geom->pnts[0].y));
|
||||
|
||||
// Move painter to the beginning
|
||||
path.moveTo(Rez::guiX(geom->pnts[0].x), Rez::guiX(geom->pnts[0].y));
|
||||
} else if ( geom->poles == 3 ) {
|
||||
path.quadTo(Rez::guiX(geom->pnts[1].x), Rez::guiX(geom->pnts[1].y),
|
||||
Rez::guiX(geom->pnts[0].x), Rez::guiX(geom->pnts[0].y));
|
||||
} else if ( geom->poles == 4 ) {
|
||||
path.cubicTo(Rez::guiX(geom->pnts[2].x), Rez::guiX(geom->pnts[2].y),
|
||||
Rez::guiX(geom->pnts[1].x), Rez::guiX(geom->pnts[1].y),
|
||||
Rez::guiX(geom->pnts[0].x), Rez::guiX(geom->pnts[0].y));
|
||||
} else { //can only handle lines,quads,cubes
|
||||
Base::Console().Error("Bad pole count (%d) for BezierSegment\n",geom->poles);
|
||||
auto itBez = geom->pnts.begin() + 1;
|
||||
for (; itBez != geom->pnts.end();itBez++) {
|
||||
path.lineTo(Rez::guiX((*itBez).x), Rez::guiX((*itBez).y)); //show something for debugging
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Move painter to the beginning
|
||||
path.moveTo(Rez::guiX(geom->pnts[0].x), Rez::guiX(geom->pnts[0].y));
|
||||
|
||||
if ( geom->poles == 2 ) {
|
||||
// Degree 1 bezier = straight line...
|
||||
path.lineTo(Rez::guiX(geom->pnts[1].x), Rez::guiX(geom->pnts[1].y));
|
||||
if ( geom->poles == 2 ) {
|
||||
// Degree 1 bezier = straight line...
|
||||
path.lineTo(Rez::guiX(geom->pnts[1].x), Rez::guiX(geom->pnts[1].y));
|
||||
|
||||
} else if ( geom->poles == 3 ) {
|
||||
path.quadTo(Rez::guiX(geom->pnts[1].x), Rez::guiX(geom->pnts[1].y),
|
||||
Rez::guiX(geom->pnts[2].x), Rez::guiX(geom->pnts[2].y));
|
||||
} else if ( geom->poles == 3 ) {
|
||||
path.quadTo(Rez::guiX(geom->pnts[1].x), Rez::guiX(geom->pnts[1].y),
|
||||
Rez::guiX(geom->pnts[2].x), Rez::guiX(geom->pnts[2].y));
|
||||
|
||||
} else if ( geom->poles == 4 ) {
|
||||
path.cubicTo(Rez::guiX(geom->pnts[1].x), Rez::guiX(geom->pnts[1].y),
|
||||
Rez::guiX(geom->pnts[2].x), Rez::guiX(geom->pnts[2].y),
|
||||
Rez::guiX(geom->pnts[3].x), Rez::guiX(geom->pnts[3].y));
|
||||
} else { //can only handle lines,quads,cubes
|
||||
Base::Console().Error("Bad pole count (%d) for BezierSegment\n",geom->poles);
|
||||
auto itBez = geom->pnts.begin() + 1;
|
||||
for (; itBez != geom->pnts.end();itBez++) {
|
||||
path.lineTo(Rez::guiX((*itBez).x), Rez::guiX((*itBez).y)); //show something for debugging
|
||||
}
|
||||
}
|
||||
} break;
|
||||
} else if ( geom->poles == 4 ) {
|
||||
path.cubicTo(Rez::guiX(geom->pnts[1].x), Rez::guiX(geom->pnts[1].y),
|
||||
Rez::guiX(geom->pnts[2].x), Rez::guiX(geom->pnts[2].y),
|
||||
Rez::guiX(geom->pnts[3].x), Rez::guiX(geom->pnts[3].y));
|
||||
} else { //can only handle lines,quads,cubes
|
||||
Base::Console().Error("Bad pole count (%d) for BezierSegment\n",geom->poles);
|
||||
auto itBez = geom->pnts.begin() + 1;
|
||||
for (; itBez != geom->pnts.end();itBez++) {
|
||||
path.lineTo(Rez::guiX((*itBez).x), Rez::guiX((*itBez).y)); //show something for debugging
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TechDraw::BSPLINE: {
|
||||
TechDraw::BSpline *geom = static_cast<TechDraw::BSpline *>(baseGeom);
|
||||
TechDraw::BSpline *geom = static_cast<TechDraw::BSpline *>(baseGeom);
|
||||
if (baseGeom->reversed) {
|
||||
// Move painter to the end of our last segment
|
||||
std::vector<TechDraw::BezierSegment>::const_reverse_iterator it = geom->segments.rbegin();
|
||||
Base::Vector3d rStart = it->pnts.back();
|
||||
path.moveTo(Rez::guiX(rStart.x), Rez::guiX(rStart.y));
|
||||
|
||||
std::vector<TechDraw::BezierSegment>::const_iterator it = geom->segments.begin();
|
||||
for ( ; it != geom->segments.rend(); ++it) {
|
||||
// At this point, the painter is either at the beginning
|
||||
// of the first segment, or end of the last
|
||||
if ( it->poles == 2 ) {
|
||||
// Degree 1 bezier = straight line...
|
||||
path.lineTo(Rez::guiX(it->pnts[0].x), Rez::guiX(it->pnts[0].y));
|
||||
|
||||
// Move painter to the beginning of our first segment
|
||||
path.moveTo(Rez::guiX(it->pnts[0].x), Rez::guiX(it->pnts[0].y));
|
||||
} else if ( it->poles == 3 ) {
|
||||
path.quadTo(Rez::guiX(it->pnts[1].x), Rez::guiX(it->pnts[1].y),
|
||||
Rez::guiX(it->pnts[0].x), Rez::guiX(it->pnts[0].y));
|
||||
} else if ( it->poles == 4 ) {
|
||||
path.cubicTo(Rez::guiX(it->pnts[2].x), Rez::guiX(it->pnts[2].y),
|
||||
Rez::guiX(it->pnts[1].x), Rez::guiX(it->pnts[1].y),
|
||||
Rez::guiX(it->pnts[0].x), Rez::guiX(it->pnts[0].y));
|
||||
} else { //can only handle lines,quads,cubes
|
||||
Base::Console().Error("Bad pole count (%d) for BezierSegment of B-spline geometry\n",
|
||||
it->poles);
|
||||
path.lineTo(it->pnts[1].x, it->pnts[1].y); //show something for debugging
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Move painter to the beginning of our first segment
|
||||
std::vector<TechDraw::BezierSegment>::const_iterator it = geom->segments.begin();
|
||||
path.moveTo(Rez::guiX(it->pnts[0].x), Rez::guiX(it->pnts[0].y));
|
||||
|
||||
for ( ; it != geom->segments.end(); ++it) {
|
||||
// At this point, the painter is either at the beginning
|
||||
// of the first segment, or end of the last
|
||||
if ( it->poles == 2 ) {
|
||||
// Degree 1 bezier = straight line...
|
||||
path.lineTo(Rez::guiX(it->pnts[1].x), Rez::guiX(it->pnts[1].y));
|
||||
|
||||
} else if ( it->poles == 3 ) {
|
||||
path.quadTo(Rez::guiX(it->pnts[1].x), Rez::guiX(it->pnts[1].y),
|
||||
Rez::guiX(it->pnts[2].x), Rez::guiX(it->pnts[2].y));
|
||||
|
||||
} else if ( it->poles == 4 ) {
|
||||
path.cubicTo(Rez::guiX(it->pnts[1].x), Rez::guiX(it->pnts[1].y),
|
||||
Rez::guiX(it->pnts[2].x), Rez::guiX(it->pnts[2].y),
|
||||
Rez::guiX(it->pnts[3].x), Rez::guiX(it->pnts[3].y));
|
||||
} else { //can only handle lines,quads,cubes
|
||||
Base::Console().Error("Bad pole count (%d) for BezierSegment of B-spline geometry\n",it->poles);
|
||||
path.lineTo(it->pnts[1].x, it->pnts[1].y); //show something for debugging
|
||||
}
|
||||
}
|
||||
} break;
|
||||
for ( ; it != geom->segments.end(); ++it) {
|
||||
// At this point, the painter is either at the beginning
|
||||
// of the first segment, or end of the last
|
||||
if ( it->poles == 2 ) {
|
||||
// Degree 1 bezier = straight line...
|
||||
path.lineTo(Rez::guiX(it->pnts[1].x), Rez::guiX(it->pnts[1].y));
|
||||
} else if ( it->poles == 3 ) {
|
||||
path.quadTo(Rez::guiX(it->pnts[1].x), Rez::guiX(it->pnts[1].y),
|
||||
Rez::guiX(it->pnts[2].x), Rez::guiX(it->pnts[2].y));
|
||||
} else if ( it->poles == 4 ) {
|
||||
path.cubicTo(Rez::guiX(it->pnts[1].x), Rez::guiX(it->pnts[1].y),
|
||||
Rez::guiX(it->pnts[2].x), Rez::guiX(it->pnts[2].y),
|
||||
Rez::guiX(it->pnts[3].x), Rez::guiX(it->pnts[3].y));
|
||||
} else {
|
||||
Base::Console().Error("Bad pole count (%d) for BezierSegment of B-spline geometry\n",
|
||||
it->poles);
|
||||
path.lineTo(it->pnts[1].x, it->pnts[1].y); //show something for debugging
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TechDraw::GENERIC: {
|
||||
TechDraw::Generic *geom = static_cast<TechDraw::Generic *>(baseGeom);
|
||||
|
||||
path.moveTo(Rez::guiX(geom->points[0].x), Rez::guiX(geom->points[0].y));
|
||||
std::vector<Base::Vector3d>::const_iterator it = geom->points.begin();
|
||||
for(++it; it != geom->points.end(); ++it) {
|
||||
path.lineTo(Rez::guiX((*it).x), Rez::guiX((*it).y));
|
||||
}
|
||||
} break;
|
||||
default:
|
||||
Base::Console().Error("Error - geomToPainterPath - UNKNOWN geomType: %d\n",baseGeom->geomType);
|
||||
break;
|
||||
}
|
||||
TechDraw::Generic *geom = static_cast<TechDraw::Generic *>(baseGeom);
|
||||
if (baseGeom->reversed) {
|
||||
if (!geom->points.empty()) {
|
||||
Base::Vector3d rStart = geom->points.back();
|
||||
path.moveTo(Rez::guiX(rStart.x), Rez::guiX(rStart.y));
|
||||
}
|
||||
std::vector<Base::Vector3d>::const_reverse_iterator it = geom->points.rbegin();
|
||||
for(++it; it != geom->points.rend(); ++it) {
|
||||
path.lineTo(Rez::guiX((*it).x), Rez::guiX((*it).y));
|
||||
}
|
||||
} else {
|
||||
path.moveTo(Rez::guiX(geom->points[0].x), Rez::guiX(geom->points[0].y));
|
||||
std::vector<Base::Vector3d>::const_iterator it = geom->points.begin();
|
||||
for(++it; it != geom->points.end(); ++it) {
|
||||
path.lineTo(Rez::guiX((*it).x), Rez::guiX((*it).y));
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
Base::Console().Error("Error - geomToPainterPath - UNKNOWN geomType: %d\n",baseGeom->geomType);
|
||||
}
|
||||
break;
|
||||
} //sb end of switch
|
||||
|
||||
//old rotate path logic. now done on App side.
|
||||
// if (rot != 0.0) {
|
||||
@@ -633,21 +730,26 @@ bool QGIViewPart::formatGeomFromCenterLine(int sourceIndex, QGIEdge* item)
|
||||
|
||||
QGIFace* QGIViewPart::drawFace(TechDraw::Face* f, int idx)
|
||||
{
|
||||
// Base::Console().Message("QGIVP::drawFace - %d\n", idx);
|
||||
std::vector<TechDraw::Wire *> fWires = f->wires;
|
||||
QPainterPath facePath;
|
||||
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
|
||||
QPainterPath edgePath = drawPainterPath(*edge);
|
||||
// If the current end point matches the shape end point the new edge path needs reversing
|
||||
QPointF shapePos = (wirePath.currentPosition()- edgePath.currentPosition());
|
||||
if(sqrt(shapePos.x() * shapePos.x() + shapePos.y()*shapePos.y()) < 0.05) { //magic tolerance
|
||||
edgePath = edgePath.toReversed();
|
||||
}
|
||||
// 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();
|
||||
// }
|
||||
wirePath.connectPath(edgePath);
|
||||
}
|
||||
//dumpPath("wirePath:",wirePath);
|
||||
// dumpPath("wirePath:",wirePath);
|
||||
facePath.addPath(wirePath);
|
||||
}
|
||||
facePath.setFillRule(Qt::OddEvenFill);
|
||||
@@ -795,6 +897,9 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b
|
||||
Base::Vector3d offset = pAdjOrg + displace;
|
||||
|
||||
// makeMark(0.0, 0.0); //red
|
||||
// makeMark(Rez::guiX(offset.x),
|
||||
// Rez::guiX(offset.y),
|
||||
// Qt::green);
|
||||
|
||||
sectionLine->setPos(Rez::guiX(offset.x),Rez::guiX(offset.y));
|
||||
double sectionSpan;
|
||||
@@ -1143,8 +1248,9 @@ void QGIViewPart::dumpPath(const char* text,QPainterPath path)
|
||||
} else {
|
||||
typeName = "CurveData";
|
||||
}
|
||||
Base::Console().Message(">>>>> element %d: type:%d/%s pos(%.3f,%.3f) M:%d L:%d C:%d\n",iElem,
|
||||
elem.type,typeName,elem.x,elem.y,elem.isMoveTo(),elem.isLineTo(),elem.isCurveTo());
|
||||
Base::Console().Message(">>>>> element %d: type:%d/%s pos(%.3f,%.3f) M:%d L:%d C:%d\n",
|
||||
iElem, elem.type, typeName, elem.x, elem.y, elem.isMoveTo(), elem.isLineTo(),
|
||||
elem.isCurveTo());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -82,7 +82,8 @@ void QGIViewSection::drawSectionFace()
|
||||
|
||||
float lineWidth = sectionVp->LineWidth.getValue();
|
||||
|
||||
|
||||
std::vector<TopoDS_Wire> sectionWires = section->getSectionFaceWires();
|
||||
|
||||
auto sectionFaces( section->getFaceGeometry() );
|
||||
if (sectionFaces.empty()) {
|
||||
Base::Console().
|
||||
|
||||
@@ -75,36 +75,29 @@
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="leSymbol">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Identifier for this section</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Scale</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QDoubleSpinBox" name="sbScale">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>249</width>
|
||||
<height>33</height>
|
||||
<width>0</width>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>249</width>
|
||||
<height>33</height>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="decimals">
|
||||
@@ -121,6 +114,13 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label">
|
||||
<property name="text">
|
||||
<string>Scale</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -298,7 +298,7 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>24</height>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
@@ -342,7 +342,7 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>24</height>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
@@ -386,7 +386,7 @@
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>24</height>
|
||||
<height>32</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
|
||||
Reference in New Issue
Block a user