David's final changes: more profiler features, fixes.
[ipdf/code.git] / src / bezier.h
index 298bcf3..77429cf 100644 (file)
@@ -20,7 +20,7 @@ namespace IPDF
        
        extern std::vector<BReal> SolveQuadratic(const BReal & a, const BReal & b, const BReal & c, const BReal & min = 0, const BReal & max = 1);
 
        
        extern std::vector<BReal> SolveQuadratic(const BReal & a, const BReal & b, const BReal & c, const BReal & min = 0, const BReal & max = 1);
 
-       extern std::vector<BReal> SolveCubic(const BReal & a, const BReal & b, const BReal & c, const BReal & d, const BReal & min = 0, const BReal & max = 1, const BReal & delta = 1e-5);
+       extern std::vector<BReal> SolveCubic(const BReal & a, const BReal & b, const BReal & c, const BReal & d, const BReal & min = 0, const BReal & max = 1, const BReal & delta = 1e-9);
 
        /** A _cubic_ bezier. **/
        struct Bezier
 
        /** A _cubic_ bezier. **/
        struct Bezier
@@ -258,8 +258,8 @@ namespace IPDF
                        // Find points of intersection with the rectangle.
                        Debug("Clipping Bezier to BRect %s", r.Str().c_str());
 
                        // Find points of intersection with the rectangle.
                        Debug("Clipping Bezier to BRect %s", r.Str().c_str());
 
-                       bool isVerticalLine = (x0 == x1 && x1 == x2 && x2 == x3);
-                       bool isHorizontalLine = (y0 == y1 && y1 == y2 && y2 == y3);
+                       bool isVerticalLine = false;//(x0 == x1 && x1 == x2 && x2 == x3);
+                       bool isHorizontalLine = false;//(y0 == y1 && y1 == y2 && y2 == y3);
 
                        // Find its roots.
                        
 
                        // Find its roots.
                        
@@ -269,11 +269,13 @@ namespace IPDF
                        {
                                std::vector<BReal> x_intersection = SolveXParam(r.x);
                                intersection.insert(intersection.end(), x_intersection.begin(), x_intersection.end());
                        {
                                std::vector<BReal> x_intersection = SolveXParam(r.x);
                                intersection.insert(intersection.end(), x_intersection.begin(), x_intersection.end());
+                               Debug("Number of top intersections: %d", x_intersection.size());
 
                                // And for the other side.
 
                                std::vector<BReal> x_intersection_pt2 = SolveXParam(r.x + r.w);
                                intersection.insert(intersection.end(), x_intersection_pt2.begin(), x_intersection_pt2.end());
 
                                // And for the other side.
 
                                std::vector<BReal> x_intersection_pt2 = SolveXParam(r.x + r.w);
                                intersection.insert(intersection.end(), x_intersection_pt2.begin(), x_intersection_pt2.end());
+                               Debug("Number of bottom intersections: %d", x_intersection_pt2.size());
                        }
 
                        // Find its roots.
                        }
 
                        // Find its roots.
@@ -281,15 +283,18 @@ namespace IPDF
                        {
                                std::vector<BReal> y_intersection = SolveYParam(r.y);
                                intersection.insert(intersection.end(), y_intersection.begin(), y_intersection.end());
                        {
                                std::vector<BReal> y_intersection = SolveYParam(r.y);
                                intersection.insert(intersection.end(), y_intersection.begin(), y_intersection.end());
+                               Debug("Number of left intersections: %d", y_intersection.size());
 
                                std::vector<BReal> y_intersection_pt2 = SolveYParam(r.y+r.h);
                                intersection.insert(intersection.end(), y_intersection_pt2.begin(), y_intersection_pt2.end());
 
                                std::vector<BReal> y_intersection_pt2 = SolveYParam(r.y+r.h);
                                intersection.insert(intersection.end(), y_intersection_pt2.begin(), y_intersection_pt2.end());
+                               Debug("Number of right intersections: %d", y_intersection_pt2.size());
                        }
 
                        // Merge and sort.
                        intersection.push_back(BReal(0));
                        intersection.push_back(BReal(1));
                        std::sort(intersection.begin(), intersection.end());
                        }
 
                        // Merge and sort.
                        intersection.push_back(BReal(0));
                        intersection.push_back(BReal(1));
                        std::sort(intersection.begin(), intersection.end());
+                       Debug("Number of intersections: %d", intersection.size());
                        
                        std::vector<Bezier> all_beziers;
                        if (intersection.size() <= 2)
                        
                        std::vector<Bezier> all_beziers;
                        if (intersection.size() <= 2)

UCC git Repository :: git.ucc.asn.au