rename 2d tool classes to be consistent with 3d classes
This commit is contained in:
parent
31d43b4a12
commit
e54e9515fc
|
@ -84,9 +84,9 @@ public:
|
|||
/** Checks for intersection. */
|
||||
inline bool operator && (const BoundBox3<_Precision> &rcBB) const;
|
||||
/** Checks for intersection. */
|
||||
inline bool Intersect (const BoundBox2D &rcBB) const;
|
||||
inline bool Intersect (const BoundBox2d &rcBB) const;
|
||||
/** Checks for intersection. */
|
||||
inline bool operator && (const BoundBox2D &rcBB) const;
|
||||
inline bool operator && (const BoundBox2d &rcBB) const;
|
||||
/** Computes the intersection between two bounding boxes.
|
||||
* The result is also a bounding box.
|
||||
*/
|
||||
|
@ -112,7 +112,7 @@ public:
|
|||
/** Checks if this 2D box lies inside the box.
|
||||
* @note It's up to the client programmer to make sure that both bounding boxes are valid.
|
||||
*/
|
||||
inline bool IsInBox (const BoundBox2D &rcbb) const;
|
||||
inline bool IsInBox (const BoundBox2d &rcbb) const;
|
||||
/** Checks whether the bounding box is valid. */
|
||||
bool IsValid (void) const;
|
||||
//@}
|
||||
|
@ -167,7 +167,7 @@ public:
|
|||
*/
|
||||
Vector3<_Precision> ClosestPoint (const Vector3<_Precision> &rclPt) const;
|
||||
/** Projects the box onto a plane and returns a 2D box. */
|
||||
BoundBox2D ProjectBox(const ViewProjMethod *rclP) const;
|
||||
BoundBox2d ProjectBox(const ViewProjMethod *rclP) const;
|
||||
/** Transform the corners of this box with the given matrix and create a new bounding box.
|
||||
* @note It's up to the client programmer to make sure that this bounding box is valid.
|
||||
*/
|
||||
|
@ -299,17 +299,17 @@ bool BoundBox3<_Precision>::operator && (const BoundBox3<_Precision> &rcBB) cons
|
|||
}
|
||||
|
||||
template <class _Precision>
|
||||
inline bool BoundBox3<_Precision>::Intersect (const BoundBox2D &rcBB) const
|
||||
inline bool BoundBox3<_Precision>::Intersect (const BoundBox2d &rcBB) const
|
||||
{
|
||||
if (rcBB.fMaxX < this->MinX || rcBB.fMinX > this->MaxX)
|
||||
if (rcBB.MaxX < this->MinX || rcBB.MinX > this->MaxX)
|
||||
return false;
|
||||
if (rcBB.fMaxY < this->MinY || rcBB.fMinY > this->MaxY)
|
||||
if (rcBB.MaxY < this->MinY || rcBB.MinY > this->MaxY)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
template <class _Precision>
|
||||
inline bool BoundBox3<_Precision>::operator && (const BoundBox2D &rcBB) const
|
||||
inline bool BoundBox3<_Precision>::operator && (const BoundBox2d &rcBB) const
|
||||
{
|
||||
return Intersect(rcBB);
|
||||
}
|
||||
|
@ -391,11 +391,11 @@ inline bool BoundBox3<_Precision>::IsInBox (const BoundBox3<_Precision> &rcBB) c
|
|||
}
|
||||
|
||||
template <class _Precision>
|
||||
inline bool BoundBox3<_Precision>::IsInBox (const BoundBox2D &rcBB) const
|
||||
inline bool BoundBox3<_Precision>::IsInBox (const BoundBox2d &rcBB) const
|
||||
{
|
||||
if (rcBB.fMinX < this->MinX || rcBB.fMaxX > this->MaxX)
|
||||
if (rcBB.MinX < this->MinX || rcBB.MaxX > this->MaxX)
|
||||
return false;
|
||||
if (rcBB.fMinY < this->MinY || rcBB.fMaxY > this->MaxY)
|
||||
if (rcBB.MinY < this->MinY || rcBB.MaxY > this->MaxY)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
@ -872,14 +872,14 @@ inline Vector3<_Precision> BoundBox3<_Precision>::ClosestPoint (const Vector3<_P
|
|||
}
|
||||
|
||||
template <class _Precision>
|
||||
inline BoundBox2D BoundBox3<_Precision>::ProjectBox(const ViewProjMethod *pclP) const
|
||||
inline BoundBox2d BoundBox3<_Precision>::ProjectBox(const ViewProjMethod *pclP) const
|
||||
{
|
||||
BoundBox2D clBB2D;
|
||||
BoundBox2d clBB2D;
|
||||
clBB2D.SetVoid();
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
Vector3<_Precision> clTrsPt = (*pclP)(CalcPoint(i));
|
||||
clBB2D.Add(Vector2D(clTrsPt.x, clTrsPt.y));
|
||||
clBB2D.Add(Vector2d(clTrsPt.x, clTrsPt.y));
|
||||
}
|
||||
|
||||
return clBB2D;
|
||||
|
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
using namespace Base;
|
||||
|
||||
double Vector2D::GetAngle (const Vector2D &rclVect) const
|
||||
double Vector2d::GetAngle (const Vector2d &rclVect) const
|
||||
{
|
||||
double fDivid, fNum;
|
||||
|
||||
|
@ -54,83 +54,83 @@ double Vector2D::GetAngle (const Vector2D &rclVect) const
|
|||
return -FLOAT_MAX; // division by zero
|
||||
}
|
||||
|
||||
void Vector2D::ProjectToLine (const Vector2D &rclPt, const Vector2D &rclLine)
|
||||
void Vector2d::ProjectToLine (const Vector2d &rclPt, const Vector2d &rclLine)
|
||||
{
|
||||
double l = rclLine.Length();
|
||||
double t1 = (rclPt * rclLine) / l;
|
||||
Vector2D clNormal = rclLine;
|
||||
Vector2d clNormal = rclLine;
|
||||
clNormal.Normalize();
|
||||
clNormal.Scale(t1);
|
||||
*this = clNormal;
|
||||
}
|
||||
|
||||
/********************************************************/
|
||||
/** BOUNDBOX2D ********************************************/
|
||||
/** BOUNDBOX2d ********************************************/
|
||||
|
||||
bool BoundBox2D::Intersect(const Line2D &rclLine) const
|
||||
bool BoundBox2d::Intersect(const Line2d &rclLine) const
|
||||
{
|
||||
Line2D clThisLine;
|
||||
Vector2D clVct;
|
||||
Line2d clThisLine;
|
||||
Vector2d clVct;
|
||||
|
||||
// first line
|
||||
clThisLine.clV1.fX = fMinX;
|
||||
clThisLine.clV1.fY = fMinY;
|
||||
clThisLine.clV2.fX = fMaxX;
|
||||
clThisLine.clV2.fY = fMinY;
|
||||
clThisLine.clV1.x = MinX;
|
||||
clThisLine.clV1.y = MinY;
|
||||
clThisLine.clV2.x = MaxX;
|
||||
clThisLine.clV2.y = MinY;
|
||||
if (clThisLine.IntersectAndContain (rclLine, clVct))
|
||||
return true;
|
||||
|
||||
// second line
|
||||
clThisLine.clV1 = clThisLine.clV2;
|
||||
clThisLine.clV2.fX = fMaxX;
|
||||
clThisLine.clV2.fY = fMaxY;
|
||||
clThisLine.clV2.x = MaxX;
|
||||
clThisLine.clV2.y = MaxY;
|
||||
if (clThisLine.IntersectAndContain (rclLine, clVct))
|
||||
return true;
|
||||
|
||||
// third line
|
||||
clThisLine.clV1 = clThisLine.clV2;
|
||||
clThisLine.clV2.fX = fMinX;
|
||||
clThisLine.clV2.fY = fMaxY;
|
||||
clThisLine.clV2.x = MinX;
|
||||
clThisLine.clV2.y = MaxY;
|
||||
if (clThisLine.IntersectAndContain (rclLine, clVct))
|
||||
return true;
|
||||
|
||||
// fourth line
|
||||
clThisLine.clV1 = clThisLine.clV2;
|
||||
clThisLine.clV2.fX = fMinX;
|
||||
clThisLine.clV2.fY = fMinY;
|
||||
clThisLine.clV2.x = MinX;
|
||||
clThisLine.clV2.y = MinY;
|
||||
if (clThisLine.IntersectAndContain (rclLine, clVct))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BoundBox2D::Intersect(const BoundBox2D &rclBB) const
|
||||
bool BoundBox2d::Intersect(const BoundBox2d &rclBB) const
|
||||
{
|
||||
//// compare bb2-points to this
|
||||
//if (Contains (Vector2D (rclBB.fMinX, rclBB.fMinY))) return true;
|
||||
//if (Contains (Vector2D (rclBB.fMaxX, rclBB.fMinY))) return true;
|
||||
//if (Contains (Vector2D (rclBB.fMaxX, rclBB.fMaxY))) return true;
|
||||
//if (Contains (Vector2D (rclBB.fMinX, rclBB.fMaxY))) return true;
|
||||
//if (Contains (Vector2d (rclBB.fMinX, rclBB.fMinY))) return true;
|
||||
//if (Contains (Vector2d (rclBB.fMaxX, rclBB.fMinY))) return true;
|
||||
//if (Contains (Vector2d (rclBB.fMaxX, rclBB.fMaxY))) return true;
|
||||
//if (Contains (Vector2d (rclBB.fMinX, rclBB.fMaxY))) return true;
|
||||
//
|
||||
//// compare this-points to bb2
|
||||
//if (rclBB.Contains (Vector2D (fMinX, fMinY))) return true;
|
||||
//if (rclBB.Contains (Vector2D (fMaxX, fMinY))) return true;
|
||||
//if (rclBB.Contains (Vector2D (fMaxX, fMaxY))) return true;
|
||||
//if (rclBB.Contains (Vector2D (fMinX, fMaxY))) return true;
|
||||
//if (rclBB.Contains (Vector2d (fMinX, fMinY))) return true;
|
||||
//if (rclBB.Contains (Vector2d (fMaxX, fMinY))) return true;
|
||||
//if (rclBB.Contains (Vector2d (fMaxX, fMaxY))) return true;
|
||||
//if (rclBB.Contains (Vector2d (fMinX, fMaxY))) return true;
|
||||
|
||||
if (fMinX < rclBB.fMaxX &&
|
||||
rclBB.fMinX < fMaxX &&
|
||||
fMinY < rclBB.fMaxY &&
|
||||
rclBB.fMinY < fMaxY )
|
||||
if (MinX < rclBB.MaxX &&
|
||||
rclBB.MinX < MaxX &&
|
||||
MinY < rclBB.MaxY &&
|
||||
rclBB.MinY < MaxY )
|
||||
return true;
|
||||
else // no intersection
|
||||
return false;
|
||||
}
|
||||
|
||||
bool BoundBox2D::Intersect(const Polygon2D &rclPoly) const
|
||||
bool BoundBox2d::Intersect(const Polygon2d &rclPoly) const
|
||||
{
|
||||
unsigned long i;
|
||||
Line2D clLine;
|
||||
Line2d clLine;
|
||||
|
||||
// points contained in boundbox
|
||||
for (i = 0; i < rclPoly.GetCtVectors(); i++)
|
||||
|
@ -138,10 +138,10 @@ bool BoundBox2D::Intersect(const Polygon2D &rclPoly) const
|
|||
return true; /***** RETURN INTERSECTION *********/
|
||||
|
||||
// points contained in polygon
|
||||
if (rclPoly.Contains (Vector2D (fMinX, fMinY)) ||
|
||||
rclPoly.Contains (Vector2D (fMaxX, fMinY)) ||
|
||||
rclPoly.Contains (Vector2D (fMaxX, fMaxY)) ||
|
||||
rclPoly.Contains (Vector2D (fMinX, fMaxY)))
|
||||
if (rclPoly.Contains (Vector2d (MinX, MinY)) ||
|
||||
rclPoly.Contains (Vector2d (MaxX, MinY)) ||
|
||||
rclPoly.Contains (Vector2d (MaxX, MaxY)) ||
|
||||
rclPoly.Contains (Vector2d (MinX, MaxY)))
|
||||
return true; /***** RETURN INTERSECTION *********/
|
||||
|
||||
// test intersections of bound-lines
|
||||
|
@ -165,73 +165,73 @@ bool BoundBox2D::Intersect(const Polygon2D &rclPoly) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool BoundBox2D::Contains (const Vector2D &rclV) const
|
||||
bool BoundBox2d::Contains (const Vector2d &rclV) const
|
||||
{
|
||||
return
|
||||
(rclV.fX >= fMinX) && (rclV.fX <= fMaxX) &&
|
||||
(rclV.fY >= fMinY) && (rclV.fY <= fMaxY);
|
||||
(rclV.x >= MinX) && (rclV.x <= MaxX) &&
|
||||
(rclV.y >= MinY) && (rclV.y <= MaxY);
|
||||
}
|
||||
|
||||
/********************************************************/
|
||||
/** LINE2D **********************************************/
|
||||
|
||||
BoundBox2D Line2D::CalcBoundBox (void) const
|
||||
BoundBox2d Line2d::CalcBoundBox (void) const
|
||||
{
|
||||
BoundBox2D clBB;
|
||||
clBB.fMinX = std::min<double> (clV1.fX, clV2.fX);
|
||||
clBB.fMinY = std::min<double> (clV1.fY, clV2.fY);
|
||||
clBB.fMaxX = std::max<double> (clV1.fX, clV2.fX);
|
||||
clBB.fMaxY = std::max<double> (clV1.fY, clV2.fY);
|
||||
BoundBox2d clBB;
|
||||
clBB.MinX = std::min<double> (clV1.x, clV2.x);
|
||||
clBB.MinY = std::min<double> (clV1.y, clV2.y);
|
||||
clBB.MaxX = std::max<double> (clV1.x, clV2.x);
|
||||
clBB.MaxY = std::max<double> (clV1.y, clV2.y);
|
||||
return clBB;
|
||||
}
|
||||
|
||||
bool Line2D::Intersect (const Line2D& rclLine, Vector2D &rclV) const
|
||||
bool Line2d::Intersect (const Line2d& rclLine, Vector2d &rclV) const
|
||||
{
|
||||
double m1, m2, b1, b2;
|
||||
|
||||
// calc coefficients
|
||||
if (fabs (clV2.fX - clV1.fX) > 1e-10)
|
||||
m1 = (clV2.fY - clV1.fY) / (clV2.fX - clV1.fX);
|
||||
if (fabs (clV2.x - clV1.x) > 1e-10)
|
||||
m1 = (clV2.y - clV1.y) / (clV2.x - clV1.x);
|
||||
else
|
||||
m1 = FLOAT_MAX;
|
||||
if (fabs (rclLine.clV2.fX - rclLine.clV1.fX) > 1e-10)
|
||||
m2 = (rclLine.clV2.fY - rclLine.clV1.fY) / (rclLine.clV2.fX - rclLine.clV1.fX);
|
||||
if (fabs (rclLine.clV2.x - rclLine.clV1.x) > 1e-10)
|
||||
m2 = (rclLine.clV2.y - rclLine.clV1.y) / (rclLine.clV2.x - rclLine.clV1.x);
|
||||
else
|
||||
m2 = FLOAT_MAX;
|
||||
if (m1 == m2) /****** RETURN ERR (parallel lines) *************/
|
||||
return false;
|
||||
|
||||
b1 = clV1.fY - m1 * clV1.fX;
|
||||
b2 = rclLine.clV1.fY - m2 * rclLine.clV1.fX;
|
||||
b1 = clV1.y - m1 * clV1.x;
|
||||
b2 = rclLine.clV1.y - m2 * rclLine.clV1.x;
|
||||
|
||||
// calc intersection
|
||||
if (m1 == FLOAT_MAX)
|
||||
{
|
||||
rclV.fX = clV1.fX;
|
||||
rclV.fY = m2 * rclV.fX + b2;
|
||||
rclV.x = clV1.x;
|
||||
rclV.y = m2 * rclV.x + b2;
|
||||
}
|
||||
else
|
||||
if (m2 == FLOAT_MAX)
|
||||
{
|
||||
rclV.fX = rclLine.clV1.fX;
|
||||
rclV.fY = m1 * rclV.fX + b1;
|
||||
rclV.x = rclLine.clV1.x;
|
||||
rclV.y = m1 * rclV.x + b1;
|
||||
}
|
||||
else
|
||||
{
|
||||
rclV.fX = (b2 - b1) / (m1 - m2);
|
||||
rclV.fY = m1 * rclV.fX + b1;
|
||||
rclV.x = (b2 - b1) / (m1 - m2);
|
||||
rclV.y = m1 * rclV.x + b1;
|
||||
}
|
||||
|
||||
return true; /*** RETURN true (intersection) **********/
|
||||
}
|
||||
|
||||
bool Line2D::Intersect (const Vector2D &rclV, double eps) const
|
||||
bool Line2d::Intersect (const Vector2d &rclV, double eps) const
|
||||
{
|
||||
double dxc = rclV.fX - clV1.fX;
|
||||
double dyc = rclV.fY - clV1.fY;
|
||||
double dxc = rclV.x - clV1.x;
|
||||
double dyc = rclV.y - clV1.y;
|
||||
|
||||
double dxl = clV2.fX - clV1.fX;
|
||||
double dyl = clV2.fY - clV1.fY;
|
||||
double dxl = clV2.x - clV1.x;
|
||||
double dyl = clV2.y - clV1.y;
|
||||
|
||||
double cross = dxc * dyl - dyc * dxl;
|
||||
|
||||
|
@ -247,14 +247,14 @@ bool Line2D::Intersect (const Vector2D &rclV, double eps) const
|
|||
return true;
|
||||
}
|
||||
|
||||
Vector2D Line2D::FromPos (double fDistance) const
|
||||
Vector2d Line2d::FromPos (double fDistance) const
|
||||
{
|
||||
Vector2D clDir(clV2 - clV1);
|
||||
Vector2d clDir(clV2 - clV1);
|
||||
clDir.Normalize();
|
||||
return Vector2D(clV1.fX + (clDir.fX * fDistance), clV1.fY + (clDir.fY * fDistance));
|
||||
return Vector2d(clV1.x + (clDir.x * fDistance), clV1.y + (clDir.y * fDistance));
|
||||
}
|
||||
|
||||
bool Line2D::IntersectAndContain (const Line2D& rclLine, Vector2D &rclV) const
|
||||
bool Line2d::IntersectAndContain (const Line2d& rclLine, Vector2d &rclV) const
|
||||
{
|
||||
bool rc = Intersect (rclLine, rclV);
|
||||
if (rc)
|
||||
|
@ -263,18 +263,18 @@ bool Line2D::IntersectAndContain (const Line2D& rclLine, Vector2D &rclV) const
|
|||
}
|
||||
|
||||
/********************************************************/
|
||||
/** POLYGON2D ********************************************/
|
||||
/** POLYGON2d ********************************************/
|
||||
|
||||
BoundBox2D Polygon2D::CalcBoundBox (void) const
|
||||
BoundBox2d Polygon2d::CalcBoundBox (void) const
|
||||
{
|
||||
unsigned long i;
|
||||
BoundBox2D clBB;
|
||||
BoundBox2d clBB;
|
||||
for (i = 0; i < _aclVct.size(); i++)
|
||||
{
|
||||
clBB.fMinX = std::min<double> (clBB.fMinX, _aclVct[i].fX);
|
||||
clBB.fMinY = std::min<double> (clBB.fMinY, _aclVct[i].fY);
|
||||
clBB.fMaxX = std::max<double> (clBB.fMaxX, _aclVct[i].fX);
|
||||
clBB.fMaxY = std::max<double> (clBB.fMaxY, _aclVct[i].fY);
|
||||
clBB.MinX = std::min<double> (clBB.MinX, _aclVct[i].x);
|
||||
clBB.MinY = std::min<double> (clBB.MinY, _aclVct[i].y);
|
||||
clBB.MaxX = std::max<double> (clBB.MaxX, _aclVct[i].x);
|
||||
clBB.MaxY = std::max<double> (clBB.MaxY, _aclVct[i].y);
|
||||
}
|
||||
return clBB;
|
||||
}
|
||||
|
@ -314,7 +314,7 @@ static short _CalcTorsion (double *pfLine, double fX, double fY)
|
|||
return 0;
|
||||
}
|
||||
|
||||
bool Polygon2D::Contains (const Vector2D &rclV) const
|
||||
bool Polygon2d::Contains (const Vector2d &rclV) const
|
||||
{
|
||||
// Ermittelt mit dem Verfahren der Windungszahl, ob ein Punkt innerhalb
|
||||
// eines Polygonzugs enthalten ist.
|
||||
|
@ -333,29 +333,29 @@ bool Polygon2D::Contains (const Vector2D &rclV) const
|
|||
if (i == GetCtVectors() - 1)
|
||||
{
|
||||
// Polygon automatisch schliessen
|
||||
pfTmp[0] = _aclVct[i].fX;
|
||||
pfTmp[1] = _aclVct[i].fY;
|
||||
pfTmp[2] = _aclVct[0].fX;
|
||||
pfTmp[3] = _aclVct[0].fY;
|
||||
pfTmp[0] = _aclVct[i].x;
|
||||
pfTmp[1] = _aclVct[i].y;
|
||||
pfTmp[2] = _aclVct[0].x;
|
||||
pfTmp[3] = _aclVct[0].y;
|
||||
}
|
||||
else
|
||||
{
|
||||
// uebernehmen Punkt i und i+1
|
||||
pfTmp[0] = _aclVct[i].fX;
|
||||
pfTmp[1] = _aclVct[i].fY;
|
||||
pfTmp[2] = _aclVct[i + 1].fX;
|
||||
pfTmp[3] = _aclVct[i + 1].fY;
|
||||
pfTmp[0] = _aclVct[i].x;
|
||||
pfTmp[1] = _aclVct[i].y;
|
||||
pfTmp[2] = _aclVct[i + 1].x;
|
||||
pfTmp[3] = _aclVct[i + 1].y;
|
||||
}
|
||||
|
||||
// Schnitt-Test durchfuehren und Windungszaehler berechnen
|
||||
sTorsion += _CalcTorsion (pfTmp, rclV.fX, rclV.fY);
|
||||
sTorsion += _CalcTorsion (pfTmp, rclV.x, rclV.y);
|
||||
}
|
||||
|
||||
// Windungszaehler auswerten
|
||||
return sTorsion != 0;
|
||||
}
|
||||
|
||||
void Polygon2D::Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rclResultPolygonList) const
|
||||
void Polygon2d::Intersect (const Polygon2d &rclPolygon, std::list<Polygon2d> &rclResultPolygonList) const
|
||||
{
|
||||
// trimmen des uebergebenen Polygons mit dem aktuellen, Ergebnis ist eine Liste von Polygonen (Untermenge des uebergebenen Polygons)
|
||||
// das eigene (Trim-) Polygon ist geschlossen
|
||||
|
@ -366,7 +366,7 @@ void Polygon2D::Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rc
|
|||
// position of first points (in or out of polygon)
|
||||
bool bInner = Contains(rclPolygon[0]);
|
||||
|
||||
Polygon2D clResultPolygon;
|
||||
Polygon2d clResultPolygon;
|
||||
if (bInner == true) // add first point if inner trim-polygon
|
||||
clResultPolygon.Add(rclPolygon[0]);
|
||||
|
||||
|
@ -375,19 +375,19 @@ void Polygon2D::Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rc
|
|||
size_t ulTrimCt = GetCtVectors();
|
||||
for (size_t ulVec = 0; ulVec < (ulPolyCt-1); ulVec++)
|
||||
{
|
||||
Vector2D clPt0 = rclPolygon[ulVec];
|
||||
Vector2D clPt1 = rclPolygon[ulVec+1];
|
||||
Line2D clLine(clPt0, clPt1);
|
||||
Vector2d clPt0 = rclPolygon[ulVec];
|
||||
Vector2d clPt1 = rclPolygon[ulVec+1];
|
||||
Line2d clLine(clPt0, clPt1);
|
||||
|
||||
// try to intersect with each line of the trim-polygon
|
||||
std::set<double> afIntersections; // set of intersections (sorted by line parameter)
|
||||
Vector2D clTrimPt2; // second line point
|
||||
Vector2d clTrimPt2; // second line point
|
||||
for (size_t i = 0; i < ulTrimCt; i++)
|
||||
{
|
||||
clTrimPt2 = At((i + 1) % ulTrimCt);
|
||||
Line2D clToTrimLine(At(i), clTrimPt2);
|
||||
Line2d clToTrimLine(At(i), clTrimPt2);
|
||||
|
||||
Vector2D clV;
|
||||
Vector2d clV;
|
||||
if (clLine.IntersectAndContain(clToTrimLine, clV) == true)
|
||||
{
|
||||
// save line parameter of intersection point
|
||||
|
@ -401,7 +401,7 @@ void Polygon2D::Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rc
|
|||
for (std::set<double>::iterator pF = afIntersections.begin(); pF != afIntersections.end(); ++pF)
|
||||
{
|
||||
// intersection point
|
||||
Vector2D clPtIS = clLine.FromPos(*pF);
|
||||
Vector2d clPtIS = clLine.FromPos(*pF);
|
||||
if (bInner == true)
|
||||
{
|
||||
clResultPolygon.Add(clPtIS);
|
||||
|
@ -431,16 +431,16 @@ void Polygon2D::Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rc
|
|||
rclResultPolygonList.push_back(clResultPolygon);
|
||||
}
|
||||
|
||||
bool Polygon2D::Intersect (const Vector2D &rclV, double eps) const
|
||||
bool Polygon2d::Intersect (const Vector2d &rclV, double eps) const
|
||||
{
|
||||
if (_aclVct.size() < 2)
|
||||
return false;
|
||||
|
||||
size_t numPts = GetCtVectors();
|
||||
for (size_t i = 0; i < numPts; i++) {
|
||||
Vector2D clPt0 = (*this)[i];
|
||||
Vector2D clPt1 = (*this)[(i+1)%numPts];
|
||||
Line2D clLine(clPt0, clPt1);
|
||||
Vector2d clPt0 = (*this)[i];
|
||||
Vector2d clPt1 = (*this)[(i+1)%numPts];
|
||||
Line2d clLine(clPt0, clPt1);
|
||||
if (clLine.Intersect(rclV, eps))
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -35,247 +35,246 @@
|
|||
|
||||
namespace Base {
|
||||
|
||||
class Vector2D;
|
||||
class BoundBox2D;
|
||||
class Line2D;
|
||||
class Polygon2D;
|
||||
class Vector2d;
|
||||
class BoundBox2d;
|
||||
class Line2d;
|
||||
class Polygon2d;
|
||||
|
||||
/**
|
||||
* The vector class for 2D calculations.
|
||||
*/
|
||||
class BaseExport Vector2D
|
||||
class BaseExport Vector2d
|
||||
{
|
||||
public:
|
||||
double fX, fY;
|
||||
double x, y;
|
||||
|
||||
inline Vector2D (void);
|
||||
inline Vector2D (float x, float y);
|
||||
inline Vector2D (double x, double y);
|
||||
inline Vector2D (const Vector2D &rclVct);
|
||||
inline Vector2d (void);
|
||||
inline Vector2d (float x, float y);
|
||||
inline Vector2d (double x, double y);
|
||||
inline Vector2d (const Vector2d &rclVct);
|
||||
|
||||
// methods
|
||||
inline double Length (void) const;
|
||||
|
||||
// operators
|
||||
inline Vector2D& operator= (const Vector2D &rclVct);
|
||||
inline double operator* (const Vector2D &rclVct) const;
|
||||
inline bool operator== (const Vector2D &rclVct) const;
|
||||
inline Vector2D operator+ (const Vector2D &rclVct) const;
|
||||
inline Vector2D operator- (const Vector2D &rclVct) const;
|
||||
inline Vector2D operator/ (double c) const;
|
||||
inline Vector2d& operator= (const Vector2d &rclVct);
|
||||
inline double operator* (const Vector2d &rclVct) const;
|
||||
inline bool operator== (const Vector2d &rclVct) const;
|
||||
inline Vector2d operator+ (const Vector2d &rclVct) const;
|
||||
inline Vector2d operator- (const Vector2d &rclVct) const;
|
||||
inline Vector2d operator/ (double c) const;
|
||||
|
||||
inline void Set (double fPX, double fPY);
|
||||
inline void Scale (double fS);
|
||||
inline void Normalize (void);
|
||||
double GetAngle (const Vector2D &rclVect) const;
|
||||
void ProjectToLine (const Vector2D &rclPt, const Vector2D &rclLine);
|
||||
double GetAngle (const Vector2d &rclVect) const;
|
||||
void ProjectToLine (const Vector2d &rclPt, const Vector2d &rclLine);
|
||||
};
|
||||
|
||||
/** BoundBox2D ********************************************/
|
||||
/** BoundBox2d ********************************************/
|
||||
|
||||
/**
|
||||
* Two dimensional bounding box.
|
||||
*/
|
||||
class BaseExport BoundBox2D
|
||||
class BaseExport BoundBox2d
|
||||
{
|
||||
public:
|
||||
double fMinX, fMinY, fMaxX, fMaxY;
|
||||
double MinX, MinY, MaxX, MaxY;
|
||||
|
||||
inline BoundBox2D (void);
|
||||
inline BoundBox2D (const BoundBox2D &rclBB);
|
||||
inline BoundBox2D (double fX1, double fY1, double fX2, double fY2);
|
||||
inline BoundBox2d (void);
|
||||
inline BoundBox2d (const BoundBox2d &rclBB);
|
||||
inline BoundBox2d (double fX1, double fY1, double fX2, double fY2);
|
||||
inline bool IsValid (void);
|
||||
|
||||
// operators
|
||||
inline BoundBox2D& operator= (const BoundBox2D& rclBB);
|
||||
inline bool operator== (const BoundBox2D& rclBB) const;
|
||||
bool Intersect(const Line2D &rclLine) const;
|
||||
bool Intersect(const BoundBox2D &rclBB) const;
|
||||
bool Intersect(const Polygon2D &rclPoly) const;
|
||||
inline void Add(const Vector2D &rclVct);
|
||||
inline BoundBox2d& operator= (const BoundBox2d& rclBB);
|
||||
inline bool operator== (const BoundBox2d& rclBB) const;
|
||||
bool Intersect(const Line2d &rclLine) const;
|
||||
bool Intersect(const BoundBox2d &rclBB) const;
|
||||
bool Intersect(const Polygon2d &rclPoly) const;
|
||||
inline void Add(const Vector2d &rclVct);
|
||||
|
||||
void SetVoid (void) { fMinX = fMinY = DOUBLE_MAX; fMaxX = fMaxY = -DOUBLE_MAX; }
|
||||
void SetVoid (void) { MinX = MinY = DOUBLE_MAX; MaxX = MaxY = -DOUBLE_MAX; }
|
||||
|
||||
// misc
|
||||
bool Contains (const Vector2D &rclV) const;
|
||||
bool Contains (const Vector2d &rclV) const;
|
||||
};
|
||||
|
||||
/** Line2D ********************************************/
|
||||
/** Line2d ********************************************/
|
||||
|
||||
/**
|
||||
* 2D line class.
|
||||
*/
|
||||
class BaseExport Line2D
|
||||
class BaseExport Line2d
|
||||
{
|
||||
public:
|
||||
Vector2D clV1, clV2;
|
||||
Vector2d clV1, clV2;
|
||||
|
||||
Line2D (void) {}
|
||||
inline Line2D (const Line2D &rclLine);
|
||||
inline Line2D (const Vector2D &rclV1, const Vector2D &rclV2);
|
||||
Line2d (void) {}
|
||||
inline Line2d (const Line2d &rclLine);
|
||||
inline Line2d (const Vector2d &rclV1, const Vector2d &rclV2);
|
||||
|
||||
// methods
|
||||
inline double Length (void) const;
|
||||
BoundBox2D CalcBoundBox (void) const;
|
||||
BoundBox2d CalcBoundBox (void) const;
|
||||
|
||||
// operators
|
||||
inline Line2D& operator= (const Line2D& rclLine);
|
||||
inline bool operator== (const Line2D& rclLine) const;
|
||||
inline Line2d& operator= (const Line2d& rclLine);
|
||||
inline bool operator== (const Line2d& rclLine) const;
|
||||
|
||||
// misc
|
||||
inline bool Contains (const Vector2D &rclV) const;
|
||||
bool Intersect (const Line2D& rclLine, Vector2D &rclV) const;
|
||||
bool Intersect (const Vector2D &rclV, double eps) const;
|
||||
bool IntersectAndContain (const Line2D& rclLine, Vector2D &rclV) const;
|
||||
Vector2D FromPos (double fDistance) const;
|
||||
inline bool Contains (const Vector2d &rclV) const;
|
||||
bool Intersect (const Line2d& rclLine, Vector2d &rclV) const;
|
||||
bool Intersect (const Vector2d &rclV, double eps) const;
|
||||
bool IntersectAndContain (const Line2d& rclLine, Vector2d &rclV) const;
|
||||
Vector2d FromPos (double fDistance) const;
|
||||
};
|
||||
|
||||
/** Polygon2D ********************************************/
|
||||
/** Polygon2d ********************************************/
|
||||
|
||||
/**
|
||||
* 2D polygon class.
|
||||
*/
|
||||
class BaseExport Polygon2D
|
||||
class BaseExport Polygon2d
|
||||
{
|
||||
public:
|
||||
Polygon2D (void) {}
|
||||
inline Polygon2D (const Polygon2D &rclPoly);
|
||||
virtual ~Polygon2D () {}
|
||||
Polygon2d (void) {}
|
||||
inline Polygon2d (const Polygon2d &rclPoly);
|
||||
virtual ~Polygon2d () {}
|
||||
|
||||
inline Polygon2D& operator = (const Polygon2D &rclP);
|
||||
inline Polygon2d& operator = (const Polygon2d &rclP);
|
||||
|
||||
// admin-interface
|
||||
inline size_t GetCtVectors (void) const;
|
||||
inline bool Add (const Vector2D &rclVct);
|
||||
inline Vector2D& operator[] (size_t ulNdx) const;
|
||||
inline Vector2D& At (size_t ulNdx) const;
|
||||
inline bool Add (const Vector2d &rclVct);
|
||||
inline Vector2d& operator[] (size_t ulNdx) const;
|
||||
inline Vector2d& At (size_t ulNdx) const;
|
||||
inline bool Delete (size_t ulNdx);
|
||||
inline void DeleteAll (void);
|
||||
|
||||
// misc
|
||||
BoundBox2D CalcBoundBox (void) const;
|
||||
bool Contains (const Vector2D &rclV) const;
|
||||
void Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rclResultPolygonList) const;
|
||||
bool Intersect (const Vector2D &rclV, double eps) const;
|
||||
BoundBox2d CalcBoundBox (void) const;
|
||||
bool Contains (const Vector2d &rclV) const;
|
||||
void Intersect (const Polygon2d &rclPolygon, std::list<Polygon2d> &rclResultPolygonList) const;
|
||||
bool Intersect (const Vector2d &rclV, double eps) const;
|
||||
|
||||
private:
|
||||
std::vector<Vector2D> _aclVct;
|
||||
std::vector<Vector2d> _aclVct;
|
||||
};
|
||||
|
||||
/** INLINES ********************************************/
|
||||
|
||||
inline Vector2D::Vector2D (void)
|
||||
: fX(0.0), fY(0.0)
|
||||
inline Vector2d::Vector2d (void)
|
||||
: x(0.0), y(0.0)
|
||||
{
|
||||
}
|
||||
|
||||
inline Vector2D::Vector2D (float x, float y)
|
||||
: fX (x), fY (y)
|
||||
inline Vector2d::Vector2d (float x, float y)
|
||||
: x(x), y(y)
|
||||
{
|
||||
}
|
||||
|
||||
inline Vector2D::Vector2D (double x, double y)
|
||||
: fX(x),
|
||||
fY(y)
|
||||
inline Vector2d::Vector2d (double x, double y)
|
||||
: x(x), y(y)
|
||||
{
|
||||
}
|
||||
|
||||
inline Vector2D::Vector2D (const Vector2D &rclVct)
|
||||
: fX(rclVct.fX), fY(rclVct.fY)
|
||||
inline Vector2d::Vector2d (const Vector2d &rclVct)
|
||||
: x(rclVct.x), y(rclVct.y)
|
||||
{
|
||||
}
|
||||
|
||||
inline double Vector2D::Length (void) const
|
||||
inline double Vector2d::Length (void) const
|
||||
{
|
||||
return sqrt ((fX * fX) + (fY * fY));
|
||||
return sqrt ((x * x) + (y * y));
|
||||
}
|
||||
|
||||
inline Vector2D& Vector2D::operator= (const Vector2D &rclVct)
|
||||
inline Vector2d& Vector2d::operator= (const Vector2d &rclVct)
|
||||
{
|
||||
fX = rclVct.fX;
|
||||
fY = rclVct.fY;
|
||||
x = rclVct.x;
|
||||
y = rclVct.y;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool Vector2D::operator== (const Vector2D &rclVct) const
|
||||
inline bool Vector2d::operator== (const Vector2d &rclVct) const
|
||||
{
|
||||
return (fX == rclVct.fX) && (fY == rclVct.fY);
|
||||
return (x == rclVct.x) && (y == rclVct.y);
|
||||
}
|
||||
|
||||
inline Vector2D Vector2D::operator+ (const Vector2D &rclVct) const
|
||||
inline Vector2d Vector2d::operator+ (const Vector2d &rclVct) const
|
||||
{
|
||||
return Vector2D(fX + rclVct.fX, fY + rclVct.fY);
|
||||
return Vector2d(x + rclVct.x, y + rclVct.y);
|
||||
}
|
||||
|
||||
inline Vector2D Vector2D::operator- (const Vector2D &rclVct) const
|
||||
inline Vector2d Vector2d::operator- (const Vector2d &rclVct) const
|
||||
{
|
||||
return Vector2D(fX - rclVct.fX, fY - rclVct.fY);
|
||||
return Vector2d(x - rclVct.x, y - rclVct.y);
|
||||
}
|
||||
|
||||
inline double Vector2D::operator* (const Vector2D &rclVct) const
|
||||
inline double Vector2d::operator* (const Vector2d &rclVct) const
|
||||
{
|
||||
return (fX * rclVct.fX) + (fY * rclVct.fY);
|
||||
return (x * rclVct.x) + (y * rclVct.y);
|
||||
}
|
||||
|
||||
inline Vector2D Vector2D::operator/ (double c) const
|
||||
inline Vector2d Vector2d::operator/ (double c) const
|
||||
{
|
||||
return Vector2D(fX / c, fY / c);
|
||||
return Vector2d(x / c, y / c);
|
||||
}
|
||||
|
||||
inline void Vector2D::Scale (double fS)
|
||||
inline void Vector2d::Scale (double fS)
|
||||
{
|
||||
fX *= fS;
|
||||
fY *= fS;
|
||||
x *= fS;
|
||||
y *= fS;
|
||||
}
|
||||
|
||||
inline void Vector2D::Normalize (void)
|
||||
inline void Vector2d::Normalize (void)
|
||||
{
|
||||
double fLen = Length();
|
||||
if (fLen != 0.0f)
|
||||
{
|
||||
fX /= fLen;
|
||||
fY /= fLen;
|
||||
x /= fLen;
|
||||
y /= fLen;
|
||||
}
|
||||
}
|
||||
|
||||
inline void Vector2D::Set (double fPX, double fPY)
|
||||
inline void Vector2d::Set (double fPX, double fPY)
|
||||
{
|
||||
fX = fPX;
|
||||
fY = fPY;
|
||||
x = fPX;
|
||||
y = fPY;
|
||||
}
|
||||
|
||||
inline Polygon2D::Polygon2D (const Polygon2D &rclPoly)
|
||||
inline Polygon2d::Polygon2d (const Polygon2d &rclPoly)
|
||||
{
|
||||
*this = rclPoly;
|
||||
}
|
||||
|
||||
inline Polygon2D& Polygon2D::operator = (const Polygon2D &rclP)
|
||||
inline Polygon2d& Polygon2d::operator = (const Polygon2d &rclP)
|
||||
{
|
||||
_aclVct = rclP._aclVct;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline void Polygon2D::DeleteAll (void)
|
||||
inline void Polygon2d::DeleteAll (void)
|
||||
{
|
||||
_aclVct.clear();
|
||||
}
|
||||
|
||||
inline size_t Polygon2D::GetCtVectors (void) const
|
||||
inline size_t Polygon2d::GetCtVectors (void) const
|
||||
{
|
||||
return _aclVct.size ();
|
||||
}
|
||||
|
||||
inline bool Polygon2D::Add (const Vector2D &rclVct)
|
||||
inline bool Polygon2d::Add (const Vector2d &rclVct)
|
||||
{
|
||||
_aclVct.push_back (rclVct);
|
||||
return true;
|
||||
}
|
||||
|
||||
inline bool Polygon2D::Delete (size_t ulNdx)
|
||||
inline bool Polygon2d::Delete (size_t ulNdx)
|
||||
{
|
||||
if ( ulNdx < _aclVct.size() )
|
||||
{
|
||||
std::vector<Vector2D>::iterator it = _aclVct.begin() + ulNdx;
|
||||
std::vector<Vector2d>::iterator it = _aclVct.begin() + ulNdx;
|
||||
_aclVct.erase ( it );
|
||||
return true;
|
||||
}
|
||||
|
@ -283,101 +282,101 @@ inline bool Polygon2D::Delete (size_t ulNdx)
|
|||
return false;
|
||||
}
|
||||
|
||||
inline Vector2D& Polygon2D::operator[] (size_t ulNdx) const
|
||||
inline Vector2d& Polygon2d::operator[] (size_t ulNdx) const
|
||||
{
|
||||
return (Vector2D&) _aclVct[ulNdx];
|
||||
return (Vector2d&) _aclVct[ulNdx];
|
||||
}
|
||||
|
||||
inline Vector2D& Polygon2D::At (size_t ulNdx) const
|
||||
inline Vector2d& Polygon2d::At (size_t ulNdx) const
|
||||
{
|
||||
return (Vector2D&) _aclVct[ulNdx];
|
||||
return (Vector2d&) _aclVct[ulNdx];
|
||||
}
|
||||
|
||||
|
||||
inline Line2D::Line2D (const Line2D &rclLine)
|
||||
inline Line2d::Line2d (const Line2d &rclLine)
|
||||
: clV1 (rclLine.clV1),
|
||||
clV2 (rclLine.clV2)
|
||||
{
|
||||
}
|
||||
|
||||
inline Line2D::Line2D (const Vector2D &rclV1, const Vector2D &rclV2)
|
||||
inline Line2d::Line2d (const Vector2d &rclV1, const Vector2d &rclV2)
|
||||
: clV1 (rclV1), clV2 (rclV2)
|
||||
{
|
||||
}
|
||||
|
||||
inline double Line2D::Length (void) const
|
||||
inline double Line2d::Length (void) const
|
||||
{
|
||||
return (clV2 - clV1).Length ();
|
||||
}
|
||||
|
||||
inline Line2D& Line2D::operator= (const Line2D& rclLine)
|
||||
inline Line2d& Line2d::operator= (const Line2d& rclLine)
|
||||
{
|
||||
clV1 = rclLine.clV1;
|
||||
clV2 = rclLine.clV2;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool Line2D::operator== (const Line2D& rclLine) const
|
||||
inline bool Line2d::operator== (const Line2d& rclLine) const
|
||||
{
|
||||
return (clV1 == rclLine.clV1) && (clV2 == rclLine.clV2);
|
||||
}
|
||||
|
||||
inline bool Line2D::Contains (const Vector2D &rclV) const
|
||||
inline bool Line2d::Contains (const Vector2d &rclV) const
|
||||
{
|
||||
return CalcBoundBox ().Contains (rclV);
|
||||
}
|
||||
|
||||
inline BoundBox2D::BoundBox2D (void)
|
||||
inline BoundBox2d::BoundBox2d (void)
|
||||
{
|
||||
fMinX = fMinY = DOUBLE_MAX;
|
||||
fMaxX = fMaxY = - DOUBLE_MAX;
|
||||
MinX = MinY = DOUBLE_MAX;
|
||||
MaxX = MaxY = - DOUBLE_MAX;
|
||||
}
|
||||
|
||||
inline BoundBox2D::BoundBox2D (const BoundBox2D &rclBB)
|
||||
: fMinX (rclBB.fMinX),
|
||||
fMinY (rclBB.fMinY),
|
||||
fMaxX (rclBB.fMaxX),
|
||||
fMaxY (rclBB.fMaxY)
|
||||
inline BoundBox2d::BoundBox2d (const BoundBox2d &rclBB)
|
||||
: MinX (rclBB.MinX),
|
||||
MinY (rclBB.MinY),
|
||||
MaxX (rclBB.MaxX),
|
||||
MaxY (rclBB.MaxY)
|
||||
{
|
||||
}
|
||||
|
||||
inline BoundBox2D::BoundBox2D (double fX1, double fY1, double fX2, double fY2)
|
||||
inline BoundBox2d::BoundBox2d (double fX1, double fY1, double fX2, double fY2)
|
||||
{
|
||||
fMinX = std::min<double>( fX1, fX2 );
|
||||
fMaxX = std::max<double>( fX1, fX2 );
|
||||
fMinY = std::min<double>( fY1, fY2 );
|
||||
fMaxY = std::max<double>( fY1, fY2 );
|
||||
MinX = std::min<double>( fX1, fX2 );
|
||||
MaxX = std::max<double>( fX1, fX2 );
|
||||
MinY = std::min<double>( fY1, fY2 );
|
||||
MaxY = std::max<double>( fY1, fY2 );
|
||||
}
|
||||
|
||||
inline bool BoundBox2D::IsValid (void)
|
||||
inline bool BoundBox2d::IsValid (void)
|
||||
{
|
||||
return (fMaxX >= fMinX) && (fMaxY >= fMinY);
|
||||
return (MaxX >= MinX) && (MaxY >= MinY);
|
||||
}
|
||||
|
||||
inline BoundBox2D& BoundBox2D::operator= (const BoundBox2D& rclBB)
|
||||
inline BoundBox2d& BoundBox2d::operator= (const BoundBox2d& rclBB)
|
||||
{
|
||||
fMinX = rclBB.fMinX;
|
||||
fMinY = rclBB.fMinY;
|
||||
fMaxX = rclBB.fMaxX;
|
||||
fMaxY = rclBB.fMaxY;
|
||||
MinX = rclBB.MinX;
|
||||
MinY = rclBB.MinY;
|
||||
MaxX = rclBB.MaxX;
|
||||
MaxY = rclBB.MaxY;
|
||||
return *this;
|
||||
}
|
||||
|
||||
inline bool BoundBox2D::operator== (const BoundBox2D& rclBB) const
|
||||
inline bool BoundBox2d::operator== (const BoundBox2d& rclBB) const
|
||||
{
|
||||
return
|
||||
(fMinX == rclBB.fMinX) &&
|
||||
(fMinY == rclBB.fMinY) &&
|
||||
(fMaxX == rclBB.fMaxX) &&
|
||||
(fMaxY == rclBB.fMaxY);
|
||||
(MinX == rclBB.MinX) &&
|
||||
(MinY == rclBB.MinY) &&
|
||||
(MaxX == rclBB.MaxX) &&
|
||||
(MaxY == rclBB.MaxY);
|
||||
}
|
||||
|
||||
inline void BoundBox2D::Add(const Vector2D &rclVct)
|
||||
inline void BoundBox2d::Add(const Vector2d &rclVct)
|
||||
{
|
||||
fMinX = std::min<double>(fMinX, rclVct.fX);
|
||||
fMinY = std::min<double>(fMinY, rclVct.fY);
|
||||
fMaxX = std::max<double>(fMaxX, rclVct.fX);
|
||||
fMaxY = std::max<double>(fMaxY, rclVct.fY);
|
||||
MinX = std::min<double>(MinX, rclVct.x);
|
||||
MinY = std::min<double>(MinY, rclVct.y);
|
||||
MaxX = std::max<double>(MaxX, rclVct.x);
|
||||
MaxY = std::max<double>(MaxY, rclVct.y);
|
||||
}
|
||||
|
||||
} // namespace Base
|
||||
|
|
|
@ -2272,14 +2272,14 @@ static void selectionCallback(void * ud, SoEventCallback * cb)
|
|||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
Base::Polygon2D polygon;
|
||||
Base::Polygon2d polygon;
|
||||
if (picked.size() == 2) {
|
||||
SbVec2f pt1 = picked[0];
|
||||
SbVec2f pt2 = picked[1];
|
||||
polygon.Add(Base::Vector2D(pt1[0], pt1[1]));
|
||||
polygon.Add(Base::Vector2D(pt1[0], pt2[1]));
|
||||
polygon.Add(Base::Vector2D(pt2[0], pt2[1]));
|
||||
polygon.Add(Base::Vector2D(pt2[0], pt1[1]));
|
||||
polygon.Add(Base::Vector2d(pt1[0], pt1[1]));
|
||||
polygon.Add(Base::Vector2d(pt1[0], pt2[1]));
|
||||
polygon.Add(Base::Vector2d(pt2[0], pt2[1]));
|
||||
polygon.Add(Base::Vector2d(pt2[0], pt1[1]));
|
||||
|
||||
// when selecting from right to left then select by intersection
|
||||
// oterwise if the center is inside the rectangle
|
||||
|
@ -2288,7 +2288,7 @@ static void selectionCallback(void * ud, SoEventCallback * cb)
|
|||
}
|
||||
else {
|
||||
for (std::vector<SbVec2f>::const_iterator it = picked.begin(); it != picked.end(); ++it)
|
||||
polygon.Add(Base::Vector2D((*it)[0],(*it)[1]));
|
||||
polygon.Add(Base::Vector2d((*it)[0],(*it)[1]));
|
||||
}
|
||||
|
||||
App::Document* doc = App::GetApplication().getActiveDocument();
|
||||
|
@ -2315,12 +2315,12 @@ static void selectionCallback(void * ud, SoEventCallback * cb)
|
|||
if (selectionMode == CENTER) {
|
||||
Base::Vector3d pt2d;
|
||||
pt2d = proj(bbox.GetCenter());
|
||||
if (polygon.Contains(Base::Vector2D(pt2d.x, pt2d.y))) {
|
||||
if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) {
|
||||
Gui::Selection().addSelection(doc->getName(), (*it)->getNameInDocument());
|
||||
}
|
||||
}
|
||||
else {
|
||||
Base::BoundBox2D bbox2 = bbox.ProjectBox(&proj);
|
||||
Base::BoundBox2d bbox2 = bbox.ProjectBox(&proj);
|
||||
if (bbox2.Intersect(polygon)) {
|
||||
Gui::Selection().addSelection(doc->getName(), (*it)->getNameInDocument());
|
||||
}
|
||||
|
|
|
@ -906,9 +906,9 @@ void DefineNodesCallback(void * ud, SoEventCallback * n)
|
|||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
Base::Polygon2D polygon;
|
||||
Base::Polygon2d polygon;
|
||||
for (std::vector<SbVec2f>::const_iterator it = clPoly.begin(); it != clPoly.end(); ++it)
|
||||
polygon.Add(Base::Vector2D((*it)[0],(*it)[1]));
|
||||
polygon.Add(Base::Vector2d((*it)[0],(*it)[1]));
|
||||
|
||||
|
||||
std::vector<App::DocumentObject*> docObj = Gui::Selection().getObjectsOfType(Fem::FemMeshObject::getClassTypeId());
|
||||
|
@ -925,7 +925,7 @@ void DefineNodesCallback(void * ud, SoEventCallback * n)
|
|||
const SMDS_MeshNode* aNode = aNodeIter->next();
|
||||
Base::Vector3f vec(aNode->X(),aNode->Y(),aNode->Z());
|
||||
pt2d = proj(vec);
|
||||
if (polygon.Contains(Base::Vector2D(pt2d.x, pt2d.y)) == true)
|
||||
if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y)) == true)
|
||||
IntSet.insert(aNode->GetID());
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class Ui_TaskAnalysisInfo;
|
|||
class SoEventCallback;
|
||||
|
||||
namespace Base {
|
||||
class Polygon2D;
|
||||
class Polygon2d;
|
||||
}
|
||||
namespace App {
|
||||
class Property;
|
||||
|
|
|
@ -151,15 +151,15 @@ void TaskCreateNodeSet::DefineNodesCallback(void * ud, SoEventCallback * n)
|
|||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
Base::Polygon2D polygon;
|
||||
Base::Polygon2d polygon;
|
||||
for (std::vector<SbVec2f>::const_iterator it = clPoly.begin(); it != clPoly.end(); ++it)
|
||||
polygon.Add(Base::Vector2D((*it)[0],(*it)[1]));
|
||||
polygon.Add(Base::Vector2d((*it)[0],(*it)[1]));
|
||||
|
||||
taskBox->DefineNodes(polygon,proj,clip_inner);
|
||||
|
||||
}
|
||||
|
||||
void TaskCreateNodeSet::DefineNodes(const Base::Polygon2D &polygon,const Gui::ViewVolumeProjection &proj,bool inner)
|
||||
void TaskCreateNodeSet::DefineNodes(const Base::Polygon2d &polygon,const Gui::ViewVolumeProjection &proj,bool inner)
|
||||
{
|
||||
const SMESHDS_Mesh* data = const_cast<SMESH_Mesh*>(pcObject->FemMesh.getValue<Fem::FemMeshObject*>()->FemMesh.getValue().getSMesh())->GetMeshDS();
|
||||
|
||||
|
@ -173,7 +173,7 @@ void TaskCreateNodeSet::DefineNodes(const Base::Polygon2D &polygon,const Gui::Vi
|
|||
const SMDS_MeshNode* aNode = aNodeIter->next();
|
||||
Base::Vector3f vec(aNode->X(),aNode->Y(),aNode->Z());
|
||||
pt2d = proj(vec);
|
||||
if (polygon.Contains(Base::Vector2D(pt2d.x, pt2d.y)) == inner)
|
||||
if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y)) == inner)
|
||||
tempSet.insert(aNode->GetID());
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ class Ui_TaskCreateNodeSet;
|
|||
class SoEventCallback;
|
||||
|
||||
namespace Base {
|
||||
class Polygon2D;
|
||||
class Polygon2d;
|
||||
}
|
||||
namespace App {
|
||||
class Property;
|
||||
|
@ -69,7 +69,7 @@ private Q_SLOTS:
|
|||
protected:
|
||||
Fem::FemSetNodesObject *pcObject;
|
||||
static void DefineNodesCallback(void * ud, SoEventCallback * n);
|
||||
void DefineNodes(const Base::Polygon2D &polygon,const Gui::ViewVolumeProjection &proj,bool);
|
||||
void DefineNodes(const Base::Polygon2d &polygon,const Gui::ViewVolumeProjection &proj,bool);
|
||||
|
||||
protected:
|
||||
virtual void onSelectionChanged(const Gui::SelectionChanges& msg);
|
||||
|
|
|
@ -34,7 +34,7 @@ class Ui_TaskDriver;
|
|||
class SoEventCallback;
|
||||
|
||||
namespace Base {
|
||||
class Polygon2D;
|
||||
class Polygon2d;
|
||||
}
|
||||
namespace App {
|
||||
class Property;
|
||||
|
|
|
@ -31,7 +31,7 @@ class Ui_TaskTetParameter;
|
|||
class SoEventCallback;
|
||||
|
||||
namespace Base {
|
||||
class Polygon2D;
|
||||
class Polygon2d;
|
||||
}
|
||||
namespace App {
|
||||
class Property;
|
||||
|
|
|
@ -39,8 +39,8 @@
|
|||
|
||||
using namespace MeshCore;
|
||||
using Base::BoundBox3f;
|
||||
using Base::BoundBox2D;
|
||||
using Base::Polygon2D;
|
||||
using Base::BoundBox2d;
|
||||
using Base::Polygon2d;
|
||||
|
||||
|
||||
bool MeshAlgorithm::IsVertexVisible (const Base::Vector3f &rcVertex, const Base::Vector3f &rcView, const MeshFacetGrid &rclGrid) const
|
||||
|
@ -1075,7 +1075,7 @@ int MeshAlgorithm::Surround(const Base::BoundBox3f& rBox, const Base::Vector3f&
|
|||
return -1;
|
||||
}
|
||||
|
||||
void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclProj, const Base::Polygon2D& rclPoly,
|
||||
void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly,
|
||||
bool bInner, std::vector<unsigned long> &raulFacets) const
|
||||
{
|
||||
std::vector<unsigned long>::iterator it;
|
||||
|
@ -1088,7 +1088,7 @@ void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewPr
|
|||
if (bInner)
|
||||
{
|
||||
BoundBox3f clBBox3d;
|
||||
BoundBox2D clViewBBox, clPolyBBox;
|
||||
BoundBox2d clViewBBox, clPolyBBox;
|
||||
std::vector<unsigned long> aulAllElements;
|
||||
|
||||
//B-Box des Polygons
|
||||
|
@ -1121,7 +1121,7 @@ void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewPr
|
|||
{
|
||||
clPt2d = pclProj->operator()(rclFacet._aclPoints[j]);
|
||||
clGravityOfFacet += clPt2d;
|
||||
if (rclPoly.Contains(Base::Vector2D(clPt2d.x, clPt2d.y)) == bInner)
|
||||
if (rclPoly.Contains(Base::Vector2d(clPt2d.x, clPt2d.y)) == bInner)
|
||||
{
|
||||
raulFacets.push_back(*it);
|
||||
bNoPointInside = false;
|
||||
|
@ -1134,7 +1134,7 @@ void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewPr
|
|||
{
|
||||
clGravityOfFacet *= 1.0f/3.0f;
|
||||
|
||||
if (rclPoly.Contains(Base::Vector2D(clGravityOfFacet.x, clGravityOfFacet.y)) == bInner)
|
||||
if (rclPoly.Contains(Base::Vector2d(clGravityOfFacet.x, clGravityOfFacet.y)) == bInner)
|
||||
raulFacets.push_back(*it);
|
||||
}
|
||||
|
||||
|
@ -1150,7 +1150,7 @@ void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewPr
|
|||
for (int j=0; j<3; j++)
|
||||
{
|
||||
clPt2d = pclProj->operator()(clIter->_aclPoints[j]);
|
||||
if (rclPoly.Contains(Base::Vector2D(clPt2d.x, clPt2d.y)) == bInner)
|
||||
if (rclPoly.Contains(Base::Vector2d(clPt2d.x, clPt2d.y)) == bInner)
|
||||
{
|
||||
raulFacets.push_back(clIter.Position());
|
||||
break;
|
||||
|
@ -1161,7 +1161,7 @@ void MeshAlgorithm::CheckFacets(const MeshFacetGrid& rclGrid, const Base::ViewPr
|
|||
}
|
||||
}
|
||||
|
||||
void MeshAlgorithm::CheckFacets(const Base::ViewProjMethod* pclProj, const Base::Polygon2D& rclPoly,
|
||||
void MeshAlgorithm::CheckFacets(const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly,
|
||||
bool bInner, std::vector<unsigned long> &raulFacets) const
|
||||
{
|
||||
const MeshPointArray& p = _rclMesh.GetPoints();
|
||||
|
@ -1171,7 +1171,7 @@ void MeshAlgorithm::CheckFacets(const Base::ViewProjMethod* pclProj, const Base:
|
|||
for (MeshFacetArray::_TConstIterator it = f.begin(); it != f.end(); ++it,++index) {
|
||||
for (int i = 0; i < 3; i++) {
|
||||
pt2d = (*pclProj)(p[it->_aulPoints[i]]);
|
||||
if (rclPoly.Contains(Base::Vector2D(pt2d.x, pt2d.y)) == bInner) {
|
||||
if (rclPoly.Contains(Base::Vector2d(pt2d.x, pt2d.y)) == bInner) {
|
||||
raulFacets.push_back(index);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
|
||||
namespace Base{
|
||||
class ViewProjMethod;
|
||||
class Polygon2D;
|
||||
class Polygon2d;
|
||||
}
|
||||
|
||||
namespace MeshCore {
|
||||
|
@ -225,12 +225,12 @@ public:
|
|||
* bInner is \a false then all facets with at least one corner outside the polygon get deleted.
|
||||
* This algorithm is optimized by using a grid.
|
||||
*/
|
||||
void CheckFacets (const MeshFacetGrid &rclGrid, const Base::ViewProjMethod* pclProj, const Base::Polygon2D& rclPoly,
|
||||
void CheckFacets (const MeshFacetGrid &rclGrid, const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly,
|
||||
bool bInner, std::vector<unsigned long> &rclRes) const;
|
||||
/**
|
||||
* Does the same as the above method unless that it doesn't use a grid.
|
||||
*/
|
||||
void CheckFacets (const Base::ViewProjMethod* pclProj, const Base::Polygon2D& rclPoly,
|
||||
void CheckFacets (const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly,
|
||||
bool bInner, std::vector<unsigned long> &rclRes) const;
|
||||
/**
|
||||
* Determines all facets of the given array \a raclFacetIndices that lie at the edge or that
|
||||
|
|
|
@ -698,7 +698,7 @@ void MeshKernel::RemoveInvalids ()
|
|||
}
|
||||
|
||||
void MeshKernel::CutFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclProj,
|
||||
const Base::Polygon2D& rclPoly, bool bCutInner, std::vector<MeshGeomFacet> &raclFacets)
|
||||
const Base::Polygon2d& rclPoly, bool bCutInner, std::vector<MeshGeomFacet> &raclFacets)
|
||||
{
|
||||
std::vector<unsigned long> aulFacets;
|
||||
|
||||
|
@ -711,7 +711,7 @@ void MeshKernel::CutFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMet
|
|||
}
|
||||
|
||||
void MeshKernel::CutFacets(const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclProj,
|
||||
const Base::Polygon2D& rclPoly, bool bInner, std::vector<unsigned long> &raclCutted)
|
||||
const Base::Polygon2d& rclPoly, bool bInner, std::vector<unsigned long> &raclCutted)
|
||||
{
|
||||
MeshAlgorithm(*this).CheckFacets(rclGrid, pclProj, rclPoly, bInner, raclCutted);
|
||||
DeleteFacets(raclCutted);
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#include <Base/Matrix.h>
|
||||
|
||||
namespace Base{
|
||||
class Polygon2D;
|
||||
class Polygon2d;
|
||||
class ViewProjMethod;
|
||||
}
|
||||
|
||||
|
@ -408,13 +408,13 @@ public:
|
|||
* The facets to be deleted are returned with their geometric reprsentation.
|
||||
* @see CheckFacets().
|
||||
*/
|
||||
void CutFacets (const MeshFacetGrid& rclGrid, const Base::ViewProjMethod *pclP, const Base::Polygon2D& rclPoly,
|
||||
void CutFacets (const MeshFacetGrid& rclGrid, const Base::ViewProjMethod *pclP, const Base::Polygon2d& rclPoly,
|
||||
bool bCutInner, std::vector<MeshGeomFacet> &raclFacets);
|
||||
/**
|
||||
* Does basically the same as method above unless that the facets to be deleted are returned with their
|
||||
* index number in the facet array of the mesh structure.
|
||||
*/
|
||||
void CutFacets (const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclP, const Base::Polygon2D& rclPoly,
|
||||
void CutFacets (const MeshFacetGrid& rclGrid, const Base::ViewProjMethod* pclP, const Base::Polygon2d& rclPoly,
|
||||
bool bCutInner, std::vector<unsigned long> &raclCutted);
|
||||
//@}
|
||||
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
using namespace MeshCore;
|
||||
|
||||
MeshTrimming::MeshTrimming(MeshKernel &rclM, const Base::ViewProjMethod* pclProj,
|
||||
const Base::Polygon2D& rclPoly)
|
||||
const Base::Polygon2d& rclPoly)
|
||||
: myMesh(rclM), myInner(true), myProj(pclProj), myPoly(rclPoly)
|
||||
{
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ void MeshTrimming::CheckFacets(const MeshFacetGrid& rclGrid, std::vector<unsigne
|
|||
// cut inner: use grid to accelerate search
|
||||
if (myInner) {
|
||||
Base::BoundBox3f clBBox3d;
|
||||
Base::BoundBox2D clViewBBox, clPolyBBox;
|
||||
Base::BoundBox2d clViewBBox, clPolyBBox;
|
||||
std::vector<unsigned long> aulAllElements;
|
||||
|
||||
// BBox of polygon
|
||||
|
@ -105,16 +105,16 @@ bool MeshTrimming::HasIntersection(const MeshGeomFacet& rclFacet) const
|
|||
{
|
||||
int i;
|
||||
unsigned long j;
|
||||
Base::Polygon2D clPoly;
|
||||
Base::Line2D clFacLine, clPolyLine;
|
||||
Base::Vector2D S;
|
||||
Base::Polygon2d clPoly;
|
||||
Base::Line2d clFacLine, clPolyLine;
|
||||
Base::Vector2d S;
|
||||
// is corner of facet inside the polygon
|
||||
for (i=0; i<3; i++) {
|
||||
Base::Vector3f clPt2d = myProj->operator ()(rclFacet._aclPoints[i]);
|
||||
if (myPoly.Contains(Base::Vector2D(clPt2d.x, clPt2d.y)) == myInner)
|
||||
if (myPoly.Contains(Base::Vector2d(clPt2d.x, clPt2d.y)) == myInner)
|
||||
return true;
|
||||
else
|
||||
clPoly.Add(Base::Vector2D(clPt2d.x, clPt2d.y));
|
||||
clPoly.Add(Base::Vector2d(clPt2d.x, clPt2d.y));
|
||||
}
|
||||
|
||||
// is corner of polygon inside the facet
|
||||
|
@ -147,7 +147,7 @@ bool MeshTrimming::PolygonContainsCompleteFacet(bool bInner, unsigned long ulInd
|
|||
for (int i=0; i<3; i++) {
|
||||
const MeshPoint &rclFacPt = myMesh._aclPointArray[rclFacet._aulPoints[i]];
|
||||
Base::Vector3f clPt = (*myProj)(rclFacPt);
|
||||
if (myPoly.Contains(Base::Vector2D(clPt.x, clPt.y)) != bInner)
|
||||
if (myPoly.Contains(Base::Vector2d(clPt.x, clPt.y)) != bInner)
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -156,28 +156,28 @@ bool MeshTrimming::PolygonContainsCompleteFacet(bool bInner, unsigned long ulInd
|
|||
|
||||
bool MeshTrimming::IsPolygonPointInFacet(unsigned long ulIndex, Base::Vector3f& clPoint)
|
||||
{
|
||||
Base::Vector2D A, B, C, P;
|
||||
Base::Vector2d A, B, C, P;
|
||||
float u,v,w, fDetPAC, fDetPBC, fDetPAB, fDetABC;
|
||||
Base::Polygon2D clFacPoly;
|
||||
Base::Polygon2d clFacPoly;
|
||||
const MeshGeomFacet &rclFacet = myMesh.GetFacet(ulIndex);
|
||||
|
||||
for (int i=0; i<3; i++) {
|
||||
Base::Vector3f clPt = (*myProj)(rclFacet._aclPoints[i]);
|
||||
clFacPoly.Add(Base::Vector2D(clPt.x, clPt.y));
|
||||
clFacPoly.Add(Base::Vector2d(clPt.x, clPt.y));
|
||||
}
|
||||
|
||||
A = clFacPoly[0];
|
||||
B = clFacPoly[1];
|
||||
C = clFacPoly[2];
|
||||
fDetABC = (float)(A.fX*B.fY+A.fY*C.fX+B.fX*C.fY-(B.fY*C.fX+A.fY*B.fX+A.fX*C.fY));
|
||||
fDetABC = (float)(A.x*B.y+A.y*C.x+B.x*C.y-(B.y*C.x+A.y*B.x+A.x*C.y));
|
||||
|
||||
for (unsigned long j=0; j<myPoly.GetCtVectors(); j++) {
|
||||
// facet contains a polygon point -> calculate the corresponding 3d-point
|
||||
if (clFacPoly.Contains(myPoly[j])) {
|
||||
P = myPoly[j];
|
||||
fDetPAC = (float)(A.fX*P.fY+A.fY*C.fX+P.fX*C.fY-(P.fY*C.fX+A.fY*P.fX+A.fX*C.fY));
|
||||
fDetPBC = (float)(P.fX*B.fY+P.fY*C.fX+B.fX*C.fY-(B.fY*C.fX+P.fY*B.fX+P.fX*C.fY));
|
||||
fDetPAB = (float)(A.fX*B.fY+A.fY*P.fX+B.fX*P.fY-(B.fY*P.fX+A.fY*B.fX+A.fX*P.fY));
|
||||
fDetPAC = (float)(A.x*P.y+A.y*C.x+P.x*C.y-(P.y*C.x+A.y*P.x+A.x*C.y));
|
||||
fDetPBC = (float)(P.x*B.y+P.y*C.x+B.x*C.y-(B.y*C.x+P.y*B.x+P.x*C.y));
|
||||
fDetPAB = (float)(A.x*B.y+A.y*P.x+B.x*P.y-(B.y*P.x+A.y*B.x+A.x*P.y));
|
||||
u = fDetPBC / fDetABC;
|
||||
v = fDetPAC / fDetABC;
|
||||
w = fDetPAB / fDetABC;
|
||||
|
@ -198,8 +198,8 @@ bool MeshTrimming::IsPolygonPointInFacet(unsigned long ulIndex, Base::Vector3f&
|
|||
bool MeshTrimming::GetIntersectionPointsOfPolygonAndFacet(unsigned long ulIndex, int& iSide, std::vector<Base::Vector3f>& raclPoints) const
|
||||
{
|
||||
MeshGeomFacet clFac(myMesh.GetFacet(ulIndex));
|
||||
Base::Vector2D S;
|
||||
Base::Line2D clFacLine, clPolyLine;
|
||||
Base::Vector2d S;
|
||||
Base::Line2d clFacLine, clPolyLine;
|
||||
int iIntersections=0;
|
||||
int iIntsctWithEdge0=0, iIntsctWithEdge1=0, iIntsctWithEdge2=0;
|
||||
|
||||
|
@ -211,15 +211,15 @@ bool MeshTrimming::GetIntersectionPointsOfPolygonAndFacet(unsigned long ulIndex,
|
|||
if (iIntersections == 4)
|
||||
break;
|
||||
|
||||
Base::Vector2D P3(myPoly[i]), P4(myPoly[(i+1)%myPoly.GetCtVectors()]);
|
||||
Base::Vector2d P3(myPoly[i]), P4(myPoly[(i+1)%myPoly.GetCtVectors()]);
|
||||
clPolyLine.clV1 = P3;
|
||||
clPolyLine.clV2 = P4;
|
||||
|
||||
for (int j=0; j<3; j++) {
|
||||
Base::Vector3f clP1((*myProj)(clFac._aclPoints[j]));
|
||||
Base::Vector3f clP2((*myProj)(clFac._aclPoints[(j+1)%3]));
|
||||
Base::Vector2D P1(clP1.x, clP1.y);
|
||||
Base::Vector2D P2(clP2.x, clP2.y);
|
||||
Base::Vector2d P1(clP1.x, clP1.y);
|
||||
Base::Vector2d P2(clP2.x, clP2.y);
|
||||
clFacLine.clV1 = P1;
|
||||
clFacLine.clV2 = P2;
|
||||
|
||||
|
@ -349,10 +349,10 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::
|
|||
int iCtPtsIn=0;
|
||||
int iCtPtsOn=0;
|
||||
Base::Vector3f clFacPnt;
|
||||
Base::Vector2D clProjPnt;
|
||||
Base::Vector2d clProjPnt;
|
||||
for (int i=0; i<3; i++) {
|
||||
clFacPnt = (*myProj)(myMesh._aclPointArray[facet._aulPoints[i]]);
|
||||
clProjPnt = Base::Vector2D(clFacPnt.x, clFacPnt.y);
|
||||
clProjPnt = Base::Vector2d(clFacPnt.x, clFacPnt.y);
|
||||
if (myPoly.Intersect(clProjPnt, MESH_MIN_PT_DIST))
|
||||
++iCtPtsOn;
|
||||
else if (myPoly.Contains(clProjPnt) == myInner)
|
||||
|
@ -367,16 +367,16 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::
|
|||
else if (raclPoints.size() == 1) {
|
||||
Base::Vector3f clP(raclPoints[0]);
|
||||
clP = ((*myProj)(clP));
|
||||
Base::Vector2D P(clP.x, clP.y);
|
||||
Base::Vector2d P(clP.x, clP.y);
|
||||
MeshGeomFacet clFac(myMesh.GetFacet(ulFacetPos));
|
||||
|
||||
// determine the edge containing the intersection point
|
||||
Base::Line2D clFacLine;
|
||||
Base::Line2d clFacLine;
|
||||
for (int j=0; j<3; j++) {
|
||||
Base::Vector3f clP1((*myProj)(clFac._aclPoints[j]));
|
||||
Base::Vector3f clP2((*myProj)(clFac._aclPoints[(j+1)%3]));
|
||||
Base::Vector2D P1(clP1.x, clP1.y);
|
||||
Base::Vector2D P2(clP2.x, clP2.y);
|
||||
Base::Vector2d P1(clP1.x, clP1.y);
|
||||
Base::Vector2d P2(clP2.x, clP2.y);
|
||||
clFacLine.clV1 = P1;
|
||||
clFacLine.clV2 = P2;
|
||||
|
||||
|
@ -415,10 +415,10 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::
|
|||
// check which facets can be inserted
|
||||
int iCtPts=0;
|
||||
Base::Vector3f clFacPnt;
|
||||
Base::Vector2D clProjPnt;
|
||||
Base::Vector2d clProjPnt;
|
||||
for (int i=0; i<3; i++) {
|
||||
clFacPnt = (*myProj)(myMesh._aclPointArray[facet._aulPoints[i]]);
|
||||
clProjPnt = Base::Vector2D(clFacPnt.x, clFacPnt.y);
|
||||
clProjPnt = Base::Vector2d(clFacPnt.x, clFacPnt.y);
|
||||
if (myPoly.Contains(clProjPnt) == myInner)
|
||||
++iCtPts;
|
||||
}
|
||||
|
@ -458,10 +458,10 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::
|
|||
// check which facets can be inserted
|
||||
int iCtPts=0;
|
||||
Base::Vector3f clFacPnt;
|
||||
Base::Vector2D clProjPnt;
|
||||
Base::Vector2d clProjPnt;
|
||||
for (int i=0; i<3; i++) {
|
||||
clFacPnt = (*myProj)(myMesh._aclPointArray[facet._aulPoints[i]]);
|
||||
clProjPnt = Base::Vector2D(clFacPnt.x, clFacPnt.y);
|
||||
clProjPnt = Base::Vector2d(clFacPnt.x, clFacPnt.y);
|
||||
if (myPoly.Contains(clProjPnt) == myInner)
|
||||
++iCtPts;
|
||||
}
|
||||
|
@ -635,10 +635,10 @@ bool MeshTrimming::CreateFacets(unsigned long ulFacetPos, int iSide, const std::
|
|||
// check which facets should be inserted
|
||||
int iCtPts=0;
|
||||
Base::Vector3f clFacPnt;
|
||||
Base::Vector2D clProjPnt;
|
||||
Base::Vector2d clProjPnt;
|
||||
for (int i=0; i<3; i++) {
|
||||
clFacPnt = (*myProj)(myMesh._aclPointArray[facet._aulPoints[i]]);
|
||||
clProjPnt = Base::Vector2D(clFacPnt.x, clFacPnt.y);
|
||||
clProjPnt = Base::Vector2d(clFacPnt.x, clFacPnt.y);
|
||||
if (myPoly.Contains(clProjPnt) == myInner)
|
||||
++iCtPts;
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public:
|
|||
enum TMode {INNER, OUTER};
|
||||
|
||||
public:
|
||||
MeshTrimming(MeshKernel& mesh, const Base::ViewProjMethod* pclProj, const Base::Polygon2D& rclPoly);
|
||||
MeshTrimming(MeshKernel& mesh, const Base::ViewProjMethod* pclProj, const Base::Polygon2d& rclPoly);
|
||||
~MeshTrimming();
|
||||
|
||||
public:
|
||||
|
@ -100,7 +100,7 @@ private:
|
|||
bool myInner;
|
||||
std::vector<MeshGeomFacet> myTriangles;
|
||||
const Base::ViewProjMethod* myProj;
|
||||
const Base::Polygon2D& myPoly;
|
||||
const Base::Polygon2d& myPoly;
|
||||
};
|
||||
|
||||
} //namespace MeshCore
|
||||
|
|
|
@ -979,7 +979,7 @@ void MeshObject::crossSections(const std::vector<MeshObject::TPlane>& planes, st
|
|||
}
|
||||
}
|
||||
|
||||
void MeshObject::cut(const Base::Polygon2D& polygon2d,
|
||||
void MeshObject::cut(const Base::Polygon2d& polygon2d,
|
||||
const Base::ViewProjMethod& proj, MeshObject::CutType type)
|
||||
{
|
||||
MeshCore::MeshAlgorithm meshAlg(this->_kernel);
|
||||
|
@ -1004,7 +1004,7 @@ void MeshObject::cut(const Base::Polygon2D& polygon2d,
|
|||
this->deleteFacets(check);
|
||||
}
|
||||
|
||||
void MeshObject::trim(const Base::Polygon2D& polygon2d,
|
||||
void MeshObject::trim(const Base::Polygon2d& polygon2d,
|
||||
const Base::ViewProjMethod& proj, MeshObject::CutType type)
|
||||
{
|
||||
MeshCore::MeshTrimming trim(this->_kernel, &proj, polygon2d);
|
||||
|
|
|
@ -50,7 +50,7 @@ class List;
|
|||
}
|
||||
|
||||
namespace Base {
|
||||
class Polygon2D;
|
||||
class Polygon2d;
|
||||
class ViewProjMethod;
|
||||
}
|
||||
|
||||
|
@ -217,8 +217,8 @@ public:
|
|||
std::vector<Base::Vector3d> getPointNormals() const;
|
||||
void crossSections(const std::vector<TPlane>&, std::vector<TPolylines> §ions,
|
||||
float fMinEps = 1.0e-2f, bool bConnectPolygons = false) const;
|
||||
void cut(const Base::Polygon2D& polygon, const Base::ViewProjMethod& proj, CutType);
|
||||
void trim(const Base::Polygon2D& polygon, const Base::ViewProjMethod& proj, CutType);
|
||||
void cut(const Base::Polygon2d& polygon, const Base::ViewProjMethod& proj, CutType);
|
||||
void trim(const Base::Polygon2d& polygon, const Base::ViewProjMethod& proj, CutType);
|
||||
//@}
|
||||
|
||||
/** @name Selection */
|
||||
|
|
|
@ -1524,9 +1524,9 @@ PyObject* MeshPy::cut(PyObject *args)
|
|||
polygon = tria.ProjectToFitPlane();
|
||||
|
||||
Base::ViewProjMatrix proj(mat);
|
||||
Base::Polygon2D polygon2d;
|
||||
Base::Polygon2d polygon2d;
|
||||
for (std::vector<Base::Vector3f>::const_iterator it = polygon.begin(); it != polygon.end(); ++it)
|
||||
polygon2d.Add(Base::Vector2D(it->x, it->y));
|
||||
polygon2d.Add(Base::Vector2d(it->x, it->y));
|
||||
getMeshObjectPtr()->cut(polygon2d, proj, MeshObject::CutType(mode));
|
||||
|
||||
Py_Return;
|
||||
|
@ -1558,9 +1558,9 @@ PyObject* MeshPy::trim(PyObject *args)
|
|||
polygon = tria.ProjectToFitPlane();
|
||||
|
||||
Base::ViewProjMatrix proj(mat);
|
||||
Base::Polygon2D polygon2d;
|
||||
Base::Polygon2d polygon2d;
|
||||
for (std::vector<Base::Vector3f>::const_iterator it = polygon.begin(); it != polygon.end(); ++it)
|
||||
polygon2d.Add(Base::Vector2D(it->x, it->y));
|
||||
polygon2d.Add(Base::Vector2d(it->x, it->y));
|
||||
getMeshObjectPtr()->trim(polygon2d, proj, MeshObject::CutType(mode));
|
||||
|
||||
Py_Return;
|
||||
|
|
|
@ -986,11 +986,11 @@ void CmdMeshTrimByPlane::activated(int)
|
|||
p3 = mat * p3;
|
||||
p4 = mat * p4;
|
||||
|
||||
Base::Polygon2D polygon2d;
|
||||
polygon2d.Add(Base::Vector2D(p1.x, p1.y));
|
||||
polygon2d.Add(Base::Vector2D(p2.x, p2.y));
|
||||
polygon2d.Add(Base::Vector2D(p3.x, p3.y));
|
||||
polygon2d.Add(Base::Vector2D(p4.x, p4.y));
|
||||
Base::Polygon2d polygon2d;
|
||||
polygon2d.Add(Base::Vector2d(p1.x, p1.y));
|
||||
polygon2d.Add(Base::Vector2d(p2.x, p2.y));
|
||||
polygon2d.Add(Base::Vector2d(p3.x, p3.y));
|
||||
polygon2d.Add(Base::Vector2d(p4.x, p4.y));
|
||||
|
||||
Mesh::MeshObject::CutType type = Mesh::MeshObject::INNER;
|
||||
mesh->trim(polygon2d, proj, type);
|
||||
|
|
|
@ -1059,9 +1059,9 @@ void ViewProviderMesh::getFacetsFromPolygon(const std::vector<SbVec2f>& picked,
|
|||
{
|
||||
#if 1
|
||||
const bool ok = true;
|
||||
Base::Polygon2D polygon;
|
||||
Base::Polygon2d polygon;
|
||||
for (std::vector<SbVec2f>::const_iterator it = picked.begin(); it != picked.end(); ++it)
|
||||
polygon.Add(Base::Vector2D((*it)[0],(*it)[1]));
|
||||
polygon.Add(Base::Vector2d((*it)[0],(*it)[1]));
|
||||
|
||||
// Get the attached mesh property
|
||||
Mesh::PropertyMeshKernel& meshProp = static_cast<Mesh::Feature*>(pcObject)->Mesh;
|
||||
|
@ -1289,9 +1289,9 @@ void ViewProviderMesh::trimMesh(const std::vector<SbVec2f>& polygon,
|
|||
{
|
||||
Mesh::MeshObject* mesh = static_cast<Mesh::Feature*>(pcObject)->Mesh.startEditing();
|
||||
|
||||
Base::Polygon2D polygon2d;
|
||||
Base::Polygon2d polygon2d;
|
||||
for (std::vector<SbVec2f>::const_iterator it = polygon.begin(); it != polygon.end(); ++it)
|
||||
polygon2d.Add(Base::Vector2D((*it)[0],(*it)[1]));
|
||||
polygon2d.Add(Base::Vector2d((*it)[0],(*it)[1]));
|
||||
|
||||
Mesh::MeshObject::CutType type = inner ?
|
||||
Mesh::MeshObject::INNER :
|
||||
|
|
|
@ -163,7 +163,7 @@ public:
|
|||
}
|
||||
void addFacesToSelection(Gui::View3DInventorViewer* /*viewer*/,
|
||||
const Gui::ViewVolumeProjection& proj,
|
||||
const Base::Polygon2D& polygon,
|
||||
const Base::Polygon2d& polygon,
|
||||
const TopoDS_Shape& shape)
|
||||
{
|
||||
try {
|
||||
|
@ -184,7 +184,7 @@ public:
|
|||
gp_Pnt p = BRep_Tool::Pnt(TopoDS::Vertex(xp_vertex.Current()));
|
||||
Base::Vector3d pt2d;
|
||||
pt2d = proj(Base::Vector3d(p.X(), p.Y(), p.Z()));
|
||||
if (polygon.Contains(Base::Vector2D(pt2d.x, pt2d.y))) {
|
||||
if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) {
|
||||
#if 0
|
||||
// TODO
|
||||
if (isVisibleFace(k-1, SbVec2f(pt2d.x, pt2d.y), viewer))
|
||||
|
@ -204,7 +204,7 @@ public:
|
|||
//gp_Pnt c = props.CentreOfMass();
|
||||
//Base::Vector3d pt2d;
|
||||
//pt2d = proj(Base::Vector3d(c.X(), c.Y(), c.Z()));
|
||||
//if (polygon.Contains(Base::Vector2D(pt2d.x, pt2d.y))) {
|
||||
//if (polygon.Contains(Base::Vector2d(pt2d.x, pt2d.y))) {
|
||||
// if (isVisibleFace(k-1, SbVec2f(pt2d.x, pt2d.y), viewer)) {
|
||||
// std::stringstream str;
|
||||
// str << "Face" << k;
|
||||
|
@ -227,18 +227,18 @@ public:
|
|||
SoCamera* cam = view->getSoRenderManager()->getCamera();
|
||||
SbViewVolume vv = cam->getViewVolume();
|
||||
Gui::ViewVolumeProjection proj(vv);
|
||||
Base::Polygon2D polygon;
|
||||
Base::Polygon2d polygon;
|
||||
if (picked.size() == 2) {
|
||||
SbVec2f pt1 = picked[0];
|
||||
SbVec2f pt2 = picked[1];
|
||||
polygon.Add(Base::Vector2D(pt1[0], pt1[1]));
|
||||
polygon.Add(Base::Vector2D(pt1[0], pt2[1]));
|
||||
polygon.Add(Base::Vector2D(pt2[0], pt2[1]));
|
||||
polygon.Add(Base::Vector2D(pt2[0], pt1[1]));
|
||||
polygon.Add(Base::Vector2d(pt1[0], pt1[1]));
|
||||
polygon.Add(Base::Vector2d(pt1[0], pt2[1]));
|
||||
polygon.Add(Base::Vector2d(pt2[0], pt2[1]));
|
||||
polygon.Add(Base::Vector2d(pt2[0], pt1[1]));
|
||||
}
|
||||
else {
|
||||
for (std::vector<SbVec2f>::const_iterator it = picked.begin(); it != picked.end(); ++it)
|
||||
polygon.Add(Base::Vector2D((*it)[0],(*it)[1]));
|
||||
polygon.Add(Base::Vector2d((*it)[0],(*it)[1]));
|
||||
}
|
||||
|
||||
FaceColors* self = reinterpret_cast<FaceColors*>(ud);
|
||||
|
|
|
@ -204,11 +204,11 @@ void ViewProvider2DObject::updateData(const App::Property* prop)
|
|||
Base::Placement place = static_cast<const Part::PropertyPartShape*>(prop)->getComplexData()->getPlacement();
|
||||
place.invert();
|
||||
Base::ViewProjMatrix proj(place.toMatrix());
|
||||
Base::BoundBox2D bbox2d = bbox.ProjectBox(&proj);
|
||||
this->MinX = bbox2d.fMinX;
|
||||
this->MaxX = bbox2d.fMaxX;
|
||||
this->MinY = bbox2d.fMinY;
|
||||
this->MaxY = bbox2d.fMaxY;
|
||||
Base::BoundBox2d bbox2d = bbox.ProjectBox(&proj);
|
||||
this->MinX = bbox2d.MinX;
|
||||
this->MaxX = bbox2d.MaxX;
|
||||
this->MinY = bbox2d.MinY;
|
||||
this->MaxY = bbox2d.MaxY;
|
||||
if (ShowGrid.getValue()) {
|
||||
createGrid();
|
||||
}
|
||||
|
|
|
@ -408,9 +408,9 @@ void ViewProviderScattered::updateData(const App::Property* prop)
|
|||
void ViewProviderScattered::cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer)
|
||||
{
|
||||
// create the polygon from the picked points
|
||||
Base::Polygon2D cPoly;
|
||||
Base::Polygon2d cPoly;
|
||||
for (std::vector<SbVec2f>::const_iterator it = picked.begin(); it != picked.end(); ++it) {
|
||||
cPoly.Add(Base::Vector2D((*it)[0],(*it)[1]));
|
||||
cPoly.Add(Base::Vector2d((*it)[0],(*it)[1]));
|
||||
}
|
||||
|
||||
// get a reference to the point feature
|
||||
|
@ -430,7 +430,7 @@ void ViewProviderScattered::cut(const std::vector<SbVec2f>& picked, Gui::View3DI
|
|||
|
||||
// project from 3d to 2d
|
||||
vol.projectToScreen(pt, pt);
|
||||
if (cPoly.Contains(Base::Vector2D(pt[0],pt[1])))
|
||||
if (cPoly.Contains(Base::Vector2d(pt[0],pt[1])))
|
||||
removeIndices.push_back(index);
|
||||
}
|
||||
|
||||
|
@ -560,9 +560,9 @@ void ViewProviderStructured::updateData(const App::Property* prop)
|
|||
void ViewProviderStructured::cut(const std::vector<SbVec2f>& picked, Gui::View3DInventorViewer &Viewer)
|
||||
{
|
||||
// create the polygon from the picked points
|
||||
Base::Polygon2D cPoly;
|
||||
Base::Polygon2d cPoly;
|
||||
for (std::vector<SbVec2f>::const_iterator it = picked.begin(); it != picked.end(); ++it) {
|
||||
cPoly.Add(Base::Vector2D((*it)[0],(*it)[1]));
|
||||
cPoly.Add(Base::Vector2d((*it)[0],(*it)[1]));
|
||||
}
|
||||
|
||||
// get a reference to the point feature
|
||||
|
@ -586,7 +586,7 @@ void ViewProviderStructured::cut(const std::vector<SbVec2f>& picked, Gui::View3D
|
|||
|
||||
// project from 3d to 2d
|
||||
vol.projectToScreen(pt, pt);
|
||||
if (cPoly.Contains(Base::Vector2D(pt[0],pt[1]))) {
|
||||
if (cPoly.Contains(Base::Vector2d(pt[0],pt[1]))) {
|
||||
invalidatePoints = true;
|
||||
vec.Set(nan, nan, nan);
|
||||
}
|
||||
|
|
|
@ -630,37 +630,37 @@ bool ParameterCorrection::GetUVParameters(double fSizeFactor)
|
|||
}
|
||||
}
|
||||
|
||||
std::vector<Base::Vector2D> vcProjPts;
|
||||
Base::BoundBox2D clBBox;
|
||||
std::vector<Base::Vector2d> vcProjPts;
|
||||
Base::BoundBox2d clBBox;
|
||||
|
||||
// Berechne die Koordinaten der transf. Punkte und projiz. diese auf die x,y-Ebene des neuen
|
||||
// Koordinatensystems
|
||||
for (int ii=_pvcPoints->Lower(); ii<=_pvcPoints->Upper(); ii++) {
|
||||
const gp_Pnt& pnt = (*_pvcPoints)(ii);
|
||||
Wm4::Vector3d clProjPnt = clRotMatTrans * Wm4::Vector3d(pnt.X(), pnt.Y(), pnt.Z());
|
||||
vcProjPts.push_back(Base::Vector2D(clProjPnt.X(), clProjPnt.Y()));
|
||||
clBBox.Add(Base::Vector2D(clProjPnt.X(), clProjPnt.Y()));
|
||||
vcProjPts.push_back(Base::Vector2d(clProjPnt.X(), clProjPnt.Y()));
|
||||
clBBox.Add(Base::Vector2d(clProjPnt.X(), clProjPnt.Y()));
|
||||
}
|
||||
|
||||
if ((clBBox.fMaxX == clBBox.fMinX) || (clBBox.fMaxY == clBBox.fMinY))
|
||||
if ((clBBox.MaxX == clBBox.MinX) || (clBBox.MaxY == clBBox.MinY))
|
||||
return false;
|
||||
double tx = fSizeFactor*clBBox.fMinX-(fSizeFactor-1.0)*clBBox.fMaxX;
|
||||
double ty = fSizeFactor*clBBox.fMinY-(fSizeFactor-1.0)*clBBox.fMaxY;
|
||||
double fDeltaX = (2*fSizeFactor-1.0)*(clBBox.fMaxX - clBBox.fMinX);
|
||||
double fDeltaY = (2*fSizeFactor-1.0)*(clBBox.fMaxY - clBBox.fMinY);
|
||||
double tx = fSizeFactor*clBBox.MinX-(fSizeFactor-1.0)*clBBox.MaxX;
|
||||
double ty = fSizeFactor*clBBox.MinY-(fSizeFactor-1.0)*clBBox.MaxY;
|
||||
double fDeltaX = (2*fSizeFactor-1.0)*(clBBox.MaxX - clBBox.MinX);
|
||||
double fDeltaY = (2*fSizeFactor-1.0)*(clBBox.MaxY - clBBox.MinY);
|
||||
|
||||
// Berechne die u,v-Parameter mit u,v aus [0,1]
|
||||
_pvcUVParam->Init(gp_Pnt2d(0.0, 0.0));
|
||||
int ii=0;
|
||||
if (clBBox.fMaxX - clBBox.fMinX >= clBBox.fMaxY - clBBox.fMinY) {
|
||||
for (std::vector<Base::Vector2D>::iterator It2=vcProjPts.begin(); It2!=vcProjPts.end(); ++It2) {
|
||||
(*_pvcUVParam)(ii) = gp_Pnt2d((It2->fX-tx)/fDeltaX, (It2->fY-ty)/fDeltaY);
|
||||
if (clBBox.MaxX - clBBox.MinX >= clBBox.MaxY - clBBox.MinY) {
|
||||
for (std::vector<Base::Vector2d>::iterator It2=vcProjPts.begin(); It2!=vcProjPts.end(); ++It2) {
|
||||
(*_pvcUVParam)(ii) = gp_Pnt2d((It2->x-tx)/fDeltaX, (It2->y-ty)/fDeltaY);
|
||||
ii++;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (std::vector<Base::Vector2D>::iterator It2=vcProjPts.begin(); It2!=vcProjPts.end(); ++It2) {
|
||||
(*_pvcUVParam)(ii) = gp_Pnt2d((It2->fY-ty)/fDeltaY, (It2->fX-tx)/fDeltaX);
|
||||
for (std::vector<Base::Vector2d>::iterator It2=vcProjPts.begin(); It2!=vcProjPts.end(); ++It2) {
|
||||
(*_pvcUVParam)(ii) = gp_Pnt2d((It2->y-ty)/fDeltaY, (It2->x-tx)/fDeltaX);
|
||||
ii++;
|
||||
}
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1247,21 +1247,21 @@ static const char *cursor_createcopy[]={
|
|||
{
|
||||
setCursor(QPixmap(cursor_createcopy),7,7);
|
||||
Origin = static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->getPoint(OriginGeoId, OriginPos);
|
||||
EditCurve[0] = Base::Vector2D(Origin.x,Origin.y);
|
||||
EditCurve[0] = Base::Vector2d(Origin.x,Origin.y);
|
||||
}
|
||||
|
||||
virtual void mouseMove(Base::Vector2D onSketchPos)
|
||||
virtual void mouseMove(Base::Vector2d onSketchPos)
|
||||
{
|
||||
if (Mode==STATUS_SEEK_First) {
|
||||
float length = (onSketchPos - EditCurve[0]).Length();
|
||||
float angle = (onSketchPos - EditCurve[0]).GetAngle(Base::Vector2D(1.f,0.f));
|
||||
float angle = (onSketchPos - EditCurve[0]).GetAngle(Base::Vector2d(1.f,0.f));
|
||||
SbString text;
|
||||
text.sprintf(" (%.1f,%.1fdeg)", length, angle * 180 / M_PI);
|
||||
setPositionText(onSketchPos, text);
|
||||
|
||||
EditCurve[1] = onSketchPos;
|
||||
sketchgui->drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr1, onSketchPos, Base::Vector2D(0.0,0.0),AutoConstraint::VERTEX)) {
|
||||
if (seekAutoConstraint(sugConstr1, onSketchPos, Base::Vector2d(0.0,0.0),AutoConstraint::VERTEX)) {
|
||||
renderSuggestConstraintsCursor(sugConstr1);
|
||||
return;
|
||||
}
|
||||
|
@ -1270,7 +1270,7 @@ static const char *cursor_createcopy[]={
|
|||
applyCursor();
|
||||
}
|
||||
|
||||
virtual bool pressButton(Base::Vector2D onSketchPos)
|
||||
virtual bool pressButton(Base::Vector2d onSketchPos)
|
||||
{
|
||||
if (Mode==STATUS_SEEK_First){
|
||||
EditCurve[1] = onSketchPos;
|
||||
|
@ -1281,12 +1281,12 @@ static const char *cursor_createcopy[]={
|
|||
return true;
|
||||
}
|
||||
|
||||
virtual bool releaseButton(Base::Vector2D onSketchPos)
|
||||
virtual bool releaseButton(Base::Vector2d onSketchPos)
|
||||
{
|
||||
Q_UNUSED(onSketchPos);
|
||||
if (Mode==STATUS_End){
|
||||
|
||||
Base::Vector2D vector = EditCurve[1]-EditCurve[0];
|
||||
Base::Vector2d vector = EditCurve[1]-EditCurve[0];
|
||||
|
||||
unsetCursor();
|
||||
resetPositionText();
|
||||
|
@ -1300,7 +1300,7 @@ static const char *cursor_createcopy[]={
|
|||
Gui::Command::doCommand(
|
||||
Gui::Command::Doc, "App.ActiveDocument.%s.addCopy(%s,App.Vector(%f,%f,0),%s)",
|
||||
sketchgui->getObject()->getNameInDocument(),
|
||||
geoIdList.c_str(), vector.fX, vector.fY,
|
||||
geoIdList.c_str(), vector.x, vector.y,
|
||||
(Clone?"True":"False"));
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
|
@ -1336,7 +1336,7 @@ static const char *cursor_createcopy[]={
|
|||
Sketcher::PointPos OriginPos;
|
||||
int nElements;
|
||||
bool Clone;
|
||||
std::vector<Base::Vector2D> EditCurve;
|
||||
std::vector<Base::Vector2d> EditCurve;
|
||||
std::vector<AutoConstraint> sugConstr1;
|
||||
};
|
||||
|
||||
|
@ -1692,21 +1692,21 @@ static const char *cursor_createrectangulararray[]={
|
|||
{
|
||||
setCursor(QPixmap(cursor_createrectangulararray),7,7);
|
||||
Origin = static_cast<Sketcher::SketchObject *>(sketchgui->getObject())->getPoint(OriginGeoId, OriginPos);
|
||||
EditCurve[0] = Base::Vector2D(Origin.x,Origin.y);
|
||||
EditCurve[0] = Base::Vector2d(Origin.x,Origin.y);
|
||||
}
|
||||
|
||||
virtual void mouseMove(Base::Vector2D onSketchPos)
|
||||
virtual void mouseMove(Base::Vector2d onSketchPos)
|
||||
{
|
||||
if (Mode==STATUS_SEEK_First) {
|
||||
float length = (onSketchPos - EditCurve[0]).Length();
|
||||
float angle = (onSketchPos - EditCurve[0]).GetAngle(Base::Vector2D(1.f,0.f));
|
||||
float angle = (onSketchPos - EditCurve[0]).GetAngle(Base::Vector2d(1.f,0.f));
|
||||
SbString text;
|
||||
text.sprintf(" (%.1f,%.1fdeg)", length, angle * 180 / M_PI);
|
||||
setPositionText(onSketchPos, text);
|
||||
|
||||
EditCurve[1] = onSketchPos;
|
||||
sketchgui->drawEdit(EditCurve);
|
||||
if (seekAutoConstraint(sugConstr1, onSketchPos, Base::Vector2D(0.0,0.0),AutoConstraint::VERTEX)) {
|
||||
if (seekAutoConstraint(sugConstr1, onSketchPos, Base::Vector2d(0.0,0.0),AutoConstraint::VERTEX)) {
|
||||
renderSuggestConstraintsCursor(sugConstr1);
|
||||
return;
|
||||
}
|
||||
|
@ -1715,7 +1715,7 @@ static const char *cursor_createrectangulararray[]={
|
|||
applyCursor();
|
||||
}
|
||||
|
||||
virtual bool pressButton(Base::Vector2D onSketchPos)
|
||||
virtual bool pressButton(Base::Vector2d onSketchPos)
|
||||
{
|
||||
if (Mode==STATUS_SEEK_First){
|
||||
EditCurve[1] = onSketchPos;
|
||||
|
@ -1726,12 +1726,12 @@ static const char *cursor_createrectangulararray[]={
|
|||
return true;
|
||||
}
|
||||
|
||||
virtual bool releaseButton(Base::Vector2D onSketchPos)
|
||||
virtual bool releaseButton(Base::Vector2d onSketchPos)
|
||||
{
|
||||
Q_UNUSED(onSketchPos);
|
||||
if (Mode==STATUS_End){
|
||||
|
||||
Base::Vector2D vector = EditCurve[1]-EditCurve[0];
|
||||
Base::Vector2d vector = EditCurve[1]-EditCurve[0];
|
||||
|
||||
unsetCursor();
|
||||
resetPositionText();
|
||||
|
@ -1745,7 +1745,7 @@ static const char *cursor_createrectangulararray[]={
|
|||
Gui::Command::doCommand(
|
||||
Gui::Command::Doc, "App.ActiveDocument.%s.addRectangularArray(%s, App.Vector(%f,%f,0),%s,%d,%d,%s,%f)",
|
||||
sketchgui->getObject()->getNameInDocument(),
|
||||
geoIdList.c_str(), vector.fX, vector.fY,
|
||||
geoIdList.c_str(), vector.x, vector.y,
|
||||
(Clone?"True":"False"),
|
||||
Cols, Rows,
|
||||
(ConstraintSeparation?"True":"False"),
|
||||
|
@ -1788,7 +1788,7 @@ static const char *cursor_createrectangulararray[]={
|
|||
int Cols;
|
||||
bool ConstraintSeparation;
|
||||
bool EqualVerticalHorizontalSpacing;
|
||||
std::vector<Base::Vector2D> EditCurve;
|
||||
std::vector<Base::Vector2d> EditCurve;
|
||||
std::vector<AutoConstraint> sugConstr1;
|
||||
};
|
||||
|
||||
|
|
|
@ -75,7 +75,7 @@ DrawSketchHandler::~DrawSketchHandler()
|
|||
void DrawSketchHandler::quit(void)
|
||||
{
|
||||
assert(sketchgui);
|
||||
sketchgui->drawEdit(std::vector<Base::Vector2D>());
|
||||
sketchgui->drawEdit(std::vector<Base::Vector2d>());
|
||||
resetPositionText();
|
||||
|
||||
unsetCursor();
|
||||
|
@ -133,7 +133,7 @@ void DrawSketchHandler::unsetCursor(void)
|
|||
}
|
||||
|
||||
int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggestedConstraints,
|
||||
const Base::Vector2D& Pos, const Base::Vector2D& Dir,
|
||||
const Base::Vector2d& Pos, const Base::Vector2d& Dir,
|
||||
AutoConstraint::TargetType type)
|
||||
{
|
||||
suggestedConstraints.clear();
|
||||
|
@ -191,7 +191,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
|
|||
constr.Type = Sketcher::Tangent;
|
||||
|
||||
if(constr.Type == Sketcher::Tangent && Dir.Length() > 1e-8 && hitShapeDir.Length() > 1e-8) { // We are hitting a line and have hitting vector information
|
||||
Base::Vector3d dir3d = Base::Vector3d(Dir.fX,Dir.fY,0);
|
||||
Base::Vector3d dir3d = Base::Vector3d(Dir.x,Dir.y,0);
|
||||
double cosangle=dir3d.Normalize()*hitShapeDir.Normalize();
|
||||
|
||||
// the angle between the line and the hitting direction are over around 6 degrees (it is substantially parallel)
|
||||
|
@ -221,7 +221,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
|
|||
constr.Type = Sketcher::None;
|
||||
constr.GeoId = Constraint::GeoUndef;
|
||||
constr.PosId = Sketcher::none;
|
||||
double angle = std::abs(atan2(Dir.fY, Dir.fX));
|
||||
double angle = std::abs(atan2(Dir.y, Dir.x));
|
||||
if (angle < angleDevRad || (M_PI - angle) < angleDevRad )
|
||||
// Suggest horizontal constraint
|
||||
constr.Type = Sketcher::Horizontal;
|
||||
|
@ -243,9 +243,9 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
|
|||
// Get geometry list
|
||||
const std::vector<Part::Geometry *> geomlist = sketchgui->getSketchObject()->getCompleteGeometry();
|
||||
|
||||
Base::Vector3d tmpPos(Pos.fX, Pos.fY, 0.f); // Current cursor point
|
||||
Base::Vector3d tmpDir(Dir.fX, Dir.fY, 0.f); // Direction of line
|
||||
Base::Vector3d tmpStart(Pos.fX-Dir.fX, Pos.fY-Dir.fY, 0.f); // Start point
|
||||
Base::Vector3d tmpPos(Pos.x, Pos.y, 0.f); // Current cursor point
|
||||
Base::Vector3d tmpDir(Dir.x, Dir.y, 0.f); // Direction of line
|
||||
Base::Vector3d tmpStart(Pos.x-Dir.x, Pos.y-Dir.y, 0.f); // Start point
|
||||
|
||||
// Iterate through geometry
|
||||
int i = 0;
|
||||
|
@ -287,7 +287,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
|
|||
Base::Vector3d focus1P = center + cf * majdir;
|
||||
Base::Vector3d focus2P = center - cf * majdir;
|
||||
|
||||
Base::Vector3d norm = Base::Vector3d(Dir.fY,-Dir.fX).Normalize();
|
||||
Base::Vector3d norm = Base::Vector3d(Dir.y,-Dir.x).Normalize();
|
||||
|
||||
double distancetoline = norm*(tmpPos - focus1P); // distance focus1 to line
|
||||
|
||||
|
@ -342,7 +342,7 @@ int DrawSketchHandler::seekAutoConstraint(std::vector<AutoConstraint> &suggested
|
|||
Base::Vector3d focus1P = center + cf * majdir;
|
||||
Base::Vector3d focus2P = center - cf * majdir;
|
||||
|
||||
Base::Vector3d norm = Base::Vector3d(Dir.fY,-Dir.fX).Normalize();
|
||||
Base::Vector3d norm = Base::Vector3d(Dir.y,-Dir.x).Normalize();
|
||||
|
||||
double distancetoline = norm*(tmpPos - focus1P); // distance focus1 to line
|
||||
|
||||
|
@ -581,13 +581,13 @@ void DrawSketchHandler::renderSuggestConstraintsCursor(std::vector<AutoConstrain
|
|||
applyCursor(newCursor);
|
||||
}
|
||||
|
||||
void DrawSketchHandler::setPositionText(const Base::Vector2D &Pos, const SbString &text)
|
||||
void DrawSketchHandler::setPositionText(const Base::Vector2d &Pos, const SbString &text)
|
||||
{
|
||||
sketchgui->setPositionText(Pos, text);
|
||||
}
|
||||
|
||||
|
||||
void DrawSketchHandler::setPositionText(const Base::Vector2D &Pos)
|
||||
void DrawSketchHandler::setPositionText(const Base::Vector2d &Pos)
|
||||
{
|
||||
sketchgui->setPositionText(Pos);
|
||||
}
|
||||
|
|
|
@ -64,9 +64,9 @@ public:
|
|||
|
||||
virtual void activated(ViewProviderSketch *){}
|
||||
virtual void deactivated(ViewProviderSketch *){}
|
||||
virtual void mouseMove(Base::Vector2D onSketchPos)=0;
|
||||
virtual bool pressButton(Base::Vector2D onSketchPos)=0;
|
||||
virtual bool releaseButton(Base::Vector2D onSketchPos)=0;
|
||||
virtual void mouseMove(Base::Vector2d onSketchPos)=0;
|
||||
virtual bool pressButton(Base::Vector2d onSketchPos)=0;
|
||||
virtual bool releaseButton(Base::Vector2d onSketchPos)=0;
|
||||
virtual bool onSelectionChanged(const Gui::SelectionChanges&) { return false; }
|
||||
virtual void registerPressedKey(bool /*pressed*/, int /*key*/){}
|
||||
|
||||
|
@ -80,13 +80,13 @@ public:
|
|||
int getHighestCurveIndex(void);
|
||||
|
||||
int seekAutoConstraint(std::vector<AutoConstraint> &suggestedConstraints,
|
||||
const Base::Vector2D &Pos, const Base::Vector2D &Dir,
|
||||
const Base::Vector2d &Pos, const Base::Vector2d &Dir,
|
||||
AutoConstraint::TargetType type = AutoConstraint::VERTEX);
|
||||
void createAutoConstraints(const std::vector<AutoConstraint> &autoConstrs,
|
||||
int geoId, Sketcher::PointPos pointPos=Sketcher::none);
|
||||
|
||||
void setPositionText(const Base::Vector2D &Pos, const SbString &text);
|
||||
void setPositionText(const Base::Vector2D &Pos);
|
||||
void setPositionText(const Base::Vector2d &Pos, const SbString &text);
|
||||
void setPositionText(const Base::Vector2d &Pos);
|
||||
void resetPositionText(void);
|
||||
void renderSuggestConstraintsCursor(std::vector<AutoConstraint> &suggestedConstraints);
|
||||
|
||||
|
|
|
@ -345,7 +345,7 @@ void ViewProviderSketch::deactivateHandler()
|
|||
{
|
||||
assert(edit);
|
||||
if(edit->sketchHandler != 0){
|
||||
std::vector<Base::Vector2D> editCurve;
|
||||
std::vector<Base::Vector2d> editCurve;
|
||||
editCurve.clear();
|
||||
drawEdit(editCurve); // erase any line
|
||||
edit->sketchHandler->deactivated(this);
|
||||
|
@ -612,7 +612,7 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
|
|||
return done;
|
||||
}
|
||||
case STATUS_SKETCH_UseHandler:
|
||||
return edit->sketchHandler->pressButton(Base::Vector2D(x,y));
|
||||
return edit->sketchHandler->pressButton(Base::Vector2d(x,y));
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
|
@ -799,7 +799,7 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
|
|||
Gui::Command::openCommand("Drag Constraint");
|
||||
for(std::set<int>::iterator it = edit->DragConstraintSet.begin();
|
||||
it != edit->DragConstraintSet.end(); ++it) {
|
||||
moveConstraint(*it, Base::Vector2D(x, y));
|
||||
moveConstraint(*it, Base::Vector2d(x, y));
|
||||
//updateColor();
|
||||
}
|
||||
edit->PreselectConstraintSet = edit->DragConstraintSet;
|
||||
|
@ -823,7 +823,7 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe
|
|||
Mode = STATUS_NONE;
|
||||
return true;
|
||||
case STATUS_SKETCH_UseHandler:
|
||||
return edit->sketchHandler->releaseButton(Base::Vector2D(x,y));
|
||||
return edit->sketchHandler->releaseButton(Base::Vector2d(x,y));
|
||||
case STATUS_NONE:
|
||||
default:
|
||||
return false;
|
||||
|
@ -1108,7 +1108,7 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
|
|||
Base::Vector3d vec(x-xInit,y-yInit,0);
|
||||
if (GeoId != Sketcher::Constraint::GeoUndef && PosId != Sketcher::none) {
|
||||
if (getSketchObject()->getSolvedSketch().movePoint(GeoId, PosId, vec, relative) == 0) {
|
||||
setPositionText(Base::Vector2D(x,y));
|
||||
setPositionText(Base::Vector2d(x,y));
|
||||
draw(true);
|
||||
signalSolved(QString::fromLatin1("Solved in %1 sec").arg(getSketchObject()->getSolvedSketch().SolveTime));
|
||||
} else {
|
||||
|
@ -1122,7 +1122,7 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
|
|||
if (edit->DragCurve != -1) {
|
||||
Base::Vector3d vec(x-xInit,y-yInit,0);
|
||||
if (getSketchObject()->getSolvedSketch().movePoint(edit->DragCurve, Sketcher::none, vec, relative) == 0) {
|
||||
setPositionText(Base::Vector2D(x,y));
|
||||
setPositionText(Base::Vector2d(x,y));
|
||||
draw(true);
|
||||
signalSolved(QString::fromLatin1("Solved in %1 sec").arg(getSketchObject()->getSolvedSketch().SolveTime));
|
||||
} else {
|
||||
|
@ -1134,11 +1134,11 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
|
|||
if (edit->DragConstraintSet.empty() == false) {
|
||||
for(std::set<int>::iterator it = edit->DragConstraintSet.begin();
|
||||
it != edit->DragConstraintSet.end(); ++it)
|
||||
moveConstraint(*it, Base::Vector2D(x,y));
|
||||
moveConstraint(*it, Base::Vector2d(x,y));
|
||||
}
|
||||
return true;
|
||||
case STATUS_SKETCH_UseHandler:
|
||||
edit->sketchHandler->mouseMove(Base::Vector2D(x,y));
|
||||
edit->sketchHandler->mouseMove(Base::Vector2d(x,y));
|
||||
if (preselectChanged) {
|
||||
this->drawConstraintIcons();
|
||||
this->updateColor();
|
||||
|
@ -1166,7 +1166,7 @@ bool ViewProviderSketch::mouseMove(const SbVec2s &cursorPos, Gui::View3DInventor
|
|||
return false;
|
||||
}
|
||||
|
||||
void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2D &toPos)
|
||||
void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2d &toPos)
|
||||
{
|
||||
// are we in edit?
|
||||
if (!edit)
|
||||
|
@ -1227,7 +1227,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2D &toPo
|
|||
angle = (startangle + endangle)/2;
|
||||
}
|
||||
else {
|
||||
Base::Vector3d tmpDir = Base::Vector3d(toPos.fX, toPos.fY, 0) - p1;
|
||||
Base::Vector3d tmpDir = Base::Vector3d(toPos.x, toPos.y, 0) - p1;
|
||||
angle = atan2(tmpDir.y, tmpDir.x);
|
||||
}
|
||||
p2 = p1 + radius * Base::Vector3d(cos(angle),sin(angle),0.);
|
||||
|
@ -1236,7 +1236,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2D &toPo
|
|||
const Part::GeomCircle *circle = static_cast<const Part::GeomCircle *>(geo);
|
||||
double radius = circle->getRadius();
|
||||
p1 = circle->getCenter();
|
||||
Base::Vector3d tmpDir = Base::Vector3d(toPos.fX, toPos.fY, 0) - p1;
|
||||
Base::Vector3d tmpDir = Base::Vector3d(toPos.x, toPos.y, 0) - p1;
|
||||
double angle = atan2(tmpDir.y, tmpDir.x);
|
||||
p2 = p1 + radius * Base::Vector3d(cos(angle),sin(angle),0.);
|
||||
}
|
||||
|
@ -1245,7 +1245,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2D &toPo
|
|||
} else
|
||||
return;
|
||||
|
||||
Base::Vector3d vec = Base::Vector3d(toPos.fX, toPos.fY, 0) - p2;
|
||||
Base::Vector3d vec = Base::Vector3d(toPos.x, toPos.y, 0) - p2;
|
||||
|
||||
Base::Vector3d dir;
|
||||
if (Constr->Type == Distance || Constr->Type == Radius)
|
||||
|
@ -1263,7 +1263,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2D &toPo
|
|||
Constr->LabelDistance = vec.x * norm.x + vec.y * norm.y;
|
||||
if (Constr->Type == Distance ||
|
||||
Constr->Type == DistanceX || Constr->Type == DistanceY) {
|
||||
vec = Base::Vector3d(toPos.fX, toPos.fY, 0) - (p2 + p1) / 2;
|
||||
vec = Base::Vector3d(toPos.x, toPos.y, 0) - (p2 + p1) / 2;
|
||||
Constr->LabelPosition = vec.x * dir.x + vec.y * dir.y;
|
||||
}
|
||||
}
|
||||
|
@ -1325,7 +1325,7 @@ void ViewProviderSketch::moveConstraint(int constNum, const Base::Vector2D &toPo
|
|||
} else
|
||||
return;
|
||||
|
||||
Base::Vector3d vec = Base::Vector3d(toPos.fX, toPos.fY, 0) - p0;
|
||||
Base::Vector3d vec = Base::Vector3d(toPos.x, toPos.y, 0) - p0;
|
||||
Constr->LabelDistance = vec.Length()/2;
|
||||
}
|
||||
|
||||
|
@ -1872,11 +1872,11 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
|||
std::vector<SbVec2f> corners = viewer->getGLPolygon(corners0);
|
||||
|
||||
// all calculations with polygon and proj are in dimensionless [0 1] screen coordinates
|
||||
Base::Polygon2D polygon;
|
||||
polygon.Add(Base::Vector2D(corners[0].getValue()[0], corners[0].getValue()[1]));
|
||||
polygon.Add(Base::Vector2D(corners[0].getValue()[0], corners[1].getValue()[1]));
|
||||
polygon.Add(Base::Vector2D(corners[1].getValue()[0], corners[1].getValue()[1]));
|
||||
polygon.Add(Base::Vector2D(corners[1].getValue()[0], corners[0].getValue()[1]));
|
||||
Base::Polygon2d polygon;
|
||||
polygon.Add(Base::Vector2d(corners[0].getValue()[0], corners[0].getValue()[1]));
|
||||
polygon.Add(Base::Vector2d(corners[0].getValue()[0], corners[1].getValue()[1]));
|
||||
polygon.Add(Base::Vector2d(corners[1].getValue()[0], corners[1].getValue()[1]));
|
||||
polygon.Add(Base::Vector2d(corners[1].getValue()[0], corners[0].getValue()[1]));
|
||||
|
||||
Gui::ViewVolumeProjection proj(viewer->getSoRenderManager()->getCamera()->getViewVolume());
|
||||
|
||||
|
@ -1908,7 +1908,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
|||
pnt0 = proj(pnt0);
|
||||
VertexId += 1;
|
||||
|
||||
if (polygon.Contains(Base::Vector2D(pnt0.x, pnt0.y))) {
|
||||
if (polygon.Contains(Base::Vector2d(pnt0.x, pnt0.y))) {
|
||||
std::stringstream ss;
|
||||
ss << "Vertex" << VertexId + 1;
|
||||
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
|
||||
|
@ -1923,8 +1923,8 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
|||
pnt2 = proj(pnt2);
|
||||
VertexId += 2;
|
||||
|
||||
bool pnt1Inside = polygon.Contains(Base::Vector2D(pnt1.x, pnt1.y));
|
||||
bool pnt2Inside = polygon.Contains(Base::Vector2D(pnt2.x, pnt2.y));
|
||||
bool pnt1Inside = polygon.Contains(Base::Vector2d(pnt1.x, pnt1.y));
|
||||
bool pnt2Inside = polygon.Contains(Base::Vector2d(pnt2.x, pnt2.y));
|
||||
if (pnt1Inside) {
|
||||
std::stringstream ss;
|
||||
ss << "Vertex" << VertexId;
|
||||
|
@ -1952,7 +1952,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
|||
Plm.multVec(pnt0, pnt0);
|
||||
pnt0 = proj(pnt0);
|
||||
|
||||
if (polygon.Contains(Base::Vector2D(pnt0.x, pnt0.y))) {
|
||||
if (polygon.Contains(Base::Vector2d(pnt0.x, pnt0.y))) {
|
||||
std::stringstream ss;
|
||||
ss << "Vertex" << VertexId + 1;
|
||||
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
|
||||
|
@ -1972,7 +1972,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
|||
0.f);
|
||||
Plm.multVec(pnt, pnt);
|
||||
pnt = proj(pnt);
|
||||
if (!polygon.Contains(Base::Vector2D(pnt.x, pnt.y))) {
|
||||
if (!polygon.Contains(Base::Vector2d(pnt.x, pnt.y))) {
|
||||
bpolyInside = false;
|
||||
break;
|
||||
}
|
||||
|
@ -1994,7 +1994,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
|||
Plm.multVec(pnt0, pnt0);
|
||||
pnt0 = proj(pnt0);
|
||||
|
||||
if (polygon.Contains(Base::Vector2D(pnt0.x, pnt0.y))) {
|
||||
if (polygon.Contains(Base::Vector2d(pnt0.x, pnt0.y))) {
|
||||
std::stringstream ss;
|
||||
ss << "Vertex" << VertexId + 1;
|
||||
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
|
||||
|
@ -2015,7 +2015,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
|||
pnt = pnt0 + (cos(angle)*a)*majdir + sin(angle)*b*mindir;
|
||||
Plm.multVec(pnt, pnt);
|
||||
pnt = proj(pnt);
|
||||
if (!polygon.Contains(Base::Vector2D(pnt.x, pnt.y))) {
|
||||
if (!polygon.Contains(Base::Vector2d(pnt.x, pnt.y))) {
|
||||
bpolyInside = false;
|
||||
break;
|
||||
}
|
||||
|
@ -2045,21 +2045,21 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
|||
pnt1 = proj(pnt1);
|
||||
pnt2 = proj(pnt2);
|
||||
|
||||
bool pnt0Inside = polygon.Contains(Base::Vector2D(pnt0.x, pnt0.y));
|
||||
bool pnt0Inside = polygon.Contains(Base::Vector2d(pnt0.x, pnt0.y));
|
||||
if (pnt0Inside) {
|
||||
std::stringstream ss;
|
||||
ss << "Vertex" << VertexId - 1;
|
||||
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
|
||||
}
|
||||
|
||||
bool pnt1Inside = polygon.Contains(Base::Vector2D(pnt1.x, pnt1.y));
|
||||
bool pnt1Inside = polygon.Contains(Base::Vector2d(pnt1.x, pnt1.y));
|
||||
if (pnt1Inside) {
|
||||
std::stringstream ss;
|
||||
ss << "Vertex" << VertexId;
|
||||
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
|
||||
}
|
||||
|
||||
if (polygon.Contains(Base::Vector2D(pnt2.x, pnt2.y))) {
|
||||
if (polygon.Contains(Base::Vector2d(pnt2.x, pnt2.y))) {
|
||||
std::stringstream ss;
|
||||
ss << "Vertex" << VertexId + 1;
|
||||
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
|
||||
|
@ -2087,7 +2087,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
|||
0.f);
|
||||
Plm.multVec(pnt, pnt);
|
||||
pnt = proj(pnt);
|
||||
if (!polygon.Contains(Base::Vector2D(pnt.x, pnt.y))) {
|
||||
if (!polygon.Contains(Base::Vector2d(pnt.x, pnt.y))) {
|
||||
bpolyInside = false;
|
||||
break;
|
||||
}
|
||||
|
@ -2116,21 +2116,21 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
|||
pnt1 = proj(pnt1);
|
||||
pnt2 = proj(pnt2);
|
||||
|
||||
bool pnt0Inside = polygon.Contains(Base::Vector2D(pnt0.x, pnt0.y));
|
||||
bool pnt0Inside = polygon.Contains(Base::Vector2d(pnt0.x, pnt0.y));
|
||||
if (pnt0Inside) {
|
||||
std::stringstream ss;
|
||||
ss << "Vertex" << VertexId - 1;
|
||||
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
|
||||
}
|
||||
|
||||
bool pnt1Inside = polygon.Contains(Base::Vector2D(pnt1.x, pnt1.y));
|
||||
bool pnt1Inside = polygon.Contains(Base::Vector2d(pnt1.x, pnt1.y));
|
||||
if (pnt1Inside) {
|
||||
std::stringstream ss;
|
||||
ss << "Vertex" << VertexId;
|
||||
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
|
||||
}
|
||||
|
||||
if (polygon.Contains(Base::Vector2D(pnt2.x, pnt2.y))) {
|
||||
if (polygon.Contains(Base::Vector2d(pnt2.x, pnt2.y))) {
|
||||
std::stringstream ss;
|
||||
ss << "Vertex" << VertexId + 1;
|
||||
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), ss.str().c_str());
|
||||
|
@ -2159,7 +2159,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
|||
pnt = pnt0 + cos(angle)*a*majdir + sin(angle)*b*mindir;
|
||||
Plm.multVec(pnt, pnt);
|
||||
pnt = proj(pnt);
|
||||
if (!polygon.Contains(Base::Vector2D(pnt.x, pnt.y))) {
|
||||
if (!polygon.Contains(Base::Vector2d(pnt.x, pnt.y))) {
|
||||
bpolyInside = false;
|
||||
break;
|
||||
}
|
||||
|
@ -2181,7 +2181,7 @@ void ViewProviderSketch::doBoxSelection(const SbVec2s &startPos, const SbVec2s &
|
|||
}
|
||||
|
||||
pnt0 = proj(Plm.getPosition());
|
||||
if (polygon.Contains(Base::Vector2D(pnt0.x, pnt0.y)))
|
||||
if (polygon.Contains(Base::Vector2d(pnt0.x, pnt0.y)))
|
||||
Gui::Selection().addSelection(doc->getName(), sketchObject->getNameInDocument(), "RootPoint");
|
||||
}
|
||||
|
||||
|
@ -4108,7 +4108,7 @@ void ViewProviderSketch::rebuildConstraintsVisual(void)
|
|||
}
|
||||
}
|
||||
|
||||
void ViewProviderSketch::drawEdit(const std::vector<Base::Vector2D> &EditCurve)
|
||||
void ViewProviderSketch::drawEdit(const std::vector<Base::Vector2d> &EditCurve)
|
||||
{
|
||||
assert(edit);
|
||||
|
||||
|
@ -4118,8 +4118,8 @@ void ViewProviderSketch::drawEdit(const std::vector<Base::Vector2D> &EditCurve)
|
|||
int32_t *index = edit->EditCurveSet->numVertices.startEditing();
|
||||
|
||||
int i=0; // setting up the line set
|
||||
for (std::vector<Base::Vector2D>::const_iterator it = EditCurve.begin(); it != EditCurve.end(); ++it,i++)
|
||||
verts[i].setValue(it->fX,it->fY,zEdit);
|
||||
for (std::vector<Base::Vector2d>::const_iterator it = EditCurve.begin(); it != EditCurve.end(); ++it,i++)
|
||||
verts[i].setValue(it->x,it->y,zEdit);
|
||||
|
||||
index[0] = EditCurve.size();
|
||||
edit->EditCurvesCoordinate->point.finishEditing();
|
||||
|
@ -4720,18 +4720,18 @@ void ViewProviderSketch::unsetEditViewer(Gui::View3DInventorViewer* viewer)
|
|||
static_cast<Gui::SoFCUnifiedSelection*>(root)->selectionRole.setValue(true);
|
||||
}
|
||||
|
||||
void ViewProviderSketch::setPositionText(const Base::Vector2D &Pos, const SbString &text)
|
||||
void ViewProviderSketch::setPositionText(const Base::Vector2d &Pos, const SbString &text)
|
||||
{
|
||||
edit->textX->string = text;
|
||||
edit->textPos->translation = SbVec3f(Pos.fX,Pos.fY,zText);
|
||||
edit->textPos->translation = SbVec3f(Pos.x,Pos.y,zText);
|
||||
}
|
||||
|
||||
void ViewProviderSketch::setPositionText(const Base::Vector2D &Pos)
|
||||
void ViewProviderSketch::setPositionText(const Base::Vector2d &Pos)
|
||||
{
|
||||
SbString text;
|
||||
text.sprintf(" (%.1f,%.1f)", Pos.fX, Pos.fY);
|
||||
text.sprintf(" (%.1f,%.1f)", Pos.x, Pos.y);
|
||||
edit->textX->string = text;
|
||||
edit->textPos->translation = SbVec3f(Pos.fX,Pos.fY,zText);
|
||||
edit->textPos->translation = SbVec3f(Pos.x,Pos.y,zText);
|
||||
}
|
||||
|
||||
void ViewProviderSketch::resetPositionText(void)
|
||||
|
|
|
@ -113,7 +113,7 @@ public:
|
|||
void draw(bool temp=false);
|
||||
|
||||
/// draw the edit curve
|
||||
void drawEdit(const std::vector<Base::Vector2D> &EditCurve);
|
||||
void drawEdit(const std::vector<Base::Vector2d> &EditCurve);
|
||||
|
||||
/// Is the view provider selectable
|
||||
bool isSelectable(void) const;
|
||||
|
@ -189,7 +189,7 @@ public:
|
|||
void snapToGrid(double &x, double &y);
|
||||
|
||||
/// moves a selected constraint
|
||||
void moveConstraint(int constNum, const Base::Vector2D &toPos);
|
||||
void moveConstraint(int constNum, const Base::Vector2d &toPos);
|
||||
/// finds a free position for placing a constraint icon
|
||||
Base::Vector3d seekConstraintPosition(const Base::Vector3d &origPos,
|
||||
const Base::Vector3d &norm,
|
||||
|
@ -342,8 +342,8 @@ protected:
|
|||
SbVec3s getDisplayedSize(const SoImage *) const;
|
||||
//@}
|
||||
|
||||
void setPositionText(const Base::Vector2D &Pos, const SbString &txt);
|
||||
void setPositionText(const Base::Vector2D &Pos);
|
||||
void setPositionText(const Base::Vector2d &Pos, const SbString &txt);
|
||||
void setPositionText(const Base::Vector2d &Pos);
|
||||
void resetPositionText(void);
|
||||
|
||||
// handle preselection and selection of points
|
||||
|
|
|
@ -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>;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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[];
|
||||
|
|
|
@ -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 )
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue
Block a user