Panda3D
|
00001 // Filename: nurbsSurfaceEvaluator.h 00002 // Created by: drose (10Oct03) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef NURBSSURFACEEVALUATOR_H 00016 #define NURBSSURFACEEVALUATOR_H 00017 00018 #include "pandabase.h" 00019 #include "nurbsBasisVector.h" 00020 #include "nurbsSurfaceResult.h" 00021 #include "nurbsVertex.h" 00022 #include "pointerTo.h" 00023 #include "vector_float.h" 00024 #include "pvector.h" 00025 #include "nodePath.h" 00026 #include "referenceCount.h" 00027 #include "luse.h" 00028 00029 //////////////////////////////////////////////////////////////////// 00030 // Class : NurbsSurfaceEvaluator 00031 // Description : This class is an abstraction for evaluating NURBS 00032 // surfaces. It accepts an array of vertices, each of 00033 // which may be in a different coordinate space (as 00034 // defined by a NodePath), as well as an optional knot 00035 // vector. 00036 //////////////////////////////////////////////////////////////////// 00037 class EXPCL_PANDA_PARAMETRICS NurbsSurfaceEvaluator : public ReferenceCount { 00038 PUBLISHED: 00039 NurbsSurfaceEvaluator(); 00040 ~NurbsSurfaceEvaluator(); 00041 00042 INLINE void set_u_order(int u_order); 00043 INLINE int get_u_order() const; 00044 00045 INLINE void set_v_order(int v_order); 00046 INLINE int get_v_order() const; 00047 00048 void reset(int num_u_vertices, int num_v_vertices); 00049 00050 INLINE int get_num_u_vertices() const; 00051 INLINE int get_num_v_vertices() const; 00052 INLINE void set_vertex(int ui, int vi, const LVecBase4f &vertex); 00053 INLINE void set_vertex(int ui, int vi, const LVecBase3f &vertex, float weight = 1.0); 00054 INLINE const LVecBase4f &get_vertex(int ui, int vi) const; 00055 INLINE LVecBase4f get_vertex(int ui, int vi, const NodePath &rel_to) const; 00056 00057 INLINE void set_vertex_space(int ui, int vi, const NodePath &space); 00058 INLINE void set_vertex_space(int ui, int vi, const string &space); 00059 NodePath get_vertex_space(int ui, int vi, const NodePath &rel_to) const; 00060 00061 INLINE void set_extended_vertex(int ui, int vi, int d, float value); 00062 INLINE float get_extended_vertex(int ui, int vi, int d) const; 00063 void set_extended_vertices(int ui, int vi, int d, 00064 const float values[], int num_values); 00065 00066 INLINE int get_num_u_knots() const; 00067 void set_u_knot(int i, float knot); 00068 float get_u_knot(int i) const; 00069 MAKE_SEQ(get_u_knots, get_num_u_knots, get_u_knot); 00070 void normalize_u_knots(); 00071 00072 INLINE int get_num_v_knots() const; 00073 void set_v_knot(int i, float knot); 00074 float get_v_knot(int i) const; 00075 MAKE_SEQ(get_v_knots, get_num_v_knots, get_v_knot); 00076 void normalize_v_knots(); 00077 00078 INLINE int get_num_u_segments() const; 00079 INLINE int get_num_v_segments() const; 00080 00081 PT(NurbsSurfaceResult) evaluate(const NodePath &rel_to = NodePath()) const; 00082 00083 void output(ostream &out) const; 00084 00085 public: 00086 void get_vertices(pvector<LVecBase4f> &verts, const NodePath &rel_to) const; 00087 void get_vertices(pvector<LPoint3f> &verts, const NodePath &rel_to) const; 00088 00089 private: 00090 INLINE NurbsVertex &vert(int ui, int vi); 00091 INLINE const NurbsVertex &vert(int ui, int vi) const; 00092 00093 void recompute_u_knots(); 00094 void recompute_v_knots(); 00095 void recompute_u_basis(); 00096 void recompute_v_basis(); 00097 00098 int _u_order; 00099 int _v_order; 00100 00101 typedef pvector<NurbsVertex> Vertices; 00102 Vertices _vertices; 00103 int _num_u_vertices; 00104 int _num_v_vertices; 00105 00106 bool _u_knots_dirty; 00107 bool _v_knots_dirty; 00108 typedef vector_float Knots; 00109 Knots _u_knots; 00110 Knots _v_knots; 00111 00112 bool _u_basis_dirty; 00113 bool _v_basis_dirty; 00114 NurbsBasisVector _u_basis; 00115 NurbsBasisVector _v_basis; 00116 }; 00117 00118 INLINE ostream &operator << (ostream &out, const NurbsSurfaceEvaluator &n); 00119 00120 #include "nurbsSurfaceEvaluator.I" 00121 00122 #endif 00123