00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef EGGNURBSSURFACE_H
00020 #define EGGNURBSSURFACE_H
00021
00022 #include <pandabase.h>
00023
00024 #include "eggSurface.h"
00025 #include "eggNurbsCurve.h"
00026
00027 #include <vector_double.h>
00028
00029 #include "plist.h"
00030
00031
00032
00033
00034
00035 class EXPCL_PANDAEGG EggNurbsSurface : public EggSurface {
00036 public:
00037 typedef plist< PT(EggNurbsCurve) > Curves;
00038 typedef Curves Loop;
00039 typedef plist<Loop> Loops;
00040 typedef Loops Trim;
00041 typedef plist<Trim> Trims;
00042
00043 INLINE EggNurbsSurface(const string &name = "");
00044 INLINE EggNurbsSurface(const EggNurbsSurface ©);
00045 INLINE EggNurbsSurface &operator = (const EggNurbsSurface ©);
00046
00047 void setup(int u_order, int v_order,
00048 int num_u_knots, int num_v_knots);
00049
00050 INLINE void set_u_order(int u_order);
00051 INLINE void set_v_order(int v_order);
00052 void set_num_u_knots(int num);
00053 void set_num_v_knots(int num);
00054
00055 INLINE void set_u_knot(int k, double value);
00056 INLINE void set_v_knot(int k, double value);
00057 INLINE void set_cv(int ui, int vi, EggVertex *vertex);
00058
00059 bool is_valid() const;
00060
00061 INLINE int get_u_order() const;
00062 INLINE int get_v_order() const;
00063 INLINE int get_u_degree() const;
00064 INLINE int get_v_degree() const;
00065 INLINE int get_num_u_knots() const;
00066 INLINE int get_num_v_knots() const;
00067 INLINE int get_num_u_cvs() const;
00068 INLINE int get_num_v_cvs() const;
00069 INLINE int get_num_cvs() const;
00070
00071 INLINE int get_u_index(int vertex_index) const;
00072 INLINE int get_v_index(int vertex_index) const;
00073 INLINE int get_vertex_index(int ui, int vi) const;
00074
00075 bool is_closed_u() const;
00076 bool is_closed_v() const;
00077
00078 INLINE double get_u_knot(int k) const;
00079 INLINE double get_v_knot(int k) const;
00080 INLINE EggVertex *get_cv(int ui, int vi) const;
00081
00082 virtual void write(ostream &out, int indent_level) const;
00083
00084 Curves _curves_on_surface;
00085 Trims _trims;
00086
00087 protected:
00088 virtual void r_apply_texmats(EggTextureCollection &textures);
00089
00090 private:
00091 typedef vector_double Knots;
00092 Knots _u_knots;
00093 Knots _v_knots;
00094 int _u_order;
00095 int _v_order;
00096
00097 public:
00098
00099 static TypeHandle get_class_type() {
00100 return _type_handle;
00101 }
00102 static void init_type() {
00103 EggPrimitive::init_type();
00104 register_type(_type_handle, "EggNurbsSurface",
00105 EggPrimitive::get_class_type());
00106 }
00107 virtual TypeHandle get_type() const {
00108 return get_class_type();
00109 }
00110 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00111
00112 private:
00113 static TypeHandle _type_handle;
00114
00115 };
00116
00117 #include "eggNurbsSurface.I"
00118
00119 #endif