From 06aecef405c4cf6f7551ab622c3040562cb62c78 Mon Sep 17 00:00:00 2001 From: verbalshadow Date: Sun, 28 Dec 2008 22:44:35 +0000 Subject: [PATCH] More NR ==> Geom changes --- src/display/nr-filter-image.cpp | 8 +- src/dyna-draw-context.cpp | 4 +- src/gradient-drag.cpp | 26 +-- src/graphlayout/graphlayout.cpp | 6 +- src/interface.cpp | 12 +- src/knot-holder-entity.cpp | 20 +- src/knot.cpp | 2 +- src/libnrtype/Layout-TNG-OutIter.cpp | 8 +- src/libnrtype/Layout-TNG-Output.cpp | 10 +- src/livarot/Path.cpp | 232 +++++++++--------- src/livarot/Path.h | 128 +++++----- src/livarot/PathConversion.cpp | 268 ++++++++++----------- src/livarot/PathCutting.cpp | 128 +++++----- src/livarot/PathOutline.cpp | 204 ++++++++-------- src/livarot/PathSimplify.cpp | 338 +++++++++++++-------------- src/livarot/PathStroke.cpp | 122 +++++----- src/livarot/Shape.cpp | 62 ++--- src/livarot/Shape.h | 34 +-- src/livarot/ShapeMisc.cpp | 44 ++-- src/livarot/ShapeRaster.cpp | 6 +- src/livarot/ShapeSweep.cpp | 52 ++--- src/livarot/path-description.cpp | 60 ++--- src/livarot/path-description.h | 58 ++--- src/livarot/sweep-event-queue.h | 8 +- src/livarot/sweep-event.cpp | 12 +- src/livarot/sweep-event.h | 4 +- src/livarot/sweep-tree.cpp | 20 +- src/livarot/sweep-tree.h | 4 +- src/lpe-tool-context.cpp | 6 +- src/main.cpp | 8 +- src/marker.cpp | 4 +- src/node-context.cpp | 16 +- src/object-edit.cpp | 62 ++--- src/pen-context.cpp | 16 +- src/selcue.cpp | 2 +- src/select-context.cpp | 24 +- src/selection-chemistry.cpp | 28 +-- src/sp-conn-end.cpp | 2 +- src/sp-image.cpp | 16 +- src/sp-item-group.cpp | 4 +- src/sp-root.cpp | 4 +- src/sp-shape.cpp | 8 +- src/sp-symbol.cpp | 4 +- src/sp-tspan.cpp | 8 +- src/sp-use-reference.cpp | 8 +- src/sp-use.cpp | 2 +- src/splivarot.cpp | 18 +- src/splivarot.h | 4 +- src/text-chemistry.cpp | 8 +- src/trace/trace.cpp | 4 +- src/ui/view/edit-widget.cpp | 1 + 51 files changed, 1069 insertions(+), 1068 deletions(-) diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp index 517f2dac9..978ecc6af 100644 --- a/src/display/nr-filter-image.cpp +++ b/src/display/nr-filter-image.cpp @@ -65,10 +65,10 @@ int FilterImage::render(FilterSlot &slot, FilterUnits const &units) { 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); diff --git a/src/dyna-draw-context.cpp b/src/dyna-draw-context.cpp index 257e6f7dc..bd4f82096 100644 --- a/src/dyna-draw-context.cpp +++ b/src/dyna-draw-context.cpp @@ -403,7 +403,7 @@ sp_dyna_draw_apply(SPDynaDrawContext *dc, Geom::Point p) // 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; @@ -672,7 +672,7 @@ sp_dyna_draw_context_root_handler(SPEventContext *event_context, ) { // 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 08be1a849..a24f45c84 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -298,7 +298,7 @@ GrDrag::addStopNearPoint (SPItem *item, Geom::Point mouse_p, double tolerance) 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); @@ -309,7 +309,7 @@ GrDrag::addStopNearPoint (SPItem *item, Geom::Point mouse_p, double tolerance) 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; @@ -319,7 +319,7 @@ GrDrag::addStopNearPoint (SPItem *item, Geom::Point mouse_p, double tolerance) 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; @@ -364,7 +364,7 @@ GrDrag::dropColor(SPItem */*item*/, gchar *c, Geom::Point p) 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"); @@ -385,7 +385,7 @@ GrDrag::dropColor(SPItem */*item*/, gchar *c, Geom::Point p) 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; } } @@ -1452,7 +1452,7 @@ GrDrag::selectByCoords(std::vector coords) 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); } } @@ -1563,7 +1563,7 @@ GrDrag::addDragger (GrDraggable *draggable) 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(); diff --git a/src/graphlayout/graphlayout.cpp b/src/graphlayout/graphlayout.cpp index 12bca8891..cd1683c34 100644 --- a/src/graphlayout/graphlayout.cpp +++ b/src/graphlayout/graphlayout.cpp @@ -66,9 +66,9 @@ struct CheckProgress : TestConvergence { 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 fbdb8a5f6..2242e6224 100644 --- a/src/interface.cpp +++ b/src/interface.cpp @@ -1146,9 +1146,9 @@ sp_ui_drag_data_received(GtkWidget *widget, 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}; @@ -1190,8 +1190,8 @@ sp_ui_drag_data_received(GtkWidget *widget, boost::optional 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 = @@ -1202,7 +1202,7 @@ sp_ui_drag_data_received(GtkWidget *widget, : 0.0) + prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100); - if (NR::L2 (delta) < stroke_tolerance) { + if (Geom::L2 (delta) < stroke_tolerance) { fillnotstroke = false; } } diff --git a/src/knot-holder-entity.cpp b/src/knot-holder-entity.cpp index f6c82582b..36a072c44 100644 --- a/src/knot-holder-entity.cpp +++ b/src/knot-holder-entity.cpp @@ -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 741199098..cf1a3e944 100644 --- 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); diff --git a/src/libnrtype/Layout-TNG-OutIter.cpp b/src/libnrtype/Layout-TNG-OutIter.cpp index bbd4aa6fd..8dd61c491 100644 --- a/src/libnrtype/Layout-TNG-OutIter.cpp +++ b/src/libnrtype/Layout-TNG-OutIter.cpp @@ -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_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_fitted)->PointAndTangentAt(midpoint_otp[0].piece, midpoint_otp[0].t, midpoint, tangent); @@ -415,8 +415,8 @@ void Layout::queryCursorShape(iterator const &it, Geom::Point &position, double } g_free(path_parameter_list); - NR::Point point; - NR::Point tangent; + Geom::Point point; + Geom::Point tangent; const_cast(_path_fitted)->PointAndTangentAt(path_parameter.piece, path_parameter.t, point, tangent); if (x < 0.0) point += x * tangent; diff --git a/src/libnrtype/Layout-TNG-Output.cpp b/src/libnrtype/Layout-TNG-Output.cpp index 49967cd59..2003ca26b 100644 --- a/src/libnrtype/Layout-TNG-Output.cpp +++ b/src/libnrtype/Layout-TNG-Output.cpp @@ -436,8 +436,8 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path) int unused = 0; Path::cut_position *point_otp = const_cast(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).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]); @@ -477,8 +477,8 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path) // as far as I know these functions are const, they're just not marked as such Path::cut_position *midpoint_otp = const_cast(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).PointAndTangentAt(midpoint_otp[0].piece, midpoint_otp[0].t, midpoint, tangent); if (start_offset >= 0.0 && end_offset >= 0.0) { @@ -497,7 +497,7 @@ void Layout::fitToPathAlign(SVGLength const &startOffset, Path const &path) } 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).PointAt(start_otp[0].piece, start_otp[0].t, startpoint); const_cast(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 bc62e817e..66ec87274 100644 --- a/src/livarot/Path.cpp +++ b/src/livarot/Path.cpp @@ -135,7 +135,7 @@ int Path::Close() 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); @@ -151,7 +151,7 @@ int Path::MoveTo(NR::Point const &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; @@ -165,7 +165,7 @@ void Path::InsertMoveTo(NR::Point const &iPt, int at) 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); @@ -178,7 +178,7 @@ int Path::LineTo(NR::Point const &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; @@ -192,7 +192,7 @@ void Path::InsertLineTo(NR::Point const &iPt, int at) 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; @@ -220,7 +220,7 @@ void Path::InsertCubicTo(NR::Point const &iPt, NR::Point const &iStD, NR::Point 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) { @@ -235,7 +235,7 @@ int Path::ArcTo(NR::Point const &iPt, double iRx, double iRy, double angle, } -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()) ) { @@ -262,7 +262,7 @@ int Path::TempBezierTo() } 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; @@ -293,7 +293,7 @@ int Path::EndBezierTo() 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); @@ -313,7 +313,7 @@ int Path::EndBezierTo(NR::Point const &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); @@ -331,7 +331,7 @@ int Path::IntermBezierTo(NR::Point const &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; @@ -346,7 +346,7 @@ void Path::InsertIntermBezierTo(NR::Point const &iPt, int at) } -int Path::BezierTo(NR::Point const &iPt) +int Path::BezierTo(Geom::Point const &iPt) { if ( descr_flags & descr_adding_bezier ) { EndBezierTo(iPt); @@ -365,7 +365,7 @@ int Path::BezierTo(NR::Point const &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; @@ -412,7 +412,7 @@ void Path::ResetPoints() } -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); @@ -428,7 +428,7 @@ int Path::AddPoint(NR::Point const &iPt, bool mvto) } -int Path::ReplacePoint(NR::Point const &iPt) +int Path::ReplacePoint(Geom::Point const &iPt) { if (pts.empty()) { return -1; @@ -440,7 +440,7 @@ int Path::ReplacePoint(NR::Point const &iPt) } -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); @@ -455,7 +455,7 @@ int Path::AddPoint(NR::Point const &iPt, int ip, double it, bool 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); @@ -471,7 +471,7 @@ int Path::AddForcedPoint(NR::Point const &iPt) } -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) { @@ -495,15 +495,15 @@ void Path::PolylineBoundingBox(double &l, double &t, double &r, double &b) } std::vector::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]); } } @@ -514,18 +514,18 @@ void Path::PolylineBoundingBox(double &l, double &t, double &r, double &b) * \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; @@ -575,7 +575,7 @@ void Path::PointAt(int piece, double at, NR::Point &pos) } 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(descr_cmd[bez_st + 1]); TangentOnBezAt(at, bStPt, *nData, *stB, false, pos, tgt, len, rad); @@ -589,13 +589,13 @@ void Path::PointAt(int piece, double at, NR::Point &pos) } else if (k == stB->nb) { PathDescrIntermBezierTo *nextI = dynamic_cast(descr_cmd[bez_st + k]); PathDescrIntermBezierTo *prevI = dynamic_cast(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(descr_cmd[bez_st + k]); PathDescrIntermBezierTo *prevI = dynamic_cast(descr_cmd[bez_st + k - 1]); PathDescrIntermBezierTo *nnextI = dynamic_cast(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); } @@ -604,11 +604,11 @@ void Path::PointAt(int piece, double at, NR::Point &pos) } -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(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(descr_cmd[bez_st + k - 1]); PathDescrIntermBezierTo *nextI = dynamic_cast(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(descr_cmd[bez_st + k - 1]); PathDescrIntermBezierTo *nextI = dynamic_cast(descr_cmd[bez_st + k]); PathDescrIntermBezierTo *nnextI = dynamic_cast(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::iterator i = descr_cmd.begin(); i != descr_cmd.end(); i++) { (*i)->transform(trans); @@ -711,7 +711,7 @@ void Path::FastBBox(double &l,double &t,double &r,double &b) { 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(); @@ -720,21 +720,21 @@ void Path::FastBBox(double &l,double &t,double &r,double &b) { PathDescrLineTo *nData = dynamic_cast(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; @@ -745,21 +745,21 @@ void Path::FastBBox(double &l,double &t,double &r,double &b) { PathDescrMoveTo *nData = dynamic_cast(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; @@ -770,21 +770,21 @@ void Path::FastBBox(double &l,double &t,double &r,double &b) { PathDescrArcTo *nData = dynamic_cast(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; @@ -795,21 +795,21 @@ void Path::FastBBox(double &l,double &t,double &r,double &b) { PathDescrCubicTo *nData = dynamic_cast(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]; } } @@ -821,32 +821,32 @@ bezier-paths used by True-Type fonts." */ #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 @@ -858,21 +858,21 @@ bezier-paths used by True-Type fonts." { PathDescrBezierTo *nData = dynamic_cast(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; @@ -883,21 +883,21 @@ bezier-paths used by True-Type fonts." { PathDescrIntermBezierTo *nData = dynamic_cast(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]; } } } @@ -911,7 +911,7 @@ char *Path::svg_dump_path() const 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 4887883c8..b478449cd 100644 --- a/src/livarot/Path.h +++ b/src/livarot/Path.h @@ -76,11 +76,11 @@ public: // 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; }; @@ -99,15 +99,15 @@ public: // 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) @@ -120,11 +120,11 @@ public: // 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 @@ -163,12 +163,12 @@ public: // 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 @@ -182,7 +182,7 @@ public: 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 @@ -206,7 +206,7 @@ public: 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); @@ -223,13 +223,13 @@ public: // 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 @@ -237,17 +237,17 @@ public: // 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 @@ -258,21 +258,21 @@ public: 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 { @@ -316,24 +316,24 @@ public: 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 const &cmd, int curD, NR::Point const &curX); + static bool IsNulCurve (std::vector const &cmd, int curD, Geom::Point const &curX); static void RecStdCubicTo (outline_callback_data * data, double tol, double width, int lev); @@ -347,26 +347,26 @@ public: // 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); @@ -382,7 +382,7 @@ public: }; 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: diff --git a/src/livarot/PathConversion.cpp b/src/livarot/PathConversion.cpp index 4ae4afe86..6ac6717af 100644 --- a/src/livarot/PathConversion.cpp +++ b/src/livarot/PathConversion.cpp @@ -35,7 +35,7 @@ void Path::ConvertWithBackData(double treshhold) return; } - NR::Point curX; + Geom::Point curX; int curP = 1; int lastMoveTo = -1; @@ -46,7 +46,7 @@ void Path::ConvertWithBackData(double treshhold) curX = dynamic_cast(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); } @@ -55,7 +55,7 @@ void Path::ConvertWithBackData(double treshhold) while ( curP < int(descr_cmd.size()) ) { int const nType = descr_cmd[curP]->getType(); - NR::Point nextX; + Geom::Point nextX; switch (nType) { case descr_forced: { @@ -118,9 +118,9 @@ void Path::ConvertWithBackData(double treshhold) PathDescrIntermBezierTo *nData = dynamic_cast(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++; @@ -136,14 +136,14 @@ void Path::ConvertWithBackData(double treshhold) ip++; nData = dynamic_cast(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); } @@ -155,7 +155,7 @@ void Path::ConvertWithBackData(double treshhold) dx = nextX; dx = 2 * dx - cx; - NR::Point stx; + Geom::Point stx; stx = (bx + cx) / 2; if ( nbInterm > 1 ) { @@ -163,7 +163,7 @@ void Path::ConvertWithBackData(double treshhold) } { - NR::Point mx; + Geom::Point mx; mx = (cx + dx) / 2; RecBezierTo(cx, stx, mx, treshhold, 8, 0.0, 1.0, curP + nbInterm - 1); } @@ -200,7 +200,7 @@ void Path::Convert(double treshhold) return; } - NR::Point curX; + Geom::Point curX; int curP = 1; int lastMoveTo = 0; @@ -221,7 +221,7 @@ void Path::Convert(double treshhold) while ( curP < int(descr_cmd.size()) ) { int const nType = descr_cmd[curP]->getType(); - NR::Point nextX; + Geom::Point nextX; switch (nType) { case descr_forced: { @@ -316,12 +316,12 @@ void Path::Convert(double treshhold) PathDescrIntermBezierTo *nData = dynamic_cast(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++; @@ -337,7 +337,7 @@ void Path::Convert(double treshhold) ip++; nData = dynamic_cast(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 ) { @@ -350,7 +350,7 @@ void Path::Convert(double treshhold) } { - NR::Point const mx = (cx + dx) / 2; + Geom::Point const mx = (cx + dx) / 2; RecBezierTo(cx, stx, mx, treshhold, 8); } } @@ -362,7 +362,7 @@ void Path::Convert(double treshhold) 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 ) { @@ -374,7 +374,7 @@ void Path::Convert(double treshhold) } { - NR::Point mx = (cx + dx) / 2; + Geom::Point mx = (cx + dx) / 2; RecBezierTo(cx, stx, mx, treshhold, 8); } } @@ -417,7 +417,7 @@ void Path::Convert(NRRectL *area, double treshhold) return; } - NR::Point curX; + Geom::Point curX; int curP = 1; int lastMoveTo = 0; short last_point_relation = 0; @@ -445,7 +445,7 @@ void Path::Convert(NRRectL *area, double treshhold) while ( curP < int(descr_cmd.size()) ) { int const nType = descr_cmd[curP]->getType(); - NR::Point nextX; + Geom::Point nextX; switch (nType) { case descr_forced: { @@ -586,12 +586,12 @@ void Path::Convert(NRRectL *area, double treshhold) PathDescrIntermBezierTo *nData = dynamic_cast(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++; @@ -607,7 +607,7 @@ void Path::Convert(NRRectL *area, double treshhold) ip++; nData = dynamic_cast(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 ) { @@ -620,7 +620,7 @@ void Path::Convert(NRRectL *area, double treshhold) } { - NR::Point const mx = (cx + dx) / 2; + Geom::Point const mx = (cx + dx) / 2; RecBezierTo(cx, stx, mx, treshhold, 8); } } @@ -632,7 +632,7 @@ void Path::Convert(NRRectL *area, double treshhold) 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 ) { @@ -644,7 +644,7 @@ void Path::Convert(NRRectL *area, double treshhold) } { - NR::Point mx = (cx + dx) / 2; + Geom::Point mx = (cx + dx) / 2; RecBezierTo(cx, stx, mx, treshhold, 8); } } @@ -687,7 +687,7 @@ void Path::ConvertEvenLines(double treshhold) return; } - NR::Point curX; + Geom::Point curX; int curP = 1; int lastMoveTo = 0; @@ -708,7 +708,7 @@ void Path::ConvertEvenLines(double treshhold) while ( curP < int(descr_cmd.size()) ) { int const nType = descr_cmd[curP]->getType(); - NR::Point nextX; + Geom::Point nextX; switch (nType) { case descr_forced: { @@ -731,12 +731,12 @@ void Path::ConvertEvenLines(double treshhold) 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); @@ -760,11 +760,11 @@ void Path::ConvertEvenLines(double treshhold) case descr_lineto: { PathDescrLineTo* nData = dynamic_cast(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); } } @@ -828,12 +828,12 @@ void Path::ConvertEvenLines(double treshhold) PathDescrIntermBezierTo *nData = dynamic_cast(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++; @@ -849,7 +849,7 @@ void Path::ConvertEvenLines(double treshhold) ip++; nData = dynamic_cast(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 ) { @@ -862,7 +862,7 @@ void Path::ConvertEvenLines(double treshhold) } { - NR::Point const mx = (cx + dx) / 2; + Geom::Point const mx = (cx + dx) / 2; RecBezierTo(cx, stx, mx, treshhold, 8, 4 * treshhold); } } @@ -874,7 +874,7 @@ void Path::ConvertEvenLines(double 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 ) { @@ -886,7 +886,7 @@ void Path::ConvertEvenLines(double treshhold) } { - NR::Point const mx = (cx + dx) / 2; + Geom::Point const mx = (cx + dx) / 2; RecBezierTo(cx, stx, mx, treshhold, 8, 4 * treshhold); } } @@ -912,7 +912,7 @@ void Path::ConvertEvenLines(double 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. */ @@ -944,64 +944,64 @@ const NR::Point Path::PrevPoint(int i) const 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 ) { @@ -1073,7 +1073,7 @@ static void ArcAnglesAndCenter(NR::Point const &iS, NR::Point const &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*/) { @@ -1088,7 +1088,7 @@ void Path::DoArc(NR::Point const &iS, NR::Point const &iE, 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 @@ -1123,12 +1123,12 @@ void Path::DoArc(NR::Point const &iS, NR::Point const &iE, } -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); @@ -1146,11 +1146,11 @@ void Path::RecCubicTo( NR::Point const &iS, NR::Point const &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); @@ -1165,11 +1165,11 @@ void Path::RecCubicTo( NR::Point const &iS, NR::Point const &isD, } { - 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); @@ -1179,24 +1179,24 @@ void Path::RecCubicTo( NR::Point const &iS, NR::Point const &isD, -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); @@ -1206,8 +1206,8 @@ void Path::RecBezierTo(const NR::Point &iP, } { - 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); @@ -1216,7 +1216,7 @@ void Path::RecBezierTo(const NR::Point &iP, } -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) { @@ -1231,7 +1231,7 @@ void Path::DoArc(NR::Point const &iS, NR::Point const &iE, 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 @@ -1265,12 +1265,12 @@ void Path::DoArc(NR::Point const &iS, NR::Point const &iE, } } -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); @@ -1289,12 +1289,12 @@ void Path::RecCubicTo(NR::Point const &iS, NR::Point const &isD, 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); @@ -1304,17 +1304,17 @@ void Path::RecCubicTo(NR::Point const &iS, NR::Point const &isD, -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; @@ -1322,7 +1322,7 @@ void Path::RecBezierTo(NR::Point const &iP, { 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); @@ -1331,7 +1331,7 @@ void Path::RecBezierTo(NR::Point const &iP, -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*/) @@ -1349,7 +1349,7 @@ void Path::DoArc(NR::Point const &iS, NR::Point const &iE, 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 @@ -1383,13 +1383,13 @@ void Path::DoArc(NR::Point const &iS, NR::Point const &iE, } -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); @@ -1413,16 +1413,16 @@ void Path::RecCubicTo(NR::Point const &iS, NR::Point const &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; @@ -1451,11 +1451,11 @@ void Path::RecCubicTo(NR::Point const &iS, NR::Point const &isD, } { - 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); @@ -1465,7 +1465,7 @@ void Path::RecCubicTo(NR::Point const &iS, NR::Point const &isD, -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); diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp index 025cf00a7..4a5aec0f5 100644 --- a/src/livarot/PathCutting.cpp +++ b/src/livarot/PathCutting.cpp @@ -96,12 +96,12 @@ void Path::DashSubPath(int spL, int spP, std::vector 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 0.0001 ) { totLength+=nl; lastP=n; @@ -118,7 +118,7 @@ void Path::DashSubPath(int spL, int spP, std::vector const &orig_pt int lastPiece=-1; lastP = orig_pts[spP].p; for (int i=1;i 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 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 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 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 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; @@ -273,7 +273,7 @@ Path::MakePathVector() 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;igetType(); @@ -354,7 +354,7 @@ Path::MakePathVector() { if ( bezNb > 0 ) { PathDescrIntermBezierTo *nData = dynamic_cast(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(descr_cmd[i+1]); p_e=0.5*(p_m+iData->p); @@ -362,7 +362,7 @@ Path::MakePathVector() 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]; @@ -482,13 +482,13 @@ double Path::Length() return 0; } - NR::Point lastP = pts[0].p; + Geom::Point lastP = pts[0].p; double len = 0; for (std::vector::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; @@ -504,8 +504,8 @@ double Path::Surface() 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::const_iterator i = pts.begin(); i != pts.end(); i++) { @@ -743,11 +743,11 @@ void Path::ConvertForcedToVoid() 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::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; @@ -948,7 +948,7 @@ hence the Path-esque coding style" */ template 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]); } } @@ -1040,10 +1040,10 @@ double Path::PositionToLength(int piece, double t) 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; } @@ -1055,7 +1055,7 @@ void Path::ConvertPositionsToForced(int nbPos, cut_position *poss) } { - 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 ) { @@ -1070,7 +1070,7 @@ void Path::ConvertPositionsToForced(int nbPos, cut_position *poss) 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 ) { @@ -1087,7 +1087,7 @@ void Path::ConvertPositionsToForced(int nbPos, cut_position *poss) case descr_bezierto: { PathDescrBezierTo *nData = dynamic_cast(descr_cmd[i]); - NR::Point theP = nData->p; + Geom::Point theP = nData->p; if ( nData->nb == 0 ) { lastPos = theP; } @@ -1144,13 +1144,13 @@ void Path::ConvertPositionsToForced(int nbPos, cut_position *poss) // 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(descr_cmd[cp]); stD=oData->start; @@ -1179,7 +1179,7 @@ void Path::ConvertPositionsToForced(int nbPos, cut_position *poss) } } } else if ( typ == descr_lineto ) { - NR::Point endP; + Geom::Point endP; { PathDescrLineTo *oData = dynamic_cast(descr_cmd[cp]); endP=oData->p; @@ -1203,7 +1203,7 @@ void Path::ConvertPositionsToForced(int nbPos, cut_position *poss) } } } else if ( typ == descr_arcto ) { - NR::Point endP; + Geom::Point endP; double rx,ry,angle; bool clockw,large; double delta=0; @@ -1265,17 +1265,17 @@ void Path::ConvertPositionsToForced(int nbPos, cut_position *poss) PathDescrBezierTo theBD=*(dynamic_cast(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(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); @@ -1301,7 +1301,7 @@ void Path::ConvertPositionsToForced(int nbPos, cut_position *poss) } else { // decouper puis repasser if ( cp > theBDI ) { - NR::Point pcP,ncP; + Geom::Point pcP,ncP; { PathDescrIntermBezierTo *nData = dynamic_cast(descr_cmd[cp]); pcP=nData->p; @@ -1310,7 +1310,7 @@ void Path::ConvertPositionsToForced(int nbPos, cut_position *poss) PathDescrIntermBezierTo *nData = dynamic_cast(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); { @@ -1328,7 +1328,7 @@ void Path::ConvertPositionsToForced(int nbPos, cut_position *poss) } curP--; } else { - NR::Point pcP,ncP; + Geom::Point pcP,ncP; { PathDescrIntermBezierTo *nData = dynamic_cast(descr_cmd[cp+1]); pcP=nData->p; @@ -1337,7 +1337,7 @@ void Path::ConvertPositionsToForced(int nbPos, cut_position *poss) PathDescrIntermBezierTo *nData = dynamic_cast(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); { @@ -1374,16 +1374,16 @@ void Path::ConvertPositionsToMoveTo(int nbPos,cut_position* poss) Path* res=new Path; - NR::Point lastP(0,0); + Geom::Point lastP(0,0); for (int i=0;igetType(); if ( typ == descr_moveto ) { - NR::Point np; + Geom::Point np; { PathDescrMoveTo *nData = dynamic_cast(descr_cmd[i]); np=nData->p; } - NR::Point endP; + Geom::Point endP; bool hasClose=false; int hasForced=-1; bool doesClose=false; @@ -1419,9 +1419,9 @@ void Path::ConvertPositionsToMoveTo(int nbPos,cut_position* poss) 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 ) { diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp index 67b5370f2..cd405d664 100644 --- a/src/livarot/PathOutline.cpp +++ b/src/livarot/PathOutline.cpp @@ -41,8 +41,8 @@ void Path::Outline(Path *dest, double width, JoinType join, ButtType butt, doubl 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; @@ -73,8 +73,8 @@ void Path::Outline(Path *dest, double width, JoinType join, ButtType butt, doubl // 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(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) { @@ -214,7 +214,7 @@ Path::OutsideOutline (Path * dest, double width, JoinType join, ButtType butt, dest->SetBackData (false); outline_callbacks calls; - NR::Point endButt, endPos; + Geom::Point endButt, endPos; calls.cubicto = StdCubicTo; calls.bezierto = StdBezierTo; calls.arcto = StdArcTo; @@ -239,7 +239,7 @@ Path::InsideOutline (Path * dest, double width, JoinType join, ButtType butt, dest->SetBackData (false); outline_callbacks calls; - NR::Point endButt, endPos; + Geom::Point endButt, endPos; calls.cubicto = StdCubicTo; calls.bezierto = StdBezierTo; calls.arcto = StdArcTo; @@ -260,8 +260,8 @@ Path::InsideOutline (Path * dest, double width, JoinType join, ButtType butt, // 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); @@ -282,8 +282,8 @@ Path::InsideOutline (Path * dest, double width, JoinType join, ButtType butt, } else if (typ == descr_cubicto) { PathDescrCubicTo *nData = dynamic_cast(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--; @@ -343,7 +343,7 @@ void Path::SubContractOutline(int off, int num_pd, 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; @@ -352,7 +352,7 @@ void Path::SubContractOutline(int off, int num_pd, int curP = 1; // le moveto - NR::Point curX; + Geom::Point curX; { int firstTyp = descr_cmd[off]->getType(); if ( firstTyp != descr_moveto ) { @@ -363,19 +363,19 @@ void Path::SubContractOutline(int off, int num_pd, 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++; @@ -402,7 +402,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure { - NR::Point pos; + Geom::Point pos; pos = curX; OutlineJoin (dest, pos, curT, stNor, width, join, miter); @@ -411,7 +411,7 @@ void Path::SubContractOutline(int off, int num_pd, // jointure { - NR::Point pos; + Geom::Point pos; pos = firstP; OutlineJoin (dest, enPos, enNor, firstT, width, join, miter); @@ -496,7 +496,7 @@ void Path::SubContractOutline(int off, int num_pd, else { // jointure - NR::Point pos; + Geom::Point pos; pos = curX; OutlineJoin (dest, pos, curT, stNor, width, join, miter); } @@ -546,7 +546,7 @@ void Path::SubContractOutline(int off, int num_pd, else { // jointure - NR::Point pos; + Geom::Point pos; pos = curX; OutlineJoin (dest, pos, curT, stNor, width, join, miter); } @@ -602,7 +602,7 @@ void Path::SubContractOutline(int off, int num_pd, else { // jointure - NR::Point pos; + Geom::Point pos; pos = curX; OutlineJoin (dest, pos, curT, stNor, width, join, miter); } @@ -660,7 +660,7 @@ void Path::SubContractOutline(int off, int num_pd, } 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); } @@ -671,7 +671,7 @@ void Path::SubContractOutline(int off, int num_pd, 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); @@ -691,7 +691,7 @@ void Path::SubContractOutline(int off, int num_pd, } else dest->MoveTo (curX+width*stNor); } else { // jointure - NR::Point pos; + Geom::Point pos; pos = curX; OutlineJoin (dest, pos, curT, stNor, width, join, miter); } @@ -708,9 +708,9 @@ void Path::SubContractOutline(int off, int num_pd, (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); @@ -729,7 +729,7 @@ void Path::SubContractOutline(int off, int num_pd, } 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); } @@ -744,7 +744,7 @@ void Path::SubContractOutline(int off, int num_pd, dx = nData->p; ip++; nData = dynamic_cast(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); @@ -773,7 +773,7 @@ void Path::SubContractOutline(int off, int num_pd, 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); @@ -822,7 +822,7 @@ void Path::SubContractOutline(int off, int num_pd, // like the name says: check whether the path command is actually more than a dumb point. bool -Path::IsNulCurve (std::vector const &cmd, int curD, NR::Point const &curX) +Path::IsNulCurve (std::vector const &cmd, int curD, Geom::Point const &curX) { switch(cmd[curD]->getType()) { case descr_lineto: @@ -836,9 +836,9 @@ Path::IsNulCurve (std::vector const &cmd, int curD, NR::Point const case descr_cubicto: { PathDescrCubicTo *nData = dynamic_cast(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 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. @@ -1164,7 +1164,7 @@ Path::TangentOnBezAt (double at, NR::Point const &iS, } 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); @@ -1250,17 +1250,17 @@ void 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, @@ -1380,17 +1380,17 @@ void 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, @@ -1414,7 +1414,7 @@ Path::RecStdArcTo (outline_callback_data * data, double tol, double width, 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); @@ -1439,16 +1439,16 @@ Path::RecStdArcTo (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 * 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) { diff --git a/src/livarot/PathSimplify.cpp b/src/livarot/PathSimplify.cpp index 5d6d918c7..0f440de24 100644 --- a/src/livarot/PathSimplify.cpp +++ b/src/livarot/PathSimplify.cpp @@ -70,23 +70,23 @@ void Path::Simplify(double treshhold) // 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 ) { @@ -116,24 +116,24 @@ double RecDistanceToCubic(NR::Point const &iS, NR::Point const &isD, } -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; } } @@ -163,9 +163,9 @@ void Path::DoSimplify(int off, int N, double treshhold) 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) { @@ -175,7 +175,7 @@ void Path::DoSimplify(int off, int N, double treshhold) // 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; @@ -246,13 +246,13 @@ void Path::DoSimplify(int off, int N, double treshhold) // 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]); @@ -267,7 +267,7 @@ bool Path::FitCubic(NR::Point const &start, PathDescrCubicTo &res, return false; } - NR::Matrix const iM = M.inverse(); + Geom::Matrix const iM = M.inverse(); M = iM; // phase 1: abcisses @@ -282,17 +282,17 @@ bool Path::FitCubic(NR::Point const &start, PathDescrCubicTo &res, } // 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++) { @@ -300,15 +300,15 @@ bool Path::FitCubic(NR::Point const &start, PathDescrCubicTo &res, } // 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); @@ -1184,15 +1184,15 @@ void Path::Coalesce(double tresh) 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(); @@ -1220,12 +1220,12 @@ void Path::Coalesce(double tresh) 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; } @@ -1238,7 +1238,7 @@ void Path::Coalesce(double tresh) } containsForced = false; - lastAddition = new PathDescrMoveTo(NR::Point(0, 0)); + lastAddition = new PathDescrMoveTo(Geom::Point(0, 0)); prevA = lastA = nextA; lastP = curP; lastAP = curP; @@ -1248,7 +1248,7 @@ void Path::Coalesce(double tresh) 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 @@ -1258,7 +1258,7 @@ void Path::Coalesce(double tresh) } 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; @@ -1271,12 +1271,12 @@ void Path::Coalesce(double tresh) 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; @@ -1308,7 +1308,7 @@ void Path::Coalesce(double tresh) 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; diff --git a/src/livarot/PathStroke.cpp b/src/livarot/PathStroke.cpp index cbd7bed5a..5e952eff7 100644 --- a/src/livarot/PathStroke.cpp +++ b/src/livarot/PathStroke.cpp @@ -20,19 +20,19 @@ */ // 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; } @@ -63,8 +63,8 @@ void Path::Stroke(Shape *dest, bool doClose, double width, JoinType join, } 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. @@ -75,10 +75,10 @@ void Path::Stroke(Shape *dest, bool doClose, double width, JoinType join, } } 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) { @@ -440,7 +440,7 @@ Path::DoLeftJoin (Shape * dest, double width, JoinType join, NR::Point pos, } 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); @@ -477,7 +477,7 @@ Path::DoLeftJoin (Shape * dest, double width, JoinType join, NR::Point pos, 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; @@ -503,7 +503,7 @@ Path::DoLeftJoin (Shape * dest, double width, JoinType join, NR::Point pos, { 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); @@ -529,9 +529,9 @@ Path::DoLeftJoin (Shape * dest, double width, JoinType join, NR::Point pos, } 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, @@ -552,12 +552,12 @@ Path::DoLeftJoin (Shape * dest, double width, JoinType join, NR::Point pos, } } 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) { @@ -588,7 +588,7 @@ Path::DoRightJoin (Shape * dest, double width, JoinType join, NR::Point pos, 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; @@ -614,7 +614,7 @@ Path::DoRightJoin (Shape * dest, double width, JoinType join, NR::Point pos, { 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); @@ -640,9 +640,9 @@ Path::DoRightJoin (Shape * dest, double width, JoinType join, NR::Point pos, } 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, @@ -662,7 +662,7 @@ Path::DoRightJoin (Shape * dest, double width, JoinType join, NR::Point pos, } else { - /* NR::Point biss; + /* Geom::Point biss; biss=next.x-prev.x; biss.y=next.y-prev.y; double c2=cross(next,biss); @@ -700,11 +700,11 @@ Path::DoRightJoin (Shape * dest, double width, JoinType join, NR::Point pos, // 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); @@ -730,13 +730,13 @@ void Path::RecRound(Shape *dest, int sNo, int eNo, // start and end index 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 d03940f2f..9107844be 100644 --- a/src/livarot/Shape.cpp +++ b/src/livarot/Shape.cpp @@ -309,7 +309,7 @@ Shape::Reset (int pointCount, int edgeCount) } int -Shape::AddPoint (const NR::Point x) +Shape::AddPoint (const Geom::Point x) { if (numberOfPoints() >= maxPt) { @@ -1134,7 +1134,7 @@ Shape::AddEdge (int st, int en) } 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; @@ -1209,7 +1209,7 @@ Shape::AddEdge (int st, int en, int leF, int riF) } 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; @@ -1552,7 +1552,7 @@ Shape::SortEdges (void) } 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; @@ -1671,7 +1671,7 @@ Shape::CmpToVert (NR::Point ax, NR::Point bx,bool as,bool bs) if (quadA > quadB) return -1; - NR::Point av, bv; + Geom::Point av, bv; av = ax; bv = bx; double si = cross (bv, av); @@ -1702,7 +1702,7 @@ Shape::SortEdgesList (edge_list * list, int s, int e) 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; @@ -2054,16 +2054,16 @@ Shape::CalcBBox (bool strict_degree) // 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; @@ -2094,7 +2094,7 @@ Shape::PtWinding (const NR::Point px) const 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) { @@ -2190,7 +2190,7 @@ bool directedEulerian(Shape const *s) * \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; @@ -2201,11 +2201,11 @@ double distance(Shape const *s, NR::Point const &p) ** 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; } @@ -2214,16 +2214,16 @@ double distance(Shape const *s, NR::Point const &p) 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; @@ -2252,7 +2252,7 @@ double distance(Shape const *s, NR::Point const &p) * \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 73199a313..ca8ae1c6e 100644 --- a/src/livarot/Shape.h +++ b/src/livarot/Shape.h @@ -124,7 +124,7 @@ public: // -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 @@ -288,12 +288,12 @@ public: // 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); @@ -314,7 +314,7 @@ public: 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::iterator it=_pts.begin();it!=_pts.end();it++) it->x*=tr;} std::vector ebData; @@ -341,7 +341,7 @@ public: // 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; @@ -351,7 +351,7 @@ public: 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 @@ -387,7 +387,7 @@ private: 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) {} @@ -439,7 +439,7 @@ private: int nextLinkedPoint; // not used Shape *askForWindingS; int askForWindingB; - NR::Point rx; // rounded coordinates of the point + Geom::Point rx; // rounded coordinates of the point }; @@ -447,7 +447,7 @@ private: { // temporary array of edges for easier sorting int no; bool starting; - NR::Point x; + Geom::Point x; }; void initialisePointData(); @@ -477,11 +477,11 @@ private: 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); @@ -518,7 +518,7 @@ private: 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); @@ -562,11 +562,11 @@ private: }; // 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 diff --git a/src/livarot/ShapeMisc.cpp b/src/livarot/ShapeMisc.cpp index 824f04a88..d6ca8c533 100644 --- a/src/livarot/ShapeMisc.cpp +++ b/src/livarot/ShapeMisc.cpp @@ -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) { @@ -987,7 +987,7 @@ Shape::ReFormeLineTo (int bord, int /*curBord*/, Path * dest, Path * /*orig*/) 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) { @@ -1022,7 +1022,7 @@ Shape::ReFormeArcTo (int bord, int /*curBord*/, Path * dest, Path * from) 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) { @@ -1099,7 +1099,7 @@ Shape::ReFormeCubicTo (int bord, int /*curBord*/, Path * dest, Path * from) 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) { @@ -1123,9 +1123,9 @@ Shape::ReFormeCubicTo (int bord, int /*curBord*/, Path * dest, Path * from) } 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(from->descr_cmd[nPiece]); Path::CubicTangent (ts, sDx, prevx,nData->start,nData->p,nData->end); @@ -1146,8 +1146,8 @@ Shape::ReFormeBezierTo (int bord, int /*curBord*/, Path * dest, Path * from) 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(); @@ -1235,7 +1235,7 @@ Shape::ReFormeBezierTo (int bord, int /*curBord*/, Path * dest, Path * from) } else { - NR::Point tx; + Geom::Point tx; { PathDescrIntermBezierTo* psData = dynamic_cast(from->descr_cmd[pe]); PathDescrIntermBezierTo* pnData = dynamic_cast(from->descr_cmd[pe+1]); @@ -1256,7 +1256,7 @@ Shape::ReFormeBezierTo (int bord, int /*curBord*/, Path * dest, Path * from) { if (te > 0.9999) { - NR::Point tx; + Geom::Point tx; { PathDescrIntermBezierTo* psData = dynamic_cast(from->descr_cmd[ps+1]); PathDescrIntermBezierTo* pnData = dynamic_cast(from->descr_cmd[ps+2]); @@ -1274,7 +1274,7 @@ Shape::ReFormeBezierTo (int bord, int /*curBord*/, Path * dest, Path * from) } else { - NR::Point tx; + Geom::Point tx; { PathDescrIntermBezierTo* psData = dynamic_cast(from->descr_cmd[ps+1]); PathDescrIntermBezierTo* pnData = dynamic_cast(from->descr_cmd[ps+2]); @@ -1315,7 +1315,7 @@ Shape::ReFormeBezierTo (int bord, int /*curBord*/, Path * dest, Path * from) } else { - NR::Point tx; + Geom::Point tx; { PathDescrIntermBezierTo* psData = dynamic_cast(from->descr_cmd[pe+1]); PathDescrIntermBezierTo* pnData = dynamic_cast(from->descr_cmd[pe+2]); @@ -1336,7 +1336,7 @@ Shape::ReFormeBezierTo (int bord, int /*curBord*/, Path * dest, Path * from) { if (te < 0.0001) { - NR::Point tx; + Geom::Point tx; { PathDescrIntermBezierTo* psData = dynamic_cast(from->descr_cmd[ps]); PathDescrIntermBezierTo* pnData = dynamic_cast(from->descr_cmd[ps+1]); @@ -1354,7 +1354,7 @@ Shape::ReFormeBezierTo (int bord, int /*curBord*/, Path * dest, Path * from) } else { - NR::Point tx; + Geom::Point tx; { PathDescrIntermBezierTo* psData = dynamic_cast(from->descr_cmd[ps]); PathDescrIntermBezierTo* pnData = dynamic_cast(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(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 @@ -1430,7 +1430,7 @@ Shape::ReFormeBezierChunk (NR::Point px, NR::Point nx, nData = dynamic_cast(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); } diff --git a/src/livarot/ShapeRaster.cpp b/src/livarot/ShapeRaster.cpp index 528fe395d..7b00cdc6b 100644 --- a/src/livarot/ShapeRaster.cpp +++ b/src/livarot/ShapeRaster.cpp @@ -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; @@ -1656,8 +1656,8 @@ void Shape::CreateEdge(int no, float to, float step) 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; diff --git a/src/livarot/ShapeSweep.cpp b/src/livarot/ShapeSweep.cpp index 2d7bfe252..00a0dd9a0 100644 --- a/src/livarot/ShapeSweep.cpp +++ b/src/livarot/ShapeSweep.cpp @@ -210,7 +210,7 @@ Shape::ConvertToShape (Shape * a, FillRule directed, bool invert) 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; @@ -250,7 +250,7 @@ Shape::ConvertToShape (Shape * a, FillRule directed, bool invert) continue; } - NR::Point rPtX; + Geom::Point rPtX; rPtX[0]= Round (ptX[0]); rPtX[1]= Round (ptX[1]); int lastPointNo = -1; @@ -916,7 +916,7 @@ Shape::Booleen (Shape * a, Shape * b, BooleanOp mod,int cutPathID) } printf("\n");*/ - NR::Point ptX; + Geom::Point ptX; double ptL, ptR; SweepTree *intersL = NULL; SweepTree *intersR = NULL; @@ -1051,7 +1051,7 @@ Shape::Booleen (Shape * a, Shape * b, BooleanOp mod,int cutPathID) continue; } - NR::Point rPtX; + Geom::Point rPtX; rPtX[0]= Round (ptX[0]); rPtX[1]= Round (ptX[1]); int lastPointNo = -1; @@ -1666,7 +1666,7 @@ void Shape::TesteIntersection(SweepTree *t, Side s, bool onlyDiff) 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)) { @@ -1676,11 +1676,11 @@ void Shape::TesteIntersection(SweepTree *t, Side s, bool 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; @@ -2001,7 +2001,7 @@ Shape::PushIncidence (Shape * a, int cb, int pt, double theta) 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); @@ -2027,13 +2027,13 @@ Shape::Winding (int nPt) const } 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; @@ -2523,7 +2523,7 @@ Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb, return false; } - NR::Point ldir, rdir; + Geom::Point ldir, rdir; ldir = ils->eData[ilb].rdx; rdir = irs->eData[irb].rdx; @@ -2561,7 +2561,7 @@ Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb, // 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; @@ -2601,11 +2601,11 @@ Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb, } // 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(); @@ -2614,7 +2614,7 @@ Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb, 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; @@ -2654,13 +2654,13 @@ Shape::TesteIntersection (Shape * ils, Shape * irs, int ilb, int irb, } 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; @@ -3026,7 +3026,7 @@ Shape::Validate (void) { 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)) { @@ -3289,12 +3289,12 @@ Shape::DoEdgeTo (Shape * iS, int iB, int iTo, bool direct, bool sens) 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; diff --git a/src/livarot/path-description.cpp b/src/livarot/path-description.cpp index 8058e0452..9ecfb99d6 100644 --- a/src/livarot/path-description.cpp +++ b/src/livarot/path-description.cpp @@ -6,12 +6,12 @@ PathDescr *PathDescrMoveTo::clone() const 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; } @@ -19,12 +19,12 @@ void PathDescrMoveTo::transform(NR::Matrix const& 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 @@ -32,7 +32,7 @@ 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; } @@ -40,7 +40,7 @@ void PathDescrLineTo::transform(NR::Matrix const& 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 @@ -48,7 +48,7 @@ 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; } @@ -56,7 +56,7 @@ void PathDescrBezierTo::transform(NR::Matrix const& 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 @@ -64,7 +64,7 @@ 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; } @@ -72,18 +72,18 @@ void PathDescrIntermBezierTo::transform(NR::Matrix const& 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 @@ -95,14 +95,14 @@ void PathDescrCubicTo::dump(std::ostream &s) 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; @@ -110,7 +110,7 @@ void PathDescrCubicTo::transform(NR::Matrix const& t) 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 @@ -127,7 +127,7 @@ 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; } @@ -136,7 +136,7 @@ void PathDescrArcTo::dump(std::ostream &s) const { /* localizing ok */ s << " a " - << p[NR::X] << " " << p[NR::Y] << " " + << p[Geom::X] << " " << p[Geom::Y] << " " << rx << " " << ry << " " << angle << " " << (clockwise ? 1 : 0) << " " @@ -148,7 +148,7 @@ PathDescr *PathDescrForced::clone() const 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 "; } diff --git a/src/livarot/path-description.h b/src/livarot/path-description.h index ccb4506f0..27521e4b8 100644 --- a/src/livarot/path-description.h +++ b/src/livarot/path-description.h @@ -35,9 +35,9 @@ struct PathDescr 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 @@ -48,41 +48,41 @@ struct PathDescr 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 }; @@ -91,44 +91,44 @@ struct PathDescrIntermBezierTo : public PathDescr { 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; @@ -145,20 +145,20 @@ struct PathDescrForced : public PathDescr /* 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 diff --git a/src/livarot/sweep-event-queue.h b/src/livarot/sweep-event-queue.h index 3c5d5f8cd..22b349abf 100644 --- a/src/livarot/sweep-event-queue.h +++ b/src/livarot/sweep-event-queue.h @@ -4,7 +4,7 @@ * A container of intersection events. */ -#include +#include <2geom/forward.h> class SweepEvent; class SweepTree; @@ -24,11 +24,11 @@ public: 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); diff --git a/src/livarot/sweep-event.cpp b/src/livarot/sweep-event.cpp index e84048a07..88d895e6b 100644 --- a/src/livarot/sweep-event.cpp +++ b/src/livarot/sweep-event.cpp @@ -19,7 +19,7 @@ SweepEventQueue::~SweepEventQueue() 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; @@ -62,7 +62,7 @@ SweepEvent *SweepEventQueue::add(SweepTree *iLeft, SweepTree *iRight, NR::Point -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; @@ -79,7 +79,7 @@ bool SweepEventQueue::peek(SweepTree * &iLeft, SweepTree * &iRight, NR::Point &p 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; @@ -122,7 +122,7 @@ void SweepEventQueue::remove(SweepEvent *e) 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; @@ -227,7 +227,7 @@ void SweepEventQueue::relocate(SweepEvent *e, int to) */ SweepEvent::SweepEvent() { - MakeNew (NULL, NULL, NR::Point(0, 0), 0, 0); + MakeNew (NULL, NULL, Geom::Point(0, 0), 0, 0); } SweepEvent::~SweepEvent() @@ -235,7 +235,7 @@ 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; diff --git a/src/livarot/sweep-event.h b/src/livarot/sweep-event.h index ce23a3ab9..bb22eddcf 100644 --- a/src/livarot/sweep-event.h +++ b/src/livarot/sweep-event.h @@ -14,7 +14,7 @@ class SweepEvent 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. @@ -23,7 +23,7 @@ public: 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. diff --git a/src/livarot/sweep-tree.cpp b/src/livarot/sweep-tree.cpp index c6c295e33..b932b1542 100644 --- a/src/livarot/sweep-tree.cpp +++ b/src/livarot/sweep-tree.cpp @@ -77,12 +77,12 @@ void SweepTree::MakeDelete() // 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) { @@ -91,7 +91,7 @@ SweepTree::Find(NR::Point const &px, SweepTree *newOne, SweepTree *&insertL, // 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 @@ -108,7 +108,7 @@ SweepTree::Find(NR::Point const &px, SweepTree *newOne, SweepTree *&insertL, // 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) @@ -165,10 +165,10 @@ SweepTree::Find(NR::Point const &px, SweepTree *newOne, SweepTree *&insertL, // 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) @@ -177,7 +177,7 @@ SweepTree::Find(NR::Point const &px, SweepTree * &insertL, } bNorm=bNorm.ccw(); - NR::Point diff; + Geom::Point diff; diff = px - bOrig; double y = 0; @@ -323,9 +323,9 @@ SweepTree::InsertAt(SweepTreeList &list, SweepEventQueue &queue, 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) { @@ -336,7 +336,7 @@ SweepTree::InsertAt(SweepTreeList &list, SweepEventQueue &queue, 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) diff --git a/src/livarot/sweep-tree.h b/src/livarot/sweep-tree.h index 67635b4c7..7f6b827dc 100644 --- a/src/livarot/sweep-tree.h +++ b/src/livarot/sweep-tree.h @@ -42,9 +42,9 @@ public: // 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); diff --git a/src/lpe-tool-context.cpp b/src/lpe-tool-context.cpp index 0f96c6ed2..30248edd0 100644 --- a/src/lpe-tool-context.cpp +++ b/src/lpe-tool-context.cpp @@ -286,7 +286,7 @@ sp_lpetool_context_root_handler(SPEventContext *event_context, GdkEvent *event) 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)); @@ -301,7 +301,7 @@ sp_lpetool_context_root_handler(SPEventContext *event_context, GdkEvent *event) } 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; @@ -454,7 +454,7 @@ lpetool_context_reset_limiting_bbox(SPLPEToolContext *lc) 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 515ed9c18..eb1a0b103 100644 --- 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); @@ -922,9 +922,9 @@ void sp_process_file_list(GSList *fl) 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; @@ -1041,7 +1041,7 @@ int sp_main_console(int argc, char const **argv) } 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 59d5355ef..3961f8473 100644 --- a/src/marker.cpp +++ b/src/marker.cpp @@ -366,8 +366,8 @@ sp_marker_update (SPObject *object, SPCtx *ctx, guint flags) /* 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 c6c639631..3f241850e 100644 --- a/src/node-context.cpp +++ b/src/node-context.cpp @@ -291,7 +291,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) 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; @@ -300,9 +300,9 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) } } } - 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(); @@ -351,9 +351,9 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) } 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; @@ -367,7 +367,7 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) } 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; @@ -390,14 +390,14 @@ sp_node_context_root_handler(SPEventContext *event_context, GdkEvent *event) 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 86e1f5302..4e8ce86c4 100644 --- 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; } @@ -729,8 +729,8 @@ public: 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 46268954a..1762d668c 100644 --- 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); @@ -1413,8 +1413,8 @@ static int pen_next_paraxial_direction(const SPPenContext *const pc, */ 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 03205d849..67c9712d1 100644 --- a/src/selcue.cpp +++ b/src/selcue.cpp @@ -102,7 +102,7 @@ void Inkscape::SelCue::_updateItemBboxes() "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 11c9cc4e9..1daf6b0e5 100644 --- 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; @@ -443,8 +443,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) 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); @@ -475,8 +475,8 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) 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) { @@ -643,7 +643,7 @@ sp_select_context_root_handler(SPEventContext *event_context, GdkEvent *event) } 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; diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp index 92f751e85..f1bb46167 100644 --- a/src/selection-chemistry.cpp +++ b/src/selection-chemistry.cpp @@ -91,8 +91,8 @@ #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 @@ -102,7 +102,7 @@ for that purpose. */ * 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); } @@ -1296,7 +1296,7 @@ sp_selection_scale_absolute(Inkscape::Selection *selection, 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))); } /** @@ -1369,7 +1369,7 @@ void sp_selection_rotate_90(SPDesktop *desktop, bool ccw) 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); @@ -2218,7 +2218,7 @@ sp_selection_tile(SPDesktop *desktop, bool apply) } // 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)); @@ -2841,7 +2841,7 @@ void sp_selection_unset_mask(SPDesktop *desktop, bool apply_clip_path) { 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 5776388c3..91ff4bc2b 100644 --- a/src/sp-conn-end.cpp +++ b/src/sp-conn-end.cpp @@ -115,7 +115,7 @@ sp_conn_end_move_compensate(Geom::Matrix const */*mp*/, SPItem */*moved_item*/, 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 be4d37909..75be3bea2 100644 --- 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; } } @@ -1352,14 +1352,14 @@ sp_image_set_transform(SPItem *item, Geom::Matrix const &xform) 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 { @@ -1524,7 +1524,7 @@ sp_image_set_curve(SPImage *image) } } 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 2b42a855b..afa3880b8 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -367,7 +367,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) 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); @@ -391,7 +391,7 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done) /* 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 0cb3d3389..81d71044d 100644 --- 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 - SP_ITEM(object)->transform = NR::identity(); + SP_ITEM(object)->transform = Geom::identity(); } /** @@ -544,7 +544,7 @@ sp_root_update(SPObject *object, SPCtx *ctx, guint flags) 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 7ee2af1ec..155c9b454 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -628,7 +628,7 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) } /* 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)); @@ -661,7 +661,7 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) 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; @@ -687,7 +687,7 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) 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; @@ -717,7 +717,7 @@ sp_shape_print (SPItem *item, SPPrintContext *ctx) 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 f70a19b06..41004db6e 100644 --- a/src/sp-symbol.cpp +++ b/src/sp-symbol.cpp @@ -270,7 +270,7 @@ sp_symbol_update (SPObject *object, SPCtx *ctx, guint flags) /* Calculate child to parent transformation */ /* Apply parent 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; @@ -353,7 +353,7 @@ sp_symbol_update (SPObject *object, SPCtx *ctx, guint flags) 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 2496fc6e0..9da95df90 100644 --- a/src/sp-tspan.cpp +++ b/src/sp-tspan.cpp @@ -579,7 +579,7 @@ sp_textpath_to_text(SPObject *tp) 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; @@ -602,9 +602,9 @@ sp_textpath_to_text(SPObject *tp) // 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]); } } diff --git a/src/sp-use-reference.cpp b/src/sp-use-reference.cpp index b2188c0d5..914e416b3 100644 --- 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 134588e65..36372e67b 100644 --- a/src/sp-use.cpp +++ b/src/sp-use.cpp @@ -356,7 +356,7 @@ sp_use_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags) } 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 b41ad4b21..c57c58a14 100644 --- 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 @@ -685,7 +685,7 @@ sp_selected_path_outline(SPDesktop *desktop) 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()); @@ -1520,7 +1520,7 @@ sp_selected_path_simplify_item(SPDesktop *desktop, 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(); @@ -1853,16 +1853,16 @@ SPCurve* curve_for_item(SPItem *item) return curve; // do not forget to unref the curve at some point! } -boost::optional get_nearest_position_on_Path(Path *path, NR::Point p, unsigned seg) +boost::optional 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 a4fe588ed..dce31a1ad 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -50,8 +50,8 @@ void sp_selected_path_simplify (SPDesktop *desktop); 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 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 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 0eeac8c4f..f1348ad67 100644 --- a/src/text-chemistry.cpp +++ b/src/text-chemistry.cpp @@ -430,10 +430,10 @@ text_unflow () 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 */ diff --git a/src/trace/trace.cpp b/src/trace/trace.cpp index 33e4ea3a1..c8937bdd8 100644 --- a/src/trace/trace.cpp +++ b/src/trace/trace.cpp @@ -282,7 +282,7 @@ Tracer::sioxProcessImage(SPImage *img, { //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); @@ -511,7 +511,7 @@ void Tracer::traceThread() 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; diff --git a/src/ui/view/edit-widget.cpp b/src/ui/view/edit-widget.cpp index 5e9b44ff6..827074016 100644 --- a/src/ui/view/edit-widget.cpp +++ b/src/ui/view/edit-widget.cpp @@ -1664,6 +1664,7 @@ EditWidget::onWindowSizeAllocate (Gtk::Allocation &newall) void EditWidget::onWindowRealize() { + if ( (sp_document_width(_desktop->doc()) < 1.0) || (sp_document_height(_desktop->doc()) < 1.0) ) { return; } -- 2.30.2