summaryrefslogtreecommitdiffstats
path: root/src/2geom
diff options
context:
space:
mode:
Diffstat (limited to 'src/2geom')
-rw-r--r--src/2geom/pointwise.cpp61
-rw-r--r--src/2geom/pointwise.h9
-rw-r--r--src/2geom/satellite.cpp42
-rw-r--r--src/2geom/satellite.h28
4 files changed, 109 insertions, 31 deletions
diff --git a/src/2geom/pointwise.cpp b/src/2geom/pointwise.cpp
index aa1620e8a..bc468343c 100644
--- a/src/2geom/pointwise.cpp
+++ b/src/2geom/pointwise.cpp
@@ -45,6 +45,67 @@ Pointwise::getSatellites(){
return _satellites;
}
+void
+Pointwise::setSatellites(std::vector<std::pair<int,Satellite> > sat){
+ _satellites = sat;
+}
+
+Piecewise<D2<SBasis> >
+Pointwise::getPwd2(){
+ return _pwd2;
+}
+
+void
+Pointwise::setPwd2(Piecewise<D2<SBasis> > pwd2_in){
+ _pwd2 = pwd2_in;
+}
+
+boost::optional<Geom::D2<Geom::SBasis> >
+Pointwise::getCurveIn(std::pair<int,Satellite> sat){
+ //curve out = sat.first;
+ std::vector<Geom::Path> path_in_processed = pathv_to_linear_and_cubic_beziers(path_from_piecewise(_pwd2, 0.001));
+ int counterTotal = 0;
+ for (PathVector::const_iterator path_it = path_in_processed.begin(); path_it != path_in_processed.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();
+ // the closing line segment is always of type
+ // LineSegment.
+ if (are_near(closingline.initialPoint(), closingline.finalPoint())) {
+ // closingline.isDegenerate() did not work, because it only checks for
+ // *exact* zero length, which goes wrong for relative coordinates and
+ // rounding errors...
+ // the closing line segment has zero-length. So stop before that one!
+ curve_endit = path_it->end_open();
+ }
+ }
+ Geom::Path::const_iterator curve_end = curve_endit;
+ --curve_end;
+ int counter = 0;
+ while (curve_it1 != curve_endit) {
+ if(counterTotal == sat.first){
+ if (counter==0) {
+ if (path_it->closed()) {
+ return (*curve_end).toSBasis();
+ } else {
+ return boost::none;
+ }
+ } else {
+ return (*path_it)[counter - 1].toSBasis();
+ }
+ }
+ ++curve_it1;
+ counter++;
+ counterTotal++;
+ }
+ }
+ return boost::none;
+}
+
std::vector<Satellite>
Pointwise::findSatellites(int A, int B) const
{
diff --git a/src/2geom/pointwise.h b/src/2geom/pointwise.h
index e7646d96c..5937264ad 100644
--- a/src/2geom/pointwise.h
+++ b/src/2geom/pointwise.h
@@ -50,6 +50,10 @@
#include <2geom/sbasis-2d.h>
#include <2geom/piecewise.h>
#include <2geom/satellite.h>
+#include <2geom/sbasis-to-bezier.h>
+#include <2geom/path.h>
+#include "helper/geom.h"
+#include <boost/optional.hpp>
namespace Geom {
/**
@@ -64,7 +68,10 @@ class Pointwise
virtual ~Pointwise();
std::vector<Satellite> findSatellites(int A, int B = -1) const;
std::vector<std::pair<int,Satellite> > getSatellites();
-
+ void setSatellites(std::vector<std::pair<int,Satellite> > sat);
+ Piecewise<D2<SBasis> > getPwd2();
+ void setPwd2(Piecewise<D2<SBasis> > pwd2_in);
+ boost::optional<Geom::D2<Geom::SBasis> > getCurveIn(std::pair<int,Satellite> sat);
Pointwise recalculate_for_new_pwd2(Piecewise<D2<SBasis> > A);
Pointwise pwd2_reverse(int index);
Pointwise pwd2_append(int index);
diff --git a/src/2geom/satellite.cpp b/src/2geom/satellite.cpp
index 5b362d87f..21361147c 100644
--- a/src/2geom/satellite.cpp
+++ b/src/2geom/satellite.cpp
@@ -40,17 +40,16 @@ namespace Geom {
Satellite::Satellite(){};
-Satellite::Satellite(SatelliteType satellitetype, bool isTime, bool active, bool hasMirror, bool hidden, double size, double time)
- : _satellitetype(satellitetype), _isTime(isTime), _active(active), _hasMirror(hasMirror), _hidden(hidden), _size(size), _time(time){};
+Satellite::Satellite(SatelliteType satellitetype, bool isTime, bool active, bool hasMirror, bool hidden, double ammount, double angle)
+ : _satellitetype(satellitetype), _isTime(isTime), _active(active), _hasMirror(hasMirror), _hidden(hidden), _ammount(ammount), _angle(angle){};
Satellite::~Satellite() {};
double
Satellite::toTime(double A,Geom::D2<Geom::SBasis> d2_in)
{
- if(!d2_in.isFinite() || d2_in.isZero()){
- _time = 0;
- _size = 0;
+ if(!d2_in.isFinite() || d2_in.isZero() || A == 0){
+ _ammount = 0;
return 0;
}
double t = 0;
@@ -80,9 +79,8 @@ Satellite::toTime(double A,Geom::D2<Geom::SBasis> d2_in)
double
Satellite::toSize(double A,Geom::D2<Geom::SBasis> d2_in)
{
- if(!d2_in.isFinite() || d2_in.isZero()){
- _time = 0;
- _size = 0;
+ if(!d2_in.isFinite() || d2_in.isZero() || A == 0){
+ _ammount = 0;
return 0;
}
double s = 0;
@@ -102,7 +100,10 @@ Satellite::toSize(double A,Geom::D2<Geom::SBasis> d2_in)
double
Satellite::getOpositeTime(Geom::D2<Geom::SBasis> d2_in)
{
- double s = getSize();
+ double s = getAmmount();
+ if(getIsTime()){
+ s = toSize(s, d2_in);
+ }
if(s == 0){
return 1;
}
@@ -111,20 +112,29 @@ Satellite::getOpositeTime(Geom::D2<Geom::SBasis> d2_in)
return toTime(size, d2_in);
}
+double
+Satellite::getTime(Geom::D2<Geom::SBasis> d2_in){
+ double t = getAmmount();
+ if(!getIsTime()){
+ t = toTime(t, d2_in);
+ }
+ return t;
+}
+
+
Geom::Point
Satellite::getPosition(Geom::D2<Geom::SBasis> d2_in){
- double t = getTime();
- if(!_isTime){
- t = toTime(getSize(), d2_in);
- }
- return d2_in.valueAt(t);
+ return d2_in.valueAt(getTime(d2_in));
}
void
Satellite::setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in)
{
- setTime(Geom::nearest_point(p, d2_in));
- setSize(toSize(getTime(),d2_in));
+ double A = Geom::nearest_point(p, d2_in);
+ if(!getIsTime()){
+ A = toSize(A, d2_in);
+ }
+ setAmmount(A);
}
} // end namespace Geom
diff --git a/src/2geom/satellite.h b/src/2geom/satellite.h
index dd8e4d9d0..c66770bb6 100644
--- a/src/2geom/satellite.h
+++ b/src/2geom/satellite.h
@@ -45,7 +45,7 @@ class Satellite
public:
Satellite();
- Satellite(SatelliteType satellitetype, bool isTime, bool active, bool hasMirror, bool hidden, double size, double time);
+ Satellite(SatelliteType satellitetype, bool isTime, bool active, bool hasMirror, bool hidden, double ammount, double angle);
virtual ~Satellite();
@@ -79,14 +79,14 @@ class Satellite
{
_hidden = A;
}
- void setTime(double A)
+ void setAmmount(double A)
{
- _time = A;
+ _ammount = A;
}
- void setSize(double A)
+ void setAngle(double A)
{
- _size = A;
+ _angle = A;
}
SatelliteType getSatelliteType() const
@@ -120,23 +120,23 @@ class Satellite
return _hidden;
}
- double getSize() const
+ double getAmmount() const
{
- return _size;
+ return _ammount;
}
- double getTime() const
+ double getAngle() const
{
- return _time;
+ return _angle;
}
- void setPosition(Geom::Point p, Geom::D2<Geom::SBasis> curve);
-
+ void setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in);
Geom::Point getPosition(Geom::D2<Geom::SBasis> curve);
-
+ double getTime(Geom::D2<Geom::SBasis> d2_in);
double getOpositeTime(Geom::D2<Geom::SBasis> SBasisCurve);
double toSize(double A,Geom::D2<Geom::SBasis> d2_in);
double toTime(double A,Geom::D2<Geom::SBasis> d2_in);
+
private:
SatelliteType _satellitetype;
@@ -144,8 +144,8 @@ class Satellite
bool _active;
bool _hasMirror;
bool _hidden;
- double _size;
- double _time;
+ double _ammount;
+ double _angle;
};
} // end namespace Geom