+ fix mesh trimming

This commit is contained in:
wmayer
2014-07-16 18:21:30 +02:00
parent fe9e77d661
commit 050bab79f0
3 changed files with 25 additions and 5 deletions

View File

@@ -431,3 +431,19 @@ void Polygon2D::Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rc
rclResultPolygonList.push_back(clResultPolygon);
}
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);
if (clLine.Intersect(rclV, eps))
return true;
}
return false;
}

View File

@@ -154,7 +154,8 @@ public:
// misc
BoundBox2D CalcBoundBox (void) const;
bool Contains (const Vector2D &rclV) const;
void Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rclResultPolygonList) const;
void Intersect (const Polygon2D &rclPolygon, std::list<Polygon2D> &rclResultPolygonList) const;
bool Intersect (const Vector2D &rclV, double eps) const;
private:
std::vector<Vector2D> _aclVct;