Panda3D
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions

EggNurbsSurface Class Reference

A parametric NURBS surface. More...

#include "eggNurbsSurface.h"

Inheritance diagram for EggNurbsSurface:
EggSurface EggPrimitive EggNode EggAttributes EggRenderMode EggNamedObject MemoryBase EggObject Namable TypedReferenceCount MemoryBase TypedObject ReferenceCount MemoryBase MemoryBase

List of all members.

Public Types

typedef plist< PT(EggNurbsCurve) > Curves
typedef Curves Loop
typedef plist< Loop > Loops
typedef Loops Trim
typedef plist< Trim > Trims

Public Member Functions

 EggNurbsSurface (const string &name="")
 EggNurbsSurface (const EggNurbsSurface &copy)
virtual TypeHandle force_init_type ()
EggVertexget_cv (int ui, int vi) const
 Returns the control vertex at the indicate U, V position.
int get_num_cvs () const
 Returns the total number of control vertices that should* be defined for the surface.
int get_num_u_cvs () const
 Returns the number of control vertices that should be present in the U direction.
int get_num_u_knots () const
 Returns the number of knots in the U direction.
int get_num_v_cvs () const
 Returns the number of control vertices that should be present in the V direction.
int get_num_v_knots () const
 Returns the number of knots in the V direction.
virtual TypeHandle get_type () const
int get_u_degree () const
 Returns the degree of the surface in the U direction.
int get_u_index (int vertex_index) const
 Returns the U index number of the given vertex within the EggPrimitive's linear list of vertices.
double get_u_knot (int k) const
 Returns the nth knot value defined in the U direction.
int get_u_order () const
 Returns the order of the surface in the U direction.
int get_v_degree () const
 Returns the degree of the surface in the V direction.
int get_v_index (int vertex_index) const
 Returns the V index number of the given vertex within the EggPrimitive's linear list of vertices.
double get_v_knot (int k) const
 Returns the nth knot value defined in the V direction.
int get_v_order () const
 Returns the order of the surface in the V direction.
int get_vertex_index (int ui, int vi) const
 Returns the index number within the EggPrimitive's list of the control vertex at position ui, vi.
bool is_closed_u () const
 Returns true if the surface appears to be closed in the U direction.
bool is_closed_v () const
 Returns true if the surface appears to be closed in the V direction.
bool is_valid () const
 Returns true if the NURBS parameters are all internally consistent (e.g.
 MAKE_SEQ (get_v_knots, get_num_v_knots, get_v_knot)
 MAKE_SEQ (get_u_knots, get_num_u_knots, get_u_knot)
EggNurbsSurfaceoperator= (const EggNurbsSurface &copy)
void set_cv (int ui, int vi, EggVertex *vertex)
 Redefines the control vertex associated with a particular u, v coordinate pair.
void set_num_u_knots (int num)
 Directly changes the number of knots in the U direction.
void set_num_v_knots (int num)
 Directly changes the number of knots in the V direction.
void set_u_knot (int k, double value)
 Resets the value of the indicated knot as indicated.
void set_u_order (int u_order)
 Directly changes the order in the U direction to the indicated value (which must be an integer in the range 1 <= u_order <= 4).
void set_v_knot (int k, double value)
 Resets the value of the indicated knot as indicated.
void set_v_order (int v_order)
 Directly changes the order in the V direction to the indicated value (which must be an integer in the range 1 <= v_order <= 4).
void setup (int u_order, int v_order, int num_u_knots, int num_v_knots)
 Prepares a new surface definition with the indicated order and number of knots in each dimension.
virtual void write (ostream &out, int indent_level) const
 Writes the nurbsSurface to the indicated output stream in Egg format.

Static Public Member Functions

static TypeHandle get_class_type ()
static void init_type ()

Public Attributes

Curves _curves_on_surface
Trims _trims

Protected Member Functions

virtual void r_apply_texmats (EggTextureCollection &textures)
 The recursive implementation of apply_texmats().

Detailed Description

A parametric NURBS surface.

Definition at line 29 of file eggNurbsSurface.h.


Member Function Documentation

EggVertex * EggNurbsSurface::get_cv ( int  ui,
int  vi 
) const [inline]

Returns the control vertex at the indicate U, V position.

Definition at line 322 of file eggNurbsSurface.I.

References EggPrimitive::get_vertex(), and get_vertex_index().

int EggNurbsSurface::get_num_cvs ( ) const [inline]

Returns the total number of control vertices that should* be defined for the surface.

This is determined by the number of knots and the order, in each direction; it does not necessarily reflect the number of vertices that have actually been added to the surface. (However, if the number of vertices in the surface are wrong, the surface is invalid.)

Definition at line 244 of file eggNurbsSurface.I.

References get_num_u_cvs(), and get_num_v_cvs().

Referenced by get_u_index(), get_v_index(), and is_valid().

int EggNurbsSurface::get_num_u_cvs ( ) const [inline]

Returns the number of control vertices that should be present in the U direction.

This is determined by the number of knots and the order; it does not necessarily reflect the number of vertices that have actually been added to the surface. (However, if the number of vertices in the surface are wrong, the surface is invalid.)

Definition at line 212 of file eggNurbsSurface.I.

References get_num_u_knots(), and get_u_order().

Referenced by get_num_cvs(), get_u_index(), get_v_index(), and get_vertex_index().

int EggNurbsSurface::get_num_u_knots ( ) const [inline]

Returns the number of knots in the U direction.

Definition at line 186 of file eggNurbsSurface.I.

Referenced by get_num_u_cvs(), and is_valid().

int EggNurbsSurface::get_num_v_cvs ( ) const [inline]

Returns the number of control vertices that should be present in the V direction.

This is determined by the number of knots and the order; it does not necessarily reflect the number of vertices that have actually been added to the surface. (However, if the number of vertices in the surface are wrong, the surface is invalid.)

Definition at line 228 of file eggNurbsSurface.I.

References get_num_v_knots(), and get_v_order().

Referenced by get_num_cvs(), and get_vertex_index().

int EggNurbsSurface::get_num_v_knots ( ) const [inline]

Returns the number of knots in the V direction.

Definition at line 196 of file eggNurbsSurface.I.

Referenced by get_num_v_cvs(), and is_valid().

int EggNurbsSurface::get_u_degree ( ) const [inline]

Returns the degree of the surface in the U direction.

For a typical NURBS, the degree is 3.

Definition at line 165 of file eggNurbsSurface.I.

int EggNurbsSurface::get_u_index ( int  vertex_index) const [inline]

Returns the U index number of the given vertex within the EggPrimitive's linear list of vertices.

An EggNurbsSurface maps a linear list of vertices to its 2-d mesh; this returns the U index number that corresponds to the nth vertex in the list.

Definition at line 258 of file eggNurbsSurface.I.

References get_num_cvs(), and get_num_u_cvs().

double EggNurbsSurface::get_u_knot ( int  k) const [inline]

Returns the nth knot value defined in the U direction.

Definition at line 298 of file eggNurbsSurface.I.

Referenced by is_closed_u(), and is_valid().

int EggNurbsSurface::get_u_order ( ) const [inline]

Returns the order of the surface in the U direction.

The order is the degree of the NURBS equation plus 1; for a typical NURBS, the order is 4. With this implementation of NURBS, the order must be in the range [1, 4].

Definition at line 140 of file eggNurbsSurface.I.

Referenced by get_num_u_cvs(), is_closed_u(), and write().

int EggNurbsSurface::get_v_degree ( ) const [inline]

Returns the degree of the surface in the V direction.

for a typical NURBS, the degree is 3.

Definition at line 176 of file eggNurbsSurface.I.

int EggNurbsSurface::get_v_index ( int  vertex_index) const [inline]

Returns the V index number of the given vertex within the EggPrimitive's linear list of vertices.

An EggNurbsSurface maps a linear list of vertices to its 2-d mesh; this returns the V index number that corresponds to the nth vertex in the list.

Definition at line 273 of file eggNurbsSurface.I.

References get_num_cvs(), and get_num_u_cvs().

double EggNurbsSurface::get_v_knot ( int  k) const [inline]

Returns the nth knot value defined in the V direction.

Definition at line 310 of file eggNurbsSurface.I.

Referenced by is_closed_v(), and is_valid().

int EggNurbsSurface::get_v_order ( ) const [inline]

Returns the order of the surface in the V direction.

The order is the degree of the NURBS equation plus 1; for a typical NURBS, the order is 4. With this implementation of NURBS, the order must be in the range [1, 4].

Definition at line 154 of file eggNurbsSurface.I.

Referenced by get_num_v_cvs(), is_closed_v(), and write().

int EggNurbsSurface::get_vertex_index ( int  ui,
int  vi 
) const [inline]

Returns the index number within the EggPrimitive's list of the control vertex at position ui, vi.

Definition at line 285 of file eggNurbsSurface.I.

References get_num_u_cvs(), and get_num_v_cvs().

Referenced by get_cv(), and set_cv().

bool EggNurbsSurface::is_closed_u ( ) const

Returns true if the surface appears to be closed in the U direction.

Since the Egg syntax does not provide a means for explicit indication of closure, this has to be guessed at by examining the surface itself.

Definition at line 148 of file eggNurbsSurface.cxx.

References get_u_knot(), and get_u_order().

bool EggNurbsSurface::is_closed_v ( ) const

Returns true if the surface appears to be closed in the V direction.

Since the Egg syntax does not provide a means for explicit indication of closure, this has to be guessed at by examining the surface itself.

Definition at line 174 of file eggNurbsSurface.cxx.

References get_v_knot(), and get_v_order().

bool EggNurbsSurface::is_valid ( ) const

Returns true if the NURBS parameters are all internally consistent (e.g.

it has the right number of vertices to match its number of knots and order in each dimension), or false otherwise.

Definition at line 110 of file eggNurbsSurface.cxx.

References get_num_cvs(), get_num_u_knots(), get_num_v_knots(), get_u_knot(), and get_v_knot().

void EggNurbsSurface::r_apply_texmats ( EggTextureCollection textures) [protected, virtual]

The recursive implementation of apply_texmats().

Reimplemented from EggPrimitive.

Definition at line 248 of file eggNurbsSurface.cxx.

void EggNurbsSurface::set_cv ( int  ui,
int  vi,
EggVertex vertex 
) [inline]

Redefines the control vertex associated with a particular u, v coordinate pair.

This is just a shorthand to access the EggPrimitive's normal vertex assignment for a 2-d control vertex.

Definition at line 125 of file eggNurbsSurface.I.

References get_vertex_index(), and EggPrimitive::set_vertex().

void EggNurbsSurface::set_num_u_knots ( int  num)

Directly changes the number of knots in the U direction.

This will either add zero-valued knots onto the end, or truncate knot values from the end, depending on whether the list is being increased or decreased. If possible, it is preferable to use the setup() method instead of directly setting the number of knots, as this may result in an invalid surface.

Definition at line 63 of file eggNurbsSurface.cxx.

void EggNurbsSurface::set_num_v_knots ( int  num)

Directly changes the number of knots in the V direction.

This will either add zero-valued knots onto the end, or truncate knot values from the end, depending on whether the list is being increased or decreased. If possible, it is preferable to use the setup() method instead of directly setting the number of knots, as this may result in an invalid surface.

Definition at line 88 of file eggNurbsSurface.cxx.

void EggNurbsSurface::set_u_knot ( int  k,
double  value 
) [inline]

Resets the value of the indicated knot as indicated.

k must be in the range 0 <= k < get_num_u_knots(), and the value must be in the range get_u_knot(k - 1) <= value <= get_u_knot(k + 1).

Definition at line 97 of file eggNurbsSurface.I.

void EggNurbsSurface::set_u_order ( int  u_order) [inline]

Directly changes the order in the U direction to the indicated value (which must be an integer in the range 1 <= u_order <= 4).

If possible, it is preferable to use the setup() method instead of this method, since changing the order directly may result in an invalid surface.

Definition at line 67 of file eggNurbsSurface.I.

void EggNurbsSurface::set_v_knot ( int  k,
double  value 
) [inline]

Resets the value of the indicated knot as indicated.

k must be in the range 0 <= k < get_num_v_knots(), and the value must be in the range get_v_knot(k - 1) <= value <= get_v_knot(k + 1).

Definition at line 111 of file eggNurbsSurface.I.

void EggNurbsSurface::set_v_order ( int  v_order) [inline]

Directly changes the order in the V direction to the indicated value (which must be an integer in the range 1 <= v_order <= 4).

If possible, it is preferable to use the setup() method instead of this method, since changing the order directly may result in an invalid surface.

Definition at line 83 of file eggNurbsSurface.I.

void EggNurbsSurface::setup ( int  u_order,
int  v_order,
int  num_u_knots,
int  num_v_knots 
)

Prepares a new surface definition with the indicated order and number of knots in each dimension.

This also implies a particular number of vertices in each dimension as well (the number of knots minus the order), but it is up to the user to add the correct number of vertices to the surface by repeatedly calling push_back().

Definition at line 33 of file eggNurbsSurface.cxx.

void EggNurbsSurface::write ( ostream &  out,
int  indent_level 
) const [virtual]

Writes the nurbsSurface to the indicated output stream in Egg format.

Implements EggPrimitive.

Definition at line 191 of file eggNurbsSurface.cxx.

References get_u_order(), EggSurface::get_u_subdiv(), get_v_order(), EggSurface::get_v_subdiv(), EggPrimitive::write_body(), and EggNamedObject::write_header().


The documentation for this class was generated from the following files:
 All Classes Functions Variables Enumerations