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

panda/src/egg/eggNurbsCurve.I

Go to the documentation of this file.
00001 // Filename: eggNurbsCurve.I
00002 // Created by:  drose (15Feb00)
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 ////////////////////////////////////////////////////////////////////
00020 //     Function: EggNurbsCurve::Constructor
00021 //       Access: Public
00022 //  Description:
00023 ////////////////////////////////////////////////////////////////////
00024 INLINE EggNurbsCurve::
00025 EggNurbsCurve(const string &name) : EggCurve(name) {
00026   _order = 0;
00027 }
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: EggNurbsCurve::Copy constructor
00031 //       Access: Public
00032 //  Description:
00033 ////////////////////////////////////////////////////////////////////
00034 INLINE EggNurbsCurve::
00035 EggNurbsCurve(const EggNurbsCurve &copy) :
00036   EggCurve(copy),
00037   _knots(copy._knots),
00038   _order(copy._order)
00039 {
00040 }
00041 
00042 ////////////////////////////////////////////////////////////////////
00043 //     Function: EggNurbsCurve::Copy assignment operator
00044 //       Access: Public
00045 //  Description:
00046 ////////////////////////////////////////////////////////////////////
00047 INLINE EggNurbsCurve &EggNurbsCurve::
00048 operator = (const EggNurbsCurve &copy) {
00049   EggCurve::operator = (copy);
00050   _knots = copy._knots;
00051   _order = copy._order;
00052   return *this;
00053 }
00054 
00055 ////////////////////////////////////////////////////////////////////
00056 //     Function: EggNurbsCurve::set_order
00057 //       Access: Public
00058 //  Description: Directly changes the order to the indicated value
00059 //               (which must be an integer in the range 1 <= order <=
00060 //               4).  If possible, it is preferable to use the setup()
00061 //               method instead of this method, since changing the
00062 //               order directly may result in an invalid curve.
00063 ////////////////////////////////////////////////////////////////////
00064 INLINE void EggNurbsCurve::
00065 set_order(int order) {
00066   nassertv(order >= 1 && order <= 4);
00067   _order = order;
00068 }
00069 
00070 ////////////////////////////////////////////////////////////////////
00071 //     Function: EggNurbsCurve::set_knot
00072 //       Access: Public
00073 //  Description: Resets the value of the indicated knot as indicated.
00074 //               k must be in the range 0 <= k < get_num_knots(),
00075 //               and the value must be in the range get_knot(k - 1)
00076 //               <= value <= get_knot(k + 1).
00077 ////////////////////////////////////////////////////////////////////
00078 INLINE void EggNurbsCurve::
00079 set_knot(int k, double value) {
00080   nassertv(k >= 0 && k < (int)_knots.size());
00081   _knots[k] = value;
00082 }
00083 
00084 ////////////////////////////////////////////////////////////////////
00085 //     Function: EggNurbsCurve::get_order
00086 //       Access: Public
00087 //  Description: Returns the order of the curve.  The order is the
00088 //               degree of the NURBS equation plus 1; for a typical
00089 //               NURBS, the order is 4.  With this implementation of
00090 //               NURBS, the order must be in the range [1, 4].
00091 ////////////////////////////////////////////////////////////////////
00092 INLINE int EggNurbsCurve::
00093 get_order() const {
00094   return _order;
00095 }
00096 
00097 ////////////////////////////////////////////////////////////////////
00098 //     Function: EggNurbsCurve::get_degree
00099 //       Access: Public
00100 //  Description: Returns the degree of the curve.  For a typical
00101 //               NURBS, the degree is 3.
00102 ////////////////////////////////////////////////////////////////////
00103 INLINE int EggNurbsCurve::
00104 get_degree() const {
00105   return _order - 1;
00106 }
00107 
00108 ////////////////////////////////////////////////////////////////////
00109 //     Function: EggNurbsCurve::get_num_knots
00110 //       Access: Public
00111 //  Description: Returns the number of knots.
00112 ////////////////////////////////////////////////////////////////////
00113 INLINE int EggNurbsCurve::
00114 get_num_knots() const {
00115   return _knots.size();
00116 }
00117 
00118 ////////////////////////////////////////////////////////////////////
00119 //     Function: EggNurbsCurve::get_num_cvs
00120 //       Access: Public
00121 //  Description: Returns the total number of control vertices that
00122 //               *should* be defined for the curve.  This is
00123 //               determined by the number of knots and the order, in
00124 //               each direction; it does not necessarily reflect the
00125 //               number of vertices that have actually been added to
00126 //               the curve.  (However, if the number of vertices in
00127 //               the curve are wrong, the curve is invalid.)
00128 ////////////////////////////////////////////////////////////////////
00129 INLINE int EggNurbsCurve::
00130 get_num_cvs() const {
00131   return get_num_knots() - get_order();
00132 }
00133 
00134 ////////////////////////////////////////////////////////////////////
00135 //     Function: EggNurbsCurve::get_knot
00136 //       Access: Public
00137 //  Description: Returns the nth knot value defined.
00138 ////////////////////////////////////////////////////////////////////
00139 INLINE double EggNurbsCurve::
00140 get_knot(int k) const {
00141   nassertr(k >= 0 && k < (int)_knots.size(), 0.0);
00142   return _knots[k];
00143 }
00144 

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