Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Changes re const, ref and TopExp per wmayer
Refactor debug routines to DrawUtil
  • Loading branch information
WandererFan committed Sep 1, 2016
1 parent 9a93185 commit b47eff7
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 83 deletions.
72 changes: 71 additions & 1 deletion src/Mod/TechDraw/App/DrawUtil.cpp
Expand Up @@ -33,10 +33,18 @@
# include <QStringList>
# include <QRegExp>

//#include <TopoDS_Vertex.hxx>

#include <BRep_Tool.hxx>
#include <gp_Pnt.hxx>
#include <Precision.hxx>
#include <BRepLProp_CLProps.hxx>
#include <TopExp_Explorer.hxx>
#include <BRepAdaptor_Curve.hxx>
#include <BRepLProp_CurveTool.hxx>
#include <TopTools_IndexedMapOfShape.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>

#endif

#include <App/Application.h>
Expand Down Expand Up @@ -109,3 +117,65 @@ bool DrawUtil::isSamePoint(TopoDS_Vertex v1, TopoDS_Vertex v2)
}
return result;
}

//============================
// various debugging routines.
void DrawUtil::dumpVertexes(const char* text, const TopoDS_Shape& s)
{
Base::Console().Message("DUMP - %s\n",text);
TopExp_Explorer expl(s, TopAbs_VERTEX);
int i;
for (i = 1 ; expl.More(); expl.Next(),i++) {
const TopoDS_Vertex& v = TopoDS::Vertex(expl.Current());
gp_Pnt pnt = BRep_Tool::Pnt(v);
Base::Console().Message("v%d: (%.3f,%.3f,%.3f)\n",i,pnt.X(),pnt.Y(),pnt.Z());
}
}

void DrawUtil::countFaces(const char* text, const TopoDS_Shape& s)
{
TopTools_IndexedMapOfShape mapOfFaces;
TopExp::MapShapes(s, TopAbs_FACE, mapOfFaces);
int num = mapOfFaces.Extent();
Base::Console().Message("COUNT - %s has %d Faces\n",text,num);
}

//count # of unique Wires in shape.
void DrawUtil::countWires(const char* text, const TopoDS_Shape& s)
{
TopTools_IndexedMapOfShape mapOfWires;
TopExp::MapShapes(s, TopAbs_WIRE, mapOfWires);
int num = mapOfWires.Extent();
Base::Console().Message("COUNT - %s has %d wires\n",text,num);
}

void DrawUtil::countEdges(const char* text, const TopoDS_Shape& s)
{
TopTools_IndexedMapOfShape mapOfEdges;
TopExp::MapShapes(s, TopAbs_EDGE, mapOfEdges);
int num = mapOfEdges.Extent();
Base::Console().Message("COUNT - %s has %d edges\n",text,num);
}

void DrawUtil::dump1Vertex(const char* text, const TopoDS_Vertex& v)
{
Base::Console().Message("DUMP - dump1Vertex - %s\n",text);
gp_Pnt pnt = BRep_Tool::Pnt(v);
Base::Console().Message("%s: (%.3f,%.3f,%.3f)\n",text,pnt.X(),pnt.Y(),pnt.Z());
}

void DrawUtil::dumpEdge(char* label, int i, TopoDS_Edge e)
{
BRepAdaptor_Curve adapt(e);
double start = BRepLProp_CurveTool::FirstParameter(adapt);
double end = BRepLProp_CurveTool::LastParameter(adapt);
BRepLProp_CLProps propStart(adapt,start,0,Precision::Confusion());
const gp_Pnt& vStart = propStart.Value();
BRepLProp_CLProps propEnd(adapt,end,0,Precision::Confusion());
const gp_Pnt& vEnd = propEnd.Value();
//Base::Console().Message("%s edge:%d start:(%.3f,%.3f,%.3f)/%0.3f end:(%.2f,%.3f,%.3f)/%.3f\n",label,i,
// vStart.X(),vStart.Y(),vStart.Z(),start,vEnd.X(),vEnd.Y(),vEnd.Z(),end);
Base::Console().Message("%s edge:%d start:(%.3f,%.3f,%.3f) end:(%.2f,%.3f,%.3f)\n",label,i,
vStart.X(),vStart.Y(),vStart.Z(),vEnd.X(),vEnd.Y(),vEnd.Z());
}
//==================================
13 changes: 13 additions & 0 deletions src/Mod/TechDraw/App/DrawUtil.h
Expand Up @@ -24,7 +24,12 @@
#define _DrawUtil_h_

#include <string>
#include <TopoDS.hxx>
#include <TopoDS_Vertex.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <TopoDS_Face.hxx>
#include <TopoDS_Shape.hxx>

namespace TechDraw
{
Expand All @@ -36,6 +41,14 @@ class TechDrawExport DrawUtil {
static std::string getGeomTypeFromName(std::string geomName);
static std::string makeGeomName(std::string geomType, int index);
static bool isSamePoint(TopoDS_Vertex v1, TopoDS_Vertex v2);

//debugging routines
static void dumpVertexes(const char* text, const TopoDS_Shape& s);
static void dumpEdge(char* label, int i, TopoDS_Edge e);
static void dump1Vertex(const char* label, const TopoDS_Vertex& v);
static void countFaces(const char* label, const TopoDS_Shape& s);
static void countWires(const char* label, const TopoDS_Shape& s);
static void countEdges(const char* label, const TopoDS_Shape& s);
};

} //end namespace TechDraw
Expand Down
72 changes: 5 additions & 67 deletions src/Mod/TechDraw/App/DrawViewPart.cpp
Expand Up @@ -58,6 +58,7 @@
#include <TopoDS_Face.hxx>
#include <TopExp.hxx>
#include <TopExp_Explorer.hxx>
#include <TopTools_IndexedMapOfShape.hxx>

#endif

Expand Down Expand Up @@ -358,7 +359,7 @@ void DrawViewPart::extractFaces()
}
}

double DrawViewPart::simpleMinDist(TopoDS_Shape s1, TopoDS_Shape s2)
double DrawViewPart::simpleMinDist(TopoDS_Shape s1, TopoDS_Shape s2) const
{
Standard_Real minDist = -1;

Expand Down Expand Up @@ -511,7 +512,7 @@ QRectF DrawViewPart::getRect() const
}

//used to project pt (ex SectionOrigin) onto paper plane
Base::Vector3d DrawViewPart::projectPoint(Base::Vector3d pt) const
Base::Vector3d DrawViewPart::projectPoint(const Base::Vector3d& pt) const
{
Base::Vector3d centeredPoint = pt - shapeCentroid;
Base::Vector3d direction = Direction.getValue();
Expand Down Expand Up @@ -562,8 +563,8 @@ Base::Vector3d DrawViewPart::getValidXDir() const
return xDir;
}

void DrawViewPart::saveParamSpace(Base::Vector3d direction,
Base::Vector3d xAxis)
void DrawViewPart::saveParamSpace(const Base::Vector3d& direction,
const Base::Vector3d& xAxis)
{
gp_Ax2 viewAxis;
viewAxis = gp_Ax2(gp_Pnt(0, 0, 0),
Expand All @@ -589,54 +590,6 @@ DrawViewSection* DrawViewPart::getSectionRef(void) const
return result;
}

void DrawViewPart::dumpVertexes(const char* text, const TopoDS_Shape& s)
{
Base::Console().Message("DUMP - %s\n",text);
TopExp_Explorer expl(s, TopAbs_VERTEX);
int i;
for (i = 1 ; expl.More(); expl.Next(),i++) {
const TopoDS_Vertex& v = TopoDS::Vertex(expl.Current());
gp_Pnt pnt = BRep_Tool::Pnt(v);
Base::Console().Message("v%d: (%.3f,%.3f,%.3f)\n",i,pnt.X(),pnt.Y(),pnt.Z());
}
}

void DrawViewPart::countFaces(const char* text, const TopoDS_Shape& s)
{
TopExp_Explorer expl(s, TopAbs_FACE);
int i;
for (i = 0 ; expl.More(); expl.Next(),i++) {
}
Base::Console().Message("COUNT - %s has %d Faces\n",text,i);
}

void DrawViewPart::countWires(const char* text, const TopoDS_Shape& s)
{
TopExp_Explorer expl(s, TopAbs_WIRE);
int i = 0;
for (; expl.More(); expl.Next()) {
i++;
}
Base::Console().Message("COUNT - %s has %d wires\n",text,i);
}

void DrawViewPart::countEdges(const char* text, const TopoDS_Shape& s)
{
TopExp_Explorer expl(s, TopAbs_EDGE);
int i = 0;
for (; expl.More(); expl.Next()) {
i++;
}
Base::Console().Message("COUNT - %s has %d edges\n",text,i);
}

void DrawViewPart::dump1Vertex(const char* text, const TopoDS_Vertex& v)
{
Base::Console().Message("DUMP - DVP::dump1Vertex - %s\n",text);
gp_Pnt pnt = BRep_Tool::Pnt(v);
Base::Console().Message("%s: (%.3f,%.3f,%.3f)\n",text,pnt.X(),pnt.Y(),pnt.Z());
}

PyObject *DrawViewPart::getPyObject(void)
{
if (PythonObject.is(Py::_None())) {
Expand All @@ -646,21 +599,6 @@ PyObject *DrawViewPart::getPyObject(void)
return Py::new_reference_to(PythonObject);
}

void DrawViewPart::dumpEdge(char* label, int i, TopoDS_Edge e)
{
BRepAdaptor_Curve adapt(e);
double start = BRepLProp_CurveTool::FirstParameter(adapt);
double end = BRepLProp_CurveTool::LastParameter(adapt);
BRepLProp_CLProps propStart(adapt,start,0,Precision::Confusion());
const gp_Pnt& vStart = propStart.Value();
BRepLProp_CLProps propEnd(adapt,end,0,Precision::Confusion());
const gp_Pnt& vEnd = propEnd.Value();
//Base::Console().Message("%s edge:%d start:(%.3f,%.3f,%.3f)/%0.3f end:(%.2f,%.3f,%.3f)/%.3f\n",label,i,
// vStart.X(),vStart.Y(),vStart.Z(),start,vEnd.X(),vEnd.Y(),vEnd.Z(),end);
Base::Console().Message("%s edge:%d start:(%.3f,%.3f,%.3f) end:(%.2f,%.3f,%.3f)\n",label,i,
vStart.X(),vStart.Y(),vStart.Z(),vEnd.X(),vEnd.Y(),vEnd.Z());
}


// Python Drawing feature ---------------------------------------------------------

Expand Down
25 changes: 10 additions & 15 deletions src/Mod/TechDraw/App/DrawViewPart.h
Expand Up @@ -94,14 +94,18 @@ class TechDrawExport DrawViewPart : public DrawView
TechDrawGeometry::BaseGeom* getProjEdgeByIndex(int idx) const; //get existing geom for edge idx in projection
TechDrawGeometry::Vertex* getProjVertexByIndex(int idx) const; //get existing geom for vertex idx in projection
std::vector<TechDrawGeometry::BaseGeom*> getProjFaceByIndex(int idx) const; //get edges for face idx in projection

virtual Base::BoundBox3d getBoundingBox() const;
double getBoxX(void) const;
double getBoxY(void) const;
virtual QRectF getRect() const;
virtual DrawViewSection* getSectionRef() const; //is there a ViewSection based on this ViewPart?
Base::Vector3d getUDir(void) {return uDir;} //paperspace X
Base::Vector3d getVDir(void) {return vDir;} //paperspace Y
Base::Vector3d getWDir(void) {return wDir;} //paperspace Z
const Base::Vector3d& getUDir(void) const {return uDir;} //paperspace X
const Base::Vector3d& getVDir(void) const {return vDir;} //paperspace Y
const Base::Vector3d& getWDir(void) const {return wDir;} //paperspace Z
const Base::Vector3d& getCentroid(void) const {return shapeCentroid;}
Base::Vector3d getValidXDir() const;
Base::Vector3d projectPoint(const Base::Vector3d& pt) const;

short mustExecute() const;

Expand All @@ -118,15 +122,6 @@ class TechDrawExport DrawViewPart : public DrawView
//return PyObject as DrawViewPartPy
virtual PyObject *getPyObject(void);

void dumpVertexes(const char* text, const TopoDS_Shape& s);
void dumpEdge(char* label, int i, TopoDS_Edge e);
void dump1Vertex(const char* label, const TopoDS_Vertex& v);
void countFaces(const char* label, const TopoDS_Shape& s);
void countWires(const char* label, const TopoDS_Shape& s);
void countEdges(const char* label, const TopoDS_Shape& s);
Base::Vector3d getValidXDir() const;
Base::Vector3d projectPoint(Base::Vector3d pt) const;

protected:
TechDrawGeometry::GeometryObject *geometryObject;
Base::BoundBox3d bbox;
Expand All @@ -137,11 +132,11 @@ class TechDrawExport DrawViewPart : public DrawView

bool isOnEdge(TopoDS_Edge e, TopoDS_Vertex v, bool allowEnds = false);
std::vector<TopoDS_Edge> splitEdge(std::vector<TopoDS_Vertex> splitPoints, TopoDS_Edge e);
double simpleMinDist(TopoDS_Shape s1, TopoDS_Shape s2);
double simpleMinDist(TopoDS_Shape s1, TopoDS_Shape s2) const; //probably sb static or DrawUtil

//Projection parameter space
void saveParamSpace(Base::Vector3d direction,
Base::Vector3d xAxis);
void saveParamSpace(const Base::Vector3d& direction,
const Base::Vector3d& xAxis);
Base::Vector3d uDir; //paperspace X
Base::Vector3d vDir; //paperspace Y
Base::Vector3d wDir; //paperspace Z
Expand Down

0 comments on commit b47eff7

Please sign in to comment.