Code

use 2geom method to calc boundingbox of shape
authorjohanengelen <johanengelen@users.sourceforge.net>
Mon, 16 Jun 2008 21:25:19 +0000 (21:25 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Mon, 16 Jun 2008 21:25:19 +0000 (21:25 +0000)
src/helper/geom.cpp
src/helper/geom.h
src/sp-shape.cpp

index 3917218bbbe0348232710aaf7e1bdcb9ab0f11e1..8a32386fc91f034371be504ccc81ab234da235fd 100644 (file)
@@ -11,6 +11,8 @@
  * Released under GNU GPL\r
  */\r
 \r
+#include "helper/geom.h"\r
+\r
 #include <2geom/pathvector.h>\r
 #include <2geom/transforms.h>\r
  \r
@@ -20,6 +22,11 @@ bounds_fast_transformed(Geom::PathVector const & pv, Geom::Matrix const & t)
     return Geom::bounds_fast(pv * t);\r
 }\r
 \r
+Geom::Rect\r
+bounds_exact_transformed(Geom::PathVector const & pv, Geom::Matrix const & t)\r
+{\r
+    return Geom::bounds_exact(pv * t);\r
+}\r
 \r
 /*\r
   Local Variables:\r
index fbc3f2c00c8455d7b92bf4a27a89816734e787ff..d7548756ad3fed5990aedb2ffe25497679e91544 100644 (file)
@@ -15,6 +15,7 @@
 #include <2geom/forward.h>\r
 \r
 Geom::Rect bounds_fast_transformed(Geom::PathVector const & pv, Geom::Matrix const & t);\r
+Geom::Rect bounds_exact_transformed(Geom::PathVector const & pv, Geom::Matrix const & t);\r
 \r
 #endif  // INKSCAPE_HELPER_GEOM_H\r
 \r
index 4ae2a98f878e5cd3027fc6a985f18e9a0bcce9f6..efed9209b332e62a710e167f81b4efb4e538032a 100644 (file)
@@ -21,6 +21,8 @@
 #include <libnr/nr-matrix-ops.h>
 #include <libnr/nr-matrix-translate-ops.h>
 #include <libnr/nr-scale-matrix-ops.h>
+#include <2geom/rect.h>
+#include "helper/geom.h"
 
 #include <sigc++/functors/ptr_fun.h>
 #include <sigc++/adaptors/bind.h>
@@ -637,14 +639,12 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr
     if (shape->curve) {
 
         NRRect  cbbox;
-        const_NRBPath bp;
-
-        bp.path = SP_CURVE_BPATH (shape->curve);
-
-        cbbox.x0 = cbbox.y0 = NR_HUGE;
-        cbbox.x1 = cbbox.y1 = -NR_HUGE;
 
-        nr_path_matrix_bbox_union(&bp, transform, &cbbox);
+        Geom::Rect geombbox = bounds_exact_transformed(shape->curve->get_pathvector(), to_2geom(transform));
+        cbbox.x0 = geombbox[0][0];
+        cbbox.y0 = geombbox[1][0];
+        cbbox.x1 = geombbox[0][1];
+        cbbox.y1 = geombbox[1][1];
 
         if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX) {