Fix #2707 hidden seam/smooth lines

This commit is contained in:
WandererFan 2016-10-04 19:54:21 -04:00 committed by Yorik van Havre
parent ae5798434a
commit c8f4de5fbc
5 changed files with 169 additions and 60 deletions

View File

@ -104,6 +104,7 @@ DrawViewPart::DrawViewPart(void) : geometryObject(0)
static const char *group = "Projection";
static const char *fgroup = "Format";
static const char *lgroup = "SectionLine";
static const char *sgroup = "Show";
//properties that affect Geometry
ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"3D Shape to view");
@ -113,19 +114,27 @@ DrawViewPart::DrawViewPart(void) : geometryObject(0)
Tolerance.setConstraints(&floatRange);
//properties that affect Appearance
ADD_PROPERTY_TYPE(ShowHiddenLines ,(false),fgroup,App::Prop_None,"Hidden lines on/off");
ADD_PROPERTY_TYPE(ShowSmoothLines ,(false),fgroup,App::Prop_None,"Smooth lines on/off");
ADD_PROPERTY_TYPE(ShowSeamLines ,(false),fgroup,App::Prop_None,"Seam lines on/off");
//ADD_PROPERTY_TYPE(ShowIsoLines ,(false),group,App::Prop_None,"Iso u,v lines on/off");
//visible outline
ADD_PROPERTY_TYPE(ShowSmoothLines ,(false),sgroup,App::Prop_None,"Visible Smooth lines on/off");
ADD_PROPERTY_TYPE(ShowSeamLines ,(false),sgroup,App::Prop_None,"Visible Seam lines on/off");
ADD_PROPERTY_TYPE(ShowIsoLines ,(false),sgroup,App::Prop_None,"Visible Iso u,v lines on/off");
ADD_PROPERTY_TYPE(ShowHiddenLines ,(false),sgroup,App::Prop_None,"Hidden Hard lines on/off"); // and outline
//hidden outline
ADD_PROPERTY_TYPE(SmoothHidden ,(false),sgroup,App::Prop_None,"Hidden Smooth lines on/off");
ADD_PROPERTY_TYPE(SeamHidden ,(false),sgroup,App::Prop_None,"Hidden Seam lines on/off");
ADD_PROPERTY_TYPE(IsoHidden ,(false),sgroup,App::Prop_None,"Hidden Iso u,v lines on/off");
ADD_PROPERTY_TYPE(IsoCount ,(0),sgroup,App::Prop_None,"Number of isoparameters");
ADD_PROPERTY_TYPE(LineWidth,(0.7f),fgroup,App::Prop_None,"The thickness of visible lines");
ADD_PROPERTY_TYPE(HiddenWidth,(0.15),fgroup,App::Prop_None,"The thickness of hidden lines, if enabled");
ADD_PROPERTY_TYPE(ShowCenters ,(true),fgroup,App::Prop_None,"Center marks on/off");
ADD_PROPERTY_TYPE(IsoWidth,(0.30),fgroup,App::Prop_None,"The thickness of UV isoparameter lines, if enabled");
ADD_PROPERTY_TYPE(ShowCenters ,(true),sgroup,App::Prop_None,"Center marks on/off");
ADD_PROPERTY_TYPE(CenterScale,(2.0),fgroup,App::Prop_None,"Center mark size adjustment, if enabled");
ADD_PROPERTY_TYPE(HorizCenterLine ,(false),fgroup,App::Prop_None,"Show a horizontal centerline through view");
ADD_PROPERTY_TYPE(VertCenterLine ,(false),fgroup,App::Prop_None,"Show a vertical centerline through view");
ADD_PROPERTY_TYPE(HorizCenterLine ,(false),sgroup,App::Prop_None,"Show a horizontal centerline through view");
ADD_PROPERTY_TYPE(VertCenterLine ,(false),sgroup,App::Prop_None,"Show a vertical centerline through view");
//properties that affect Section Line
ADD_PROPERTY_TYPE(ShowSectionLine ,(true) ,lgroup,App::Prop_None,"Show/hide section line if applicable");
ADD_PROPERTY_TYPE(ShowSectionLine ,(true) ,sgroup,App::Prop_None,"Show/hide section line if applicable");
ADD_PROPERTY_TYPE(HorizSectionLine ,(true) ,lgroup,App::Prop_None,"Section line is horizontal");
ADD_PROPERTY_TYPE(ArrowUpSection ,(false) ,lgroup,App::Prop_None,"Section line arrows point up");
ADD_PROPERTY_TYPE(SymbolSection,("A") ,lgroup,App::Prop_None,"Section identifier");
@ -189,6 +198,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
}
try {
geometryObject->setIsoCount(IsoCount.getValue());
buildGeometryObject(mirroredShape,inputCenter);
}
catch (Standard_Failure) {
@ -248,26 +258,40 @@ void DrawViewPart::buildGeometryObject(TopoDS_Shape shape, gp_Pnt& inputCenter)
inputCenter,
Direction.getValue(),
validXDir);
geometryObject->extractGeometry(TechDrawGeometry::ecHARD,
geometryObject->extractGeometry(TechDrawGeometry::ecHARD, //always show the hard&outline visible lines
true);
geometryObject->extractGeometry(TechDrawGeometry::ecOUTLINE,
true);
geometryObject->extractGeometry(TechDrawGeometry::ecSMOOTH,
true);
geometryObject->extractGeometry(TechDrawGeometry::ecSEAM,
true);
// geometryObject->extractGeometry(TechDrawGeometry::ecUVISO,
// true);
geometryObject->extractGeometry(TechDrawGeometry::ecHARD,
false);
// geometryObject->extractGeometry(TechDrawGeometry::ecOUTLINE,
// false);
// geometryObject->extractGeometry(TechDrawGeometry::ecSMOOTH,
// false);
// geometryObject->extractGeometry(TechDrawGeometry::ecSEAM,
// false);
// geometryObject->extractGeometry(TechDrawGeometry::ecUVISO,
// false);
if (ShowSmoothLines.getValue()) {
geometryObject->extractGeometry(TechDrawGeometry::ecSMOOTH,
true);
}
if (ShowSeamLines.getValue()) {
geometryObject->extractGeometry(TechDrawGeometry::ecSEAM,
true);
}
if ((ShowIsoLines.getValue()) && (IsoCount.getValue() > 0)) {
geometryObject->extractGeometry(TechDrawGeometry::ecUVISO,
true);
}
if (ShowHiddenLines.getValue()) {
geometryObject->extractGeometry(TechDrawGeometry::ecHARD,
false);
geometryObject->extractGeometry(TechDrawGeometry::ecOUTLINE,
false);
}
if (SmoothHidden.getValue()) {
geometryObject->extractGeometry(TechDrawGeometry::ecSMOOTH,
false);
}
if (SeamHidden.getValue()) {
geometryObject->extractGeometry(TechDrawGeometry::ecSEAM,
false);
}
if (IsoHidden.getValue() && (IsoCount.getValue() > 0)) {
geometryObject->extractGeometry(TechDrawGeometry::ecUVISO,
false);
}
bbox = geometryObject->calcBoundingBox();
}
@ -275,20 +299,24 @@ void DrawViewPart::buildGeometryObject(TopoDS_Shape shape, gp_Pnt& inputCenter)
void DrawViewPart::extractFaces()
{
geometryObject->clearFaceGeom();
const std::vector<TechDrawGeometry::BaseGeom*>& goEdges = geometryObject->getEdgeGeometry(); //TODO: get visible edge geom!
//const std::vector<TechDrawGeometry::BaseGeom*>& goEdges = geometryObject->getEdgeGeometry(); //TODO: get visible edge geom!
const std::vector<TechDrawGeometry::BaseGeom*>& goEdges = geometryObject->getVisibleFaceEdges(); //visible but not iso
std::vector<TechDrawGeometry::BaseGeom*>::const_iterator itEdge = goEdges.begin();
std::vector<TopoDS_Edge> origEdges;
for (;itEdge != goEdges.end(); itEdge++) {
if ((*itEdge)->visible) { //don't make invisible faces! //TODO: only use Seam/Smooth if checked
// if ((*itEdge)->visible) { //don't make invisible faces! //TODO: only use Seam/Smooth if checked
origEdges.push_back((*itEdge)->occEdge);
}
// }
}
std::vector<TopoDS_Edge> faceEdges;
std::vector<TopoDS_Edge> nonZero;
for (auto& e:origEdges) { //drop any zero edges
for (auto& e:origEdges) { //drop any zero edges (shouldn't be any by now!!!)
if (!DrawUtil::isZeroEdge(e)) {
nonZero.push_back(e);
} else {
Base::Console().Message("INFO - DVP::extractFaces for %s found ZeroEdge!\n",getNameInDocument());
}
}
faceEdges = nonZero;
@ -327,7 +355,7 @@ void DrawViewPart::extractFaces()
BRepBndLib::Add(*itInner, sInner);
sInner.SetGap(0.1);
if (sInner.IsVoid()) {
Base::Console().Message("DVP::Extract Faces - inner Bnd_Box is void for %s\n",getNameInDocument());
Base::Console().Log("INFO - DVP::Extract Faces - inner Bnd_Box is void for %s\n",getNameInDocument());
continue;
}
if (sOuter.IsOut(sInner)) { //bboxes of edges don't intersect, don't bother
@ -812,6 +840,11 @@ DrawViewSection* DrawViewPart::getSectionRef(void) const
return result;
}
const std::vector<TechDrawGeometry::BaseGeom *> DrawViewPart::getVisibleFaceEdges() const
{
return geometryObject->getVisibleFaceEdges();
}
void DrawViewPart::getRunControl()
{
Base::Reference<ParameterGrp> hGrp = App::GetApplication().GetUserParameter()

View File

@ -31,11 +31,14 @@
#include <App/DocumentObject.h>
#include <App/PropertyLinks.h>
#include <App/PropertyStandard.h>
#include "DrawView.h"
#include <App/FeaturePython.h>
#include <Base/BoundBox.h>
//#include "GeometryObject.h"
class gp_Pnt;
namespace TechDrawGeometry
@ -70,11 +73,21 @@ public:
App::PropertyLink Source; //Part Feature
App::PropertyVector Direction; //TODO: Rename to YAxisDirection or whatever this actually is (ProjectionDirection)
App::PropertyVector XAxisDirection;
App::PropertyBool ShowHiddenLines;
App::PropertyBool ShowSmoothLines;
App::PropertyBool ShowSeamLines;
App::PropertyBool ShowSmoothLines;
//App::PropertyBool ShowOutLines;
App::PropertyBool ShowIsoLines;
App::PropertyBool ShowHiddenLines;
App::PropertyBool SmoothHidden;
App::PropertyBool SeamHidden;
//App::PropertyBool OutLinesHidden;
App::PropertyBool IsoHidden;
App::PropertyInteger IsoCount;
App::PropertyFloat LineWidth;
App::PropertyFloat HiddenWidth;
App::PropertyFloat IsoWidth;
App::PropertyBool ShowCenters;
App::PropertyFloat CenterScale;
App::PropertyFloatConstraint Tolerance;
@ -93,6 +106,7 @@ public:
const std::vector<TechDrawGeometry::Vertex *> & getVertexGeometry() const;
const std::vector<TechDrawGeometry::BaseGeom *> & getEdgeGeometry() const;
const std::vector<TechDrawGeometry::BaseGeom *> getVisibleFaceEdges() const;
const std::vector<TechDrawGeometry::Face *> & getFaceGeometry() const;
bool hasGeometry(void) const;

View File

@ -67,6 +67,7 @@
#include "DrawUtil.h"
#include "GeometryObject.h"
#include "DrawViewPart.h"
//#include <QDebug>
@ -82,10 +83,11 @@ struct EdgePoints {
//debugging routine signatures
const char* _printBool(bool b);
GeometryObject::GeometryObject(DrawView* parent) :
GeometryObject::GeometryObject(DrawViewPart* parent) :
Tolerance(0.05f),
Scale(1.f),
m_parent(parent)
m_parent(parent),
m_isoCount(0)
{
}
@ -104,9 +106,40 @@ void GeometryObject::setScale(double value)
Scale = value;
}
const std::vector<BaseGeom *> GeometryObject::getVisibleFaceEdges() const
{
std::vector<BaseGeom *> result;
bool smoothOK = m_parent->ShowSmoothLines.getValue();
bool seamOK = m_parent->ShowSeamLines.getValue();
for (auto& e:edgeGeom) {
if (e->visible) {
switch (e->classOfEdge) {
case ecHARD:
case ecOUTLINE:
result.push_back(e);
break;
case ecSMOOTH:
if (smoothOK) {
result.push_back(e);
}
break;
case ecSEAM:
if (seamOK) {
result.push_back(e);
}
break;
default:
;
}
}
}
return result;
}
void GeometryObject::clear()
{
for(std::vector<BaseGeom *>::iterator it = edgeGeom.begin(); it != edgeGeom.end(); ++it) {
delete *it;
*it = 0;
@ -141,7 +174,7 @@ void GeometryObject::projectShape(const TopoDS_Shape& input,
Handle_HLRBRep_Algo brep_hlr = NULL;
try {
brep_hlr = new HLRBRep_Algo();
brep_hlr->Add(input);
brep_hlr->Add(input, m_isoCount);
// Project the shape into view space with the object's centroid
// at the origin.
@ -212,6 +245,9 @@ void GeometryObject::extractGeometry(edgeClass category, bool visible)
case ecSEAM:
filtEdges = visSeam;
break;
case ecUVISO:
filtEdges = visIso;
break;
default:
Base::Console().Warning("GeometryObject::ExtractGeometry - unsupported visible edgeClass: %d\n",category);
return;
@ -221,7 +257,18 @@ void GeometryObject::extractGeometry(edgeClass category, bool visible)
case ecHARD:
filtEdges = hidHard;
break;
//more cases here?
case ecOUTLINE:
filtEdges = hidOutline;
break;
case ecSMOOTH:
filtEdges = hidSmooth;
break;
case ecSEAM:
filtEdges = hidSeam;
break;
case ecUVISO:
filtEdges = hidIso;
break;
default:
Base::Console().Warning("GeometryObject::ExtractGeometry - unsupported hidden edgeClass: %d\n",category);
return;
@ -239,10 +286,6 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
return; // There is no OpenCascade Geometry to be calculated
}
// build a mesh to explore the shape
//BRepMesh_IncrementalMesh(edgeCompound, Tolerance); //TODO: is this needed? no idea why we need to mesh shape doesn't seem to change anything
// Explore all edges of edgeCompound and calculate base geometry representation
BaseGeom* base;
TopExp_Explorer edges(edgeCompound, TopAbs_EDGE);
for (int i = 1 ; edges.More(); edges.Next(),i++) {
@ -313,7 +356,7 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
}
}
}
}
} //end TopExp
}
//! empty Face geometry

View File

@ -32,8 +32,14 @@
#include <string>
#include <vector>
#include "DrawView.h"
#include "Geometry.h"
//#include "DrawViewPart.h"
namespace TechDraw
{
class DrawViewPart;
class DrawView;
}
namespace TechDrawGeometry
{
@ -52,7 +58,7 @@ class TechDrawExport GeometryObject
{
public:
/// Constructor
GeometryObject(TechDraw::DrawView* parent);
GeometryObject(TechDraw::DrawViewPart* parent);
virtual ~GeometryObject();
void clear();
@ -65,6 +71,7 @@ public:
const std::vector<Vertex *> & getVertexGeometry() const { return vertexGeom; };
const std::vector<BaseGeom *> & getEdgeGeometry() const { return edgeGeom; };
const std::vector<BaseGeom *> getVisibleFaceEdges() const;
const std::vector<Face *> & getFaceGeometry() const { return faceGeom; };
void projectShape(const TopoDS_Shape &input,
@ -74,6 +81,7 @@ public:
void extractGeometry(edgeClass category, bool visible);
void addFaceGeom(Face * f);
void clearFaceGeom();
void setIsoCount(int i) { m_isoCount = i; }
protected:
//HLR output
@ -121,7 +129,8 @@ protected:
double Tolerance;
double Scale;
TechDraw::DrawView* m_parent;
TechDraw::DrawViewPart* m_parent;
int m_isoCount;
};
} //namespace TechDrawGeometry

View File

@ -247,15 +247,20 @@ void QGIViewPart::updateView(bool update)
if (update ||
viewPart->isTouched() ||
viewPart->Source.isTouched() ||
viewPart->Direction.isTouched() ||
viewPart->XAxisDirection.isTouched() ||
viewPart->Tolerance.isTouched() ||
viewPart->Scale.isTouched() ||
viewPart->ShowHiddenLines.isTouched() ||
viewPart->ShowSmoothLines.isTouched() ||
viewPart->ShowSeamLines.isTouched() ) {
viewPart->isTouched() ||
viewPart->Source.isTouched() ||
viewPart->Direction.isTouched() ||
viewPart->XAxisDirection.isTouched() ||
viewPart->Tolerance.isTouched() ||
viewPart->Scale.isTouched() ||
viewPart->ShowHiddenLines.isTouched() ||
viewPart->ShowSmoothLines.isTouched() ||
viewPart->ShowSeamLines.isTouched() ||
viewPart->ShowIsoLines.isTouched() ||
viewPart->SmoothHidden.isTouched() ||
viewPart->SeamHidden.isTouched() ||
viewPart->IsoHidden.isTouched() ||
viewPart->IsoCount.isTouched() ) {
draw();
} else if (update ||
viewPart->LineWidth.isTouched() ||
@ -282,8 +287,6 @@ void QGIViewPart::draw() {
void QGIViewPart::drawViewPart()
{
//Base::Console().Message("TRACE - QGIVP::drawViewPart\n");
auto viewPart( dynamic_cast<TechDraw::DrawViewPart *>(getViewObject()) );
if ( viewPart == nullptr ) {
return;
@ -291,6 +294,7 @@ void QGIViewPart::drawViewPart()
float lineWidth = viewPart->LineWidth.getValue() * lineScaleFactor;
float lineWidthHid = viewPart->HiddenWidth.getValue() * lineScaleFactor;
float lineWidthIso = viewPart->IsoWidth.getValue() * lineScaleFactor;
prepareGeometryChange();
removePrimitives(); //clean the slate
@ -329,11 +333,16 @@ void QGIViewPart::drawViewPart()
if (((*itEdge)->classOfEdge == ecHARD) ||
((*itEdge)->classOfEdge == ecOUTLINE) ||
(((*itEdge)->classOfEdge == ecSMOOTH) && viewPart->ShowSmoothLines.getValue()) ||
(((*itEdge)->classOfEdge == ecSEAM) && viewPart->ShowSeamLines.getValue())) {
(((*itEdge)->classOfEdge == ecSEAM) && viewPart->ShowSeamLines.getValue()) ||
(((*itEdge)->classOfEdge == ecUVISO) && viewPart->ShowIsoLines.getValue())) {
showEdge = true;
}
} else {
if (viewPart->ShowHiddenLines.getValue()) {
if ( (((*itEdge)->classOfEdge == ecHARD) && (viewPart->ShowHiddenLines.getValue())) ||
(((*itEdge)->classOfEdge == ecOUTLINE) && (viewPart->ShowHiddenLines.getValue())) ||
(((*itEdge)->classOfEdge == ecSMOOTH) && (viewPart->SmoothHidden.getValue())) ||
(((*itEdge)->classOfEdge == ecSEAM) && (viewPart->SeamHidden.getValue())) ||
(((*itEdge)->classOfEdge == ecUVISO) && (viewPart->IsoHidden.getValue())) ) {
showEdge = true;
}
}
@ -349,6 +358,9 @@ void QGIViewPart::drawViewPart()
item->setHiddenEdge(true);
item->setZValue(ZVALUE::HIDEDGE);
}
if ((*itEdge)->classOfEdge == ecUVISO) {
item->setWidth(lineWidthIso);
}
item->setPrettyNormal();
//debug a path
//QPainterPath edgePath=drawPainterPath(*itEdge);
@ -454,8 +466,6 @@ void QGIViewPart::removeDecorations()
void QGIViewPart::drawSectionLine(bool b)
{
//Base::Console().Message("TRACE - QGIVP::drawSectionLine);
TechDraw::DrawViewPart *viewPart = static_cast<TechDraw::DrawViewPart *>(getViewObject());
TechDraw::DrawViewSection *viewSection = viewPart->getSectionRef();
if (!viewPart ||