Base: misc patches
Convenience macros/function (in Interpreter.h) * FC_PY_GetObject/Callable(), look for callables in a python object, which will be used in future patch to improve performance in various python observer/features. * pyCall(WithKeywords)(), helper function to invoke the callable Matrix4D: * hasScale(), check if there is any scale in the transformation. If so, further check if the scale is uniform or not. This will be used in future patch for Part::TopoShape to decide which type of transform to apply. Placement: * translate/rotate(), new convenience API Rotation: * isSame/multiVec(), new convenience API Polygon2d: * Intersect(), GetCenter(), new convenience API. FlagToggler: * New class for exception safe flag toggling, similar to StateLocker but with template (actually, FlagToggler is added earlier by me). BitsetLocker: * New class for exception manipulation of a std::bitset variable.
This commit is contained in:
@@ -431,6 +431,37 @@ void Polygon2d::Intersect (const Polygon2d &rclPolygon, std::list<Polygon2d> &rc
|
||||
rclResultPolygonList.push_back(clResultPolygon);
|
||||
}
|
||||
|
||||
bool Polygon2d::Intersect (const Polygon2d &other) const {
|
||||
if(other.GetCtVectors()<2 || GetCtVectors() < 2)
|
||||
return false;
|
||||
|
||||
for(auto &v : _aclVct) {
|
||||
if(other.Contains(v))
|
||||
return true;
|
||||
}
|
||||
|
||||
if(Contains(other[0]))
|
||||
return true;
|
||||
|
||||
for(size_t j=1; j<other.GetCtVectors(); ++j) {
|
||||
auto &v0 = other[j-1];
|
||||
auto &v1 = other[j];
|
||||
|
||||
if(Contains(v1))
|
||||
return true;
|
||||
|
||||
Line2d line(v0, v1);
|
||||
for(size_t i=0; i<GetCtVectors(); ++i) {
|
||||
Line2d line2(At(i), At((i+1)%GetCtVectors()));
|
||||
Vector2d v;
|
||||
if(line.IntersectAndContain(line2, v))
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool Polygon2d::Intersect (const Vector2d &rclV, double eps) const
|
||||
{
|
||||
if (_aclVct.size() < 2)
|
||||
|
||||
Reference in New Issue
Block a user