diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-03-01 00:18:02 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-03-01 00:18:02 +0000 |
| commit | 00d08a0f4bca11e775bbacf3d512676a0493c1a3 (patch) | |
| tree | f69813c299df49dcf00ae5467aa277a1d13df41a /src/2geom/pointwise.cpp | |
| parent | improving code (diff) | |
| download | inkscape-00d08a0f4bca11e775bbacf3d512676a0493c1a3.tar.gz inkscape-00d08a0f4bca11e775bbacf3d512676a0493c1a3.zip | |
adding mirror knot
(bzr r13645.1.25)
Diffstat (limited to 'src/2geom/pointwise.cpp')
| -rw-r--r-- | src/2geom/pointwise.cpp | 61 |
1 files changed, 61 insertions, 0 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 { |
