diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-02-15 18:29:48 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-02-15 18:29:48 +0000 |
| commit | 99fb2239028e72f8773bff39e43f7af33b4252d4 (patch) | |
| tree | 23e96adea9f08b37f066559b28aac842cb230879 /src/2geom | |
| parent | update to trunk (diff) | |
| download | inkscape-99fb2239028e72f8773bff39e43f7af33b4252d4.tar.gz inkscape-99fb2239028e72f8773bff39e43f7af33b4252d4.zip | |
first steps
(bzr r13645.1.9)
Diffstat (limited to 'src/2geom')
| -rw-r--r-- | src/2geom/2geom.h | 2 | ||||
| -rw-r--r-- | src/2geom/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | src/2geom/Makefile_insert | 1 | ||||
| -rw-r--r-- | src/2geom/pointwise.cpp | 15 | ||||
| -rw-r--r-- | src/2geom/pointwise.h | 24 | ||||
| -rw-r--r-- | src/2geom/satellite-enum.h | 19 | ||||
| -rw-r--r-- | src/2geom/satellite.h | 67 |
7 files changed, 63 insertions, 69 deletions
diff --git a/src/2geom/2geom.h b/src/2geom/2geom.h index 000f3423d..1deef9e8c 100644 --- a/src/2geom/2geom.h +++ b/src/2geom/2geom.h @@ -59,6 +59,8 @@ #include <2geom/sbasis.h> // others +#include <2geom/pointwise.h> +#include <2geom/satellite.h> #include <2geom/math-utils.h> #include <2geom/utils.h> diff --git a/src/2geom/CMakeLists.txt b/src/2geom/CMakeLists.txt index eeaecaa39..b49b78e7e 100644 --- a/src/2geom/CMakeLists.txt +++ b/src/2geom/CMakeLists.txt @@ -26,11 +26,13 @@ set(2geom_SRC pathvector.cpp piecewise.cpp point.cpp + pointwise.cpp poly.cpp quadtree.cpp rect.cpp # recursive-bezier-intersection.cpp region.cpp + satellite.cpp sbasis-2d.cpp sbasis-geometric.cpp sbasis-math.cpp @@ -100,11 +102,13 @@ set(2geom_SRC piecewise.h point-ops.h point.h + pointwise.h poly.h quadtree.h ray.h rect.h region.h + satellite.h sbasis-2d.h sbasis-curve.h sbasis-geometric.h diff --git a/src/2geom/Makefile_insert b/src/2geom/Makefile_insert index 2f23bc442..8872065fb 100644 --- a/src/2geom/Makefile_insert +++ b/src/2geom/Makefile_insert @@ -92,6 +92,7 @@ 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 \ diff --git a/src/2geom/pointwise.cpp b/src/2geom/pointwise.cpp index cd7f7914f..5cbccbca9 100644 --- a/src/2geom/pointwise.cpp +++ b/src/2geom/pointwise.cpp @@ -33,12 +33,19 @@ namespace Geom { -std::vector<satellite> -pointwise::findSatellites(int A) const +Pointwise::Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<int,Satellite> > satellites) + : _pwd2(pwd2), _satellites(satellites) { - std::vector<satelite> ret; +}; + +Pointwise::~Pointwise(){}; + +std::vector<Satellite> +Pointwise::findSatellites(int A) const +{ + std::vector<Satellite> ret; for(unsigned i = 0; i < _satellites.size(); i++){ - if(_satellites[i].first() == A){ + if(_satellites[i].first == A){ ret.push_back(_satellites[i].second); } } diff --git a/src/2geom/pointwise.h b/src/2geom/pointwise.h index c0974f54c..6e9c8840b 100644 --- a/src/2geom/pointwise.h +++ b/src/2geom/pointwise.h @@ -50,7 +50,6 @@ #include <2geom/sbasis-2d.h> #include <2geom/piecewise.h> #include <2geom/satellite.h> -#include <2geom/affine.h> namespace Geom { /** @@ -60,31 +59,28 @@ namespace Geom { class Pointwise { public: - Pointwise(){} - - Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<int,satelite> > satellites) - : _pwd2(pwd2), _satellites(satellites) - { - } - + Pointwise(){}; + Pointwise(Piecewise<D2<SBasis> > pwd2, std::vector<std::pair<int,Satellite> > satellites); virtual ~Pointwise(); - - std::vector<satelite> findSatellites(int A) const; + std::vector<Satellite> findSatellites(int A) const; Pointwise recalculate_for_new_pwd2(Piecewise<D2<SBasis> > A); Pointwise pwd2_reverse(int index); Pointwise pwd2_append(int index); Pointwise pwd2_prepend(int index); Pointwise pwd2_add(int index); Pointwise pwd2_del(int index); - Pointwise satellite_add(int index,satelite sat); - Pointwise satellite_del(int index,satelite sat); + Pointwise satellite_add(int index,Satellite sat); + Pointwise satellite_del(int index,Satellite sat); private: - std::vector<std::pair<int,satelite> > _satellites; Piecewise<D2<SBasis> > _pwd2; + std::vector<std::pair<int,Satellite> > _satellites; + }; -#endif //SEEN_GEOM_PW_SB_H +} // end namespace Geom + +#endif //SEEN_GEOM_POINTWISE_H /* Local Variables: mode:c++ diff --git a/src/2geom/satellite-enum.h b/src/2geom/satellite-enum.h index a71306bc9..474e98547 100644 --- a/src/2geom/satellite-enum.h +++ b/src/2geom/satellite-enum.h @@ -10,6 +10,8 @@ */ #include "util/enums.h" +/*#include <boost/bimap.hpp> +*/ namespace Geom { @@ -18,11 +20,20 @@ enum SatelliteType { INVERSE_FILLET, CHAMFER, INVERSE_CHAMFER, - INVALID_SATELLITE // This must be last (I made it such that it is not needed anymore I think..., Don't trust on it being last. - johan) + INVALID_SATELLITE // This must be last) }; -std::map<gchar const *value, SatelliteType> SatelliteTypeMap = boost::map_list_of("FILLET", FILLET)("INVERSE_FILLET", INVERSE_FILLET)("CHAMFER",CHAMFER)("INVERSE_CHAMFER",INVERSE_CHAMFER)("INVALID_SATELLITE",INVALID_SATELLITE); -extern const Util::EnumData<SatelliteType> SATELLITETypeData[]; /// defined in satelite.cpp -extern const Util::EnumDataConverter<SateliteType> SATELLITETypeConverter; /// defined in sattelite.cpp + +/* TODO maybe is best do next by bimap + typedef boost::bimap< Geom::SatelliteType,gchar const *> map_type ; + + map_type SatelliteTypeBimap; + + SatelliteTypeBimap.insert( map_type::value_type(FILLET, "FILLET")); + SatelliteTypeBimap.insert( map_type::value_type(INVERSE_FILLET, "INVERSE_FILLET")); + SatelliteTypeBimap.insert( map_type::value_type(CHAMFER, "CHAMFER")) ); + SatelliteTypeBimap.insert( map_type::value_type(INVERSE_CHAMFER, "INVERSE_CHAMFER")); + SatelliteTypeBimap.insert( map_type::value_type(INVALID_SATELLITE, "INVALID_SATELLITE")); +*/ } //namespace Geom diff --git a/src/2geom/satellite.h b/src/2geom/satellite.h index a18b08f27..8623ff1b0 100644 --- a/src/2geom/satellite.h +++ b/src/2geom/satellite.h @@ -34,39 +34,31 @@ #define LIB2GEOM_SEEN_SATELLITE_H #include <2geom/satellite-enum.h> +#include <2geom/d2.h> +#include <map> +#include <boost/assign.hpp> namespace Geom { -const Util::EnumData<SatelliteType> SATELLITETypeData[] = { - // {constant defined in satellite-enum.h, N_("name of satellite_type"), "name of your satellite type on SVG"} -/* 0.92 */ - {FILLET, N_("Fillet"), "fillet"}, - {INVERSE_FILLET, N_("Inverse Fillet"), "inverse_fillet"}, - {CHAMFER, N_("Chamfer"), "chamfer"}, - {INVERSE_CHAMFER, N_("Inverse Chamfer"), "inverse_chamfer"}, - {INTERPOLATE_POINTS, N_("Interpolate points"), "interpolate_points"}, -}; -const Util::EnumDataConverter<SatelliteType> SATELLITETypeConverter(SATELLITETypeData, sizeof(SATELLITETypeData)/sizeof(*SATELLITETypeData)); - - class Satellite { public: - Satellite() - {} - virtual ~Sattelite(); + Satellite(); + Satellite(SatelliteType satellitetype, bool isTime, bool active, bool hasMirror, bool hidden, double size, double time); - Satellite(SatelliteType satellitetype, bool isTime, bool active, bool mirror, bool after, bool hidden, double size, double time) - : _satellitetype(satellitetype), _time(time), _active(active), _mirror(mirror), _after(after), _hidden(hidden), _size(size), _time(time) - { - } + virtual ~Satellite(); void setSatelliteType(SatelliteType A) { _satellitetype = A; } + void setIsTime(bool A) + { + _isTime = A; + } + void setActive(bool A) { _active = A; @@ -74,7 +66,7 @@ class Satellite void setHasMirror(bool A) { - _mirror = A; + _hasMirror = A; } void setHidden(bool A) @@ -84,19 +76,17 @@ class Satellite void setTime(double A) { - _isTime = true; _time = A; } void setSize(double A) { - _isTime = false; _size = A; } SatelliteType satellitetype() const { - return _ts; + return _satellitetype; } bool isTime() const @@ -111,7 +101,7 @@ class Satellite bool hasMirror() const { - return _mirror; + return _hasMirror; } bool hidden() const @@ -129,36 +119,19 @@ class Satellite return _time; } - double time(D2<SBasis> curve) const + double time(Geom::D2<Geom::SBasis> curve) const { //todo make the process return _time; } - void setPosition(Geom::Point p, D2<SBasis> curve){ - _time = Geom::nearestPoint(p, curve); - if(!_isTime){ - if (curve.degreesOfFreedom() != 2) { - Piecewise<D2<SBasis> > u; - u.push_cut(0); - u.push(curve, 1); - u = portion(u, 0, _time); - _size = length(u, 0.001) * -1; - } else { - lenghtPart = length(last_pwd2[index], EPSILON); - _size = (time * lenghtPart) * -1; - } - } - } + void setPosition(Geom::Point p, Geom::D2<Geom::SBasis> curve); - Geom::Point getPosition(D2<SBasis> curve){ - return curve.pointAt(_time); - } + Geom::Point getPosition(Geom::D2<Geom::SBasis> curve); - bool isDegenerate() const - { - return _size = 0 && _time = 0; - } + static const std::map<SatelliteType,gchar const *> SatelliteTypeToGcharMap; + + static const std::map<gchar const *,SatelliteType> GcharMapToSatelliteType; private: SatelliteType _satellitetype; |
