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