Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/parametrics/curveFitter.h

Go to the documentation of this file.
00001 // Filename: curveFitter.h
00002 // Created by:  drose (17Sep98)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef CURVEFITTER_H
00020 #define CURVEFITTER_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include <luse.h>
00025 
00026 #include "parametricCurveCollection.h"
00027 
00028 #include <typedef.h>
00029 #include "pvector.h"
00030 
00031 class HermiteCurve;
00032 class ParametricCurve;
00033 class ClassicNurbsCurve;
00034 
00035 ////////////////////////////////////////////////////////////////////
00036 //       Class : CurveFitter
00037 // Description :
00038 ////////////////////////////////////////////////////////////////////
00039 class CurveFitter {
00040 PUBLISHED:
00041   CurveFitter();
00042   ~CurveFitter();
00043 
00044   void reset();
00045   void add_xyz(float t, const LVecBase3f &xyz);
00046   void add_hpr(float t, const LVecBase3f &hpr);
00047   void add_xyz_hpr(float t, const LVecBase3f &xyz, const LVecBase3f &hpr);
00048 
00049   int get_num_samples() const;
00050   float get_sample_t(int n) const;
00051   LVecBase3f get_sample_xyz(int n) const;
00052   LVecBase3f get_sample_hpr(int n) const;
00053   LVecBase3f get_sample_tangent(int n) const;
00054   void remove_samples(int begin, int end);
00055 
00056   void sample(ParametricCurveCollection *curves, int count);
00057   void wrap_hpr();
00058   void sort_points();
00059   void desample(float factor);
00060 
00061   void compute_tangents(float scale);
00062   PT(ParametricCurveCollection) make_hermite() const;
00063   PT(ParametricCurveCollection) make_nurbs() const;
00064 
00065   void output(ostream &out) const;
00066   void write(ostream &out) const;
00067 
00068 public:
00069   class DataPoint {
00070   public:
00071     INLINE DataPoint();
00072     INLINE void output(ostream &out) const;
00073     INLINE bool operator < (const DataPoint &other) const;
00074 
00075     float _t;
00076     LVecBase3f _xyz;
00077     LVecBase3f _hpr;
00078     LVecBase3f _tangent;
00079     LVecBase3f _hpr_tangent;
00080   };
00081 
00082   typedef pvector<DataPoint> Data;
00083   Data _data;
00084 
00085   bool _got_xyz;
00086   bool _got_hpr;
00087 
00088 public:
00089   static TypeHandle get_class_type() {
00090     return _type_handle;
00091   }
00092   static void init_type() {
00093     register_type(_type_handle, "CurveFitter");
00094   }
00095 
00096 private:
00097   static TypeHandle _type_handle;
00098 };
00099 
00100 INLINE ostream &operator << (ostream &out, const CurveFitter::DataPoint &dp) {
00101   dp.output(out);
00102   return out;
00103 }
00104 
00105 INLINE ostream &operator << (ostream &out, const CurveFitter &cf) {
00106   cf.output(out);
00107   return out;
00108 }
00109 
00110 #include "curveFitter.I"
00111 
00112 #endif

Generated on Fri May 2 00:40:42 2003 for Panda by doxygen1.3