Changes re const, ref and TopExp per wmayer
Refactor debug routines to DrawUtil
This commit is contained in:
parent
9a93185f7e
commit
b47eff76ae
|
@ -33,10 +33,18 @@
|
||||||
# include <QStringList>
|
# include <QStringList>
|
||||||
# include <QRegExp>
|
# include <QRegExp>
|
||||||
|
|
||||||
//#include <TopoDS_Vertex.hxx>
|
|
||||||
#include <BRep_Tool.hxx>
|
#include <BRep_Tool.hxx>
|
||||||
#include <gp_Pnt.hxx>
|
#include <gp_Pnt.hxx>
|
||||||
#include <Precision.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
|
#endif
|
||||||
|
|
||||||
#include <App/Application.h>
|
#include <App/Application.h>
|
||||||
|
@ -109,3 +117,65 @@ bool DrawUtil::isSamePoint(TopoDS_Vertex v1, TopoDS_Vertex v2)
|
||||||
}
|
}
|
||||||
return result;
|
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());
|
||||||
|
}
|
||||||
|
//==================================
|
||||||
|
|
|
@ -24,7 +24,12 @@
|
||||||
#define _DrawUtil_h_
|
#define _DrawUtil_h_
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <TopoDS.hxx>
|
||||||
#include <TopoDS_Vertex.hxx>
|
#include <TopoDS_Vertex.hxx>
|
||||||
|
#include <TopoDS_Edge.hxx>
|
||||||
|
#include <TopoDS_Wire.hxx>
|
||||||
|
#include <TopoDS_Face.hxx>
|
||||||
|
#include <TopoDS_Shape.hxx>
|
||||||
|
|
||||||
namespace TechDraw
|
namespace TechDraw
|
||||||
{
|
{
|
||||||
|
@ -36,6 +41,14 @@ class TechDrawExport DrawUtil {
|
||||||
static std::string getGeomTypeFromName(std::string geomName);
|
static std::string getGeomTypeFromName(std::string geomName);
|
||||||
static std::string makeGeomName(std::string geomType, int index);
|
static std::string makeGeomName(std::string geomType, int index);
|
||||||
static bool isSamePoint(TopoDS_Vertex v1, TopoDS_Vertex v2);
|
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
|
} //end namespace TechDraw
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
#include <TopoDS_Face.hxx>
|
#include <TopoDS_Face.hxx>
|
||||||
#include <TopExp.hxx>
|
#include <TopExp.hxx>
|
||||||
#include <TopExp_Explorer.hxx>
|
#include <TopExp_Explorer.hxx>
|
||||||
|
#include <TopTools_IndexedMapOfShape.hxx>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -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;
|
Standard_Real minDist = -1;
|
||||||
|
|
||||||
|
@ -511,7 +512,7 @@ QRectF DrawViewPart::getRect() const
|
||||||
}
|
}
|
||||||
|
|
||||||
//used to project pt (ex SectionOrigin) onto paper plane
|
//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 centeredPoint = pt - shapeCentroid;
|
||||||
Base::Vector3d direction = Direction.getValue();
|
Base::Vector3d direction = Direction.getValue();
|
||||||
|
@ -562,8 +563,8 @@ Base::Vector3d DrawViewPart::getValidXDir() const
|
||||||
return xDir;
|
return xDir;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DrawViewPart::saveParamSpace(Base::Vector3d direction,
|
void DrawViewPart::saveParamSpace(const Base::Vector3d& direction,
|
||||||
Base::Vector3d xAxis)
|
const Base::Vector3d& xAxis)
|
||||||
{
|
{
|
||||||
gp_Ax2 viewAxis;
|
gp_Ax2 viewAxis;
|
||||||
viewAxis = gp_Ax2(gp_Pnt(0, 0, 0),
|
viewAxis = gp_Ax2(gp_Pnt(0, 0, 0),
|
||||||
|
@ -589,54 +590,6 @@ DrawViewSection* DrawViewPart::getSectionRef(void) const
|
||||||
return result;
|
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)
|
PyObject *DrawViewPart::getPyObject(void)
|
||||||
{
|
{
|
||||||
if (PythonObject.is(Py::_None())) {
|
if (PythonObject.is(Py::_None())) {
|
||||||
|
@ -646,21 +599,6 @@ PyObject *DrawViewPart::getPyObject(void)
|
||||||
return Py::new_reference_to(PythonObject);
|
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 ---------------------------------------------------------
|
// Python Drawing feature ---------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -94,14 +94,18 @@ public:
|
||||||
TechDrawGeometry::BaseGeom* getProjEdgeByIndex(int idx) const; //get existing geom for edge idx in projection
|
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
|
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
|
std::vector<TechDrawGeometry::BaseGeom*> getProjFaceByIndex(int idx) const; //get edges for face idx in projection
|
||||||
|
|
||||||
virtual Base::BoundBox3d getBoundingBox() const;
|
virtual Base::BoundBox3d getBoundingBox() const;
|
||||||
double getBoxX(void) const;
|
double getBoxX(void) const;
|
||||||
double getBoxY(void) const;
|
double getBoxY(void) const;
|
||||||
virtual QRectF getRect() const;
|
virtual QRectF getRect() const;
|
||||||
virtual DrawViewSection* getSectionRef() const; //is there a ViewSection based on this ViewPart?
|
virtual DrawViewSection* getSectionRef() const; //is there a ViewSection based on this ViewPart?
|
||||||
Base::Vector3d getUDir(void) {return uDir;} //paperspace X
|
const Base::Vector3d& getUDir(void) const {return uDir;} //paperspace X
|
||||||
Base::Vector3d getVDir(void) {return vDir;} //paperspace Y
|
const Base::Vector3d& getVDir(void) const {return vDir;} //paperspace Y
|
||||||
Base::Vector3d getWDir(void) {return wDir;} //paperspace Z
|
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;
|
short mustExecute() const;
|
||||||
|
|
||||||
|
@ -118,15 +122,6 @@ public:
|
||||||
//return PyObject as DrawViewPartPy
|
//return PyObject as DrawViewPartPy
|
||||||
virtual PyObject *getPyObject(void);
|
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:
|
protected:
|
||||||
TechDrawGeometry::GeometryObject *geometryObject;
|
TechDrawGeometry::GeometryObject *geometryObject;
|
||||||
Base::BoundBox3d bbox;
|
Base::BoundBox3d bbox;
|
||||||
|
@ -137,11 +132,11 @@ protected:
|
||||||
|
|
||||||
bool isOnEdge(TopoDS_Edge e, TopoDS_Vertex v, bool allowEnds = false);
|
bool isOnEdge(TopoDS_Edge e, TopoDS_Vertex v, bool allowEnds = false);
|
||||||
std::vector<TopoDS_Edge> splitEdge(std::vector<TopoDS_Vertex> splitPoints, TopoDS_Edge e);
|
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
|
//Projection parameter space
|
||||||
void saveParamSpace(Base::Vector3d direction,
|
void saveParamSpace(const Base::Vector3d& direction,
|
||||||
Base::Vector3d xAxis);
|
const Base::Vector3d& xAxis);
|
||||||
Base::Vector3d uDir; //paperspace X
|
Base::Vector3d uDir; //paperspace X
|
||||||
Base::Vector3d vDir; //paperspace Y
|
Base::Vector3d vDir; //paperspace Y
|
||||||
Base::Vector3d wDir; //paperspace Z
|
Base::Vector3d wDir; //paperspace Z
|
||||||
|
|
Loading…
Reference in New Issue
Block a user