Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-05-29 03:53:28 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2012-05-29 03:53:28 +0400
commiteabf741a8d76aa9400a071c37227504378fc6315 (patch)
tree705e01ce1aaf4a4282aa3abb19d44933c48fb7b2 /source/blender/freestyle/intern/stroke
parentb6a9a953bc6aa7d81921a796e8ce1123fdedefc7 (diff)
Fix for the WithinImageBorderUP1D predicate not working with a ViewEdge such that
none of the SVertices are within the image boundary but an FEdge intersects with the image boundary. The problem was reported by edna through the BA Freestyle thread, with a .blend file for reproducing the bug. Thanks!
Diffstat (limited to 'source/blender/freestyle/intern/stroke')
-rwxr-xr-xsource/blender/freestyle/intern/stroke/Predicates1D.h57
1 files changed, 57 insertions, 0 deletions
diff --git a/source/blender/freestyle/intern/stroke/Predicates1D.h b/source/blender/freestyle/intern/stroke/Predicates1D.h
index 6461f6428ab..b1159a8332e 100755
--- a/source/blender/freestyle/intern/stroke/Predicates1D.h
+++ b/source/blender/freestyle/intern/stroke/Predicates1D.h
@@ -358,6 +358,63 @@ namespace Predicates1D {
}
};
+ // WithinImageBoundaryUP1D
+ /*! Returns true if the Interface1D is (partly) within the image boundary.
+ */
+ class WithinImageBoundaryUP1D: public UnaryPredicate1D
+ {
+ private:
+ real _xmin, _ymin, _xmax, _ymax;
+ public:
+ /*! Builds the Predicate.
+ * \param xmin
+ * The X lower bound of the image boundary.
+ * \param ymin
+ * The Y lower bound of the image boundary.
+ * \param xmax
+ * The X upper bound of the image boundary.
+ * \param ymax
+ * The Y upper bound of the image boundary.
+ */
+ WithinImageBoundaryUP1D(const real xmin, const real ymin, const real xmax, const real ymax) :
+ _xmin(xmin), _ymin(ymin), _xmax(xmax), _ymax(ymax) {}
+ /*! Returns the string "WithinImageBoundaryUP1D"*/
+ string getName() const {
+ return "WithinImageBoundaryUP1D";
+ }
+ /*! The () operator. */
+ int operator()(Interface1D& inter) {
+ // 1st pass: check if a point is within the image boundary.
+ Interface0DIterator it = inter.verticesBegin(), itend = inter.verticesEnd();
+ for (; it != itend; ++it) {
+ real x = (*it).getProjectedX();
+ real y = (*it).getProjectedY();
+ if (_xmin <= x && x <= _xmax && _ymin <= y && y <= _ymax) {
+ result = true;
+ return 0;
+ }
+ }
+ // 2nd pass: check if a line segment intersects with the image boundary.
+ it = inter.verticesBegin();
+ if (it != itend) {
+ Vec2r pmin(_xmin, _ymin);
+ Vec2r pmax(_xmax, _ymax);
+ Vec2r prev((*it).getPoint2D());
+ ++it;
+ for (; it != itend; ++it) {
+ Vec2r p((*it).getPoint2D());
+ if (GeomUtils::intersect2dSeg2dArea (pmin, pmax, prev, p)) {
+ result = true;
+ return 0;
+ }
+ prev = p;
+ }
+ }
+ result = false;
+ return 0;
+ }
+ };
+
//
// Binary Predicates definitions
//