summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7696129)
raw | patch | inline | side by side (parent: 7696129)
author | verbalshadow <verbalshadow@users.sourceforge.net> | |
Sun, 28 Dec 2008 22:44:35 +0000 (22:44 +0000) | ||
committer | verbalshadow <verbalshadow@users.sourceforge.net> | |
Sun, 28 Dec 2008 22:44:35 +0000 (22:44 +0000) |
51 files changed:
index 517f2dac9b3675f7735adde910f27e89daa4c6e7..978ecc6af950709f1f54fe02a296e9a84ed41218 100644 (file)
Geom::OptRect area = SVGElem->getBounds(identity);
NRRectL rect;
- rect.x0=area->min()[NR::X];
- rect.x1=area->max()[NR::X];
- rect.y0=area->min()[NR::Y];
- rect.y1=area->max()[NR::Y];
+ rect.x0=area->min()[Geom::X];
+ rect.x1=area->max()[Geom::X];
+ rect.y0=area->min()[Geom::Y];
+ rect.y1=area->max()[Geom::Y];
width = (int)(rect.x1-rect.x0);
height = (int)(rect.y1-rect.y0);
index 257e6f7dc9947d853158c3be03bae2b5917554fa..bd4f82096765f7dd83e23c4b5750be1e46f2dfb8 100644 (file)
// convert to point
dc->ang = Geom::Point (cos (new_ang), sin (new_ang));
-// g_print ("force %g acc %g vel_max %g vel %g a1 %g a2 %g new_ang %g\n", NR::L2(force), NR::L2(dc->acc), dc->vel_max, NR::L2(dc->vel), a1, a2, new_ang);
+// g_print ("force %g acc %g vel_max %g vel %g a1 %g a2 %g new_ang %g\n", Geom::L2(force), Geom::L2(dc->acc), dc->vel_max, Geom::L2(dc->vel), a1, a2, new_ang);
/* Apply drag */
dc->vel *= 1.0 - drag;
) {
// We are NOT attracted to the guide!
- //g_print ("\nlast_nearest %g %g nearest %g %g pointer %g %g pos %d %g\n", dc->last_nearest[NR::X], dc->last_nearest[NR::Y], nearest[NR::X], nearest[NR::Y], pointer[NR::X], pointer[NR::Y], position->piece, position->t);
+ //g_print ("\nlast_nearest %g %g nearest %g %g pointer %g %g pos %d %g\n", dc->last_nearest[Geom::X], dc->last_nearest[Geom::Y], nearest[Geom::X], nearest[Geom::Y], pointer[Geom::X], pointer[Geom::Y], position->piece, position->t);
// Remember hatch_escaped so we don't get
// attracted again until the end of this stroke
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index 08be1a849266d9b91670792394454dbb55671cec..a24f45c849c5b90bf444a39d96bc2c9b6ef2c7f1 100644 (file)
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
Geom::Point end = sp_item_gradient_get_coords(item, POINT_LG_END, 0, fill_or_stroke);
Geom::Point nearest = snap_vector_midpoint (mouse_p, begin, end, 0);
- double dist_screen = NR::L2 (mouse_p - nearest);
+ double dist_screen = Geom::L2 (mouse_p - nearest);
if ( dist_screen < tolerance ) {
// add the knot
offset = get_offset_between_points(nearest, begin, end);
Geom::Point begin = sp_item_gradient_get_coords(item, POINT_RG_CENTER, 0, fill_or_stroke);
Geom::Point end = sp_item_gradient_get_coords(item, POINT_RG_R1, 0, fill_or_stroke);
Geom::Point nearest = snap_vector_midpoint (mouse_p, begin, end, 0);
- double dist_screen = NR::L2 (mouse_p - nearest);
+ double dist_screen = Geom::L2 (mouse_p - nearest);
if ( dist_screen < tolerance ) {
offset = get_offset_between_points(nearest, begin, end);
addknot = true;
end = sp_item_gradient_get_coords(item, POINT_RG_R2, 0, fill_or_stroke);
nearest = snap_vector_midpoint (mouse_p, begin, end, 0);
- dist_screen = NR::L2 (mouse_p - nearest);
+ dist_screen = Geom::L2 (mouse_p - nearest);
if ( dist_screen < tolerance ) {
offset = get_offset_between_points(nearest, begin, end);
addknot = true;
for (GList *i = draggers; i != NULL; i = i->next) { // for all draggables of dragger
GrDragger *d = (GrDragger *) i->data;
- if (NR::L2(p - d->point)*desktop->current_zoom() < 5) {
+ if (Geom::L2(p - d->point)*desktop->current_zoom() < 5) {
SPCSSAttr *stop = sp_repr_css_attr_new ();
sp_repr_css_set_property (stop, "stop-color", c);
sp_repr_css_set_property (stop, "stop-opacity", "1");
for (GSList *l = lines; (l != NULL) && (!over_line); l = l->next) {
line = (SPCtrlLine*) l->data;
Geom::Point nearest = snap_vector_midpoint (p, line->s, line->e, 0);
- double dist_screen = NR::L2 (p - nearest) * desktop->current_zoom();
+ double dist_screen = Geom::L2 (p - nearest) * desktop->current_zoom();
if (line->item && dist_screen < 5) {
SPStop *stop = addStopNearPoint (line->item, p, 5/desktop->current_zoom());
if (stop) {
@@ -565,7 +565,7 @@ gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gp
// without Shift or Ctrl; see if we need to snap to another dragger
for (GList *di = dragger->parent->draggers; di != NULL; di = di->next) {
GrDragger *d_new = (GrDragger *) di->data;
- if (dragger->mayMerge(d_new) && NR::L2 (d_new->point - p) < snap_dist) {
+ if (dragger->mayMerge(d_new) && Geom::L2 (d_new->point - p) < snap_dist) {
// Merge draggers:
for (GSList const* i = dragger->draggables; i != NULL; i = i->next) { // for all draggables of dragger
@@ -683,7 +683,7 @@ gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gp
if (dr_snap.isFinite()) {
if (state & GDK_MOD1_MASK) {
// with Alt, snap to the original angle and its perpendiculars
- snap_vector = get_snap_vector (p, dr_snap, M_PI/2, NR::atan2 (dragger->point_original - dr_snap));
+ snap_vector = get_snap_vector (p, dr_snap, M_PI/2, Geom::atan2 (dragger->point_original - dr_snap));
} else {
// with Ctrl, snap to M_PI/snaps
snap_vector = get_snap_vector (p, dr_snap, M_PI/snaps, 0);
@@ -698,7 +698,7 @@ gr_knot_moved_handler(SPKnot *knot, Geom::Point const &ppointer, guint state, gp
Geom::Point move(9999, 9999);
for (GSList const *i = snap_vectors; i != NULL; i = i->next) {
Geom::Point *snap_vector = (Geom::Point *) i->data;
- if (NR::L2(*snap_vector) < NR::L2(move))
+ if (Geom::L2(*snap_vector) < Geom::L2(move))
move = *snap_vector;
}
if (move[Geom::X] < 9999) {
@@ -846,11 +846,11 @@ gr_knot_moved_midpoint_handler(SPKnot */*knot*/, Geom::Point const &ppointer, gu
if (state & GDK_MOD1_MASK) {
// FIXME: unify all these profiles (here, in nodepath, in tweak) in one place
double alpha = 1.0;
- if (NR::L2(drg->point - dragger->point) + NR::L2(drg->point - begin) - 1e-3 > NR::L2(dragger->point - begin)) { // drg is on the end side from dragger
- double x = NR::L2(drg->point - dragger->point)/NR::L2(end - dragger->point);
+ if (Geom::L2(drg->point - dragger->point) + Geom::L2(drg->point - begin) - 1e-3 > Geom::L2(dragger->point - begin)) { // drg is on the end side from dragger
+ double x = Geom::L2(drg->point - dragger->point)/Geom::L2(end - dragger->point);
this_move = (0.5 * cos (M_PI * (pow(x, alpha))) + 0.5) * this_move;
} else { // drg is on the begin side from dragger
- double x = NR::L2(drg->point - dragger->point)/NR::L2(begin - dragger->point);
+ double x = Geom::L2(drg->point - dragger->point)/Geom::L2(begin - dragger->point);
this_move = (0.5 * cos (M_PI * (pow(x, alpha))) + 0.5) * this_move;
}
}
for (GList *l = this->draggers; l != NULL; l = l->next) {
GrDragger *d = ((GrDragger *) l->data);
for (guint k = 0; k < coords.size(); k++) {
- if (NR::L2 (d->point - coords[k]) < 1e-4) {
+ if (Geom::L2 (d->point - coords[k]) < 1e-4) {
setSelected (d, true, true);
}
}
for (GList *i = this->draggers; i != NULL; i = i->next) {
GrDragger *dragger = (GrDragger *) i->data;
- if (dragger->mayMerge (draggable) && NR::L2 (dragger->point - p) < MERGE_DIST) {
+ if (dragger->mayMerge (draggable) && Geom::L2 (dragger->point - p) < MERGE_DIST) {
// distance is small, merge this draggable into dragger, no need to create new dragger
dragger->addDraggable (draggable);
dragger->updateKnotShape();
index 12bca8891c12ed96d45fac4756b910eaf672112a..cd1683c343d68481c28da4ecd6c7b8c4cd9d1d2d 100644 (file)
SPItem *u=*it;
if(!isConnector(u)) {
Rectangle* r=rs[nodelookup[u->id]];
- NR::Rect const item_box(sp_item_bbox_desktop(u));
- NR::Point const curr(item_box.midpoint());
- NR::Point const dest(r->getCentreX(),r->getCentreY());
+ Geom::Rect const item_box(sp_item_bbox_desktop(u));
+ Geom::Point const curr(item_box.midpoint());
+ Geom::Point const dest(r->getCentreX(),r->getCentreY());
sp_item_move_rel(u, Geom::Translate(dest - curr));
}
}
diff --git a/src/interface.cpp b/src/interface.cpp
index fbdb8a5f63b79486e8fdb0555645cf417c824b1d..2242e62247b2a1b3ce1e10a18493d7261ab4b5b6 100644 (file)
--- a/src/interface.cpp
+++ b/src/interface.cpp
int destX = 0;
int destY = 0;
gtk_widget_translate_coordinates( widget, &(desktop->canvas->widget), x, y, &destX, &destY );
- NR::Point where( sp_canvas_window_to_world( desktop->canvas, NR::Point( destX, destY ) ) );
- NR::Point const button_dt(desktop->w2d(where));
- NR::Point const button_doc(desktop->dt2doc(button_dt));
+ Geom::Point where( sp_canvas_window_to_world( desktop->canvas, Geom::Point( destX, destY ) ) );
+ Geom::Point const button_dt(desktop->w2d(where));
+ Geom::Point const button_doc(desktop->dt2doc(button_dt));
if ( data->length == 8 ) {
gchar c[64] = {0};
boost::optional<Path::cut_position> position = get_nearest_position_on_Path(livarot_path, button_doc);
if (position) {
- NR::Point nearest = get_point_on_Path(livarot_path, position->piece, position->t);
- NR::Point delta = nearest - button_doc;
+ Geom::Point nearest = get_point_on_Path(livarot_path, position->piece, position->t);
+ Geom::Point delta = nearest - button_doc;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
delta = desktop->d2w(delta);
double stroke_tolerance =
: 0.0)
+ prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
- if (NR::L2 (delta) < stroke_tolerance) {
+ if (Geom::L2 (delta) < stroke_tolerance) {
fillnotstroke = false;
}
}
index f6c82582bb412cd321c0aba63ff833e21cfa8338..36a072c444b92d2767c611b5845dcd3ce1d05057 100644 (file)
@@ -128,16 +128,16 @@ PatternKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &ori
Geom::Point p_snapped = snap_knot_position(p);
if ( state & GDK_CONTROL_MASK ) {
- if (fabs((p - origin)[NR::X]) > fabs((p - origin)[NR::Y])) {
- p_snapped[NR::Y] = origin[NR::Y];
+ if (fabs((p - origin)[Geom::X]) > fabs((p - origin)[Geom::Y])) {
+ p_snapped[Geom::Y] = origin[Geom::Y];
} else {
- p_snapped[NR::X] = origin[NR::X];
+ p_snapped[Geom::X] = origin[Geom::X];
}
}
if (state) {
Geom::Point const q = p_snapped - sp_pattern_extract_trans(pat);
- sp_item_adjust_pattern(item, NR::Matrix(Geom::Translate(q)));
+ sp_item_adjust_pattern(item, Geom::Matrix(Geom::Translate(q)));
}
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
@@ -183,10 +183,10 @@ PatternKnotHolderEntityAngle::knot_set(Geom::Point const &p, Geom::Point const &
// get the scale from the current transform so we can keep it.
Geom::Point scl = sp_pattern_extract_scale(pat);
- NR::Matrix rot = NR::Matrix(Geom::Scale(scl)) * NR::Matrix(Geom::Rotate(theta));
+ Geom::Matrix rot = Geom::Matrix(Geom::Scale(scl)) * Geom::Matrix(Geom::Rotate(theta));
Geom::Point const t = sp_pattern_extract_trans(pat);
- rot[4] = t[NR::X];
- rot[5] = t[NR::Y];
+ rot[4] = t[Geom::X];
+ rot[5] = t[Geom::Y];
sp_item_adjust_pattern(item, rot, true);
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
@@ -213,14 +213,14 @@ PatternKnotHolderEntityScale::knot_set(Geom::Point const &p, Geom::Point const &
scl = Geom::Scale(d.length() / pat_h);
} else {
d *= Geom::Rotate(-theta);
- scl = Geom::Scale(d[NR::X] / pat_x, d[NR::Y] / pat_y);
+ scl = Geom::Scale(d[Geom::X] / pat_x, d[Geom::Y] / pat_y);
}
Geom::Matrix rot = (Geom::Matrix)scl * Geom::Rotate(theta);
Geom::Point const t = sp_pattern_extract_trans(pat);
- rot[4] = t[NR::X];
- rot[5] = t[NR::Y];
+ rot[4] = t[Geom::X];
+ rot[5] = t[Geom::Y];
sp_item_adjust_pattern(item, rot, true);
item->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
diff --git a/src/knot.cpp b/src/knot.cpp
index 741199098650d0c7f010c6f01aea7b4377fa9dad..cf1a3e9444e8194d15a97b9c16a6b8973b5cbfaf 100644 (file)
--- a/src/knot.cpp
+++ b/src/knot.cpp
@@ -379,7 +379,7 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot
TRUE);
}
Geom::Point const motion_w(event->motion.x, event->motion.y);
- NR::Point const motion_dt = knot->desktop->w2d(motion_w);
+ Geom::Point const motion_dt = knot->desktop->w2d(motion_w);
Geom::Point p = motion_dt - knot->grabbed_rel_pos;
sp_knot_request_position (knot, p, event->motion.state);
knot->desktop->scroll_to_point (motion_dt);
index bbd4aa6fd1a962fc0839cc56c43b02ae2a5b763b..8dd61c4916dadf8b52fa796cd0d6113a7f0ca919 100644 (file)
@@ -260,8 +260,8 @@ Geom::Rect Layout::characterBoundingBox(iterator const &it, double *rotation) co
int unused = 0;
Path::cut_position *midpoint_otp = const_cast<Path*>(_path_fitted)->CurvilignToPosition(1, &midpoint_offset, unused);
if (midpoint_offset >= 0.0 && midpoint_otp != NULL && midpoint_otp[0].piece >= 0) {
- NR::Point midpoint;
- NR::Point tangent;
+ Geom::Point midpoint;
+ Geom::Point tangent;
Span const &span = _characters[char_index].span(this);
const_cast<Path*>(_path_fitted)->PointAndTangentAt(midpoint_otp[0].piece, midpoint_otp[0].t, midpoint, tangent);
}
g_free(path_parameter_list);
- NR::Point point;
- NR::Point tangent;
+ Geom::Point point;
+ Geom::Point tangent;
const_cast<Path*>(_path_fitted)->PointAndTangentAt(path_parameter.piece, path_parameter.t, point, tangent);
if (x < 0.0)
point += x * tangent;
index 49967cd59bad3bb82c329fea230152216a49da4e..2003ca26bbc89bd1a3635049de7635c64dd22cc3 100644 (file)
int unused = 0;
Path::cut_position *point_otp = const_cast<Path&>(path).CurvilignToPosition(1, &offset, unused);
if (offset >= 0.0 && point_otp != NULL && point_otp[0].piece >= 0) {
- NR::Point point;
- NR::Point tangent;
+ Geom::Point point;
+ Geom::Point tangent;
const_cast<Path&>(path).PointAndTangentAt(point_otp[0].piece, point_otp[0].t, point, tangent);
_empty_cursor_shape.position = point;
_empty_cursor_shape.rotation = atan2(tangent[Geom::Y], tangent[Geom::X]);
// as far as I know these functions are const, they're just not marked as such
Path::cut_position *midpoint_otp = const_cast<Path&>(path).CurvilignToPosition(1, &midpoint_offset, unused);
if (midpoint_offset >= 0.0 && midpoint_otp != NULL && midpoint_otp[0].piece >= 0) {
- NR::Point midpoint;
- NR::Point tangent;
+ Geom::Point midpoint;
+ Geom::Point tangent;
const_cast<Path&>(path).PointAndTangentAt(midpoint_otp[0].piece, midpoint_otp[0].t, midpoint, tangent);
if (start_offset >= 0.0 && end_offset >= 0.0) {
}
if (on_same_subpath) {
// both points were on the same subpath (without this test the angle is very weird)
- NR::Point startpoint, endpoint;
+ Geom::Point startpoint, endpoint;
const_cast<Path&>(path).PointAt(start_otp[0].piece, start_otp[0].t, startpoint);
const_cast<Path&>(path).PointAt(end_otp[0].piece, end_otp[0].t, endpoint);
if (endpoint != startpoint) {
diff --git a/src/livarot/Path.cpp b/src/livarot/Path.cpp
index bc62e817e0b86c86363c489634e591e172271587..66ec87274290944120250bf66a4c5da2c2f38778 100644 (file)
--- a/src/livarot/Path.cpp
+++ b/src/livarot/Path.cpp
return descr_cmd.size() - 1;
}
-int Path::MoveTo(NR::Point const &iPt)
+int Path::MoveTo(Geom::Point const &iPt)
{
if ( descr_flags & descr_adding_bezier ) {
EndBezierTo(iPt);
return descr_cmd.size() - 1;
}
-void Path::InsertMoveTo(NR::Point const &iPt, int at)
+void Path::InsertMoveTo(Geom::Point const &iPt, int at)
{
if ( at < 0 || at > int(descr_cmd.size()) ) {
return;
descr_cmd.insert(descr_cmd.begin() + at, new PathDescrMoveTo(iPt));
}
-int Path::LineTo(NR::Point const &iPt)
+int Path::LineTo(Geom::Point const &iPt)
{
if (descr_flags & descr_adding_bezier) {
EndBezierTo (iPt);
return descr_cmd.size() - 1;
}
-void Path::InsertLineTo(NR::Point const &iPt, int at)
+void Path::InsertLineTo(Geom::Point const &iPt, int at)
{
if ( at < 0 || at > int(descr_cmd.size()) ) {
return;
descr_cmd.insert(descr_cmd.begin() + at, new PathDescrLineTo(iPt));
}
-int Path::CubicTo(NR::Point const &iPt, NR::Point const &iStD, NR::Point const &iEnD)
+int Path::CubicTo(Geom::Point const &iPt, Geom::Point const &iStD, Geom::Point const &iEnD)
{
if (descr_flags & descr_adding_bezier) {
EndBezierTo(iPt);
@@ -206,7 +206,7 @@ int Path::CubicTo(NR::Point const &iPt, NR::Point const &iStD, NR::Point const &
}
-void Path::InsertCubicTo(NR::Point const &iPt, NR::Point const &iStD, NR::Point const &iEnD, int at)
+void Path::InsertCubicTo(Geom::Point const &iPt, Geom::Point const &iStD, Geom::Point const &iEnD, int at)
{
if ( at < 0 || at > int(descr_cmd.size()) ) {
return;
descr_cmd.insert(descr_cmd.begin() + at, new PathDescrCubicTo(iPt, iStD, iEnD));
}
-int Path::ArcTo(NR::Point const &iPt, double iRx, double iRy, double angle,
+int Path::ArcTo(Geom::Point const &iPt, double iRx, double iRy, double angle,
bool iLargeArc, bool iClockwise)
{
if (descr_flags & descr_adding_bezier) {
}
-void Path::InsertArcTo(NR::Point const &iPt, double iRx, double iRy, double angle,
+void Path::InsertArcTo(Geom::Point const &iPt, double iRx, double iRy, double angle,
bool iLargeArc, bool iClockwise, int at)
{
if ( at < 0 || at > int(descr_cmd.size()) ) {
}
pending_bezier_cmd = descr_cmd.size();
- descr_cmd.push_back(new PathDescrBezierTo(NR::Point(0, 0), 0));
+ descr_cmd.push_back(new PathDescrBezierTo(Geom::Point(0, 0), 0));
descr_flags |= descr_adding_bezier;
descr_flags |= descr_delayed_bezier;
return descr_cmd.size() - 1;
return -1;
}
-int Path::EndBezierTo(NR::Point const &iPt)
+int Path::EndBezierTo(Geom::Point const &iPt)
{
if ( (descr_flags & descr_adding_bezier) == 0 ) {
return LineTo(iPt);
}
-int Path::IntermBezierTo(NR::Point const &iPt)
+int Path::IntermBezierTo(Geom::Point const &iPt)
{
if ( (descr_flags & descr_adding_bezier) == 0 ) {
return LineTo (iPt);
}
-void Path::InsertIntermBezierTo(NR::Point const &iPt, int at)
+void Path::InsertIntermBezierTo(Geom::Point const &iPt, int at)
{
if ( at < 0 || at > int(descr_cmd.size()) ) {
return;
}
-int Path::BezierTo(NR::Point const &iPt)
+int Path::BezierTo(Geom::Point const &iPt)
{
if ( descr_flags & descr_adding_bezier ) {
EndBezierTo(iPt);
}
-void Path::InsertBezierTo(NR::Point const &iPt, int iNb, int at)
+void Path::InsertBezierTo(Geom::Point const &iPt, int iNb, int at)
{
if ( at < 0 || at > int(descr_cmd.size()) ) {
return;
}
-int Path::AddPoint(NR::Point const &iPt, bool mvto)
+int Path::AddPoint(Geom::Point const &iPt, bool mvto)
{
if (back) {
return AddPoint (iPt, -1, 0.0, mvto);
}
-int Path::ReplacePoint(NR::Point const &iPt)
+int Path::ReplacePoint(Geom::Point const &iPt)
{
if (pts.empty()) {
return -1;
}
-int Path::AddPoint(NR::Point const &iPt, int ip, double it, bool mvto)
+int Path::AddPoint(Geom::Point const &iPt, int ip, double it, bool mvto)
{
if (back == false) {
return AddPoint (iPt, mvto);
return n;
}
-int Path::AddForcedPoint(NR::Point const &iPt)
+int Path::AddForcedPoint(Geom::Point const &iPt)
{
if (back) {
return AddForcedPoint (iPt, -1, 0.0);
}
-int Path::AddForcedPoint(NR::Point const &iPt, int /*ip*/, double /*it*/)
+int Path::AddForcedPoint(Geom::Point const &iPt, int /*ip*/, double /*it*/)
{
/* FIXME: ip & it aren't used. Is this deliberate? */
if (!back) {
}
std::vector<path_lineto>::const_iterator i = pts.begin();
- l = r = i->p[NR::X];
- t = b = i->p[NR::Y];
+ l = r = i->p[Geom::X];
+ t = b = i->p[Geom::Y];
i++;
for (; i != pts.end(); i++) {
- r = std::max(r, i->p[NR::X]);
- l = std::min(l, i->p[NR::X]);
- b = std::max(b, i->p[NR::Y]);
- t = std::min(t, i->p[NR::Y]);
+ r = std::max(r, i->p[Geom::X]);
+ l = std::min(l, i->p[Geom::X]);
+ b = std::max(b, i->p[Geom::Y]);
+ t = std::min(t, i->p[Geom::Y]);
}
}
* \param pos Filled in with the point at `at' on `piece'.
*/
-void Path::PointAt(int piece, double at, NR::Point &pos)
+void Path::PointAt(int piece, double at, Geom::Point &pos)
{
if (piece < 0 || piece >= int(descr_cmd.size())) {
// this shouldn't happen: the piece we are asked for doesn't
// exist in the path
- pos = NR::Point(0,0);
+ pos = Geom::Point(0,0);
return;
}
PathDescr const *theD = descr_cmd[piece];
int const typ = theD->getType();
- NR::Point tgt;
+ Geom::Point tgt;
double len;
double rad;
}
int k = piece - bez_st;
- NR::Point const bStPt = PrevPoint(bez_st - 1);
+ Geom::Point const bStPt = PrevPoint(bez_st - 1);
if (stB->nb == 1 || k <= 0) {
PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + 1]);
TangentOnBezAt(at, bStPt, *nData, *stB, false, pos, tgt, len, rad);
} else if (k == stB->nb) {
PathDescrIntermBezierTo *nextI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k]);
PathDescrIntermBezierTo *prevI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k - 1]);
- NR::Point stP = 0.5 * ( prevI->p + nextI->p );
+ Geom::Point stP = 0.5 * ( prevI->p + nextI->p );
TangentOnBezAt(at, stP, *nextI, *stB, false, pos, tgt, len, rad);
} else {
PathDescrIntermBezierTo *nextI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k]);
PathDescrIntermBezierTo *prevI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k - 1]);
PathDescrIntermBezierTo *nnextI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k + 1]);
- NR::Point stP = 0.5 * ( prevI->p + nextI->p );
+ Geom::Point stP = 0.5 * ( prevI->p + nextI->p );
PathDescrBezierTo fin(0.5 * (nextI->p + nnextI->p), 1);
TangentOnBezAt(at, stP, *nextI, fin, false, pos, tgt, len, rad);
}
}
-void Path::PointAndTangentAt(int piece, double at, NR::Point &pos, NR::Point &tgt)
+void Path::PointAndTangentAt(int piece, double at, Geom::Point &pos, Geom::Point &tgt)
{
if (piece < 0 || piece >= int(descr_cmd.size())) {
// this shouldn't happen: the piece we are asked for doesn't exist in the path
- pos = NR::Point(0, 0);
+ pos = Geom::Point(0, 0);
return;
}
@@ -672,7 +672,7 @@ void Path::PointAndTangentAt(int piece, double at, NR::Point &pos, NR::Point &tg
}
int k = piece - bez_st;
- NR::Point const bStPt(PrevPoint( bez_st - 1 ));
+ Geom::Point const bStPt(PrevPoint( bez_st - 1 ));
if (stB->nb == 1 || k <= 0) {
PathDescrIntermBezierTo* nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + 1]);
TangentOnBezAt (at, bStPt, *nData, *stB, false, pos, tgt, len, rad);
@@ -686,13 +686,13 @@ void Path::PointAndTangentAt(int piece, double at, NR::Point &pos, NR::Point &tg
} else if (k == stB->nb) {
PathDescrIntermBezierTo *prevI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k - 1]);
PathDescrIntermBezierTo *nextI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k]);
- NR::Point stP = 0.5 * ( prevI->p + nextI->p );
+ Geom::Point stP = 0.5 * ( prevI->p + nextI->p );
TangentOnBezAt(at, stP, *nextI, *stB, false, pos, tgt, len, rad);
} else {
PathDescrIntermBezierTo *prevI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k - 1]);
PathDescrIntermBezierTo *nextI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k]);
PathDescrIntermBezierTo *nnextI = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[bez_st + k + 1]);
- NR::Point stP = 0.5 * ( prevI->p + nextI->p );
+ Geom::Point stP = 0.5 * ( prevI->p + nextI->p );
PathDescrBezierTo fin(0.5 * (nnextI->p + nnextI->p), 1);
TangentOnBezAt(at, stP, *nextI, fin, false, pos, tgt, len, rad);
}
@@ -700,7 +700,7 @@ void Path::PointAndTangentAt(int piece, double at, NR::Point &pos, NR::Point &tg
}
}
-void Path::Transform(const NR::Matrix &trans)
+void Path::Transform(const Geom::Matrix &trans)
{
for (std::vector<PathDescr*>::iterator i = descr_cmd.begin(); i != descr_cmd.end(); i++) {
(*i)->transform(trans);
{
l = t = r = b = 0;
bool empty = true;
- NR::Point lastP(0, 0);
+ Geom::Point lastP(0, 0);
for (int i = 0; i < int(descr_cmd.size()); i++) {
int const typ = descr_cmd[i]->getType();
{
PathDescrLineTo *nData = dynamic_cast<PathDescrLineTo *>(descr_cmd[i]);
if ( empty ) {
- l = r = nData->p[NR::X];
- t = b = nData->p[NR::Y];
+ l = r = nData->p[Geom::X];
+ t = b = nData->p[Geom::Y];
empty = false;
} else {
- if ( nData->p[NR::X] < l ) {
- l = nData->p[NR::X];
+ if ( nData->p[Geom::X] < l ) {
+ l = nData->p[Geom::X];
}
- if ( nData->p[NR::X] > r ) {
- r = nData->p[NR::X];
+ if ( nData->p[Geom::X] > r ) {
+ r = nData->p[Geom::X];
}
- if ( nData->p[NR::Y] < t ) {
- t = nData->p[NR::Y];
+ if ( nData->p[Geom::Y] < t ) {
+ t = nData->p[Geom::Y];
}
- if ( nData->p[NR::Y] > b ) {
- b = nData->p[NR::Y];
+ if ( nData->p[Geom::Y] > b ) {
+ b = nData->p[Geom::Y];
}
}
lastP = nData->p;
{
PathDescrMoveTo *nData = dynamic_cast<PathDescrMoveTo *>(descr_cmd[i]);
if ( empty ) {
- l = r = nData->p[NR::X];
- t = b = nData->p[NR::Y];
+ l = r = nData->p[Geom::X];
+ t = b = nData->p[Geom::Y];
empty = false;
} else {
- if ( nData->p[NR::X] < l ) {
- l = nData->p[NR::X];
+ if ( nData->p[Geom::X] < l ) {
+ l = nData->p[Geom::X];
}
- if ( nData->p[NR::X] > r ) {
- r = nData->p[NR::X];
+ if ( nData->p[Geom::X] > r ) {
+ r = nData->p[Geom::X];
}
- if ( nData->p[NR::Y] < t ) {
- t = nData->p[NR::Y];
+ if ( nData->p[Geom::Y] < t ) {
+ t = nData->p[Geom::Y];
}
- if ( nData->p[NR::Y] > b ) {
- b = nData->p[NR::Y];
+ if ( nData->p[Geom::Y] > b ) {
+ b = nData->p[Geom::Y];
}
}
lastP = nData->p;
{
PathDescrArcTo *nData = dynamic_cast<PathDescrArcTo *>(descr_cmd[i]);
if ( empty ) {
- l = r = nData->p[NR::X];
- t = b = nData->p[NR::Y];
+ l = r = nData->p[Geom::X];
+ t = b = nData->p[Geom::Y];
empty = false;
} else {
- if ( nData->p[NR::X] < l ) {
- l = nData->p[NR::X];
+ if ( nData->p[Geom::X] < l ) {
+ l = nData->p[Geom::X];
}
- if ( nData->p[NR::X] > r ) {
- r = nData->p[NR::X];
+ if ( nData->p[Geom::X] > r ) {
+ r = nData->p[Geom::X];
}
- if ( nData->p[NR::Y] < t ) {
- t = nData->p[NR::Y];
+ if ( nData->p[Geom::Y] < t ) {
+ t = nData->p[Geom::Y];
}
- if ( nData->p[NR::Y] > b ) {
- b = nData->p[NR::Y];
+ if ( nData->p[Geom::Y] > b ) {
+ b = nData->p[Geom::Y];
}
}
lastP = nData->p;
{
PathDescrCubicTo *nData = dynamic_cast<PathDescrCubicTo *>(descr_cmd[i]);
if ( empty ) {
- l = r = nData->p[NR::X];
- t = b = nData->p[NR::Y];
+ l = r = nData->p[Geom::X];
+ t = b = nData->p[Geom::Y];
empty = false;
} else {
- if ( nData->p[NR::X] < l ) {
- l = nData->p[NR::X];
+ if ( nData->p[Geom::X] < l ) {
+ l = nData->p[Geom::X];
}
- if ( nData->p[NR::X] > r ) {
- r = nData->p[NR::X];
+ if ( nData->p[Geom::X] > r ) {
+ r = nData->p[Geom::X];
}
- if ( nData->p[NR::Y] < t ) {
- t = nData->p[NR::Y];
+ if ( nData->p[Geom::Y] < t ) {
+ t = nData->p[Geom::Y];
}
- if ( nData->p[NR::Y] > b ) {
- b = nData->p[NR::Y];
+ if ( nData->p[Geom::Y] > b ) {
+ b = nData->p[Geom::Y];
}
}
*/
#ifdef WIN32
- NR::Point np = nData->p - nData->end;
- if ( np[NR::X] < l ) {
- l = np[NR::X];
+ Geom::Point np = nData->p - nData->end;
+ if ( np[Geom::X] < l ) {
+ l = np[Geom::X];
}
- if ( np[NR::X] > r ) {
- r = np[NR::X];
+ if ( np[Geom::X] > r ) {
+ r = np[Geom::X];
}
- if ( np[NR::Y] < t ) {
- t = np[NR::Y];
+ if ( np[Geom::Y] < t ) {
+ t = np[Geom::Y];
}
- if ( np[NR::Y] > b ) {
- b = np[NR::Y];
+ if ( np[Geom::Y] > b ) {
+ b = np[Geom::Y];
}
np = lastP + nData->start;
- if ( np[NR::X] < l ) {
- l = np[NR::X];
+ if ( np[Geom::X] < l ) {
+ l = np[Geom::X];
}
- if ( np[NR::X] > r ) {
- r = np[NR::X];
+ if ( np[Geom::X] > r ) {
+ r = np[Geom::X];
}
- if ( np[NR::Y] < t ) {
- t = np[NR::Y];
+ if ( np[Geom::Y] < t ) {
+ t = np[Geom::Y];
}
- if ( np[NR::Y] > b ) {
- b = np[NR::Y];
+ if ( np[Geom::Y] > b ) {
+ b = np[Geom::Y];
}
#endif
{
PathDescrBezierTo *nData = dynamic_cast<PathDescrBezierTo *>(descr_cmd[i]);
if ( empty ) {
- l = r = nData->p[NR::X];
- t = b = nData->p[NR::Y];
+ l = r = nData->p[Geom::X];
+ t = b = nData->p[Geom::Y];
empty = false;
} else {
- if ( nData->p[NR::X] < l ) {
- l = nData->p[NR::X];
+ if ( nData->p[Geom::X] < l ) {
+ l = nData->p[Geom::X];
}
- if ( nData->p[NR::X] > r ) {
- r = nData->p[NR::X];
+ if ( nData->p[Geom::X] > r ) {
+ r = nData->p[Geom::X];
}
- if ( nData->p[NR::Y] < t ) {
- t = nData->p[NR::Y];
+ if ( nData->p[Geom::Y] < t ) {
+ t = nData->p[Geom::Y];
}
- if ( nData->p[NR::Y] > b ) {
- b = nData->p[NR::Y];
+ if ( nData->p[Geom::Y] > b ) {
+ b = nData->p[Geom::Y];
}
}
lastP = nData->p;
{
PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[i]);
if ( empty ) {
- l = r = nData->p[NR::X];
- t = b = nData->p[NR::Y];
+ l = r = nData->p[Geom::X];
+ t = b = nData->p[Geom::Y];
empty = false;
} else {
- if ( nData->p[NR::X] < l ) {
- l = nData->p[NR::X];
+ if ( nData->p[Geom::X] < l ) {
+ l = nData->p[Geom::X];
}
- if ( nData->p[NR::X] > r ) {
- r = nData->p[NR::X];
+ if ( nData->p[Geom::X] > r ) {
+ r = nData->p[Geom::X];
}
- if ( nData->p[NR::Y] < t ) {
- t = nData->p[NR::Y];
+ if ( nData->p[Geom::Y] < t ) {
+ t = nData->p[Geom::Y];
}
- if ( nData->p[NR::Y] > b ) {
- b = nData->p[NR::Y];
+ if ( nData->p[Geom::Y] > b ) {
+ b = nData->p[Geom::Y];
}
}
}
Inkscape::SVGOStringStream os;
for (int i = 0; i < int(descr_cmd.size()); i++) {
- NR::Point const p = (i == 0) ? NR::Point(0, 0) : PrevPoint(i - 1);
+ Geom::Point const p = (i == 0) ? Geom::Point(0, 0) : PrevPoint(i - 1);
descr_cmd[i]->dumpSVG(os, p);
}
diff --git a/src/livarot/Path.h b/src/livarot/Path.h
index 4887883c8102a6064a7a2c8f19b78cbfcb5429ec..b478449cdda7f9f955b25c2cb3a1c3961b81e6dc 100644 (file)
--- a/src/livarot/Path.h
+++ b/src/livarot/Path.h
// t=0 means it's at the start of the command's chunk, t=1 it's at the end
struct path_lineto
{
- path_lineto(bool m, NR::Point pp) : isMoveTo(m), p(pp), piece(-1), t(0) {}
- path_lineto(bool m, NR::Point pp, int pie, double tt) : isMoveTo(m), p(pp), piece(pie), t(tt) {}
+ path_lineto(bool m, Geom::Point pp) : isMoveTo(m), p(pp), piece(-1), t(0) {}
+ path_lineto(bool m, Geom::Point pp, int pie, double tt) : isMoveTo(m), p(pp), piece(pie), t(tt) {}
int isMoveTo;
- NR::Point p;
+ Geom::Point p;
int piece;
double t;
};
// the commands...
int ForcePoint();
int Close();
- int MoveTo ( NR::Point const &ip);
- int LineTo ( NR::Point const &ip);
- int CubicTo ( NR::Point const &ip, NR::Point const &iStD, NR::Point const &iEnD);
- int ArcTo ( NR::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise);
- int IntermBezierTo ( NR::Point const &ip); // add a quadratic bezier spline control point
- int BezierTo ( NR::Point const &ip); // quadratic bezier spline to this point (control points can be added after this)
+ int MoveTo ( Geom::Point const &ip);
+ int LineTo ( Geom::Point const &ip);
+ int CubicTo ( Geom::Point const &ip, Geom::Point const &iStD, Geom::Point const &iEnD);
+ int ArcTo ( Geom::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise);
+ int IntermBezierTo ( Geom::Point const &ip); // add a quadratic bezier spline control point
+ int BezierTo ( Geom::Point const &ip); // quadratic bezier spline to this point (control points can be added after this)
int TempBezierTo(); // start a quadratic bezier spline (control points can be added after this)
int EndBezierTo();
- int EndBezierTo ( NR::Point const &ip); // ends a quadratic bezier spline (for curves started with TempBezierTo)
+ int EndBezierTo ( Geom::Point const &ip); // ends a quadratic bezier spline (for curves started with TempBezierTo)
// transforms a description in a polyline (for stroking and filling)
// treshhold is the max length^2 (sort of)
// creation of the polyline (you can tinker with these function if you want)
void SetBackData (bool nVal); // has back data?
void ResetPoints(); // resets to the empty polyline
- int AddPoint ( NR::Point const &iPt, bool mvto = false); // add point
- int AddPoint ( NR::Point const &iPt, int ip, double it, bool mvto = false);
- int AddForcedPoint ( NR::Point const &iPt); // add point
- int AddForcedPoint ( NR::Point const &iPt, int ip, double it);
- int ReplacePoint(NR::Point const &iPt); // replace point
+ int AddPoint ( Geom::Point const &iPt, bool mvto = false); // add point
+ int AddPoint ( Geom::Point const &iPt, int ip, double it, bool mvto = false);
+ int AddForcedPoint ( Geom::Point const &iPt); // add point
+ int AddForcedPoint ( Geom::Point const &iPt, int ip, double it);
+ int ReplacePoint(Geom::Point const &iPt); // replace point
// transform in a polygon (in a graph, in fact; a subsequent call to ConvertToShape is needed)
// - fills the polyline; justAdd=true doesn't reset the Shape dest, but simply adds the polyline into it
// piece is a command no in the command list
// "at" is an abcissis on the path portion associated with this command
// 0=beginning of portion, 1=end of portion.
- void PointAt (int piece, double at, NR::Point & pos);
- void PointAndTangentAt (int piece, double at, NR::Point & pos, NR::Point & tgt);
+ void PointAt (int piece, double at, Geom::Point & pos);
+ void PointAndTangentAt (int piece, double at, Geom::Point & pos, Geom::Point & tgt);
// last control point before the command i (i included)
// used when dealing with quadratic bezier spline, cause these can contain arbitrarily many commands
- const NR::Point PrevPoint (const int i) const;
+ const Geom::Point PrevPoint (const int i) const;
// dash the polyline
// the result is stored in the polyline, so you lose the original. make a copy before if needed
void LoadPathVector(Geom::PathVector const &pv);
Geom::PathVector* MakePathVector();
- void Transform(const NR::Matrix &trans);
+ void Transform(const Geom::Matrix &trans);
// decompose le chemin en ses sous-chemin
// killNoSurf=true -> oublie les chemins de surface nulle
double t;
};
cut_position* CurvilignToPosition(int nbCv,double* cvAbs,int &nbCut);
- cut_position PointToCurvilignPosition(NR::Point const &pos, unsigned seg = 0) const;
+ cut_position PointToCurvilignPosition(Geom::Point const &pos, unsigned seg = 0) const;
//Should this take a cut_position as a param?
double PositionToLength(int piece, double t);
// utilitary functions for the path contruction
void CancelBezier ();
void CloseSubpath();
- void InsertMoveTo (NR::Point const &iPt,int at);
+ void InsertMoveTo (Geom::Point const &iPt,int at);
void InsertForcePoint (int at);
- void InsertLineTo (NR::Point const &iPt,int at);
- void InsertArcTo (NR::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise,int at);
- void InsertCubicTo (NR::Point const &ip, NR::Point const &iStD, NR::Point const &iEnD,int at);
- void InsertBezierTo (NR::Point const &iPt,int iNb,int at);
- void InsertIntermBezierTo (NR::Point const &iPt,int at);
+ void InsertLineTo (Geom::Point const &iPt,int at);
+ void InsertArcTo (Geom::Point const &ip, double iRx, double iRy, double angle, bool iLargeArc, bool iClockwise,int at);
+ void InsertCubicTo (Geom::Point const &ip, Geom::Point const &iStD, Geom::Point const &iEnD,int at);
+ void InsertBezierTo (Geom::Point const &iPt,int iNb,int at);
+ void InsertIntermBezierTo (Geom::Point const &iPt,int at);
// creation of dashes: take the polyline given by spP (length spL) and dash it according to head, body, etc. put the result in
// the polyline of this instance
// Functions used by the conversion.
// they append points to the polyline
- void DoArc ( NR::Point const &iS, NR::Point const &iE, double rx, double ry,
+ void DoArc ( Geom::Point const &iS, Geom::Point const &iE, double rx, double ry,
double angle, bool large, bool wise, double tresh);
- void RecCubicTo ( NR::Point const &iS, NR::Point const &iSd, NR::Point const &iE, NR::Point const &iEd, double tresh, int lev,
+ void RecCubicTo ( Geom::Point const &iS, Geom::Point const &iSd, Geom::Point const &iE, Geom::Point const &iEd, double tresh, int lev,
double maxL = -1.0);
- void RecBezierTo ( NR::Point const &iPt, NR::Point const &iS, NR::Point const &iE, double treshhold, int lev, double maxL = -1.0);
+ void RecBezierTo ( Geom::Point const &iPt, Geom::Point const &iS, Geom::Point const &iE, double treshhold, int lev, double maxL = -1.0);
- void DoArc ( NR::Point const &iS, NR::Point const &iE, double rx, double ry,
+ void DoArc ( Geom::Point const &iS, Geom::Point const &iE, double rx, double ry,
double angle, bool large, bool wise, double tresh, int piece);
- void RecCubicTo ( NR::Point const &iS, NR::Point const &iSd, NR::Point const &iE, NR::Point const &iEd, double tresh, int lev,
+ void RecCubicTo ( Geom::Point const &iS, Geom::Point const &iSd, Geom::Point const &iE, Geom::Point const &iEd, double tresh, int lev,
double st, double et, int piece);
- void RecBezierTo ( NR::Point const &iPt, NR::Point const &iS, const NR::Point &iE, double treshhold, int lev, double st, double et,
+ void RecBezierTo ( Geom::Point const &iPt, Geom::Point const &iS, const Geom::Point &iE, double treshhold, int lev, double st, double et,
int piece);
// don't pay attention
double tSt, tEn;
double off_dec;
};
- void DoArc ( NR::Point const &iS, NR::Point const &iE, double rx, double ry,
+ void DoArc ( Geom::Point const &iS, Geom::Point const &iE, double rx, double ry,
double angle, bool large, bool wise, double tresh, int piece,
offset_orig & orig);
- void RecCubicTo ( NR::Point const &iS, NR::Point const &iSd, NR::Point const &iE, NR::Point const &iEd, double tresh, int lev,
+ void RecCubicTo ( Geom::Point const &iS, Geom::Point const &iSd, Geom::Point const &iE, Geom::Point const &iEd, double tresh, int lev,
double st, double et, int piece, offset_orig & orig);
- void RecBezierTo ( NR::Point const &iPt, NR::Point const &iS, NR::Point const &iE, double treshhold, int lev, double st, double et,
+ void RecBezierTo ( Geom::Point const &iPt, Geom::Point const &iS, Geom::Point const &iE, double treshhold, int lev, double st, double et,
int piece, offset_orig & orig);
- static void ArcAngles ( NR::Point const &iS, NR::Point const &iE, double rx,
+ static void ArcAngles ( Geom::Point const &iS, Geom::Point const &iE, double rx,
double ry, double angle, bool large, bool wise,
double &sang, double &eang);
- static void QuadraticPoint (double t, NR::Point &oPt, NR::Point const &iS, NR::Point const &iM, NR::Point const &iE);
- static void CubicTangent (double t, NR::Point &oPt, NR::Point const &iS,
- NR::Point const &iSd, NR::Point const &iE,
- NR::Point const &iEd);
+ static void QuadraticPoint (double t, Geom::Point &oPt, Geom::Point const &iS, Geom::Point const &iM, Geom::Point const &iE);
+ static void CubicTangent (double t, Geom::Point &oPt, Geom::Point const &iS,
+ Geom::Point const &iSd, Geom::Point const &iE,
+ Geom::Point const &iEd);
struct outline_callback_data
{
Path * dest, outline_callbacks & calls,
double tolerance, double width, JoinType join,
ButtType butt, double miter, bool closeIfNeeded,
- bool skipMoveto, NR::Point & lastP, NR::Point & lastT);
+ bool skipMoveto, Geom::Point & lastP, Geom::Point & lastT);
void DoStroke(int off, int N, Shape *dest, bool doClose, double width, JoinType join,
ButtType butt, double miter, bool justAdd = false);
- static void TangentOnSegAt(double at, NR::Point const &iS, PathDescrLineTo const &fin,
- NR::Point &pos, NR::Point &tgt, double &len);
- static void TangentOnArcAt(double at, NR::Point const &iS, PathDescrArcTo const &fin,
- NR::Point &pos, NR::Point &tgt, double &len, double &rad);
- static void TangentOnCubAt (double at, NR::Point const &iS, PathDescrCubicTo const &fin, bool before,
- NR::Point &pos, NR::Point &tgt, double &len, double &rad);
- static void TangentOnBezAt (double at, NR::Point const &iS,
+ static void TangentOnSegAt(double at, Geom::Point const &iS, PathDescrLineTo const &fin,
+ Geom::Point &pos, Geom::Point &tgt, double &len);
+ static void TangentOnArcAt(double at, Geom::Point const &iS, PathDescrArcTo const &fin,
+ Geom::Point &pos, Geom::Point &tgt, double &len, double &rad);
+ static void TangentOnCubAt (double at, Geom::Point const &iS, PathDescrCubicTo const &fin, bool before,
+ Geom::Point &pos, Geom::Point &tgt, double &len, double &rad);
+ static void TangentOnBezAt (double at, Geom::Point const &iS,
PathDescrIntermBezierTo & mid,
PathDescrBezierTo & fin, bool before,
- NR::Point & pos, NR::Point & tgt, double &len, double &rad);
- static void OutlineJoin (Path * dest, NR::Point pos, NR::Point stNor, NR::Point enNor,
+ Geom::Point & pos, Geom::Point & tgt, double &len, double &rad);
+ static void OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point enNor,
double width, JoinType join, double miter);
- static bool IsNulCurve (std::vector<PathDescr*> const &cmd, int curD, NR::Point const &curX);
+ static bool IsNulCurve (std::vector<PathDescr*> const &cmd, int curD, Geom::Point const &curX);
static void RecStdCubicTo (outline_callback_data * data, double tol,
double width, int lev);
// fonctions annexes pour le stroke
- static void DoButt (Shape * dest, double width, ButtType butt, NR::Point pos,
- NR::Point dir, int &leftNo, int &rightNo);
- static void DoJoin (Shape * dest, double width, JoinType join, NR::Point pos,
- NR::Point prev, NR::Point next, double miter, double prevL,
+ static void DoButt (Shape * dest, double width, ButtType butt, Geom::Point pos,
+ Geom::Point dir, int &leftNo, int &rightNo);
+ static void DoJoin (Shape * dest, double width, JoinType join, Geom::Point pos,
+ Geom::Point prev, Geom::Point next, double miter, double prevL,
double nextL, int *stNo, int *enNo);
- static void DoLeftJoin (Shape * dest, double width, JoinType join, NR::Point pos,
- NR::Point prev, NR::Point next, double miter, double prevL,
+ static void DoLeftJoin (Shape * dest, double width, JoinType join, Geom::Point pos,
+ Geom::Point prev, Geom::Point next, double miter, double prevL,
double nextL, int &leftStNo, int &leftEnNo,int pathID=-1,int pieceID=0,double tID=0.0);
- static void DoRightJoin (Shape * dest, double width, JoinType join, NR::Point pos,
- NR::Point prev, NR::Point next, double miter, double prevL,
+ static void DoRightJoin (Shape * dest, double width, JoinType join, Geom::Point pos,
+ Geom::Point prev, Geom::Point next, double miter, double prevL,
double nextL, int &rightStNo, int &rightEnNo,int pathID=-1,int pieceID=0,double tID=0.0);
static void RecRound (Shape * dest, int sNo, int eNo,
- NR::Point const &iS, NR::Point const &iE,
- NR::Point const &nS, NR::Point const &nE,
- NR::Point &origine,float width);
+ Geom::Point const &iS, Geom::Point const &iE,
+ Geom::Point const &nS, Geom::Point const &nE,
+ Geom::Point &origine,float width);
void DoSimplify(int off, int N, double treshhold);
bool AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &res, int &worstP);
- static bool FitCubic(NR::Point const &start,
+ static bool FitCubic(Geom::Point const &start,
PathDescrCubicTo &res,
double *Xk, double *Yk, double *Qk, double *tk, int nbPt);
};
bool AttemptSimplify (fitting_tables &data,double treshhold, PathDescrCubicTo & res,int &worstP);
bool ExtendFit(int off, int N, fitting_tables &data,double treshhold, PathDescrCubicTo & res,int &worstP);
- double RaffineTk (NR::Point pt, NR::Point p0, NR::Point p1, NR::Point p2, NR::Point p3, double it);
+ double RaffineTk (Geom::Point pt, Geom::Point p0, Geom::Point p1, Geom::Point p2, Geom::Point p3, double it);
void FlushPendingAddition(Path* dest,PathDescr *lastAddition,PathDescrCubicTo &lastCubic,int lastAD);
private:
index 4ae4afe8610a29ae82bd04c31127a6fefb308a1c..6ac6717afc40bc324a307f6fbdab3d1aeadee864 100644 (file)
return;
}
- NR::Point curX;
+ Geom::Point curX;
int curP = 1;
int lastMoveTo = -1;
curX = dynamic_cast<PathDescrMoveTo *>(descr_cmd[0])->p;
} else {
curP = 0;
- curX[NR::X] = curX[NR::Y] = 0;
+ curX[Geom::X] = curX[Geom::Y] = 0;
}
lastMoveTo = AddPoint(curX, 0, 0.0, true);
}
while ( curP < int(descr_cmd.size()) ) {
int const nType = descr_cmd[curP]->getType();
- NR::Point nextX;
+ Geom::Point nextX;
switch (nType) {
case descr_forced: {
PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
if ( nbInterm >= 1 ) {
- NR::Point bx = curX;
- NR::Point cx = curX;
- NR::Point dx = curX;
+ Geom::Point bx = curX;
+ Geom::Point cx = curX;
+ Geom::Point dx = curX;
dx = nData->p;
ip++;
ip++;
nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
- NR::Point stx;
+ Geom::Point stx;
stx = (bx + cx) / 2;
if ( k > 0 ) {
AddPoint(stx,curP - 1+k,1.0,false);
}
{
- NR::Point mx;
+ Geom::Point mx;
mx = (cx + dx) / 2;
RecBezierTo(cx, stx, mx, treshhold, 8, 0.0, 1.0, curP + k);
}
dx = nextX;
dx = 2 * dx - cx;
- NR::Point stx;
+ Geom::Point stx;
stx = (bx + cx) / 2;
if ( nbInterm > 1 ) {
}
{
- NR::Point mx;
+ Geom::Point mx;
mx = (cx + dx) / 2;
RecBezierTo(cx, stx, mx, treshhold, 8, 0.0, 1.0, curP + nbInterm - 1);
}
return;
}
- NR::Point curX;
+ Geom::Point curX;
int curP = 1;
int lastMoveTo = 0;
while ( curP < int(descr_cmd.size()) ) {
int const nType = descr_cmd[curP]->getType();
- NR::Point nextX;
+ Geom::Point nextX;
switch (nType) {
case descr_forced: {
PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
if ( nbInterm == 1 ) {
- NR::Point const midX = nData->p;
+ Geom::Point const midX = nData->p;
RecBezierTo(midX, curX, nextX, treshhold, 8);
} else if ( nbInterm > 1 ) {
- NR::Point bx = curX;
- NR::Point cx = curX;
- NR::Point dx = curX;
+ Geom::Point bx = curX;
+ Geom::Point cx = curX;
+ Geom::Point dx = curX;
dx = nData->p;
ip++;
ip++;
nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
- NR::Point stx = (bx + cx) / 2;
+ Geom::Point stx = (bx + cx) / 2;
if ( k > 0 ) {
descr_cmd[ip - 2]->associated = AddPoint(stx, false);
if ( descr_cmd[ip - 2]->associated < 0 ) {
}
{
- NR::Point const mx = (cx + dx) / 2;
+ Geom::Point const mx = (cx + dx) / 2;
RecBezierTo(cx, stx, mx, treshhold, 8);
}
}
dx = nextX;
dx = 2 * dx - cx;
- NR::Point stx = (bx + cx) / 2;
+ Geom::Point stx = (bx + cx) / 2;
descr_cmd[ip - 1]->associated = AddPoint(stx, false);
if ( descr_cmd[ip - 1]->associated < 0 ) {
}
{
- NR::Point mx = (cx + dx) / 2;
+ Geom::Point mx = (cx + dx) / 2;
RecBezierTo(cx, stx, mx, treshhold, 8);
}
}
return;
}
- NR::Point curX;
+ Geom::Point curX;
int curP = 1;
int lastMoveTo = 0;
short last_point_relation = 0;
while ( curP < int(descr_cmd.size()) ) {
int const nType = descr_cmd[curP]->getType();
- NR::Point nextX;
+ Geom::Point nextX;
switch (nType) {
case descr_forced: {
PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
if ( nbInterm == 1 ) {
- NR::Point const midX = nData->p;
+ Geom::Point const midX = nData->p;
RecBezierTo(midX, curX, nextX, treshhold, 8);
} else if ( nbInterm > 1 ) {
- NR::Point bx = curX;
- NR::Point cx = curX;
- NR::Point dx = curX;
+ Geom::Point bx = curX;
+ Geom::Point cx = curX;
+ Geom::Point dx = curX;
dx = nData->p;
ip++;
ip++;
nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
- NR::Point stx = (bx + cx) / 2;
+ Geom::Point stx = (bx + cx) / 2;
if ( k > 0 ) {
descr_cmd[ip - 2]->associated = AddPoint(stx, false);
if ( descr_cmd[ip - 2]->associated < 0 ) {
}
{
- NR::Point const mx = (cx + dx) / 2;
+ Geom::Point const mx = (cx + dx) / 2;
RecBezierTo(cx, stx, mx, treshhold, 8);
}
}
dx = nextX;
dx = 2 * dx - cx;
- NR::Point stx = (bx + cx) / 2;
+ Geom::Point stx = (bx + cx) / 2;
descr_cmd[ip - 1]->associated = AddPoint(stx, false);
if ( descr_cmd[ip - 1]->associated < 0 ) {
}
{
- NR::Point mx = (cx + dx) / 2;
+ Geom::Point mx = (cx + dx) / 2;
RecBezierTo(cx, stx, mx, treshhold, 8);
}
}
return;
}
- NR::Point curX;
+ Geom::Point curX;
int curP = 1;
int lastMoveTo = 0;
while ( curP < int(descr_cmd.size()) ) {
int const nType = descr_cmd[curP]->getType();
- NR::Point nextX;
+ Geom::Point nextX;
switch (nType) {
case descr_forced: {
case descr_close: {
nextX = pts[lastMoveTo].p;
{
- NR::Point nexcur;
+ Geom::Point nexcur;
nexcur = nextX - curX;
- const double segL = NR::L2(nexcur);
+ const double segL = Geom::L2(nexcur);
if ( segL > treshhold ) {
for (double i = treshhold; i < segL; i += treshhold) {
- NR::Point nX;
+ Geom::Point nX;
nX = (segL - i) * curX + i * nextX;
nX /= segL;
AddPoint(nX);
case descr_lineto: {
PathDescrLineTo* nData = dynamic_cast<PathDescrLineTo *>(descr_cmd[curP]);
nextX = nData->p;
- NR::Point nexcur = nextX - curX;
+ Geom::Point nexcur = nextX - curX;
const double segL = L2(nexcur);
if ( segL > treshhold ) {
for (double i = treshhold; i < segL; i += treshhold) {
- NR::Point nX = ((segL - i) * curX + i * nextX) / segL;
+ Geom::Point nX = ((segL - i) * curX + i * nextX) / segL;
AddPoint(nX);
}
}
PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
if ( nbInterm == 1 ) {
- NR::Point const midX = nData->p;
+ Geom::Point const midX = nData->p;
RecBezierTo(midX, curX, nextX, treshhold, 8, 4 * treshhold);
} else if ( nbInterm > 1 ) {
- NR::Point bx = curX;
- NR::Point cx = curX;
- NR::Point dx = curX;
+ Geom::Point bx = curX;
+ Geom::Point cx = curX;
+ Geom::Point dx = curX;
dx = nData->p;
ip++;
ip++;
nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[ip]);
- NR::Point stx = (bx+cx) / 2;
+ Geom::Point stx = (bx+cx) / 2;
if ( k > 0 ) {
descr_cmd[ip - 2]->associated = AddPoint(stx, false);
if ( descr_cmd[ip - 2]->associated < 0 ) {
}
{
- NR::Point const mx = (cx + dx) / 2;
+ Geom::Point const mx = (cx + dx) / 2;
RecBezierTo(cx, stx, mx, treshhold, 8, 4 * treshhold);
}
}
dx = nextX;
dx = 2 * dx - cx;
- NR::Point const stx = (bx + cx) / 2;
+ Geom::Point const stx = (bx + cx) / 2;
descr_cmd[ip - 1]->associated = AddPoint(stx, false);
if ( descr_cmd[ip - 1]->associated < 0 ) {
}
{
- NR::Point const mx = (cx + dx) / 2;
+ Geom::Point const mx = (cx + dx) / 2;
RecBezierTo(cx, stx, mx, treshhold, 8, 4 * treshhold);
}
}
}
}
-const NR::Point Path::PrevPoint(int i) const
+const Geom::Point Path::PrevPoint(int i) const
{
/* TODO: I suspect this should assert `(unsigned) i < descr_nb'. We can probably change
the argument to unsigned. descr_nb should probably be changed to unsigned too. */
return PrevPoint(i - 1);
default:
g_assert_not_reached();
- return NR::Point(0, 0);
+ return Geom::Point(0, 0);
}
}
// utilitaries: given a quadratic bezier curve (start point, control point, end point, ie that's a clamped curve),
// and an abcissis on it, get the point with that abcissis.
// warning: it's NOT a curvilign abcissis (or whatever you call that in english), so "t" is NOT the length of "start point"->"result point"
-void Path::QuadraticPoint(double t, NR::Point &oPt,
- const NR::Point &iS, const NR::Point &iM, const NR::Point &iE)
+void Path::QuadraticPoint(double t, Geom::Point &oPt,
+ const Geom::Point &iS, const Geom::Point &iM, const Geom::Point &iE)
{
- NR::Point const ax = iE - 2 * iM + iS;
- NR::Point const bx = 2 * iM - 2 * iS;
- NR::Point const cx = iS;
+ Geom::Point const ax = iE - 2 * iM + iS;
+ Geom::Point const bx = 2 * iM - 2 * iS;
+ Geom::Point const cx = iS;
oPt = t * t * ax + t * bx + cx;
}
// idem for cubic bezier patch
-void Path::CubicTangent(double t, NR::Point &oPt, const NR::Point &iS, const NR::Point &isD,
- const NR::Point &iE, const NR::Point &ieD)
+void Path::CubicTangent(double t, Geom::Point &oPt, const Geom::Point &iS, const Geom::Point &isD,
+ const Geom::Point &iE, const Geom::Point &ieD)
{
- NR::Point const ax = ieD - 2 * iE + 2 * iS + isD;
- NR::Point const bx = 3 * iE - ieD - 2 * isD - 3 * iS;
- NR::Point const cx = isD;
+ Geom::Point const ax = ieD - 2 * iE + 2 * iS + isD;
+ Geom::Point const bx = 3 * iE - ieD - 2 * isD - 3 * iS;
+ Geom::Point const cx = isD;
oPt = 3 * t * t * ax + 2 * t * bx + cx;
}
// extract interesting info of a SVG arc description
-static void ArcAnglesAndCenter(NR::Point const &iS, NR::Point const &iE,
+static void ArcAnglesAndCenter(Geom::Point const &iS, Geom::Point const &iE,
double rx, double ry, double angle,
bool large, bool wise,
- double &sang, double &eang, NR::Point &dr);
+ double &sang, double &eang, Geom::Point &dr);
-void Path::ArcAngles(const NR::Point &iS, const NR::Point &iE,
+void Path::ArcAngles(const Geom::Point &iS, const Geom::Point &iE,
double rx, double ry, double angle, bool large, bool wise, double &sang, double &eang)
{
- NR::Point dr;
+ Geom::Point dr;
ArcAnglesAndCenter(iS, iE, rx, ry, angle, large, wise, sang, eang, dr);
}
/* N.B. If iS == iE then sang,eang,dr each become NaN. Probably a bug. */
-static void ArcAnglesAndCenter(NR::Point const &iS, NR::Point const &iE,
+static void ArcAnglesAndCenter(Geom::Point const &iS, Geom::Point const &iE,
double rx, double ry, double angle,
bool large, bool wise,
- double &sang, double &eang, NR::Point &dr)
+ double &sang, double &eang, Geom::Point &dr)
{
- NR::Point se = iE - iS;
- NR::Point ca(cos(angle), sin(angle));
- NR::Point cse(dot(se, ca), cross(se, ca));
+ Geom::Point se = iE - iS;
+ Geom::Point ca(cos(angle), sin(angle));
+ Geom::Point cse(dot(se, ca), cross(se, ca));
cse[0] /= rx;
cse[1] /= ry;
double const lensq = dot(cse,cse);
- NR::Point csd = ( ( lensq < 4
+ Geom::Point csd = ( ( lensq < 4
? sqrt( 1/lensq - .25 )
: 0.0 )
* cse.ccw() );
- NR::Point ra = -csd - 0.5 * cse;
+ Geom::Point ra = -csd - 0.5 * cse;
if ( ra[0] <= -1 ) {
sang = M_PI;
} else if ( ra[0] >= 1 ) {
-void Path::DoArc(NR::Point const &iS, NR::Point const &iE,
+void Path::DoArc(Geom::Point const &iS, Geom::Point const &iE,
double const rx, double const ry, double const angle,
bool const large, bool const wise, double const /*tresh*/)
{
double sang;
double eang;
- NR::Point dr_temp;
+ Geom::Point dr_temp;
ArcAnglesAndCenter(iS, iE, rx, ry, angle, large, wise, sang, eang, dr_temp);
Geom::Point dr = dr_temp;
/* TODO: This isn't as good numerically as treating iS and iE as primary. E.g. consider
}
-void Path::RecCubicTo( NR::Point const &iS, NR::Point const &isD,
- NR::Point const &iE, NR::Point const &ieD,
+void Path::RecCubicTo( Geom::Point const &iS, Geom::Point const &isD,
+ Geom::Point const &iE, Geom::Point const &ieD,
double tresh, int lev, double maxL)
{
- NR::Point se = iE - iS;
- const double dC = NR::L2(se);
+ Geom::Point se = iE - iS;
+ const double dC = Geom::L2(se);
if ( dC < 0.01 ) {
const double sC = dot(isD,isD);
if ( lev <= 0 ) {
return;
}
- NR::Point m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
- NR::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
+ Geom::Point m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
+ Geom::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
- NR::Point hisD = 0.5 * isD;
- NR::Point hieD = 0.5 * ieD;
+ Geom::Point hisD = 0.5 * isD;
+ Geom::Point hieD = 0.5 * ieD;
RecCubicTo(iS, hisD, m, md, tresh, lev - 1, maxL);
AddPoint(m);
}
{
- NR::Point m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
- NR::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
+ Geom::Point m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
+ Geom::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
- NR::Point hisD = 0.5 * isD;
- NR::Point hieD = 0.5 * ieD;
+ Geom::Point hisD = 0.5 * isD;
+ Geom::Point hieD = 0.5 * ieD;
RecCubicTo(iS, hisD, m, md, tresh, lev - 1, maxL);
AddPoint(m);
-void Path::RecBezierTo(const NR::Point &iP,
- const NR::Point &iS,
- const NR::Point &iE,
+void Path::RecBezierTo(const Geom::Point &iP,
+ const Geom::Point &iS,
+ const Geom::Point &iE,
double tresh, int lev, double maxL)
{
if ( lev <= 0 ) {
return;
}
- NR::Point ps = iS - iP;
- NR::Point pe = iE - iP;
- NR::Point se = iE - iS;
+ Geom::Point ps = iS - iP;
+ Geom::Point pe = iE - iP;
+ Geom::Point se = iE - iS;
double s = fabs(cross(pe, ps));
if ( s < tresh ) {
const double l = L2(se);
if ( maxL > 0 && l > maxL ) {
- const NR::Point m = 0.25 * (iS + iE + 2 * iP);
- NR::Point md = 0.5 * (iS + iP);
+ const Geom::Point m = 0.25 * (iS + iE + 2 * iP);
+ Geom::Point md = 0.5 * (iS + iP);
RecBezierTo(md, iS, m, tresh, lev - 1, maxL);
AddPoint(m);
md = 0.5 * (iP + iE);
}
{
- const NR::Point m = 0.25 * (iS + iE + 2 * iP);
- NR::Point md = 0.5 * (iS + iP);
+ const Geom::Point m = 0.25 * (iS + iE + 2 * iP);
+ Geom::Point md = 0.5 * (iS + iP);
RecBezierTo(md, iS, m, tresh, lev - 1, maxL);
AddPoint(m);
md = 0.5 * (iP + iE);
}
-void Path::DoArc(NR::Point const &iS, NR::Point const &iE,
+void Path::DoArc(Geom::Point const &iS, Geom::Point const &iE,
double const rx, double const ry, double const angle,
bool const large, bool const wise, double const /*tresh*/, int const piece)
{
double sang;
double eang;
- NR::Point dr_temp;
+ Geom::Point dr_temp;
ArcAnglesAndCenter(iS, iE, rx, ry, angle, large, wise, sang, eang, dr_temp);
Geom::Point dr = dr_temp;
/* TODO: This isn't as good numerically as treating iS and iE as primary. E.g. consider
}
}
-void Path::RecCubicTo(NR::Point const &iS, NR::Point const &isD,
- NR::Point const &iE, NR::Point const &ieD,
+void Path::RecCubicTo(Geom::Point const &iS, Geom::Point const &isD,
+ Geom::Point const &iE, Geom::Point const &ieD,
double tresh, int lev, double st, double et, int piece)
{
- const NR::Point se = iE - iS;
- const double dC = NR::L2(se);
+ const Geom::Point se = iE - iS;
+ const double dC = Geom::L2(se);
if ( dC < 0.01 ) {
const double sC = dot(isD, isD);
const double eC = dot(ieD, ieD);
return;
}
- NR::Point m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
- NR::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
+ Geom::Point m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
+ Geom::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
double mt = (st + et) / 2;
- NR::Point hisD = 0.5 * isD;
- NR::Point hieD = 0.5 * ieD;
+ Geom::Point hisD = 0.5 * isD;
+ Geom::Point hieD = 0.5 * ieD;
RecCubicTo(iS, hisD, m, md, tresh, lev - 1, st, mt, piece);
AddPoint(m, piece, mt);
-void Path::RecBezierTo(NR::Point const &iP,
- NR::Point const &iS,
- NR::Point const &iE,
+void Path::RecBezierTo(Geom::Point const &iP,
+ Geom::Point const &iS,
+ Geom::Point const &iE,
double tresh, int lev, double st, double et, int piece)
{
if ( lev <= 0 ) {
return;
}
- NR::Point ps = iS - iP;
- NR::Point pe = iE - iP;
+ Geom::Point ps = iS - iP;
+ Geom::Point pe = iE - iP;
const double s = fabs(cross(pe, ps));
if ( s < tresh ) {
return;
{
const double mt = (st + et) / 2;
- const NR::Point m = 0.25 * (iS + iE + 2 * iP);
+ const Geom::Point m = 0.25 * (iS + iE + 2 * iP);
RecBezierTo(0.5 * (iS + iP), iS, m, tresh, lev - 1, st, mt, piece);
AddPoint(m, piece, mt);
RecBezierTo(0.5 * (iP + iE), m, iE, tresh, lev - 1, mt, et, piece);
-void Path::DoArc(NR::Point const &iS, NR::Point const &iE,
+void Path::DoArc(Geom::Point const &iS, Geom::Point const &iE,
double const rx, double const ry, double const angle,
bool const large, bool const wise, double const /*tresh*/,
int const piece, offset_orig &/*orig*/)
double sang;
double eang;
- NR::Point dr_temp;
+ Geom::Point dr_temp;
ArcAnglesAndCenter(iS, iE, rx, ry, angle, large, wise, sang, eang, dr_temp);
Geom::Point dr = dr_temp;
/* TODO: This isn't as good numerically as treating iS and iE as primary. E.g. consider
}
-void Path::RecCubicTo(NR::Point const &iS, NR::Point const &isD,
- NR::Point const &iE, NR::Point const &ieD,
+void Path::RecCubicTo(Geom::Point const &iS, Geom::Point const &isD,
+ Geom::Point const &iE, Geom::Point const &ieD,
double tresh, int lev, double st, double et,
int piece, offset_orig &orig)
{
- const NR::Point se = iE - iS;
- const double dC = NR::L2(se);
+ const Geom::Point se = iE - iS;
+ const double dC = Geom::L2(se);
bool doneSub = false;
if ( dC < 0.01 ) {
const double sC = dot(isD, isD);
bool stInv = false;
bool enInv = false;
{
- NR::Point os_pos;
- NR::Point os_tgt;
- NR::Point oe_pos;
- NR::Point oe_tgt;
+ Geom::Point os_pos;
+ Geom::Point os_tgt;
+ Geom::Point oe_pos;
+ Geom::Point oe_tgt;
orig.orig->PointAndTangentAt(orig.piece, orig.tSt * (1 - st) + orig.tEn * st, os_pos, os_tgt);
orig.orig->PointAndTangentAt(orig.piece, orig.tSt * (1 - et) + orig.tEn * et, oe_pos, oe_tgt);
- NR::Point n_tgt = isD;
+ Geom::Point n_tgt = isD;
double si = dot(n_tgt, os_tgt);
if ( si < 0 ) {
stInv = true;
}
{
- const NR::Point m = 0.5 * (iS+iE) + 0.125 * (isD - ieD);
- const NR::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
+ const Geom::Point m = 0.5 * (iS+iE) + 0.125 * (isD - ieD);
+ const Geom::Point md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
const double mt = (st + et) / 2;
- const NR::Point hisD = 0.5 * isD;
- const NR::Point hieD = 0.5 * ieD;
+ const Geom::Point hisD = 0.5 * isD;
+ const Geom::Point hieD = 0.5 * ieD;
RecCubicTo(iS, hisD, m, md, tresh, lev - 1, st, mt, piece, orig);
AddPoint(m, piece, mt);
-void Path::RecBezierTo(NR::Point const &iP, NR::Point const &iS,NR::Point const &iE,
+void Path::RecBezierTo(Geom::Point const &iP, Geom::Point const &iS,Geom::Point const &iE,
double tresh, int lev, double st, double et,
int piece, offset_orig& orig)
{
@@ -1474,8 +1474,8 @@ void Path::RecBezierTo(NR::Point const &iP, NR::Point const &iS,NR::Point const
return;
}
- const NR::Point ps = iS - iP;
- const NR::Point pe = iE - iP;
+ const Geom::Point ps = iS - iP;
+ const Geom::Point pe = iE - iP;
const double s = fabs(cross(pe, ps));
if ( s < tresh ) {
doneSub = true ;
@@ -1485,12 +1485,12 @@ void Path::RecBezierTo(NR::Point const &iP, NR::Point const &iS,NR::Point const
bool stInv = false;
bool enInv = false;
{
- NR::Point os_pos;
- NR::Point os_tgt;
- NR::Point oe_pos;
- NR::Point oe_tgt;
- NR::Point n_tgt;
- NR::Point n_pos;
+ Geom::Point os_pos;
+ Geom::Point os_tgt;
+ Geom::Point oe_pos;
+ Geom::Point oe_tgt;
+ Geom::Point n_tgt;
+ Geom::Point n_pos;
double n_len;
double n_rad;
@@ -1526,8 +1526,8 @@ void Path::RecBezierTo(NR::Point const &iP, NR::Point const &iS,NR::Point const
{
double mt = (st + et) / 2;
- NR::Point m = 0.25 * (iS + iE + 2 * iP);
- NR::Point md = 0.5 * (iS + iP);
+ Geom::Point m = 0.25 * (iS + iE + 2 * iP);
+ Geom::Point md = 0.5 * (iS + iP);
RecBezierTo(md, iS, m, tresh, lev - 1, st, mt, piece, orig);
AddPoint(m, piece, mt);
md = 0.5 * (iP + iE);
index 025cf00a78a52fa03f6fa25a642054260c16faf3..4a5aec0f5e8029c314cb537eb87813639a7efa33 100644 (file)
@@ -96,12 +96,12 @@ void Path::DashSubPath(int spL, int spP, std::vector<path_lineto> const &orig_pt
if ( spL <= 0 || spP == -1 ) return;
double totLength=0;
- NR::Point lastP;
+ Geom::Point lastP;
lastP = orig_pts[spP].p;
for (int i=1;i<spL;i++) {
- NR::Point const n = orig_pts[spP + i].p;
- NR::Point d=n-lastP;
- double nl=NR::L2(d);
+ Geom::Point const n = orig_pts[spP + i].p;
+ Geom::Point d=n-lastP;
+ double nl=Geom::L2(d);
if ( nl > 0.0001 ) {
totLength+=nl;
lastP=n;
@@ -118,7 +118,7 @@ void Path::DashSubPath(int spL, int spP, std::vector<path_lineto> const &orig_pt
int lastPiece=-1;
lastP = orig_pts[spP].p;
for (int i=1;i<spL;i++) {
- NR::Point n;
+ Geom::Point n;
int nPiece=-1;
double nT=0;
if ( back ) {
@@ -128,8 +128,8 @@ void Path::DashSubPath(int spL, int spP, std::vector<path_lineto> const &orig_pt
} else {
n = orig_pts[spP + i].p;
}
- NR::Point d=n-lastP;
- double nl=NR::L2(d);
+ Geom::Point d=n-lastP;
+ double nl=Geom::L2(d);
if ( nl > 0.0001 ) {
double stLength=curLength;
double enLength=curLength+nl;
@@ -150,7 +150,7 @@ void Path::DashSubPath(int spL, int spP, std::vector<path_lineto> const &orig_pt
}
}
if ( nPlain == true && dashPlain == false ) {
- NR::Point p=(enLength-curLength)*lastP+(curLength-stLength)*n;
+ Geom::Point p=(enLength-curLength)*lastP+(curLength-stLength)*n;
p/=(enLength-stLength);
if ( back ) {
double pT=0;
@@ -188,7 +188,7 @@ void Path::DashSubPath(int spL, int spP, std::vector<path_lineto> const &orig_pt
nPlain=dashPlain;
}
if ( nPlain == true && dashPlain == false ) {
- NR::Point p=(enLength-curLength-leftInDash)*lastP+(curLength+leftInDash-stLength)*n;
+ Geom::Point p=(enLength-curLength-leftInDash)*lastP+(curLength+leftInDash-stLength)*n;
p/=(enLength-stLength);
if ( back ) {
double pT=0;
@@ -202,7 +202,7 @@ void Path::DashSubPath(int spL, int spP, std::vector<path_lineto> const &orig_pt
AddPoint(p,true);
}
} else if ( nPlain == false && dashPlain == true ) {
- NR::Point p=(enLength-curLength-leftInDash)*lastP+(curLength+leftInDash-stLength)*n;
+ Geom::Point p=(enLength-curLength-leftInDash)*lastP+(curLength+leftInDash-stLength)*n;
p/=(enLength-stLength);
if ( back ) {
double pT=0;
@@ -242,7 +242,7 @@ void Path::DashSubPath(int spL, int spP, std::vector<path_lineto> const &orig_pt
bool nPlain=false;
if ( nPlain == true && dashPlain == false ) {
} else if ( nPlain == false && dashPlain == true ) {
- NR::Point p=(enLength-curLength)*lastP+(curLength-stLength)*n;
+ Geom::Point p=(enLength-curLength)*lastP+(curLength-stLength)*n;
p/=(enLength-stLength);
if ( back ) {
double pT=0;
Geom::PathVector *pv = new Geom::PathVector();
Geom::Path * currentpath = NULL;
- NR::Point lastP,bezSt,bezEn;
+ Geom::Point lastP,bezSt,bezEn;
int bezNb=0;
for (int i=0;i<int(descr_cmd.size());i++) {
int const typ = descr_cmd[i]->getType();
{
if ( bezNb > 0 ) {
PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[i]);
- NR::Point p_m=nData->p,p_s=0.5*(bezSt+p_m),p_e;
+ Geom::Point p_m=nData->p,p_s=0.5*(bezSt+p_m),p_e;
if ( bezNb > 1 ) {
PathDescrIntermBezierTo *iData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[i+1]);
p_e=0.5*(p_m+iData->p);
p_e=bezEn;
}
- NR::Point cp1=0.333333*(p_s+2*p_m),cp2=0.333333*(2*p_m+p_e);
+ Geom::Point cp1=0.333333*(p_s+2*p_m),cp2=0.333333*(2*p_m+p_e);
gdouble x1=cp1[0];
gdouble y1=cp1[1];
gdouble x2=cp2[0];
return 0;
}
- NR::Point lastP = pts[0].p;
+ Geom::Point lastP = pts[0].p;
double len = 0;
for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); i++) {
if ( i->isMoveTo != polyline_moveto ) {
- len += NR::L2(i->p - lastP);
+ len += Geom::L2(i->p - lastP);
}
lastP = i->p;
return 0;
}
- NR::Point lastM = pts[0].p;
- NR::Point lastP = lastM;
+ Geom::Point lastM = pts[0].p;
+ Geom::Point lastP = lastM;
double surf = 0;
for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); i++) {
void Path::ConvertForcedToMoveTo()
{
- NR::Point lastSeen(0, 0);
- NR::Point lastMove(0, 0);
+ Geom::Point lastSeen(0, 0);
+ Geom::Point lastMove(0, 0);
{
- NR::Point lastPos(0, 0);
+ Geom::Point lastPos(0, 0);
for (int i = int(descr_cmd.size()) - 1; i >= 0; i--) {
int const typ = descr_cmd[i]->getType();
switch ( typ ) {
@@ -900,8 +900,8 @@ Path::cut_position* Path::CurvilignToPosition(int nbCv, double *cvAbs, int &nbCu
double lastT = 0;
int lastPiece = -1;
- NR::Point lastM = pts[0].p;
- NR::Point lastP = lastM;
+ Geom::Point lastM = pts[0].p;
+ Geom::Point lastP = lastM;
for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); i++) {
@@ -913,7 +913,7 @@ Path::cut_position* Path::CurvilignToPosition(int nbCv, double *cvAbs, int &nbCu
} else {
- double const add = NR::L2(i->p - lastP);
+ double const add = Geom::L2(i->p - lastP);
double curPos = len;
double curAdd = add;
*/
template<typename T> inline static T square(T x) {return x*x;}
-Path::cut_position Path::PointToCurvilignPosition(NR::Point const &pos, unsigned seg) const
+Path::cut_position Path::PointToCurvilignPosition(Geom::Point const &pos, unsigned seg) const
{
// if the parameter "seg" == 0, then all segments will be considered
// In however e.g. "seg" == 6 , then only the 6th segment will be considered
@@ -959,16 +959,16 @@ Path::cut_position Path::PointToCurvilignPosition(NR::Point const &pos, unsigned
for (unsigned i = 1 ; i < pts.size() ; i++) {
if (pts[i].isMoveTo == polyline_moveto || (seg > 0 && i != seg)) continue;
- NR::Point p1, p2, localPos;
+ Geom::Point p1, p2, localPos;
double thisRangeSquared;
double t;
if (pts[i - 1].p == pts[i].p) {
- thisRangeSquared = square(pts[i].p[NR::X] - pos[NR::X]) + square(pts[i].p[NR::Y] - pos[NR::Y]);
+ thisRangeSquared = square(pts[i].p[Geom::X] - pos[Geom::X]) + square(pts[i].p[Geom::Y] - pos[Geom::Y]);
t = 0.0;
} else {
// we rotate all our coordinates so we're always looking at a mostly vertical line.
- if (fabs(pts[i - 1].p[NR::X] - pts[i].p[NR::X]) < fabs(pts[i - 1].p[NR::Y] - pts[i].p[NR::Y])) {
+ if (fabs(pts[i - 1].p[Geom::X] - pts[i].p[Geom::X]) < fabs(pts[i - 1].p[Geom::Y] - pts[i].p[Geom::Y])) {
p1 = pts[i - 1].p;
p2 = pts[i].p;
localPos = pos;
@@ -977,32 +977,32 @@ Path::cut_position Path::PointToCurvilignPosition(NR::Point const &pos, unsigned
p2 = pts[i].p.cw();
localPos = pos.cw();
}
- double gradient = (p2[NR::X] - p1[NR::X]) / (p2[NR::Y] - p1[NR::Y]);
- double intersection = p1[NR::X] - gradient * p1[NR::Y];
+ double gradient = (p2[Geom::X] - p1[Geom::X]) / (p2[Geom::Y] - p1[Geom::Y]);
+ double intersection = p1[Geom::X] - gradient * p1[Geom::Y];
/*
orthogonalGradient = -1.0 / gradient; // you are going to have numerical problems here.
- orthogonalIntersection = localPos[NR::X] - orthogonalGradient * localPos[NR::Y];
+ orthogonalIntersection = localPos[Geom::X] - orthogonalGradient * localPos[Geom::Y];
nearestY = (orthogonalIntersection - intersection) / (gradient - orthogonalGradient);
expand out nearestY fully :
- nearestY = (localPos[NR::X] - (-1.0 / gradient) * localPos[NR::Y] - intersection) / (gradient - (-1.0 / gradient));
+ nearestY = (localPos[Geom::X] - (-1.0 / gradient) * localPos[Geom::Y] - intersection) / (gradient - (-1.0 / gradient));
multiply top and bottom by gradient:
- nearestY = (localPos[NR::X] * gradient - (-1.0) * localPos[NR::Y] - intersection * gradient) / (gradient * gradient - (-1.0));
+ nearestY = (localPos[Geom::X] * gradient - (-1.0) * localPos[Geom::Y] - intersection * gradient) / (gradient * gradient - (-1.0));
and simplify to get:
*/
- double nearestY = (localPos[NR::X] * gradient + localPos[NR::Y] - intersection * gradient)
+ double nearestY = (localPos[Geom::X] * gradient + localPos[Geom::Y] - intersection * gradient)
/ (gradient * gradient + 1.0);
- t = (nearestY - p1[NR::Y]) / (p2[NR::Y] - p1[NR::Y]);
+ t = (nearestY - p1[Geom::Y]) / (p2[Geom::Y] - p1[Geom::Y]);
if (t <= 0.0) {
- thisRangeSquared = square(p1[NR::X] - localPos[NR::X]) + square(p1[NR::Y] - localPos[NR::Y]);
+ thisRangeSquared = square(p1[Geom::X] - localPos[Geom::X]) + square(p1[Geom::Y] - localPos[Geom::Y]);
t = 0.0;
} else if (t >= 1.0) {
- thisRangeSquared = square(p2[NR::X] - localPos[NR::X]) + square(p2[NR::Y] - localPos[NR::Y]);
+ thisRangeSquared = square(p2[Geom::X] - localPos[Geom::X]) + square(p2[Geom::Y] - localPos[Geom::Y]);
t = 1.0;
} else {
- thisRangeSquared = square(nearestY * gradient + intersection - localPos[NR::X]) + square(nearestY - localPos[NR::Y]);
+ thisRangeSquared = square(nearestY * gradient + intersection - localPos[Geom::X]) + square(nearestY - localPos[Geom::Y]);
}
}
for (unsigned i = 1 ; i < pts.size() ; i++) {
if (pts[i].isMoveTo == polyline_moveto) continue;
if (pts[i].piece == piece && t < pts[i].t) {
- length += NR::L2((t - pts[i - 1].t) / (pts[i].t - pts[i - 1].t) * (pts[i].p - pts[i - 1].p));
+ length += Geom::L2((t - pts[i - 1].t) / (pts[i].t - pts[i - 1].t) * (pts[i].p - pts[i - 1].p));
break;
}
- length += NR::L2(pts[i].p - pts[i - 1].p);
+ length += Geom::L2(pts[i].p - pts[i - 1].p);
}
return length;
}
}
{
- NR::Point lastPos(0, 0);
+ Geom::Point lastPos(0, 0);
for (int i = int(descr_cmd.size()) - 1; i >= 0; i--) {
int const typ = descr_cmd[i]->getType();
switch ( typ ) {
case descr_close:
{
delete descr_cmd[i];
- descr_cmd[i] = new PathDescrLineTo(NR::Point(0, 0));
+ descr_cmd[i] = new PathDescrLineTo(Geom::Point(0, 0));
int fp = i - 1;
while ( fp >= 0 && (descr_cmd[fp]->getType()) != descr_moveto ) {
case descr_bezierto:
{
PathDescrBezierTo *nData = dynamic_cast<PathDescrBezierTo *>(descr_cmd[i]);
- NR::Point theP = nData->p;
+ Geom::Point theP = nData->p;
if ( nData->nb == 0 ) {
lastPos = theP;
}
// ponctuel= rien a faire
} else if ( typ == descr_lineto || typ == descr_arcto || typ == descr_cubicto ) {
// facile: creation d'un morceau et d'un forced -> 2 commandes
- NR::Point theP;
- NR::Point theT;
- NR::Point startP;
+ Geom::Point theP;
+ Geom::Point theT;
+ Geom::Point startP;
startP=PrevPoint(cp-1);
if ( typ == descr_cubicto ) {
double len,rad;
- NR::Point stD,enD,endP;
+ Geom::Point stD,enD,endP;
{
PathDescrCubicTo *oData = dynamic_cast<PathDescrCubicTo *>(descr_cmd[cp]);
stD=oData->start;
}
}
} else if ( typ == descr_lineto ) {
- NR::Point endP;
+ Geom::Point endP;
{
PathDescrLineTo *oData = dynamic_cast<PathDescrLineTo *>(descr_cmd[cp]);
endP=oData->p;
}
}
} else if ( typ == descr_arcto ) {
- NR::Point endP;
+ Geom::Point endP;
double rx,ry,angle;
bool clockw,large;
double delta=0;
PathDescrBezierTo theBD=*(dynamic_cast<PathDescrBezierTo *>(descr_cmd[theBDI]));
if ( cp >= theBDI && cp < theBDI+theBD.nb ) {
if ( theBD.nb == 1 ) {
- NR::Point endP=theBD.p;
- NR::Point midP;
- NR::Point startP;
+ Geom::Point endP=theBD.p;
+ Geom::Point midP;
+ Geom::Point startP;
startP=PrevPoint(theBDI-1);
{
PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[theBDI+1]);
midP=nData->p;
}
- NR::Point aP=ct*midP+(1-ct)*startP;
- NR::Point bP=ct*endP+(1-ct)*midP;
- NR::Point knotP=ct*bP+(1-ct)*aP;
+ Geom::Point aP=ct*midP+(1-ct)*startP;
+ Geom::Point bP=ct*endP+(1-ct)*midP;
+ Geom::Point knotP=ct*bP+(1-ct)*aP;
InsertIntermBezierTo(bP,theBDI+2);
InsertBezierTo(knotP,1,theBDI+2);
} else {
// decouper puis repasser
if ( cp > theBDI ) {
- NR::Point pcP,ncP;
+ Geom::Point pcP,ncP;
{
PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[cp]);
pcP=nData->p;
PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[cp+1]);
ncP=nData->p;
}
- NR::Point knotP=0.5*(pcP+ncP);
+ Geom::Point knotP=0.5*(pcP+ncP);
InsertBezierTo(knotP,theBD.nb-(cp-theBDI),cp+1);
{
}
curP--;
} else {
- NR::Point pcP,ncP;
+ Geom::Point pcP,ncP;
{
PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[cp+1]);
pcP=nData->p;
PathDescrIntermBezierTo *nData = dynamic_cast<PathDescrIntermBezierTo *>(descr_cmd[cp+2]);
ncP=nData->p;
}
- NR::Point knotP=0.5*(pcP+ncP);
+ Geom::Point knotP=0.5*(pcP+ncP);
InsertBezierTo(knotP,theBD.nb-1,cp+2);
{
Path* res=new Path;
- NR::Point lastP(0,0);
+ Geom::Point lastP(0,0);
for (int i=0;i<int(descr_cmd.size());i++) {
int const typ = descr_cmd[i]->getType();
if ( typ == descr_moveto ) {
- NR::Point np;
+ Geom::Point np;
{
PathDescrMoveTo *nData = dynamic_cast<PathDescrMoveTo *>(descr_cmd[i]);
np=nData->p;
}
- NR::Point endP;
+ Geom::Point endP;
bool hasClose=false;
int hasForced=-1;
bool doesClose=false;
if ( ( doesClose || hasClose ) && hasForced >= 0 ) {
// printf("nasty i=%i j=%i frc=%i\n",i,j,hasForced);
// aghhh.
- NR::Point nMvtP=PrevPoint(hasForced);
+ Geom::Point nMvtP=PrevPoint(hasForced);
res->MoveTo(nMvtP);
- NR::Point nLastP=nMvtP;
+ Geom::Point nLastP=nMvtP;
for (int k = hasForced + 1; k < j; k++) {
int ntyp=descr_cmd[k]->getType();
if ( ntyp == descr_moveto ) {
index 67b5370f24df57f2a851c455c39c590fa048cb8f..cd405d664bbce1de576fa8b279c2938d7344809c 100644 (file)
dest->SetBackData(false);
outline_callbacks calls;
- NR::Point endButt;
- NR::Point endPos;
+ Geom::Point endButt;
+ Geom::Point endPos;
calls.cubicto = StdCubicTo;
calls.bezierto = StdBezierTo;
calls.arcto = StdArcTo;
// we do so by taking the subpath in the reverse and constructing a path as appropriate
// the construct is stored in "rev"
int curD = curP - 1;
- NR::Point curX;
- NR::Point nextX;
+ Geom::Point curX;
+ Geom::Point nextX;
int firstTyp = descr_cmd[curD]->getType();
bool const needClose = (firstTyp == descr_close);
while (curD > lastM && descr_cmd[curD]->getType() == descr_close) {
@@ -102,8 +102,8 @@ void Path::Outline(Path *dest, double width, JoinType join, ButtType butt, doubl
} else if (typ == descr_cubicto) {
PathDescrCubicTo* nData = dynamic_cast<PathDescrCubicTo*>(descr_cmd[curD]);
nextX = PrevPoint (curD - 1);
- NR::Point isD=-nData->start;
- NR::Point ieD=-nData->end;
+ Geom::Point isD=-nData->start;
+ Geom::Point ieD=-nData->end;
rev->CubicTo (nextX, ieD,isD);
curX = nextX;
curD--;
@@ -157,7 +157,7 @@ void Path::Outline(Path *dest, double width, JoinType join, ButtType butt, doubl
rev->SubContractOutline (0, rev->descr_cmd.size(),
dest, calls, 0.0025 * width * width, width,
join, butt, miter, false, false, endPos, endButt);
- NR::Point endNor=endButt.ccw();
+ Geom::Point endNor=endButt.ccw();
if (butt == butt_round) {
dest->ArcTo (endPos+width*endNor, 1.0001 * width, 1.0001 * width, 0.0, true, true);
} else if (butt == butt_square) {
dest->SetBackData (false);
outline_callbacks calls;
- NR::Point endButt, endPos;
+ Geom::Point endButt, endPos;
calls.cubicto = StdCubicTo;
calls.bezierto = StdBezierTo;
calls.arcto = StdArcTo;
dest->SetBackData (false);
outline_callbacks calls;
- NR::Point endButt, endPos;
+ Geom::Point endButt, endPos;
calls.cubicto = StdCubicTo;
calls.bezierto = StdBezierTo;
calls.arcto = StdArcTo;
// Otherwise there's only one point. (tr: or "only a point")
// [sinon il n'y a qu'un point]
int curD = curP - 1;
- NR::Point curX;
- NR::Point nextX;
+ Geom::Point curX;
+ Geom::Point nextX;
while (curD > lastM && (descr_cmd[curD]->getType()) == descr_close) curD--;
if (curD > lastM) {
curX = PrevPoint (curD);
} else if (typ == descr_cubicto) {
PathDescrCubicTo *nData = dynamic_cast<PathDescrCubicTo*>(descr_cmd[curD]);
nextX = PrevPoint (curD - 1);
- NR::Point isD=-nData->start;
- NR::Point ieD=-nData->end;
+ Geom::Point isD=-nData->start;
+ Geom::Point ieD=-nData->end;
rev->CubicTo (nextX, ieD,isD);
curX = nextX;
curD--;
Path *dest, outline_callbacks & calls,
double tolerance, double width, JoinType join,
ButtType /*butt*/, double miter, bool closeIfNeeded,
- bool skipMoveto, NR::Point &lastP, NR::Point &lastT)
+ bool skipMoveto, Geom::Point &lastP, Geom::Point &lastT)
{
outline_callback_data callsData;
int curP = 1;
// le moveto
- NR::Point curX;
+ Geom::Point curX;
{
int firstTyp = descr_cmd[off]->getType();
if ( firstTyp != descr_moveto ) {
curX = nData->p;
}
}
- NR::Point curT(0, 0);
+ Geom::Point curT(0, 0);
bool doFirst = true;
- NR::Point firstP(0, 0);
- NR::Point firstT(0, 0);
+ Geom::Point firstP(0, 0);
+ Geom::Point firstT(0, 0);
// et le reste, 1 par 1
while (curP < num_pd)
{
int curD = off + curP;
int nType = descr_cmd[curD]->getType();
- NR::Point nextX;
- NR::Point stPos, enPos, stTgt, enTgt, stNor, enNor;
+ Geom::Point nextX;
+ Geom::Point stPos, enPos, stTgt, enTgt, stNor, enNor;
double stRad, enRad, stTle, enTle;
if (nType == descr_forced) {
curP++;
// jointure
{
- NR::Point pos;
+ Geom::Point pos;
pos = curX;
OutlineJoin (dest, pos, curT, stNor, width, join,
miter);
// jointure
{
- NR::Point pos;
+ Geom::Point pos;
pos = firstP;
OutlineJoin (dest, enPos, enNor, firstT, width, join,
miter);
else
{
// jointure
- NR::Point pos;
+ Geom::Point pos;
pos = curX;
OutlineJoin (dest, pos, curT, stNor, width, join, miter);
}
else
{
// jointure
- NR::Point pos;
+ Geom::Point pos;
pos = curX;
OutlineJoin (dest, pos, curT, stNor, width, join, miter);
}
else
{
// jointure
- NR::Point pos;
+ Geom::Point pos;
pos = curX;
OutlineJoin (dest, pos, curT, stNor, width, join, miter);
}
} else dest->MoveTo (curX+width*stNor);
} else {
// jointure
- NR::Point pos;
+ Geom::Point pos;
pos = curX;
if (stTle > 0) OutlineJoin (dest, pos, curT, stNor, width, join, miter);
}
dest->descr_cmd[n_d]->tEn = 1.0;
}
} else if (nbInterm == 1) {
- NR::Point midX;
+ Geom::Point midX;
midX = nData->p;
// et on avance
TangentOnBezAt (0.0, curX, *nData, *nBData, false, stPos, stTgt, stTle, stRad);
} else dest->MoveTo (curX+width*stNor);
} else {
// jointure
- NR::Point pos;
+ Geom::Point pos;
pos = curX;
OutlineJoin (dest, pos, curT, stNor, width, join, miter);
}
(calls.bezierto) (&callsData, tolerance, width);
} else if (nbInterm > 1) {
- NR::Point bx=curX;
- NR::Point cx=curX;
- NR::Point dx=curX;
+ Geom::Point bx=curX;
+ Geom::Point cx=curX;
+ Geom::Point dx=curX;
dx = nData->p;
TangentOnBezAt (0.0, curX, *nData, *nBData, false, stPos, stTgt, stTle, stRad);
} else dest->MoveTo (curX+width*stNor);
} else {
// jointure
- NR::Point pos=curX;
+ Geom::Point pos=curX;
OutlineJoin (dest, pos, stTgt, stNor, width, join, miter);
// dest->LineTo(curX+width*stNor.x,curY+width*stNor.y);
}
dx = nData->p;
ip++;
nData = dynamic_cast<PathDescrIntermBezierTo*>(descr_cmd[ip]);
- NR::Point stx = (bx + cx) / 2;
+ Geom::Point stx = (bx + cx) / 2;
// double stw=(bw+cw)/2;
PathDescrBezierTo tempb((cx + dx) / 2, 1);
dx = nextX;
dx = 2 * dx - cx;
- NR::Point stx = (bx + cx) / 2;
+ Geom::Point stx = (bx + cx) / 2;
// double stw=(bw+cw)/2;
PathDescrBezierTo tempb((cx + dx) / 2, 1);
// like the name says: check whether the path command is actually more than a dumb point.
bool
-Path::IsNulCurve (std::vector<PathDescr*> const &cmd, int curD, NR::Point const &curX)
+Path::IsNulCurve (std::vector<PathDescr*> const &cmd, int curD, Geom::Point const &curX)
{
switch(cmd[curD]->getType()) {
case descr_lineto:
case descr_cubicto:
{
PathDescrCubicTo *nData = dynamic_cast<PathDescrCubicTo*>(cmd[curD]);
- NR::Point A = nData->start + nData->end + 2*(curX - nData->p);
- NR::Point B = 3*(nData->p - curX) - 2*nData->start - nData->end;
- NR::Point C = nData->start;
+ Geom::Point A = nData->start + nData->end + 2*(curX - nData->p);
+ Geom::Point B = 3*(nData->p - curX) - 2*nData->start - nData->end;
+ Geom::Point C = nData->start;
if (Geom::LInfty(A) < 0.0001
&& Geom::LInfty(B) < 0.0001
&& Geom::LInfty (C) < 0.0001) {
@@ -908,15 +908,15 @@ Path::IsNulCurve (std::vector<PathDescr*> const &cmd, int curD, NR::Point const
* \param len Filled in with the length of the segment.
*/
-void Path::TangentOnSegAt(double at, NR::Point const &iS, PathDescrLineTo const &fin,
- NR::Point &pos, NR::Point &tgt, double &len)
+void Path::TangentOnSegAt(double at, Geom::Point const &iS, PathDescrLineTo const &fin,
+ Geom::Point &pos, Geom::Point &tgt, double &len)
{
- NR::Point const iE = fin.p;
- NR::Point const seg = iE - iS;
+ Geom::Point const iE = fin.p;
+ Geom::Point const seg = iE - iS;
double const l = L2(seg);
if (l <= 0.000001) {
pos = iS;
- tgt = NR::Point(0, 0);
+ tgt = Geom::Point(0, 0);
len = 0;
} else {
tgt = seg / l;
@@ -926,10 +926,10 @@ void Path::TangentOnSegAt(double at, NR::Point const &iS, PathDescrLineTo const
}
// barf
-void Path::TangentOnArcAt(double at, const NR::Point &iS, PathDescrArcTo const &fin,
- NR::Point &pos, NR::Point &tgt, double &len, double &rad)
+void Path::TangentOnArcAt(double at, const Geom::Point &iS, PathDescrArcTo const &fin,
+ Geom::Point &pos, Geom::Point &tgt, double &len, double &rad)
{
- NR::Point const iE = fin.p;
+ Geom::Point const iE = fin.p;
double const rx = fin.rx;
double const ry = fin.ry;
double const angle = fin.angle;
@@ -1045,7 +1045,7 @@ void Path::TangentOnArcAt(double at, const NR::Point &iS, PathDescrArcTo const &
pos[1] = dry + sa * rx * cb + ca * ry * sb;
tgt[0] = ca * rx * sb + sa * ry * cb;
tgt[1] = sa * rx * sb - ca * ry * cb;
- NR::Point dtgt;
+ Geom::Point dtgt;
dtgt[0] = -ca * rx * cb + sa * ry * sb;
dtgt[1] = -sa * rx * cb - ca * ry * sb;
len = L2(tgt);
@@ -1062,7 +1062,7 @@ void Path::TangentOnArcAt(double at, const NR::Point &iS, PathDescrArcTo const &
pos[1] = dry + sa * rx * cb + ca * ry * sb;
tgt[0] = ca * rx * sb + sa * ry * cb;
tgt[1] = sa * rx * sb - ca * ry * cb;
- NR::Point dtgt;
+ Geom::Point dtgt;
dtgt[0] = -ca * rx * cb + sa * ry * sb;
dtgt[1] = -sa * rx * cb - ca * ry * sb;
len = L2(tgt);
@@ -1071,28 +1071,28 @@ void Path::TangentOnArcAt(double at, const NR::Point &iS, PathDescrArcTo const &
}
}
void
-Path::TangentOnCubAt (double at, NR::Point const &iS, PathDescrCubicTo const &fin, bool before,
- NR::Point &pos, NR::Point &tgt, double &len, double &rad)
+Path::TangentOnCubAt (double at, Geom::Point const &iS, PathDescrCubicTo const &fin, bool before,
+ Geom::Point &pos, Geom::Point &tgt, double &len, double &rad)
{
- const NR::Point E = fin.p;
- const NR::Point Sd = fin.start;
- const NR::Point Ed = fin.end;
+ const Geom::Point E = fin.p;
+ const Geom::Point Sd = fin.start;
+ const Geom::Point Ed = fin.end;
pos = iS;
- tgt = NR::Point(0,0);
+ tgt = Geom::Point(0,0);
len = rad = 0;
- const NR::Point A = Sd + Ed - 2*E + 2*iS;
- const NR::Point B = 0.5*(Ed - Sd);
- const NR::Point C = 0.25*(6*E - 6*iS - Sd - Ed);
- const NR::Point D = 0.125*(4*iS + 4*E - Ed + Sd);
+ const Geom::Point A = Sd + Ed - 2*E + 2*iS;
+ const Geom::Point B = 0.5*(Ed - Sd);
+ const Geom::Point C = 0.25*(6*E - 6*iS - Sd - Ed);
+ const Geom::Point D = 0.125*(4*iS + 4*E - Ed + Sd);
const double atb = at - 0.5;
pos = (atb * atb * atb)*A + (atb * atb)*B + atb*C + D;
- const NR::Point der = (3 * atb * atb)*A + (2 * atb)*B + C;
- const NR::Point dder = (6 * atb)*A + 2*B;
- const NR::Point ddder = 6 * A;
+ const Geom::Point der = (3 * atb * atb)*A + (2 * atb)*B + C;
+ const Geom::Point dder = (6 * atb)*A + 2*B;
+ const Geom::Point ddder = 6 * A;
- double l = NR::L2 (der);
+ double l = Geom::L2 (der);
// lots of nasty cases. inversion points are sadly too common...
if (l <= 0.0001) {
len = 0;
@@ -1125,26 +1125,26 @@ Path::TangentOnCubAt (double at, NR::Point const &iS, PathDescrCubicTo const &fi
}
void
-Path::TangentOnBezAt (double at, NR::Point const &iS,
+Path::TangentOnBezAt (double at, Geom::Point const &iS,
PathDescrIntermBezierTo & mid,
- PathDescrBezierTo & fin, bool before, NR::Point & pos,
- NR::Point & tgt, double &len, double &rad)
+ PathDescrBezierTo & fin, bool before, Geom::Point & pos,
+ Geom::Point & tgt, double &len, double &rad)
{
pos = iS;
- tgt = NR::Point(0,0);
+ tgt = Geom::Point(0,0);
len = rad = 0;
- const NR::Point A = fin.p + iS - 2*mid.p;
- const NR::Point B = 2*mid.p - 2 * iS;
- const NR::Point C = iS;
+ const Geom::Point A = fin.p + iS - 2*mid.p;
+ const Geom::Point B = 2*mid.p - 2 * iS;
+ const Geom::Point C = iS;
pos = at * at * A + at * B + C;
- const NR::Point der = 2 * at * A + B;
- const NR::Point dder = 2 * A;
- double l = NR::L2(der);
+ const Geom::Point der = 2 * at * A + B;
+ const Geom::Point dder = 2 * A;
+ double l = Geom::L2(der);
if (l <= 0.0001) {
- l = NR::L2(dder);
+ l = Geom::L2(dder);
if (l <= 0.0001) {
// pas de segment....
// Not a segment.
}
void
-Path::OutlineJoin (Path * dest, NR::Point pos, NR::Point stNor, NR::Point enNor, double width,
+Path::OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point enNor, double width,
JoinType join, double miter)
{
const double angSi = cross (enNor,stNor);
@@ -1194,15 +1194,15 @@ Path::OutlineJoin (Path * dest, NR::Point pos, NR::Point stNor, NR::Point enNor,
// l'arrondi des coordonnees des extremites
/* double angle=acos(angCo);
if ( angCo >= 0 ) {
- NR::Point stTgt,enTgt;
+ Geom::Point stTgt,enTgt;
RotCCWTo(stNor,stTgt);
RotCCWTo(enNor,enTgt);
dest->CubicTo(pos.x+width*enNor.x,pos.y+width*enNor.y,
angle*width*stTgt.x,angle*width*stTgt.y,
angle*width*enTgt.x,angle*width*enTgt.y);
} else {
- NR::Point biNor;
- NR::Point stTgt,enTgt,biTgt;
+ Geom::Point biNor;
+ Geom::Point stTgt,enTgt,biTgt;
biNor.x=stNor.x+enNor.x;
biNor.y=stNor.y+enNor.y;
double biL=sqrt(biNor.x*biNor.x+biNor.y*biNor.y);
@@ -1227,8 +1227,8 @@ Path::OutlineJoin (Path * dest, NR::Point pos, NR::Point stNor, NR::Point enNor,
false);
}
} else if (join == join_pointy) {
- NR::Point const biss = unit_vector(NR::rot90( stNor - enNor ));
- double c2 = NR::dot (biss, enNor);
+ Geom::Point const biss = unit_vector(Geom::rot90( stNor - enNor ));
+ double c2 = Geom::dot (biss, enNor);
double l = width / c2;
if ( fabs(l) > miter) {
dest->LineTo (pos + width*enNor);
Path::RecStdCubicTo (outline_callback_data * data, double tol, double width,
int lev)
{
- NR::Point stPos, miPos, enPos;
- NR::Point stTgt, enTgt, miTgt, stNor, enNor, miNor;
+ Geom::Point stPos, miPos, enPos;
+ Geom::Point stTgt, enTgt, miTgt, stNor, enNor, miNor;
double stRad, miRad, enRad;
double stTle, miTle, enTle;
// un cubic
{
- PathDescrCubicTo temp(NR::Point(data->x2, data->y2),
- NR::Point(data->d.c.dx1, data->d.c.dy1),
- NR::Point(data->d.c.dx2, data->d.c.dy2));
+ PathDescrCubicTo temp(Geom::Point(data->x2, data->y2),
+ Geom::Point(data->d.c.dx1, data->d.c.dy1),
+ Geom::Point(data->d.c.dx2, data->d.c.dy2));
- NR::Point initial_point(data->x1, data->y1);
+ Geom::Point initial_point(data->x1, data->y1);
TangentOnCubAt (0.0, initial_point, temp, false, stPos, stTgt, stTle,
stRad);
TangentOnCubAt (0.5, initial_point, temp, false, miPos, miTgt, miTle,
@@ -1298,18 +1298,18 @@ Path::RecStdCubicTo (outline_callback_data * data, double tol, double width,
return;
}
- NR::Point chk;
- const NR::Point req = miPos + width * miNor;
+ Geom::Point chk;
+ const Geom::Point req = miPos + width * miNor;
{
PathDescrCubicTo temp(enPos + width * enNor,
stGue * stTgt,
enGue * enTgt);
double chTle, chRad;
- NR::Point chTgt;
+ Geom::Point chTgt;
TangentOnCubAt (0.5, stPos+width*stNor,
temp, false, chk, chTgt, chTle, chRad);
}
- const NR::Point diff = req - chk;
+ const Geom::Point diff = req - chk;
const double err = dot(diff,diff);
if (err <= tol ) { // tolerance is given as a quadratic value, no need to use tol*tol here
// printf("%f <= %f %i\n",err,tol,lev);
@@ -1360,11 +1360,11 @@ Path::StdCubicTo (Path::outline_callback_data * data, double tol, double width)
void
Path::StdBezierTo (Path::outline_callback_data * data, double tol, double width)
{
- PathDescrBezierTo tempb(NR::Point(data->x2, data->y2), 1);
- PathDescrIntermBezierTo tempi(NR::Point(data->d.b.mx, data->d.b.my));
- NR::Point stPos, enPos, stTgt, enTgt;
+ PathDescrBezierTo tempb(Geom::Point(data->x2, data->y2), 1);
+ PathDescrIntermBezierTo tempi(Geom::Point(data->d.b.mx, data->d.b.my));
+ Geom::Point stPos, enPos, stTgt, enTgt;
double stRad, enRad, stTle, enTle;
- NR::Point tmp(data->x1,data->y1);
+ Geom::Point tmp(data->x1,data->y1);
TangentOnBezAt (0.0, tmp, tempi, tempb, false, stPos, stTgt,
stTle, stRad);
TangentOnBezAt (1.0, tmp, tempi, tempb, true, enPos, enTgt,
Path::RecStdArcTo (outline_callback_data * data, double tol, double width,
int lev)
{
- NR::Point stPos, miPos, enPos;
- NR::Point stTgt, enTgt, miTgt, stNor, enNor, miNor;
+ Geom::Point stPos, miPos, enPos;
+ Geom::Point stTgt, enTgt, miTgt, stNor, enNor, miNor;
double stRad, miRad, enRad;
double stTle, miTle, enTle;
// un cubic
{
- PathDescrArcTo temp(NR::Point(data->x2, data->y2),
+ PathDescrArcTo temp(Geom::Point(data->x2, data->y2),
data->d.a.rx, data->d.a.ry,
data->d.a.angle, data->d.a.large, data->d.a.clock);
- NR::Point tmp(data->x1,data->y1);
+ Geom::Point tmp(data->x1,data->y1);
TangentOnArcAt (data->d.a.stA, tmp, temp, stPos, stTgt,
stTle, stRad);
TangentOnArcAt ((data->d.a.stA + data->d.a.enA) / 2, tmp,
enGue *= enTle;
double sang, eang;
{
- NR::Point tms(data->x1,data->y1),tme(data->x2,data->y2);
+ Geom::Point tms(data->x1,data->y1),tme(data->x2,data->y2);
ArcAngles (tms,tme, data->d.a.rx,
data->d.a.ry, data->d.a.angle, data->d.a.large, !data->d.a.clock,
sang, eang);
return;
}
- NR::Point chk;
- const NR::Point req = miPos + width*miNor;
+ Geom::Point chk;
+ const Geom::Point req = miPos + width*miNor;
{
PathDescrCubicTo temp(enPos + width * enNor, stGue * scal * stTgt, enGue * scal * enTgt);
double chTle, chRad;
- NR::Point chTgt;
+ Geom::Point chTgt;
TangentOnCubAt (0.5, stPos+width*stNor,
temp, false, chk, chTgt, chTle, chRad);
}
- const NR::Point diff = req - chk;
+ const Geom::Point diff = req - chk;
const double err = (dot(diff,diff));
if (err <= tol * tol)
{
index 5d6d918c7bc2c970f7dcdcf0ed0ebd6a79849f1e..0f440de24c088d2c68cf249aae72b920f2c41897 100644 (file)
// dichomtomic method to get distance to curve approximation
// a real polynomial solver would get the minimum more efficiently, but since the polynom
// would likely be of degree >= 5, that would imply using some generic solver, liek using the sturm metod
-double RecDistanceToCubic(NR::Point const &iS, NR::Point const &isD,
- NR::Point const &iE, NR::Point const &ieD,
- NR::Point &pt, double current, int lev, double st, double et)
+double RecDistanceToCubic(Geom::Point const &iS, Geom::Point const &isD,
+ Geom::Point const &iE, Geom::Point const &ieD,
+ Geom::Point &pt, double current, int lev, double st, double et)
{
if ( lev <= 0 ) {
return current;
}
- NR::Point const m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
- NR::Point const md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
+ Geom::Point const m = 0.5 * (iS + iE) + 0.125 * (isD - ieD);
+ Geom::Point const md = 0.75 * (iE - iS) - 0.125 * (isD + ieD);
double const mt = (st + et) / 2;
- NR::Point const hisD = 0.5 * isD;
- NR::Point const hieD = 0.5 * ieD;
+ Geom::Point const hisD = 0.5 * isD;
+ Geom::Point const hieD = 0.5 * ieD;
- NR::Point const mp = pt - m;
- double nle = NR::dot(mp, mp);
+ Geom::Point const mp = pt - m;
+ double nle = Geom::dot(mp, mp);
if ( nle < current ) {
}
-double DistanceToCubic(NR::Point const &start, PathDescrCubicTo res, NR::Point &pt)
+double DistanceToCubic(Geom::Point const &start, PathDescrCubicTo res, Geom::Point &pt)
{
- NR::Point const sp = pt - start;
- NR::Point const ep = pt - res.p;
- double nle = NR::dot(sp, sp);
- double nnle = NR::dot(ep, ep);
+ Geom::Point const sp = pt - start;
+ Geom::Point const ep = pt - res.p;
+ double nle = Geom::dot(sp, sp);
+ double nnle = Geom::dot(ep, ep);
if ( nnle < nle ) {
nle = nnle;
}
- NR::Point seg = res.p - start;
+ Geom::Point seg = res.p - start;
nnle = NR::cross(seg, sp);
nnle *= nnle;
- nnle /= NR::dot(seg, seg);
+ nnle /= Geom::dot(seg, seg);
if ( nnle < nle ) {
- if ( NR::dot(sp,seg) >= 0 ) {
+ if ( Geom::dot(sp,seg) >= 0 ) {
seg = start - res.p;
- if ( NR::dot(ep,seg) >= 0 ) {
+ if ( Geom::dot(ep,seg) >= 0 ) {
nle = nnle;
}
}
data.totLen = 0;
data.nbPt = data.maxPt = data.inPt = 0;
- NR::Point const moveToPt = pts[off].p;
+ Geom::Point const moveToPt = pts[off].p;
MoveTo(moveToPt);
- NR::Point endToPt = moveToPt;
+ Geom::Point endToPt = moveToPt;
while (curP < N - 1) {
// remettre a zero
data.inPt = data.nbPt = 0;
- PathDescrCubicTo res(NR::Point(0, 0), NR::Point(0, 0), NR::Point(0, 0));
+ PathDescrCubicTo res(Geom::Point(0, 0), Geom::Point(0, 0), Geom::Point(0, 0));
bool contains_forced = false;
int step = 64;
// primitive= calc the cubic bezier patche that fits Xk and Yk best
// Qk est deja alloue
// retourne false si probleme (matrice non-inversible)
-bool Path::FitCubic(NR::Point const &start, PathDescrCubicTo &res,
+bool Path::FitCubic(Geom::Point const &start, PathDescrCubicTo &res,
double *Xk, double *Yk, double *Qk, double *tk, int nbPt)
{
- NR::Point const end = res.p;
+ Geom::Point const end = res.p;
// la matrice tNN
- NR::Matrix M(0, 0, 0, 0, 0, 0);
+ Geom::Matrix M(0, 0, 0, 0, 0, 0);
for (int i = 1; i < nbPt - 1; i++) {
M[0] += N13(tk[i]) * N13(tk[i]);
M[1] += N23(tk[i]) * N13(tk[i]);
return false;
}
- NR::Matrix const iM = M.inverse();
+ Geom::Matrix const iM = M.inverse();
M = iM;
// phase 1: abcisses
}
// le vecteur Q
- NR::Point Q(0, 0);
+ Geom::Point Q(0, 0);
for (int i = 1; i < nbPt - 1; i++) {
Q[0] += N13 (tk[i]) * Qk[i];
Q[1] += N23 (tk[i]) * Qk[i];
}
- NR::Point P = Q * M;
- NR::Point cp1;
- NR::Point cp2;
- cp1[NR::X] = P[NR::X];
- cp2[NR::X] = P[NR::Y];
+ Geom::Point P = Q * M;
+ Geom::Point cp1;
+ Geom::Point cp2;
+ cp1[Geom::X] = P[Geom::X];
+ cp2[Geom::X] = P[Geom::Y];
// phase 2: les ordonnees
for (int i = 1; i < nbPt - 1; i++) {
}
// le vecteur Q
- Q = NR::Point(0, 0);
+ Q = Geom::Point(0, 0);
for (int i = 1; i < nbPt - 1; i++) {
Q[0] += N13 (tk[i]) * Qk[i];
Q[1] += N23 (tk[i]) * Qk[i];
}
P = Q * M;
- cp1[NR::Y] = P[NR::X];
- cp2[NR::Y] = P[NR::Y];
+ cp1[Geom::Y] = P[Geom::X];
+ cp2[Geom::Y] = P[Geom::Y];
res.start = 3.0 * (cp1 - start);
res.end = 3.0 * (end - cp2 );
@@ -331,8 +331,8 @@ bool Path::ExtendFit(int off, int N, fitting_tables &data, double treshhold, Pat
if ( N > data.inPt ) {
for (int i = data.inPt; i < N; i++) {
- data.Xk[i] = pts[off + i].p[NR::X];
- data.Yk[i] = pts[off + i].p[NR::Y];
+ data.Xk[i] = pts[off + i].p[Geom::X];
+ data.Yk[i] = pts[off + i].p[Geom::Y];
data.fk[i] = ( pts[off + i].isMoveTo == polyline_forced ) ? 0x01 : 0x00;
}
data.lk[0] = 0;
@@ -345,10 +345,10 @@ bool Path::ExtendFit(int off, int N, fitting_tables &data, double treshhold, Pat
data.totLen = prevLen;
for (int i = ( (data.inPt > 0) ? data.inPt : 1); i < N; i++) {
- NR::Point diff;
- diff[NR::X] = data.Xk[i] - data.Xk[i - 1];
- diff[NR::Y] = data.Yk[i] - data.Yk[i - 1];
- data.lk[i] = NR::L2(diff);
+ Geom::Point diff;
+ diff[Geom::X] = data.Xk[i] - data.Xk[i - 1];
+ diff[Geom::Y] = data.Yk[i] - data.Yk[i - 1];
+ data.lk[i] = Geom::L2(diff);
data.totLen += data.lk[i];
data.tk[i] = data.totLen;
}
@@ -396,12 +396,12 @@ bool Path::ExtendFit(int off, int N, fitting_tables &data, double treshhold, Pat
if ( data.totLen < 0.0001 ) {
double worstD = 0;
- NR::Point start;
+ Geom::Point start;
worstP = -1;
start[0] = data.Xk[0];
start[1] = data.Yk[0];
for (int i = 1; i < N; i++) {
- NR::Point nPt;
+ Geom::Point nPt;
bool isForced = data.fk[i];
nPt[0] = data.Xk[i];
nPt[1] = data.Yk[i];
@@ -432,9 +432,9 @@ bool Path::ExtendFit(int off, int N, fitting_tables &data, double treshhold, Pat
// version that uses tables from the previous iteration, to minimize amount of work done
bool Path::AttemptSimplify (fitting_tables &data,double treshhold, PathDescrCubicTo & res,int &worstP)
{
- NR::Point start,end;
+ Geom::Point start,end;
// pour une coordonnee
- NR::Point cp1, cp2;
+ Geom::Point cp1, cp2;
worstP = 1;
if (pts.size() == 2) {
@@ -465,9 +465,9 @@ bool Path::AttemptSimplify (fitting_tables &data,double treshhold, PathDescrCubi
double worstD = 0;
worstP = -1;
for (int i = 1; i < data.nbPt; i++) {
- NR::Point nPt;
- nPt[NR::X] = data.Xk[i];
- nPt[NR::Y] = data.Yk[i];
+ Geom::Point nPt;
+ nPt[Geom::X] = data.Xk[i];
+ nPt[Geom::Y] = data.Yk[i];
double nle = DistanceToCubic(start, res, nPt);
if ( data.fk[i] ) {
// forced points are favored for splitting the recursion; we do this by increasing their distance
@@ -490,50 +490,50 @@ bool Path::AttemptSimplify (fitting_tables &data,double treshhold, PathDescrCubi
{
double worstD = 0;
worstP = -1;
- NR::Point prevAppP;
- NR::Point prevP;
+ Geom::Point prevAppP;
+ Geom::Point prevP;
double prevDist;
- prevP[NR::X] = data.Xk[0];
- prevP[NR::Y] = data.Yk[0];
+ prevP[Geom::X] = data.Xk[0];
+ prevP[Geom::Y] = data.Yk[0];
prevAppP = prevP; // le premier seulement
prevDist = 0;
#ifdef with_splotch_killer
if ( data.nbPt <= 20 ) {
for (int i = 1; i < data.nbPt - 1; i++) {
- NR::Point curAppP;
- NR::Point curP;
+ Geom::Point curAppP;
+ Geom::Point curP;
double curDist;
- NR::Point midAppP;
- NR::Point midP;
+ Geom::Point midAppP;
+ Geom::Point midP;
double midDist;
- curAppP[NR::X] = N13(data.tk[i]) * cp1[NR::X] +
- N23(data.tk[i]) * cp2[NR::X] +
+ curAppP[Geom::X] = N13(data.tk[i]) * cp1[Geom::X] +
+ N23(data.tk[i]) * cp2[Geom::X] +
N03(data.tk[i]) * data.Xk[0] +
N33(data.tk[i]) * data.Xk[data.nbPt - 1];
- curAppP[NR::Y] = N13(data.tk[i]) * cp1[NR::Y] +
- N23(data.tk[i]) * cp2[NR::Y] +
+ curAppP[Geom::Y] = N13(data.tk[i]) * cp1[Geom::Y] +
+ N23(data.tk[i]) * cp2[Geom::Y] +
N03(data.tk[i]) * data.Yk[0] +
N33(data.tk[i]) * data.Yk[data.nbPt - 1];
- curP[NR::X] = data.Xk[i];
- curP[NR::Y] = data.Yk[i];
+ curP[Geom::X] = data.Xk[i];
+ curP[Geom::Y] = data.Yk[i];
double mtk = 0.5 * (data.tk[i] + data.tk[i - 1]);
- midAppP[NR::X] = N13(mtk) * cp1[NR::X] +
- N23(mtk) * cp2[NR::X] +
+ midAppP[Geom::X] = N13(mtk) * cp1[Geom::X] +
+ N23(mtk) * cp2[Geom::X] +
N03(mtk) * data.Xk[0] +
N33(mtk) * data.Xk[data.nbPt - 1];
- midAppP[NR::Y] = N13(mtk) * cp1[NR::Y] +
- N23(mtk) * cp2[NR::Y] +
+ midAppP[Geom::Y] = N13(mtk) * cp1[Geom::Y] +
+ N23(mtk) * cp2[Geom::Y] +
N03(mtk) * data.Yk[0] +
N33(mtk) * data.Yk[data.nbPt - 1];
midP = 0.5 * (curP + prevP);
- NR::Point diff = curAppP - curP;
+ Geom::Point diff = curAppP - curP;
curDist = dot(diff, diff);
diff = midAppP - midP;
midDist = dot(diff, diff);
@@ -555,24 +555,24 @@ bool Path::AttemptSimplify (fitting_tables &data,double treshhold, PathDescrCubi
} else {
#endif
for (int i = 1; i < data.nbPt - 1; i++) {
- NR::Point curAppP;
- NR::Point curP;
+ Geom::Point curAppP;
+ Geom::Point curP;
double curDist;
- curAppP[NR::X] = N13(data.tk[i]) * cp1[NR::X] +
- N23(data.tk[i]) * cp2[NR::X] +
+ curAppP[Geom::X] = N13(data.tk[i]) * cp1[Geom::X] +
+ N23(data.tk[i]) * cp2[Geom::X] +
N03(data.tk[i]) * data.Xk[0] +
N33(data.tk[i]) * data.Xk[data.nbPt - 1];
- curAppP[NR::Y] = N13(data.tk[i]) * cp1[NR::Y] +
- N23(data.tk[i]) * cp2[NR::Y] +
+ curAppP[Geom::Y] = N13(data.tk[i]) * cp1[Geom::Y] +
+ N23(data.tk[i]) * cp2[Geom::Y] +
N03(data.tk[i]) * data.Yk[0] +
N33(data.tk[i]) * data.Yk[data.nbPt - 1];
- curP[NR::X] = data.Xk[i];
- curP[NR::Y] = data.Yk[i];
+ curP[Geom::X] = data.Xk[i];
+ curP[Geom::Y] = data.Yk[i];
- NR::Point diff = curAppP-curP;
+ Geom::Point diff = curAppP-curP;
curDist = dot(diff, diff);
delta += curDist;
@@ -597,7 +597,7 @@ bool Path::AttemptSimplify (fitting_tables &data,double treshhold, PathDescrCubi
// Refine a little.
for (int i = 1; i < data.nbPt - 1; i++) {
- NR::Point pt(data.Xk[i], data.Yk[i]);
+ Geom::Point pt(data.Xk[i], data.Yk[i]);
data.tk[i] = RaffineTk(pt, start, cp1, cp2, end, data.tk[i]);
if (data.tk[i] < data.tk[i - 1]) {
// Force tk to be monotonic non-decreasing.
@@ -616,47 +616,47 @@ bool Path::AttemptSimplify (fitting_tables &data,double treshhold, PathDescrCubi
{
double worstD = 0;
worstP = -1;
- NR::Point prevAppP;
- NR::Point prevP(data.Xk[0], data.Yk[0]);
+ Geom::Point prevAppP;
+ Geom::Point prevP(data.Xk[0], data.Yk[0]);
double prevDist = 0;
prevAppP = prevP; // le premier seulement
#ifdef with_splotch_killer
if ( data.nbPt <= 20 ) {
for (int i = 1; i < data.nbPt - 1; i++) {
- NR::Point curAppP;
- NR::Point curP;
+ Geom::Point curAppP;
+ Geom::Point curP;
double curDist;
- NR::Point midAppP;
- NR::Point midP;
+ Geom::Point midAppP;
+ Geom::Point midP;
double midDist;
- curAppP[NR::X] = N13(data.tk[i]) * cp1[NR::X] +
- N23(data.tk[i]) * cp2[NR::X] +
+ curAppP[Geom::X] = N13(data.tk[i]) * cp1[Geom::X] +
+ N23(data.tk[i]) * cp2[Geom::X] +
N03(data.tk[i]) * data.Xk[0] +
N33(data.tk[i]) * data.Xk[data.nbPt - 1];
- curAppP[NR::Y] = N13(data.tk[i]) * cp1[NR::Y] +
- N23(data.tk[i]) * cp2[NR::Y] +
+ curAppP[Geom::Y] = N13(data.tk[i]) * cp1[Geom::Y] +
+ N23(data.tk[i]) * cp2[Geom::Y] +
N03(data.tk[i]) * data.Yk[0] +
N33(data.tk[i]) * data.Yk[data.nbPt - 1];
- curP[NR::X] = data.Xk[i];
- curP[NR::Y] = data.Yk[i];
+ curP[Geom::X] = data.Xk[i];
+ curP[Geom::Y] = data.Yk[i];
double mtk = 0.5 * (data.tk[i] + data.tk[i - 1]);
- midAppP[NR::X] = N13(mtk) * cp1[NR::X] +
- N23(mtk) * cp2[NR::X] +
+ midAppP[Geom::X] = N13(mtk) * cp1[Geom::X] +
+ N23(mtk) * cp2[Geom::X] +
N03(mtk) * data.Xk[0] +
N33(mtk) * data.Xk[data.nbPt - 1];
- midAppP[NR::Y] = N13(mtk) * cp1[NR::Y] +
- N23(mtk) * cp2[NR::Y] +
+ midAppP[Geom::Y] = N13(mtk) * cp1[Geom::Y] +
+ N23(mtk) * cp2[Geom::Y] +
N03(mtk) * data.Yk[0] +
N33(mtk) * data.Yk[data.nbPt - 1];
midP = 0.5 * (curP + prevP);
- NR::Point diff = curAppP - curP;
+ Geom::Point diff = curAppP - curP;
curDist = dot(diff, diff);
diff = midAppP - midP;
@@ -680,24 +680,24 @@ bool Path::AttemptSimplify (fitting_tables &data,double treshhold, PathDescrCubi
} else {
#endif
for (int i = 1; i < data.nbPt - 1; i++) {
- NR::Point curAppP;
- NR::Point curP;
+ Geom::Point curAppP;
+ Geom::Point curP;
double curDist;
- curAppP[NR::X] = N13(data.tk[i]) * cp1[NR::X] +
- N23(data.tk[i]) * cp2[NR::X] +
+ curAppP[Geom::X] = N13(data.tk[i]) * cp1[Geom::X] +
+ N23(data.tk[i]) * cp2[Geom::X] +
N03(data.tk[i]) * data.Xk[0] +
N33(data.tk[i]) * data.Xk[data.nbPt - 1];
- curAppP[NR::Y] = N13(data.tk[i]) * cp1[NR::Y] +
+ curAppP[Geom::Y] = N13(data.tk[i]) * cp1[Geom::Y] +
N23(data.tk[i]) * cp2[1] +
N03(data.tk[i]) * data.Yk[0] +
N33(data.tk[i]) * data.Yk[data.nbPt - 1];
- curP[NR::X] = data.Xk[i];
- curP[NR::Y] = data.Yk[i];
+ curP[Geom::X] = data.Xk[i];
+ curP[Geom::Y] = data.Yk[i];
- NR::Point diff = curAppP - curP;
+ Geom::Point diff = curAppP - curP;
curDist = dot(diff, diff);
ndelta += curDist;
@@ -735,8 +735,8 @@ bool Path::AttemptSimplify (fitting_tables &data,double treshhold, PathDescrCubi
bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &res,int &worstP)
{
- NR::Point start;
- NR::Point end;
+ Geom::Point start;
+ Geom::Point end;
// pour une coordonnee
double *Xk; // la coordonnee traitee (x puis y)
@@ -746,8 +746,8 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
double *Qk; // les Qk
char *fk; // si point force
- NR::Point cp1;
- NR::Point cp2;
+ Geom::Point cp1;
+ Geom::Point cp2;
if (N == 2) {
worstP = 1;
@@ -781,10 +781,10 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
tk[0] = 0.0;
lk[0] = 0.0;
{
- NR::Point prevP = start;
+ Geom::Point prevP = start;
for (int i = 1; i < N; i++) {
- Xk[i] = pts[off + i].p[NR::X];
- Yk[i] = pts[off + i].p[NR::Y];
+ Xk[i] = pts[off + i].p[Geom::X];
+ Yk[i] = pts[off + i].p[Geom::Y];
if ( pts[off + i].isMoveTo == polyline_forced ) {
fk[i] = 0x01;
@@ -792,10 +792,10 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
fk[i] = 0;
}
- NR::Point diff(Xk[i] - prevP[NR::X], Yk[i] - prevP[1]);
+ Geom::Point diff(Xk[i] - prevP[Geom::X], Yk[i] - prevP[1]);
prevP[0] = Xk[i];
prevP[1] = Yk[i];
- lk[i] = NR::L2(diff);
+ lk[i] = Geom::L2(diff);
tk[i] = tk[i - 1] + lk[i];
}
}
@@ -807,7 +807,7 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
double worstD = 0;
worstP = -1;
for (int i = 1; i < N; i++) {
- NR::Point nPt;
+ Geom::Point nPt;
bool isForced = fk[i];
nPt[0] = Xk[i];
nPt[1] = Yk[i];
@@ -853,7 +853,7 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
double worstD = 0;
worstP = -1;
for (int i = 1; i < N; i++) {
- NR::Point nPt(Xk[i], Yk[i]);
+ Geom::Point nPt(Xk[i], Yk[i]);
bool isForced = fk[i];
double nle = DistanceToCubic(start, res, nPt);
if ( isForced ) {
@@ -884,8 +884,8 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
{
double worstD = 0;
worstP = -1;
- NR::Point prevAppP;
- NR::Point prevP;
+ Geom::Point prevAppP;
+ Geom::Point prevP;
double prevDist;
prevP[0] = Xk[0];
prevP[1] = Yk[0];
@@ -895,11 +895,11 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
if ( N <= 20 ) {
for (int i = 1; i < N - 1; i++)
{
- NR::Point curAppP;
- NR::Point curP;
+ Geom::Point curAppP;
+ Geom::Point curP;
double curDist;
- NR::Point midAppP;
- NR::Point midP;
+ Geom::Point midAppP;
+ Geom::Point midP;
double midDist;
curAppP[0] = N13 (tk[i]) * cp1[0] + N23 (tk[i]) * cp2[0] + N03 (tk[i]) * Xk[0] + N33 (tk[i]) * Xk[N - 1];
@@ -910,7 +910,7 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
midAppP[1] = N13 (0.5*(tk[i]+tk[i-1])) * cp1[1] + N23 (0.5*(tk[i]+tk[i-1])) * cp2[1] + N03 (0.5*(tk[i]+tk[i-1])) * Yk[0] + N33 (0.5*(tk[i]+tk[i-1])) * Yk[N - 1];
midP=0.5*(curP+prevP);
- NR::Point diff;
+ Geom::Point diff;
diff = curAppP-curP;
curDist = dot(diff,diff);
@@ -935,8 +935,8 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
#endif
for (int i = 1; i < N - 1; i++)
{
- NR::Point curAppP;
- NR::Point curP;
+ Geom::Point curAppP;
+ Geom::Point curP;
double curDist;
curAppP[0] = N13 (tk[i]) * cp1[0] + N23 (tk[i]) * cp2[0] + N03 (tk[i]) * Xk[0] + N33 (tk[i]) * Xk[N - 1];
@@ -944,7 +944,7 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
curP[0] = Xk[i];
curP[1] = Yk[i];
- NR::Point diff;
+ Geom::Point diff;
diff = curAppP-curP;
curDist = dot(diff,diff);
delta += curDist;
@@ -974,7 +974,7 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
// Refine a little.
for (int i = 1; i < N - 1; i++)
{
- NR::Point
+ Geom::Point
pt;
pt[0] = Xk[i];
pt[1] = Yk[i];
@@ -1003,8 +1003,8 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
{
double worstD = 0;
worstP = -1;
- NR::Point prevAppP;
- NR::Point prevP;
+ Geom::Point prevAppP;
+ Geom::Point prevP;
double prevDist;
prevP[0] = Xk[0];
prevP[1] = Yk[0];
@@ -1014,11 +1014,11 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
if ( N <= 20 ) {
for (int i = 1; i < N - 1; i++)
{
- NR::Point curAppP;
- NR::Point curP;
+ Geom::Point curAppP;
+ Geom::Point curP;
double curDist;
- NR::Point midAppP;
- NR::Point midP;
+ Geom::Point midAppP;
+ Geom::Point midP;
double midDist;
curAppP[0] = N13 (tk[i]) * cp1[0] + N23 (tk[i]) * cp2[0] + N03 (tk[i]) * Xk[0] + N33 (tk[i]) * Xk[N - 1];
@@ -1029,7 +1029,7 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
midAppP[1] = N13 (0.5*(tk[i]+tk[i-1])) * cp1[1] + N23 (0.5*(tk[i]+tk[i-1])) * cp2[1] + N03 (0.5*(tk[i]+tk[i-1])) * Yk[0] + N33 (0.5*(tk[i]+tk[i-1])) * Yk[N - 1];
midP = 0.5*(curP+prevP);
- NR::Point diff;
+ Geom::Point diff;
diff = curAppP-curP;
curDist = dot(diff,diff);
diff = midAppP-midP;
@@ -1053,8 +1053,8 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
#endif
for (int i = 1; i < N - 1; i++)
{
- NR::Point curAppP;
- NR::Point curP;
+ Geom::Point curAppP;
+ Geom::Point curP;
double curDist;
curAppP[0] = N13 (tk[i]) * cp1[0] + N23 (tk[i]) * cp2[0] + N03 (tk[i]) * Xk[0] + N33 (tk[i]) * Xk[N - 1];
@@ -1062,7 +1062,7 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
curP[0]=Xk[i];
curP[1]=Yk[i];
- NR::Point diff;
+ Geom::Point diff;
diff=curAppP-curP;
curDist=dot(diff,diff);
ndelta+=curDist;
@@ -1112,36 +1112,36 @@ bool Path::AttemptSimplify(int off, int N, double treshhold, PathDescrCubicTo &r
return false;
}
-double Path::RaffineTk (NR::Point pt, NR::Point p0, NR::Point p1, NR::Point p2, NR::Point p3, double it)
+double Path::RaffineTk (Geom::Point pt, Geom::Point p0, Geom::Point p1, Geom::Point p2, Geom::Point p3, double it)
{
// Refinement of the tk values.
// Just one iteration of Newtow Raphson, given that we're approaching the curve anyway.
// [fr: vu que de toute facon la courbe est approchC)e]
- double const Ax = pt[NR::X] -
- p0[NR::X] * N03(it) -
- p1[NR::X] * N13(it) -
- p2[NR::X] * N23(it) -
- p3[NR::X] * N33(it);
+ double const Ax = pt[Geom::X] -
+ p0[Geom::X] * N03(it) -
+ p1[Geom::X] * N13(it) -
+ p2[Geom::X] * N23(it) -
+ p3[Geom::X] * N33(it);
- double const Bx = (p1[NR::X] - p0[NR::X]) * N02(it) +
- (p2[NR::X] - p1[NR::X]) * N12(it) +
- (p3[NR::X] - p2[NR::X]) * N22(it);
+ double const Bx = (p1[Geom::X] - p0[Geom::X]) * N02(it) +
+ (p2[Geom::X] - p1[Geom::X]) * N12(it) +
+ (p3[Geom::X] - p2[Geom::X]) * N22(it);
- double const Cx = (p0[NR::X] - 2 * p1[NR::X] + p2[NR::X]) * N01(it) +
- (p3[NR::X] - 2 * p2[NR::X] + p1[NR::X]) * N11(it);
+ double const Cx = (p0[Geom::X] - 2 * p1[Geom::X] + p2[Geom::X]) * N01(it) +
+ (p3[Geom::X] - 2 * p2[Geom::X] + p1[Geom::X]) * N11(it);
- double const Ay = pt[NR::Y] -
- p0[NR::Y] * N03(it) -
- p1[NR::Y] * N13(it) -
- p2[NR::Y] * N23(it) -
- p3[NR::Y] * N33(it);
+ double const Ay = pt[Geom::Y] -
+ p0[Geom::Y] * N03(it) -
+ p1[Geom::Y] * N13(it) -
+ p2[Geom::Y] * N23(it) -
+ p3[Geom::Y] * N33(it);
- double const By = (p1[NR::Y] - p0[NR::Y]) * N02(it) +
- (p2[NR::Y] - p1[NR::Y]) * N12(it) +
- (p3[NR::Y] - p2[NR::Y]) * N22(it);
+ double const By = (p1[Geom::Y] - p0[Geom::Y]) * N02(it) +
+ (p2[Geom::Y] - p1[Geom::Y]) * N12(it) +
+ (p3[Geom::Y] - p2[Geom::Y]) * N22(it);
- double const Cy = (p0[NR::Y] - 2 * p1[NR::Y] + p2[NR::Y]) * N01(it) +
- (p3[NR::Y] - 2 * p2[NR::Y] + p1[NR::Y]) * N11(it);
+ double const Cy = (p0[Geom::Y] - 2 * p1[Geom::Y] + p2[Geom::Y]) * N01(it) +
+ (p3[Geom::Y] - 2 * p2[Geom::Y] + p1[Geom::Y]) * N11(it);
double const dF = -6 * (Ax * Bx + Ay * By);
double const ddF = 18 * (Bx * Bx + By * By) - 12 * (Ax * Cx + Ay * Cy);
int lastA = descr_cmd[0]->associated;
int prevA = lastA;
- NR::Point firstP;
+ Geom::Point firstP;
/* FIXME: the use of this variable probably causes a leak or two.
** It's a hack anyway, and probably only needs to be a type rather than
** a full PathDescr.
*/
- PathDescr *lastAddition = new PathDescrMoveTo(NR::Point(0, 0));
+ PathDescr *lastAddition = new PathDescrMoveTo(Geom::Point(0, 0));
bool containsForced = false;
- PathDescrCubicTo pending_cubic(NR::Point(0, 0), NR::Point(0, 0), NR::Point(0, 0));
+ PathDescrCubicTo pending_cubic(Geom::Point(0, 0), Geom::Point(0, 0), Geom::Point(0, 0));
for (int curP = 0; curP < int(descr_cmd.size()); curP++) {
int typ = descr_cmd[curP]->getType();
nextA = descr_cmd[curP]->associated;
if (lastAddition->flags != descr_moveto) {
- PathDescrCubicTo res(NR::Point(0, 0), NR::Point(0, 0), NR::Point(0, 0));
+ PathDescrCubicTo res(Geom::Point(0, 0), Geom::Point(0, 0), Geom::Point(0, 0));
int worstP = -1;
if (AttemptSimplify(lastA, nextA - lastA + 1, (containsForced) ? 0.05 * tresh : tresh, res, worstP)) {
- lastAddition = new PathDescrCubicTo(NR::Point(0, 0),
- NR::Point(0, 0),
- NR::Point(0, 0));
+ lastAddition = new PathDescrCubicTo(Geom::Point(0, 0),
+ Geom::Point(0, 0),
+ Geom::Point(0, 0));
pending_cubic = res;
lastAP = -1;
}
}
containsForced = false;
- lastAddition = new PathDescrMoveTo(NR::Point(0, 0));
+ lastAddition = new PathDescrMoveTo(Geom::Point(0, 0));
prevA = lastA = nextA;
lastP = curP;
lastAP = curP;
nextA = descr_cmd[curP]->associated;
if (lastAddition->flags != descr_moveto) {
- PathDescrCubicTo res(NR::Point(0, 0), NR::Point(0, 0), NR::Point(0, 0));
+ PathDescrCubicTo res(Geom::Point(0, 0), Geom::Point(0, 0), Geom::Point(0, 0));
int worstP = -1;
if (AttemptSimplify(lastA, nextA - lastA + 1, 0.05 * tresh, res, worstP)) {
// plus sensible parce que point force
} else {
// Force the addition.
FlushPendingAddition(tempDest, lastAddition, pending_cubic, lastAP);
- lastAddition = new PathDescrMoveTo(NR::Point(0, 0));
+ lastAddition = new PathDescrMoveTo(Geom::Point(0, 0));
prevA = lastA = nextA;
lastP = curP;
lastAP = curP;
nextA = descr_cmd[curP]->associated;
if (lastAddition->flags != descr_moveto) {
- PathDescrCubicTo res(NR::Point(0, 0), NR::Point(0, 0), NR::Point(0, 0));
+ PathDescrCubicTo res(Geom::Point(0, 0), Geom::Point(0, 0), Geom::Point(0, 0));
int worstP = -1;
if (AttemptSimplify(lastA, nextA - lastA + 1, tresh, res, worstP)) {
- lastAddition = new PathDescrCubicTo(NR::Point(0, 0),
- NR::Point(0, 0),
- NR::Point(0, 0));
+ lastAddition = new PathDescrCubicTo(Geom::Point(0, 0),
+ Geom::Point(0, 0),
+ Geom::Point(0, 0));
pending_cubic = res;
lastAddition->associated = lastA;
lastP = curP;
if (lastAddition->flags != descr_moveto) {
FlushPendingAddition(tempDest, lastAddition, pending_cubic, lastAP);
- lastAddition = new PathDescrMoveTo(NR::Point(0, 0));
+ lastAddition = new PathDescrMoveTo(Geom::Point(0, 0));
}
lastAP = -1;
lastA = descr_cmd[curP]->associated;
index cbd7bed5a26c3ea076077fc281e5b46b853c67e9..5e952eff7c91a266589c56ac1fa65793c453074f 100644 (file)
*/
// until i find something better
-NR::Point StrokeNormalize(const NR::Point value) {
+Geom::Point StrokeNormalize(const Geom::Point value) {
double length = L2(value);
if ( length < 0.0000001 ) {
- return NR::Point(0, 0);
+ return Geom::Point(0, 0);
} else {
return value/length;
}
}
// faster version if length is known
-NR::Point StrokeNormalize(const NR::Point value, double length) {
+Geom::Point StrokeNormalize(const Geom::Point value, double length) {
if ( length < 0.0000001 ) {
- return NR::Point(0, 0);
+ return Geom::Point(0, 0);
} else {
return value/length;
}
}
if ( lastP > lastM+1 ) {
- NR::Point sbStart = pts[lastM].p;
- NR::Point sbEnd = pts[lastP - 1].p;
+ Geom::Point sbStart = pts[lastM].p;
+ Geom::Point sbEnd = pts[lastP - 1].p;
if ( Geom::LInfty(sbEnd-sbStart) < 0.00001 ) { // why close lines that shouldn't be closed?
// ah I see, because close is defined here for
// a whole path and should be defined per subpath.
}
} else if (butt == butt_round) { // special case: zero length round butt is a circle
int last[2] = { -1, -1 };
- NR::Point dir;
+ Geom::Point dir;
dir[0] = 1;
dir[1] = 0;
- NR::Point pos = pts[lastM].p;
+ Geom::Point pos = pts[lastM].p;
DoButt(dest, width, butt, pos, dir, last[RIGHT], last[LEFT]);
int end[2];
dir = -dir;
@@ -97,19 +97,19 @@ void Path::DoStroke(int off, int N, Shape *dest, bool doClose, double width, Joi
return;
}
- NR::Point prevP, nextP;
+ Geom::Point prevP, nextP;
int prevI, nextI;
int upTo;
int curI = 0;
- NR::Point curP = pts[off].p;
+ Geom::Point curP = pts[off].p;
if (doClose) {
prevI = N - 1;
while (prevI > 0) {
prevP = pts[off + prevI].p;
- NR::Point diff = curP - prevP;
+ Geom::Point diff = curP - prevP;
double dist = dot(diff, diff);
if (dist > 0.001) {
break;
@@ -132,7 +132,7 @@ void Path::DoStroke(int off, int N, Shape *dest, bool doClose, double width, Joi
nextI = 1;
while (nextI <= upTo) {
nextP = pts[off + nextI].p;
- NR::Point diff = curP - nextP;
+ Geom::Point diff = curP - nextP;
double dist = dot(diff, diff);
if (dist > 0.0) { // more tolerance for the first distance, to give the cap the right direction
break;
@@ -142,7 +142,7 @@ void Path::DoStroke(int off, int N, Shape *dest, bool doClose, double width, Joi
if (nextI > upTo) {
if (butt == butt_round) { // special case: zero length round butt is a circle
int last[2] = { -1, -1 };
- NR::Point dir;
+ Geom::Point dir;
dir[0] = 1;
dir[1] = 0;
DoButt(dest, width, butt, curP, dir, last[RIGHT], last[LEFT]);
@@ -158,10 +158,10 @@ void Path::DoStroke(int off, int N, Shape *dest, bool doClose, double width, Joi
int start[2] = { -1, -1 };
int last[2] = { -1, -1 };
- NR::Point prevD = curP - prevP;
- NR::Point nextD = nextP - curP;
- double prevLe = NR::L2(prevD);
- double nextLe = NR::L2(nextD);
+ Geom::Point prevD = curP - prevP;
+ Geom::Point nextD = nextP - curP;
+ double prevLe = Geom::L2(prevD);
+ double nextLe = Geom::L2(nextD);
prevD = StrokeNormalize(prevD, prevLe);
nextD = StrokeNormalize(nextD, nextLe);
@@ -183,7 +183,7 @@ void Path::DoStroke(int off, int N, Shape *dest, bool doClose, double width, Joi
nextI++;
while (nextI <= upTo) {
nextP = pts[off + nextI].p;
- NR::Point diff = curP - nextP;
+ Geom::Point diff = curP - nextP;
double dist = dot(diff, diff);
if (dist > 0.001 || (nextI == upTo && dist > 0.0)) { // more tolerance for the last distance too, for the right cap direction
break;
@@ -195,7 +195,7 @@ void Path::DoStroke(int off, int N, Shape *dest, bool doClose, double width, Joi
}
nextD = nextP - curP;
- nextLe = NR::L2(nextD);
+ nextLe = Geom::L2(nextD);
nextD = StrokeNormalize(nextD, nextLe);
int nSt[2] = { -1, -1 };
int nEn[2] = { -1, -1 };
@@ -215,7 +215,7 @@ void Path::DoStroke(int off, int N, Shape *dest, bool doClose, double width, Joi
nextP = pts[off].p;
nextD = nextP - curP;
- nextLe = NR::L2(nextD);
+ nextLe = Geom::L2(nextD);
nextD = StrokeNormalize(nextD, nextLe);
int nSt[2] = { -1, -1 };
int nEn[2] = { -1, -1 };
@@ -238,15 +238,15 @@ void Path::DoStroke(int off, int N, Shape *dest, bool doClose, double width, Joi
}
-void Path::DoButt(Shape *dest, double width, ButtType butt, NR::Point pos, NR::Point dir,
+void Path::DoButt(Shape *dest, double width, ButtType butt, Geom::Point pos, Geom::Point dir,
int &leftNo, int &rightNo)
{
- NR::Point nor;
+ Geom::Point nor;
nor = dir.ccw();
if (butt == butt_square)
{
- NR::Point x;
+ Geom::Point x;
x = pos + width * dir + width * nor;
int bleftNo = dest->AddPoint (x);
x = pos + width * dir - width * nor;
@@ -269,8 +269,8 @@ void Path::DoButt(Shape *dest, double width, ButtType butt, NR::Point pos, NR::P
}
else if (butt == butt_round)
{
- const NR::Point sx = pos + width * nor;
- const NR::Point ex = pos - width * nor;
+ const Geom::Point sx = pos + width * nor;
+ const Geom::Point ex = pos - width * nor;
leftNo = dest->AddPoint (sx);
rightNo = dest->AddPoint (ex);
@@ -285,12 +285,12 @@ void Path::DoButt(Shape *dest, double width, ButtType butt, NR::Point pos, NR::P
}
-void Path::DoJoin (Shape *dest, double width, JoinType join, NR::Point pos, NR::Point prev,
- NR::Point next, double miter, double /*prevL*/, double /*nextL*/,
+void Path::DoJoin (Shape *dest, double width, JoinType join, Geom::Point pos, Geom::Point prev,
+ Geom::Point next, double miter, double /*prevL*/, double /*nextL*/,
int *stNo, int *enNo)
{
- NR::Point pnor = prev.ccw();
- NR::Point nnor = next.ccw();
+ Geom::Point pnor = prev.ccw();
+ Geom::Point nnor = next.ccw();
double angSi = cross(next, prev);
/* FIXED: this special case caused bug 1028953 */
@@ -302,8 +302,8 @@ void Path::DoJoin (Shape *dest, double width, JoinType join, NR::Point pos, NR::
stNo[RIGHT] = enNo[RIGHT] = dest->AddPoint(pos - width * pnor);
} else {
// demi-tour
- const NR::Point sx = pos + width * pnor;
- const NR::Point ex = pos - width * pnor;
+ const Geom::Point sx = pos + width * pnor;
+ const Geom::Point ex = pos - width * pnor;
stNo[LEFT] = enNo[RIGHT] = dest->AddPoint (sx);
stNo[RIGHT] = enNo[LEFT] = dest->AddPoint (ex);
if (join == join_round) {
@@ -329,7 +329,7 @@ void Path::DoJoin (Shape *dest, double width, JoinType join, NR::Point pos, NR::
stNo[RIGHT] = dest->AddPoint(pos - width * pnor);
enNo[RIGHT] = dest->AddPoint(pos - width * nnor);
- const NR::Point biss = StrokeNormalize(prev - next);
+ const Geom::Point biss = StrokeNormalize(prev - next);
double c2 = dot(biss, nnor);
double l = width / c2;
double emiter = width * c2;
@@ -346,9 +346,9 @@ void Path::DoJoin (Shape *dest, double width, JoinType join, NR::Point pos, NR::
}
} else if (join == join_round) {
- NR::Point sx = pos - width * pnor;
+ Geom::Point sx = pos - width * pnor;
stNo[RIGHT] = dest->AddPoint(sx);
- NR::Point ex = pos - width * nnor;
+ Geom::Point ex = pos - width * nnor;
enNo[RIGHT] = dest->AddPoint(ex);
RecRound(dest, stNo[RIGHT], enNo[RIGHT],
@@ -373,7 +373,7 @@ void Path::DoJoin (Shape *dest, double width, JoinType join, NR::Point pos, NR::
stNo[LEFT] = dest->AddPoint(pos + width * pnor);
enNo[LEFT] = dest->AddPoint(pos + width * nnor);
- const NR::Point biss = StrokeNormalize(next - prev);
+ const Geom::Point biss = StrokeNormalize(next - prev);
double c2 = dot(biss, nnor);
double l = width / c2;
double emiter = width * c2;
@@ -392,9 +392,9 @@ void Path::DoJoin (Shape *dest, double width, JoinType join, NR::Point pos, NR::
} else if (join == join_round) {
- NR::Point sx = pos + width * pnor;
+ Geom::Point sx = pos + width * pnor;
stNo[LEFT] = dest->AddPoint(sx);
- NR::Point ex = pos + width * nnor;
+ Geom::Point ex = pos + width * nnor;
enNo[LEFT] = dest->AddPoint(ex);
RecRound(dest, enNo[LEFT], stNo[LEFT],
@@ -409,12 +409,12 @@ void Path::DoJoin (Shape *dest, double width, JoinType join, NR::Point pos, NR::
}
void
-Path::DoLeftJoin (Shape * dest, double width, JoinType join, NR::Point pos,
- NR::Point prev, NR::Point next, double miter, double /*prevL*/, double /*nextL*/,
+Path::DoLeftJoin (Shape * dest, double width, JoinType join, Geom::Point pos,
+ Geom::Point prev, Geom::Point next, double miter, double /*prevL*/, double /*nextL*/,
int &leftStNo, int &leftEnNo,int pathID,int pieceID,double tID)
{
- NR::Point pnor=prev.ccw();
- NR::Point nnor=next.ccw();
+ Geom::Point pnor=prev.ccw();
+ Geom::Point nnor=next.ccw();
double angSi = cross (next, prev);
if (angSi > -0.0001 && angSi < 0.0001)
{
}
if (angSi < 0)
{
- /* NR::Point biss;
+ /* Geom::Point biss;
biss.x=next.x-prev.x;
biss.y=next.y-prev.y;
double c2=cross(biss,next);
leftStNo = dest->AddPoint (pos + width * pnor);
leftEnNo = dest->AddPoint (pos + width * nnor);
- const NR::Point biss = StrokeNormalize (pnor + nnor);
+ const Geom::Point biss = StrokeNormalize (pnor + nnor);
double c2 = dot (biss, nnor);
double l = width / c2;
double emiter = width * c2;
{
double s2 = cross (biss, nnor);
double dec = (l - emiter) * c2 / s2;
- const NR::Point tbiss=biss.ccw();
+ const Geom::Point tbiss=biss.ccw();
int nleftStNo = dest->AddPoint (pos + emiter * biss + dec * tbiss);
int nleftEnNo = dest->AddPoint (pos + emiter * biss - dec * tbiss);
}
else if (join == join_round)
{
- const NR::Point sx = pos + width * pnor;
+ const Geom::Point sx = pos + width * pnor;
leftStNo = dest->AddPoint (sx);
- const NR::Point ex = pos + width * nnor;
+ const Geom::Point ex = pos + width * nnor;
leftEnNo = dest->AddPoint (ex);
RecRound(dest, leftEnNo, leftStNo,
}
}
void
-Path::DoRightJoin (Shape * dest, double width, JoinType join, NR::Point pos,
- NR::Point prev, NR::Point next, double miter, double /*prevL*/,
+Path::DoRightJoin (Shape * dest, double width, JoinType join, Geom::Point pos,
+ Geom::Point prev, Geom::Point next, double miter, double /*prevL*/,
double /*nextL*/, int &rightStNo, int &rightEnNo,int pathID,int pieceID,double tID)
{
- const NR::Point pnor=prev.ccw();
- const NR::Point nnor=next.ccw();
+ const Geom::Point pnor=prev.ccw();
+ const Geom::Point nnor=next.ccw();
double angSi = cross (next,prev);
if (angSi > -0.0001 && angSi < 0.0001)
{
rightStNo = dest->AddPoint (pos - width*pnor);
rightEnNo = dest->AddPoint (pos - width*nnor);
- const NR::Point biss = StrokeNormalize (pnor + nnor);
+ const Geom::Point biss = StrokeNormalize (pnor + nnor);
double c2 = dot (biss, nnor);
double l = width / c2;
double emiter = width * c2;
{
double s2 = cross (biss, nnor);
double dec = (l - emiter) * c2 / s2;
- const NR::Point tbiss=biss.ccw();
+ const Geom::Point tbiss=biss.ccw();
int nrightStNo = dest->AddPoint (pos - emiter*biss - dec*tbiss);
int nrightEnNo = dest->AddPoint (pos - emiter*biss + dec*tbiss);
}
else if (join == join_round)
{
- const NR::Point sx = pos - width * pnor;
+ const Geom::Point sx = pos - width * pnor;
rightStNo = dest->AddPoint (sx);
- const NR::Point ex = pos - width * nnor;
+ const Geom::Point ex = pos - width * nnor;
rightEnNo = dest->AddPoint (ex);
RecRound(dest, rightStNo, rightEnNo,
}
else
{
- /* NR::Point biss;
+ /* Geom::Point biss;
biss=next.x-prev.x;
biss.y=next.y-prev.y;
double c2=cross(next,biss);
// a very nice way to produce round joins, caps or dots
void Path::RecRound(Shape *dest, int sNo, int eNo, // start and end index
- NR::Point const &iS, NR::Point const &iE, // start and end point
- NR::Point const &nS, NR::Point const &nE, // start and end normal vector
- NR::Point &origine, float width) // center and radius of round
+ Geom::Point const &iS, Geom::Point const &iE, // start and end point
+ Geom::Point const &nS, Geom::Point const &nE, // start and end normal vector
+ Geom::Point &origine, float width) // center and radius of round
{
- //NR::Point diff = iS - iE;
+ //Geom::Point diff = iS - iE;
//double dist = dot(diff, diff);
if (width < 0.5 || dot(iS - iE, iS - iE)/width < 2.0) {
dest->AddEdge(sNo, eNo);
int nbS = (int) floor(ang);
Geom::Rotate omega(((sia > 0) ? -lod : lod));
- NR::Point cur = iS - origine;
+ Geom::Point cur = iS - origine;
// StrokeNormalize(cur);
// cur*=width;
int lastNo = sNo;
for (int i = 0; i < nbS; i++) {
cur = cur * omega;
- NR::Point m = origine + cur;
+ Geom::Point m = origine + cur;
int mNo = dest->AddPoint(m);
dest->AddEdge(lastNo, mNo);
lastNo = mNo;
diff --git a/src/livarot/Shape.cpp b/src/livarot/Shape.cpp
index d03940f2f7fe01268ecb6df0506460e997e20efa..9107844be8c61fbf581f4c9a48d2e2ddc8b885ab 100644 (file)
--- a/src/livarot/Shape.cpp
+++ b/src/livarot/Shape.cpp
}
int
-Shape::AddPoint (const NR::Point x)
+Shape::AddPoint (const Geom::Point x)
{
if (numberOfPoints() >= maxPt)
{
}
dg_arete a;
- a.dx = NR::Point(0, 0);
+ a.dx = Geom::Point(0, 0);
a.st = a.en = -1;
a.prevS = a.nextS = -1;
a.prevE = a.nextE = -1;
}
dg_arete a;
- a.dx = NR::Point(0, 0);
+ a.dx = Geom::Point(0, 0);
a.st = a.en = -1;
a.prevS = a.nextS = -1;
a.prevE = a.nextE = -1;
}
int
-Shape::CmpToVert (NR::Point ax, NR::Point bx,bool as,bool bs)
+Shape::CmpToVert (Geom::Point ax, Geom::Point bx,bool as,bool bs)
{
int tstAX = 0;
int tstAY = 0;
if (quadA > quadB)
return -1;
- NR::Point av, bv;
+ Geom::Point av, bv;
av = ax;
bv = bx;
double si = cross (bv, av);
int ppos = (s + e) / 2;
int plast = ppos;
- NR::Point pvalx = list[ppos].x;
+ Geom::Point pvalx = list[ppos].x;
bool pvals = list[ppos].starting;
int le = s, ri = e;
// other=depends on your fill rule
// if the polygon is uncrossed, it's all the same, usually
int
-Shape::PtWinding (const NR::Point px) const
+Shape::PtWinding (const Geom::Point px) const
{
int lr = 0, ll = 0, rr = 0;
for (int i = 0; i < numberOfEdges(); i++)
{
- NR::Point const adir = getEdge(i).dx;
+ Geom::Point const adir = getEdge(i).dx;
- NR::Point const ast = getPoint(getEdge(i).st).x;
- NR::Point const aen = getPoint(getEdge(i).en).x;
+ Geom::Point const ast = getPoint(getEdge(i).st).x;
+ Geom::Point const aen = getPoint(getEdge(i).en).x;
//int const nWeight = eData[i].weight;
int const nWeight = 1;
if (aen[1] >= px[1]) continue;
}
- NR::Point const diff = px - ast;
+ Geom::Point const diff = px - ast;
double const cote = cross(diff, adir);
if (cote == 0) continue;
if (cote < 0) {
* \return Minimum distance from p to any of the points or edges of s.
*/
-double distance(Shape const *s, NR::Point const &p)
+double distance(Shape const *s, Geom::Point const &p)
{
if ( s->hasPoints() == false) {
return 0.0;
** us the distance squared; we can leave the square root
** until the end.
*/
- double bdot = NR::dot(p - s->getPoint(0).x, p - s->getPoint(0).x);
+ double bdot = Geom::dot(p - s->getPoint(0).x, p - s->getPoint(0).x);
for (int i = 0; i < s->numberOfPoints(); i++) {
- NR::Point const offset( p - s->getPoint(i).x );
- double ndot = NR::dot(offset, offset);
+ Geom::Point const offset( p - s->getPoint(i).x );
+ double ndot = Geom::dot(offset, offset);
if ( ndot < bdot ) {
bdot = ndot;
}
for (int i = 0; i < s->numberOfEdges(); i++) {
if ( s->getEdge(i).st >= 0 && s->getEdge(i).en >= 0 ) {
/* The edge has start and end points */
- NR::Point const st(s->getPoint(s->getEdge(i).st).x); // edge start
- NR::Point const en(s->getPoint(s->getEdge(i).en).x); // edge end
+ Geom::Point const st(s->getPoint(s->getEdge(i).st).x); // edge start
+ Geom::Point const en(s->getPoint(s->getEdge(i).en).x); // edge end
- NR::Point const d(p - st); // vector between p and edge start
- NR::Point const e(en - st); // vector of the edge
- double const el = NR::dot(e, e); // edge length
+ Geom::Point const d(p - st); // vector between p and edge start
+ Geom::Point const e(en - st); // vector of the edge
+ double const el = Geom::dot(e, e); // edge length
/* Update bdot if appropriate */
if ( el > 0.001 ) {
- double const npr = NR::dot(d, e);
+ double const npr = Geom::dot(d, e);
if ( npr > 0 && npr < el ) {
double const nl = fabs( NR::cross(d, e) );
double ndot = nl * nl / el;
* \param max_l2 L2 distance.
*/
-bool distanceLessThanOrEqual(Shape const *s, NR::Point const &p, double const max_l2)
+bool distanceLessThanOrEqual(Shape const *s, Geom::Point const &p, double const max_l2)
{
if ( s->hasPoints() == false ) {
return false;
@@ -2270,23 +2270,23 @@ bool distanceLessThanOrEqual(Shape const *s, NR::Point const &p, double const ma
double const max_l1 = max_l2 * M_SQRT2;
for (int i = 0; i < s->numberOfPoints(); i++) {
- NR::Point const offset( p - s->getPoint(i).x );
+ Geom::Point const offset( p - s->getPoint(i).x );
double const l1 = NR::L1(offset);
- if ( (l1 <= max_l2) || ((l1 <= max_l1) && (NR::L2(offset) <= max_l2)) ) {
+ if ( (l1 <= max_l2) || ((l1 <= max_l1) && (Geom::L2(offset) <= max_l2)) ) {
return true;
}
}
for (int i = 0; i < s->numberOfEdges(); i++) {
if ( s->getEdge(i).st >= 0 && s->getEdge(i).en >= 0 ) {
- NR::Point const st(s->getPoint(s->getEdge(i).st).x);
- NR::Point const en(s->getPoint(s->getEdge(i).en).x);
- NR::Point const d(p - st);
- NR::Point const e(en - st);
- double const el = NR::L2(e);
+ Geom::Point const st(s->getPoint(s->getEdge(i).st).x);
+ Geom::Point const en(s->getPoint(s->getEdge(i).en).x);
+ Geom::Point const d(p - st);
+ Geom::Point const e(en - st);
+ double const el = Geom::L2(e);
if ( el > 0.001 ) {
- NR::Point const e_unit(e / el);
- double const npr = NR::dot(d, e_unit);
+ Geom::Point const e_unit(e / el);
+ double const npr = Geom::dot(d, e_unit);
if ( npr > 0 && npr < el ) {
double const nl = fabs(NR::cross(d, e_unit));
if ( nl <= max_l2 ) {
diff --git a/src/livarot/Shape.h b/src/livarot/Shape.h
index 73199a313969feb4295125c46ce994d8fdba9308..ca8ae1c6eb3fa8513b06a15a3e03caad24dd1012 100644 (file)
--- a/src/livarot/Shape.h
+++ b/src/livarot/Shape.h
// -reset the graph, and ensure there's room for n points and m edges
void Reset(int n = 0, int m = 0);
// -points:
- int AddPoint(const NR::Point x); // as the function name says
+ int AddPoint(const Geom::Point x); // as the function name says
// returns the index at which the point has been added in the array
void SubPoint(int p); // removes the point at index p
// nota: this function relocates the last point to the index p
// create a graph that is an offseted version of the graph "of"
// the offset is dec, with joins between edges of type "join" (see LivarotDefs.h)
// the result is NOT a polygon; you need a subsequent call to ConvertToShape to get a real polygon
- int MakeOffset(Shape *of, double dec, JoinType join, double miter, bool do_profile=false, double cx = 0, double cy = 0, double radius = 0, NR::Matrix *i2doc = NULL);
+ int MakeOffset(Shape *of, double dec, JoinType join, double miter, bool do_profile=false, double cx = 0, double cy = 0, double radius = 0, Geom::Matrix *i2doc = NULL);
int MakeTweak (int mode, Shape *a, double dec, JoinType join, double miter, bool do_profile, Geom::Point c, Geom::Point vector, double radius, Geom::Matrix *i2doc);
- int PtWinding(const NR::Point px) const; // plus rapide
- int Winding(const NR::Point px) const;
+ int PtWinding(const Geom::Point px) const; // plus rapide
+ int Winding(const Geom::Point px) const;
// rasterization
void BeginRaster(float &pos, int &curPt);
void QuickScan(float &pos, int &curP, float to, FillRule directed, BitLigne* line, float step);
void QuickScan(float &pos, int &curP, float to, AlphaLigne* line, float step);
- void Transform(NR::Matrix const &tr)
+ void Transform(Geom::Matrix const &tr)
{for(std::vector<dg_point>::iterator it=_pts.begin();it!=_pts.end();it++) it->x*=tr;}
std::vector<back_data> ebData;
// topological information: who links who?
struct dg_point
{
- NR::Point x; // position
+ Geom::Point x; // position
int dI, dO; // indegree and outdegree
int incidentEdge[2]; // first and last incident edge
int oldDegree;
struct dg_arete
{
- NR::Point dx; // edge vector
+ Geom::Point dx; // edge vector
int st, en; // start and end points of the edge
int nextS, prevS; // next and previous edge in the double-linked list at the start point
int nextE, prevE; // next and previous edge in the double-linked list at the end point
struct edge_data
{
int weight; // weight of the edge (to handle multiple edges)
- NR::Point rdx; // rounded edge vector
+ Geom::Point rdx; // rounded edge vector
double length, sqlength, ilength, isqlength; // length^2, length, 1/length^2, 1/length
double siEd, coEd; // siEd=abs(rdy/length) and coEd=rdx/length
edge_data() : weight(0), length(0.0), sqlength(0.0), ilength(0.0), isqlength(0.0), siEd(0.0), coEd(0.0) {}
int nextLinkedPoint; // not used
Shape *askForWindingS;
int askForWindingB;
- NR::Point rx; // rounded coordinates of the point
+ Geom::Point rx; // rounded coordinates of the point
};
{ // temporary array of edges for easier sorting
int no;
bool starting;
- NR::Point x;
+ Geom::Point x;
};
void initialisePointData();
void SortEdgesList(edge_list *edges, int s, int e);
void TesteIntersection(SweepTree *t, Side s, bool onlyDiff); // test if there is an intersection
- bool TesteIntersection(SweepTree *iL, SweepTree *iR, NR::Point &atx, double &atL, double &atR, bool onlyDiff);
+ bool TesteIntersection(SweepTree *iL, SweepTree *iR, Geom::Point &atx, double &atL, double &atR, bool onlyDiff);
bool TesteIntersection(Shape *iL, Shape *iR, int ilb, int irb,
- NR::Point &atx, double &atL, double &atR,
+ Geom::Point &atx, double &atL, double &atR,
bool onlyDiff);
- bool TesteAdjacency(Shape *iL, int ilb, const NR::Point atx, int nPt,
+ bool TesteAdjacency(Shape *iL, int ilb, const Geom::Point atx, int nPt,
bool push);
int PushIncidence(Shape *a, int cb, int pt, double theta);
int CreateIncidence(Shape *a, int cb, int pt);
int ReFormeArcTo(int bord, int curBord, Path *dest, Path *orig);
int ReFormeCubicTo(int bord, int curBord, Path *dest, Path *orig);
int ReFormeBezierTo(int bord, int curBord, Path *dest, Path *orig);
- void ReFormeBezierChunk(const NR::Point px, const NR::Point nx,
+ void ReFormeBezierChunk(const Geom::Point px, const Geom::Point nx,
Path *dest, int inBezier, int nbInterm,
Path *from, int p, double ts, double te);
};
// edge direction comparison function
- static int CmpToVert(const NR::Point ax, const NR::Point bx, bool as, bool bs);
+ static int CmpToVert(const Geom::Point ax, const Geom::Point bx, bool as, bool bs);
};
bool directedEulerian(Shape const *s);
-double distance(Shape const *s, NR::Point const &p);
-bool distanceLessThanOrEqual(Shape const *s, NR::Point const &p, double const max_l2);
+double distance(Shape const *s, Geom::Point const &p);
+bool distanceLessThanOrEqual(Shape const *s, Geom::Point const &p, double const max_l2);
#endif
index 824f04a88ff0bb72bf494819b2f0d575c2b453b5..d6ca8c5333861da6117494c56aa34d62a8322b07 100644 (file)
@@ -718,7 +718,7 @@ Shape::MakeTweak (int mode, Shape *a, double power, JoinType join, double miter,
// you gotta be very careful with the join, as anything but the right one will fuck everything up
// see PathStroke.cpp for the "right" joins
int
-Shape::MakeOffset (Shape * a, double dec, JoinType join, double miter, bool do_profile, double cx, double cy, double radius, NR::Matrix *i2doc)
+Shape::MakeOffset (Shape * a, double dec, JoinType join, double miter, bool do_profile, double cx, double cy, double radius, Geom::Matrix *i2doc)
{
Reset (0, 0);
MakeBackData(a->_has_back_data);
@@ -778,7 +778,7 @@ Shape::MakeOffset (Shape * a, double dec, JoinType join, double miter, bool do_p
enB = a->CycleNextAt (a->getEdge(i).en, i);
}
- NR::Point stD, seD, enD;
+ Geom::Point stD, seD, enD;
double stL, seL, enL;
stD = a->getEdge(stB).dx;
seD = a->getEdge(i).dx;
@@ -791,14 +791,14 @@ Shape::MakeOffset (Shape * a, double dec, JoinType join, double miter, bool do_p
MiscNormalize (enD);
MiscNormalize (seD);
- NR::Point ptP;
+ Geom::Point ptP;
int stNo, enNo;
ptP = a->getPoint(a->getEdge(i).st).x;
double this_dec;
if (do_profile && i2doc) {
double alpha = 1;
- double x = (NR::L2(ptP * (*i2doc) - NR::Point(cx,cy))/radius);
+ double x = (Geom::L2(ptP * (*i2doc) - Geom::Point(cx,cy))/radius);
if (x > 1) {
this_dec = 0;
} else if (x <= 0) {
int nPiece = ebData[bord].pieceID;
int nPath = ebData[bord].pathID;
double /*ts=ebData[bord].tSt, */ te = ebData[bord].tEn;
- NR::Point nx = getPoint(getEdge(bord).en).x;
+ Geom::Point nx = getPoint(getEdge(bord).en).x;
bord = swdData[bord].suivParc;
while (bord >= 0)
{
int nPath = ebData[bord].pathID;
double ts = ebData[bord].tSt, te = ebData[bord].tEn;
// double px=pts[getEdge(bord).st].x,py=pts[getEdge(bord).st].y;
- NR::Point nx = getPoint(getEdge(bord).en).x;
+ Geom::Point nx = getPoint(getEdge(bord).en).x;
bord = swdData[bord].suivParc;
while (bord >= 0)
{
int nPiece = ebData[bord].pieceID;
int nPath = ebData[bord].pathID;
double ts = ebData[bord].tSt, te = ebData[bord].tEn;
- NR::Point nx = getPoint(getEdge(bord).en).x;
+ Geom::Point nx = getPoint(getEdge(bord).en).x;
bord = swdData[bord].suivParc;
while (bord >= 0)
{
}
bord = swdData[bord].suivParc;
}
- NR::Point prevx = from->PrevPoint (nPiece - 1);
+ Geom::Point prevx = from->PrevPoint (nPiece - 1);
- NR::Point sDx, eDx;
+ Geom::Point sDx, eDx;
{
PathDescrCubicTo *nData = dynamic_cast<PathDescrCubicTo *>(from->descr_cmd[nPiece]);
Path::CubicTangent (ts, sDx, prevx,nData->start,nData->p,nData->end);
int nPath = ebData[bord].pathID;
double ts = ebData[bord].tSt, te = ebData[bord].tEn;
int ps = nPiece, pe = nPiece;
- NR::Point px = getPoint(getEdge(bord).st).x;
- NR::Point nx = getPoint(getEdge(bord).en).x;
+ Geom::Point px = getPoint(getEdge(bord).st).x;
+ Geom::Point nx = getPoint(getEdge(bord).en).x;
int inBezier = -1, nbInterm = -1;
int typ;
typ = from->descr_cmd[nPiece]->getType();
}
else
{
- NR::Point tx;
+ Geom::Point tx;
{
PathDescrIntermBezierTo* psData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[pe]);
PathDescrIntermBezierTo* pnData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[pe+1]);
{
if (te > 0.9999)
{
- NR::Point tx;
+ Geom::Point tx;
{
PathDescrIntermBezierTo* psData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps+1]);
PathDescrIntermBezierTo* pnData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps+2]);
}
else
{
- NR::Point tx;
+ Geom::Point tx;
{
PathDescrIntermBezierTo* psData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps+1]);
PathDescrIntermBezierTo* pnData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps+2]);
}
else
{
- NR::Point tx;
+ Geom::Point tx;
{
PathDescrIntermBezierTo* psData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[pe+1]);
PathDescrIntermBezierTo* pnData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[pe+2]);
{
if (te < 0.0001)
{
- NR::Point tx;
+ Geom::Point tx;
{
PathDescrIntermBezierTo* psData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps]);
PathDescrIntermBezierTo* pnData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps+1]);
}
else
{
- NR::Point tx;
+ Geom::Point tx;
{
PathDescrIntermBezierTo* psData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps]);
PathDescrIntermBezierTo* pnData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[ps+1]);
@@ -1383,15 +1383,15 @@ Shape::ReFormeBezierTo (int bord, int /*curBord*/, Path * dest, Path * from)
}
void
-Shape::ReFormeBezierChunk (NR::Point px, NR::Point nx,
+Shape::ReFormeBezierChunk (Geom::Point px, Geom::Point nx,
Path * dest, int inBezier, int nbInterm,
Path * from, int p, double ts, double te)
{
PathDescrBezierTo* nBData = dynamic_cast<PathDescrBezierTo*>(from->descr_cmd[inBezier]);
- NR::Point bstx = from->PrevPoint (inBezier - 1);
- NR::Point benx = nBData->p;
+ Geom::Point bstx = from->PrevPoint (inBezier - 1);
+ Geom::Point benx = nBData->p;
- NR::Point mx;
+ Geom::Point mx;
if (p == inBezier)
{
// premier bout
nData = dynamic_cast<PathDescrIntermBezierTo*>(from->descr_cmd[p+2]);
benx = (nData->p + mx) / 2;
}
- NR::Point cx;
+ Geom::Point cx;
{
Path::QuadraticPoint ((ts + te) / 2, cx, bstx, mx, benx);
}
index 528fe395d7f929a22926a3df5608eec20a736694..7b00cdc6b0049b22da980f3c9e95ead80cc22e22 100644 (file)
@@ -1622,7 +1622,7 @@ void Shape::QuickScan(float &pos, int &curP, float to, AlphaLigne* line, float s
void Shape::CreateEdge(int no, float to, float step)
{
int cPt;
- NR::Point dir;
+ Geom::Point dir;
if ( getEdge(no).st < getEdge(no).en ) {
cPt = getEdge(no).st;
swrData[no].sens = true;
void Shape::AvanceEdge(int no, float to, bool exact, float step)
{
if ( exact ) {
- NR::Point dir;
- NR::Point stp;
+ Geom::Point dir;
+ Geom::Point stp;
if ( swrData[no].sens ) {
stp = getPoint(getEdge(no).st).x;
dir = getEdge(no).dx;
index 2d7bfe252d3d023847aa198983eb334dee29d98a..00a0dd9a03efa9e680f1f2c2651560d3991e1f7a 100644 (file)
int curAPt = 0;
while (curAPt < a->numberOfPoints() || sEvts->size() > 0) {
- NR::Point ptX;
+ Geom::Point ptX;
double ptL, ptR;
SweepTree *intersL = NULL;
SweepTree *intersR = NULL;
continue;
}
- NR::Point rPtX;
+ Geom::Point rPtX;
rPtX[0]= Round (ptX[0]);
rPtX[1]= Round (ptX[1]);
int lastPointNo = -1;
}
printf("\n");*/
- NR::Point ptX;
+ Geom::Point ptX;
double ptL, ptR;
SweepTree *intersL = NULL;
SweepTree *intersR = NULL;
continue;
}
- NR::Point rPtX;
+ Geom::Point rPtX;
rPtX[0]= Round (ptX[0]);
rPtX[1]= Round (ptX[1]);
int lastPointNo = -1;
SweepTree *a = (s == LEFT) ? tt : t;
SweepTree *b = (s == LEFT) ? t : tt;
- NR::Point atx;
+ Geom::Point atx;
double atl;
double atr;
if (TesteIntersection(a, b, atx, atl, atr, onlyDiff)) {
// a crucial piece of code: computing intersections between segments
bool
-Shape::TesteIntersection (SweepTree * iL, SweepTree * iR, NR::Point &atx, double &atL, double &atR, bool onlyDiff)
+Shape::TesteIntersection (SweepTree * iL, SweepTree * iR, Geom::Point &atx, double &atL, double &atR, bool onlyDiff)
{
int lSt = iL->src->getEdge(iL->bord).st, lEn = iL->src->getEdge(iL->bord).en;
int rSt = iR->src->getEdge(iR->bord).st, rEn = iR->src->getEdge(iR->bord).en;
- NR::Point ldir, rdir;
+ Geom::Point ldir, rdir;
ldir = iL->src->eData[iL->bord].rdx;
rdir = iR->src->eData[iR->bord].rdx;
// first, a round of checks to quickly dismiss edge which obviously dont intersect,
@@ -1774,7 +1774,7 @@ Shape::TesteIntersection (SweepTree * iL, SweepTree * iR, NR::Point &atx, double
// Boissonat anr Preparata said in one paper that double precision floats were sufficient for get single precision
// coordinates for the intersection, if the endpoints are single precision. i hope they're right...
{
- NR::Point sDiff, eDiff;
+ Geom::Point sDiff, eDiff;
double slDot, elDot;
double srDot, erDot;
sDiff = iL->src->pData[lSt].rx - iR->src->pData[rSt].rx;
int
Shape::CreateIncidence (Shape * a, int no, int nPt)
{
- NR::Point adir, diff;
+ Geom::Point adir, diff;
adir = a->eData[no].rdx;
diff = getPoint(nPt).x - a->pData[a->getEdge(no).st].rx;
double t = dot (diff, adir);
}
int
-Shape::Winding (const NR::Point px) const
+Shape::Winding (const Geom::Point px) const
{
int lr = 0, ll = 0, rr = 0;
for (int i = 0; i < numberOfEdges(); i++)
{
- NR::Point adir, diff, ast, aen;
+ Geom::Point adir, diff, ast, aen;
adir = eData[i].rdx;
ast = pData[getEdge(i).st].rx;
@@ -2509,7 +2509,7 @@ Shape::GetWindings (Shape * /*a*/, Shape * /*b*/, BooleanOp /*mod*/, bool brutal
bool
Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb,
- NR::Point &atx, double &atL, double &atR,
+ Geom::Point &atx, double &atL, double &atR,
bool /*onlyDiff*/)
{
int lSt = ils->getEdge(ilb).st, lEn = ils->getEdge(ilb).en;
return false;
}
- NR::Point ldir, rdir;
+ Geom::Point ldir, rdir;
ldir = ils->eData[ilb].rdx;
rdir = irs->eData[irb].rdx;
// pre-test
{
- NR::Point sDiff, eDiff;
+ Geom::Point sDiff, eDiff;
double slDot, elDot;
double srDot, erDot;
sDiff = ils->pData[lSt].rx - irs->pData[rSt].rx;
}
// a mettre en double precision pour des resultats exacts
- NR::Point usvs;
+ Geom::Point usvs;
usvs = irs->pData[rSt].rx - ils->pData[lSt].rx;
// pas sur de l'ordre des coefs de m
- NR::Matrix m(ldir[0], ldir[1],
+ Geom::Matrix m(ldir[0], ldir[1],
rdir[0], rdir[1],
0, 0);
double det = m.det();
if (tdet > -0.0001 && tdet < 0.0001)
{ // ces couillons de vecteurs sont colineaires
- NR::Point sDiff, eDiff;
+ Geom::Point sDiff, eDiff;
double sDot, eDot;
sDiff = ils->pData[lSt].rx - irs->pData[rSt].rx;
eDiff = ils->pData[lEn].rx - irs->pData[rSt].rx;
}
bool
-Shape::TesteAdjacency (Shape * a, int no, const NR::Point atx, int nPt,
+Shape::TesteAdjacency (Shape * a, int no, const Geom::Point atx, int nPt,
bool push)
{
if (nPt == a->swsData[no].stPt || nPt == a->swsData[no].enPt)
return false;
- NR::Point adir, diff, ast, aen, diff1, diff2, diff3, diff4;
+ Geom::Point adir, diff, ast, aen, diff1, diff2, diff3, diff4;
ast = a->pData[a->getEdge(no).st].rx;
aen = a->pData[a->getEdge(no).en].rx;
{
for (int j = i + 1; j < numberOfEdges(); j++)
{
- NR::Point atx;
+ Geom::Point atx;
double atL, atR;
if (TesteIntersection (this, this, i, j, atx, atL, atR, false))
{
else
{
double bdl = iS->eData[iB].ilength;
- NR::Point bpx = iS->pData[iS->getEdge(iB).st].rx;
- NR::Point bdx = iS->eData[iB].rdx;
- NR::Point psx = getPoint(getEdge(ne).st).x;
- NR::Point pex = getPoint(getEdge(ne).en).x;
- NR::Point psbx=psx-bpx;
- NR::Point pebx=pex-bpx;
+ Geom::Point bpx = iS->pData[iS->getEdge(iB).st].rx;
+ Geom::Point bdx = iS->eData[iB].rdx;
+ Geom::Point psx = getPoint(getEdge(ne).st).x;
+ Geom::Point pex = getPoint(getEdge(ne).en).x;
+ Geom::Point psbx=psx-bpx;
+ Geom::Point pebx=pex-bpx;
double pst = dot(psbx,bdx) * bdl;
double pet = dot(pebx,bdx) * bdl;
pst = iS->ebData[iB].tSt * (1 - pst) + iS->ebData[iB].tEn * pst;
index 8058e0452bd434dc8b54ecae5e241c910ec7c5e8..9ecfb99d6011b751d1c40d6ad17ab816e3f3758f 100644 (file)
return new PathDescrMoveTo(*this);
}
-void PathDescrMoveTo::dumpSVG(Inkscape::SVGOStringStream& s, NR::Point const &/*last*/) const
+void PathDescrMoveTo::dumpSVG(Inkscape::SVGOStringStream& s, Geom::Point const &/*last*/) const
{
- s << "M " << p[NR::X] << " " << p[NR::Y] << " ";
+ s << "M " << p[Geom::X] << " " << p[Geom::Y] << " ";
}
-void PathDescrMoveTo::transform(NR::Matrix const& t)
+void PathDescrMoveTo::transform(Geom::Matrix const& t)
{
p = p * t;
}
void PathDescrMoveTo::dump(std::ostream &s) const
{
/* localizing ok */
- s << " m " << p[NR::X] << " " << p[NR::Y];
+ s << " m " << p[Geom::X] << " " << p[Geom::Y];
}
-void PathDescrLineTo::dumpSVG(Inkscape::SVGOStringStream& s, NR::Point const &/*last*/) const
+void PathDescrLineTo::dumpSVG(Inkscape::SVGOStringStream& s, Geom::Point const &/*last*/) const
{
- s << "L " << p[NR::X] << " " << p[NR::Y] << " ";
+ s << "L " << p[Geom::X] << " " << p[Geom::Y] << " ";
}
PathDescr *PathDescrLineTo::clone() const
return new PathDescrLineTo(*this);
}
-void PathDescrLineTo::transform(NR::Matrix const& t)
+void PathDescrLineTo::transform(Geom::Matrix const& t)
{
p = p * t;
}
void PathDescrLineTo::dump(std::ostream &s) const
{
/* localizing ok */
- s << " l " << p[NR::X] << " " << p[NR::Y];
+ s << " l " << p[Geom::X] << " " << p[Geom::Y];
}
PathDescr *PathDescrBezierTo::clone() const
return new PathDescrBezierTo(*this);
}
-void PathDescrBezierTo::transform(NR::Matrix const& t)
+void PathDescrBezierTo::transform(Geom::Matrix const& t)
{
p = p * t;
}
void PathDescrBezierTo::dump(std::ostream &s) const
{
/* localizing ok */
- s << " b " << p[NR::X] << " " << p[NR::Y] << " " << nb;
+ s << " b " << p[Geom::X] << " " << p[Geom::Y] << " " << nb;
}
PathDescr *PathDescrIntermBezierTo::clone() const
return new PathDescrIntermBezierTo(*this);
}
-void PathDescrIntermBezierTo::transform(NR::Matrix const& t)
+void PathDescrIntermBezierTo::transform(Geom::Matrix const& t)
{
p = p * t;
}
void PathDescrIntermBezierTo::dump(std::ostream &s) const
{
/* localizing ok */
- s << " i " << p[NR::X] << " " << p[NR::Y];
+ s << " i " << p[Geom::X] << " " << p[Geom::Y];
}
-void PathDescrCubicTo::dumpSVG(Inkscape::SVGOStringStream& s, NR::Point const &last) const
+void PathDescrCubicTo::dumpSVG(Inkscape::SVGOStringStream& s, Geom::Point const &last) const
{
s << "C "
- << last[NR::X] + start[0] / 3 << " "
- << last[NR::Y] + start[1] / 3 << " "
- << p[NR::X] - end[0] / 3 << " "
- << p[NR::Y] - end[1] / 3 << " "
- << p[NR::X] << " "
- << p[NR::Y] << " ";
+ << last[Geom::X] + start[0] / 3 << " "
+ << last[Geom::Y] + start[1] / 3 << " "
+ << p[Geom::X] - end[0] / 3 << " "
+ << p[Geom::Y] - end[1] / 3 << " "
+ << p[Geom::X] << " "
+ << p[Geom::Y] << " ";
}
PathDescr *PathDescrCubicTo::clone() const
{
/* localizing ok */
s << " c "
- << p[NR::X] << " " << p[NR::Y] << " "
- << start[NR::X] << " " << start[NR::Y] << " "
- << end[NR::X] << " " << end[NR::Y] << " ";
+ << p[Geom::X] << " " << p[Geom::Y] << " "
+ << start[Geom::X] << " " << start[Geom::Y] << " "
+ << end[Geom::X] << " " << end[Geom::Y] << " ";
}
-void PathDescrCubicTo::transform(NR::Matrix const& t)
+void PathDescrCubicTo::transform(Geom::Matrix const& t)
{
- NR::Matrix tr = t;
+ Geom::Matrix tr = t;
tr[4] = tr[5] = 0;
start = start * tr;
end = end * tr;
p = p * t;
}
-void PathDescrArcTo::dumpSVG(Inkscape::SVGOStringStream& s, NR::Point const &/*last*/) const
+void PathDescrArcTo::dumpSVG(Inkscape::SVGOStringStream& s, Geom::Point const &/*last*/) const
{
s << "A "
<< rx << " "
@@ -118,8 +118,8 @@ void PathDescrArcTo::dumpSVG(Inkscape::SVGOStringStream& s, NR::Point const &/*l
<< angle << " "
<< (large ? "1" : "0") << " "
<< (clockwise ? "0" : "1") << " "
- << p[NR::X] << " "
- << p[NR::Y] << " ";
+ << p[Geom::X] << " "
+ << p[Geom::Y] << " ";
}
PathDescr *PathDescrArcTo::clone() const
return new PathDescrArcTo(*this);
}
-void PathDescrArcTo::transform(NR::Matrix const& t)
+void PathDescrArcTo::transform(Geom::Matrix const& t)
{
p = p * t;
}
{
/* localizing ok */
s << " a "
- << p[NR::X] << " " << p[NR::Y] << " "
+ << p[Geom::X] << " " << p[Geom::Y] << " "
<< rx << " " << ry << " "
<< angle << " "
<< (clockwise ? 1 : 0) << " "
return new PathDescrForced(*this);
}
-void PathDescrClose::dumpSVG(Inkscape::SVGOStringStream& s, NR::Point const &/*last*/) const
+void PathDescrClose::dumpSVG(Inkscape::SVGOStringStream& s, Geom::Point const &/*last*/) const
{
s << "z ";
}
index ccb4506f0307d0e57a4b1a3a7575dd39e3289199..27521e4b8a0e0d330786eeb04612be9110438f2a 100644 (file)
flags |= t;
}
- virtual void dumpSVG(Inkscape::SVGOStringStream &/*s*/, NR::Point const &/*last*/) const {}
+ virtual void dumpSVG(Inkscape::SVGOStringStream &/*s*/, Geom::Point const &/*last*/) const {}
virtual PathDescr *clone() const = 0;
- virtual void transform(NR::Matrix const &/*t*/) {}
+ virtual void transform(Geom::Matrix const &/*t*/) {}
virtual void dump(std::ostream &/*s*/) const {}
int flags; // most notably contains the path command no
struct PathDescrMoveTo : public PathDescr
{
- PathDescrMoveTo(NR::Point const &pp)
+ PathDescrMoveTo(Geom::Point const &pp)
: PathDescr(descr_moveto), p(pp) {}
- void dumpSVG(Inkscape::SVGOStringStream &s, NR::Point const &last) const;
+ void dumpSVG(Inkscape::SVGOStringStream &s, Geom::Point const &last) const;
PathDescr *clone() const;
- void transform(NR::Matrix const &t);
+ void transform(Geom::Matrix const &t);
void dump(std::ostream &s) const;
- NR::Point p;
+ Geom::Point p;
};
struct PathDescrLineTo : public PathDescr
{
- PathDescrLineTo(NR::Point const &pp)
+ PathDescrLineTo(Geom::Point const &pp)
: PathDescr(descr_lineto), p(pp) {}
- void dumpSVG(Inkscape::SVGOStringStream &s, NR::Point const &last) const;
+ void dumpSVG(Inkscape::SVGOStringStream &s, Geom::Point const &last) const;
PathDescr *clone() const;
- void transform(NR::Matrix const &t);
+ void transform(Geom::Matrix const &t);
void dump(std::ostream &s) const;
- NR::Point p;
+ Geom::Point p;
};
// quadratic bezier curves: a set of control points, and an endpoint
struct PathDescrBezierTo : public PathDescr
{
- PathDescrBezierTo(NR::Point const &pp, int n)
+ PathDescrBezierTo(Geom::Point const &pp, int n)
: PathDescr(descr_bezierto), p(pp), nb(n) {}
PathDescr *clone() const;
- void transform(NR::Matrix const &t);
+ void transform(Geom::Matrix const &t);
void dump(std::ostream &s) const;
- NR::Point p; // the endpoint's coordinates
+ Geom::Point p; // the endpoint's coordinates
int nb; // number of control points, stored in the next path description commands
};
{
PathDescrIntermBezierTo()
: PathDescr(descr_interm_bezier) , p(0, 0) {}
- PathDescrIntermBezierTo(NR::Point const &pp)
+ PathDescrIntermBezierTo(Geom::Point const &pp)
: PathDescr(descr_interm_bezier), p(pp) {}
PathDescr *clone() const;
- void transform(NR::Matrix const &t);
+ void transform(Geom::Matrix const &t);
void dump(std::ostream &s) const;
- NR::Point p; // control point coordinates
+ Geom::Point p; // control point coordinates
};
// cubic spline curve: 2 tangents and one endpoint
struct PathDescrCubicTo : public PathDescr
{
- PathDescrCubicTo(NR::Point const &pp, NR::Point const &s, NR::Point const& e)
+ PathDescrCubicTo(Geom::Point const &pp, Geom::Point const &s, Geom::Point const& e)
: PathDescr(descr_cubicto), p(pp), start(s), end(e) {}
- void dumpSVG(Inkscape::SVGOStringStream &s, NR::Point const &last) const;
+ void dumpSVG(Inkscape::SVGOStringStream &s, Geom::Point const &last) const;
PathDescr *clone() const;
- void transform(NR::Matrix const &t);
+ void transform(Geom::Matrix const &t);
void dump(std::ostream &s) const;
- NR::Point p;
- NR::Point start;
- NR::Point end;
+ Geom::Point p;
+ Geom::Point start;
+ Geom::Point end;
};
// arc: endpoint, 2 radii and one angle, plus 2 booleans to choose the arc (svg style)
struct PathDescrArcTo : public PathDescr
{
- PathDescrArcTo(NR::Point const &pp, double x, double y, double a, bool l, bool c)
+ PathDescrArcTo(Geom::Point const &pp, double x, double y, double a, bool l, bool c)
: PathDescr(descr_arcto), p(pp), rx(x), ry(y), angle(a), large(l), clockwise(c) {}
- void dumpSVG(Inkscape::SVGOStringStream &s, NR::Point const &last) const;
+ void dumpSVG(Inkscape::SVGOStringStream &s, Geom::Point const &last) const;
PathDescr *clone() const;
- void transform(NR::Matrix const &t);
+ void transform(Geom::Matrix const &t);
void dump(std::ostream &s) const;
- NR::Point p;
+ Geom::Point p;
double rx;
double ry;
double angle;
/* FIXME: not sure whether _forced should have a point associated with it;
** Path::ConvertForcedToMoveTo suggests that maybe it should.
*/
- NR::Point p;
+ Geom::Point p;
};
struct PathDescrClose : public PathDescr
{
PathDescrClose() : PathDescr(descr_close) {}
- void dumpSVG(Inkscape::SVGOStringStream &s, NR::Point const &last) const;
+ void dumpSVG(Inkscape::SVGOStringStream &s, Geom::Point const &last) const;
PathDescr *clone() const;
/* FIXME: not sure whether _forced should have a point associated with it;
** Path::ConvertForcedToMoveTo suggests that maybe it should.
*/
- NR::Point p;
+ Geom::Point p;
};
#endif
index 3c5d5f8cd3faabf890a83b486b3f990fcf3ea398..22b349abfd11a3ebdbe21afb96418efc224191a2 100644 (file)
* A container of intersection events.
*/
-#include <libnr/nr-forward.h>
+#include <2geom/forward.h>
class SweepEvent;
class SweepTree;
int size() const { return nbEvt; }
/// Look for the topmost intersection in the heap
- bool peek(SweepTree * &iLeft, SweepTree * &iRight, NR::Point &oPt, double &itl, double &itr);
+ bool peek(SweepTree * &iLeft, SweepTree * &iRight, Geom::Point &oPt, double &itl, double &itr);
/// Extract the topmost intersection from the heap
- bool extract(SweepTree * &iLeft, SweepTree * &iRight, NR::Point &oPt, double &itl, double &itr);
+ bool extract(SweepTree * &iLeft, SweepTree * &iRight, Geom::Point &oPt, double &itl, double &itr);
/// Add one intersection in the binary heap
- SweepEvent *add(SweepTree *iLeft, SweepTree *iRight, NR::Point &iPt, double itl, double itr);
+ SweepEvent *add(SweepTree *iLeft, SweepTree *iRight, Geom::Point &iPt, double itl, double itr);
void remove(SweepEvent *e);
void relocate(SweepEvent *e, int to);
index e84048a07fd00a26edb307d1b1631e2b499007e1..88d895e6b47485f87c3688a1d869abdd948411fc 100644 (file)
delete []inds;
}
-SweepEvent *SweepEventQueue::add(SweepTree *iLeft, SweepTree *iRight, NR::Point &px, double itl, double itr)
+SweepEvent *SweepEventQueue::add(SweepTree *iLeft, SweepTree *iRight, Geom::Point &px, double itl, double itr)
{
if (nbEvt > maxEvt) {
return NULL;
-bool SweepEventQueue::peek(SweepTree * &iLeft, SweepTree * &iRight, NR::Point &px, double &itl, double &itr)
+bool SweepEventQueue::peek(SweepTree * &iLeft, SweepTree * &iRight, Geom::Point &px, double &itl, double &itr)
{
if (nbEvt <= 0) {
return false;
return true;
}
-bool SweepEventQueue::extract(SweepTree * &iLeft, SweepTree * &iRight, NR::Point &px, double &itl, double &itr)
+bool SweepEventQueue::extract(SweepTree * &iLeft, SweepTree * &iRight, Geom::Point &px, double &itl, double &itr)
{
if (nbEvt <= 0) {
return false;
inds[n] = to;
int curInd = n;
- NR::Point const px = events[to].posx;
+ Geom::Point const px = events[to].posx;
bool didClimb = false;
while (curInd > 0) {
int const half = (curInd - 1) / 2;
*/
SweepEvent::SweepEvent()
{
- MakeNew (NULL, NULL, NR::Point(0, 0), 0, 0);
+ MakeNew (NULL, NULL, Geom::Point(0, 0), 0, 0);
}
SweepEvent::~SweepEvent()
MakeDelete();
}
-void SweepEvent::MakeNew(SweepTree *iLeft, SweepTree *iRight, NR::Point const &px, double itl, double itr)
+void SweepEvent::MakeNew(SweepTree *iLeft, SweepTree *iRight, Geom::Point const &px, double itl, double itr)
{
ind = -1;
posx = px;
index ce23a3ab9f7ad5ccc5fc8e45b590f710379ed099..bb22eddcfe7e1ce44ea2d04ce14477e6c2a13756 100644 (file)
public:
SweepTree *sweep[2]; ///< Sweep element associated with the left and right edge of the intersection.
- NR::Point posx; ///< Coordinates of the intersection.
+ Geom::Point posx; ///< Coordinates of the intersection.
double tl, tr; ///< Coordinates of the intersection on the left edge (tl) and on the right edge (tr).
int ind; ///< Index in the binary heap.
virtual ~SweepEvent(); // not used.
/// Initialize a SweepEvent structure.
- void MakeNew (SweepTree * iLeft, SweepTree * iRight, NR::Point const &iPt,
+ void MakeNew (SweepTree * iLeft, SweepTree * iRight, Geom::Point const &iPt,
double itl, double itr);
/// Void a SweepEvent structure.
index c6c295e333e7fc31ede023e39b0153cfb08ba987..b932b1542e412ebeba0d40c66480dcef3c0e43b6 100644 (file)
// lying at y=px[1].
// px is the upper endpoint of newOne
int
-SweepTree::Find(NR::Point const &px, SweepTree *newOne, SweepTree *&insertL,
+SweepTree::Find(Geom::Point const &px, SweepTree *newOne, SweepTree *&insertL,
SweepTree *&insertR, bool sweepSens)
{
// get the edge associated with this node: one point+one direction
// since we're dealing with line, the direction (bNorm) is taken downwards
- NR::Point bOrig, bNorm;
+ Geom::Point bOrig, bNorm;
bOrig = src->pData[src->getEdge(bord).st].rx;
bNorm = src->eData[bord].rdx;
if (src->getEdge(bord).st > src->getEdge(bord).en) {
// rotate to get the normal to the edge
bNorm=bNorm.ccw();
- NR::Point diff;
+ Geom::Point diff;
diff = px - bOrig;
// compute (px-orig)^dir to know on which side of this edge the point px lies
// sweepSens is needed (actually only used by the Scan() functions) because if the sweepline goes upward,
// signs change
// prendre en compte les directions
- NR::Point nNorm;
+ Geom::Point nNorm;
nNorm = newOne->src->eData[newOne->bord].rdx;
if (newOne->src->getEdge(newOne->bord).st >
newOne->src->getEdge(newOne->bord).en)
// only find a point's position
int
-SweepTree::Find(NR::Point const &px, SweepTree * &insertL,
+SweepTree::Find(Geom::Point const &px, SweepTree * &insertL,
SweepTree * &insertR)
{
- NR::Point bOrig, bNorm;
+ Geom::Point bOrig, bNorm;
bOrig = src->pData[src->getEdge(bord).st].rx;
bNorm = src->eData[bord].rdx;
if (src->getEdge(bord).st > src->getEdge(bord).en)
}
bNorm=bNorm.ccw();
- NR::Point diff;
+ Geom::Point diff;
diff = px - bOrig;
double y = 0;
return avl_no_err;
}
- NR::Point fromP;
+ Geom::Point fromP;
fromP = src->pData[fromPt].rx;
- NR::Point nNorm;
+ Geom::Point nNorm;
nNorm = src->getEdge(bord).dx;
if (src->getEdge(bord).st > src->getEdge(bord).en)
{
nNorm = -nNorm;
}
- NR::Point bNorm;
+ Geom::Point bNorm;
bNorm = insNode->src->getEdge(insNode->bord).dx;
if (insNode->src->getEdge(insNode->bord).st >
insNode->src->getEdge(insNode->bord).en)
index 67635b4c78993c46bded234ebe6e2dc85004d5ed..7f6b827dc99959e435a259b2f5997c20660bf796 100644 (file)
--- a/src/livarot/sweep-tree.h
+++ b/src/livarot/sweep-tree.h
// the find function that was missing in the AVLTrree class
// the return values are defined in LivarotDefs.h
- int Find(NR::Point const &iPt, SweepTree *newOne, SweepTree *&insertL,
+ int Find(Geom::Point const &iPt, SweepTree *newOne, SweepTree *&insertL,
SweepTree *&insertR, bool sweepSens = true);
- int Find(NR::Point const &iPt, SweepTree *&insertL, SweepTree *&insertR);
+ int Find(Geom::Point const &iPt, SweepTree *&insertL, SweepTree *&insertR);
/// Remove sweepevents attached to this node.
void RemoveEvents(SweepEventQueue &queue);
index 0f96c6ed28592c5ff0e1565fda38b88e0b358648..30248edd0bc148703fa91badda8f82ea6e65f8d0 100644 (file)
--- a/src/lpe-tool-context.cpp
+++ b/src/lpe-tool-context.cpp
int mode = prefs->getInt("/tools/lpetool/mode");
EffectType type = lpesubtools[mode];
- //bool over_stroke = lc->shape_editor->is_over_stroke(NR::Point(event->button.x, event->button.y), true);
+ //bool over_stroke = lc->shape_editor->is_over_stroke(Geom::Point(event->button.x, event->button.y), true);
sp_pen_context_wait_for_LPE_mouse_clicks(lc, type, Inkscape::LivePathEffect::Effect::acceptsNumClicks(type));
}
bool over_stroke = false;
- over_stroke = lc->shape_editor->is_over_stroke(NR::Point(event->motion.x, event->motion.y), false);
+ over_stroke = lc->shape_editor->is_over_stroke(Geom::Point(event->motion.x, event->motion.y), false);
if (over_stroke) {
event_context->cursor_shape = cursor_node_xpm;
Geom::Point A, B;
lpetool_get_limiting_bbox_corners(document, A, B);
- NR::Matrix doc2dt(lc->desktop->doc2dt());
+ Geom::Matrix doc2dt(lc->desktop->doc2dt());
A *= doc2dt;
B *= doc2dt;
diff --git a/src/main.cpp b/src/main.cpp
index 515ed9c1838a0d131f8e7577b1970f32b711e402..eb1a0b103fefbe3d3a8d6de512b848e0df8082c9 100644 (file)
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -167,7 +167,7 @@ static void do_export_ps_pdf(SPDocument* doc, gchar const* uri, char const *mime
#ifdef WIN32
static void do_export_emf(SPDocument* doc, gchar const* uri, char const *mime);
#endif //WIN32
-static void do_query_dimension (SPDocument *doc, bool extent, NR::Dim2 const axis, const gchar *id);
+static void do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const gchar *id);
static void do_query_all (SPDocument *doc);
static void do_query_all_recurse (SPObject *o);
if (sp_query_all) {
do_query_all (doc);
} else if (sp_query_width || sp_query_height) {
- do_query_dimension (doc, true, sp_query_width? NR::X : NR::Y, sp_query_id);
+ do_query_dimension (doc, true, sp_query_width? Geom::X : Geom::Y, sp_query_id);
} else if (sp_query_x || sp_query_y) {
- do_query_dimension (doc, false, sp_query_x? NR::X : NR::Y, sp_query_id);
+ do_query_dimension (doc, false, sp_query_x? Geom::X : Geom::Y, sp_query_id);
}
delete doc;
}
static void
-do_query_dimension (SPDocument *doc, bool extent, NR::Dim2 const axis, const gchar *id)
+do_query_dimension (SPDocument *doc, bool extent, Geom::Dim2 const axis, const gchar *id)
{
SPObject *o = NULL;
diff --git a/src/marker.cpp b/src/marker.cpp
index 59d5355ef99a13122d46897ffe58f526e1a8247d..3961f847376d284e1541419ade12c880905a7a2c 100644 (file)
--- a/src/marker.cpp
+++ b/src/marker.cpp
/* Copy parent context */
rctx.ctx = *ctx;
/* Initialize tranformations */
- rctx.i2doc = NR::identity();
- rctx.i2vp = NR::identity();
+ rctx.i2doc = Geom::identity();
+ rctx.i2vp = Geom::identity();
/* Set up viewport */
rctx.vp.x0 = 0.0;
rctx.vp.y0 = 0.0;
diff --git a/src/node-context.cpp b/src/node-context.cpp
index c6c639631aa051de6d7d6edbfed98517b91c8a30..3f241850e76f9bc3407f77b9ea490e30e470aa12 100644 (file)
--- a/src/node-context.cpp
+++ b/src/node-context.cpp
if (!nc->drag) {
if (nc->shape_editor->has_nodepath() && selection->single() /* && item_over */) {
// save drag origin
- bool over_stroke = nc->shape_editor->is_over_stroke(NR::Point(event->button.x, event->button.y), true);
+ bool over_stroke = nc->shape_editor->is_over_stroke(Geom::Point(event->button.x, event->button.y), true);
//only dragging curves
if (over_stroke) {
ret = TRUE;
}
}
}
- NR::Point const button_w(event->button.x,
+ Geom::Point const button_w(event->button.x,
event->button.y);
- NR::Point const button_dt(desktop->w2d(button_w));
+ Geom::Point const button_dt(desktop->w2d(button_w));
Inkscape::Rubberband::get(desktop)->start(desktop, button_dt);
nc->current_state = SP_NODE_CONTEXT_INACTIVE;
desktop->updateNow();
}
case SP_NODE_CONTEXT_RUBBERBAND_DRAGGING:
if (Inkscape::Rubberband::get(desktop)->is_started()) {
- NR::Point const motion_w(event->motion.x,
+ Geom::Point const motion_w(event->motion.x,
event->motion.y);
- NR::Point const motion_dt(desktop->w2d(motion_w));
+ Geom::Point const motion_dt(desktop->w2d(motion_w));
Inkscape::Rubberband::get(desktop)->move(motion_dt);
}
break;
}
bool over_stroke = false;
- over_stroke = nc->shape_editor->is_over_stroke(NR::Point(event->motion.x, event->motion.y), false);
+ over_stroke = nc->shape_editor->is_over_stroke(Geom::Point(event->motion.x, event->motion.y), false);
if (nc->cursor_drag && !over_stroke) {
event_context->cursor_shape = cursor_node_xpm;
if ( (event->button.button == 1) && (!nc->drag) && !event_context->space_panning) {
// find out clicked item, disregarding groups, honoring Alt
SPItem *item_clicked = sp_event_context_find_item (desktop,
- NR::Point(event->button.x, event->button.y),
+ Geom::Point(event->button.x, event->button.y),
(event->button.state & GDK_MOD1_MASK) && !(event->button.state & GDK_CONTROL_MASK), TRUE);
event_context->xp = event_context->yp = 0;
bool over_stroke = false;
if (nc->shape_editor->has_nodepath()) {
- over_stroke = nc->shape_editor->is_over_stroke(NR::Point(event->button.x, event->button.y), false);
+ over_stroke = nc->shape_editor->is_over_stroke(Geom::Point(event->button.x, event->button.y), false);
}
if (item_clicked || over_stroke) {
diff --git a/src/object-edit.cpp b/src/object-edit.cpp
index 86e1f5302bfa5adea987bf0aaf42f2d507c25a2f..4e8ce86c443ff34bda21632ece6070fddfebaa23 100644 (file)
--- a/src/object-edit.cpp
+++ b/src/object-edit.cpp
@@ -145,11 +145,11 @@ RectKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*orig
if (state & GDK_CONTROL_MASK) {
gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0;
- rect->rx.computed = rect->ry.computed = CLAMP(rect->x.computed + rect->width.computed - p[NR::X], 0.0, temp);
+ rect->rx.computed = rect->ry.computed = CLAMP(rect->x.computed + rect->width.computed - p[Geom::X], 0.0, temp);
rect->rx._set = rect->ry._set = true;
} else {
- rect->rx.computed = CLAMP(rect->x.computed + rect->width.computed - p[NR::X], 0.0, rect->width.computed / 2.0);
+ rect->rx.computed = CLAMP(rect->x.computed + rect->width.computed - p[Geom::X], 0.0, rect->width.computed / 2.0);
rect->rx._set = true;
}
@@ -194,15 +194,15 @@ RectKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*orig
if (state & GDK_CONTROL_MASK) {
gdouble temp = MIN(rect->height.computed, rect->width.computed) / 2.0;
- rect->rx.computed = rect->ry.computed = CLAMP(p[NR::Y] - rect->y.computed, 0.0, temp);
+ rect->rx.computed = rect->ry.computed = CLAMP(p[Geom::Y] - rect->y.computed, 0.0, temp);
rect->ry._set = rect->rx._set = true;
} else {
if (!rect->rx._set || rect->rx.computed == 0) {
- rect->ry.computed = CLAMP(p[NR::Y] - rect->y.computed,
+ rect->ry.computed = CLAMP(p[Geom::Y] - rect->y.computed,
0.0,
MIN(rect->height.computed / 2.0, rect->width.computed / 2.0));
} else {
- rect->ry.computed = CLAMP(p[NR::Y] - rect->y.computed,
+ rect->ry.computed = CLAMP(p[Geom::Y] - rect->y.computed,
0.0,
rect->height.computed / 2.0);
}
@@ -261,15 +261,15 @@ RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &or
if (state & GDK_CONTROL_MASK) {
// original width/height when drag started
- gdouble const w_orig = (origin[NR::X] - rect->x.computed);
- gdouble const h_orig = (origin[NR::Y] - rect->y.computed);
+ gdouble const w_orig = (origin[Geom::X] - rect->x.computed);
+ gdouble const h_orig = (origin[Geom::Y] - rect->y.computed);
//original ratio
gdouble const ratio = (w_orig / h_orig);
// mouse displacement since drag started
- gdouble const minx = s[NR::X] - origin[NR::X];
- gdouble const miny = s[NR::Y] - origin[NR::Y];
+ gdouble const minx = s[Geom::X] - origin[Geom::X];
+ gdouble const miny = s[Geom::Y] - origin[Geom::Y];
if (fabs(minx) > fabs(miny)) {
@@ -299,8 +299,8 @@ RectKnotHolderEntityWH::set_internal(Geom::Point const &p, Geom::Point const &or
} else {
// move freely
- rect->width.computed = MAX(s[NR::X] - rect->x.computed, 0);
- rect->height.computed = MAX(s[NR::Y] - rect->y.computed, 0);
+ rect->width.computed = MAX(s[Geom::X] - rect->x.computed, 0);
+ rect->height.computed = MAX(s[Geom::Y] - rect->y.computed, 0);
rect->width._set = rect->height._set = true;
}
@@ -334,14 +334,14 @@ RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin
gdouble opposite_y = (rect->y.computed + rect->height.computed);
// original width/height when drag started
- gdouble w_orig = opposite_x - origin[NR::X];
- gdouble h_orig = opposite_y - origin[NR::Y];
+ gdouble w_orig = opposite_x - origin[Geom::X];
+ gdouble h_orig = opposite_y - origin[Geom::Y];
Geom::Point const s = snap_knot_position(p);
// mouse displacement since drag started
- gdouble minx = s[NR::X] - origin[NR::X];
- gdouble miny = s[NR::Y] - origin[NR::Y];
+ gdouble minx = s[Geom::X] - origin[Geom::X];
+ gdouble miny = s[Geom::Y] - origin[Geom::Y];
if (state & GDK_CONTROL_MASK) {
//original ratio
@@ -350,30 +350,30 @@ RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin
if (fabs(minx) > fabs(miny)) {
// snap to horizontal or diagonal
- rect->x.computed = MIN(s[NR::X], opposite_x);
+ rect->x.computed = MIN(s[Geom::X], opposite_x);
rect->width.computed = MAX(w_orig - minx, 0);
if (minx != 0 && fabs(miny/minx) > 0.5 * 1/ratio && (SGN(minx) == SGN(miny))) {
// closer to the diagonal and in same-sign quarters, change both using ratio
- rect->y.computed = MIN(origin[NR::Y] + minx / ratio, opposite_y);
+ rect->y.computed = MIN(origin[Geom::Y] + minx / ratio, opposite_y);
rect->height.computed = MAX(h_orig - minx / ratio, 0);
} else {
// closer to the horizontal, change only width, height is h_orig
- rect->y.computed = MIN(origin[NR::Y], opposite_y);
+ rect->y.computed = MIN(origin[Geom::Y], opposite_y);
rect->height.computed = MAX(h_orig, 0);
}
} else {
// snap to vertical or diagonal
- rect->y.computed = MIN(s[NR::Y], opposite_y);
+ rect->y.computed = MIN(s[Geom::Y], opposite_y);
rect->height.computed = MAX(h_orig - miny, 0);
if (miny != 0 && fabs(minx/miny) > 0.5 *ratio && (SGN(minx) == SGN(miny))) {
// closer to the diagonal and in same-sign quarters, change both using ratio
- rect->x.computed = MIN(origin[NR::X] + miny * ratio, opposite_x);
+ rect->x.computed = MIN(origin[Geom::X] + miny * ratio, opposite_x);
rect->width.computed = MAX(w_orig - miny * ratio, 0);
} else {
// closer to the vertical, change only height, width is w_orig
- rect->x.computed = MIN(origin[NR::X], opposite_x);
+ rect->x.computed = MIN(origin[Geom::X], opposite_x);
rect->width.computed = MAX(w_orig, 0);
}
@@ -383,9 +383,9 @@ RectKnotHolderEntityXY::knot_set(Geom::Point const &p, Geom::Point const &origin
} else {
// move freely
- rect->x.computed = MIN(s[NR::X], opposite_x);
+ rect->x.computed = MIN(s[Geom::X], opposite_x);
rect->width.computed = MAX(w_orig - minx, 0);
- rect->y.computed = MIN(s[NR::Y], opposite_y);
+ rect->y.computed = MIN(s[Geom::Y], opposite_y);
rect->height.computed = MAX(h_orig - miny, 0);
rect->width._set = rect->height._set = rect->x._set = rect->y._set = true;
}
static gint
sp_genericellipse_side(SPGenericEllipse *ellipse, Geom::Point const &p)
{
- gdouble dx = (p[NR::X] - ellipse->cx.computed) / ellipse->rx.computed;
- gdouble dy = (p[NR::Y] - ellipse->cy.computed) / ellipse->ry.computed;
+ gdouble dx = (p[Geom::X] - ellipse->cx.computed) / ellipse->rx.computed;
+ gdouble dy = (p[Geom::Y] - ellipse->cy.computed) / ellipse->ry.computed;
gdouble s = dx * dx + dy * dy;
if (s < 1.0) return 1;
@@ -822,7 +822,7 @@ ArcKnotHolderEntityRX::knot_set(Geom::Point const &p, Geom::Point const &/*origi
Geom::Point const s = snap_knot_position(p);
- ge->rx.computed = fabs( ge->cx.computed - s[NR::X] );
+ ge->rx.computed = fabs( ge->cx.computed - s[Geom::X] );
if ( state & GDK_CONTROL_MASK ) {
ge->ry.computed = ge->rx.computed;
@@ -857,7 +857,7 @@ ArcKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origi
Geom::Point const s = snap_knot_position(p);
- ge->ry.computed = fabs( ge->cy.computed - s[NR::Y] );
+ ge->ry.computed = fabs( ge->cy.computed - s[Geom::Y] );
if ( state & GDK_CONTROL_MASK ) {
ge->rx.computed = ge->ry.computed;
@@ -1087,8 +1087,8 @@ SpiralKnotHolderEntityInner::knot_set(Geom::Point const &p, Geom::Point const &/
SPSpiral *spiral = SP_SPIRAL(item);
- gdouble dx = p[NR::X] - spiral->cx;
- gdouble dy = p[NR::Y] - spiral->cy;
+ gdouble dx = p[Geom::X] - spiral->cx;
+ gdouble dy = p[Geom::Y] - spiral->cy;
if (state & GDK_MOD1_MASK) {
// adjust divergence by vertical drag, relative to rad
@@ -1130,8 +1130,8 @@ SpiralKnotHolderEntityOuter::knot_set(Geom::Point const &p, Geom::Point const &/
SPSpiral *spiral = SP_SPIRAL(item);
- gdouble dx = p[NR::X] - spiral->cx;
- gdouble dy = p[NR::Y] - spiral->cy;
+ gdouble dx = p[Geom::X] - spiral->cx;
+ gdouble dy = p[Geom::Y] - spiral->cy;
if (state & GDK_SHIFT_MASK) { // rotate without roll/unroll
spiral->arg = atan2(dy, dx) - 2.0*M_PI*spiral->revo;
diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index 46268954a39b44fce3f13b34ba6a85aff803ac8e..1762d668c00d3ba7ccffaffe10b47b25b3eacaf8 100644 (file)
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
@@ -1211,8 +1211,8 @@ spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, Geom::Point c
SPDesktop *desktop = SP_EVENT_CONTEXT(pc)->desktop;
Geom::Point rel = p - pc->p[pc_point_to_compare];
- GString *dist = SP_PX_TO_METRIC_STRING(NR::L2(rel), desktop->namedview->getDefaultMetric());
- double angle = atan2(rel[NR::Y], rel[NR::X]) * 180 / M_PI;
+ GString *dist = SP_PX_TO_METRIC_STRING(Geom::L2(rel), desktop->namedview->getDefaultMetric());
+ double angle = atan2(rel[Geom::Y], rel[Geom::X]) * 180 / M_PI;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/options/compassangledisplay/value", 0) != 0)
angle = angle_to_compass (angle);
*/
if (pc->num_clicks == 0) {
// first mouse click
- double dist_h = fabs(pt[NR::X] - origin[NR::X]);
- double dist_v = fabs(pt[NR::Y] - origin[NR::Y]);
+ double dist_h = fabs(pt[Geom::X] - origin[Geom::X]);
+ double dist_v = fabs(pt[Geom::Y] - origin[Geom::Y]);
int ret = (dist_h < dist_v) ? 1 : 0; // 0 = horizontal, 1 = vertical
pen_last_paraxial_dir = (state & GDK_SHIFT_MASK) ? 1 - ret : ret;
return pen_last_paraxial_dir;
@@ -1432,10 +1432,10 @@ void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt
if (next_dir == 0) {
// line is forced to be horizontal
- pt[NR::Y] = origin[NR::Y];
+ pt[Geom::Y] = origin[Geom::Y];
} else {
// line is forced to be vertical
- pt[NR::X] = origin[NR::X];
+ pt[Geom::X] = origin[Geom::X];
}
}
@@ -1444,9 +1444,9 @@ Geom::Point pen_get_intermediate_horiz_vert(const SPPenContext *const pc, Geom::
Geom::Point const &origin = pc->p[0];
if (pen_last_paraxial_dir == 0) {
- return Geom::Point (origin[NR::X], pt[NR::Y]);
+ return Geom::Point (origin[Geom::X], pt[Geom::Y]);
} else {
- return Geom::Point (pt[NR::X], origin[NR::Y]);
+ return Geom::Point (pt[Geom::X], origin[Geom::Y]);
}
}
diff --git a/src/selcue.cpp b/src/selcue.cpp
index 03205d8498a893b08b50785c9fa0cd782d6d287f..67c9712d1f14b2a73b6f34417bb642ce1357022b 100644 (file)
--- a/src/selcue.cpp
+++ b/src/selcue.cpp
"stroke_color", 0x000000ff,
NULL);
sp_canvas_item_show(box);
- SP_CTRL(box)->moveto(NR::Point(b->min()[NR::X], b->max()[NR::Y]));
+ SP_CTRL(box)->moveto(Geom::Point(b->min()[Geom::X], b->max()[Geom::Y]));
sp_canvas_item_move_to_z(box, 0); // just low enough to not get in the way of other draggable knots
diff --git a/src/select-context.cpp b/src/select-context.cpp
index 11c9cc4e9cafcc9bfca8c381cc86f87c0880e4bc..1daf6b0e56967be6363dfba5b2c67f47feb2b4df 100644 (file)
--- a/src/select-context.cpp
+++ b/src/select-context.cpp
@@ -333,7 +333,7 @@ sp_select_context_item_handler(SPEventContext *event_context, SPItem *item, GdkE
sc->item = NULL;
}
sc->item = sp_event_context_find_item (desktop,
- NR::Point(event->button.x, event->button.y), event->button.state & GDK_MOD1_MASK, FALSE);
+ Geom::Point(event->button.x, event->button.y), event->button.state & GDK_MOD1_MASK, FALSE);
sp_object_ref(sc->item, NULL);
rb_escaped = drag_escaped = 0;
yp = (gint) event->button.y;
within_tolerance = true;
- NR::Point const button_pt(event->button.x, event->button.y);
- NR::Point const p(desktop->w2d(button_pt));
+ Geom::Point const button_pt(event->button.x, event->button.y);
+ Geom::Point const p(desktop->w2d(button_pt));
if (event->button.state & GDK_MOD1_MASK)
Inkscape::Rubberband::get(desktop)->setMode(RUBBERBAND_MODE_TOUCHPATH);
Inkscape::Rubberband::get(desktop)->start(desktop, p);
case GDK_MOTION_NOTIFY:
if (event->motion.state & GDK_BUTTON1_MASK && !event_context->space_panning) {
- NR::Point const motion_pt(event->motion.x, event->motion.y);
- NR::Point const p(desktop->w2d(motion_pt));
+ Geom::Point const motion_pt(event->motion.x, event->motion.y);
+ Geom::Point const p(desktop->w2d(motion_pt));
if ( within_tolerance
&& ( abs( (gint) event->motion.x - xp ) < tolerance )
@@ -502,14 +502,14 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
// and also when we started within tolerance, but trespassed tolerance outside of item
Inkscape::Rubberband::get(desktop)->stop();
SP_EVENT_CONTEXT(sc)->defaultMessageContext()->clear();
- item_at_point = desktop->item_at_point(NR::Point(event->button.x, event->button.y), FALSE);
+ item_at_point = desktop->item_at_point(Geom::Point(event->button.x, event->button.y), FALSE);
if (!item_at_point) // if no item at this point, try at the click point (bug 1012200)
- item_at_point = desktop->item_at_point(NR::Point(xp, yp), FALSE);
+ item_at_point = desktop->item_at_point(Geom::Point(xp, yp), FALSE);
if (item_at_point || sc->moved || sc->button_press_alt) {
// drag only if starting from an item, or if something is already grabbed, or if alt-dragging
if (!sc->moved) {
- item_in_group = desktop->item_at_point(NR::Point(event->button.x, event->button.y), TRUE);
- group_at_point = desktop->group_at_point(NR::Point(event->button.x, event->button.y));
+ item_in_group = desktop->item_at_point(Geom::Point(event->button.x, event->button.y), TRUE);
+ group_at_point = desktop->group_at_point(Geom::Point(event->button.x, event->button.y));
// group-at-point is meant to be topmost item if it's a group,
// not topmost group of all items at point
@@ -627,12 +627,12 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event)
if (sc->button_press_ctrl) {
// go into groups, honoring Alt
item = sp_event_context_find_item (desktop,
- NR::Point(event->button.x, event->button.y), event->button.state & GDK_MOD1_MASK, TRUE);
+ Geom::Point(event->button.x, event->button.y), event->button.state & GDK_MOD1_MASK, TRUE);
sc->button_press_ctrl = FALSE;
} else {
// don't go into groups, honoring Alt
item = sp_event_context_find_item (desktop,
- NR::Point(event->button.x, event->button.y), event->button.state & GDK_MOD1_MASK, FALSE);
+ Geom::Point(event->button.x, event->button.y), event->button.state & GDK_MOD1_MASK, FALSE);
}
if (item) {
} else if ((sc->button_press_ctrl || sc->button_press_alt) && !rb_escaped && !drag_escaped) { // ctrl+click, alt+click
item = sp_event_context_find_item (desktop,
- NR::Point(event->button.x, event->button.y), sc->button_press_alt, sc->button_press_ctrl);
+ Geom::Point(event->button.x, event->button.y), sc->button_press_alt, sc->button_press_ctrl);
sc->button_press_ctrl = FALSE;
sc->button_press_alt = FALSE;
index 92f751e85673b288c80a3a26fefe02d12a5526ec..f1bb46167de8e2bbd8d3e77ef370b5d2be4a8e91 100644 (file)
#include "ui/clipboard.h"
-using NR::X;
-using NR::Y;
+using Geom::X;
+using Geom::Y;
/* The clipboard handling is in ui/clipboard.cpp now. There are some legacy functions left here,
because the layer manipulation code uses them. It should be rewritten specifically
* Copies repr and its inherited css style elements, along with the accumulated transform 'full_t',
* then prepends the copy to 'clip'.
*/
-void sp_selection_copy_one (Inkscape::XML::Node *repr, NR::Matrix full_t, GSList **clip, Inkscape::XML::Document* xml_doc)
+void sp_selection_copy_one (Inkscape::XML::Node *repr, Geom::Matrix full_t, GSList **clip, Inkscape::XML::Document* xml_doc)
{
Inkscape::XML::Node *copy = repr->duplicate(xml_doc);
@@ -147,8 +147,8 @@ GSList *sp_selection_paste_impl (SPDocument *doc, SPObject *parent, GSList **cli
Inkscape::XML::Node *copy = repr->duplicate(xml_doc);
// premultiply the item transform by the accumulated parent transform in the paste layer
- NR::Matrix local (sp_item_i2doc_affine(SP_ITEM(parent)));
- if (!local.test_identity()) {
+ Geom::Matrix local (sp_item_i2doc_affine(SP_ITEM(parent)));
+ if (!local.isIdentity()) {
gchar const *t_str = copy->attribute("transform");
Geom::Matrix item_t (Geom::identity());
if (t_str)
@@ -1234,7 +1234,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Matrix cons
} else if (prefs_unmoved) {
//if (SP_IS_USE(sp_use_get_original(SP_USE(item))))
- // clone_move = NR::identity();
+ // clone_move = Geom::identity();
Geom::Matrix move = result * clone_move;
sp_item_write_transform(item, SP_OBJECT_REPR(item), move, &t);
}
y1 - y0);
Geom::Scale const scale( newSize * Geom::Scale(bbox->dimensions()).inverse() );
Geom::Translate const o2n(x0, y0);
- NR::Matrix const final( p2o * scale * o2n );
+ Geom::Matrix const final( p2o * scale * o2n );
sp_selection_apply_affine(selection, final);
}
@@ -1314,8 +1314,8 @@ void sp_selection_scale_relative(Inkscape::Selection *selection, Geom::Point con
}
// FIXME: ARBITRARY LIMIT: don't try to scale above 1 Mpx, it won't display properly and will crash sooner or later anyway
- if ( bbox->dimensions()[NR::X] * scale[Geom::X] > 1e6 ||
- bbox->dimensions()[NR::Y] * scale[Geom::Y] > 1e6 )
+ if ( bbox->dimensions()[Geom::X] * scale[Geom::X] > 1e6 ||
+ bbox->dimensions()[Geom::Y] * scale[Geom::Y] > 1e6 )
{
return;
}
@@ -1350,12 +1350,12 @@ sp_selection_skew_relative(Inkscape::Selection *selection, Geom::Point const &al
void sp_selection_move_relative(Inkscape::Selection *selection, Geom::Point const &move)
{
- sp_selection_apply_affine(selection, NR::Matrix(Geom::Translate(move)));
+ sp_selection_apply_affine(selection, Geom::Matrix(Geom::Translate(move)));
}
void sp_selection_move_relative(Inkscape::Selection *selection, double dx, double dy)
{
- sp_selection_apply_affine(selection, NR::Matrix(Geom::Translate(dx, dy)));
+ sp_selection_apply_affine(selection, Geom::Matrix(Geom::Translate(dx, dy)));
}
/**
return;
GSList const *l = selection->itemList();
- Geom::Rotate const rot_90(NR::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw
+ Geom::Rotate const rot_90(Geom::Point(0, ccw ? 1 : -1)); // pos. or neg. rotation, depending on the value of ccw
for (GSList const *l2 = l ; l2 != NULL ; l2 = l2->next) {
SPItem *item = SP_ITEM(l2->data);
sp_item_rotate_rel(item, rot_90);
}
// calculate the transform to be applied to objects to move them to 0,0
- Geom::Point move_p = Geom::Point(0, sp_document_height(doc)) - (r->min() + Geom::Point (0, r->dimensions()[NR::Y]));
+ Geom::Point move_p = Geom::Point(0, sp_document_height(doc)) - (r->min() + Geom::Point (0, r->dimensions()[Geom::Y]));
move_p[Geom::Y] = -move_p[Geom::Y];
Geom::Matrix move = Geom::Matrix (Geom::Translate (move_p));
selection->add(repr);
// transform mask, so it is moved the same spot where mask was applied
- NR::Matrix transform (mask_item->transform);
+ Geom::Matrix transform (mask_item->transform);
transform *= (*it).second->transform;
sp_item_write_transform(mask_item, SP_OBJECT_REPR(mask_item), transform);
}
diff --git a/src/sp-conn-end.cpp b/src/sp-conn-end.cpp
index 5776388c36f12ae7b417009534fe4493712efcbe..91ff4bc2bf3fd1a3d85f6723f120c01e9875078a 100644 (file)
--- a/src/sp-conn-end.cpp
+++ b/src/sp-conn-end.cpp
Geom::Rect otherpt_rect = Geom::Rect(other_endpt, other_endpt);
Geom::Rect h2bbox_icoordsys[2] = { otherpt_rect, otherpt_rect };
- Geom::OptRect bbox = h2attItem[ind]->getBounds(NR::identity());
+ Geom::OptRect bbox = h2attItem[ind]->getBounds(Geom::identity());
if (!bbox) {
if (updatePathRepr) {
path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
diff --git a/src/sp-image.cpp b/src/sp-image.cpp
index be4d37909f292e2e028833c3a05b184a633f06a9..75be3bea2cb951f3c9702d69b5590ef631ebf7ad 100644 (file)
--- a/src/sp-image.cpp
+++ b/src/sp-image.cpp
@@ -1326,11 +1326,11 @@ static void sp_image_snappoints(SPItem const *item, SnapPointsIter p, Inkscape::
double const y0 = image.y.computed;
double const x1 = x0 + image.width.computed;
double const y1 = y0 + image.height.computed;
- NR::Matrix const i2d (sp_item_i2d_affine (item));
- *p = NR::Point(x0, y0) * i2d;
- *p = NR::Point(x0, y1) * i2d;
- *p = NR::Point(x1, y1) * i2d;
- *p = NR::Point(x1, y0) * i2d;
+ Geom::Matrix const i2d (sp_item_i2d_affine (item));
+ *p = Geom::Point(x0, y0) * i2d;
+ *p = Geom::Point(x0, y1) * i2d;
+ *p = Geom::Point(x1, y1) * i2d;
+ *p = Geom::Point(x1, y0) * i2d;
}
}
Geom::Matrix ret(Geom::Matrix(xform).without_translation());
Geom::Point const scale(hypot(ret[0], ret[1]),
hypot(ret[2], ret[3]));
- if ( scale[NR::X] > MAGIC_EPSILON ) {
+ if ( scale[Geom::X] > MAGIC_EPSILON ) {
ret[0] /= scale[Geom::X];
ret[1] /= scale[Geom::X];
} else {
ret[0] = 1.0;
ret[1] = 0.0;
}
- if ( scale[NR::Y] > MAGIC_EPSILON ) {
+ if ( scale[Geom::Y] > MAGIC_EPSILON ) {
ret[2] /= scale[Geom::Y];
ret[3] /= scale[Geom::Y];
} else {
}
} else {
NRRect rect;
- sp_image_bbox(image, &rect, NR::identity(), 0);
+ sp_image_bbox(image, &rect, Geom::identity(), 0);
Geom::Rect rect2 = to_2geom(*rect.upgrade());
SPCurve *c = SPCurve::new_from_rect(rect2);
diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp
index 2b42a855b3c5877dcb39444fb17d12e63582cc1b..afa3880b8ae6f6f453ec20090c061b3b0a6d01c8 100644 (file)
--- a/src/sp-item-group.cpp
+++ b/src/sp-item-group.cpp
g_return_if_fail (!strcmp (grepr->name(), "svg:g") || !strcmp (grepr->name(), "svg:a") || !strcmp (grepr->name(), "svg:switch"));
// this converts the gradient/pattern fill/stroke on the group, if any, to userSpaceOnUse
- sp_item_adjust_paint_recursive (gitem, NR::identity(), NR::identity(), false);
+ sp_item_adjust_paint_recursive (gitem, Geom::identity(), Geom::identity(), false);
SPItem *pitem = SP_ITEM (SP_OBJECT_PARENT (gitem));
Inkscape::XML::Node *prepr = SP_OBJECT_REPR (pitem);
/* Merging of style */
// this converts the gradient/pattern fill/stroke, if any, to userSpaceOnUse; we need to do
// it here _before_ the new transform is set, so as to use the pre-transform bbox
- sp_item_adjust_paint_recursive (citem, NR::identity(), NR::identity(), false);
+ sp_item_adjust_paint_recursive (citem, Geom::identity(), Geom::identity(), false);
sp_style_merge_from_dying_parent(SP_OBJECT_STYLE(child), SP_OBJECT_STYLE(gitem));
/*
diff --git a/src/sp-root.cpp b/src/sp-root.cpp
index 0cb3d3389a4b33f39b6efeefebafc0141ae5cbc8..81d71044d9a8830afb05dbee053826e275069ace 100644 (file)
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
@@ -174,7 +174,7 @@ sp_root_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
}
// clear transform, if any was read in - SVG does not allow transform= on <svg>
- SP_ITEM(object)->transform = NR::identity();
+ SP_ITEM(object)->transform = Geom::identity();
}
/**
rctx.vp.y1 = root->height.computed;
}
- rctx.i2vp = NR::identity();
+ rctx.i2vp = Geom::identity();
/* And invoke parent method */
if (((SPObjectClass *) (parent_class))->update)
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 7ee2af1ec97321eecde89ff6d8331847cebf773e..155c9b45411a7eab924c74d8a09fbfab28c1f686 100644 (file)
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
}
/* fixme: Think (Lauris) */
- sp_item_invoke_bbox(item, &pbox, NR::identity(), TRUE);
+ sp_item_invoke_bbox(item, &pbox, Geom::identity(), TRUE);
dbox.x0 = 0.0;
dbox.y0 = 0.0;
dbox.x1 = sp_document_width (SP_OBJECT_DOCUMENT (item));
tr = marker_item->transform * marker->c2p * tr;
- NR::Matrix old_tr = marker_item->transform;
+ Geom::Matrix old_tr = marker_item->transform;
marker_item->transform = tr;
sp_item_invoke_print (marker_item, ctx);
marker_item->transform = old_tr;
tr = marker_item->transform * marker->c2p * tr;
- NR::Matrix old_tr = marker_item->transform;
+ Geom::Matrix old_tr = marker_item->transform;
marker_item->transform = tr;
sp_item_invoke_print (marker_item, ctx);
marker_item->transform = old_tr;
tr = marker_item->transform * marker->c2p * tr;
- NR::Matrix old_tr = marker_item->transform;
+ Geom::Matrix old_tr = marker_item->transform;
marker_item->transform = tr;
sp_item_invoke_print (marker_item, ctx);
marker_item->transform = old_tr;
diff --git a/src/sp-symbol.cpp b/src/sp-symbol.cpp
index f70a19b06a6c5c56db457302ba022914b12d3f1c..41004db6e37154db0e98ae5ae6f687d2dc2af5ae 100644 (file)
--- a/src/sp-symbol.cpp
+++ b/src/sp-symbol.cpp
/* Calculate child to parent transformation */
/* Apply parent <use> translation (set up as vewport) */
- symbol->c2p = NR::Matrix(Geom::Translate(rctx.vp.x0, rctx.vp.y0));
+ symbol->c2p = Geom::Matrix(Geom::Translate(rctx.vp.x0, rctx.vp.y0));
if (symbol->viewBox_set) {
double x, y, width, height;
rctx.vp.y0 = symbol->viewBox.y0;
rctx.vp.x1 = symbol->viewBox.x1;
rctx.vp.y1 = symbol->viewBox.y1;
- rctx.i2vp = NR::identity();
+ rctx.i2vp = Geom::identity();
}
/* And invoke parent method */
diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp
index 2496fc6e0095f619dc985fb82a0fa935fe3d1137..9da95df904906e9d947ea5327c9ba7c088bbd5bd 100644 (file)
--- a/src/sp-tspan.cpp
+++ b/src/sp-tspan.cpp
NRRect bbox;
sp_item_invoke_bbox(SP_ITEM(text), &bbox, sp_item_i2doc_affine(SP_ITEM(text)), TRUE);
- NR::Point xy(bbox.x0, bbox.y0);
+ Geom::Point xy(bbox.x0, bbox.y0);
// make a list of textpath children
GSList *tp_reprs = NULL;
// set x/y on text
/* fixme: Yuck, is this really the right test? */
- if (xy[NR::X] != 1e18 && xy[NR::Y] != 1e18) {
- sp_repr_set_svg_double(SP_OBJECT_REPR(text), "x", xy[NR::X]);
- sp_repr_set_svg_double(SP_OBJECT_REPR(text), "y", xy[NR::Y]);
+ if (xy[Geom::X] != 1e18 && xy[Geom::Y] != 1e18) {
+ sp_repr_set_svg_double(SP_OBJECT_REPR(text), "x", xy[Geom::X]);
+ sp_repr_set_svg_double(SP_OBJECT_REPR(text), "y", xy[Geom::Y]);
}
}
index b2188c0d5e0d220f6c415a75c65e71ccfd3e329f..914e416b3f77c357cc4db36a8098115fe2c5af98 100644 (file)
--- a/src/sp-use-reference.cpp
+++ b/src/sp-use-reference.cpp
@@ -150,15 +150,15 @@ sp_usepath_move_compensate(Geom::Matrix const *mp, SPItem *original, SPUsePath *
// TODO kill naughty naughty #if 0
#if 0
- NR::Matrix m(*mp);
+ Geom::Matrix m(*mp);
if (!(m.is_translation())) {
return;
}
- NR::Matrix const t(item->transform);
- NR::Matrix clone_move = t.inverse() * m * t;
+ Geom::Matrix const t(item->transform);
+ Geom::Matrix clone_move = t.inverse() * m * t;
// Calculate the compensation matrix and the advertized movement matrix.
- NR::Matrix advertized_move;
+ Geom::Matrix advertized_move;
if (mode == SP_CLONE_COMPENSATION_PARALLEL) {
//clone_move = clone_move.inverse();
advertized_move.set_identity();
diff --git a/src/sp-use.cpp b/src/sp-use.cpp
index 134588e659c78071a68ec9859e01c71f75c9ca85..36372e67b4f3f8a5a0c7fadb0d98a6e994cb93b9 100644 (file)
--- a/src/sp-use.cpp
+++ b/src/sp-use.cpp
}
Geom::Translate t(use->x.computed,
use->y.computed);
- nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), NR::Matrix(t));
+ nr_arena_group_set_child_transform(NR_ARENA_GROUP(ai), Geom::Matrix(t));
}
return ai;
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index b41ad4b21b665506835625e39c45156ce8d6d0f3..c57c58a1421285bd6272023a6fb1932235321b11 100644 (file)
--- a/src/splivarot.cpp
+++ b/src/splivarot.cpp
@@ -452,7 +452,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
// adjust style properties that depend on a possible transform in the source object in order
// to get a correct style attribute for the new path
SPItem* item_source = SP_ITEM(source);
- NR::Matrix i2doc(sp_item_i2doc_affine(item_source));
+ Geom::Matrix i2doc(sp_item_i2doc_affine(item_source));
sp_item_adjust_stroke(item_source, i2doc.descrim());
sp_item_adjust_pattern(item_source, i2doc);
sp_item_adjust_gradient(item_source, i2doc);
@@ -485,7 +485,7 @@ sp_selected_path_boolop(SPDesktop *desktop, bool_op bop, const unsigned int verb
// premultiply by the inverse of parent's repr
SPItem *parent_item = SP_ITEM(sp_desktop_document(desktop)->getObjectByRepr(parent));
- NR::Matrix local (sp_item_i2doc_affine(parent_item));
+ Geom::Matrix local (sp_item_i2doc_affine(parent_item));
gchar *transform = sp_svg_transform_write(local.inverse());
// now that we have the result, add it on the canvas
sp_repr_css_unset_property(ncss, "marker-end");
}
- NR::Matrix const transform(item->transform);
+ Geom::Matrix const transform(item->transform);
float const scale = transform.descrim();
gchar const *mask = SP_OBJECT_REPR(item)->attribute("mask");
gchar const *clip_path = SP_OBJECT_REPR(item)->attribute("clip-path");
@@ -1048,7 +1048,7 @@ sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool updat
return;
}
- NR::Matrix const transform(item->transform);
+ Geom::Matrix const transform(item->transform);
sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity());
@@ -1273,7 +1273,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
continue;
}
- NR::Matrix const transform(item->transform);
+ Geom::Matrix const transform(item->transform);
sp_item_write_transform(item, SP_OBJECT_REPR(item), Geom::identity());
size /= sp_item_i2doc_affine(item).descrim();
// save the transform, to re-apply it after simplification
- NR::Matrix const transform(item->transform);
+ Geom::Matrix const transform(item->transform);
/*
reset the transform, effectively transforming the item by transform.inverse();
return curve; // do not forget to unref the curve at some point!
}
-boost::optional<Path::cut_position> get_nearest_position_on_Path(Path *path, NR::Point p, unsigned seg)
+boost::optional<Path::cut_position> get_nearest_position_on_Path(Path *path, Geom::Point p, unsigned seg)
{
//get nearest position on path
Path::cut_position pos = path->PointToCurvilignPosition(p, seg);
return pos;
}
-NR::Point get_point_on_Path(Path *path, int piece, double t)
+Geom::Point get_point_on_Path(Path *path, int piece, double t)
{
- NR::Point p;
+ Geom::Point p;
path->PointAt(piece, t, p);
return p;
}
diff --git a/src/splivarot.h b/src/splivarot.h
index a4fe588ed2b0e7eefb9c7ff8dce386e51788bc5a..dce31a1ad6eb1f7454a97d4f6111f185baa43568 100644 (file)
--- a/src/splivarot.h
+++ b/src/splivarot.h
Path *Path_for_item(SPItem *item, bool doTransformation, bool transformFull = true);
Geom::PathVector* pathvector_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull, Geom::Matrix extraPreAffine, Geom::Matrix extraPostAffine);
SPCurve *curve_for_item(SPItem *item);
-boost::optional<Path::cut_position> get_nearest_position_on_Path(Path *path, NR::Point p, unsigned seg = 0);
-NR::Point get_point_on_Path(Path *path, int piece, double t);
+boost::optional<Path::cut_position> get_nearest_position_on_Path(Path *path, Geom::Point p, unsigned seg = 0);
+Geom::Point get_point_on_Path(Path *path, int piece, double t);
#endif
diff --git a/src/text-chemistry.cpp b/src/text-chemistry.cpp
index 0eeac8c4f7c3008a9471f2a3e1cd0651703d1d42..f1348ad670c1393efd6c8cf1d47a6c4d2141aa1b 100644 (file)
--- a/src/text-chemistry.cpp
+++ b/src/text-chemistry.cpp
NRRect bbox;
sp_item_invoke_bbox(SP_ITEM(flowtext), &bbox, sp_item_i2doc_affine(SP_ITEM(flowtext)), TRUE);
- NR::Point xy(bbox.x0, bbox.y0);
- if (xy[NR::X] != 1e18 && xy[NR::Y] != 1e18) {
- sp_repr_set_svg_double(rtext, "x", xy[NR::X]);
- sp_repr_set_svg_double(rtext, "y", xy[NR::Y]);
+ Geom::Point xy(bbox.x0, bbox.y0);
+ if (xy[Geom::X] != 1e18 && xy[Geom::Y] != 1e18) {
+ sp_repr_set_svg_double(rtext, "x", xy[Geom::X]);
+ sp_repr_set_svg_double(rtext, "y", xy[Geom::Y]);
}
/* Create <tspan> */
diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp
index 33e4ea3a14c4fda57d0320128dcdcb880105e778..c8937bdd82c2e8adbbd2d110facae9036ae05afc 100644 (file)
--- a/src/trace/trace.cpp
+++ b/src/trace/trace.cpp
{
//Get absolute X,Y position
double xpos = ((double)aImg->bbox.x0) + iwscale * (double)col;
- NR::Point point(xpos, ypos);
+ Geom::Point point(xpos, ypos);
point *= *aImg->transform;
//point *= imgMat;
//point = desktop->doc2dt(point);
Geom::Scale scal(iwscale, ihscale);
//# Convolve scale, translation, and the original transform
- NR::Matrix tf(scal * trans);
+ Geom::Matrix tf(scal * trans);
tf *= img->transform;
index 5e9b44ff675081d51b1f62c74aad33566cce0574..827074016aab8cf93008420a343334c0a7dacf49 100644 (file)
void
EditWidget::onWindowRealize()
{
+
if ( (sp_document_width(_desktop->doc()) < 1.0) || (sp_document_height(_desktop->doc()) < 1.0) ) {
return;
}