Fix issue 7 Projection Results

This commit is contained in:
WandererFan 2016-03-06 19:52:41 -05:00 committed by wmayer
parent d95bf4786d
commit 14a9fd4fcd
12 changed files with 692 additions and 1203 deletions

View File

@ -89,14 +89,15 @@ DrawViewPart::DrawViewPart(void) : geometryObject(0)
ADD_PROPERTY_TYPE(Direction ,(0,0,1.0) ,group,App::Prop_None,"Projection normal direction"); ADD_PROPERTY_TYPE(Direction ,(0,0,1.0) ,group,App::Prop_None,"Projection normal direction");
ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"3D Shape to view"); ADD_PROPERTY_TYPE(Source ,(0),group,App::Prop_None,"3D Shape to view");
ADD_PROPERTY_TYPE(ShowHiddenLines ,(false),group,App::Prop_None,"Control the appearance of the dashed hidden lines"); ADD_PROPERTY_TYPE(ShowHiddenLines ,(false),group,App::Prop_None,"Hidden lines on/off");
ADD_PROPERTY_TYPE(ShowSmoothLines ,(false),group,App::Prop_None,"Control the appearance of the smooth lines"); ADD_PROPERTY_TYPE(ShowSmoothLines ,(false),group,App::Prop_None,"Smooth lines on/off");
ADD_PROPERTY_TYPE(LineWidth,(0.7f),vgroup,App::Prop_None,"The thickness of the resulting lines"); ADD_PROPERTY_TYPE(ShowSeamLines ,(false),group,App::Prop_None,"Seam lines on/off");
ADD_PROPERTY_TYPE(HiddenWidth,(0.15),vgroup,App::Prop_None,"The thickness of the hidden lines, if enabled"); //ADD_PROPERTY_TYPE(ShowIsoLines ,(false),group,App::Prop_None,"Iso u,v lines on/off");
ADD_PROPERTY_TYPE(LineWidth,(0.7f),vgroup,App::Prop_None,"The thickness of visible lines");
ADD_PROPERTY_TYPE(HiddenWidth,(0.15),vgroup,App::Prop_None,"The thickness of hidden lines, if enabled");
ADD_PROPERTY_TYPE(Tolerance,(0.05f),vgroup,App::Prop_None,"The tessellation tolerance"); ADD_PROPERTY_TYPE(Tolerance,(0.05f),vgroup,App::Prop_None,"The tessellation tolerance");
Tolerance.setConstraints(&floatRange); Tolerance.setConstraints(&floatRange);
ADD_PROPERTY_TYPE(XAxisDirection ,(1,0,0) ,group,App::Prop_None,"X-Axis direction"); ADD_PROPERTY_TYPE(XAxisDirection ,(1,0,0) ,group,App::Prop_None,"Direction to use as X-axis in projection");
//ADD_PROPERTY_TYPE(HatchAreas ,(0),vgroup,App::Prop_None,"Hatched areas of this view");
geometryObject = new TechDrawGeometry::GeometryObject(); geometryObject = new TechDrawGeometry::GeometryObject();
} }
@ -124,22 +125,13 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
} }
try { try {
geometryObject->setTolerance(Tolerance.getValue()); buildGeometryObject(shape);
geometryObject->setScale(Scale.getValue());
geometryObject->extractGeometry(shape,
Direction.getValue(),
ShowHiddenLines.getValue(),
_getValidXDir(this));
bbox = geometryObject->calcBoundingBox();
touch();
} }
catch (Standard_Failure) { catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught(); Handle_Standard_Failure e = Standard_Failure::Caught();
return new App::DocumentObjectExecReturn(e->GetMessageString()); return new App::DocumentObjectExecReturn(e->GetMessageString());
} }
// There is a guaranteed change so check any references linked to this and touch // There is a guaranteed change so check any references linked to this and touch
// We need to update all views pointing at this (ProjectionGroup, ClipGroup, etc) // We need to update all views pointing at this (ProjectionGroup, ClipGroup, etc)
std::vector<App::DocumentObject*> parent = getInList(); std::vector<App::DocumentObject*> parent = getInList();
@ -150,6 +142,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void)
} }
} }
touch();
return DrawView::execute(); return DrawView::execute();
} }
@ -160,7 +153,9 @@ short DrawViewPart::mustExecute() const
Source.isTouched() || Source.isTouched() ||
Scale.isTouched() || Scale.isTouched() ||
ScaleType.isTouched() || ScaleType.isTouched() ||
ShowHiddenLines.isTouched()); ShowHiddenLines.isTouched() ||
ShowSmoothLines.isTouched() ||
ShowSeamLines.isTouched());
return result; return result;
} }
@ -172,7 +167,9 @@ void DrawViewPart::onChanged(const App::Property* prop)
prop == &Source || prop == &Source ||
prop == &Scale || prop == &Scale ||
prop == &ScaleType || prop == &ScaleType ||
prop == &ShowHiddenLines) { prop == &ShowHiddenLines ||
prop == &ShowSmoothLines ||
prop == &ShowSeamLines) {
try { try {
App::DocumentObjectExecReturn *ret = recompute(); App::DocumentObjectExecReturn *ret = recompute();
delete ret; delete ret;
@ -183,43 +180,45 @@ void DrawViewPart::onChanged(const App::Property* prop)
} }
DrawView::onChanged(prop); DrawView::onChanged(prop);
//TODO: when scale changes, any Dimensions for this View sb recalculated. //TODO: when scale changes, any Dimensions for this View sb recalculated. (might happen anyway if document is recomputed?)
} }
#if 0 void DrawViewPart::buildGeometryObject(TopoDS_Shape shape)
int DrawViewPart::addHatch(App::DocumentObject *docObj)
{ {
if(!docObj->isDerivedFrom(TechDraw::DrawHatch::getClassTypeId())) geometryObject->setTolerance(Tolerance.getValue());
return -1; geometryObject->setScale(Scale.getValue());
//TODO: need to pass ShowSmoothLines, ShowSeamLines
const std::vector<App::DocumentObject *> currAreas = HatchAreas.getValues(); //geometryObject->extractGeometry(shape,
std::vector<App::DocumentObject *> newAreas(currAreas); // Direction.getValue(),
newAreas.push_back(docObj); // ShowHiddenLines.getValue(),
HatchAreas.setValues(newAreas); // _getValidXDir(this));
HatchAreas.touch(); geometryObject->initHLR(shape,
return HatchAreas.getSize(); Direction.getValue(),
} _getValidXDir(this));
geometryObject->extractGeometry(TechDrawGeometry::ecHARD,
int DrawViewPart::removeHatch(App::DocumentObject *docObj) true);
{ geometryObject->extractGeometry(TechDrawGeometry::ecOUTLINE,
if(!docObj->isDerivedFrom(TechDraw::DrawHatch::getClassTypeId())) true);
return -1; if (ShowSmoothLines.getValue()) {
geometryObject->extractGeometry(TechDrawGeometry::ecSMOOTH,
const std::vector<App::DocumentObject*> currAreas = HatchAreas.getValues(); true);
std::vector<App::DocumentObject*> newAreas;
std::vector<App::DocumentObject*>::const_iterator it = currAreas.begin();
for (; it != currAreas.end(); it++) {
std::string areaName = docObj->getNameInDocument();
if (areaName.compare((*it)->getNameInDocument()) != 0) {
newAreas.push_back((*it));
} }
if (ShowSeamLines.getValue()) {
geometryObject->extractGeometry(TechDrawGeometry::ecSEAM,
true);
} }
HatchAreas.setValues(newAreas); //if (ShowIsoLines.getValue()) {
HatchAreas.touch(); // geometryObject->extractGeometry(TechDrawGeometry::ecUVISO,
// true);
return HatchAreas.getSize(); //}
if (ShowHiddenLines.getValue()) {
geometryObject->extractGeometry(TechDrawGeometry::ecHARD,
false);
//geometryObject->extractGeometry(TechDrawGeometry::ecOUTLINE, //hidden outline,smooth,seam??
// true);
}
bbox = geometryObject->calcBoundingBox();
} }
#endif
std::vector<TechDraw::DrawHatch*> DrawViewPart::getHatches() const std::vector<TechDraw::DrawHatch*> DrawViewPart::getHatches() const
{ {

View File

@ -51,10 +51,11 @@ public:
virtual ~DrawViewPart(); virtual ~DrawViewPart();
App::PropertyLink Source; //Part Feature App::PropertyLink Source; //Part Feature
App::PropertyVector Direction; //TODO: Rename to YAxisDirection or whatever this actually is App::PropertyVector Direction; //TODO: Rename to YAxisDirection or whatever this actually is (ProjectionDirection)
App::PropertyVector XAxisDirection; App::PropertyVector XAxisDirection;
App::PropertyBool ShowHiddenLines; App::PropertyBool ShowHiddenLines;
App::PropertyBool ShowSmoothLines; App::PropertyBool ShowSmoothLines;
App::PropertyBool ShowSeamLines;
App::PropertyFloat LineWidth; App::PropertyFloat LineWidth;
App::PropertyFloat HiddenWidth; App::PropertyFloat HiddenWidth;
App::PropertyFloatConstraint Tolerance; App::PropertyFloatConstraint Tolerance;
@ -108,7 +109,7 @@ public:
protected: protected:
void onChanged(const App::Property* prop); void onChanged(const App::Property* prop);
void buildGeometryObject(TopoDS_Shape shape);
TechDrawGeometry::GeometryObject *geometryObject; TechDrawGeometry::GeometryObject *geometryObject;
Base::BoundBox3d bbox; Base::BoundBox3d bbox;

View File

@ -204,26 +204,37 @@ App::DocumentObjectExecReturn *DrawViewSection::execute(void)
if (!mkCut.IsDone()) if (!mkCut.IsDone())
return new App::DocumentObjectExecReturn("Section cut has failed"); return new App::DocumentObjectExecReturn("Section cut has failed");
// Cache the result // Cache the sectionShape
result = mkCut.Shape(); sectionShape = mkCut.Shape();
try { try {
geometryObject->setTolerance(Tolerance.getValue()); buildGeometryObject(sectionShape);
geometryObject->setScale(Scale.getValue());
//TODO: Do we need to check for nonzero XAxisDirection here?
geometryObject->extractGeometry(result, Direction.getValue(), ShowHiddenLines.getValue(), XAxisDirection.getValue());
bbox = geometryObject->calcBoundingBox();
touch();
} }
catch (Standard_Failure) { catch (Standard_Failure) {
Handle_Standard_Failure e = Standard_Failure::Caught(); Handle_Standard_Failure e1 = Standard_Failure::Caught();
Base::Console().Log("DrawViewSection::execute - extractGeometry failed: %s\n",e->GetMessageString()); Base::Console().Log("DrawViewSection::execute - extractGeometry failed: %s\n",e1->GetMessageString());
return new App::DocumentObjectExecReturn(e->GetMessageString()); return new App::DocumentObjectExecReturn(e1->GetMessageString());
}
TopoDS_Compound sectionFaces;
try {
sectionFaces = getSectionFaces();
}
catch (Standard_Failure) {
Handle_Standard_Failure e2 = Standard_Failure::Caught();
Base::Console().Log("DrawViewSection::execute - getSectionFaces failed: %s\n",e2->GetMessageString());
return new App::DocumentObjectExecReturn(e2->GetMessageString());
}
if (!sectionFaces.IsNull()) {
//TODO: do something with sectionFaces
//?add to GeometryObject faceGeom? but need to tag these faces as "special"
//how does QGIVSection know to shade these faces??
} }
// TODO: touch references? see DrawViewPart.execute() // TODO: touch references? see DrawViewPart.execute()
return DrawView::execute(); //sb DrawViewPart? touch();
return DrawView::execute(); //note: not DrawViewPart
} }
gp_Pln DrawViewSection::getSectionPlane() const gp_Pln DrawViewSection::getSectionPlane() const
@ -234,39 +245,37 @@ gp_Pln DrawViewSection::getSectionPlane() const
return gp_Pln(gp_Pnt(plnPnt.x, plnPnt.y, plnPnt.z), gp_Dir(plnNorm.x, plnNorm.y, plnNorm.z)); return gp_Pln(gp_Pnt(plnPnt.x, plnPnt.y, plnPnt.z), gp_Dir(plnNorm.x, plnNorm.y, plnNorm.z));
} }
//! tries to find the intersection of the section plane with the part??? //! tries to find the intersection of the section plane with the sectionShape (a collection of planar faces)
//face logic is turned off in GeometryObject, so this won't work now. TopoDS_Compound DrawViewSection::getSectionFaces(void)
void DrawViewSection::getSectionSurface(std::vector<TechDrawGeometry::Face *> &sectionFace) const { {
TopoDS_Compound result;
#if MOD_TECHDRAW_HANDLE_FACES if(sectionShape.IsNull()){
if(result.IsNull()){ //throw Base::Exception("Sectional View sectionShape is Empty");
//throw Base::Exception("Sectional View Result is Empty"); Base::Console().Log("DrawViewSection::getSectionSurface - Sectional View sectionShape is Empty\n");
Base::Console().Log("DrawViewSection::getSectionSurface - Sectional View Result is Empty\n"); return result;
return;
} }
gp_Pln pln = getSectionPlane(); gp_Pln pln = getSectionPlane();
BRep_Builder builder; BRep_Builder builder;
TopoDS_Compound comp; builder.MakeCompound(result);
builder.MakeCompound(comp);
// Iterate through all faces // Iterate through all faces
TopExp_Explorer face(result, TopAbs_FACE); TopExp_Explorer expFaces(sectionShape, TopAbs_FACE);
for ( ; faces.More(); faces.Next()) { for ( ; expFaces.More(); expFaces.Next()) {
const TopoDS_Face& face = TopoDS::Face(faces.Current()); const TopoDS_Face& face = TopoDS::Face(expFaces.Current());
BRepAdaptor_Surface adapt(face); BRepAdaptor_Surface adapt(face);
if (adapt.GetType() == GeomAbs_Plane){ if (adapt.GetType() == GeomAbs_Plane){
gp_Pln plane = adapt.Plane(); gp_Pln plane = adapt.Plane();
if(plane.Contains(pln.Location(), Precision::Confusion()) && plane.Axis().IsParallel(pln.Axis(), Precision::Angular())) { if(plane.Contains(pln.Location(), Precision::Confusion()) && plane.Axis().IsParallel(pln.Axis(), Precision::Angular())) {
builder.Add(comp, face); builder.Add(result, face);
} }
} }
} }
//TODO: Do we need to check for nonzero XAxisDirection here? return result;
geometryObject->projectSurfaces(comp, result, Direction.getValue(), XAxisDirection.getValue(), sectionFace);
#endif
} }
// Python Drawing feature --------------------------------------------------------- // Python Drawing feature ---------------------------------------------------------
namespace App { namespace App {

View File

@ -30,6 +30,7 @@
#include "DrawViewPart.h" #include "DrawViewPart.h"
class gp_Pln; class gp_Pln;
class TopoDS_Compound;
namespace TechDraw namespace TechDraw
{ {
@ -65,10 +66,10 @@ public:
} }
public: public:
void getSectionSurface(std::vector<TechDrawGeometry::Face *> &sectionFace) const; TopoDS_Compound getSectionFaces(void);
protected: protected:
TopoDS_Shape result; TopoDS_Shape sectionShape;
gp_Pln getSectionPlane() const; gp_Pln getSectionPlane() const;
}; };

View File

@ -30,6 +30,7 @@
#include <Bnd_Box.hxx> #include <Bnd_Box.hxx>
#include <BRepBndLib.hxx> #include <BRepBndLib.hxx>
#include <BRepLib.hxx>
#include <BRepBuilderAPI_Transform.hxx> #include <BRepBuilderAPI_Transform.hxx>
#include <HLRBRep_Algo.hxx> #include <HLRBRep_Algo.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
@ -109,50 +110,23 @@ Face::~Face()
BaseGeom::BaseGeom() : BaseGeom::BaseGeom() :
geomType(NOTDEF), geomType(NOTDEF),
reversed(false) extractType(Plain),
classOfEdge(ecNONE),
visible(true),
reversed(false),
ref3D(-1)
{ {
} }
//! ugh. yuck.
std::vector<Base::Vector2D> BaseGeom::findEndPoints() std::vector<Base::Vector2D> BaseGeom::findEndPoints()
{ {
std::vector<Base::Vector2D> result; std::vector<Base::Vector2D> result;
switch(this->geomType) { //if (occEdge) {
case TechDrawGeometry::CIRCLE: { gp_Pnt p = BRep_Tool::Pnt(TopExp::FirstVertex(occEdge));
TechDrawGeometry::Circle *geom = static_cast<TechDrawGeometry::Circle *>(this); result.push_back(Base::Vector2D(p.X(),p.Y()));
double x = geom->center.fX + geom->radius; p = BRep_Tool::Pnt(TopExp::LastVertex(occEdge));
result.push_back(Base::Vector2D(x,geom->center.fY)); result.push_back(Base::Vector2D(p.X(),p.Y()));
result.push_back(Base::Vector2D(x,geom->center.fY)); //}
} break;
case TechDrawGeometry::ARCOFCIRCLE: {
TechDrawGeometry::AOC *geom = static_cast<TechDrawGeometry::AOC *>(this);
result.push_back(geom->startPnt);
result.push_back(geom->endPnt);
} break;
case TechDrawGeometry::ELLIPSE: {
TechDrawGeometry::Ellipse *geom = static_cast<TechDrawGeometry::Ellipse *>(this);
result.push_back(geom->center + Base::Vector2D(geom->major * cos(geom->angle), geom->major * sin(geom->angle)));
result.push_back(geom->center + Base::Vector2D(geom->major * cos(geom->angle), geom->major * sin(geom->angle)));
} break;
case TechDrawGeometry::ARCOFELLIPSE: {
TechDrawGeometry::AOE *geom = static_cast<TechDrawGeometry::AOE *>(this);
result.push_back(geom->startPnt);
result.push_back(geom->endPnt);
} break;
case TechDrawGeometry::BSPLINE: {
TechDrawGeometry::BSpline *geom = static_cast<TechDrawGeometry::BSpline *>(this);
result.push_back(geom->segments.front().pnts[0]);
TechDrawGeometry::BezierSegment tempSeg = geom->segments.back();
result.push_back(tempSeg.pnts[tempSeg.poles - 1]);
} break;
case TechDrawGeometry::GENERIC: {
TechDrawGeometry::Generic *geom = static_cast<TechDrawGeometry::Generic *>(this);
result.push_back(geom->points.front());
result.push_back(geom->points.back());
} break;
default:
break;
}
return result; return result;
} }
@ -168,15 +142,11 @@ Base::Vector2D BaseGeom::getEndPoint()
return verts[1]; return verts[1];
} }
Ellipse::Ellipse() Ellipse::Ellipse(const TopoDS_Edge &e)
{ {
geomType = ELLIPSE; geomType = ELLIPSE;
} BRepAdaptor_Curve c(e);
occEdge = e;
Ellipse::Ellipse(const BRepAdaptor_Curve& c)
{
geomType = ELLIPSE;
gp_Elips ellp = c.Ellipse(); gp_Elips ellp = c.Ellipse();
const gp_Pnt &p = ellp.Location(); const gp_Pnt &p = ellp.Location();
@ -189,23 +159,20 @@ Ellipse::Ellipse(const BRepAdaptor_Curve& c)
angle = xaxis.AngleWithRef(gp_Dir(1, 0, 0), gp_Dir(0, 0, -1)); angle = xaxis.AngleWithRef(gp_Dir(1, 0, 0), gp_Dir(0, 0, -1));
} }
AOE::AOE()
{
geomType = ARCOFELLIPSE;
}
AOE::AOE(const BRepAdaptor_Curve& c) : Ellipse(c) AOE::AOE(const TopoDS_Edge &e) : Ellipse(e)
{ {
geomType = ARCOFELLIPSE; geomType = ARCOFELLIPSE;
BRepAdaptor_Curve c(e);
double f = c.FirstParameter(); double f = c.FirstParameter();
double l = c.LastParameter(); double l = c.LastParameter();
gp_Pnt s = c.Value(f); gp_Pnt s = c.Value(f);
gp_Pnt m = c.Value((l+f)/2.0); gp_Pnt m = c.Value((l+f)/2.0);
gp_Pnt e = c.Value(l); gp_Pnt ePt = c.Value(l);
gp_Vec v1(m,s); gp_Vec v1(m,s);
gp_Vec v2(m,e); gp_Vec v2(m,ePt);
gp_Vec v3(0,0,1); gp_Vec v3(0,0,1);
double a = v3.DotCross(v1,v2); double a = v3.DotCross(v1,v2);
@ -215,38 +182,15 @@ AOE::AOE(const BRepAdaptor_Curve& c) : Ellipse(c)
largeArc = (l-f > M_PI) ? true : false; largeArc = (l-f > M_PI) ? true : false;
startPnt = Base::Vector2D(s.X(), s.Y()); startPnt = Base::Vector2D(s.X(), s.Y());
endPnt = Base::Vector2D(e.X(), e.Y()); endPnt = Base::Vector2D(ePt.X(), ePt.Y());
midPnt = Base::Vector2D(m.X(), m.Y()); midPnt = Base::Vector2D(m.X(), m.Y());
/*
char las = (l-f > D_PI) ? '1' : '0'; // large-arc-flag
char swp = (a < 0) ? '1' : '0'; // sweep-flag, i.e. clockwise (0) or counter-clockwise (1)
out << "<path d=\"M" << s.X() << " " << s.Y()
<< " A" << r1 << " " << r2 << " "
<< angle << " " << las << " " << swp << " "
<< e.X() << " " << e.Y() << "\" />" << std::endl;
// if (startAngle > endAngle) {// if arc is reversed
// std::swap(startAngle, endAngle);
// }*/
// double ax = s.X() - center.fX;
// double ay = s.Y() - center.fY;
// double bx = e.X() - center.fX;
// double by = e.Y() - center.fY;
// startAngle = f;
// float range = l-f;
//
// endAngle = startAngle + range;
} }
Circle::Circle() Circle::Circle(const TopoDS_Edge &e)
{
geomType = CIRCLE;
}
Circle::Circle(const BRepAdaptor_Curve& c)
{ {
geomType = CIRCLE; geomType = CIRCLE;
BRepAdaptor_Curve c(e);
occEdge = e;
gp_Circ circ = c.Circle(); gp_Circ circ = c.Circle();
const gp_Pnt& p = circ.Location(); const gp_Pnt& p = circ.Location();
@ -255,23 +199,19 @@ Circle::Circle(const BRepAdaptor_Curve& c)
center = Base::Vector2D(p.X(), p.Y()); center = Base::Vector2D(p.X(), p.Y());
} }
AOC::AOC() AOC::AOC(const TopoDS_Edge &e) : Circle(e)
{
geomType = ARCOFCIRCLE;
}
AOC::AOC(const BRepAdaptor_Curve& c) : Circle(c)
{ {
geomType = ARCOFCIRCLE; geomType = ARCOFCIRCLE;
BRepAdaptor_Curve c(e);
double f = c.FirstParameter(); double f = c.FirstParameter();
double l = c.LastParameter(); double l = c.LastParameter();
gp_Pnt s = c.Value(f); gp_Pnt s = c.Value(f);
gp_Pnt m = c.Value((l+f)/2.0); gp_Pnt m = c.Value((l+f)/2.0);
gp_Pnt e = c.Value(l); gp_Pnt ePt = c.Value(l);
gp_Vec v1(m,s); gp_Vec v1(m,s);
gp_Vec v2(m,e); gp_Vec v2(m,ePt);
gp_Vec v3(0,0,1); gp_Vec v3(0,0,1);
double a = v3.DotCross(v1,v2); double a = v3.DotCross(v1,v2);
@ -281,46 +221,49 @@ AOC::AOC(const BRepAdaptor_Curve& c) : Circle(c)
largeArc = (l-f > M_PI) ? true : false; largeArc = (l-f > M_PI) ? true : false;
startPnt = Base::Vector2D(s.X(), s.Y()); startPnt = Base::Vector2D(s.X(), s.Y());
endPnt = Base::Vector2D(e.X(), e.Y()); endPnt = Base::Vector2D(ePt.X(), ePt.Y());
midPnt = Base::Vector2D(m.X(), m.Y()); midPnt = Base::Vector2D(m.X(), m.Y());
} }
//!Generic is a multiline
Generic::Generic(const TopoDS_Edge &e)
{
geomType = GENERIC;
occEdge = e;
BRepLib::BuildCurve3d(occEdge);
TopLoc_Location location;
Handle_Poly_Polygon3D polygon = BRep_Tool::Polygon3D(occEdge, location);
if (!polygon.IsNull()) {
const TColgp_Array1OfPnt &nodes = polygon->Nodes();
for (int i = nodes.Lower(); i <= nodes.Upper(); i++){
points.push_back(Base::Vector2D(nodes(i).X(), nodes(i).Y()));
}
} else {
//no polygon representation? approximate with line?
Base::Console().Log("INFO - Generic::Generic(edge) - polygon is NULL\n");
gp_Pnt p = BRep_Tool::Pnt(TopExp::FirstVertex(occEdge));
points.push_back(Base::Vector2D(p.X(), p.Y()));
p = BRep_Tool::Pnt(TopExp::LastVertex(occEdge));
points.push_back(Base::Vector2D(p.X(), p.Y()));
}
}
Generic::Generic() Generic::Generic()
{ {
geomType = GENERIC; geomType = GENERIC;
} }
Generic::Generic(const BRepAdaptor_Curve& c) BSpline::BSpline(const TopoDS_Edge &e)
{
geomType = GENERIC;
TopLoc_Location location;
Handle_Poly_Polygon3D polygon = BRep_Tool::Polygon3D(c.Edge(), location);
if (!polygon.IsNull()) {
const TColgp_Array1OfPnt &nodes = polygon->Nodes();
for (int i = nodes.Lower(); i <= nodes.Upper(); i++){
points.push_back(Base::Vector2D(nodes(i).X(), nodes(i).Y()));
}
}
}
Generic::Generic(Base::Vector2D start, Base::Vector2D end)
{
geomType = GENERIC;
points.push_back(start);
points.push_back(end);
}
BSpline::BSpline()
{
geomType = BSPLINE;
}
BSpline::BSpline(const BRepAdaptor_Curve &c)
{ {
geomType = BSPLINE; geomType = BSPLINE;
BRepAdaptor_Curve c(e);
occEdge = e;
Handle_Geom_BSplineCurve spline = c.BSpline(); Handle_Geom_BSplineCurve spline = c.BSpline();
if (spline->Degree() > 3) {
if (spline->Degree() > 3) { //if spline is too complex, approximate it
Standard_Real tol3D = 0.001; Standard_Real tol3D = 0.001;
Standard_Integer maxDegree = 3, maxSegment = 10; Standard_Integer maxDegree = 3, maxSegment = 10;
Handle_BRepAdaptor_HCurve hCurve = new BRepAdaptor_HCurve(c); Handle_BRepAdaptor_HCurve hCurve = new BRepAdaptor_HCurve(c);
@ -359,6 +302,14 @@ BSpline::BSpline(const BRepAdaptor_Curve &c)
//! can this BSpline be represented by a straight line? //! can this BSpline be represented by a straight line?
bool BSpline::isLine() bool BSpline::isLine()
{ {
bool result = false;
BRepAdaptor_Curve c(occEdge);
Handle_Geom_BSplineCurve spline = c.BSpline();
if (spline->Degree() == 1) {
result = true;
}
return result;
#if 0
bool result = true; bool result = true;
std::vector<BezierSegment>::iterator iSeg = segments.begin(); std::vector<BezierSegment>::iterator iSeg = segments.begin();
double slope; double slope;
@ -378,6 +329,18 @@ bool BSpline::isLine()
} }
} }
return result; return result;
#endif
}
//**** Vertex
bool Vertex::isEqual(Vertex* v, double tol)
{
bool result = false;
double dist = (pnt - (v->pnt)).Length();
if (dist <= tol) {
result = true;
}
return result;
} }
//**** TechDrawGeometry utility funtions //**** TechDrawGeometry utility funtions
@ -401,7 +364,7 @@ std::vector<TechDrawGeometry::BaseGeom*> TechDrawExport chainGeoms(std::vector<T
Base::Vector2D atPoint = (geoms[0])->getEndPoint(); Base::Vector2D atPoint = (geoms[0])->getEndPoint();
used[0] = true; used[0] = true;
for (unsigned int i = 1; i < geoms.size(); i++) { //do size-1 more edges for (unsigned int i = 1; i < geoms.size(); i++) { //do size-1 more edges
getNextReturn next = nextGeom(atPoint,geoms,used,tolerance); getNextReturnVal next = nextGeom(atPoint,geoms,used,tolerance);
if (next.index) { //found an unused edge with vertex == atPoint if (next.index) { //found an unused edge with vertex == atPoint
TechDrawGeometry::BaseGeom* nextEdge = geoms.at(next.index); TechDrawGeometry::BaseGeom* nextEdge = geoms.at(next.index);
used[next.index] = true; used[next.index] = true;
@ -422,12 +385,12 @@ std::vector<TechDrawGeometry::BaseGeom*> TechDrawExport chainGeoms(std::vector<T
} }
//! find an unused geom starts or ends at atPoint. returns index[1:geoms.size()),reversed [true,false] //! find an unused geom starts or ends at atPoint. returns index[1:geoms.size()),reversed [true,false]
getNextReturn TechDrawExport nextGeom(Base::Vector2D atPoint, getNextReturnVal TechDrawExport nextGeom(Base::Vector2D atPoint,
std::vector<TechDrawGeometry::BaseGeom*> geoms, std::vector<TechDrawGeometry::BaseGeom*> geoms,
std::vector<bool> used, std::vector<bool> used,
double tolerance) double tolerance)
{ {
getNextReturn result(0,false); getNextReturnVal result(0,false);
std::vector<TechDrawGeometry::BaseGeom*>::iterator itGeom = geoms.begin(); std::vector<TechDrawGeometry::BaseGeom*>::iterator itGeom = geoms.begin();
for (; itGeom != geoms.end(); itGeom++) { for (; itGeom != geoms.end(); itGeom++) {
unsigned int index = itGeom - geoms.begin(); unsigned int index = itGeom - geoms.begin();

View File

@ -24,16 +24,29 @@
#define TECHDRAW_GEOMETRY_H #define TECHDRAW_GEOMETRY_H
#include <Base/Tools2D.h> #include <Base/Tools2D.h>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
class BRepAdaptor_Curve; class BRepAdaptor_Curve;
namespace TechDrawGeometry { namespace TechDrawGeometry {
enum ExtractionType { enum ExtractionType { //obs sb vis/hid + hard/smooth/seam/out(edgeClass?)
Plain = 0, Plain = 0,
WithHidden = 1, WithHidden = 1,
WithSmooth = 2 WithSmooth = 2
}; };
enum edgeClass {
ecNONE, //not used, OCC index starts at 1
ecUVISO,
ecOUTLINE,
ecSMOOTH,
ecSEAM,
ecHARD
};
enum GeomType { enum GeomType {
NOTDEF, NOTDEF,
CIRCLE, CIRCLE,
@ -48,11 +61,15 @@ class TechDrawExport BaseGeom
{ {
public: public:
BaseGeom(); BaseGeom();
~BaseGeom() {} virtual ~BaseGeom() {}
public: public:
GeomType geomType; GeomType geomType;
ExtractionType extractType; ExtractionType extractType; //obs
edgeClass classOfEdge;
bool visible;
bool reversed; bool reversed;
int ref3D;
TopoDS_Edge occEdge; //projected Edge
std::vector<Base::Vector2D> findEndPoints(); std::vector<Base::Vector2D> findEndPoints();
Base::Vector2D getStartPoint(); Base::Vector2D getStartPoint();
Base::Vector2D getEndPoint(); Base::Vector2D getEndPoint();
@ -61,8 +78,7 @@ public:
class TechDrawExport Circle: public BaseGeom class TechDrawExport Circle: public BaseGeom
{ {
public: public:
Circle(const BRepAdaptor_Curve &c); Circle(const TopoDS_Edge &e);
Circle();
~Circle() {} ~Circle() {}
public: public:
Base::Vector2D center; Base::Vector2D center;
@ -72,8 +88,7 @@ public:
class TechDrawExport Ellipse: public BaseGeom class TechDrawExport Ellipse: public BaseGeom
{ {
public: public:
Ellipse(const BRepAdaptor_Curve &c); Ellipse(const TopoDS_Edge &e);
Ellipse();
~Ellipse() {} ~Ellipse() {}
public: public:
Base::Vector2D center; Base::Vector2D center;
@ -86,8 +101,7 @@ public:
class TechDrawExport AOE: public Ellipse class TechDrawExport AOE: public Ellipse
{ {
public: public:
AOE(const BRepAdaptor_Curve &c); AOE(const TopoDS_Edge &e);
AOE();
~AOE() {} ~AOE() {}
public: public:
Base::Vector2D startPnt; //TODO: The points are used for drawing, the angles for bounding box calcs - seems redundant Base::Vector2D startPnt; //TODO: The points are used for drawing, the angles for bounding box calcs - seems redundant
@ -105,8 +119,7 @@ public:
class TechDrawExport AOC: public Circle class TechDrawExport AOC: public Circle
{ {
public: public:
AOC(const BRepAdaptor_Curve &c); AOC(const TopoDS_Edge &e);
AOC();
~AOC() {} ~AOC() {}
public: public:
Base::Vector2D startPnt; Base::Vector2D startPnt;
@ -142,23 +155,20 @@ struct BezierSegment
class TechDrawExport BSpline: public BaseGeom class TechDrawExport BSpline: public BaseGeom
{ {
public: public:
BSpline(const BRepAdaptor_Curve &c); BSpline(const TopoDS_Edge &e);
BSpline();
~BSpline(){} ~BSpline(){}
public: public:
bool isLine(void); bool isLine(void);
std::vector<BezierSegment> segments; std::vector<BezierSegment> segments;
}; };
class Generic: public BaseGeom class TechDrawExport Generic: public BaseGeom
{ {
public: public:
Generic(Base::Vector2D start, Base::Vector2D end); Generic(const TopoDS_Edge &e);
Generic(const BRepAdaptor_Curve& c);
Generic(); Generic();
~Generic() {} ~Generic() {}
std::vector<Base::Vector2D> points; std::vector<Base::Vector2D> points;
}; };
/// Simple Collection of geometric features based on BaseGeom inherited classes in order /// Simple Collection of geometric features based on BaseGeom inherited classes in order
@ -177,30 +187,35 @@ struct TechDrawExport Face
std::vector<Wire *> wires; std::vector<Wire *> wires;
}; };
/// Simple vertex //! 2D Vertex
struct TechDrawExport Vertex class TechDrawExport Vertex
{ {
public:
Vertex(double x, double y) { pnt = Base::Vector2D(x, y); } Vertex(double x, double y) { pnt = Base::Vector2D(x, y); }
Vertex(Base::Vector2D v) { pnt = v; } Vertex(Base::Vector2D v) { pnt = v; }
~Vertex() {} ~Vertex() {}
Base::Vector2D pnt; Base::Vector2D pnt;
ExtractionType extractType; ExtractionType extractType;
bool visible;
int ref3D;
TopoDS_Vertex occVertex;
bool isEqual(Vertex* v, double tol);
}; };
//*** utility functions //*** utility functions
extern "C" { extern "C" {
struct TechDrawExport getNextReturn { struct TechDrawExport getNextReturnVal {
unsigned int index; unsigned int index;
bool reversed; bool reversed;
explicit getNextReturn(int i = 0, bool r = false) : explicit getNextReturnVal(int i = 0, bool r = false) :
index(i), index(i),
reversed(r) reversed(r)
{} {}
}; };
std::vector<TechDrawGeometry::BaseGeom*> chainGeoms(std::vector<TechDrawGeometry::BaseGeom*> geoms); std::vector<TechDrawGeometry::BaseGeom*> chainGeoms(std::vector<TechDrawGeometry::BaseGeom*> geoms);
getNextReturn nextGeom(Base::Vector2D atPoint, getNextReturnVal nextGeom(Base::Vector2D atPoint,
std::vector<TechDrawGeometry::BaseGeom*> geoms, std::vector<TechDrawGeometry::BaseGeom*> geoms,
std::vector<bool> used, std::vector<bool> used,
double tolerance); double tolerance);

File diff suppressed because it is too large Load Diff

View File

@ -23,6 +23,7 @@
#ifndef _TECHDRAW_GEOMETRYOBJECT_H #ifndef _TECHDRAW_GEOMETRYOBJECT_H
#define _TECHDRAW_GEOMETRYOBJECT_H #define _TECHDRAW_GEOMETRYOBJECT_H
#include <Handle_HLRBRep_Algo.hxx>
#include <TopoDS_Shape.hxx> #include <TopoDS_Shape.hxx>
#include <gp_Pnt.hxx> #include <gp_Pnt.hxx>
@ -36,13 +37,13 @@ class HLRBRep_Algo;
class Handle_HLRBRep_Data; class Handle_HLRBRep_Data;
class HLRBRep_EdgeData; class HLRBRep_EdgeData;
class TopoDS_Wire; class TopoDS_Wire;
class HLRBRep_HLRToShape;
namespace TechDrawGeometry namespace TechDrawGeometry
{ {
class BaseGeom; class BaseGeom;
/** Algo class for projecting shapes and creating SVG output of it
*/
class TechDrawExport GeometryObject class TechDrawExport GeometryObject
{ {
public: public:
@ -66,39 +67,29 @@ public:
const std::vector<int> & getEdgeRefs() const { return edgeReferences; }; const std::vector<int> & getEdgeRefs() const { return edgeReferences; };
const std::vector<int> & getFaceRefs() const { return faceReferences; }; const std::vector<int> & getFaceRefs() const { return faceReferences; };
TechDrawGeometry::BaseGeom * projectEdge(const TopoDS_Shape &edge,
const TopoDS_Shape &support,
const Base::Vector3d &direction,
const Base::Vector3d &projXAxis) const;
TechDrawGeometry::Vertex * projectVertex(const TopoDS_Shape &vert,
const TopoDS_Shape &support,
const Base::Vector3d &direction,
const Base::Vector3d &projXAxis) const;
void projectSurfaces(const TopoDS_Shape &face, void projectSurfaces(const TopoDS_Shape &face,
const TopoDS_Shape &support, const TopoDS_Shape &support,
const Base::Vector3d &direction, const Base::Vector3d &direction,
const Base::Vector3d &xaxis, const Base::Vector3d &xaxis,
std::vector<TechDrawGeometry::Face *> &result) const; std::vector<TechDrawGeometry::Face *> &result) const;
BaseGeom* projectEdge(const TopoDS_Shape &edge,
const TopoDS_Shape &support,
const Base::Vector3d &direction,
const Base::Vector3d &projXAxis) const;
Vertex* projectVertex(const TopoDS_Shape &vert,
const TopoDS_Shape &support,
const Base::Vector3d &direction,
const Base::Vector3d &projXAxis) const;
/// Process 3D shape to get 2D geometry void initHLR(const TopoDS_Shape &input,
/*! const Base::Vector3d &direction,
* Applies a projection to the input based on direction and vAxis, then const Base::Vector3d &xAxis);
* calls extractEdges (which in turn calls extractVerts) and extractFaces void extractGeometry(edgeClass category, bool visible);
* to populate vectors used by getVertexRefs(), getEdgeRefs(), and BaseGeom* edgeToBase(TopoDS_Edge edge);
* getFaceRefs() void update3DRefs();
*/
void extractGeometry(const TopoDS_Shape &input,const Base::Vector3d &direction, bool extractHidden = false, const Base::Vector3d &vAxis = Base::Vector3d(0.,0.,0.));
protected: protected:
bool shouldDraw(const bool inFace, const int typ,HLRBRep_EdgeData& ed); void addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass category, bool visible);
bool isSameCurve(const BRepAdaptor_Curve &c1, const BRepAdaptor_Curve &c2) const;
/// Reimplements HLRBRep Drawing Algorithms to satisfy Drawing Workbench requirements
void drawFace(const bool visible, const int iface, Handle_HLRBRep_Data & DS, TopoDS_Shape& Result) const;
/// Add (visible) intervals of ed to Result as Edges
void drawEdge(HLRBRep_EdgeData& ed, TopoDS_Shape& Result, const bool visible) const;
/// Helper for calcBoundingBox() /// Helper for calcBoundingBox()
/*! Note that the name of this function isn't totally accurate due to /*! Note that the name of this function isn't totally accurate due to
@ -121,21 +112,6 @@ protected:
*/ */
bool isWithinArc(double theta, double first, double last, bool cw) const; bool isWithinArc(double theta, double first, double last, bool cw) const;
void extractVerts(HLRBRep_Algo *myAlgo, const TopoDS_Shape &S, HLRBRep_EdgeData& ed, int ie, ExtractionType extractionType);
void extractEdges(HLRBRep_Algo *myAlgo, const TopoDS_Shape &S, int type, bool visible, ExtractionType extractionType);
void extractFaces(HLRBRep_Algo *myAlgo,
const TopoDS_Shape &S,
bool visible,
ExtractionType extractionType,
std::vector<TechDrawGeometry::Face *> &projFaces,
std::vector<int> &faceRefs) const;
int calculateGeometry(const TopoDS_Shape &input, ExtractionType extractionType, std::vector<BaseGeom *> &geoms) const;
/// Accumulate edges from input and store them in wires
void createWire(const TopoDS_Shape &input, std::vector<TopoDS_Wire> &wiresOut) const;
// Geometry // Geometry
std::vector<BaseGeom *> edgeGeom; std::vector<BaseGeom *> edgeGeom;
std::vector<Vertex *> vertexGeom; std::vector<Vertex *> vertexGeom;
@ -148,7 +124,7 @@ protected:
std::vector<int> edgeReferences; std::vector<int> edgeReferences;
std::vector<int> faceReferences; std::vector<int> faceReferences;
HLRBRep_Algo *brep_hlr; Handle_HLRBRep_Algo brep_hlr;
double Tolerance; double Tolerance;
double Scale; double Scale;

View File

@ -111,11 +111,10 @@ void CmdTechDrawNewDimension::activated(int iMsg)
std::vector<App::DocumentObject *> objs; std::vector<App::DocumentObject *> objs;
std::vector<std::string> subs; std::vector<std::string> subs;
//TODO: do all these validations have to be accessible from Python? //All Dimensions start as Projected
//selected edge(s) must have valid reference to Source edge for True Dimension //bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
//otherwise Dimension must be Projected //int edgeType = _isValidSingleEdge(this,trueDimAllowed);
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames); int edgeType = _isValidSingleEdge(this,false);
int edgeType = _isValidSingleEdge(this,trueDimAllowed);
if (edgeType) { if (edgeType) {
if (edgeType < isCircle) { if (edgeType < isCircle) {
@ -187,12 +186,7 @@ void CmdTechDrawNewDimension::activated(int iMsg)
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str())); dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
dim->References.setValues(objs, subs); dim->References.setValues(objs, subs);
// make a True dimension if you can, Projected otherwise
if (trueDimAllowed) {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
} else {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
}
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId()); std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front()); TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
@ -240,11 +234,10 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
std::vector<App::DocumentObject *> objs; std::vector<App::DocumentObject *> objs;
std::vector<std::string> subs; std::vector<std::string> subs;
//selected edge(s) must have valid reference to Source edge for True Dimension //All Dimensions start as Projected
//otherwise Dimension must be Projected //bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames); //int edgeType = _isValidSingleEdge(this,trueDimAllowed);
int edgeType = _isValidSingleEdge(this,trueDimAllowed); int edgeType = _isValidSingleEdge(this,false); if (edgeType == isCircle) {
if (edgeType == isCircle) {
centerLine = true; centerLine = true;
objs.push_back(objFeat); objs.push_back(objFeat);
subs.push_back(SubNames[0]); subs.push_back(SubNames[0]);
@ -272,11 +265,7 @@ void CmdTechDrawNewRadiusDimension::activated(int iMsg)
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str())); dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
dim->References.setValues(objs, subs); dim->References.setValues(objs, subs);
if (trueDimAllowed) {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
} else {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
}
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId()); std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front()); TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
@ -325,11 +314,10 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
std::vector<App::DocumentObject *> objs; std::vector<App::DocumentObject *> objs;
std::vector<std::string> subs; std::vector<std::string> subs;
//selected edge(s) must have valid reference to Source edge for True Dimension //All Dimensions start as Projected
//otherwise Dimension must be Projected //bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames); //int edgeType = _isValidSingleEdge(this,trueDimAllowed);
int edgeType = _isValidSingleEdge(this,false);
int edgeType = _isValidSingleEdge(this,trueDimAllowed);
if (edgeType == isCircle) { if (edgeType == isCircle) {
centerLine = true; centerLine = true;
objs.push_back(objFeat); objs.push_back(objFeat);
@ -358,12 +346,7 @@ void CmdTechDrawNewDiameterDimension::activated(int iMsg)
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str())); dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
dim->References.setValues(objs, subs); dim->References.setValues(objs, subs);
// make a True dimension if you can, Projected otherwise
if (trueDimAllowed) {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
} else {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
}
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId()); std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front()); TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
@ -413,10 +396,10 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
std::vector<App::DocumentObject *> objs; std::vector<App::DocumentObject *> objs;
std::vector<std::string> subs; std::vector<std::string> subs;
//selected edge(s) must have valid reference to Source edge for True Dimension //All Dimensions start as Projected
//otherwise Dimension must be Projected //bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames); //int edgeType = _isValidSingleEdge(this,trueDimAllowed);
int edgeType = _isValidSingleEdge(this,trueDimAllowed); int edgeType = _isValidSingleEdge(this,false);
if ((edgeType == isHorizontal) || if ((edgeType == isHorizontal) ||
(edgeType == isVertical) || (edgeType == isVertical) ||
(edgeType == isDiagonal)) { (edgeType == isDiagonal)) {
@ -451,12 +434,7 @@ void CmdTechDrawNewLengthDimension::activated(int iMsg)
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
// make a True dimension if you can, Projected otherwise
if (trueDimAllowed) {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
} else {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
}
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId()); std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front()); TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
@ -505,10 +483,10 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
std::vector<App::DocumentObject *> objs; std::vector<App::DocumentObject *> objs;
std::vector<std::string> subs; std::vector<std::string> subs;
//selected edge(s) must have valid reference to Source edge for True Dimension //All Dimensions start as Projected
//otherwise Dimension must be Projected //bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames); //int edgeType = _isValidSingleEdge(this,trueDimAllowed);
int edgeType = _isValidSingleEdge(this,trueDimAllowed); int edgeType = _isValidSingleEdge(this,false);
if ((edgeType == isHorizontal) || if ((edgeType == isHorizontal) ||
(edgeType == isDiagonal)) { (edgeType == isDiagonal)) {
objs.push_back(objFeat); objs.push_back(objFeat);
@ -541,12 +519,7 @@ void CmdTechDrawNewDistanceXDimension::activated(int iMsg)
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
// make a True dimension if you can, Projected otherwise
if (trueDimAllowed) {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
} else {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
}
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId()); std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front()); TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
@ -596,10 +569,10 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
std::vector<App::DocumentObject *> objs; std::vector<App::DocumentObject *> objs;
std::vector<std::string> subs; std::vector<std::string> subs;
//selected edge(s) must have valid reference to Source edge for True Dimension //All Dimensions start as Projected
//otherwise Dimension must be Projected //bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames); //int edgeType = _isValidSingleEdge(this,trueDimAllowed);
int edgeType = _isValidSingleEdge(this,trueDimAllowed); int edgeType = _isValidSingleEdge(this,false);
if ((edgeType == isVertical) || if ((edgeType == isVertical) ||
(edgeType == isDiagonal)) { (edgeType == isDiagonal)) {
objs.push_back(objFeat); objs.push_back(objFeat);
@ -631,12 +604,7 @@ void CmdTechDrawNewDistanceYDimension::activated(int iMsg)
doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.FormatSpec = '%%value%%'", FeatName.c_str());
// make a True dimension if you can, Projected otherwise
if (trueDimAllowed) {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
} else {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
}
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId()); std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front()); TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());
@ -685,10 +653,10 @@ void CmdTechDrawNewAngleDimension::activated(int iMsg)
std::vector<App::DocumentObject *> objs; std::vector<App::DocumentObject *> objs;
std::vector<std::string> subs; std::vector<std::string> subs;
//selected edge(s) must have valid reference to Source edge for True Dimension //All Dimensions start as Projected
//otherwise Dimension must be Projected //bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames);
bool trueDimAllowed = _isTrueAllowed(objFeat,SubNames); //int edgeType = _isValidSingleEdge(this,trueDimAllowed);
int edgeType = _isValidEdgeToEdge(this,trueDimAllowed); int edgeType = _isValidSingleEdge(this,false);
if (edgeType == isAngle) { if (edgeType == isAngle) {
objs.push_back(objFeat); objs.push_back(objFeat);
objs.push_back(objFeat); objs.push_back(objFeat);
@ -711,12 +679,7 @@ void CmdTechDrawNewAngleDimension::activated(int iMsg)
dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str())); dim = dynamic_cast<TechDraw::DrawViewDimension *>(getDocument()->getObject(FeatName.c_str()));
dim->References.setValues(objs, subs); dim->References.setValues(objs, subs);
// make a True dimension if you can, Projected otherwise
if (trueDimAllowed) {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'True'",FeatName.c_str());
} else {
doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str()); doCommand(Doc,"App.activeDocument().%s.ProjectionType = 'Projected'",FeatName.c_str());
}
std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId()); std::vector<App::DocumentObject*> pages = getDocument()->getObjectsOfType(TechDraw::DrawPage::getClassTypeId());
TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front()); TechDraw::DrawPage *page = dynamic_cast<TechDraw::DrawPage *>(pages.front());

View File

@ -485,6 +485,7 @@ void MDIViewPage::selectionChanged()
static_cast<void> (Gui::Selection().addSelection(viewObj->getDocument()->getName(), static_cast<void> (Gui::Selection().addSelection(viewObj->getDocument()->getName(),
viewObj->getNameInDocument(), viewObj->getNameInDocument(),
ss.str().c_str())); ss.str().c_str()));
//Base::Console().Message("TRACE - MDIVP::selectionChanged - selection: %s\n",ss.str().c_str());
} }
QGIVertex *vert = dynamic_cast<QGIVertex *>(*it); QGIVertex *vert = dynamic_cast<QGIVertex *>(*it);

View File

@ -48,9 +48,11 @@
#include "../App/DrawUtil.h" #include "../App/DrawUtil.h"
#include "../App/DrawViewPart.h" #include "../App/DrawViewPart.h"
#include "../App/DrawHatch.h" #include "../App/DrawHatch.h"
#include "../App/Geometry.h"
#include "QGIViewPart.h" #include "QGIViewPart.h"
using namespace TechDrawGui; using namespace TechDrawGui;
using namespace TechDrawGeometry;
void _dumpPath(const char* text,QPainterPath path); void _dumpPath(const char* text,QPainterPath path);
@ -384,33 +386,39 @@ void QGIViewPart::drawViewPart()
// Draw Edges // Draw Edges
const std::vector<TechDrawGeometry::BaseGeom *> &geoms = viewPart->getEdgeGeometry(); const std::vector<TechDrawGeometry::BaseGeom *> &geoms = viewPart->getEdgeGeometry();
const std::vector<int> &refs = viewPart->getEdgeReferences(); const std::vector<int> &refs = viewPart->getEdgeReferences();
std::vector<TechDrawGeometry::BaseGeom *>::const_iterator it = geoms.begin(); std::vector<TechDrawGeometry::BaseGeom *>::const_iterator itEdge = geoms.begin();
QGIEdge* item; QGIEdge* item;
for(int i = 0 ; it != geoms.end(); ++it, i++) { for(int i = 0 ; itEdge != geoms.end(); itEdge++, i++) {
//TODO: investigate if an Edge can be both Hidden and Smooth??? bool showEdge = false;
if(((*it)->extractType == TechDrawGeometry::Plain) || if ((*itEdge)->visible) {
(((*it)->extractType == TechDrawGeometry::WithHidden) && viewPart->ShowHiddenLines.getValue()) || if (((*itEdge)->classOfEdge == ecHARD) ||
((*it)->extractType == TechDrawGeometry::WithSmooth)) { ((*itEdge)->classOfEdge == ecOUTLINE) ||
// (((*it)->extractType == TechDrawGeometry::WithSmooth) && part->ShowSmoothLines.getValue())) { (((*itEdge)->classOfEdge == ecSMOOTH) && viewPart->ShowSmoothLines.getValue()) ||
//item = new QGIEdge(refs.at(i)); (((*itEdge)->classOfEdge == ecSEAM) && viewPart->ShowSeamLines.getValue())) {
showEdge = true;
}
} else {
if (viewPart->ShowHiddenLines.getValue()) {
showEdge = true;
}
}
if (showEdge) {
item = new QGIEdge(i); item = new QGIEdge(i);
item->setReference(refs.at(i)); item->setReference(refs.at(i));
addToGroup(item); //item is at scene(0,0), not group(0,0) addToGroup(item); //item is at scene(0,0), not group(0,0)
item->setPos(0.0,0.0); item->setPos(0.0,0.0);
item->setStrokeWidth(lineWidth); item->setStrokeWidth(lineWidth);
if((*it)->extractType == TechDrawGeometry::WithHidden) { if(!(*itEdge)->visible) {
item->setStrokeWidth(lineWidthHid); item->setStrokeWidth(lineWidthHid);
item->setHiddenEdge(true); item->setHiddenEdge(true);
} else if((*it)->extractType == TechDrawGeometry::WithSmooth) {
item->setSmoothEdge(true);
} }
item->setPath(drawPainterPath(*it)); item->setPath(drawPainterPath(*itEdge));
item->setFlag(QGraphicsItem::ItemIsSelectable, true); item->setFlag(QGraphicsItem::ItemIsSelectable, true);
item->setAcceptHoverEvents(true); item->setAcceptHoverEvents(true);
//debug a path //debug a path
//QPainterPath edgePath=drawPainterPath(*it); //QPainterPath edgePath=drawPainterPath(*itEdge);
//item->setPath(edgePath); //item->setPath(edgePath);
//std::stringstream edgeId; //std::stringstream edgeId;
//edgeId << "edge" << i; //edgeId << "edge" << i;
@ -422,7 +430,6 @@ void QGIViewPart::drawViewPart()
const std::vector<TechDrawGeometry::Vertex *> &verts = viewPart->getVertexGeometry(); const std::vector<TechDrawGeometry::Vertex *> &verts = viewPart->getVertexGeometry();
const std::vector<int> &vertRefs = viewPart->getVertexReferences(); const std::vector<int> &vertRefs = viewPart->getVertexReferences();
std::vector<TechDrawGeometry::Vertex *>::const_iterator vert = verts.begin(); std::vector<TechDrawGeometry::Vertex *>::const_iterator vert = verts.begin();
for(int i = 0 ; vert != verts.end(); ++vert, i++) { for(int i = 0 ; vert != verts.end(); ++vert, i++) {
QGIVertex *item = new QGIVertex(i); QGIVertex *item = new QGIVertex(i);
item->setReference(vertRefs.at(i)); item->setReference(vertRefs.at(i));

View File

@ -72,11 +72,11 @@ void QGIViewSection::drawSectionFace()
//Base::Console().Log("drawing section face\n"); //Base::Console().Log("drawing section face\n");
// Get the section face from the feature // Get the section faces from the feature
std::vector<TechDrawGeometry::Face *> faceGeoms; std::vector<TechDrawGeometry::Face *> sectionFaces;
part->getSectionSurface(faceGeoms); //part->getSectionFaces(faceGeoms);
if (faceGeoms.empty()) { if (sectionFaces.empty()) {
Base::Console().Log("INFO - QGIViewSection::drawSectionFace - No Face available. Check Section plane.\n"); Base::Console().Log("INFO - QGIViewSection::drawSectionFace - No sectionFaces available. Check Section plane.\n");
return; return;
} }
@ -124,7 +124,7 @@ void QGIViewSection::drawSectionFace()
if(graphicsItem) { if(graphicsItem) {
// Hide any edges that are hidden if option is set. // Hide any edges that are hidden if option is set.
// if((*fit)->extractType == TechDrawGeometry::WithHidden && !part->ShowHiddenLines.getValue()) // if(!(*fit)->visible && !part->ShowHiddenLines.getValue())
// graphicsItem->hide(); // graphicsItem->hide();
addToGroup(graphicsItem); addToGroup(graphicsItem);