Changeset 5:59e37f7014a1 in rrlib_geometry


Ignore:
Timestamp:
12.01.2011 03:09:02 (9 years ago)
Author:
Tobias Föhst <foehst@…>
Branch:
default
Phase:
public
Convert:
svn:2168a036-5f5f-4461-96ec-bf27dc59b608/trunk@6
Message:

Generalized interfaces for arbitrary data sources and not only std::vector

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • tCardinalSplineCurve.h

    r4 r5  
    8080public: 
    8181 
    82   tCardinalSplineCurve(const std::vector<typename tShape::tPoint> &control_points, double tension = 0.0); 
     82  template <typename TIterator> 
     83  tCardinalSplineCurve(TIterator begin, TIterator end, double tension = 0.0); 
     84 
     85  template <typename TSTLContainer> 
     86  explicit tCardinalSplineCurve(const TSTLContainer &control_points, double tension = 0.0); 
    8387 
    8488  inline double GetTension() const 
  • tCardinalSplineCurve.hpp

    r4 r5  
    6666//---------------------------------------------------------------------- 
    6767template <size_t Tdimension, typename TElement> 
    68 tCardinalSplineCurve<Tdimension, TElement>::tCardinalSplineCurve(const std::vector<typename tShape::tPoint> &control_points, double tension) 
     68template <typename TIterator> 
     69tCardinalSplineCurve<Tdimension, TElement>::tCardinalSplineCurve(TIterator begin, TIterator end, double tension) 
     70    : tSplineCurve(begin, end), 
     71    tension(tension) 
     72{} 
     73 
     74template <size_t Tdimension, typename TElement> 
     75template <typename TSTLContainer> 
     76tCardinalSplineCurve<Tdimension, TElement>::tCardinalSplineCurve(const TSTLContainer &control_points, double tension) 
    6977    : tSplineCurve(control_points), 
    7078    tension(tension) 
  • tSplineCurve.h

    r4 r5  
    8686  typedef typename tBezierCurve::tParameter tParameter; 
    8787 
    88   tSplineCurve(const std::vector<typename tShape::tPoint> &control_points); 
     88  template <typename TIterator> 
     89  tSplineCurve(TIterator begin, TIterator end); 
     90 
     91  template <typename TSTLContainer> 
     92  explicit tSplineCurve(const TSTLContainer &control_points); 
    8993 
    9094  inline const size_t GetNumberOfControlPoints() const 
  • tSplineCurve.hpp

    r4 r5  
    3232// External includes (system with <>, local with "") 
    3333//---------------------------------------------------------------------- 
     34#include <algorithm> 
    3435 
    3536//---------------------------------------------------------------------- 
     
    6667//---------------------------------------------------------------------- 
    6768template <size_t Tdimension, typename TElement, unsigned int Tdegree> 
    68 tSplineCurve<Tdimension, TElement, Tdegree>::tSplineCurve(const std::vector<typename tShape::tPoint> &control_points) 
    69     : control_points(control_points) 
    70 { 
     69template <typename TIterator> 
     70tSplineCurve<Tdimension, TElement, Tdegree>::tSplineCurve(TIterator begin, TIterator end) 
     71{ 
     72  std::copy(begin, end, std::back_inserter(this->control_points)); 
     73  assert(control_points.size() > Tdegree); 
     74} 
     75 
     76template <size_t Tdimension, typename TElement, unsigned int Tdegree> 
     77template <typename TSTLContainer> 
     78tSplineCurve<Tdimension, TElement, Tdegree>::tSplineCurve(const TSTLContainer &control_points) 
     79{ 
     80  std::copy(control_points.begin(), control_points.end(), std::back_inserter(this->control_points)); 
    7181  assert(control_points.size() > Tdegree); 
    7282} 
     
    136146const typename tSplineCurve<Tdimension, TElement, Tdegree>::tBezierCurve tSplineCurve<Tdimension, TElement, Tdegree>::GetBezierCurveForParameter(tParameter t, tParameter &local_t) const 
    137147{ 
    138   local_t = t < this->GetNumberOfSegments() ? t - trunc(t) : 1.0; 
     148  local_t = t < this->GetNumberOfSegments() ? t - std::trunc(t) : 1.0; 
    139149  return this->GetBezierCurveForParameter(t); 
    140150} 
  • tUniformBSplineCurve.h

    r4 r5  
    8080public: 
    8181 
    82   tUniformBSplineCurve(const std::vector<typename tShape::tPoint> &control_points, double tension = 0.0); 
     82  template <typename TIterator> 
     83  tUniformBSplineCurve(TIterator begin, TIterator end, double tension = 0.0); 
     84 
     85  template <typename TSTLContainer> 
     86  explicit tUniformBSplineCurve(const TSTLContainer &control_points, double tension = 0.0); 
    8387 
    8488  inline double GetTension() const 
  • tUniformBSplineCurve.hpp

    r4 r5  
    6666//---------------------------------------------------------------------- 
    6767template <size_t Tdimension, typename TElement> 
    68 tUniformBSplineCurve<Tdimension, TElement>::tUniformBSplineCurve(const std::vector<typename tShape::tPoint> &control_points, double tension) 
     68template <typename TIterator> 
     69tUniformBSplineCurve<Tdimension, TElement>::tUniformBSplineCurve(TIterator begin, TIterator end, double tension) 
     70    : tSplineCurve(begin, end), 
     71    tension(tension) 
     72{} 
     73 
     74template <size_t Tdimension, typename TElement> 
     75template <typename TSTLContainer> 
     76tUniformBSplineCurve<Tdimension, TElement>::tUniformBSplineCurve(const TSTLContainer &control_points, double tension) 
    6977    : tSplineCurve(control_points), 
    7078    tension(tension) 
  • test/test_geometries.cpp

    r4 r5  
    6868typedef rrlib::geometry::tBezierCurve<2, tElement, 3> tBezierCurve; 
    6969typedef rrlib::geometry::tSplineCurve<2, tElement, 3> tSplineCurve; 
    70 //typedef rrlib::geometry::tUniformBSplineCurve<2, tElement> tConcreteSplineCurve; 
    71 typedef rrlib::geometry::tCardinalSplineCurve<2, tElement> tConcreteSplineCurve; 
     70typedef rrlib::geometry::tUniformBSplineCurve<2, tElement> tConcreteSplineCurve; 
     71//typedef rrlib::geometry::tCardinalSplineCurve<2, tElement> tConcreteSplineCurve; 
    7272 
    7373//---------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.