From 86891a9e442c81435c6d197cb09b3dc210643bc0 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Sun, 8 Feb 2015 16:40:25 +0100 Subject: starting whith pointwise (bzr r13645.1.7) --- src/2geom/Makefile_insert | 3 +++ src/2geom/pointwise.cpp | 6 ++++-- src/2geom/pointwise.h | 16 +++++++++++++--- src/2geom/satellite-enum.h | 2 +- src/2geom/satellite.h | 28 +++++++++++++++++++++------- 5 files changed, 42 insertions(+), 13 deletions(-) (limited to 'src/2geom') diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert index e77f413cb..2f23bc442 100644 --- a/src/2geom/Makefile_insert +++ b/src/2geom/Makefile_insert @@ -80,6 +80,8 @@ 2geom/point.cpp \ 2geom/point.h \ 2geom/point-ops.h \ + 2geom/pointwise.cpp \ + 2geom/pointwise.h \ 2geom/poly.cpp \ 2geom/poly.h \ 2geom/quadtree.cpp \ @@ -90,6 +92,7 @@ 2geom/recursive-bezier-intersection.cpp \ 2geom/region.cpp \ 2geom/region.h \ + 2geom/satellite.h \ 2geom/sbasis-2d.cpp \ 2geom/sbasis-2d.h \ 2geom/sbasis.cpp \ diff --git a/src/2geom/pointwise.cpp b/src/2geom/pointwise.cpp index ce3aa86f6..cd7f7914f 100644 --- a/src/2geom/pointwise.cpp +++ b/src/2geom/pointwise.cpp @@ -1,6 +1,8 @@ /* - * pointwise.cpp - Pointwise function class - * + * pointwise.cpp + * Authors: + * 2015 Jabier Arraiza Cenoz + * Copyright 2015 authors * * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public diff --git a/src/2geom/pointwise.h b/src/2geom/pointwise.h index 33289f4f0..c0974f54c 100644 --- a/src/2geom/pointwise.h +++ b/src/2geom/pointwise.h @@ -3,10 +3,20 @@ * \brief Pointwise *//* * Authors: + * 2015 Jabier Arraiza Cenoz + * Copyright 2015 authors * - * Copyright 2014 authors - * - * + * Pointwise maintains a set of "Satellite" positions along a curve/pathvector. + * The positions are specified as arc length distances along the curve or by + * time in the curve. Splicing operations automatically update the satellite + * positions to preserve the intent. + * The data is serialised to SVG using a specialiced pointwise LPE parameter to + * handle it in th future can be a inkscape based property to paths + * //all operations are O(1) per satellite, with the exception of .., .., and .., which + * //need to use binary search to find the locations. + * Anywhere a Piecewise is used, a Pointwise can be substituted, allowing + * existing algorithms to correctly update satellite positions. + * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public * License version 2.1 as published by the Free Software Foundation diff --git a/src/2geom/satellite-enum.h b/src/2geom/satellite-enum.h index 3872cf718..a71306bc9 100644 --- a/src/2geom/satellite-enum.h +++ b/src/2geom/satellite-enum.h @@ -20,7 +20,7 @@ enum SatelliteType { INVERSE_CHAMFER, INVALID_SATELLITE // This must be last (I made it such that it is not needed anymore I think..., Don't trust on it being last. - johan) }; - +std::map SatelliteTypeMap = boost::map_list_of("FILLET", FILLET)("INVERSE_FILLET", INVERSE_FILLET)("CHAMFER",CHAMFER)("INVERSE_CHAMFER",INVERSE_CHAMFER)("INVALID_SATELLITE",INVALID_SATELLITE); extern const Util::EnumData SATELLITETypeData[]; /// defined in satelite.cpp extern const Util::EnumDataConverter SATELLITETypeConverter; /// defined in sattelite.cpp diff --git a/src/2geom/satellite.h b/src/2geom/satellite.h index 8e570db4c..a18b08f27 100644 --- a/src/2geom/satellite.h +++ b/src/2geom/satellite.h @@ -3,8 +3,8 @@ * \brief Satellite *//* * Authors: - * - * Copyright 2014 authors + * 2015 Jabier Arraiza Cenoz + * Copyright 2015 authors * * This library is free software; you can redistribute it and/or * modify it either under the terms of the GNU Lesser General Public @@ -129,16 +129,30 @@ class Satellite return _time; } - double toTime(double A,D2 curve) const + double time(D2 curve) const { //todo make the process return _time; } - double toSize(double A,D2 curve) const - { - //todo make the process - return _size; + void setPosition(Geom::Point p, D2 curve){ + _time = Geom::nearestPoint(p, curve); + if(!_isTime){ + if (curve.degreesOfFreedom() != 2) { + Piecewise > u; + u.push_cut(0); + u.push(curve, 1); + u = portion(u, 0, _time); + _size = length(u, 0.001) * -1; + } else { + lenghtPart = length(last_pwd2[index], EPSILON); + _size = (time * lenghtPart) * -1; + } + } + } + + Geom::Point getPosition(D2 curve){ + return curve.pointAt(_time); } bool isDegenerate() const -- cgit v1.2.3