summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2015-04-01 02:13:16 +0000
committerJabiertxof <jtx@jtx.marker.es>2015-04-01 02:13:16 +0000
commitdff3aa428ff050c2cce501f646977ddad921feca (patch)
tree3152c9b571095e1db57af2522129d278b5f4ce39
parentremoved code comments (diff)
downloadinkscape-dff3aa428ff050c2cce501f646977ddad921feca.tar.gz
inkscape-dff3aa428ff050c2cce501f646977ddad921feca.zip
Move 2Geom work to a intermediate positon -helper-
Removed dependency to helper/geom.h Now use a simple vector, not a vector of pairs of size_t and Satellite Getters and setters on Satellite removed Update store parameter to a more friendly string, like powerstroke Todo: Documentation and Fix coding style. (bzr r13645.1.63)
-rw-r--r--po/POTFILES.in2
-rw-r--r--src/2geom/Makefile_insert4
-rw-r--r--src/2geom/pointwise.cpp519
-rw-r--r--src/2geom/satellite.cpp156
-rw-r--r--src/helper/Makefile_insert7
-rw-r--r--src/helper/geom-pathinfo.cpp178
-rw-r--r--src/helper/geom-pathinfo.h81
-rw-r--r--src/helper/geom-pointwise.cpp268
-rw-r--r--src/helper/geom-pointwise.h (renamed from src/2geom/pointwise.h)28
-rw-r--r--src/helper/geom-satellite-enum.h (renamed from src/2geom/satellite-enum.h)0
-rw-r--r--src/helper/geom-satellite.cpp237
-rw-r--r--src/helper/geom-satellite.h (renamed from src/2geom/satellite.h)133
-rw-r--r--src/live_effects/CMakeLists.txt4
-rw-r--r--src/live_effects/lpe-fillet-chamfer.cpp173
-rw-r--r--src/live_effects/lpe-fillet-chamfer.h9
-rw-r--r--src/live_effects/parameter/Makefile_insert4
-rw-r--r--src/live_effects/parameter/array.cpp77
-rw-r--r--src/live_effects/parameter/array.h38
-rw-r--r--src/live_effects/parameter/satellitearray.cpp (renamed from src/live_effects/parameter/satellitepairarray.cpp)159
-rw-r--r--src/live_effects/parameter/satellitearray.h (renamed from src/live_effects/parameter/satellitepairarray.h)18
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.cpp24
-rw-r--r--src/ui/dialog/lpe-fillet-chamfer-properties.h2
22 files changed, 1049 insertions, 1072 deletions
diff --git a/po/POTFILES.in b/po/POTFILES.in
index d1aef8ead..96be5baf7 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -160,7 +160,7 @@ src/live_effects/lpe-taperstroke.cpp
src/live_effects/lpe-vonkoch.cpp
src/live_effects/parameter/bool.cpp
src/live_effects/parameter/enum.h
-src/live_effects/parameter/satellitepairarray.cpp
+src/live_effects/parameter/satellitearray.cpp
src/live_effects/parameter/originalpath.cpp
src/live_effects/parameter/originalpatharray.cpp
src/live_effects/parameter/parameter.cpp
diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert
index 8872065fb..e77f413cb 100644
--- a/src/2geom/Makefile_insert
+++ b/src/2geom/Makefile_insert
@@ -80,8 +80,6 @@
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 \
@@ -92,8 +90,6 @@
2geom/recursive-bezier-intersection.cpp \
2geom/region.cpp \
2geom/region.h \
- 2geom/satellite.cpp \
- 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
deleted file mode 100644
index bc82780d7..000000000
--- a/src/2geom/pointwise.cpp
+++ /dev/null
@@ -1,519 +0,0 @@
-/*
- * pointwise.cpp
- * Authors:
- * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es>
- * 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
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, output to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- *
- */
-
-#include <2geom/pointwise.h>
-#include <2geom/ray.h>
-#include <2geom/path-intersection.h>
-#include <cmath>
-
-namespace Geom {
-
-Pointwise::Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<size_t,Satellite> > satellites)
- : _pwd2(pwd2),_satellites(satellites),_pathInfo()
-{
- setPathInfo();
-};
-
-Pointwise::~Pointwise(){};
-
-Piecewise<D2<SBasis> >
-Pointwise::getPwd2() const
-{
- return _pwd2;
-}
-
-void
-Pointwise::setPwd2(Piecewise<D2<SBasis> > pwd2_in)
-{
- _pwd2 = pwd2_in;
- setPathInfo();
-}
-
-std::vector<std::pair<size_t,Satellite> >
-Pointwise::getSatellites() const
-{
- return _satellites;
-}
-
-void
-Pointwise::setSatellites(std::vector<std::pair<size_t,Satellite> > sats)
-{
- _satellites = sats;
-}
-
-//START QUESTION Next functions maybe is beter land outside the class?
-void
-Pointwise::setPathInfo()
-{
- setPathInfo(_pwd2);
-}
-
-void
-Pointwise::setPathInfo(Piecewise<D2<SBasis> > pwd2)
-{
- _pathInfo.clear();
- std::vector<Geom::Path> path_in = path_from_piecewise(remove_short_cuts(pwd2,0.1), 0.001);
- size_t counter = 0;
- for (PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) {
- if (path_it->empty()){
- continue;
- }
- Geom::Path::const_iterator curve_it1 = path_it->begin();
- Geom::Path::const_iterator curve_endit = path_it->end_default();
- if (path_it->closed()) {
- const Curve &closingline = path_it->back_closed();
- if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
- curve_endit = path_it->end_open();
- }
- }
- while (curve_it1 != curve_endit) {
- ++curve_it1;
- counter++;
- }
- if(path_it->closed()){
- _pathInfo.push_back(std::make_pair(counter-1,true));
- } else {
- _pathInfo.push_back(std::make_pair(counter-1,false));
- }
- }
-}
-
-size_t
-Pointwise::getSubPathIndex(size_t index) const
-{
- for(size_t i = 0; i < _pathInfo.size(); i++){
- if(index <= _pathInfo[i].first){
- return i;
- }
- }
- return 0;
-}
-
-size_t
-Pointwise::getLast(size_t index) const
-{
- for(size_t i = 0; i < _pathInfo.size(); i++){
- if(index <= _pathInfo[i].first){
- return _pathInfo[i].first;
- }
- }
- return 0;
-}
-
-size_t
-Pointwise::getFirst(size_t index) const
-{
- for(size_t i = 0; i < _pathInfo.size(); i++){
- if(index <= _pathInfo[i].first){
- if(i==0){
- return 0;
- } else {
- return _pathInfo[i-1].first + 1;
- }
- }
- }
- return 0;
-}
-
-boost::optional<size_t>
-Pointwise::getPrevious(size_t index) const
-{
- if(getFirst(index) == index && getIsClosed(index)){
- return getLast(index);
- }
- if(getFirst(index) == index && !getIsClosed(index)){
- return boost::none;
- }
- return index - 1;
-}
-
-boost::optional<size_t>
-Pointwise::getNext(size_t index) const
-{
- if(getLast(index) == index && getIsClosed(index)){
- return getFirst(index);
- }
- if(getLast(index) == index && !getIsClosed(index)){
- return boost::none;
- }
- return index + 1;
-}
-
-bool
-Pointwise::getIsClosed(size_t index) const
-{
- for(size_t i = 0; i < _pathInfo.size(); i++){
- if(index <= _pathInfo[i].first){
- return _pathInfo[i].second;
- }
- }
- return false;
-}
-//END QUESTION
-
-void
-Pointwise::recalculate_for_new_pwd2(Piecewise<D2<SBasis> > A)
-{
- if( _pwd2.size() > A.size()){
- pwd2_sustract(A);
- } else if (_pwd2.size() < A.size()){
- pwd2_append(A);
- }
-}
-
-void
-Pointwise::pwd2_append(Piecewise<D2<SBasis> > A)
-{
- size_t counter = 0;
- std::vector<std::pair<size_t,Satellite> > sats;
- for (std::vector<std::pair<size_t,Satellite> >::iterator it=_satellites.begin(); it!=_satellites.end();)
- {
- if(it->second.getIsEndOpen()){
- it = _satellites.erase(it);
- } else {
- ++it;
- }
- }
- bool reversed = false;
- bool reorder = false;
- for(size_t i = 0; i < A.size(); i++){
- size_t first = getFirst(i-counter);
- size_t last = getLast(i-counter);
- setPathInfo(A);
- size_t subpathAIndex = getSubPathIndex(i);
- setPathInfo(_pwd2);
- bool changedSubpath = false;
- if(_pwd2.size() <= i-counter){
- changedSubpath = false;
- } else {
- changedSubpath = subpathAIndex != getSubPathIndex(i-counter);
- }
- if(!reorder && first == i-counter && !are_near(_pwd2[i-counter].at0(),A[i].at0(),0.001) && !changedSubpath){
- subpath_append_reorder(getSubPathIndex(first));
- reorder = true;
- i--;
- continue;
- }
- if(!reversed && first == i-counter && !are_near(_pwd2[i-counter].at0(),A[i].at0(),0.001) && !changedSubpath){
- reverse(first, last);
- reversed = true;
- }
- if(_pwd2.size() <= i-counter || !are_near(_pwd2[i-counter].at0(),A[i].at0(),0.001)){
- counter++;
- bool isEndOpen = false;
- bool active = true;
- bool hidden = false;
- bool isTime = _satellites[0].second.getIsTime();
- bool mirror_knots = _satellites[0].second.getHasMirror();
- double amount = 0.0;
- double degrees = 0.0;
- int steps = 0;
- Satellite sat(_satellites[0].second.getSatelliteType(), isTime, isEndOpen, active, mirror_knots, hidden, amount, degrees, steps);
- sats.push_back(std::make_pair(i,sat));
- } else {
- std::vector<size_t> satsFind = findSatellites(i-counter,999);
- for(size_t j = 0; j< satsFind.size(); j++){
- sats.push_back(std::make_pair(i,_satellites[satsFind[j]].second));
- }
- }
- }
- setPwd2(A);
- setSatellites(sats);
-}
-
-void
-Pointwise::pwd2_sustract(Piecewise<D2<SBasis> > A)
-{
- size_t counter = 0;
- std::vector<std::pair<size_t,Satellite> > sats;
- for (std::vector<std::pair<size_t,Satellite> >::iterator it=_satellites.begin(); it!=_satellites.end();)
- {
- if(it->second.getIsEndOpen()){
- it = _satellites.erase(it);
- } else {
- ++it;
- }
- }
- Piecewise<D2<SBasis> > pwd2 = _pwd2;
- setPwd2(A);
- for(size_t i = 0; i < _satellites.size(); i++){
- if(getLast(_satellites[i].first-counter) < _satellites[i].first-counter || !are_near(pwd2[_satellites[i].first].at0(),A[_satellites[i].first-counter].at0(),0.001)){
- counter++;
- } else {
- std::vector<size_t> satsFind = findSatellites(_satellites[i].first-counter,999);
- for(size_t j = 0; j< satsFind.size(); j++){
- sats.push_back(std::make_pair(_satellites[i].first-counter,_satellites[satsFind[j]].second));
- }
- }
- }
- setSatellites(sats);
-}
-
-void
-Pointwise::set_extremes(bool active, bool hidden, double amount, double angle)
-{
- for(size_t i = 0; i < _pathInfo.size(); i++){
- size_t firstNode = getFirst(_pathInfo[i].first);
- size_t lastNode = getLast(_pathInfo[i].first);
- if(!getIsClosed(lastNode)){
- long lastIndex = -1;
- for(size_t j = 0; j < _satellites.size(); j++){
- if(_satellites[j].first < firstNode || _satellites[j].first > lastNode){
- continue;
- }
- _satellites[j].second.setIsEndOpen(false);
- if(_satellites[j].first == firstNode){
- _satellites[j].second.setActive(active);
- _satellites[j].second.setHidden(hidden);
- if(amount >= 0){
- _satellites[j].second.setAmount(amount);
- }
- if(angle >= 0){
- _satellites[j].second.setAngle(angle);
- }
- }
- if(_satellites[j].first == lastNode && lastIndex == -1){
- lastIndex = j;
- }
- }
- Satellite sat(_satellites[0].second.getSatelliteType(), _satellites[0].second.getIsTime(), true, active, _satellites[0].second.getHasMirror(), hidden, 0.0, 0.0, _satellites[0].second.getSteps());
- _satellites.insert(_satellites.begin() + lastIndex + 1, std::make_pair(lastNode,sat));
- } else {
- for(size_t j = 0; j < _satellites.size(); j++){
- if(_satellites[j].first < firstNode){
- continue;
- }
- if(_satellites[j].first == firstNode && !_satellites[j].second.getActive()){
- _satellites[j].second.setActive(true);
- _satellites[j].second.setHidden(_satellites[j+1].second.getHidden());
- }
-
- }
- }
- }
-}
-
-void
-Pointwise::subpath_append_reorder(size_t subpath){
- std::vector<Geom::Path> path_in = path_from_piecewise(remove_short_cuts(_pwd2,0.1), 0.001);
- size_t nSubpath = 0;
- size_t counter = 0;
- std::vector<Geom::Path> tmp_path;
- Geom::Path rev;
- for (PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) {
- if (path_it->empty()){
- continue;
- }
- Geom::Path::const_iterator curve_it1 = path_it->begin();
- Geom::Path::const_iterator curve_endit = path_it->end_default();
- const Curve &closingline = path_it->back_closed();
- if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
- curve_endit = path_it->end_open();
- }
- while (curve_it1 != curve_endit) {
- if(nSubpath == subpath){
- std::vector<size_t> sats = findSatellites(counter,999);
- for(size_t i = 0; i< sats.size(); i++){
- _satellites.push_back(std::make_pair(_pwd2.size(),_satellites[sats[i]].second));
- }
- deleteSatellites(counter);
- } else {
- counter++;
- }
- ++curve_it1;
- }
- if(nSubpath == subpath){
- rev = *path_it;
- } else {
- tmp_path.push_back(*path_it);
- }
- nSubpath++;
- }
- tmp_path.push_back(rev);
- setPwd2(remove_short_cuts(paths_to_pw(pathv_to_linear_and_cubic_beziers(tmp_path)),0.01));
-}
-
-void
-Pointwise::reverse(size_t start,size_t end){
- start ++;
- for(size_t i = end; i >= start; i--){
- std::vector<size_t> sats = findSatellites(i,999);
- for(size_t j = 0; j< sats.size(); j++){
- _satellites.push_back(std::make_pair(_pwd2.size(),_satellites[sats[j]].second));
- }
- deleteSatellites(i);
- }
- std::vector<Geom::Path> path_in = path_from_piecewise(remove_short_cuts(_pwd2,0.1), 0.001);
- size_t counter = 0;
- size_t nSubpath = 0;
- size_t subpath = getSubPathIndex(start);
- std::vector<Geom::Path> tmp_path;
- Geom::Path rev;
- for (PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) {
- if (path_it->empty()){
- continue;
- }
- counter ++;
- if(nSubpath == subpath){
- tmp_path.push_back(path_it->reverse());
- } else {
- tmp_path.push_back(*path_it);
- }
- nSubpath++;
- }
- setPwd2(remove_short_cuts(paths_to_pw(pathv_to_linear_and_cubic_beziers(tmp_path)),0.01));
-}
-
-double
-Pointwise::rad_to_len(double A, std::pair<size_t,Geom::Satellite> sat) const
-{
- double len = 0;
- boost::optional<size_t> d2_prev_index = getPrevious(sat.first);
- if(d2_prev_index){
- Geom::D2<Geom::SBasis> d2_in = _pwd2[*d2_prev_index];
- Geom::D2<Geom::SBasis> d2_out = _pwd2[sat.first];
- Piecewise<D2<SBasis> > offset_curve0 = Piecewise<D2<SBasis> >(d2_in)+rot90(unitVector(derivative(d2_in)))*(A);
- Piecewise<D2<SBasis> > offset_curve1 = Piecewise<D2<SBasis> >(d2_out)+rot90(unitVector(derivative(d2_out)))*(A);
- Geom::Path p0 = path_from_piecewise(offset_curve0, 0.1)[0];
- Geom::Path p1 = path_from_piecewise(offset_curve1, 0.1)[0];
- Geom::Crossings cs = Geom::crossings(p0, p1);
- if(cs.size() > 0){
- Point cp =p0(cs[0].ta);
- double p0pt = nearest_point(cp, d2_out);
- len = sat.second.toSize(p0pt,d2_out);
- } else {
- if(A > 0){
- len = rad_to_len(A * -1, sat);
- }
- }
- }
- return len;
-}
-
-double
-Pointwise::len_to_rad(double A, std::pair<size_t,Geom::Satellite> sat) const
-{
- boost::optional<size_t> d2_prev_index = getPrevious(sat.first);
- if(d2_prev_index){
- Geom::D2<Geom::SBasis> d2_in = _pwd2[*d2_prev_index];
- Geom::D2<Geom::SBasis> d2_out = _pwd2[sat.first];
- double time_in = sat.second.getOpositeTime(A, d2_in);
- double time_out = sat.second.toTime(A,d2_out);
- Geom::Point startArcPoint = (d2_in).valueAt(time_in);
- Geom::Point endArcPoint = d2_out.valueAt(time_out);
- Piecewise<D2<SBasis> > u;
- u.push_cut(0);
- u.push((d2_in), 1);
- Geom::Curve * A = path_from_piecewise(u, 0.1)[0][0].duplicate();
- Piecewise<D2<SBasis> > u2;
- u2.push_cut(0);
- u2.push((d2_out), 1);
- Geom::Curve * B = path_from_piecewise(u2, 0.1)[0][0].duplicate();
- Curve *knotCurve1 = A->portion(0, time_in);
- Curve *knotCurve2 = B->portion(time_out, 1);
- Geom::CubicBezier const *cubic1 = dynamic_cast<Geom::CubicBezier const *>(&*knotCurve1);
- Ray ray1(startArcPoint, (d2_in).valueAt(1));
- if (cubic1) {
- ray1.setPoints((*cubic1)[2], startArcPoint);
- }
- Geom::CubicBezier const *cubic2 = dynamic_cast<Geom::CubicBezier const *>(&*knotCurve2);
- Ray ray2(d2_out.valueAt(0), endArcPoint);
- if (cubic2) {
- ray2.setPoints(endArcPoint, (*cubic2)[1]);
- }
- bool ccwToggle = cross((d2_in).valueAt(1) - startArcPoint, endArcPoint - startArcPoint) < 0;
- double distanceArc = Geom::distance(startArcPoint,middle_point(startArcPoint,endArcPoint));
- double angleBetween = angle_between(ray1, ray2, ccwToggle);
- double divisor = std::sin(angleBetween/2.0);
- if(divisor > 0){
- return distanceArc/divisor;
- }
- }
- return 0;
-}
-
-void
-Pointwise::deleteSatellites(size_t A)
-{
- bool erased = false;
- for (std::vector<std::pair<size_t,Satellite> >::iterator it=_satellites.begin(); it!=_satellites.end();)
- {
- if(it->first == A){
- it = _satellites.erase(it);
- erased = true;
- } else {
- if(erased){
- it->first = it->first-1;
- }
- ++it;
- }
- }
-}
-
-std::vector<size_t>
-Pointwise::findSatellites(size_t A, long B) const
-{
- std::vector<size_t> ret;
- long counter = 0;
- for(size_t i = 0; i < _satellites.size(); i++){
- if(_satellites[i].first == A){
- if(counter >= B && B != (long)-1){
- return ret;
- }
- ret.push_back(i);
- counter++;
- }
- }
- return ret;
-}
-
-std::vector<size_t >
-Pointwise::findPeviousSatellites(size_t A, long B) const
-{
- boost::optional<size_t> previous = getPrevious(A);
- std::vector<size_t> ret;
- if(previous){
- ret = findSatellites(*previous,B);
- }
- return ret;
-}
-
-}
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/2geom/satellite.cpp b/src/2geom/satellite.cpp
deleted file mode 100644
index d1420b20c..000000000
--- a/src/2geom/satellite.cpp
+++ /dev/null
@@ -1,156 +0,0 @@
-/**
- * \file
- * \brief Satellite
- *//*
- * Authors:
- * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es>
- * 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
- * License version 2.1 as published by the Free Software Foundation
- * (the "LGPL") or, at your option, under the terms of the Mozilla
- * Public License Version 1.1 (the "MPL"). If you do not alter this
- * notice, a recipient may use your version of this file under either
- * the MPL or the LGPL.
- *
- * You should have received a copy of the LGPL along with this library
- * in the file COPYING-LGPL-2.1; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- * You should have received a copy of the MPL along with this library
- * in the file COPYING-MPL-1.1
- *
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
- * OF ANY KIND, either express or implied. See the LGPL or the MPL for
- * the specific language governing rights and limitations.
- */
-
-#include <2geom/satellite.h>
-#include <2geom/curve.h>
-#include <2geom/nearest-point.h>
-#include <2geom/sbasis-geometric.h>
-
-
-namespace Geom {
-
-Satellite::Satellite(){};
-
-Satellite::Satellite(SatelliteType satellitetype, bool isTime, bool isEndOpen, bool active, bool hasMirror, bool hidden, double amount, double angle, size_t steps)
- : _satellitetype(satellitetype), _isTime(isTime), _isEndOpen(isEndOpen), _active(active), _hasMirror(hasMirror), _hidden(hidden), _amount(amount), _angle(angle), _steps(steps){};
-
-Satellite::~Satellite() {};
-
-double
-Satellite::toTime(double A,Geom::D2<Geom::SBasis> d2_in) const
-{
- if(!d2_in.isFinite() || d2_in.isZero() || A == 0){
- return 0;
- }
- double t = 0;
- double lenghtPart = Geom::length(d2_in, Geom::EPSILON);
- if (A > lenghtPart || d2_in[0].degreesOfFreedom() == 2) {
- if (lenghtPart != 0) {
- t = A / lenghtPart;
- }
- } else if (d2_in[0].degreesOfFreedom() != 2) {
- Geom::Piecewise<Geom::D2<Geom::SBasis> > u;
- u.push_cut(0);
- u.push(d2_in, 1);
- std::vector<double> t_roots = roots(arcLengthSb(u) - A);
- if (t_roots.size() > 0) {
- t = t_roots[0];
- }
- }
-
- return t;
-}
-
-double
-Satellite::toSize(double A,Geom::D2<Geom::SBasis> d2_in) const
-{
- if(!d2_in.isFinite() || d2_in.isZero() || A == 0){
- return 0;
- }
- double s = 0;
- double lenghtPart = Geom::length(d2_in, Geom::EPSILON);
- if (A > lenghtPart || d2_in[0].degreesOfFreedom() == 2) {
- s = (A * lenghtPart);
- } else if (d2_in[0].degreesOfFreedom() != 2) {
- Geom::Piecewise<Geom::D2<Geom::SBasis> > u;
- u.push_cut(0);
- u.push(d2_in, 1);
- u = Geom::portion(u, 0.0, A);
- s = Geom::length(u, 0.001);
- }
- return s;
-}
-
-double
-Satellite::getOpositeTime(double s, Geom::D2<Geom::SBasis> d2_in) const
-{
- if(s == 0){
- return 1;
- }
- double lenghtPart = Geom::length(d2_in, Geom::EPSILON);
- double size = lenghtPart - s;
- return toTime(size, d2_in);
-}
-
-double
-Satellite::getTime(Geom::D2<Geom::SBasis> d2_in) const
-{
- double t = getAmount();
- if(!getIsTime()){
- t = toTime(t, d2_in);
- }
- if(t > 1){
- t = 1;
- }
- return t;
-}
-
-double
-Satellite::getSize(Geom::D2<Geom::SBasis> d2_in) const
-{
- double s = getAmount();
- if(getIsTime()){
- s = toSize(s, d2_in);
- }
- return s;
-}
-
-
-Geom::Point
-Satellite::getPosition(Geom::D2<Geom::SBasis> d2_in) const
-{
- double t = getTime(d2_in);
- return d2_in.valueAt(t);
-}
-
-void
-Satellite::setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in)
-{
- double A = Geom::nearest_point(p, d2_in);
- if(!getIsTime()){
- A = toSize(A, d2_in);
- }
- setAmount(A);
-}
-
-} // end namespace Geom
-
-/*
- Local Variables:
- mode:c++
- c-file-style:"stroustrup"
- c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
- indent-tabs-mode:nil
- fill-column:99
- End:
-*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/helper/Makefile_insert b/src/helper/Makefile_insert
index e59fcfb70..1d051734e 100644
--- a/src/helper/Makefile_insert
+++ b/src/helper/Makefile_insert
@@ -12,8 +12,15 @@ ink_common_sources += \
helper/geom-curves.h \
helper/geom-nodetype.cpp \
helper/geom-nodetype.h \
+ helper/geom-pathinfo.cpp \
+ helper/geom-pathinfo.h \
helper/geom-pathstroke.cpp \
helper/geom-pathstroke.h \
+ helper/geom-pointwise.cpp \
+ helper/geom-pointwise.h \
+ helper/geom-satellite.cpp \
+ helper/geom-satellite.h \
+ helper/geom-satellite-enum.h \
helper/gnome-utils.cpp \
helper/gnome-utils.h \
helper/mathfns.h \
diff --git a/src/helper/geom-pathinfo.cpp b/src/helper/geom-pathinfo.cpp
new file mode 100644
index 000000000..c8ba01bd0
--- /dev/null
+++ b/src/helper/geom-pathinfo.cpp
@@ -0,0 +1,178 @@
+/*
+ * pathinfo.cpp
+ * Authors:
+ * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es>
+ * 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
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, output to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ */
+
+#include <helper/geom-pathinfo.h>
+#include <2geom/sbasis-to-bezier.h>
+
+namespace Geom {
+
+Pathinfo::Pathinfo(Piecewise<D2<SBasis> > pwd2)
+ : _pwd2(pwd2)
+{
+ setPathInfo();
+};
+
+Pathinfo::~Pathinfo(){};
+
+Piecewise<D2<SBasis> >
+Pathinfo::getPwd2() const
+{
+ return _pwd2;
+}
+
+void
+Pathinfo::setPwd2(Piecewise<D2<SBasis> > pwd2_in)
+{
+ _pwd2 = pwd2_in;
+ setPathInfo();
+}
+
+
+void
+Pathinfo::setPathInfo()
+{
+ _pathInfo.clear();
+ std::vector<Geom::Path> path_in = path_from_piecewise(remove_short_cuts(_pwd2,0.1), 0.001);
+ size_t counter = 0;
+ for (PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) {
+ if (path_it->empty()){
+ continue;
+ }
+ Geom::Path::const_iterator curve_it1 = path_it->begin();
+ Geom::Path::const_iterator curve_endit = path_it->end_default();
+ if (path_it->closed()) {
+ const Curve &closingline = path_it->back_closed();
+ if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
+ curve_endit = path_it->end_open();
+ }
+ }
+ while (curve_it1 != curve_endit) {
+ ++curve_it1;
+ counter++;
+ }
+ if(path_it->closed()){
+ _pathInfo.push_back(std::make_pair(counter-1,true));
+ } else {
+ _pathInfo.push_back(std::make_pair(counter-1,false));
+ }
+ }
+}
+
+size_t
+Pathinfo::getSubPathIndex(size_t index) const
+{
+ for(size_t i = 0; i < _pathInfo.size(); i++){
+ if(index <= _pathInfo[i].first){
+ return i;
+ }
+ }
+ return 0;
+}
+
+size_t
+Pathinfo::getLast(size_t index) const
+{
+ for(size_t i = 0; i < _pathInfo.size(); i++){
+ if(index <= _pathInfo[i].first){
+ return _pathInfo[i].first;
+ }
+ }
+ return 0;
+}
+
+size_t
+Pathinfo::getFirst(size_t index) const
+{
+ for(size_t i = 0; i < _pathInfo.size(); i++){
+ if(index <= _pathInfo[i].first){
+ if(i==0){
+ return 0;
+ } else {
+ return _pathInfo[i-1].first + 1;
+ }
+ }
+ }
+ return 0;
+}
+
+boost::optional<size_t>
+Pathinfo::getPrevious(size_t index) const
+{
+ if(getFirst(index) == index && getIsClosed(index)){
+ return getLast(index);
+ }
+ if(getFirst(index) == index && !getIsClosed(index)){
+ return boost::none;
+ }
+ return index - 1;
+}
+
+boost::optional<size_t>
+Pathinfo::getNext(size_t index) const
+{
+ if(getLast(index) == index && getIsClosed(index)){
+ return getFirst(index);
+ }
+ if(getLast(index) == index && !getIsClosed(index)){
+ return boost::none;
+ }
+ return index + 1;
+}
+
+bool
+Pathinfo::getIsClosed(size_t index) const
+{
+ for(size_t i = 0; i < _pathInfo.size(); i++){
+ if(index <= _pathInfo[i].first){
+ return _pathInfo[i].second;
+ }
+ }
+ return false;
+}
+
+std::vector<std::pair<size_t, bool> >
+Pathinfo::getPathInfo() const
+{
+ return _pathInfo;
+}
+
+}; // namespace Geom
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/helper/geom-pathinfo.h b/src/helper/geom-pathinfo.h
new file mode 100644
index 000000000..1696fd366
--- /dev/null
+++ b/src/helper/geom-pathinfo.h
@@ -0,0 +1,81 @@
+/**
+ * \file
+ * \brief Pathinfo
+ *//*
+ * Authors:
+ * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es>
+ * Copyright 2015 authors
+ *
+ * Pathinfo maintains ....
+ * 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
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, output to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ */
+
+#ifndef SEEN_GEOM_PATHINFO_H
+#define SEEN_GEOM_PATHINFO_H
+
+#include <2geom/path.h>
+#include <boost/optional.hpp>
+
+namespace Geom {
+
+/**
+ * %Pathinfo function class.
+ */
+
+class Pathinfo
+{
+ public:
+ Pathinfo(Piecewise<D2<SBasis> > pwd2);
+ virtual ~Pathinfo();
+ Piecewise<D2<SBasis> > getPwd2() const;
+ void setPwd2(Piecewise<D2<SBasis> > pwd2_in);
+ size_t getSubPathIndex(size_t index) const;
+ size_t getLast(size_t index) const;
+ size_t getFirst(size_t index) const;
+ boost::optional<size_t> getPrevious(size_t index) const;
+ boost::optional<size_t> getNext(size_t index) const;
+ bool getIsClosed(size_t index) const;
+ std::vector<std::pair<size_t, bool> > getPathInfo() const;
+
+ private:
+ void setPathInfo();
+ Piecewise<D2<SBasis> > _pwd2;
+ std::vector<std::pair<size_t, bool> > _pathInfo;
+};
+
+} //namespace Geom
+
+
+#endif //SEEN_GEOM_PATHINFO_H
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/helper/geom-pointwise.cpp b/src/helper/geom-pointwise.cpp
new file mode 100644
index 000000000..4926bcc47
--- /dev/null
+++ b/src/helper/geom-pointwise.cpp
@@ -0,0 +1,268 @@
+/*
+ * pointwise.cpp
+ * Authors:
+ * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es>
+ * 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
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, output to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ */
+
+#include <helper/geom-pointwise.h>
+#include <cmath>
+
+namespace Geom {
+
+Pointwise::Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<Satellite> satellites)
+ : _pwd2(pwd2), _satellites(satellites), _pathInfo(pwd2)
+{
+};
+
+Pointwise::~Pointwise(){};
+
+Piecewise<D2<SBasis> >
+Pointwise::getPwd2() const
+{
+ return _pwd2;
+}
+
+void
+Pointwise::setPwd2(Piecewise<D2<SBasis> > pwd2_in)
+{
+ _pwd2 = pwd2_in;
+ _pathInfo.setPwd2(_pwd2);
+}
+
+std::vector<Satellite>
+Pointwise::getSatellites() const
+{
+ return _satellites;
+}
+
+void
+Pointwise::setSatellites(std::vector<Satellite> sats)
+{
+ _satellites = sats;
+}
+
+void
+Pointwise::recalculate_for_new_pwd2(Piecewise<D2<SBasis> > A)
+{
+ if( _pwd2.size() > A.size()){
+ pwd2_sustract(A);
+ } else if (_pwd2.size() < A.size()){
+ pwd2_append(A);
+ }
+}
+
+void
+Pointwise::pwd2_append(Piecewise<D2<SBasis> > A)
+{
+ size_t counter = 0;
+ std::vector<Satellite> sats;
+ bool reversed = false;
+ bool reorder = false;
+ for(size_t i = 0; i < A.size(); i++){
+ size_t first = _pathInfo.getFirst(i-counter);
+ size_t last = _pathInfo.getLast(i-counter);
+ _pathInfo.setPwd2(A);
+ size_t subpathAIndex = _pathInfo.getSubPathIndex(i);
+ _pathInfo.setPwd2(_pwd2);
+ bool changedSubpath = false;
+ if(_pwd2.size() <= i-counter){
+ changedSubpath = false;
+ } else {
+ changedSubpath = subpathAIndex != _pathInfo.getSubPathIndex(i-counter);
+ }
+ if(!reorder && first == i-counter && !are_near(_pwd2[i-counter].at0(),A[i].at0(),0.001) && !changedSubpath){
+ subpath_append_reorder(_pathInfo.getSubPathIndex(first));
+ reorder = true;
+ i--;
+ continue;
+ }
+ if(!reversed && first == i-counter && !are_near(_pwd2[i-counter].at0(),A[i].at0(),0.001) && !changedSubpath){
+ reverse(first, last);
+ reversed = true;
+ }
+ if(_pwd2.size() <= i-counter || !are_near(_pwd2[i-counter].at0(),A[i].at0(),0.001)){
+ counter++;
+ bool active = true;
+ bool hidden = false;
+ bool isTime = _satellites[0].isTime;
+ bool mirror_knots = _satellites[0].hasMirror;
+ double amount = 0.0;
+ double degrees = 0.0;
+ int steps = 0;
+ Satellite sat(_satellites[0].satelliteType, isTime, active, mirror_knots, hidden, amount, degrees, steps);
+ sats.push_back(sat);
+ } else {
+ sats.push_back(_satellites[i-counter]);
+ }
+ }
+ setPwd2(A);
+ setSatellites(sats);
+}
+
+void
+Pointwise::pwd2_sustract(Piecewise<D2<SBasis> > A)
+{
+ size_t counter = 0;
+ std::vector<Satellite> sats;
+ Piecewise<D2<SBasis> > pwd2 = _pwd2;
+ setPwd2(A);
+ for(size_t i = 0; i < _satellites.size(); i++){
+ if(_pathInfo.getLast(i-counter) < i-counter || !are_near(pwd2[i].at0(),A[i-counter].at0(),0.001)){
+ counter++;
+ } else {
+ sats.push_back(_satellites[i-counter]);
+ }
+ }
+ setSatellites(sats);
+}
+
+void
+Pointwise::set_extremes(bool active, bool hidden, double amount, double angle)
+{
+ std::vector<std::pair<size_t, bool> > pathInfo = _pathInfo.getPathInfo();
+ for(size_t i = 0; i < pathInfo.size(); i++){
+ size_t firstNode = _pathInfo.getFirst(pathInfo[i].first);
+ size_t lastNode = _pathInfo.getLast(pathInfo[i].first);
+ if(!_pathInfo.getIsClosed(lastNode)){
+ for(size_t j = 0; j < _satellites.size(); j++){
+ if(j < firstNode || j > lastNode){
+ continue;
+ }
+ if(j == firstNode){
+ _satellites[j].active = active;
+ _satellites[j].hidden = hidden;
+ if(amount >= 0){
+ _satellites[j].amount = amount;
+ }
+ if(angle >= 0){
+ _satellites[j].angle = angle;
+ }
+ }
+ }
+ } else {
+ for(size_t j = 0; j < _satellites.size(); j++){
+ if(j < firstNode){
+ continue;
+ }
+ if(j == firstNode && !_satellites[j].active){
+ _satellites[j].active = true;
+ _satellites[j].hidden = _satellites[j+1].hidden;
+ }
+
+ }
+ }
+ }
+}
+
+void
+Pointwise::subpath_append_reorder(size_t subpath){
+ std::vector<Geom::Path> path_in = path_from_piecewise(remove_short_cuts(_pwd2,0.1), 0.001);
+ size_t nSubpath = 0;
+ size_t counter = 0;
+ std::vector<Geom::Path> tmp_path;
+ Geom::Path rev;
+ for (PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) {
+ if (path_it->empty()){
+ continue;
+ }
+ Geom::Path::const_iterator curve_it1 = path_it->begin();
+ Geom::Path::const_iterator curve_endit = path_it->end_default();
+ const Curve &closingline = path_it->back_closed();
+ if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
+ curve_endit = path_it->end_open();
+ }
+ while (curve_it1 != curve_endit) {
+ if(nSubpath == subpath){
+ _satellites.push_back(_satellites[counter]);
+ deleteSatellite(counter);
+ } else {
+ counter++;
+ }
+ ++curve_it1;
+ }
+ if(nSubpath == subpath){
+ rev = *path_it;
+ } else {
+ tmp_path.push_back(*path_it);
+ }
+ nSubpath++;
+ }
+ tmp_path.push_back(rev);
+ setPwd2(remove_short_cuts(paths_to_pw(tmp_path),0.01));
+}
+
+void
+Pointwise::reverse(size_t start,size_t end){
+ start ++;
+ for(size_t i = end; i >= start; i--){
+ _satellites.push_back(_satellites[i]);
+ deleteSatellite(i);
+ }
+ std::vector<Geom::Path> path_in = path_from_piecewise(remove_short_cuts(_pwd2,0.1), 0.001);
+ size_t counter = 0;
+ size_t nSubpath = 0;
+ size_t subpath = _pathInfo.getSubPathIndex(start);
+ std::vector<Geom::Path> tmp_path;
+ Geom::Path rev;
+ for (PathVector::const_iterator path_it = path_in.begin(); path_it != path_in.end(); ++path_it) {
+ if (path_it->empty()){
+ continue;
+ }
+ counter ++;
+ if(nSubpath == subpath){
+ tmp_path.push_back(path_it->reverse());
+ } else {
+ tmp_path.push_back(*path_it);
+ }
+ nSubpath++;
+ }
+ setPwd2(remove_short_cuts(paths_to_pw(tmp_path),0.01));
+}
+
+void
+Pointwise::deleteSatellite(size_t A)
+{
+ for (std::vector<Satellite>::iterator it = _satellites.begin(); it != _satellites.end();)
+ {
+ if((unsigned)(it - _satellites.begin()) == A){
+ it = _satellites.erase(it);
+ }
+ }
+}
+
+} // namespace Geom
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/2geom/pointwise.h b/src/helper/geom-pointwise.h
index 0eb7c7073..8b5c275b9 100644
--- a/src/2geom/pointwise.h
+++ b/src/helper/geom-pointwise.h
@@ -47,10 +47,10 @@
#include <2geom/sbasis.h>
#include <2geom/sbasis-2d.h>
#include <2geom/piecewise.h>
-#include <2geom/satellite.h>
+#include <helper/geom-satellite.h>
+#include <helper/geom-pathinfo.h>
#include <2geom/sbasis-to-bezier.h>
#include <2geom/path.h>
-#include "helper/geom.h"
#include <boost/optional.hpp>
namespace Geom {
@@ -61,36 +61,24 @@ namespace Geom {
class Pointwise
{
public:
- Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<size_t,Satellite> > satellites);
+ Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<Satellite> satellites);
virtual ~Pointwise();
- std::vector<size_t> findSatellites(size_t A, long B = -1) const;
- std::vector<size_t> findPeviousSatellites(size_t A, long B) const;
- double rad_to_len(double A, std::pair<size_t,Geom::Satellite> sat) const;
- double len_to_rad(double A, std::pair<size_t,Geom::Satellite> sat) const;
- std::vector<std::pair<size_t,Satellite> > getSatellites() const;
- void setSatellites(std::vector<std::pair<size_t,Satellite> > sats);
+ std::vector<Satellite> getSatellites() const;
+ void setSatellites(std::vector<Satellite> sats);
Piecewise<D2<SBasis> > getPwd2() const;
void setPwd2(Piecewise<D2<SBasis> > pwd2_in);
void recalculate_for_new_pwd2(Piecewise<D2<SBasis> > A);
void pwd2_append(Piecewise<D2<SBasis> > A);
void pwd2_sustract(Piecewise<D2<SBasis> > A);
void set_extremes(bool active, bool hidden, double amount = -1, double angle = -1);
- void deleteSatellites(size_t A);
+ void deleteSatellite(size_t A);
void subpath_append_reorder(size_t subpath);
void reverse(size_t start,size_t end);
- void setPathInfo();
- void setPathInfo(Piecewise<D2<SBasis> >);
- size_t getSubPathIndex(size_t index) const;
- size_t getLast(size_t index) const;
- size_t getFirst(size_t index) const;
- boost::optional<size_t> getPrevious(size_t index) const;
- boost::optional<size_t> getNext(size_t index) const;
- bool getIsClosed(size_t index) const;
private:
Piecewise<D2<SBasis> > _pwd2;
- std::vector<std::pair<size_t,Satellite> > _satellites;
- std::vector<std::pair<size_t, bool> > _pathInfo;
+ std::vector<Satellite> _satellites;
+ Pathinfo _pathInfo;
};
} // end namespace Geom
diff --git a/src/2geom/satellite-enum.h b/src/helper/geom-satellite-enum.h
index bcd8d1bb3..bcd8d1bb3 100644
--- a/src/2geom/satellite-enum.h
+++ b/src/helper/geom-satellite-enum.h
diff --git a/src/helper/geom-satellite.cpp b/src/helper/geom-satellite.cpp
new file mode 100644
index 000000000..73201445a
--- /dev/null
+++ b/src/helper/geom-satellite.cpp
@@ -0,0 +1,237 @@
+/**
+ * \file
+ * \brief Satellite
+ *//*
+ * Authors:
+ * 2015 Jabier Arraiza Cenoz<jabier.arraiza@marker.es>
+ * 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
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ */
+
+#include <helper/geom-satellite.h>
+#include <2geom/curve.h>
+#include <2geom/nearest-point.h>
+#include <2geom/sbasis-geometric.h>
+#include <2geom/path-intersection.h>
+#include <2geom/sbasis-to-bezier.h>
+#include <2geom/ray.h>
+#include <boost/optional.hpp>
+
+
+namespace Geom {
+
+Satellite::Satellite(){};
+
+Satellite::Satellite(SatelliteType satelliteType, bool isTime, bool active, bool hasMirror, bool hidden, double amount, double angle, size_t steps)
+ : satelliteType(satelliteType), isTime(isTime), active(active), hasMirror(hasMirror), hidden(hidden), amount(amount), angle(angle), steps(steps){};
+
+Satellite::~Satellite() {};
+
+double
+Satellite::toTime(double A,Geom::D2<Geom::SBasis> d2_in) const
+{
+ if(!d2_in.isFinite() || d2_in.isZero() || A == 0){
+ return 0;
+ }
+ double t = 0;
+ double lenghtPart = Geom::length(d2_in, Geom::EPSILON);
+ if (A > lenghtPart || d2_in[0].degreesOfFreedom() == 2) {
+ if (lenghtPart != 0) {
+ t = A / lenghtPart;
+ }
+ } else if (d2_in[0].degreesOfFreedom() != 2) {
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > u;
+ u.push_cut(0);
+ u.push(d2_in, 1);
+ std::vector<double> t_roots = roots(arcLengthSb(u) - A);
+ if (t_roots.size() > 0) {
+ t = t_roots[0];
+ }
+ }
+
+ return t;
+}
+
+double
+Satellite::toSize(double A,Geom::D2<Geom::SBasis> d2_in) const
+{
+ if(!d2_in.isFinite() || d2_in.isZero() || A == 0){
+ return 0;
+ }
+ double s = 0;
+ double lenghtPart = Geom::length(d2_in, Geom::EPSILON);
+ if (A > lenghtPart || d2_in[0].degreesOfFreedom() == 2) {
+ s = (A * lenghtPart);
+ } else if (d2_in[0].degreesOfFreedom() != 2) {
+ Geom::Piecewise<Geom::D2<Geom::SBasis> > u;
+ u.push_cut(0);
+ u.push(d2_in, 1);
+ u = Geom::portion(u, 0.0, A);
+ s = Geom::length(u, 0.001);
+ }
+ return s;
+}
+
+
+double
+Satellite::rad_to_len(double A, boost::optional<Geom::D2<Geom::SBasis> > d2_in, Geom::D2<Geom::SBasis> d2_out, boost::optional<Geom::Satellite> previousSatellite) const
+{
+ double len = 0;
+ if(d2_in && previousSatellite){
+ Piecewise<D2<SBasis> > offset_curve0 = Piecewise<D2<SBasis> >(*d2_in)+rot90(unitVector(derivative(*d2_in)))*(A);
+ Piecewise<D2<SBasis> > offset_curve1 = Piecewise<D2<SBasis> >(d2_out)+rot90(unitVector(derivative(d2_out)))*(A);
+ Geom::Path p0 = path_from_piecewise(offset_curve0, 0.1)[0];
+ Geom::Path p1 = path_from_piecewise(offset_curve1, 0.1)[0];
+ Geom::Crossings cs = Geom::crossings(p0, p1);
+ if(cs.size() > 0){
+ Point cp =p0(cs[0].ta);
+ double p0pt = nearest_point(cp, d2_out);
+ len = (*previousSatellite).toSize(p0pt,d2_out);
+ } else {
+ if(A > 0){
+ len = rad_to_len(A * -1, *d2_in, d2_out, previousSatellite);
+ }
+ }
+ }
+ return len;
+}
+
+double
+Satellite::len_to_rad(double A, boost::optional<Geom::D2<Geom::SBasis> > d2_in, Geom::D2<Geom::SBasis> d2_out, boost::optional<Geom::Satellite> previousSatellite) const
+{
+ if(d2_in && previousSatellite){
+ double time_in = (*previousSatellite).getOpositeTime(A, *d2_in);
+ double time_out = (*previousSatellite).toTime(A,d2_out);
+ Geom::Point startArcPoint = (*d2_in).valueAt(time_in);
+ Geom::Point endArcPoint = d2_out.valueAt(time_out);
+ Piecewise<D2<SBasis> > u;
+ u.push_cut(0);
+ u.push(*d2_in, 1);
+ Geom::Curve * C = path_from_piecewise(u, 0.1)[0][0].duplicate();
+ Piecewise<D2<SBasis> > u2;
+ u2.push_cut(0);
+ u2.push(d2_out, 1);
+ Geom::Curve * D = path_from_piecewise(u2, 0.1)[0][0].duplicate();
+ Curve *knotCurve1 = C->portion(0, time_in);
+ Curve *knotCurve2 = D->portion(time_out, 1);
+ Geom::CubicBezier const *cubic1 = dynamic_cast<Geom::CubicBezier const *>(&*knotCurve1);
+ Ray ray1(startArcPoint, (*d2_in).valueAt(1));
+ if (cubic1) {
+ ray1.setPoints((*cubic1)[2], startArcPoint);
+ }
+ Geom::CubicBezier const *cubic2 = dynamic_cast<Geom::CubicBezier const *>(&*knotCurve2);
+ Ray ray2(d2_out.valueAt(0), endArcPoint);
+ if (cubic2) {
+ ray2.setPoints(endArcPoint, (*cubic2)[1]);
+ }
+ bool ccwToggle = cross((*d2_in).valueAt(1) - startArcPoint, endArcPoint - startArcPoint) < 0;
+ double distanceArc = Geom::distance(startArcPoint,middle_point(startArcPoint,endArcPoint));
+ double angleBetween = angle_between(ray1, ray2, ccwToggle);
+ double divisor = std::sin(angleBetween/2.0);
+ if(divisor > 0){
+ return distanceArc/divisor;
+ }
+ }
+ return 0;
+}
+
+double
+Satellite::getOpositeTime(double s, Geom::D2<Geom::SBasis> d2_in) const
+{
+ if(s == 0){
+ return 1;
+ }
+ double lenghtPart = Geom::length(d2_in, Geom::EPSILON);
+ double size = lenghtPart - s;
+ return toTime(size, d2_in);
+}
+
+double
+Satellite::getTime(Geom::D2<Geom::SBasis> d2_in) const
+{
+ double t = amount;
+ if(!isTime){
+ t = toTime(t, d2_in);
+ }
+ if(t > 1){
+ t = 1;
+ }
+ return t;
+}
+
+double
+Satellite::getSize(Geom::D2<Geom::SBasis> d2_in) const
+{
+ double s = amount;
+ if(isTime){
+ s = toSize(s, d2_in);
+ }
+ return s;
+}
+
+
+Geom::Point
+Satellite::getPosition(Geom::D2<Geom::SBasis> d2_in) const
+{
+ double t = getTime(d2_in);
+ return d2_in.valueAt(t);
+}
+
+void
+Satellite::setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in)
+{
+ double A = Geom::nearest_point(p, d2_in);
+ if(!isTime){
+ A = toSize(A, d2_in);
+ }
+ amount = A;
+}
+
+void
+Satellite::setSatelliteType(gchar const * A)
+{
+ std::map<std::string,SatelliteType> GcharMapToSatelliteType = boost::assign::map_list_of("F", F)("IF", IF)("C",C)("IC",IC)("KO",KO);
+ satelliteType = GcharMapToSatelliteType.find(std::string(A))->second;
+}
+
+gchar const *
+Satellite::getSatelliteTypeGchar() const
+{
+ std::map<SatelliteType,gchar const *> SatelliteTypeToGcharMap = boost::assign::map_list_of(F, "F")(IF, "IF")(C,"C")(IC,"IC")(KO,"KO");
+ return SatelliteTypeToGcharMap.at(satelliteType);
+}
+
+} //namespace Geom
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
diff --git a/src/2geom/satellite.h b/src/helper/geom-satellite.h
index 42ed9c291..f367bb7f3 100644
--- a/src/2geom/satellite.h
+++ b/src/helper/geom-satellite.h
@@ -33,7 +33,7 @@
#ifndef LIB2GEOM_SEEN_SATELLITE_H
#define LIB2GEOM_SEEN_SATELLITE_H
-#include <2geom/satellite-enum.h>
+#include <helper/geom-satellite-enum.h>
#include <2geom/d2.h>
#include <map>
#include <boost/assign.hpp>
@@ -45,131 +45,30 @@ class Satellite
public:
Satellite();
- Satellite(SatelliteType satellitetype, bool isTime, bool isEndOpen, bool active, bool hasMirror, bool hidden, double amount, double angle, size_t steps);
+ Satellite(SatelliteType satelliteType, bool isTime, bool active, bool hasMirror, bool hidden, double amount, double angle, size_t steps);
virtual ~Satellite();
- void setSatelliteType(SatelliteType A)
- {
- _satellitetype = A;
- }
-
- void setSatelliteType(gchar const * A)
- {
- std::map<std::string,SatelliteType> GcharMapToSatelliteType = boost::assign::map_list_of("F", F)("IF", IF)("C",C)("IC",IC)("KO",KO);
- _satellitetype = GcharMapToSatelliteType.find(std::string(A))->second;
- }
-
- void setIsTime(bool A)
- {
- _isTime = A;
- }
-
- void setIsEndOpen(bool A)
- {
- _isEndOpen = A;
- }
-
-
- void setActive(bool A)
- {
- _active = A;
- }
-
- void setHasMirror(bool A)
- {
- _hasMirror = A;
- }
-
- void setHidden(bool A)
- {
- _hidden = A;
- }
- void setAmount(double A)
- {
- _amount = A;
- }
-
- void setAngle(double A)
- {
- _angle = A;
- }
-
- void setSteps(int A)
- {
- _steps = A;
- }
-
- SatelliteType getSatelliteType() const
- {
- return _satellitetype;
- }
-
- gchar const * getSatelliteTypeGchar() const
- {
- std::map<SatelliteType,gchar const *> SatelliteTypeToGcharMap = boost::assign::map_list_of(F, "F")(IF, "IF")(C,"C")(IC,"IC")(KO,"KO");
- return SatelliteTypeToGcharMap.at(_satellitetype);
- }
-
- bool getIsTime() const
- {
- return _isTime;
- }
-
- bool getIsEndOpen() const
- {
- return _isEndOpen;
- }
-
- bool getActive() const
- {
- return _active;
- }
-
- bool getHasMirror() const
- {
- return _hasMirror;
- }
-
- bool getHidden() const
- {
- return _hidden;
- }
-
- double getAmount() const
- {
- return _amount;
- }
-
- double getAngle() const
- {
- return _angle;
- }
-
- int getSteps() const
- {
- return _steps;
- }
-
void setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in);
- Geom::Point getPosition(Geom::D2<Geom::SBasis> curve) const;
+ Geom::Point getPosition(Geom::D2<Geom::SBasis> d2_in) const;
double getSize(Geom::D2<Geom::SBasis> d2_in) const;
double getTime(Geom::D2<Geom::SBasis> d2_in) const;
double getOpositeTime(double A,Geom::D2<Geom::SBasis> SBasisCurve) const;
double toSize(double A,Geom::D2<Geom::SBasis> d2_in) const;
double toTime(double A,Geom::D2<Geom::SBasis> d2_in) const;
-
- private:
-
- SatelliteType _satellitetype;
- bool _isTime;
- bool _isEndOpen;
- bool _active;
- bool _hasMirror;
- bool _hidden;
- double _amount;
- double _angle;
- size_t _steps;
+ double len_to_rad(double A, boost::optional<Geom::D2<Geom::SBasis> > d2_in, Geom::D2<Geom::SBasis> d2_out, boost::optional<Geom::Satellite> previousSatellite) const;
+ double rad_to_len(double A, boost::optional<Geom::D2<Geom::SBasis> > d2_in, Geom::D2<Geom::SBasis> d2_out, boost::optional<Geom::Satellite> previousSatellite) const;
+ void setSatelliteType(gchar const * A);
+ gchar const * getSatelliteTypeGchar() const;
+
+ SatelliteType satelliteType;
+ bool isTime;
+ bool active;
+ bool hasMirror;
+ bool hidden;
+ double amount;
+ double angle;
+ size_t steps;
};
} // end namespace Geom
diff --git a/src/live_effects/CMakeLists.txt b/src/live_effects/CMakeLists.txt
index 3af27a220..7bafb356d 100644
--- a/src/live_effects/CMakeLists.txt
+++ b/src/live_effects/CMakeLists.txt
@@ -62,7 +62,7 @@ set(live_effects_SRC
parameter/path-reference.cpp
parameter/point.cpp
parameter/powerstrokepointarray.cpp
- parameter/satellitepairarray.cpp
+ parameter/satellitearray.cpp
parameter/random.cpp
parameter/text.cpp
paramter/transformedpoint.cpp
@@ -138,7 +138,7 @@ set(live_effects_SRC
parameter/originalpatharray.h
parameter/point.h
parameter/powerstrokepointarray.h
- parameter/satellitepairarray.h
+ parameter/satellitearray.h
parameter/random.h
parameter/text.h
parameter/togglebutton.h
diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp
index 6775fa000..54b2fb52f 100644
--- a/src/live_effects/lpe-fillet-chamfer.cpp
+++ b/src/live_effects/lpe-fillet-chamfer.cpp
@@ -16,13 +16,15 @@
#include "live_effects/lpe-fillet-chamfer.h"
-#include <2geom/satellite.h>
-#include <2geom/satellite-enum.h>
#include "helper/geom.h"
#include "display/curve.h"
#include "helper/geom-curves.h"
+#include "helper/geom-satellite.h"
+#include "helper/geom-satellite-enum.h"
+#include "helper/geom-pathinfo.h"
#include <2geom/svg-elliptical-arc.h>
#include "knotholder.h"
+#include <boost/optional.hpp>
// TODO due to internal breakage in glibmm headers, this must be last:
#include <glibmm/i18n.h>
@@ -40,7 +42,7 @@ FMConverter(FilletMethodData, FM_END);
LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) :
Effect(lpeobject),
- satellitepairarrayparam_values(_("pair_array_param"), _("pair_array_param"), "satellitepairarrayparam_values", &wr, this),
+ satellitearrayparam_values(_("pair_array_param"), _("pair_array_param"), "satellitearrayparam_values", &wr, this),
unit(_("Unit:"), _("Unit"), "unit", &wr, this),
method(_("Method:"), _("Methods to calculate the fillet or chamfer"), "method", FMConverter, &wr, this, FM_AUTO),
radius(_("Radius (unit or %):"), _("Radius, in unit or %"), "radius", &wr, this, 0.),
@@ -55,7 +57,7 @@ LPEFilletChamfer::LPEFilletChamfer(LivePathEffectObject *lpeobject) :
pointwise(NULL),
segCount(0)
{
- registerParameter(&satellitepairarrayparam_values);
+ registerParameter(&satellitearrayparam_values);
registerParameter(&unit);
registerParameter(&method);
registerParameter(&radius);
@@ -91,7 +93,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
Piecewise<D2<SBasis> > pwd2_in = paths_to_pw(original_pathv);
pwd2_in = remove_short_cuts(pwd2_in, 0.01);
int counterTotal = 0;
- std::vector<std::pair<size_t,Geom::Satellite> > satellites;
+ std::vector<Geom::Satellite> satellites;
for (PathVector::const_iterator path_it = original_pathv.begin(); path_it != original_pathv.end(); ++path_it) {
if (path_it->empty()){
continue;
@@ -121,7 +123,6 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
item->removeCurrentPathEffect(false);
return;
}
- bool isEndOpen = false;
bool active = true;
bool hidden = false;
if (counter==0) {
@@ -129,22 +130,15 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem)
active = false;
}
}
- Satellite satellite(F, flexible, isEndOpen, active, mirror_knots, hidden, 0.0, 0.0, steps);
- satellites.push_back(std::make_pair(counterTotal, satellite));
+ Satellite satellite(F, flexible, active, mirror_knots, hidden, 0.0, 0.0, steps);
+ satellites.push_back(satellite);
++curve_it1;
counter++;
counterTotal++;
}
- if (!path_it->closed()){
- bool active = false;
- bool isEndOpen = true;
- bool hidden = true;
- Satellite satellite(F, flexible, isEndOpen, active, mirror_knots, hidden, 0.0, 0.0, steps);
- satellites.push_back(std::make_pair(counterTotal-1, satellite));
- }
}
pointwise = new Pointwise( pwd2_in,satellites);
- satellitepairarrayparam_values.set_pointwise(pointwise);
+ satellitearrayparam_values.set_pointwise(pointwise);
} else {
g_warning("LPE Fillet/Chamfer can only be applied to shapes (not groups).");
SPLPEItem * item = const_cast<SPLPEItem*>(lpeItem);
@@ -253,8 +247,8 @@ void LPEFilletChamfer::inverseChamfer()
void LPEFilletChamfer::refreshKnots()
{
- if(satellitepairarrayparam_values.knoth){
- satellitepairarrayparam_values.knoth->update_knots();
+ if(satellitearrayparam_values.knoth){
+ satellitearrayparam_values.knoth->update_knots();
}
}
@@ -266,81 +260,85 @@ void LPEFilletChamfer::updateAmount()
} else {
power = radius/100;
}
- std::vector<std::pair<size_t,Geom::Satellite> > satellites = pointwise->getSatellites();
+ std::vector<Geom::Satellite> satellites = pointwise->getSatellites();
Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2();
- for (std::vector<std::pair<size_t,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
- if(!pointwise->getIsClosed(it->first) && pointwise->getFirst(it->first) == it->first){
- it->second.setAmount(0);
+ Pathinfo pathInfo(pwd2);
+ for (std::vector<Geom::Satellite>::iterator it = satellites.begin(); it != satellites.end(); ++it) {
+ if(!pathInfo.getIsClosed(it - satellites.begin()) && pathInfo.getFirst(it - satellites.begin()) == (unsigned)(it - satellites.begin())){
+ it->amount = 0;
continue;
}
- if(ignore_radius_0 && it->second.getAmount() == 0){
+ if(ignore_radius_0 && it->amount == 0){
continue;
}
-
+ boost::optional<size_t> prev = pathInfo.getPrevious(it - satellites.begin());
+ boost::optional<Geom::D2<Geom::SBasis> > prevPwd2 = boost::none;
+ boost::optional<Geom::Satellite > prevSat = boost::none;
+ if(prev){
+ prevPwd2 = pwd2[*prev];
+ prevSat = satellites[*prev];
+ }
if(only_selected){
- Geom::Point satPoint = pwd2.valueAt(it->first);
+ Geom::Point satPoint = pwd2.valueAt(it - satellites.begin());
if(isNodePointSelected(satPoint)){
if(!use_knot_distance && !flexible){
- it->second.setAmount(pointwise->rad_to_len(power,*it));
+ it->amount = it->rad_to_len(power, prevPwd2, pwd2[it - satellites.begin()], prevSat);
} else {
- it->second.setAmount(power);
+ it->amount = power;
}
}
} else {
if(!use_knot_distance && !flexible){
- it->second.setAmount(pointwise->rad_to_len(power,*it));
+ it->amount = it->rad_to_len(power, prevPwd2, pwd2[it - satellites.begin()], prevSat);
} else {
- it->second.setAmount(power);
+ it->amount = power;
}
}
- if(it->second.getIsEndOpen()){
- it->second.setAmount(0);
- }
}
pointwise->setSatellites(satellites);
- satellitepairarrayparam_values.set_pointwise(pointwise);
+ satellitearrayparam_values.set_pointwise(pointwise);
}
void LPEFilletChamfer::updateChamferSteps()
{
- std::vector<std::pair<size_t,Geom::Satellite> > satellites = pointwise->getSatellites();
+ std::vector<Geom::Satellite> satellites = pointwise->getSatellites();
Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2();
- for (std::vector<std::pair<size_t,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
- if(ignore_radius_0 && it->second.getAmount() == 0){
+ for (std::vector<Geom::Satellite>::iterator it = satellites.begin(); it != satellites.end(); ++it) {
+ if(ignore_radius_0 && it->amount == 0){
continue;
}
if(only_selected){
- Geom::Point satPoint = pwd2.valueAt(it->first);
+ Geom::Point satPoint = pwd2.valueAt(it - satellites.begin());
if(isNodePointSelected(satPoint)){
- it->second.setSteps(chamfer_steps);
+ it->steps = chamfer_steps;
}
} else {
- it->second.setSteps(chamfer_steps);
+ it->steps = chamfer_steps;
}
}
pointwise->setSatellites(satellites);
- satellitepairarrayparam_values.set_pointwise(pointwise);
+ satellitearrayparam_values.set_pointwise(pointwise);
}
void LPEFilletChamfer::updateSatelliteType(Geom::SatelliteType satellitetype)
{
- std::vector<std::pair<size_t,Geom::Satellite> > satellites = pointwise->getSatellites();
+ std::vector<Geom::Satellite> satellites = pointwise->getSatellites();
Piecewise<D2<SBasis> > pwd2 = pointwise->getPwd2();
- for (std::vector<std::pair<size_t,Geom::Satellite> >::iterator it = satellites.begin(); it != satellites.end(); ++it) {
- if(ignore_radius_0 && it->second.getAmount() == 0){
+ for (std::vector<Geom::Satellite>::iterator it = satellites.begin(); it != satellites.end(); ++it) {
+ if(ignore_radius_0 && it->amount == 0){
continue;
}
if(only_selected){
- Geom::Point satPoint = pwd2.valueAt(it->first);
+ Geom::Point satPoint = pwd2.valueAt(it - satellites.begin());
if(isNodePointSelected(satPoint)){
- it->second.setSatelliteType(satellitetype);
+ it->satelliteType = satellitetype;
}
} else {
- it->second.setSatelliteType(satellitetype);
+ it->satelliteType = satellitetype;
}
}
pointwise->setSatellites(satellites);
- satellitepairarrayparam_values.set_pointwise(pointwise);
+ satellitearrayparam_values.set_pointwise(pointwise);
}
void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
@@ -354,51 +352,47 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
c = path->get_original_curve();
}
//fillet chamfer specific calls
- satellitepairarrayparam_values.set_document_unit(defaultUnit);
- satellitepairarrayparam_values.set_use_distance(use_knot_distance);
- satellitepairarrayparam_values.set_unit(unit.get_abbreviation());
+ satellitearrayparam_values.set_document_unit(defaultUnit);
+ satellitearrayparam_values.set_use_distance(use_knot_distance);
+ satellitearrayparam_values.set_unit(unit.get_abbreviation());
//mandatory call
- satellitepairarrayparam_values.set_effect_type(this->effectType());
+ satellitearrayparam_values.set_effect_type(this->effectType());
PathVector const &original_pathv = pathv_to_linear_and_cubic_beziers(c->get_pathvector());
Piecewise<D2<SBasis> > pwd2_in = paths_to_pw(original_pathv);
pwd2_in = remove_short_cuts(pwd2_in, 0.01);
- std::vector<std::pair<size_t,Geom::Satellite> > sats = satellitepairarrayparam_values.data();
+ std::vector<Geom::Satellite> sats = satellitearrayparam_values.data();
//optional call
if(hide_knots){
- satellitepairarrayparam_values.set_helper_size(0);
+ satellitearrayparam_values.set_helper_size(0);
} else {
- satellitepairarrayparam_values.set_helper_size(helper_size);
+ satellitearrayparam_values.set_helper_size(helper_size);
}
bool refresh = false;
bool hide = true;
- for (std::vector<std::pair<size_t,Satellite> >::iterator it = sats.begin(); it != sats.end();)
+ for (std::vector<Satellite>::iterator it = sats.begin(); it != sats.end();)
{
- if(it->second.getIsTime() != flexible){
- it->second.setIsTime(flexible);
- double amount = it->second.getAmount();
- D2<SBasis> d2_in = pwd2_in[it->first];
- if(it->second.getIsTime()){
- double time = it->second.toTime(amount,d2_in);
- it->second.setAmount(time);
+ if(it->isTime != flexible){
+ it->isTime = flexible;
+ double amount = it->amount;
+ D2<SBasis> d2_in = pwd2_in[it - sats.begin()];
+ if(it->isTime){
+ double time = it->toTime(amount,d2_in);
+ it->amount = time;
} else {
- double size = it->second.toSize(amount,d2_in);
- it->second.setAmount(size);
+ double size = it->toSize(amount,d2_in);
+ it->amount = size;
}
}
- if(it->second.getHasMirror() != mirror_knots){
- it->second.setHasMirror(mirror_knots);
+ if(it->hasMirror != mirror_knots){
+ it->hasMirror = mirror_knots;
refresh = true;
}
- if(it->second.getHidden() == false){
+ if(it->hidden == false){
hide = false;
}
- it->second.setHidden(hide_knots);
- if(it->second.getIsEndOpen()){
- it = sats.erase(it);
- } else {
- ++it;
- }
+ it->hidden = hide_knots;
+ ++it;
}
if(hide != hide_knots){
refresh = true;
@@ -414,7 +408,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem)
pointwise->set_extremes(false, true);
segCount = c->get_segment_count();
}
- satellitepairarrayparam_values.set_pointwise(pointwise);
+ satellitearrayparam_values.set_pointwise(pointwise);
if(refresh){
refreshKnots();
}
@@ -429,7 +423,7 @@ LPEFilletChamfer::adjustForNewPath(std::vector<Geom::Path> const &path_in)
if (!path_in.empty() && pointwise) {
pointwise->recalculate_for_new_pwd2(remove_short_cuts(paths_to_pw(pathv_to_linear_and_cubic_beziers(path_in)),0.01));
pointwise->set_extremes(false, true, 0.0, 0.0);
- satellitepairarrayparam_values.set_pointwise(pointwise);
+ satellitearrayparam_values.set_pointwise(pointwise);
}
}
@@ -472,20 +466,19 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
size_t counterCurves = 0;
size_t first = counter;
double time0 = 0;
+ std::vector<Geom::Satellite> sats = pointwise->getSatellites();
while (curve_it1 != curve_endit) {
if((*curve_it1).isDegenerate() || (*curve_it1).isDegenerate()){
g_warning("LPE Fillet not handle degenerate curves.");
return path_in;
}
- std::vector<size_t> satIndexes;
Satellite satellite;
Curve *curve_it2Fixed = path_it->begin()->duplicate();
if(!path_it->closed()){
if(curve_it2 != curve_endit){
curve_it2Fixed = (*curve_it2).duplicate();
- satIndexes = pointwise->findSatellites(counter+1,1);
- if(satIndexes.size()>0){
- satellite = pointwise->getSatellites()[satIndexes[0]].second;
+ if(sats.size()> counter+1 ){
+ satellite = sats[counter+1];
}
} else {
if(time0 != 1){
@@ -501,21 +494,19 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
} else {
if(curve_it2 != curve_endit){
curve_it2Fixed = (*curve_it2).duplicate();
- satIndexes = pointwise->findSatellites(counter+1,1);
- if(satIndexes.size()>0){
- satellite = pointwise->getSatellites()[satIndexes[0]].second;
+ if(sats.size()> counter+1 ){
+ satellite = sats[counter+1];
}
+
} else {
- satIndexes = pointwise->findSatellites(first,1);
- if(satIndexes.size()>0){
- satellite = pointwise->getSatellites()[satIndexes[0]].second;
+ if(sats.size()> first ){
+ satellite = sats[first];
}
}
}
if(first == counter){
- satIndexes = pointwise->findSatellites(first,1);
- if(satIndexes.size()>0 && pointwise->getSatellites()[satIndexes[0]].second.getActive()){
- time0 = pointwise->getSatellites()[satIndexes[0]].second.getTime(path_it->begin()->duplicate()->toSBasis());
+ if(sats.size() > first && sats[first].active){
+ time0 = sats[first].getTime(path_it->begin()->duplicate()->toSBasis());
} else {
time0 = 0;
}
@@ -525,7 +516,7 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
double s = satellite.getSize(curve_it2Fixed->toSBasis());
double time1 = satellite.getOpositeTime(s,(*curve_it1).toSBasis());
double time2 = satellite.getTime(curve_it2Fixed->toSBasis());
- if(!satellite.getActive()){
+ if(!satellite.active){
time1 = 1;
time2 = 0;
}
@@ -604,8 +595,8 @@ LPEFilletChamfer::doEffect_path(std::vector<Geom::Path> const &path_in)
path_out.append(*knotCurve1);
}
}
- SatelliteType type = satellite.getSatelliteType();
- size_t steps = satellite.getSteps();
+ SatelliteType type = satellite.satelliteType;
+ size_t steps = satellite.steps;
if(steps < 1){
steps = 1;
}
diff --git a/src/live_effects/lpe-fillet-chamfer.h b/src/live_effects/lpe-fillet-chamfer.h
index 89d91265a..e56200a17 100644
--- a/src/live_effects/lpe-fillet-chamfer.h
+++ b/src/live_effects/lpe-fillet-chamfer.h
@@ -14,11 +14,12 @@
*
* Released under GNU GPL, read the file 'COPYING' for more information
*/
+
#include "live_effects/parameter/enum.h"
#include "live_effects/parameter/unit.h"
-#include "2geom/pointwise.h"
-#include "live_effects/parameter/satellitepairarray.h"
+#include "live_effects/parameter/satellitearray.h"
#include "live_effects/effect.h"
+#include "helper/geom-pointwise.h"
namespace Inkscape {
namespace LivePathEffect {
@@ -39,7 +40,7 @@ public:
virtual void doOnApply(SPLPEItem const *lpeItem);
virtual void adjustForNewPath(std::vector<Geom::Path> const &path_in);
virtual Gtk::Widget* newWidget();
- /*double len_to_rad(double A, std::pair<int,Geom::Satellite> sat);*/
+
void updateSatelliteType(Geom::SatelliteType satellitetype);
void updateChamferSteps();
void updateAmount();
@@ -49,7 +50,7 @@ public:
void fillet();
void inverseFillet();
- SatellitePairArrayParam satellitepairarrayparam_values;
+ SatelliteArrayParam satellitearrayparam_values;
private:
UnitParam unit;
diff --git a/src/live_effects/parameter/Makefile_insert b/src/live_effects/parameter/Makefile_insert
index 74b499fa2..9a0ebe235 100644
--- a/src/live_effects/parameter/Makefile_insert
+++ b/src/live_effects/parameter/Makefile_insert
@@ -22,8 +22,8 @@ ink_common_sources += \
live_effects/parameter/originalpatharray.h \
live_effects/parameter/powerstrokepointarray.cpp \
live_effects/parameter/powerstrokepointarray.h \
- live_effects/parameter/satellitepairarray.cpp \
- live_effects/parameter/satellitepairarray.h \
+ live_effects/parameter/satellitearray.cpp \
+ live_effects/parameter/satellitearray.h \
live_effects/parameter/text.cpp \
live_effects/parameter/text.h \
live_effects/parameter/transformedpoint.cpp \
diff --git a/src/live_effects/parameter/array.cpp b/src/live_effects/parameter/array.cpp
index 33cb53f4e..c8ee63fec 100644
--- a/src/live_effects/parameter/array.cpp
+++ b/src/live_effects/parameter/array.cpp
@@ -5,9 +5,7 @@
*/
#include "live_effects/parameter/array.h"
-
#include "helper-fns.h"
-
#include <2geom/coord.h>
#include <2geom/point.h>
@@ -15,6 +13,35 @@ namespace Inkscape {
namespace LivePathEffect {
+//TODO: move maybe to svg-lenght.cpp
+unsigned int
+sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){
+ if (!str) {
+ return 0;
+ }
+ gchar ** strarray = g_strsplit(str, ",", 8);
+ if(strarray[7] && !strarray[8]){
+ sat->setSatelliteType(g_strstrip(strarray[0]));
+ sat->isTime = strncmp(strarray[1],"1",1) == 0;
+ sat->active = strncmp(strarray[2],"1",1) == 0;
+ sat->hasMirror = strncmp(strarray[3],"1",1) == 0;
+ sat->hidden = strncmp(strarray[4],"1",1) == 0;
+ double amount,angle;
+ float stepsTmp;
+ sp_svg_number_read_d(strarray[5], &amount);
+ sp_svg_number_read_d(strarray[6], &angle);
+ sp_svg_number_read_f(strarray[7], &stepsTmp);
+ unsigned int steps = (unsigned int)stepsTmp;
+ sat->amount = amount;
+ sat->angle = angle;
+ sat->steps = steps;
+ g_strfreev (strarray);
+ return 1;
+ }
+ g_strfreev (strarray);
+ return 0;
+}
+
template <>
double
ArrayParam<double>::readsvg(const gchar * str)
@@ -47,51 +74,17 @@ ArrayParam<Geom::Point>::readsvg(const gchar * str)
}
return Geom::Point(Geom::infinity(),Geom::infinity());
}
-//TODO: move maybe to svg-lenght.cpp
-unsigned int
-sp_svg_satellite_read_d(gchar const *str, Geom::Satellite *sat){
- if (!str) {
- return 0;
- }
- gchar ** strarray = g_strsplit(str, "*", 0);
- if(strarray[8] && !strarray[9]){
- sat->setSatelliteType(strarray[0]);
- sat->setIsTime(strncmp(strarray[1],"1",1) == 0);
- sat->setIsEndOpen(strncmp(strarray[2],"1",1) == 0);
- sat->setActive(strncmp(strarray[3],"1",1) == 0);
- sat->setHasMirror(strncmp(strarray[4],"1",1) == 0);
- sat->setHidden(strncmp(strarray[5],"1",1) == 0);
- double amount,angle;
- float stepsTmp;
- sp_svg_number_read_d(strarray[6], &amount);
- sp_svg_number_read_d(strarray[7], &angle);
- sp_svg_number_read_f(strarray[8], &stepsTmp);
- unsigned int steps = (unsigned int)stepsTmp;
- sat->setAmount(amount);
- sat->setAngle(angle);
- sat->setSteps(steps);
- g_strfreev (strarray);
- return 1;
- }
- g_strfreev (strarray);
- return 0;
-}
template <>
-std::pair<size_t, Geom::Satellite>
-ArrayParam<std::pair<size_t, Geom::Satellite> >::readsvg(const gchar * str)
+Geom::Satellite
+ArrayParam<Geom::Satellite >::readsvg(const gchar * str)
{
- gchar ** strarray = g_strsplit(str, ",", 2);
- double index;
- std::pair<size_t, Geom::Satellite> result;
- unsigned int success = (int)sp_svg_number_read_d(strarray[0], &index);
Geom::Satellite sat;
- success += sp_svg_satellite_read_d(strarray[1], &sat);
- g_strfreev (strarray);
- if (success == 2) {
- return std::make_pair((size_t)index, sat);
+ if (sp_svg_satellite_read_d(str, &sat)) {
+ return sat;
}
- return std::make_pair((size_t)0,sat);
+ Geom::Satellite satellite(Geom::F, true, false, false, true, 0.0, 0.0, 0);
+ return satellite;
}
} /* namespace LivePathEffect */
diff --git a/src/live_effects/parameter/array.h b/src/live_effects/parameter/array.h
index 4fb053dbb..25e479304 100644
--- a/src/live_effects/parameter/array.h
+++ b/src/live_effects/parameter/array.h
@@ -15,8 +15,8 @@
#include "live_effects/parameter/parameter.h"
-#include <2geom/satellite.h>
-#include <2geom/satellite-enum.h>
+#include "helper/geom-satellite.h"
+#include "helper/geom-satellite-enum.h"
#include "svg/svg.h"
#include "svg/stringstream.h"
@@ -111,26 +111,22 @@ protected:
str << nVector;
}
- void writesvgData(SVGOStringStream &str, std::pair<size_t, Geom::Satellite> const &nVector) const {
- str << nVector.first;
+ void writesvgData(SVGOStringStream &str, Geom::Satellite const &nVector) const {
+ str << nVector.getSatelliteTypeGchar();
str << ",";
- str << nVector.second.getSatelliteTypeGchar();
- str << "*";
- str << nVector.second.getIsTime();
- str << "*";
- str << nVector.second.getIsEndOpen();
- str << "*";
- str << nVector.second.getActive();
- str << "*";
- str << nVector.second.getHasMirror();
- str << "*";
- str << nVector.second.getHidden();
- str << "*";
- str << nVector.second.getAmount();
- str << "*";
- str << nVector.second.getAngle();
- str << "*";
- str << nVector.second.getSteps();
+ str << nVector.isTime;
+ str << ",";
+ str << nVector.active;
+ str << ",";
+ str << nVector.hasMirror;
+ str << ",";
+ str << nVector.hidden;
+ str << ",";
+ str << nVector.amount;
+ str << ",";
+ str << nVector.angle;
+ str << ",";
+ str << nVector.steps;
}
StorageType readsvg(const gchar * str);
diff --git a/src/live_effects/parameter/satellitepairarray.cpp b/src/live_effects/parameter/satellitearray.cpp
index 461a6b54e..24a491b4b 100644
--- a/src/live_effects/parameter/satellitepairarray.cpp
+++ b/src/live_effects/parameter/satellitearray.cpp
@@ -10,10 +10,11 @@
#include "knotholder.h"
#include "ui/dialog/lpe-fillet-chamfer-properties.h"
-#include "live_effects/parameter/satellitepairarray.h"
+#include "live_effects/parameter/satellitearray.h"
#include "live_effects/effect.h"
#include "sp-lpe-item.h"
#include <preferences.h>
+#include <boost/optional.hpp>
// TODO due to internal breakage in glibmm headers,
// this has to be included last.
#include <glibmm/i18n.h>
@@ -25,11 +26,11 @@ namespace Inkscape {
namespace LivePathEffect {
-SatellitePairArrayParam::SatellitePairArrayParam(
+SatelliteArrayParam::SatelliteArrayParam(
const Glib::ustring &label, const Glib::ustring &tip,
const Glib::ustring &key, Inkscape::UI::Widget::Registry *wr,
Effect *effect)
- : ArrayParam<std::pair<size_t,Geom::Satellite> >(label, tip, key, wr, effect, 0),
+ : ArrayParam<Geom::Satellite>(label, tip, key, wr, effect, 0),
knoth(NULL)
{
knot_shape = SP_KNOT_SHAPE_DIAMOND;
@@ -41,9 +42,9 @@ SatellitePairArrayParam::SatellitePairArrayParam(
last_pointwise = NULL;
}
-SatellitePairArrayParam::~SatellitePairArrayParam() {}
+SatelliteArrayParam::~SatelliteArrayParam() {}
-void SatellitePairArrayParam::set_oncanvas_looks(SPKnotShapeType shape,
+void SatelliteArrayParam::set_oncanvas_looks(SPKnotShapeType shape,
SPKnotModeType mode,
guint32 color)
{
@@ -52,77 +53,78 @@ void SatellitePairArrayParam::set_oncanvas_looks(SPKnotShapeType shape,
knot_color = color;
}
-void SatellitePairArrayParam::set_pointwise(Geom::Pointwise *pointwise)
+void SatelliteArrayParam::set_pointwise(Geom::Pointwise *pointwise)
{
last_pointwise = pointwise;
param_set_and_write_new_value(last_pointwise->getSatellites());
}
-void SatellitePairArrayParam::set_document_unit(Glib::ustring value_document_unit)
+void SatelliteArrayParam::set_document_unit(Glib::ustring value_document_unit)
{
documentUnit = value_document_unit;
}
-void SatellitePairArrayParam::set_use_distance(bool use_knot_distance )
+void SatelliteArrayParam::set_use_distance(bool use_knot_distance )
{
use_distance = use_knot_distance;
}
-void SatellitePairArrayParam::set_unit(const gchar *abbr)
+void SatelliteArrayParam::set_unit(const gchar *abbr)
{
unit = abbr;
}
-void SatellitePairArrayParam::set_effect_type(EffectType et)
+void SatelliteArrayParam::set_effect_type(EffectType et)
{
_effectType = et;
}
-void SatellitePairArrayParam::set_helper_size(int hs)
+void SatelliteArrayParam::set_helper_size(int hs)
{
helper_size = hs;
updateCanvasIndicators();
}
-void SatellitePairArrayParam::updateCanvasIndicators(bool mirror)
+void SatelliteArrayParam::updateCanvasIndicators(bool mirror)
{
if(!last_pointwise){
return;
}
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = last_pointwise->getPwd2();
+ Pathinfo pathInfo(pwd2);
if( mirror == true){
hp.clear();
}
for (size_t i = 0; i < _vector.size(); ++i) {
- if(!_vector[i].second.getActive() || _vector[i].second.getHidden()){
+ if(!_vector[i].active || _vector[i].hidden){
continue;
}
- if((!_vector[i].second.getHasMirror() && mirror == true) || _vector[i].second.getAmount() == 0){
+ if((!_vector[i].hasMirror && mirror == true) || _vector[i].amount == 0){
continue;
}
double pos = 0;
- if(pwd2.size() <= (unsigned)_vector[i].first){
+ if(pwd2.size() <= i){
break;
}
- Geom::D2<Geom::SBasis> d2 = pwd2[_vector[i].first];
+ Geom::D2<Geom::SBasis> d2 = pwd2[i];
bool overflow = false;
- double size_out = _vector[i].second.getSize(pwd2[_vector[i].first]);
- double lenght_out = Geom::length(pwd2[_vector[i].first], Geom::EPSILON);
+ double size_out = _vector[i].getSize(pwd2[i]);
+ double lenght_out = Geom::length(pwd2[i], Geom::EPSILON);
double lenght_in = 0;
- boost::optional<size_t> d2_prev_index = last_pointwise->getPrevious(_vector[i].first);
+ boost::optional<size_t> d2_prev_index = pathInfo.getPrevious(i);
if(d2_prev_index){
lenght_in = Geom::length(pwd2[*d2_prev_index], Geom::EPSILON);
}
if(mirror == true){
if(d2_prev_index){
d2 = pwd2[*d2_prev_index];
- pos = _vector[i].second.getOpositeTime(size_out,d2);
+ pos = _vector[i].getOpositeTime(size_out,d2);
if(lenght_out < size_out){
overflow = true;
}
}
} else {
- pos = _vector[i].second.getTime(d2);
+ pos = _vector[i].getTime(d2);
if(lenght_in < size_out){
overflow = true;
}
@@ -181,18 +183,18 @@ void SatellitePairArrayParam::updateCanvasIndicators(bool mirror)
updateCanvasIndicators(false);
}
}
-void SatellitePairArrayParam::updateCanvasIndicators()
+void SatelliteArrayParam::updateCanvasIndicators()
{
updateCanvasIndicators(true);
}
-void SatellitePairArrayParam::addCanvasIndicators(
+void SatelliteArrayParam::addCanvasIndicators(
SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec)
{
hp_vec.push_back(hp);
}
-void SatellitePairArrayParam::recalculate_knots()
+void SatelliteArrayParam::recalculate_knots()
{
if(last_pointwise){
_vector = last_pointwise->getSatellites();
@@ -200,15 +202,15 @@ void SatellitePairArrayParam::recalculate_knots()
}
void
-SatellitePairArrayParam::param_transform_multiply(Geom::Affine const &postmul,
+SatelliteArrayParam::param_transform_multiply(Geom::Affine const &postmul,
bool /*set*/)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/options/transform/rectcorners", true)) {
for (size_t i = 0; i < _vector.size(); ++i) {
- if(!_vector[i].second.getIsTime() && _vector[i].second.getAmount() > 0){
- _vector[i].second.setAmount(_vector[i].second.getAmount() * ((postmul.expansionX() + postmul.expansionY()) / 2));
+ if(!_vector[i].isTime && _vector[i].amount > 0){
+ _vector[i].amount = _vector[i].amount * ((postmul.expansionX() + postmul.expansionY()) / 2);
}
}
param_set_and_write_new_value(_vector);
@@ -217,7 +219,7 @@ SatellitePairArrayParam::param_transform_multiply(Geom::Affine const &postmul,
// param_set_and_write_new_value( (*this) * postmul );
}
-void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
+void SatelliteArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
SPDesktop *desktop,
SPItem *item,
bool mirror)
@@ -228,14 +230,14 @@ void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
if( mirror == true){
iPlus = i + _vector.size();
}
- if(!_vector[i].second.getActive()){
+ if(!_vector[i].active){
continue;
}
- if(!_vector[i].second.getHasMirror() && mirror == true){
+ if(!_vector[i].hasMirror && mirror == true){
continue;
}
using namespace Geom;
- SatelliteType type = _vector[i].second.getSatelliteType();
+ SatelliteType type = _vector[i].satelliteType;
//IF is for filletChamfer effect...
if(_effectType == FILLET_CHAMFER){
const gchar *tip;
@@ -268,7 +270,7 @@ void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
}
}
-void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
+void SatelliteArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
SPDesktop *desktop,
SPItem *item)
{
@@ -276,7 +278,7 @@ void SatellitePairArrayParam::addKnotHolderEntities(KnotHolder *knotholder,
addKnotHolderEntities(knotholder, desktop, item, true);
}
-FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, size_t index)
+FilletChamferKnotHolderEntity::FilletChamferKnotHolderEntity(SatelliteArrayParam *p, size_t index)
: _pparam(p),
_index(index)
{
@@ -299,34 +301,33 @@ void FilletChamferKnotHolderEntity::knot_set(Point const &p,
return;
}
- std::pair<int,Geom::Satellite> satellite = _pparam->_vector.at(index);
- if(!satellite.second.getActive() || satellite.second.getHidden()){
+ Geom::Satellite satellite = _pparam->_vector.at(index);
+ if(!satellite.active || satellite.hidden){
return;
}
Geom::Pointwise* pointwise = _pparam->last_pointwise;
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
+ Pathinfo pathInfo(pwd2);
if(_pparam->_vector.size() <= _index){
- boost::optional<size_t> d2_prev_index = pointwise->getPrevious(satellite.first);
+ boost::optional<size_t> d2_prev_index = pathInfo.getPrevious(index);
if(d2_prev_index){
Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index];
double mirrorTime = Geom::nearest_point(s, d2_in);
double timeStart = 0;
- std::vector<size_t> satIndexes = pointwise->findPeviousSatellites(satellite.first,1);
- if(satIndexes.size()>0){
- timeStart = pointwise->getSatellites()[satIndexes[0]].second.getTime(d2_in);
- }
+ std::vector<Geom::Satellite> sats = pointwise->getSatellites();
+ timeStart = sats[*d2_prev_index].getTime(d2_in);
if(timeStart > mirrorTime){
mirrorTime = timeStart;
}
- double size = satellite.second.toSize(mirrorTime, d2_in);
+ double size = satellite.toSize(mirrorTime, d2_in);
double amount = Geom::length(d2_in, Geom::EPSILON) - size;
- if(satellite.second.getIsTime()){
- amount = satellite.second.toTime(amount,pwd2[satellite.first]);
+ if(satellite.isTime){
+ amount = satellite.toTime(amount,pwd2[index]);
}
- satellite.second.setAmount(amount);
+ satellite.amount = amount;
}
} else {
- satellite.second.setPosition(s,pwd2[satellite.first]);
+ satellite.setPosition(s,pwd2[index]);
}
_pparam->_vector.at(index) = satellite;
SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
@@ -347,26 +348,27 @@ FilletChamferKnotHolderEntity::knot_get() const
if (!valid_index(index)) {
return Point(infinity(), infinity());
}
- std::pair<int,Geom::Satellite> satellite = _pparam->_vector.at(index);
+ Geom::Satellite satellite = _pparam->_vector.at(index);
if(!_pparam->last_pointwise){
return Point(infinity(), infinity());
}
- if(!satellite.second.getActive() || satellite.second.getHidden()){
+ if(!satellite.active || satellite.hidden){
return Point(infinity(), infinity());
}
Geom::Pointwise* pointwise = _pparam->last_pointwise;
Geom::Piecewise<Geom::D2<Geom::SBasis> > pwd2 = pointwise->getPwd2();
- if(pwd2.size() <= (unsigned)satellite.first){
+ Pathinfo pathInfo(pwd2);
+ if(pwd2.size() <= index){
return Point(infinity(), infinity());
}
this->knot->show();
if( _index >= _pparam->_vector.size()){
- tmpPoint = satellite.second.getPosition(pwd2[satellite.first]);
- boost::optional<size_t> d2_prev_index = pointwise->getPrevious(satellite.first);
+ tmpPoint = satellite.getPosition(pwd2[index]);
+ boost::optional<size_t> d2_prev_index = pathInfo.getPrevious(index);
if(d2_prev_index){
Geom::D2<Geom::SBasis> d2_in = pwd2[*d2_prev_index];
- double s = satellite.second.getSize(pwd2[satellite.first]);
- double t = satellite.second.getOpositeTime(s,d2_in);
+ double s = satellite.getSize(pwd2[index]);
+ double t = satellite.getOpositeTime(s,d2_in);
if(t > 1){
t = 1;
}
@@ -374,17 +376,14 @@ FilletChamferKnotHolderEntity::knot_get() const
t = 0;
}
double timeStart = 0;
- std::vector<size_t> satIndexes = pointwise->findPeviousSatellites(satellite.first,1);
- if(satIndexes.size()>0){
- timeStart = pointwise->getSatellites()[satIndexes[0]].second.getTime(d2_in);
- }
+ timeStart = pointwise->getSatellites()[*d2_prev_index].getTime(d2_in);
if(timeStart > t){
t = timeStart;
}
tmpPoint = (d2_in).valueAt(t);
}
} else {
- tmpPoint = satellite.second.getPosition(pwd2[satellite.first]);
+ tmpPoint = satellite.getPosition(pwd2[index]);
}
Geom::Point const canvas_point = tmpPoint;
return canvas_point;
@@ -402,12 +401,12 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
}
if (state & GDK_CONTROL_MASK) {
if (state & GDK_MOD1_MASK) {
- _pparam->_vector.at(index).second.setAmount(0.0);
+ _pparam->_vector.at(index).amount = 0.0;
_pparam->param_set_and_write_new_value(_pparam->_vector);
sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
}else{
using namespace Geom;
- SatelliteType type = _pparam->_vector.at(index).second.getSatelliteType();
+ SatelliteType type = _pparam->_vector.at(index).satelliteType;
switch(type){
case F:
type = IF;
@@ -422,7 +421,7 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
type = F;
break;
}
- _pparam->_vector.at(index).second.setSatelliteType(type);
+ _pparam->_vector.at(index).satelliteType = type;
_pparam->param_set_and_write_new_value(_pparam->_vector);
sp_lpe_item_update_patheffect(SP_LPE_ITEM(item), false, false);
const gchar *tip;
@@ -447,19 +446,28 @@ void FilletChamferKnotHolderEntity::knot_click(guint state)
this->knot->show();
}
} else if (state & GDK_SHIFT_MASK) {
- double amount = _pparam->_vector.at(index).second.getAmount();
- if(!_pparam->use_distance && !_pparam->_vector.at(index).second.getIsTime()){
- amount = _pparam->last_pointwise->len_to_rad(amount, _pparam->_vector.at(index));
+ Piecewise<D2<SBasis> > pwd2 = _pparam->last_pointwise->getPwd2();
+ Pathinfo pathInfo(pwd2);
+ double amount = _pparam->_vector.at(index).amount;
+ if(!_pparam->use_distance && !_pparam->_vector.at(index).isTime){
+ boost::optional<size_t> prev = pathInfo.getPrevious(index);
+ boost::optional<Geom::D2<Geom::SBasis> > prevPwd2 = boost::none;
+ boost::optional<Geom::Satellite > prevSat = boost::none;
+ if(prev){
+ prevPwd2 = pwd2[*prev];
+ prevSat = _pparam->_vector.at(*prev);
+ }
+ amount = _pparam->_vector.at(index).len_to_rad(amount, prevPwd2, pwd2[index], prevSat);
}
bool aprox = false;
D2<SBasis> d2_out = _pparam->last_pointwise->getPwd2()[index];
- boost::optional<size_t> d2_prev_index = _pparam->last_pointwise->getPrevious(_pparam->_vector.at(index).first);
+ boost::optional<size_t> d2_prev_index = pathInfo.getPrevious(index);
if(d2_prev_index){
Geom::D2<Geom::SBasis> d2_in = _pparam->last_pointwise->getPwd2()[*d2_prev_index];
aprox = ((d2_in)[0].degreesOfFreedom() != 2 || d2_out[0].degreesOfFreedom() != 2) && !_pparam->use_distance?true:false;
}
Inkscape::UI::Dialogs::FilletChamferPropertiesDialog::showDialog(
- this->desktop, amount , this, _pparam->unit, _pparam->use_distance, aprox, _pparam->documentUnit,_pparam->_vector.at(index).second);
+ this->desktop, amount , this, _pparam->unit, _pparam->use_distance, aprox, _pparam->documentUnit,_pparam->_vector.at(index));
}
}
@@ -473,16 +481,25 @@ void FilletChamferKnotHolderEntity::knot_set_offset(Geom::Satellite satellite)
if( _index >= _pparam->_vector.size()){
index = _index-_pparam->_vector.size();
}
- double amount = satellite.getAmount();
+ double amount = satellite.amount;
double maxAmount = amount;
- if(!_pparam->use_distance && !satellite.getIsTime()){
- amount = _pparam->last_pointwise->rad_to_len(amount, _pparam->_vector.at(index));
+ if(!_pparam->use_distance && !satellite.isTime){
+ Piecewise<D2<SBasis> > pwd2 = _pparam->last_pointwise->getPwd2();
+ Pathinfo pathInfo(pwd2);
+ boost::optional<size_t> prev = pathInfo.getPrevious(index);
+ boost::optional<Geom::D2<Geom::SBasis> > prevPwd2 = boost::none;
+ boost::optional<Geom::Satellite > prevSat = boost::none;
+ if(prev){
+ prevPwd2 = pwd2[*prev];
+ prevSat = _pparam->_vector.at(*prev);
+ }
+ amount = _pparam->_vector.at(index).rad_to_len(amount, prevPwd2, pwd2[index], prevSat);
if(maxAmount > 0 && amount == 0){
- amount = _pparam->_vector.at(index).second.getAmount();
+ amount = _pparam->_vector.at(index).amount;
}
}
- satellite.setAmount(amount);
- _pparam->_vector.at(index).second = satellite;
+ satellite.amount = amount;
+ _pparam->_vector.at(index) = satellite;
this->parent_holder->knot_ungrabbed_handler(this->knot, 0);
_pparam->param_set_and_write_new_value(_pparam->_vector);
SPLPEItem * splpeitem = dynamic_cast<SPLPEItem *>(item);
diff --git a/src/live_effects/parameter/satellitepairarray.h b/src/live_effects/parameter/satellitearray.h
index fcd3bd736..ee0cfbad3 100644
--- a/src/live_effects/parameter/satellitepairarray.h
+++ b/src/live_effects/parameter/satellitearray.h
@@ -18,11 +18,11 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include <glib.h>
#include "live_effects/parameter/array.h"
#include "live_effects/effect-enum.h"
+#include "helper/geom-pointwise.h"
#include "knot-holder-entity.h"
-#include <2geom/pointwise.h>
+#include <glib.h>
namespace Inkscape {
@@ -30,14 +30,14 @@ namespace LivePathEffect {
class FilletChamferKnotHolderEntity;
-class SatellitePairArrayParam : public ArrayParam<std::pair<size_t, Geom::Satellite> > {
+class SatelliteArrayParam : public ArrayParam<Geom::Satellite> {
public:
- SatellitePairArrayParam(const Glib::ustring &label,
+ SatelliteArrayParam(const Glib::ustring &label,
const Glib::ustring &tip,
const Glib::ustring &key,
Inkscape::UI::Widget::Registry *wr,
Effect *effect);
- virtual ~SatellitePairArrayParam();
+ virtual ~SatelliteArrayParam();
virtual Gtk::Widget * param_newWidget() {
return NULL;
@@ -66,8 +66,8 @@ public:
protected:
KnotHolder *knoth;
private:
- SatellitePairArrayParam(const SatellitePairArrayParam &);
- SatellitePairArrayParam &operator=(const SatellitePairArrayParam &);
+ SatelliteArrayParam(const SatelliteArrayParam &);
+ SatelliteArrayParam &operator=(const SatelliteArrayParam &);
SPKnotShapeType knot_shape;
SPKnotModeType knot_mode;
@@ -84,7 +84,7 @@ private:
class FilletChamferKnotHolderEntity : public KnotHolderEntity {
public:
- FilletChamferKnotHolderEntity(SatellitePairArrayParam *p, size_t index);
+ FilletChamferKnotHolderEntity(SatelliteArrayParam *p, size_t index);
virtual ~FilletChamferKnotHolderEntity() {_pparam->knoth = NULL;}
virtual void knot_set(Geom::Point const &p, Geom::Point const &origin, guint state);
@@ -97,7 +97,7 @@ public:
};
private:
- SatellitePairArrayParam *_pparam;
+ SatelliteArrayParam *_pparam;
size_t _index;
};
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
index 6875799f8..443a48c13 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.cpp
@@ -160,13 +160,13 @@ void FilletChamferPropertiesDialog::_apply()
double d_pos = _fillet_chamfer_position_numeric.get_value();
if (d_pos >= 0) {
if (_fillet_chamfer_type_fillet.get_active() == true) {
- _satellite.setSatelliteType(Geom::F);
+ _satellite.satelliteType = Geom::F;
} else if (_fillet_chamfer_type_inverse_fillet.get_active() == true) {
- _satellite.setSatelliteType(Geom::IF);
+ _satellite.satelliteType = Geom::IF;
} else if (_fillet_chamfer_type_inverse_chamfer.get_active() == true) {
- _satellite.setSatelliteType(Geom::IC);
+ _satellite.satelliteType = Geom::IC;
} else {
- _satellite.setSatelliteType(Geom::C);
+ _satellite.satelliteType = Geom::C;
}
if (_flexible) {
if (d_pos > 99.99999 || d_pos < 0) {
@@ -176,12 +176,12 @@ void FilletChamferPropertiesDialog::_apply()
} else {
d_pos = Inkscape::Util::Quantity::convert(d_pos, unit, document_unit);
}
- _satellite.setAmount( d_pos);
+ _satellite.amount = d_pos;
size_t steps = (size_t)_fillet_chamfer_chamfer_subdivisions.get_value();
if(steps < 1){
steps = 1;
}
- _satellite.setSteps(steps);
+ _satellite.steps = steps;
_knotpoint->knot_set_offset(_satellite);
}
_close();
@@ -221,7 +221,7 @@ void FilletChamferPropertiesDialog::_set_satellite(Geom::Satellite satellite)
if(use_distance){
distance_or_radius = std::string(_("Knot distance"));
}
- if (satellite.getIsTime()) {
+ if (satellite.isTime) {
position = amount * 100;
_flexible = true;
_fillet_chamfer_position_label.set_label(_("Position (%):"));
@@ -233,14 +233,14 @@ void FilletChamferPropertiesDialog::_set_satellite(Geom::Satellite satellite)
position = Inkscape::Util::Quantity::convert(position, document_unit, unit);
}
_fillet_chamfer_position_numeric.set_value(position);
- _fillet_chamfer_chamfer_subdivisions.set_value(satellite.getSteps());
- if (satellite.getSatelliteType() == Geom::F) {
+ _fillet_chamfer_chamfer_subdivisions.set_value(satellite.steps);
+ if (satellite.satelliteType == Geom::F) {
_fillet_chamfer_type_fillet.set_active(true);
- } else if (satellite.getSatelliteType() == Geom::IF) {
+ } else if (satellite.satelliteType == Geom::IF) {
_fillet_chamfer_type_inverse_fillet.set_active(true);
- } else if (satellite.getSatelliteType() == Geom::C) {
+ } else if (satellite.satelliteType == Geom::C) {
_fillet_chamfer_type_chamfer.set_active(true);
- } else if (satellite.getSatelliteType() == Geom::IC) {
+ } else if (satellite.satelliteType == Geom::IC) {
_fillet_chamfer_type_inverse_chamfer.set_active(true);
}
_satellite = satellite;
diff --git a/src/ui/dialog/lpe-fillet-chamfer-properties.h b/src/ui/dialog/lpe-fillet-chamfer-properties.h
index 533f7af2a..1a40eea9b 100644
--- a/src/ui/dialog/lpe-fillet-chamfer-properties.h
+++ b/src/ui/dialog/lpe-fillet-chamfer-properties.h
@@ -10,7 +10,7 @@
#include <2geom/point.h>
#include <gtkmm.h>
-#include "live_effects/parameter/satellitepairarray.h"
+#include "live_effects/parameter/satellitearray.h"
class SPDesktop;