summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 880bb64)
raw | patch | inline | side by side (parent: 880bb64)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Mon, 7 Jul 2008 19:31:39 +0000 (19:31 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Mon, 7 Jul 2008 19:31:39 +0000 (19:31 +0000) |
src/display/curve.cpp | patch | blob | history | |
src/display/curve.h | patch | blob | history |
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index 107dbca3a2ec0c6d12738ba3b9ec872a86f46846..68cb1c900a1c5294ea2760b41c6453ad0712ed12 100644 (file)
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
static unsigned sp_bpath_length(NArtBpath const bpath[]);
static bool sp_bpath_closed(NArtBpath const bpath[]);
-#define NO_CHECKS // define this to disable the checking for unequal paths in SPCurve, improves performance by a lot!
-
-
-#ifndef NO_CHECKS
-static void debug_out( char const * text, Geom::PathVector const & pathv) {
- char * str = sp_svg_write_path(pathv);
- g_message("%s : %s", text, str);
- g_free(str);
-}
-#endif
-
-#ifndef NO_CHECKS
-static void debug_out( char const * text, NArtBpath const * bpath) {
- char * str = sp_svg_write_path(bpath);
- g_message("%s : %s", text, str);
- g_free(str);
-}
-#endif
-
-#ifndef NO_CHECKS
-void SPCurve::debug_check( char const * text, SPCurve const * curve) {
- char * pathv_str = sp_svg_write_path(curve->_pathv);
- char * bpath_str = sp_svg_write_path(curve->_bpath);
- if ( strcmp(pathv_str, bpath_str) ) {
- g_message("%s : unequal paths", text);
- g_message("bpath : %s", bpath_str);
- g_message("pathv : %s", pathv_str);
- }
- g_free(pathv_str);
- g_free(bpath_str);
-#else
-void SPCurve::debug_check( char const *, SPCurve const *) {
-#endif
-}
-
-#ifndef NO_CHECKS
-void SPCurve::debug_check( char const * text, bool a) {
- if ( !a ) {
- g_message("%s : bool fail", text);
- }
-#else
-void SPCurve::debug_check( char const *, bool) {
-#endif
-}
-
/* Constructors */
/**
_bpath->code = NR_END;
_pathv.clear();
-
- debug_check("SPCurve::SPCurve(guint length)", this);
}
SPCurve::SPCurve(Geom::PathVector const& pathv)
break;
_substart = i;
_closed = sp_bpath_closed(_bpath);
-
- debug_check("SPCurve::SPCurve(Geom::PathVector const& pathv)", this);
}
// * 2GEOMproof
curve->_pathv = BPath_to_2GeomPath(curve->_bpath);
- debug_check("SPCurve::new_from_foreign_bpath", curve);
-
return curve;
}
SPCurve *curve = SPCurve::new_from_foreign_bpath(bpath);
g_free(bpath);
- debug_check("SPCurve::new_from_bpath", curve);
-
return curve;
}
}
c->closepath_current();
- debug_check("SPCurve::new_from_rect", c);
-
return c;
}
break;
_substart = i;
_closed = sp_bpath_closed(_bpath);
-
- debug_check("SPCurve::set_pathvector", this);
}
/**
NArtBpath const *
SPCurve::get_bpath() const
{
- debug_check("SPCurve::get_bpath", this);
return _bpath;
};
Geom::PathVector const &
SPCurve::get_pathvector() const
{
- debug_check("SPCurve::get_pathvector", this);
return _pathv;
}
new_curve->_pathv.insert( new_curve->_pathv.end(), c->get_pathvector().begin(), c->get_pathvector().end() );
}
- debug_check("SPCurve::concat", new_curve);
-
return new_curve;
}
}
}
-/**
- * Transform all paths in curve using matrix.
- * 2GEOMified, can be deleted when completely 2geom
- */
+
void
SPCurve::transform(NR::Matrix const &m)
{
- tmpl_curve_transform<NR::Matrix>(this, m);
-
- _pathv = _pathv * to_2geom(m);
-
- debug_check("SPCurve::transform(NR::Matrix const &m)", this);
-}
+ transform(to_2geom(m));
+};
+
/**
* Transform all paths in curve using matrix.
*/
tmpl_curve_transform<NR::Matrix>(this, from_2geom(m));
_pathv = _pathv * m;
-
- debug_check("SPCurve::transform(Geom::Matrix const &m)", this);
-}
-
-/**
- * Transform all paths in curve using NR::translate.
- * 2GEOMified, can be deleted when completely 2geom
- */
-void
-SPCurve::transform(NR::translate const &m)
-{
- tmpl_curve_transform<NR::translate>(this, m);
-
- _pathv = _pathv * to_2geom(m);
-
- debug_check("SPCurve::transform(NR::translate const &m)", this);
}
/**
_closed = false;
_pathv.clear();
-
- debug_check("SPCurve::reset", this);
}
/* Several consecutive movetos are ALLOWED */
_movePos = p;
_pathv.push_back( Geom::Path() ); // for some reason Geom::Path(p) does not work...
_pathv.back().start(to_2geom(p));
-
- // the output is not the same. This is because SPCurve *incorrectly* coaslesces multiple moveto's into one for NArtBpath.
-// debug_check("SPCurve::moveto", this);
}
/**
_end++;
_pathv.back().appendNew<Geom::LineSegment>( Geom::Point(x,y) );
}
-
- debug_check("SPCurve::lineto", this);
}
/**
@@ -718,8 +628,6 @@ SPCurve::curveto(gdouble x0, gdouble y0, gdouble x1, gdouble y1, gdouble x2, gdo
if (_pathv.empty()) g_message("leeg");
else _pathv.back().appendNew<Geom::CubicBezier>( Geom::Point(x0,y0), Geom::Point(x1,y1), Geom::Point(x2,y2) );
}
-
- debug_check("SPCurve::curveto", this);
}
/**
}
_hascpt = false;
-
- debug_check("SPCurve::closepath", this);
}
/** Like SPCurve::closepath() but sets the end point of the current
_hascpt = false;
_moving = false;
-
- debug_check("SPCurve::closepath_current", this);
}
/**
Geom::Curve const& back = _pathv.back().back_default();
Geom::Point p = back.initialPoint();
-
- debug_check("SPCurve::penultimate_point", bpath->c(3) == from_2geom(p) );
return from_2geom(p);
}
}
new_curve->_pathv = Geom::reverse_paths_and_order(_pathv);
-
- debug_check("SPCurve::create_reverse", new_curve);
}
/**
closepath();
}
- debug_check("SPCurve::append", this);
-
/* 2GEOM code when code above is removed:
if (use_lineto) {
Geom::PathVector::const_iterator it = curve2->_pathv.begin();
return this;
}
- debug_check("SPCurve::append_continuous 11", this);
-
NArtBpath const *be = last_bpath();
if (be) {
NArtBpath const *bs = c1->get_bpath();
append(c1, TRUE);
}
- debug_check("SPCurve::append_continuous", this);
-
return this;
}
_pathv.back().erase_last();
_pathv.back().close(false);
}
-
- debug_check("SPCurve::backspace", this);
}
/* Private methods */
Geom::Piecewise<Geom::D2<Geom::SBasis> > offsetpath = Geom::sectionize( Geom::D2<Geom::Piecewise<Geom::SBasis> >(offsetx, offsety) );
pwd2 += offsetpath;
_pathv = Geom::path_from_piecewise( pwd2, 0.001 );
-
- debug_check("SPCurve::stretch_endpoints", this);
}
/**
_pathv.front().setInitial(to_2geom(new_p0));
_pathv.front().setFinal(to_2geom(new_p1));
-
- debug_check("SPCurve::move_endpoints", this);
}
/**
nr++; // count last node (this works also for closed paths because although they don't have a 'last node', they do have an extra segment
}
- debug_check("SPCurve::nodes_in_path", r == (gint)nr);
-
return r;
}
newcube.setPoint(2, newcube[2] + p);
_pathv.back().replace( --_pathv.back().end(), newcube );
}
-
- debug_check("SPCurve::last_point_additive_move", this);
}
/*
diff --git a/src/display/curve.h b/src/display/curve.h
index 7dee3dbf10316c62020759f67dcc47e52c6a13d7..39720e40195157e00e51630e75d57c79fc0167ef 100644 (file)
--- a/src/display/curve.h
+++ b/src/display/curve.h
SPCurve * copy() const;
GSList * split() const;
+ void transform(NR::Matrix const &m);
void transform(Geom::Matrix const &m);
- void transform(NR::Matrix const &);
- void transform(NR::translate const &);
void stretch_endpoints(NR::Point const &, NR::Point const &);
void move_endpoints(NR::Point const &, NR::Point const &);
void last_point_additive_move(Geom::Point const & p);
//friends:
friend double sp_curve_distance_including_space(SPCurve const *const curve, double seg2len[]);
friend double sp_curve_nonzero_distance_including_space(SPCurve const *const curve, double seg2len[]);
- template<class M> friend void tmpl_curve_transform(SPCurve *const curve, M const &m);
- // this function is the only one who needs read access to _movePos and _posSet
- friend void sp_polygon_set(SPObject *object, unsigned int key, const gchar *value);
-
- static void debug_check( char const * text, SPCurve const * curve);
- static void debug_check( char const * text, bool a);
+ template<class M> friend void tmpl_curve_transform(SPCurve * curve, M const &m);
};
#define SP_CURVE_LENGTH(c) (((SPCurve const *)(c))->get_length())
#define SP_CURVE_BPATH(c) (((SPCurve const *)(c))->get_bpath())
-#define SP_CURVE_SEGMENT(c,i) (((SPCurve const *)(c))->get_bpath() + (i))
+
#endif /* !SEEN_DISPLAY_CURVE_H */