Prevent DetailView crop circle marker

This commit is contained in:
WandererFan 2017-01-11 15:40:33 -05:00
parent 0cb29cfa45
commit afa8c9fece
4 changed files with 53 additions and 45 deletions

View File

@ -127,7 +127,7 @@ std::vector<TopoDS_Edge> DrawProjectSplit::getEdgesForWalker(TopoDS_Shape shape,
TechDrawGeometry::GeometryObject* DrawProjectSplit::buildGeometryObject(TopoDS_Shape shape,
const gp_Ax2& viewAxis)
{
TechDrawGeometry::GeometryObject* geometryObject = new TechDrawGeometry::GeometryObject("DrawProjectSplit");
TechDrawGeometry::GeometryObject* geometryObject = new TechDrawGeometry::GeometryObject("DrawProjectSplit",nullptr);
geometryObject->projectShape(shape,
viewAxis);

View File

@ -225,7 +225,7 @@ void DrawViewPart::onChanged(const App::Property* prop)
//note: slightly different than routine with same name in DrawProjectSplit
TechDrawGeometry::GeometryObject* DrawViewPart::buildGeometryObject(TopoDS_Shape shape, gp_Ax2 viewAxis)
{
TechDrawGeometry::GeometryObject* go = new TechDrawGeometry::GeometryObject(getNameInDocument());
TechDrawGeometry::GeometryObject* go = new TechDrawGeometry::GeometryObject(getNameInDocument(), this);
go->setIsoCount(IsoCount.getValue());
Base::Vector3d baseProjDir = Direction.getValue();
@ -428,7 +428,11 @@ TechDrawGeometry::BaseGeom* DrawViewPart::getProjEdgeByIndex(int idx) const
Base::Console().Log("INFO - getProjEdgeByIndex(%d) - no Edge Geometry. Probably restoring?\n",idx);
return NULL;
}
return geoms[idx];
if ((unsigned)idx >= geoms.size()) {
Base::Console().Log("INFO - getProjEdgeByIndex(%d) - invalid index\n",idx);
return NULL;
}
return geoms.at(idx);
}
//! returns existing geometry of 2D Vertex(idx)
@ -439,13 +443,18 @@ TechDrawGeometry::Vertex* DrawViewPart::getProjVertexByIndex(int idx) const
Base::Console().Log("INFO - getProjVertexByIndex(%d) - no Vertex Geometry. Probably restoring?\n",idx);
return NULL;
}
return geoms[idx];
if ((unsigned)idx >= geoms.size()) {
Base::Console().Log("INFO - getProjVertexByIndex(%d) - invalid index\n",idx);
return NULL;
}
return geoms.at(idx);
}
//! returns existing geometry of 2D Face(idx)
//version 1 Face has 1 wire
std::vector<TechDrawGeometry::BaseGeom*> DrawViewPart::getProjFaceByIndex(int /*idx*/) const
std::vector<TechDrawGeometry::BaseGeom*> DrawViewPart::getProjFaceByIndex(int idx) const
{
(void) idx;
std::vector<TechDrawGeometry::BaseGeom*> result;
const std::vector<TechDrawGeometry::Face *>& faces = getFaceGeometry();
for (auto& f:faces) {

View File

@ -67,6 +67,7 @@
#include "DrawUtil.h"
#include "GeometryObject.h"
#include "DrawViewPart.h"
#include "DrawViewDetail.h"
using namespace TechDrawGeometry;
using namespace TechDraw;
@ -77,9 +78,9 @@ struct EdgePoints {
TopoDS_Edge edge;
};
GeometryObject::GeometryObject(const string& parent) :
Scale(1.f),
GeometryObject::GeometryObject(const string& parent, TechDraw::DrawView* parentObj) :
m_parentName(parent),
m_parent(parentObj),
m_isoCount(0)
{
}
@ -89,12 +90,6 @@ GeometryObject::~GeometryObject()
clear();
}
void GeometryObject::setScale(double value)
{
Scale = value;
}
const std::vector<BaseGeom *> GeometryObject::getVisibleFaceEdges(const bool smooth, const bool seam) const
{
std::vector<BaseGeom *> result;
@ -157,17 +152,6 @@ void GeometryObject::projectShape(const TopoDS_Shape& input,
// Clear previous Geometry
clear();
//*******
gp_Dir x = viewAxis.XDirection();
gp_Dir y = viewAxis.YDirection();
gp_Dir z = viewAxis.Direction();
Base::Vector3d vx(x.X(),x.Y(),x.Z());
Base::Vector3d vy(y.X(),y.Y(),y.Z());
Base::Vector3d vz(z.X(),z.Y(),z.Z());
// Base::Console().Message("TRACE - GO::projectShape - %s viewAxis x: %s y: %s Z: %s\n",m_parentName.c_str(),
// DrawUtil::formatVector(vx).c_str(), DrawUtil::formatVector(vy).c_str(), DrawUtil::formatVector(vz).c_str());
//*******
auto start = chrono::high_resolution_clock::now();
Handle_HLRBRep_Algo brep_hlr = NULL;
@ -301,6 +285,7 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
edgeGeom.push_back(base);
//add vertices of new edge if not already in list
bool skipDetail = false;
if (visible) {
BaseGeom* lastAdded = edgeGeom.back();
bool v1Add = true, v2Add = true;
@ -310,9 +295,23 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
TechDrawGeometry::Circle* circle = dynamic_cast<TechDrawGeometry::Circle*>(lastAdded);
TechDrawGeometry::Vertex* c1 = nullptr;
if (circle) {
c1 = new TechDrawGeometry::Vertex(circle->center);
c1->isCenter = true;
c1->visible = true;
// if this is the center of a detail view, skip it
TechDraw::DrawViewDetail* detail = isParentDetail();
if (detail != nullptr) {
double scale = m_parent->Scale.getValue();
if ((circle->center == Base::Vector2d(0.0,0.0)) &&
(DrawUtil::fpCompare(circle->radius, scale * detail->getFudgeRadius()))) {
skipDetail = true;
} else {
c1 = new TechDrawGeometry::Vertex(circle->center);
c1->isCenter = true;
c1->visible = true;
}
} else {
c1 = new TechDrawGeometry::Vertex(circle->center);
c1->isCenter = true;
c1->visible = true;
}
}
std::vector<Vertex *>::iterator itVertex = vertexGeom.begin();
@ -323,7 +322,7 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
if ((*itVertex)->isEqual(v2,Precision::Confusion())) {
v2Add = false;
}
if (circle) {
if (circle && !skipDetail) {
if ((*itVertex)->isEqual(c1,Precision::Confusion())) {
c1Add = false;
}
@ -343,7 +342,7 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca
delete v2;
}
if (circle) {
if (circle && !skipDetail) {
if (c1Add) {
vertexGeom.push_back(c1);
c1->visible = true;
@ -367,6 +366,18 @@ void GeometryObject::addFaceGeom(Face* f)
faceGeom.push_back(f);
}
TechDraw::DrawViewDetail* GeometryObject::isParentDetail()
{
TechDraw::DrawViewDetail* result = nullptr;
if (m_parent != nullptr) {
TechDraw::DrawViewDetail* detail = dynamic_cast<TechDraw::DrawViewDetail*>(m_parent);
if (detail != nullptr) {
result = detail;
}
}
return result;
}
bool GeometryObject::isWithinArc(double theta, double first,
double last, bool cw) const
@ -439,16 +450,6 @@ bool GeometryObject::findVertex(Base::Vector2d v)
return found;
}
//"Top" X should == "Front" X for front = [front,rear]
//"Top" X should == "Front" X for front = [right]
//"Top" X should == "Front" -X for front = [left]
//"Top" X should == "Front" X for front = [top,bottom]
//view XAxis == anchor XAxis except
// anchor.ProjDir = (-1,0,0) then
// view XAxis == -Anchor XAxis
/// utility non-class member functions
//! gets a coordinate system that matches view system used in 3D with +Z up (or +Y up if neccessary)
//! used for individual views, but not secondary views in projection groups

View File

@ -37,6 +37,7 @@
namespace TechDraw
{
class DrawViewPart;
class DrawViewDetail;
class DrawView;
}
@ -66,13 +67,11 @@ class TechDrawExport GeometryObject
{
public:
/// Constructor
GeometryObject(const std::string& parent);
GeometryObject(const std::string& parent, TechDraw::DrawView* parentObj);
virtual ~GeometryObject();
void clear();
void setScale(double value);
//! Returns 2D bounding box
Base::BoundBox3d calcBoundingBox() const;
@ -104,7 +103,7 @@ protected:
TopoDS_Shape hidIso;
void addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass category, bool visible);
TechDraw::DrawViewDetail* isParentDetail(void);
//similar function in Geometry?
/*!
@ -120,9 +119,8 @@ protected:
bool findVertex(Base::Vector2d v);
double Scale;
std::string m_parentName;
TechDraw::DrawView* m_parent;
int m_isoCount;
};