Panda3D
nurbsCurveInterface.h
1 // Filename: nurbsCurveInterface.h
2 // Created by: drose (02Mar01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #ifndef NURBSCURVEINTERFACE_H
16 #define NURBSCURVEINTERFACE_H
17 
18 #include "pandabase.h"
19 
20 #include "luse.h"
21 #include "filename.h"
22 
23 class ParametricCurve;
24 
25 ////////////////////////////////////////////////////////////////////
26 // Class : NurbsCurveInterface
27 // Description : This abstract class defines the interface only for a
28 // Nurbs-style curve, with knots and coordinates in
29 // homogeneous space.
30 //
31 // The NurbsCurve class inherits both from this and from
32 // ParametricCurve.
33 ////////////////////////////////////////////////////////////////////
34 class EXPCL_PANDA_PARAMETRICS NurbsCurveInterface {
35 PUBLISHED:
36  virtual ~NurbsCurveInterface();
37  virtual void set_order(int order)=0;
38  virtual int get_order() const=0;
39 
40  virtual int get_num_cvs() const=0;
41  virtual int get_num_knots() const=0;
42 
43  virtual bool insert_cv(PN_stdfloat t)=0;
44 
45  INLINE int append_cv(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
46  INLINE int append_cv(const LVecBase3 &v);
47  INLINE int append_cv(const LVecBase4 &v);
48 
49  virtual bool remove_cv(int n)=0;
50  virtual void remove_all_cvs()=0;
51 
52  INLINE bool set_cv_point(int n, PN_stdfloat x, PN_stdfloat y, PN_stdfloat z);
53  INLINE bool set_cv_point(int n, const LVecBase3 &v);
54  INLINE LVecBase3 get_cv_point(int n) const;
55 
56  bool set_cv_weight(int n, PN_stdfloat w);
57  INLINE PN_stdfloat get_cv_weight(int n) const;
58 
59  virtual bool set_cv(int n, const LVecBase4 &v)=0;
60  virtual LVecBase4 get_cv(int n) const=0;
61 
62  virtual bool set_knot(int n, PN_stdfloat t)=0;
63  virtual PN_stdfloat get_knot(int n) const=0;
64 
65  MAKE_SEQ(get_cvs, get_num_cvs, get_cv);
66  MAKE_SEQ(get_knots, get_num_knots, get_knot);
67 
68  void write_cv(ostream &out, int n) const;
69 
70 protected:
71  virtual int append_cv_impl(const LVecBase4 &v)=0;
72 
73  void write(ostream &out, int indent_level) const;
74  bool format_egg(ostream &out, const string &name,
75  const string &curve_type, int indent_level) const;
76 
77  bool convert_to_nurbs(ParametricCurve *nc) const;
78 
79 public:
80  static TypeHandle get_class_type() {
81  return _type_handle;
82  }
83  static void init_type() {
84  register_type(_type_handle, "NurbsCurveInterface");
85  }
86 
87 private:
88  static TypeHandle _type_handle;
89 };
90 
91 #include "nurbsCurveInterface.I"
92 
93 #endif
This is the base class for all three-component vectors and points.
Definition: lvecBase3.h:105
A virtual base class for parametric curves.
This abstract class defines the interface only for a Nurbs-style curve, with knots and coordinates in...
This is the base class for all three-component vectors and points.
Definition: lvecBase4.h:111
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85