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

panda/src/parametrics/nurbsPPCurve.h

Go to the documentation of this file.
00001 // Filename: nurbsPPCurve.h
00002 // Created by:  drose (01Mar01)
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 NURBSPPCURVE_H
00020 #define NURBSPPCURVE_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "parametricCurve.h"
00025 #include "nurbsCurveInterface.h"
00026 
00027 #include <nurbs.hh>
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //       Class : NurbsPPCurve
00031 // Description : A Nonuniform Rational B-Spline.
00032 //
00033 //               This class is an extension to Panda NURBS curves,
00034 //               taking advantage of the external NURBS++ library, if
00035 //               it is available.  It stands in for the Panda-native
00036 //               ClassicNurbsCurve, providing more and better
00037 //               functionality.
00038 //
00039 //               This file is only compiled if NURBS++ is available.
00040 ////////////////////////////////////////////////////////////////////
00041 class EXPCL_PANDA NurbsPPCurve : public ParametricCurve, public NurbsCurveInterface {
00042 PUBLISHED:
00043   NurbsPPCurve();
00044   NurbsPPCurve(const ParametricCurve &pc);
00045 public:
00046   NurbsPPCurve(int order, int num_cvs,
00047                const float knots[], const LVecBase4f cvs[]);
00048 PUBLISHED:
00049   virtual ~NurbsPPCurve();
00050 
00051 public:
00052   // We don't need to re-publish these, since they're all published
00053   // from NurbsCurveInterface.
00054   virtual float get_max_t() const;
00055 
00056   virtual void set_order(int order);
00057   virtual int get_order() const;
00058 
00059   virtual int get_num_cvs() const;
00060   virtual int get_num_knots() const;
00061 
00062   virtual bool insert_cv(float t);
00063 
00064   virtual bool remove_cv(int n);
00065   virtual void remove_all_cvs();
00066 
00067   virtual bool set_cv(int n, const LVecBase4f &v);
00068   virtual LVecBase4f get_cv(int n) const;
00069 
00070   virtual bool set_knot(int n, float t);
00071   virtual float get_knot(int n) const;
00072 
00073   virtual bool recompute();
00074 
00075 public:
00076   virtual bool get_point(float t, LVecBase3f &point) const;
00077   virtual bool get_tangent(float t, LVecBase3f &tangent) const;
00078   virtual bool get_pt(float t, LVecBase3f &point, LVecBase3f &tangent) const;
00079   virtual bool get_2ndtangent(float t, LVecBase3f &tangent2) const;
00080 
00081   virtual bool stitch(const ParametricCurve *a, const ParametricCurve *b);
00082 
00083   virtual NurbsCurveInterface *get_nurbs_interface();
00084   virtual bool convert_to_nurbs(ParametricCurve *nc) const;
00085   virtual void write(ostream &out, int indent_level = 0) const;
00086 
00087 protected:
00088   virtual int append_cv_impl(const LVecBase4f &v);
00089   virtual bool format_egg(ostream &out, const string &name,
00090                           const string &curve_type, int indent_level) const;
00091 
00092 private:
00093   typedef pvector<LVecBase4f> Points;
00094   typedef pvector<float> Knots;
00095 
00096   bool make_nurbs_valid();
00097   void make_arrays_valid();
00098   bool copy_nurbs(PLib::NurbsCurvef &nurbs) const;
00099   void copy_arrays(Points &points, Knots &knots, int &order) const;
00100 
00101   static bool make_nurbs_from(PLib::NurbsCurvef &nurbs,
00102                               const Points &points, const Knots &knots,
00103                               int order);
00104   static void make_arrays_from(const PLib::NurbsCurvef &nurbs,
00105                                Points &points, Knots &knots, int &order);
00106 
00107   PLib::NurbsCurvef _nurbs;
00108 
00109   int _order;
00110   Points _points;
00111   Knots _knots;
00112   bool _nurbs_valid;
00113 
00114 public:
00115   static TypeHandle get_class_type() {
00116     return _type_handle;
00117   }
00118   static void init_type() {
00119     ParametricCurve::init_type();
00120     NurbsCurveInterface::init_type();
00121     register_type(_type_handle, "NurbsPPCurve",
00122                   ParametricCurve::get_class_type(),
00123                   NurbsCurveInterface::get_class_type());
00124   }
00125   virtual TypeHandle get_type() const {
00126     return get_class_type();
00127   }
00128   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00129 
00130 private:
00131   static TypeHandle _type_handle;
00132 };
00133 
00134 typedef NurbsPPCurve NurbsCurve;
00135 
00136 #endif

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