rename 2d tool classes to be consistent with 3d classes

This commit is contained in:
wmayer
2016-11-21 14:29:51 +01:00
parent 31d43b4a12
commit e54e9515fc
42 changed files with 950 additions and 951 deletions

View File

@@ -119,8 +119,8 @@ int DrawParametricTemplate::drawLine(double x1, double y1, double x2, double y2)
{
TechDrawGeometry::Generic *line = new TechDrawGeometry::Generic();
line->points.push_back(Base::Vector2D(x1, y1));
line->points.push_back(Base::Vector2D(x2, y2));
line->points.push_back(Base::Vector2d(x1, y1));
line->points.push_back(Base::Vector2d(x2, y2));
geom.push_back(line); // Push onto geometry stack
return geom.size() -1;
@@ -148,4 +148,4 @@ template<> const char* TechDraw::DrawParametricTemplatePython::getViewProviderNa
// explicit template instantiation
template class TechDrawExport FeaturePythonT<TechDraw::DrawParametricTemplate>;
}
}

View File

@@ -286,15 +286,15 @@ double DrawViewDimension::getDimValue() const
int idx = DrawUtil::getIndexFromName(subElements[0]);
TechDrawGeometry::BaseGeom* geom = getViewPart()->getProjEdgeByIndex(idx);
TechDrawGeometry::Generic* gen = static_cast<TechDrawGeometry::Generic*>(geom);
Base::Vector2D start = gen->points[0];
Base::Vector2D end = gen->points[1];
Base::Vector2D line = end - start;
Base::Vector2d start = gen->points[0];
Base::Vector2d end = gen->points[1];
Base::Vector2d line = end - start;
if (Type.isValue("Distance")) {
result = line.Length() / getViewPart()->Scale.getValue();
} else if (Type.isValue("DistanceX")) {
return fabs(line.fX) / getViewPart()->Scale.getValue();
return fabs(line.x) / getViewPart()->Scale.getValue();
} else {
result = fabs(line.fY) / getViewPart()->Scale.getValue();
result = fabs(line.y) / getViewPart()->Scale.getValue();
}
}else if (getRefType() == twoEdge) {
//only works for straight line edges
@@ -304,35 +304,35 @@ double DrawViewDimension::getDimValue() const
TechDrawGeometry::BaseGeom* geom1 = getViewPart()->getProjEdgeByIndex(idx1);
TechDrawGeometry::Generic* gen0 = static_cast<TechDrawGeometry::Generic*>(geom0);
TechDrawGeometry::Generic* gen1 = static_cast<TechDrawGeometry::Generic*>(geom1);
Base::Vector2D s0 = gen0->points[0];
Base::Vector2D e0 = gen0->points[1];
Base::Vector2D s1 = gen1->points[0];
Base::Vector2D e1 = gen1->points[1];
Base::Vector2d s0 = gen0->points[0];
Base::Vector2d e0 = gen0->points[1];
Base::Vector2d s1 = gen1->points[0];
Base::Vector2d e1 = gen1->points[1];
if (Type.isValue("Distance")) {
result = dist2Segs(s0,e0,s1,e1) / getViewPart()->Scale.getValue();
} else if (Type.isValue("DistanceX")) {
Base::Vector2D p1 = geom0->nearPoint(geom1);
Base::Vector2D p2 = geom1->nearPoint(geom0);
result = fabs(p1.fX - p2.fX) / getViewPart()->Scale.getValue();
Base::Vector2d p1 = geom0->nearPoint(geom1);
Base::Vector2d p2 = geom1->nearPoint(geom0);
result = fabs(p1.x - p2.x) / getViewPart()->Scale.getValue();
} else if (Type.isValue("DistanceY")) {
Base::Vector2D p1 = geom0->nearPoint(geom1);
Base::Vector2D p2 = geom1->nearPoint(geom0);
result = fabs(p1.fY - p2.fY) / getViewPart()->Scale.getValue();
Base::Vector2d p1 = geom0->nearPoint(geom1);
Base::Vector2d p2 = geom1->nearPoint(geom0);
result = fabs(p1.y - p2.y) / getViewPart()->Scale.getValue();
}
} else if (getRefType() == twoVertex) {
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
int idx1 = DrawUtil::getIndexFromName(subElements[1]);
TechDrawGeometry::Vertex* v0 = getViewPart()->getProjVertexByIndex(idx0);
TechDrawGeometry::Vertex* v1 = getViewPart()->getProjVertexByIndex(idx1);
Base::Vector2D start = v0->pnt;
Base::Vector2D end = v1->pnt;
Base::Vector2D line = end - start;
Base::Vector2d start = v0->pnt;
Base::Vector2d end = v1->pnt;
Base::Vector2d line = end - start;
if (Type.isValue("Distance")) {
result = line.Length() / getViewPart()->Scale.getValue();
} else if (Type.isValue("DistanceX")) {
result = fabs(line.fX) / getViewPart()->Scale.getValue();
result = fabs(line.x) / getViewPart()->Scale.getValue();
} else {
result = fabs(line.fY) / getViewPart()->Scale.getValue();
result = fabs(line.y) / getViewPart()->Scale.getValue();
}
} else if (getRefType() == vertexEdge) {
int idx0 = DrawUtil::getIndexFromName(subElements[0]);
@@ -346,14 +346,14 @@ double DrawViewDimension::getDimValue() const
e = getViewPart()->getProjEdgeByIndex(idx1);
v = getViewPart()->getProjVertexByIndex(idx0);
}
Base::Vector2D nearPoint = e->nearPoint(v->pnt);
Base::Vector2D line = nearPoint - v->pnt;
Base::Vector2d nearPoint = e->nearPoint(v->pnt);
Base::Vector2d line = nearPoint - v->pnt;
if (Type.isValue("Distance")) {
result = e->minDist(v->pnt) / getViewPart()->Scale.getValue();
} else if (Type.isValue("DistanceX")) {
result = fabs(line.fX) / getViewPart()->Scale.getValue();
result = fabs(line.x) / getViewPart()->Scale.getValue();
} else {
result = fabs(line.fY) / getViewPart()->Scale.getValue();
result = fabs(line.y) / getViewPart()->Scale.getValue();
}
} //else tarfu
} else if(Type.isValue("Radius")){
@@ -371,7 +371,7 @@ double DrawViewDimension::getDimValue() const
} else if(Type.isValue("Angle")){
// Must project lines to 2D so cannot use measurement framework this time
//Relcalculate the measurement based on references stored.
//WF: why not use projected geom in GeomObject and Vector2D.GetAngle? intersection pt & direction issues?
//WF: why not use projected geom in GeomObject and Vector2d.GetAngle? intersection pt & direction issues?
//TODO: do we need to distinguish inner vs outer angle? -wf
// if(subElements.size() != 2) {
// throw Base::Exception("FVD - Two references required for angle measurement");
@@ -395,11 +395,11 @@ double DrawViewDimension::getDimValue() const
TechDrawGeometry::Generic *gen1 = static_cast<TechDrawGeometry::Generic *>(edge0);
TechDrawGeometry::Generic *gen2 = static_cast<TechDrawGeometry::Generic *>(edge1);
Base::Vector3d p1S(gen1->points.at(0).fX, gen1->points.at(0).fY, 0.);
Base::Vector3d p1E(gen1->points.at(1).fX, gen1->points.at(1).fY, 0.);
Base::Vector3d p1S(gen1->points.at(0).x, gen1->points.at(0).y, 0.);
Base::Vector3d p1E(gen1->points.at(1).x, gen1->points.at(1).y, 0.);
Base::Vector3d p2S(gen2->points.at(0).fX, gen2->points.at(0).fY, 0.);
Base::Vector3d p2E(gen2->points.at(1).fX, gen2->points.at(1).fY, 0.);
Base::Vector3d p2S(gen2->points.at(0).x, gen2->points.at(0).y, 0.);
Base::Vector3d p2E(gen2->points.at(1).x, gen2->points.at(1).y, 0.);
Base::Vector3d dir1 = p1E - p1S;
Base::Vector3d dir2 = p2E - p2S;
@@ -409,8 +409,8 @@ double DrawViewDimension::getDimValue() const
if ((det > 0 ? det : -det) < 1e-10)
throw Base::Exception("Invalid selection - Det = 0");
double c1 = dir1.y*gen1->points.at(0).fX - dir1.x*gen1->points.at(0).fY;
double c2 = dir2.y*gen2->points.at(1).fX - dir2.x*gen2->points.at(1).fY;
double c1 = dir1.y*gen1->points.at(0).x - dir1.x*gen1->points.at(0).y;
double c2 = dir2.y*gen2->points.at(1).x - dir2.x*gen2->points.at(1).y;
double x = (dir1.x*c2 - dir2.x*c1)/det;
double y = (dir1.y*c2 - dir2.y*c1)/det;
@@ -519,20 +519,20 @@ void DrawViewDimension::dumpRefs2D(char* text) const
}
}
double DrawViewDimension::dist2Segs(Base::Vector2D s1,
Base::Vector2D e1,
Base::Vector2D s2,
Base::Vector2D e2) const
double DrawViewDimension::dist2Segs(Base::Vector2d s1,
Base::Vector2d e1,
Base::Vector2d s2,
Base::Vector2d e2) const
{
gp_Pnt start(s1.fX,s1.fY,0.0);
gp_Pnt end(e1.fX,e1.fY,0.0);
gp_Pnt start(s1.x,s1.y,0.0);
gp_Pnt end(e1.x,e1.y,0.0);
TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(start);
TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(end);
BRepBuilderAPI_MakeEdge makeEdge1(v1,v2);
TopoDS_Edge edge1 = makeEdge1.Edge();
start = gp_Pnt(s2.fX,s2.fY,0.0);
end = gp_Pnt(e2.fX,e2.fY,0.0);
start = gp_Pnt(s2.x,s2.y,0.0);
end = gp_Pnt(e2.x,e2.y,0.0);
v1 = BRepBuilderAPI_MakeVertex(start);
v2 = BRepBuilderAPI_MakeVertex(end);
BRepBuilderAPI_MakeEdge makeEdge2(v1,v2);

View File

@@ -103,10 +103,10 @@ protected:
protected:
Measure::Measurement *measurement;
double dist2Segs(Base::Vector2D s1,
Base::Vector2D e1,
Base::Vector2D s2,
Base::Vector2D e2) const;
double dist2Segs(Base::Vector2d s1,
Base::Vector2d e1,
Base::Vector2d s2,
Base::Vector2d e2) const;
private:
static const char* TypeEnums[];
static const char* MeasureTypeEnums[];

View File

@@ -101,46 +101,46 @@ BaseGeom::BaseGeom() :
}
std::vector<Base::Vector2D> BaseGeom::findEndPoints()
std::vector<Base::Vector2d> BaseGeom::findEndPoints()
{
std::vector<Base::Vector2D> result;
std::vector<Base::Vector2d> result;
gp_Pnt p = BRep_Tool::Pnt(TopExp::FirstVertex(occEdge));
result.push_back(Base::Vector2D(p.X(),p.Y()));
result.push_back(Base::Vector2d(p.X(),p.Y()));
p = BRep_Tool::Pnt(TopExp::LastVertex(occEdge));
result.push_back(Base::Vector2D(p.X(),p.Y()));
result.push_back(Base::Vector2d(p.X(),p.Y()));
return result;
}
Base::Vector2D BaseGeom::getStartPoint()
Base::Vector2d BaseGeom::getStartPoint()
{
std::vector<Base::Vector2D> verts = findEndPoints();
std::vector<Base::Vector2d> verts = findEndPoints();
return verts[0];
}
Base::Vector2D BaseGeom::getEndPoint()
Base::Vector2d BaseGeom::getEndPoint()
{
std::vector<Base::Vector2D> verts = findEndPoints();
std::vector<Base::Vector2d> verts = findEndPoints();
return verts[1];
}
double BaseGeom::minDist(Base::Vector2D p)
double BaseGeom::minDist(Base::Vector2d p)
{
double minDist = -1.0;
gp_Pnt pnt(p.fX,p.fY,0.0);
gp_Pnt pnt(p.x,p.y,0.0);
TopoDS_Vertex v = BRepBuilderAPI_MakeVertex(pnt);
minDist = TechDraw::DrawUtil::simpleMinDist(occEdge,v);
return minDist;
}
//!find point on me nearest to p
Base::Vector2D BaseGeom::nearPoint(const BaseGeom* p)
Base::Vector2d BaseGeom::nearPoint(const BaseGeom* p)
{
Base::Vector2D result(0.0,0.0);
Base::Vector2d result(0.0,0.0);
TopoDS_Edge pEdge = p->occEdge;
BRepExtrema_DistShapeShape extss(occEdge, pEdge);
if (extss.IsDone()) {
@@ -148,16 +148,16 @@ Base::Vector2D BaseGeom::nearPoint(const BaseGeom* p)
if (count != 0) {
gp_Pnt p1;
p1 = extss.PointOnShape1(1);
result = Base::Vector2D(p1.X(),p1.Y());
result = Base::Vector2d(p1.X(),p1.Y());
}
}
return result;
}
Base::Vector2D BaseGeom::nearPoint(Base::Vector2D p)
Base::Vector2d BaseGeom::nearPoint(Base::Vector2d p)
{
gp_Pnt pnt(p.fX,p.fY,0.0);
Base::Vector2D result(0.0,0.0);
gp_Pnt pnt(p.x,p.y,0.0);
Base::Vector2d result(0.0,0.0);
TopoDS_Vertex v = BRepBuilderAPI_MakeVertex(pnt);
BRepExtrema_DistShapeShape extss(occEdge, v);
if (extss.IsDone()) {
@@ -165,7 +165,7 @@ Base::Vector2D BaseGeom::nearPoint(Base::Vector2D p)
if (count != 0) {
gp_Pnt p1;
p1 = extss.PointOnShape1(1);
result = Base::Vector2D(p1.X(),p1.Y());
result = Base::Vector2d(p1.X(),p1.Y());
}
}
return result;
@@ -173,10 +173,10 @@ Base::Vector2D BaseGeom::nearPoint(Base::Vector2D p)
std::string BaseGeom::dump()
{
Base::Vector2D start = getStartPoint();
Base::Vector2D end = getEndPoint();
Base::Vector2d start = getStartPoint();
Base::Vector2d end = getEndPoint();
std::stringstream ss;
ss << "BaseGeom: s:(" << start.fX << "," << start.fY << ") e:(" << end.fX << "," << end.fY << ") ";
ss << "BaseGeom: s:(" << start.x << "," << start.y << ") e:(" << end.x << "," << end.y << ") ";
ss << "type: " << geomType << " class: " << classOfEdge << " viz: " << visible << " rev: " << reversed;
return ss.str();
}
@@ -265,7 +265,7 @@ Ellipse::Ellipse(const TopoDS_Edge &e)
gp_Elips ellp = c.Ellipse();
const gp_Pnt &p = ellp.Location();
center = Base::Vector2D(p.X(), p.Y());
center = Base::Vector2d(p.X(), p.Y());
major = ellp.MajorRadius();
minor = ellp.MinorRadius();
@@ -296,9 +296,9 @@ AOE::AOE(const TopoDS_Edge &e) : Ellipse(e)
cw = (a < 0) ? true: false;
largeArc = (l-f > M_PI) ? true : false;
startPnt = Base::Vector2D(s.X(), s.Y());
endPnt = Base::Vector2D(ePt.X(), ePt.Y());
midPnt = Base::Vector2D(m.X(), m.Y());
startPnt = Base::Vector2d(s.X(), s.Y());
endPnt = Base::Vector2d(ePt.X(), ePt.Y());
midPnt = Base::Vector2d(m.X(), m.Y());
}
@@ -312,7 +312,7 @@ Circle::Circle(const TopoDS_Edge &e)
const gp_Pnt& p = circ.Location();
radius = circ.Radius();
center = Base::Vector2D(p.X(), p.Y());
center = Base::Vector2d(p.X(), p.Y());
}
@@ -337,9 +337,9 @@ AOC::AOC(const TopoDS_Edge &e) : Circle(e)
cw = (a < 0) ? true: false;
largeArc = (l-f > M_PI) ? true : false;
startPnt = Base::Vector2D(s.X(), s.Y());
endPnt = Base::Vector2D(ePt.X(), ePt.Y());
midPnt = Base::Vector2D(m.X(), m.Y());
startPnt = Base::Vector2d(s.X(), s.Y());
endPnt = Base::Vector2d(ePt.X(), ePt.Y());
midPnt = Base::Vector2d(m.X(), m.Y());
}
bool AOC::isOnArc(Base::Vector3d p)
@@ -363,7 +363,7 @@ bool AOC::isOnArc(Base::Vector3d p)
double AOC::distToArc(Base::Vector3d p)
{
Base::Vector2D p2(p.x,p.y);
Base::Vector2d p2(p.x,p.y);
double result = minDist(p2);
return result;
}
@@ -406,14 +406,14 @@ Generic::Generic(const TopoDS_Edge &e)
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()));
points.push_back(Base::Vector2d(nodes(i).X(), nodes(i).Y()));
}
} else {
//no polygon representation? approximate with line
gp_Pnt p = BRep_Tool::Pnt(TopExp::FirstVertex(occEdge));
points.push_back(Base::Vector2D(p.X(), p.Y()));
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()));
points.push_back(Base::Vector2d(p.X(), p.Y()));
}
}
@@ -471,9 +471,9 @@ BSpline::BSpline(const TopoDS_Edge &e)
BezierSegment tempSegment;
tempSegment.poles = 3;
tempSegment.degree = 2;
tempSegment.pnts.push_back(Base::Vector2D(s.X(),s.Y()));
tempSegment.pnts.push_back(Base::Vector2D(m.X(),m.Y()));
tempSegment.pnts.push_back(Base::Vector2D(ePt.X(),ePt.Y()));
tempSegment.pnts.push_back(Base::Vector2d(s.X(),s.Y()));
tempSegment.pnts.push_back(Base::Vector2d(m.X(),m.Y()));
tempSegment.pnts.push_back(Base::Vector2d(ePt.X(),ePt.Y()));
segments.push_back(tempSegment);
} else {
for (Standard_Integer i = 1; i <= crt.NbArcs(); ++i) {
@@ -486,7 +486,7 @@ BSpline::BSpline(const TopoDS_Edge &e)
tempSegment.degree = bezier->Degree();
for (int pole = 1; pole <= tempSegment.poles; ++pole) {
controlPoint = bezier->Pole(pole);
tempSegment.pnts.push_back(Base::Vector2D(controlPoint.X(), controlPoint.Y()));
tempSegment.pnts.push_back(Base::Vector2d(controlPoint.X(), controlPoint.Y()));
}
segments.push_back(tempSegment);
}
@@ -519,7 +519,7 @@ BezierSegment::BezierSegment(const TopoDS_Edge &e)
}
for (int i = 1; i <= poles; ++i) {
gp_Pnt controlPoint = bez->Pole(i);
pnts.push_back(Base::Vector2D(controlPoint.X(), controlPoint.Y()));
pnts.push_back(Base::Vector2d(controlPoint.X(), controlPoint.Y()));
}
}
@@ -527,7 +527,7 @@ BezierSegment::BezierSegment(const TopoDS_Edge &e)
//**** Vertex
Vertex::Vertex(double x, double y)
{
pnt = Base::Vector2D(x, y);
pnt = Base::Vector2d(x, y);
extractType = ExtractionType::Plain; //obs?
visible = false;
ref3D = -1; //obs. never used.
@@ -561,7 +561,7 @@ BaseGeomPtrVector GeometryUtils::chainGeoms(BaseGeomPtrVector geoms)
} else {
//start with first edge
result.push_back(geoms[0]);
Base::Vector2D atPoint = (geoms[0])->getEndPoint();
Base::Vector2d atPoint = (geoms[0])->getEndPoint();
used[0] = true;
for (unsigned int i = 1; i < geoms.size(); i++) { //do size-1 more edges
auto next( nextGeom(atPoint, geoms, used, Precision::Confusion()) );
@@ -586,7 +586,7 @@ BaseGeomPtrVector GeometryUtils::chainGeoms(BaseGeomPtrVector geoms)
/*static*/ GeometryUtils::ReturnType GeometryUtils::nextGeom(
Base::Vector2D atPoint,
Base::Vector2d atPoint,
BaseGeomPtrVector geoms,
std::vector<bool> used,
double tolerance )

View File

@@ -74,12 +74,12 @@ class TechDrawExport BaseGeom
int ref3D; //obs?
TopoDS_Edge occEdge; //projected Edge
std::vector<Base::Vector2D> findEndPoints();
Base::Vector2D getStartPoint();
Base::Vector2D getEndPoint();
double minDist(Base::Vector2D p);
Base::Vector2D nearPoint(Base::Vector2D p);
Base::Vector2D nearPoint(const BaseGeom* p);
std::vector<Base::Vector2d> findEndPoints();
Base::Vector2d getStartPoint();
Base::Vector2d getEndPoint();
double minDist(Base::Vector2d p);
Base::Vector2d nearPoint(Base::Vector2d p);
Base::Vector2d nearPoint(const BaseGeom* p);
static BaseGeom* baseFactory(TopoDS_Edge edge);
std::string dump();
};
@@ -93,7 +93,7 @@ class TechDrawExport Circle: public BaseGeom
~Circle() = default;
public:
Base::Vector2D center;
Base::Vector2d center;
double radius;
};
@@ -104,7 +104,7 @@ class TechDrawExport Ellipse: public BaseGeom
~Ellipse() = default;
public:
Base::Vector2D center;
Base::Vector2d center;
double minor;
double major;
@@ -119,9 +119,9 @@ class TechDrawExport AOE: public Ellipse
~AOE() = default;
public:
Base::Vector2D startPnt; //TODO: The points are used for drawing, the angles for bounding box calcs - seems redundant
Base::Vector2D endPnt;
Base::Vector2D midPnt;
Base::Vector2d startPnt; //TODO: The points are used for drawing, the angles for bounding box calcs - seems redundant
Base::Vector2d endPnt;
Base::Vector2d midPnt;
/// Angle in radian
double startAngle;
@@ -141,9 +141,9 @@ class TechDrawExport AOC: public Circle
~AOC() = default;
public:
Base::Vector2D startPnt;
Base::Vector2D endPnt;
Base::Vector2D midPnt;
Base::Vector2d startPnt;
Base::Vector2d endPnt;
Base::Vector2d midPnt;
/// Angle in radian ??angle with horizontal?
double startAngle;
@@ -170,8 +170,8 @@ public:
int poles;
int degree;
//Base::Vector2D pnts[4];
std::vector<Base::Vector2D> pnts;
//Base::Vector2d pnts[4];
std::vector<Base::Vector2d> pnts;
};
class TechDrawExport BSpline: public BaseGeom
@@ -192,7 +192,7 @@ class TechDrawExport Generic: public BaseGeom
Generic();
~Generic() = default;
std::vector<Base::Vector2D> points;
std::vector<Base::Vector2d> points;
};
@@ -222,19 +222,19 @@ class TechDrawExport Vertex
{
public:
Vertex(double x, double y);
Vertex(Base::Vector2D v) : Vertex(v.fX,v.fY) {}
Vertex(Base::Vector2d v) : Vertex(v.x,v.y) {}
~Vertex() = default;
Base::Vector2D pnt;
Base::Vector2d pnt;
ExtractionType extractType; //obs?
bool visible;
int ref3D; //obs. never used.
bool isCenter;
TopoDS_Vertex occVertex;
bool isEqual(Vertex* v, double tol);
Base::Vector3d getAs3D(void) {return Base::Vector3d(pnt.fX,pnt.fY,0.0);}
double x() {return pnt.fX;}
double y() {return pnt.fY;}
Base::Vector3d getAs3D(void) {return Base::Vector3d(pnt.x,pnt.y,0.0);}
double x() {return pnt.x;}
double y() {return pnt.y;}
};
/// Encapsulates some useful static methods
@@ -255,7 +255,7 @@ class TechDrawExport GeometryUtils
/*!
* returns index[1:geoms.size()),reversed [true,false]
*/
static ReturnType nextGeom( Base::Vector2D atPoint,
static ReturnType nextGeom( Base::Vector2d atPoint,
std::vector<TechDrawGeometry::BaseGeom*> geoms,
std::vector<bool> used,
double tolerance );

View File

@@ -414,7 +414,7 @@ Base::BoundBox3d GeometryObject::calcBoundingBox() const
}
//! does this GeometryObject already have this vertex
bool GeometryObject::findVertex(Base::Vector2D v)
bool GeometryObject::findVertex(Base::Vector2d v)
{
bool found = false;
std::vector<Vertex*>::iterator it = vertexGeom.begin();

View File

@@ -113,7 +113,7 @@ protected:
std::vector<Vertex *> vertexGeom;
std::vector<Face *> faceGeom;
bool findVertex(Base::Vector2D v);
bool findVertex(Base::Vector2d v);
double Scale;

View File

@@ -1009,10 +1009,10 @@ int _isValidSingleEdge(Gui::Command* cmd) {
if(gen1->points.size() > 2) { //the edge is a polyline
return isInvalid;
}
Base::Vector2D line = gen1->points.at(1) - gen1->points.at(0);
if(fabs(line.fY) < FLT_EPSILON ) {
Base::Vector2d line = gen1->points.at(1) - gen1->points.at(0);
if(fabs(line.y) < FLT_EPSILON ) {
edgeType = isHorizontal;
} else if(fabs(line.fX) < FLT_EPSILON) {
} else if(fabs(line.x) < FLT_EPSILON) {
edgeType = isVertical;
} else {
edgeType = isDiagonal;
@@ -1079,15 +1079,15 @@ int _isValidEdgeToEdge(Gui::Command* cmd) {
gen1->points.size() > 2) { //the edge is a polyline
return isInvalid;
}
Base::Vector2D line0 = gen0->points.at(1) - gen0->points.at(0);
Base::Vector2D line1 = gen1->points.at(1) - gen1->points.at(0);
double xprod = fabs(line0.fX * line1.fY - line0.fY * line1.fX);
Base::Vector2d line0 = gen0->points.at(1) - gen0->points.at(0);
Base::Vector2d line1 = gen1->points.at(1) - gen1->points.at(0);
double xprod = fabs(line0.x * line1.y - line0.y * line1.x);
if(xprod > FLT_EPSILON) { //edges are not parallel
return isAngle;
}
if(fabs(line0.fX) < FLT_EPSILON && fabs(line1.fX) < FLT_EPSILON) { //both horizontal
if(fabs(line0.x) < FLT_EPSILON && fabs(line1.x) < FLT_EPSILON) { //both horizontal
edgeType = isHorizontal;
} else if(fabs(line0.fY) < FLT_EPSILON && fabs(line1.fY) < FLT_EPSILON) { //both vertical
} else if(fabs(line0.y) < FLT_EPSILON && fabs(line1.y) < FLT_EPSILON) { //both vertical
edgeType = isVertical;
} else {
edgeType = isDiagonal;

View File

@@ -110,11 +110,11 @@ void QGIDrawingTemplate::draw()
TechDrawGeometry::Generic *geom = static_cast<TechDrawGeometry::Generic *>(*it);
path.moveTo(geom->points[0].fX, geom->points[0].fY);
std::vector<Base::Vector2D>::const_iterator it = geom->points.begin();
path.moveTo(geom->points[0].x, geom->points[0].y);
std::vector<Base::Vector2d>::const_iterator it = geom->points.begin();
for(++it; it != geom->points.end(); ++it) {
path.lineTo((*it).fX, (*it).fY);
path.lineTo((*it).x, (*it).y);
}
break;
}

View File

@@ -324,10 +324,10 @@ void QGIViewDimension::draw()
}
if (geom->geomType == TechDrawGeometry::GENERIC) {
TechDrawGeometry::Generic *gen = static_cast<TechDrawGeometry::Generic *>(geom);
Base::Vector2D pnt1 = gen->points.at(0);
Base::Vector2D pnt2 = gen->points.at(1);
distStart = Base::Vector3d(pnt1.fX, pnt1.fY, 0.);
distEnd = Base::Vector3d(pnt2.fX, pnt2.fY, 0.);
Base::Vector2d pnt1 = gen->points.at(0);
Base::Vector2d pnt2 = gen->points.at(1);
distStart = Base::Vector3d(pnt1.x, pnt1.y, 0.);
distEnd = Base::Vector3d(pnt2.x, pnt2.y, 0.);
} else {
throw Base::Exception("QGIVD::draw - Original edge not found or is invalid type (1)");
}
@@ -344,8 +344,8 @@ void QGIViewDimension::draw()
idx0,idx1,refObj->getEdgeGeometry().size());
return;
}
distStart = Base::Vector3d (v0->pnt.fX, v0->pnt.fY, 0.);
distEnd = Base::Vector3d (v1->pnt.fX, v1->pnt.fY, 0.);
distStart = Base::Vector3d (v0->pnt.x, v0->pnt.y, 0.);
distEnd = Base::Vector3d (v1->pnt.x, v1->pnt.y, 0.);
} else if(dim->References2D.getValues().size() == 2 &&
TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge" &&
TechDraw::DrawUtil::getGeomTypeFromName(SubNames[1]) == "Edge") {
@@ -360,25 +360,25 @@ void QGIViewDimension::draw()
}
if (strcmp(dimType, "DistanceX") == 0 ||
strcmp(dimType, "DistanceY") == 0) {
Base::Vector2D p1,p2;
Base::Vector2d p1,p2;
p1 = geom0->nearPoint(geom1);
p2 = geom1->nearPoint(geom0);
distStart = Base::Vector3d(p1.fX,p1.fY,0.0);
distEnd = Base::Vector3d(p2.fX,p2.fY,0.0);
distStart = Base::Vector3d(p1.x,p1.y,0.0);
distEnd = Base::Vector3d(p2.x,p2.y,0.0);
} else if ( (geom0->geomType == TechDrawGeometry::GENERIC) &&
(geom1->geomType == TechDrawGeometry::GENERIC) ){
TechDrawGeometry::Generic *gen0 = static_cast<TechDrawGeometry::Generic *>(geom0);
TechDrawGeometry::Generic *gen1 = static_cast<TechDrawGeometry::Generic *>(geom1);
Base::Vector2D pnt1, pnt2;
Base::Vector2d pnt1, pnt2;
Base::Vector3d edge1Start, edge1End, edge2Start, edge2End;
pnt1 = gen0->points.at(0);
pnt2 = gen0->points.at(1);
edge1Start = Base::Vector3d(pnt1.fX, pnt1.fY, 0);
edge1End = Base::Vector3d(pnt2.fX, pnt2.fY, 0);
edge1Start = Base::Vector3d(pnt1.x, pnt1.y, 0);
edge1End = Base::Vector3d(pnt2.x, pnt2.y, 0);
pnt1 = gen1->points.at(0);
pnt2 = gen1->points.at(1);
edge2Start = Base::Vector3d(pnt1.fX, pnt1.fY, 0);
edge2End = Base::Vector3d(pnt2.fX, pnt2.fY, 0);
edge2Start = Base::Vector3d(pnt1.x, pnt1.y, 0);
edge2End = Base::Vector3d(pnt2.x, pnt2.y, 0);
// figure out which end of each edge to use for drawing
Base::Vector3d lin1 = edge1End - edge1Start; //vector from edge1Start to edge2End
@@ -423,9 +423,9 @@ void QGIViewDimension::draw()
ex,vx,refObj->getEdgeGeometry().size());
return;
}
Base::Vector3d pnt(v->pnt.fX,v->pnt.fY, 0.0);
Base::Vector3d edgeStart(e->getStartPoint().fX,e->getStartPoint().fY,0.0);
Base::Vector3d edgeEnd(e->getEndPoint().fX,e->getEndPoint().fY,0.0);
Base::Vector3d pnt(v->pnt.x,v->pnt.y, 0.0);
Base::Vector3d edgeStart(e->getStartPoint().x,e->getStartPoint().y,0.0);
Base::Vector3d edgeEnd(e->getEndPoint().x,e->getEndPoint().y,0.0);
Base::Vector3d displace;
displace.ProjectToLine(pnt - edgeStart, edgeEnd - edgeStart);
Base::Vector3d ptOnLine = pnt + displace;
@@ -626,7 +626,7 @@ void QGIViewDimension::draw()
(geom->geomType == TechDrawGeometry::ARCOFCIRCLE) ) {
TechDrawGeometry::Circle *circ = static_cast<TechDrawGeometry::Circle *>(geom);
radius = circ->radius;
centre = Base::Vector3d (circ->center.fX, circ->center.fY, 0);
centre = Base::Vector3d (circ->center.x, circ->center.y, 0);
} else {
throw Base::Exception("FVD::draw - Original edge not found or is invalid type (2)");
}
@@ -842,15 +842,15 @@ void QGIViewDimension::draw()
if (geom->geomType == TechDrawGeometry::CIRCLE) {
TechDrawGeometry::Circle *circ = static_cast<TechDrawGeometry::Circle *>(geom);
radius = circ->radius;
curveCenter = Base::Vector3d(circ->center.fX,circ->center.fY,0.0);
curveCenter = Base::Vector3d(circ->center.x,circ->center.y,0.0);
pointOnCurve = Base::Vector3d(curveCenter.x + radius, curveCenter.y,0.0);
} else if (geom->geomType == TechDrawGeometry::ARCOFCIRCLE) {
isArc = true;
TechDrawGeometry::AOC *circ = static_cast<TechDrawGeometry::AOC *>(geom);
geomArc = circ;
radius = circ->radius;
curveCenter = Base::Vector3d(circ->center.fX,circ->center.fY,0.0);
pointOnCurve = Base::Vector3d(circ->midPnt.fX, circ->midPnt.fY,0.0);
curveCenter = Base::Vector3d(circ->center.x,circ->center.y,0.0);
pointOnCurve = Base::Vector3d(circ->midPnt.x, circ->midPnt.y,0.0);
} else {
throw Base::Exception("FVD::draw - Original edge not found or is invalid type (3)");
}
@@ -904,9 +904,9 @@ void QGIViewDimension::draw()
//handle partial arc weird cases
if (isArc) {
Base::Vector3d midPt(geomArc->midPnt.fX, geomArc->midPnt.fY,0.0);
Base::Vector3d startPt(geomArc->startPnt.fX, geomArc->startPnt.fY,0.0);
Base::Vector3d endPt(geomArc->endPnt.fX, geomArc->endPnt.fY,0.0);
Base::Vector3d midPt(geomArc->midPnt.x, geomArc->midPnt.y,0.0);
Base::Vector3d startPt(geomArc->startPnt.x, geomArc->startPnt.y,0.0);
Base::Vector3d endPt(geomArc->endPnt.x, geomArc->endPnt.y,0.0);
if (outerPlacement &&
!geomArc->intersectsArc(curveCenter,kinkPoint) ) {
pointOnCurve = midPt;
@@ -979,19 +979,19 @@ void QGIViewDimension::draw()
TechDrawGeometry::Generic *gen1 = static_cast<TechDrawGeometry::Generic *>(geom1);
// Get Points for line
Base::Vector2D pnt1, pnt2;
Base::Vector2d pnt1, pnt2;
Base::Vector3d p1S, p1E, p2S, p2E;
pnt1 = gen0->points.at(0);
pnt2 = gen0->points.at(1);
p1S = Base::Vector3d(pnt1.fX, pnt1.fY, 0);
p1E = Base::Vector3d(pnt2.fX, pnt2.fY, 0);
p1S = Base::Vector3d(pnt1.x, pnt1.y, 0);
p1E = Base::Vector3d(pnt2.x, pnt2.y, 0);
pnt1 = gen1->points.at(0);
pnt2 = gen1->points.at(1);
p2S = Base::Vector3d(pnt1.fX, pnt1.fY, 0);
p2E = Base::Vector3d(pnt2.fX, pnt2.fY, 0);
p2S = Base::Vector3d(pnt1.x, pnt1.y, 0);
p2E = Base::Vector3d(pnt2.x, pnt2.y, 0);
Base::Vector3d dir1 = p1E - p1S;
Base::Vector3d dir2 = p2E - p2S;

View File

@@ -138,8 +138,8 @@ QPainterPath QGIViewPart::drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom)
case TechDrawGeometry::CIRCLE: {
TechDrawGeometry::Circle *geom = static_cast<TechDrawGeometry::Circle *>(baseGeom);
double x = geom->center.fX - geom->radius;
double y = geom->center.fY - geom->radius;
double x = geom->center.x - geom->radius;
double y = geom->center.y - geom->radius;
path.addEllipse(x, y, geom->radius * 2, geom->radius * 2); //topleft@(x,y) radx,rady
//Base::Console().Message("TRACE -drawPainterPath - making an CIRCLE @(%.3f,%.3f) R:%.3f\n",x, y, geom->radius);
@@ -148,20 +148,20 @@ QPainterPath QGIViewPart::drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom)
TechDrawGeometry::AOC *geom = static_cast<TechDrawGeometry::AOC *>(baseGeom);
pathArc(path, geom->radius, geom->radius, 0., geom->largeArc, geom->cw,
geom->endPnt.fX, geom->endPnt.fY,
geom->startPnt.fX, geom->startPnt.fY);
// double x = geom->center.fX - geom->radius;
// double y = geom->center.fY - geom->radius;
geom->endPnt.x, geom->endPnt.y,
geom->startPnt.x, geom->startPnt.y);
// double x = geom->center.x - geom->radius;
// double y = geom->center.y - geom->radius;
//Base::Console().Message("TRACE -drawPainterPath - making an ARCOFCIRCLE @(%.3f,%.3f) R:%.3f\n",x, y, geom->radius);
} break;
case TechDrawGeometry::ELLIPSE: {
TechDrawGeometry::Ellipse *geom = static_cast<TechDrawGeometry::Ellipse *>(baseGeom);
// Calculate start and end points as ellipse with theta = 0 and pi
double startX = geom->center.fX + geom->major * cos(geom->angle),
startY = geom->center.fY + geom->major * sin(geom->angle),
endX = geom->center.fX - geom->major * cos(geom->angle),
endY = geom->center.fY - geom->major * sin(geom->angle);
double startX = geom->center.x + geom->major * cos(geom->angle),
startY = geom->center.y + geom->major * sin(geom->angle),
endX = geom->center.x - geom->major * cos(geom->angle),
endY = geom->center.y - geom->major * sin(geom->angle);
pathArc(path, geom->major, geom->minor, geom->angle, false, false,
endX, endY, startX, startY);
@@ -169,41 +169,41 @@ QPainterPath QGIViewPart::drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom)
pathArc(path, geom->major, geom->minor, geom->angle, false, false,
startX, startY, endX, endY);
//Base::Console().Message("TRACE -drawPainterPath - making an ELLIPSE @(%.3f,%.3f) R1:%.3f R2:%.3f\n",geom->center.fX,geom->center.fY, geom->major, geom->minor);
//Base::Console().Message("TRACE -drawPainterPath - making an ELLIPSE @(%.3f,%.3f) R1:%.3f R2:%.3f\n",geom->center.x,geom->center.y, geom->major, geom->minor);
} break;
case TechDrawGeometry::ARCOFELLIPSE: {
TechDrawGeometry::AOE *geom = static_cast<TechDrawGeometry::AOE *>(baseGeom);
pathArc(path, geom->major, geom->minor, geom->angle, geom->largeArc, geom->cw,
geom->endPnt.fX, geom->endPnt.fY,
geom->startPnt.fX, geom->startPnt.fY);
//Base::Console().Message("TRACE -drawPainterPath - making an ARCOFELLIPSE R1:%.3f R2:%.3f From: (%.3f,%.3f) To: (%.3f,%.3f)\n",geom->major, geom->minor,geom->startPnt.fX, geom->startPnt.fY,geom->endPnt.fX, geom->endPnt.fY);
geom->endPnt.x, geom->endPnt.y,
geom->startPnt.x, geom->startPnt.y);
//Base::Console().Message("TRACE -drawPainterPath - making an ARCOFELLIPSE R1:%.3f R2:%.3f From: (%.3f,%.3f) To: (%.3f,%.3f)\n",geom->major, geom->minor,geom->startPnt.x, geom->startPnt.y,geom->endPnt.x, geom->endPnt.y);
} break;
case TechDrawGeometry::BEZIER: {
TechDrawGeometry::BezierSegment *geom = static_cast<TechDrawGeometry::BezierSegment *>(baseGeom);
// Move painter to the beginning
path.moveTo(geom->pnts[0].fX, geom->pnts[0].fY);
//Base::Console().Message("TRACE -drawPainterPath - making an BEZIER From: (%.3f,%.3f)\n",geom->pnts[0].fX,geom->pnts[0].fY);
path.moveTo(geom->pnts[0].x, geom->pnts[0].y);
//Base::Console().Message("TRACE -drawPainterPath - making an BEZIER From: (%.3f,%.3f)\n",geom->pnts[0].x,geom->pnts[0].y);
if ( geom->poles == 2 ) {
// Degree 1 bezier = straight line...
path.lineTo(geom->pnts[1].fX, geom->pnts[1].fY);
path.lineTo(geom->pnts[1].x, geom->pnts[1].y);
} else if ( geom->poles == 3 ) {
path.quadTo(geom->pnts[1].fX, geom->pnts[1].fY,
geom->pnts[2].fX, geom->pnts[2].fY);
path.quadTo(geom->pnts[1].x, geom->pnts[1].y,
geom->pnts[2].x, geom->pnts[2].y);
} else if ( geom->poles == 4 ) {
path.cubicTo(geom->pnts[1].fX, geom->pnts[1].fY,
geom->pnts[2].fX, geom->pnts[2].fY,
geom->pnts[3].fX, geom->pnts[3].fY);
path.cubicTo(geom->pnts[1].x, geom->pnts[1].y,
geom->pnts[2].x, geom->pnts[2].y,
geom->pnts[3].x, geom->pnts[3].y);
} else { //can only handle lines,quads,cubes
Base::Console().Error("Bad pole count (%d) for BezierSegment\n",geom->poles);
auto itBez = geom->pnts.begin() + 1;
for (; itBez != geom->pnts.end();itBez++) {
path.lineTo((*itBez).fX, (*itBez).fY); //show something for debugging
path.lineTo((*itBez).x, (*itBez).y); //show something for debugging
}
}
} break;
@@ -213,39 +213,39 @@ QPainterPath QGIViewPart::drawPainterPath(TechDrawGeometry::BaseGeom *baseGeom)
std::vector<TechDrawGeometry::BezierSegment>::const_iterator it = geom->segments.begin();
// Move painter to the beginning of our first segment
path.moveTo(it->pnts[0].fX, it->pnts[0].fY);
//Base::Console().Message("TRACE -drawPainterPath - making an BSPLINE From: (%.3f,%.3f)\n",it->pnts[0].fX,it->pnts[0].fY);
path.moveTo(it->pnts[0].x, it->pnts[0].y);
//Base::Console().Message("TRACE -drawPainterPath - making an BSPLINE From: (%.3f,%.3f)\n",it->pnts[0].x,it->pnts[0].y);
for ( ; it != geom->segments.end(); ++it) {
// At this point, the painter is either at the beginning
// of the first segment, or end of the last
if ( it->poles == 2 ) {
// Degree 1 bezier = straight line...
path.lineTo(it->pnts[1].fX, it->pnts[1].fY);
path.lineTo(it->pnts[1].x, it->pnts[1].y);
} else if ( it->poles == 3 ) {
path.quadTo(it->pnts[1].fX, it->pnts[1].fY,
it->pnts[2].fX, it->pnts[2].fY);
path.quadTo(it->pnts[1].x, it->pnts[1].y,
it->pnts[2].x, it->pnts[2].y);
} else if ( it->poles == 4 ) {
path.cubicTo(it->pnts[1].fX, it->pnts[1].fY,
it->pnts[2].fX, it->pnts[2].fY,
it->pnts[3].fX, it->pnts[3].fY);
path.cubicTo(it->pnts[1].x, it->pnts[1].y,
it->pnts[2].x, it->pnts[2].y,
it->pnts[3].x, it->pnts[3].y);
} else { //can only handle lines,quads,cubes
Base::Console().Error("Bad pole count (%d) for BezierSegment of BSpline geometry\n",it->poles);
path.lineTo(it->pnts[1].fX, it->pnts[1].fY); //show something for debugging
path.lineTo(it->pnts[1].x, it->pnts[1].y); //show something for debugging
}
}
} break;
case TechDrawGeometry::GENERIC: {
TechDrawGeometry::Generic *geom = static_cast<TechDrawGeometry::Generic *>(baseGeom);
path.moveTo(geom->points[0].fX, geom->points[0].fY);
std::vector<Base::Vector2D>::const_iterator it = geom->points.begin();
//Base::Console().Message("TRACE -drawPainterPath - making an GENERIC From: (%.3f,%.3f)\n",geom->points[0].fX, geom->points[0].fY);
path.moveTo(geom->points[0].x, geom->points[0].y);
std::vector<Base::Vector2d>::const_iterator it = geom->points.begin();
//Base::Console().Message("TRACE -drawPainterPath - making an GENERIC From: (%.3f,%.3f)\n",geom->points[0].x, geom->points[0].y);
for(++it; it != geom->points.end(); ++it) {
path.lineTo((*it).fX, (*it).fY);
//Base::Console().Message(">>>> To: (%.3f,%.3f)\n",(*it).fX, (*it).fY);
path.lineTo((*it).x, (*it).y);
//Base::Console().Message(">>>> To: (%.3f,%.3f)\n",(*it).x, (*it).y);
}
} break;
default:
@@ -408,7 +408,7 @@ void QGIViewPart::drawViewPart()
if (showCenters) {
QGICMark* cmItem = new QGICMark(i);
addToGroup(cmItem);
cmItem->setPos((*vert)->pnt.fX, (*vert)->pnt.fY); //this is in ViewPart coords
cmItem->setPos((*vert)->pnt.x, (*vert)->pnt.y); //this is in ViewPart coords
cmItem->setThick(0.5 * lineWidth * lineScaleFactor); //need minimum?
cmItem->setSize( cAdjust * lineWidth * vertexScaleFactor);
cmItem->setZValue(ZVALUE::VERTEX);
@@ -416,7 +416,7 @@ void QGIViewPart::drawViewPart()
} else {
QGIVertex *item = new QGIVertex(i);
addToGroup(item);
item->setPos((*vert)->pnt.fX, (*vert)->pnt.fY); //this is in ViewPart coords
item->setPos((*vert)->pnt.x, (*vert)->pnt.y); //this is in ViewPart coords
item->setRadius(lineWidth * vertexScaleFactor);
item->setZValue(ZVALUE::VERTEX);
}
@@ -603,8 +603,8 @@ void QGIViewPart::drawCenterLines(bool b)
// As called by arc of ellipse case:
// pathArc(path, geom->major, geom->minor, geom->angle, geom->largeArc, geom->cw,
// geom->endPnt.fX, geom->endPnt.fY,
// geom->startPnt.fX, geom->startPnt.fY);
// geom->endPnt.x, geom->endPnt.y,
// geom->startPnt.x, geom->startPnt.y);
void QGIViewPart::pathArc(QPainterPath &path, double rx, double ry, double x_axis_rotation,
bool large_arc_flag, bool sweep_flag,
double x, double y,