Code

remove many unnecessary to_2geom and from_2geom calls
[inkscape.git] / src / box3d.cpp
index 2a8d24167c4fdf9ff4f0cb99cd71ed693004b123..a517ea0a2cbb7c669eb6038c02909595764f5ca5 100644 (file)
@@ -321,7 +321,8 @@ box3d_position_set (SPBox3D *box)
     /* This draws the curve and calls requestDisplayUpdate() for each side (the latter is done in
        box3d_side_position_set() to avoid update conflicts with the parent box) */
     for (SPObject *child = sp_object_first_child(SP_OBJECT (box)); child != NULL; child = SP_OBJECT_NEXT(child) ) {
-        box3d_side_position_set (SP_BOX3D_SIDE (child));
+        if (SP_IS_BOX3D_SIDE(child))
+            box3d_side_position_set(SP_BOX3D_SIDE(child));
     }
 }
 
@@ -365,21 +366,22 @@ box3d_set_transform(SPItem *item, NR::Matrix const &xform)
     gdouble const sw = hypot(ret[0], ret[1]);
     gdouble const sh = hypot(ret[2], ret[3]);
 
-    SPItem *sideitem = NULL;
-    for (SPObject *side = sp_object_first_child(box); side != NULL; side = SP_OBJECT_NEXT(side)) {
-        sideitem = SP_ITEM(side);
+    for (SPObject *child = sp_object_first_child(box); child != NULL; child = SP_OBJECT_NEXT(child)) {
+        if (SP_IS_ITEM(child)) {
+            SPItem *childitem = SP_ITEM(child);
 
-        // Adjust stroke width
-        sp_item_adjust_stroke(sideitem, sqrt(fabs(sw * sh)));
+            // Adjust stroke width
+            sp_item_adjust_stroke(childitem, sqrt(fabs(sw * sh)));
 
-        // Adjust pattern fill
-        sp_item_adjust_pattern(sideitem, xform);
+            // Adjust pattern fill
+            sp_item_adjust_pattern(childitem, xform);
 
-        // Adjust gradient fill
-        sp_item_adjust_gradient(sideitem, xform);
+            // Adjust gradient fill
+            sp_item_adjust_gradient(childitem, xform);
 
-        // Adjust LPE
-        sp_item_adjust_livepatheffect(item, xform);
+            // Adjust LPE
+            sp_item_adjust_livepatheffect(childitem, xform);
+        }
     }
 
     return NR::identity();
@@ -407,7 +409,7 @@ box3d_get_corner_screen (SPBox3D const *box, guint id, bool item_coords) {
     if (!box3d_get_perspective(box)) {
         return NR::Point (NR_HUGE, NR_HUGE);
     }
-    NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (SP_ITEM(box))));
+    NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box)));
     if (item_coords) {
         return box3d_get_perspective(box)->tmat.image(proj_corner).affine() * i2d.inverse();
     } else {
@@ -431,7 +433,7 @@ box3d_get_center_screen (SPBox3D *box) {
     if (!box3d_get_perspective(box)) {
         return NR::Point (NR_HUGE, NR_HUGE);
     }
-    NR::Matrix const i2d (from_2geom(sp_item_i2d_affine (SP_ITEM(box))));
+    NR::Matrix const i2d (sp_item_i2d_affine (SP_ITEM(box)));
     return box3d_get_perspective(box)->tmat.image(proj_center).affine() * i2d.inverse();
 }
 
@@ -1148,8 +1150,9 @@ static std::map<int, Box3DSide *>
 box3d_get_sides (SPBox3D *box) {
     std::map<int, Box3DSide *> sides;
     for (SPObject *side = sp_object_first_child(box); side != NULL; side = SP_OBJECT_NEXT(side)) {
-        sides[Box3D::face_to_int(sp_repr_get_int_attribute(SP_OBJECT_REPR(side),
-                                                           "inkscape:box3dsidetype", -1))] = SP_BOX3D_SIDE(side);
+        if (SP_IS_BOX3D_SIDE(side))
+            sides[Box3D::face_to_int(sp_repr_get_int_attribute(SP_OBJECT_REPR(side),
+                                                               "inkscape:box3dsidetype", -1))] = SP_BOX3D_SIDE(side);
     }
     sides.erase(-1);
     return sides;
@@ -1405,8 +1408,8 @@ box3d_convert_to_group(SPBox3D *box) {
 
 static inline void
 box3d_push_back_corner_pair(SPBox3D *box, std::list<std::pair<Geom::Point, Geom::Point> > &pts, int c1, int c2) {
-    pts.push_back(std::make_pair(box3d_get_corner_screen(box, c1, false).to_2geom(),
-                                 box3d_get_corner_screen(box, c2, false).to_2geom()));
+    pts.push_back(std::make_pair(box3d_get_corner_screen(box, c1, false),
+                                 box3d_get_corner_screen(box, c2, false)));
 }
 
 void
@@ -1418,8 +1421,6 @@ box3d_convert_to_guides(SPItem *item) {
         return;
     }
 
-    SPDocument *doc = SP_OBJECT_DOCUMENT(box);
-
     std::list<std::pair<Geom::Point, Geom::Point> > pts;
 
     /* perspective lines in X direction */
@@ -1440,7 +1441,7 @@ box3d_convert_to_guides(SPItem *item) {
     box3d_push_back_corner_pair(box, pts, 2, 6);
     box3d_push_back_corner_pair(box, pts, 3, 7);
 
-    sp_guide_pt_pairs_to_guides(doc, pts);
+    sp_guide_pt_pairs_to_guides(inkscape_active_desktop(), pts);
 }
 
 /*