spline.h

Go to the documentation of this file.
00001 
00009 #ifndef SPLINE_H
00010 #define SPLINE_H
00011 
00012 #include <iostream>
00013 #include <vector>
00014 
00015 #include "util.h"
00016 #include "hash_classes.h"
00017 #include "hash_set.h"
00018 #include "cell.h"
00019 
00020 /* Forward class declarations to avoid inlcuding headers */
00021 class DataStore;
00022 
00103 class QBSpline{
00104  private:
00105     /* Private Member Functions */
00106     void initialize(const std::vector<ControlPoint> &newd, const std::vector<double> &newk, DataStore *_data_store, double _restlength, bool _closed);
00107 
00108     /* Constant Private Member Fucntions */
00113     double dt(int i) const;
00114     double ratio(int a,int b) const;
00115     Point2D *compute_new_points(Point2D *dp,Point2D *dq) const;
00116     double** solve_system(Matrix &A,double **bs,int cols,int num_vectors) const;
00117     double** solve_small_system(Matrix &A,double **bs,int num_vectors) const;
00124     void evaluate_full(double,Point2D*,Point2D*,Point2D*,int*) const;
00125     void simplify(double tol,bool *mark,int j,int z) const;
00128 public:
00129     /*Data Members */
00130     std::vector<ControlPoint> b; 
00131     std::vector<double> k; 
00132     std::vector<BezierVertex*> vertexs; 
00133     bool closed; 
00134     double restlength; 
00135     DataStore *data_store; 
00137     /* Constructors */
00138     QBSpline(const std::vector<ControlPoint> &newd, DataStore *_data_store, bool _closed);
00139     QBSpline(const std::vector<ControlPoint> &newd, const std::vector<double> &newk, DataStore *_data_store, bool _closed);
00140     QBSpline(const std::vector<ControlPoint> &newd, const std::vector<double> &newk, DataStore *_data_store, double _restlength, bool _closed);
00141 
00143     ~QBSpline() {}
00144 
00155     void set_bezier_vertex(double u, BezierVertex *v);
00156     void set_bezier_vertex(int idx, BezierVertex *v);
00165     void move(Point2D *dp, Point2D *dq, unsigned xCoord, unsigned yCoord);
00166 #ifdef RAW_LS
00167     void move_raw(Point2D *dp, Point2D *dq);
00168 #endif
00169     void add_knot(double u, ControlPoint &cp0, ControlPoint &cp1, ControlPoint &cp2);
00170     void split(int i, double u, ControlPoint &cp0, ControlPoint &cp1,
00171                ControlPoint &cp2);
00172     bool remove_knot(double u, ControlPoint &cp, double &u0, double &u1);
00178     int get_num_segments() const;
00179     int get_num_deboor() const;
00180     ControlPoint get_deboor(int i) const;
00181     void getip(double i,int *j,double *p) const;
00182     Point2D evaluate(double u) const;
00183     Point2D evaluate_segment(int,double) const;
00184     void bbox(double*,double*,double*,double*) const;
00185     void print() const;
00186     void douglas_peucker(double tol, hashers::hash_set<BezierVertex*> &keep) const;
00211     BezierVertex *get_bezier_vertex(unsigned idx) const;
00212     unsigned get_bezier_vertex_idx(const BezierVertex *v) const;
00213     ControlPoint get_control_point_at_idx(unsigned idx) const;
00214     ControlPoint get_edge_center_cp(unsigned u0_idx, unsigned u1_idx) const;
00215     double get_u_at_idx(unsigned idx) const;
00216     int get_closest_knot(double u) const;
00217     int get_closest_bezier(double u) const;
00218     int get_edge_cps(double u0, double u1, ControlPoint &cp0, ControlPoint &cp1, ControlPoint &cp2, int &cp0_is_vert, int &cp2_is_vert) const;
00219     ControlPoint get_segment_center(double u0, double u1) const;
00222 private:
00223     /* Illegal. */
00224     QBSpline(const QBSpline &o);
00225     QBSpline& operator=(const QBSpline &o);
00226 };
00227 
00228 extern std::ostream& operator<<(std::ostream& stream, const QBSpline& qbs);
00229 
00230 #endif /* SPLINE_H */

Generated on Mon May 24 09:53:30 2010 for TUMBLE by  doxygen 1.5.2