diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-02-23 22:16:39 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-02-23 22:16:39 +0000 |
| commit | 83e726c8fb391f0cbbccc9b286bfecefc730dbc7 (patch) | |
| tree | 32041edefe2403cb611103322c2649607b107f79 /src/2geom | |
| parent | fixed some bugs (diff) | |
| download | inkscape-83e726c8fb391f0cbbccc9b286bfecefc730dbc7.tar.gz inkscape-83e726c8fb391f0cbbccc9b286bfecefc730dbc7.zip | |
Added flexible/fixed to fillet chamfer and fix bugs
(bzr r13645.1.20)
Diffstat (limited to 'src/2geom')
| -rw-r--r-- | src/2geom/pointwise.cpp | 5 | ||||
| -rw-r--r-- | src/2geom/pointwise.h | 3 | ||||
| -rw-r--r-- | src/2geom/satellite.cpp | 89 | ||||
| -rw-r--r-- | src/2geom/satellite.h | 6 |
4 files changed, 89 insertions, 14 deletions
diff --git a/src/2geom/pointwise.cpp b/src/2geom/pointwise.cpp index d7d5afc63..aa1620e8a 100644 --- a/src/2geom/pointwise.cpp +++ b/src/2geom/pointwise.cpp @@ -40,6 +40,11 @@ Pointwise::Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<int,Sate Pointwise::~Pointwise(){}; +std::vector<std::pair<int,Satellite> > +Pointwise::getSatellites(){ + return _satellites; +} + std::vector<Satellite> Pointwise::findSatellites(int A, int B) const { diff --git a/src/2geom/pointwise.h b/src/2geom/pointwise.h index d48321832..e7646d96c 100644 --- a/src/2geom/pointwise.h +++ b/src/2geom/pointwise.h @@ -63,6 +63,8 @@ class Pointwise Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<int,Satellite> > satellites); virtual ~Pointwise(); std::vector<Satellite> findSatellites(int A, int B = -1) const; + std::vector<std::pair<int,Satellite> > getSatellites(); + Pointwise recalculate_for_new_pwd2(Piecewise<D2<SBasis> > A); Pointwise pwd2_reverse(int index); Pointwise pwd2_append(int index); @@ -71,6 +73,7 @@ class Pointwise Pointwise pwd2_del(int index); Pointwise satellite_add(int index,Satellite sat); Pointwise satellite_del(int index,Satellite sat); + private: Piecewise<D2<SBasis> > _pwd2; diff --git a/src/2geom/satellite.cpp b/src/2geom/satellite.cpp index b8ddd040b..9a2fa0a10 100644 --- a/src/2geom/satellite.cpp +++ b/src/2geom/satellite.cpp @@ -46,7 +46,14 @@ Satellite::Satellite(SatelliteType satellitetype, bool isTime, bool active, bool Satellite::~Satellite() {}; void -Satellite::setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in){ +Satellite::setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in) +{ + if(!d2_in.isFinite() || d2_in.isZero()){ + _time = 0; + _size = 0; + return; + } + double lenghtPart = Geom::length(d2_in, Geom::EPSILON); _time = Geom::nearest_point(p, d2_in); if (d2_in[0].degreesOfFreedom() != 2) { Geom::Piecewise<Geom::D2<Geom::SBasis> > u; @@ -55,23 +62,24 @@ Satellite::setPosition(Geom::Point p, Geom::D2<Geom::SBasis> d2_in){ u = Geom::portion(u, 0.0, _time); _size = Geom::length(u, 0.001); } else { - double lenghtPart = Geom::length(d2_in, Geom::EPSILON); _size = (_time * lenghtPart); } + if(_time > 0.998){ + _time = 1; + } } -Geom::Point -Satellite::getPosition(Geom::D2<Geom::SBasis> d2_in){ - return d2_in.valueAt(_time); -} - double -Satellite::getOpositeTime(Geom::D2<Geom::SBasis> d2_in){ +Satellite::getOpositeTime(Geom::D2<Geom::SBasis> d2_in) +{ + if(!d2_in.isFinite() || d2_in.isZero()){ + return 1; + } double t = 0; + double lenghtPart = Geom::length(d2_in, Geom::EPSILON); if(_size == 0){ return 1; } - double lenghtPart = Geom::length(d2_in, Geom::EPSILON); double size = lenghtPart - _size; if (d2_in[0].degreesOfFreedom() != 2) { Geom::Piecewise<Geom::D2<Geom::SBasis> > u; @@ -86,9 +94,72 @@ Satellite::getOpositeTime(Geom::D2<Geom::SBasis> d2_in){ t = size / lenghtPart; } } + if(_time > 0.999){ + _time = 1; + } return t; } +void +Satellite::updateSizeTime(Geom::D2<Geom::SBasis> d2_in) +{ + if(!d2_in.isFinite() || d2_in.isZero()){ + _time = 0; + _size = 0; + return; + } + double lenghtPart = Geom::length(d2_in, Geom::EPSILON); + if(!_isTime){ + if (_size != 0) { + if(lenghtPart <= _size){ + _time = 1; + _size = lenghtPart; + } else if (d2_in[0].degreesOfFreedom() != 2) { + Piecewise<D2<SBasis> > u; + u.push_cut(0); + u.push(d2_in, 1); + std::vector<double> t_roots = roots(arcLengthSb(u) - _size); + if (t_roots.size() > 0) { + _time = t_roots[0]; + } + } else { + if (_size < lenghtPart && lenghtPart != 0) { + _time = _size / lenghtPart; + } + } + } else { + _time = 0; + } + } else { + if (_time != 0) { + if (d2_in[0].degreesOfFreedom() != 2) { + Piecewise<D2<SBasis> > u; + u.push_cut(0); + u.push(d2_in, 1); + u = portion(u, 0, _time); + _size = length(u, 0.001); + } else { + lenghtPart = length(d2_in, EPSILON); + _size = _time * lenghtPart; + } + } else { + _size = 0; + } + } + if(_time > 0.999){ + _time = 1; + } +} + +Geom::Point +Satellite::getPosition(Geom::D2<Geom::SBasis> d2_in){ + if(!d2_in.isFinite() || d2_in.isZero()){ + return Geom::Point(9999999999.0,9999999999.0); + } + updateSizeTime(d2_in); + return d2_in.valueAt(_time); +} + } // end namespace Geom /* diff --git a/src/2geom/satellite.h b/src/2geom/satellite.h index 7b524f912..105297f48 100644 --- a/src/2geom/satellite.h +++ b/src/2geom/satellite.h @@ -131,11 +131,7 @@ class Satellite return _time; } - double getTime(Geom::D2<Geom::SBasis> curve) const - { - //todo make the process - return _time; - } + void updateSizeTime(Geom::D2<Geom::SBasis> d2_in); void setPosition(Geom::Point p, Geom::D2<Geom::SBasis> curve); |
