Panda3D
|
This class is an abstraction for evaluating NURBS surfaces. More...
#include "nurbsSurfaceEvaluator.h"
Public Member Functions | |
float | get_extended_vertex (int ui, int vi, int d) const |
Returns an n-dimensional vertex value. | |
int | get_num_u_knots () const |
Returns the number of knot values in the surface in the U direction. | |
int | get_num_u_segments () const |
Returns the number of piecewise continuous segments in the surface in the U direction. | |
int | get_num_u_vertices () const |
Returns the number of control vertices in the U direction on the surface. | |
int | get_num_v_knots () const |
Returns the number of knot values in the surface in the V direction. | |
int | get_num_v_segments () const |
Returns the number of piecewise continuous segments in the surface in the V direction. | |
int | get_num_v_vertices () const |
Returns the number of control vertices in the V direction on the surface. | |
int | get_ref_count () const |
Returns the current reference count. | |
float | get_u_knot (int i) const |
Returns the value of the nth knot. | |
int | get_u_order () const |
Returns the order of the surface in the U direction as set by a previous call to set_u_order(). | |
float | get_v_knot (int i) const |
Returns the value of the nth knot. | |
int | get_v_order () const |
Returns the order of the surface in the V direction as set by a previous call to set_v_order(). | |
const LVecBase4f & | get_vertex (int ui, int vi) const |
Returns the nth control vertex of the surface, relative to its indicated coordinate space. | |
LVecBase4f | get_vertex (int ui, int vi, const NodePath &rel_to) const |
Returns the nth control vertex of the surface, relative to the given coordinate space. | |
NodePath | get_vertex_space (int ui, int vi, const NodePath &rel_to) const |
Returns the coordinate space of the nth control vertex of the surface, expressed as a NodePath. | |
void | get_vertices (pvector< LVecBase4f > &verts, const NodePath &rel_to) const |
Fills the indicated vector with the set of vertices in the surface, transformed to the given space. | |
void | get_vertices (pvector< LPoint3f > &verts, const NodePath &rel_to) const |
Fills the indicated vector with the set of vertices in the surface, transformed to the given space. | |
WeakReferenceList * | get_weak_list () const |
Returns the WeakReferenceList associated with this ReferenceCount object. | |
bool | has_weak_list () const |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. | |
void | local_object () |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. | |
MAKE_SEQ (get_u_knots, get_num_u_knots, get_u_knot) | |
MAKE_SEQ (get_v_knots, get_num_v_knots, get_v_knot) | |
void | normalize_u_knots () |
Normalizes the knot sequence so that the parametric range of the surface in the U direction is 0 . | |
void | normalize_v_knots () |
Normalizes the knot sequence so that the parametric range of the surface in the U direction is 0 . | |
void | operator delete (void *ptr, void *) |
void | operator delete (void *ptr) |
void | operator delete[] (void *, void *) |
void | operator delete[] (void *ptr) |
void * | operator new (size_t size) |
void * | operator new (size_t size, void *ptr) |
void * | operator new[] (size_t size, void *ptr) |
void * | operator new[] (size_t size) |
void | output (ostream &out) const |
PT (NurbsSurfaceResult) evaluate(const NodePath &rel_to | |
void | ref () const |
Explicitly increments the reference count. | |
void | reset (int num_u_vertices, int num_v_vertices) |
Resets all the vertices and knots to their default values, and sets the surface up with the indicated number of vertices. | |
void | set_extended_vertex (int ui, int vi, int d, float value) |
Sets an n-dimensional vertex value. | |
void | set_extended_vertices (int ui, int vi, int d, const float values[], int num_values) |
Simultaneously sets several extended values in the slots d through (d + num_values - 1) from the num_values elements of the indicated array. | |
void | set_u_knot (int i, float knot) |
Sets the value of the nth knot. | |
void | set_u_order (int u_order) |
Sets the order of the surface in the U direction. | |
void | set_v_knot (int i, float knot) |
Sets the value of the nth knot. | |
void | set_v_order (int v_order) |
Sets the order of the surface in the V direction. | |
void | set_vertex (int ui, int vi, const LVecBase3f &vertex, float weight=1.0) |
Sets the nth control vertex of the surface. | |
void | set_vertex (int ui, int vi, const LVecBase4f &vertex) |
Sets the nth control vertex of the surface, as a vertex in 4-d homogeneous space. | |
void | set_vertex_space (int ui, int vi, const NodePath &space) |
Sets the coordinate space of the nth control vertex. | |
void | set_vertex_space (int ui, int vi, const string &space) |
Sets the coordinate space of the nth control vertex. | |
bool | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
bool | test_ref_count_nonzero () const |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus. | |
virtual bool | unref () const |
Explicitly decrements the reference count. | |
void | weak_ref (WeakPointerToVoid *ptv) |
Adds the indicated PointerToVoid as a weak reference to this object. | |
void | weak_unref (WeakPointerToVoid *ptv) |
Removes the indicated PointerToVoid as a weak reference to this object. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Protected Member Functions | |
bool | do_test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
bool | do_test_ref_count_nonzero () const |
Returns true if the reference count is nonzero, false otherwise. |
This class is an abstraction for evaluating NURBS surfaces.
It accepts an array of vertices, each of which may be in a different coordinate space (as defined by a NodePath), as well as an optional knot vector.
Definition at line 37 of file nurbsSurfaceEvaluator.h.
bool ReferenceCount::do_test_ref_count_integrity | ( | ) | const [protected, inherited] |
Does some easy checks to make sure that the reference count isn't completely bogus.
Returns true if ok, false otherwise.
Reimplemented in NodeReferenceCount, CachedTypedWritableReferenceCount, and NodeCachedReferenceCount.
Definition at line 29 of file referenceCount.cxx.
Referenced by ReferenceCount::do_test_ref_count_nonzero(), and ReferenceCount::test_ref_count_integrity().
bool ReferenceCount::do_test_ref_count_nonzero | ( | ) | const [protected, inherited] |
Returns true if the reference count is nonzero, false otherwise.
Definition at line 56 of file referenceCount.cxx.
References ReferenceCount::do_test_ref_count_integrity().
Referenced by ReferenceCount::test_ref_count_nonzero().
float NurbsSurfaceEvaluator::get_extended_vertex | ( | int | ui, |
int | vi, | ||
int | d | ||
) | const [inline] |
Returns an n-dimensional vertex value.
See set_extended_vertex(). This returns the value set for the indicated dimension, or 0.0 if nothing has been set.
Definition at line 238 of file nurbsSurfaceEvaluator.I.
References NurbsVertex::get_extended_vertex().
int NurbsSurfaceEvaluator::get_num_u_knots | ( | ) | const [inline] |
Returns the number of knot values in the surface in the U direction.
This is based on the number of vertices and the order.
Definition at line 252 of file nurbsSurfaceEvaluator.I.
int NurbsSurfaceEvaluator::get_num_u_segments | ( | ) | const [inline] |
Returns the number of piecewise continuous segments in the surface in the U direction.
This is based on the knot vector.
Definition at line 276 of file nurbsSurfaceEvaluator.I.
References NurbsBasisVector::get_num_segments().
int NurbsSurfaceEvaluator::get_num_u_vertices | ( | ) | const [inline] |
Returns the number of control vertices in the U direction on the surface.
This is the number passed to the last call to reset().
Definition at line 80 of file nurbsSurfaceEvaluator.I.
int NurbsSurfaceEvaluator::get_num_v_knots | ( | ) | const [inline] |
Returns the number of knot values in the surface in the V direction.
This is based on the number of vertices and the order.
Definition at line 264 of file nurbsSurfaceEvaluator.I.
int NurbsSurfaceEvaluator::get_num_v_segments | ( | ) | const [inline] |
Returns the number of piecewise continuous segments in the surface in the V direction.
This is based on the knot vector.
Definition at line 291 of file nurbsSurfaceEvaluator.I.
References NurbsBasisVector::get_num_segments().
int NurbsSurfaceEvaluator::get_num_v_vertices | ( | ) | const [inline] |
Returns the number of control vertices in the V direction on the surface.
This is the number passed to the last call to reset().
Definition at line 92 of file nurbsSurfaceEvaluator.I.
int ReferenceCount::get_ref_count | ( | ) | const [inline, inherited] |
Returns the current reference count.
Definition at line 155 of file referenceCount.I.
References ReferenceCount::test_ref_count_integrity().
Referenced by TransformState::clear_cache(), RenderState::clear_cache(), RenderState::finalize(), RenderEffects::finalize(), RenderEffect::finalize(), RenderAttrib::finalize(), InternalName::finalize(), TransformState::get_num_unused_states(), RenderState::get_num_unused_states(), TransformState::list_cycles(), RenderState::list_cycles(), GeomVertexFormat::remove_column(), TransformState::unref(), RenderState::unref(), RenderState::~RenderState(), and TransformState::~TransformState().
float NurbsSurfaceEvaluator::get_u_knot | ( | int | i | ) | const |
Returns the value of the nth knot.
Definition at line 127 of file nurbsSurfaceEvaluator.cxx.
int NurbsSurfaceEvaluator::get_u_order | ( | ) | const [inline] |
Returns the order of the surface in the U direction as set by a previous call to set_u_order().
Definition at line 40 of file nurbsSurfaceEvaluator.I.
float NurbsSurfaceEvaluator::get_v_knot | ( | int | i | ) | const |
Returns the value of the nth knot.
Definition at line 182 of file nurbsSurfaceEvaluator.cxx.
int NurbsSurfaceEvaluator::get_v_order | ( | ) | const [inline] |
Returns the order of the surface in the V direction as set by a previous call to set_v_order().
Definition at line 68 of file nurbsSurfaceEvaluator.I.
const LVecBase4f & NurbsSurfaceEvaluator::get_vertex | ( | int | ui, |
int | vi | ||
) | const [inline] |
Returns the nth control vertex of the surface, relative to its indicated coordinate space.
Definition at line 134 of file nurbsSurfaceEvaluator.I.
References LVecBase4f::zero().
LVecBase4f NurbsSurfaceEvaluator::get_vertex | ( | int | ui, |
int | vi, | ||
const NodePath & | rel_to | ||
) | const [inline] |
Returns the nth control vertex of the surface, relative to the given coordinate space.
Definition at line 147 of file nurbsSurfaceEvaluator.I.
References NodePath::get_mat(), NodePath::is_empty(), and LVecBase4f::zero().
Returns the coordinate space of the nth control vertex of the surface, expressed as a NodePath.
Definition at line 74 of file nurbsSurfaceEvaluator.cxx.
void NurbsSurfaceEvaluator::get_vertices | ( | pvector< LPoint3f > & | verts, |
const NodePath & | rel_to | ||
) | const |
Fills the indicated vector with the set of vertices in the surface, transformed to the given space.
This flavor returns the vertices in 3-dimensional space.
Vertices are arranged in linear sequence, with the v coordinate changing more rapidly.
Definition at line 294 of file nurbsSurfaceEvaluator.cxx.
References NodePath::get_transform(), and NodePath::is_empty().
void NurbsSurfaceEvaluator::get_vertices | ( | pvector< LVecBase4f > & | verts, |
const NodePath & | rel_to | ||
) | const |
Fills the indicated vector with the set of vertices in the surface, transformed to the given space.
This flavor returns the vertices in 4-dimensional homogenous space.
Vertices are arranged in linear sequence, with the v coordinate changing more rapidly.
Definition at line 265 of file nurbsSurfaceEvaluator.cxx.
References NodePath::get_transform(), and NodePath::is_empty().
WeakReferenceList * ReferenceCount::get_weak_list | ( | ) | const [inline, inherited] |
Returns the WeakReferenceList associated with this ReferenceCount object.
If there has never been a WeakReferenceList associated with this object, creates one now.
Definition at line 307 of file referenceCount.I.
Referenced by ReferenceCount::weak_ref().
bool ReferenceCount::has_weak_list | ( | ) | const [inline, inherited] |
Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise.
In general, this will be true if there was ever a WeakPointerTo created for this object (even if there is not any for it now).
Definition at line 294 of file referenceCount.I.
Referenced by ReferenceCount::weak_unref().
void ReferenceCount::local_object | ( | ) | [inline, inherited] |
This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack.
This allows the object to be passed to functions that will increment and decrement the object's reference count temporarily, and it will prevent the object from being deleted (inappropriately), when the reference count returns to zero. It actually achieves this by setting a large positive value in the reference count field.
Definition at line 276 of file referenceCount.I.
Referenced by PGTop::cull_callback(), BoundingSphere::extend_by_hexahedron(), AsyncTaskManager::find_task(), AsyncTaskManager::find_tasks(), and AsyncTaskManager::find_tasks_matching().
void NurbsSurfaceEvaluator::normalize_u_knots | ( | ) |
Normalizes the knot sequence so that the parametric range of the surface in the U direction is 0 .
. 1.
Definition at line 142 of file nurbsSurfaceEvaluator.cxx.
void NurbsSurfaceEvaluator::normalize_v_knots | ( | ) |
Normalizes the knot sequence so that the parametric range of the surface in the U direction is 0 .
. 1.
Definition at line 197 of file nurbsSurfaceEvaluator.cxx.
void ReferenceCount::ref | ( | ) | const [inline, inherited] |
Explicitly increments the reference count.
User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
Definition at line 179 of file referenceCount.I.
References ReferenceCount::test_ref_count_integrity().
Referenced by CachedTypedWritableReferenceCount::cache_ref(), TypedWritable::decode_raw_from_bam_stream(), NodeCachedReferenceCount::node_ref(), NodeReferenceCount::node_ref(), BamCacheRecord::set_data(), CullableObject::set_draw_callback(), and ModelRoot::set_reference().
void NurbsSurfaceEvaluator::reset | ( | int | num_u_vertices, |
int | num_v_vertices | ||
) |
Resets all the vertices and knots to their default values, and sets the surface up with the indicated number of vertices.
You must then call set_vertex() repeatedly to fill in all of the vertex values appropriately.
Definition at line 51 of file nurbsSurfaceEvaluator.cxx.
void NurbsSurfaceEvaluator::set_extended_vertex | ( | int | ui, |
int | vi, | ||
int | d, | ||
float | value | ||
) | [inline] |
Sets an n-dimensional vertex value.
This allows definition of a NURBS surface or surface in a sparse n-dimensional space, typically used for associating additional properties (like color or joint membership) with each vertex of a surface.
The value d is an arbitrary integer value and specifies the dimension of question for this particular vertex. Any number of dimensions may be specified, and they need not be consecutive. If a value for a given dimension is not specified, is it implicitly 0.0.
The value is implicitly scaled by the homogenous weight value--that is, the fourth component of the value passed to set_vertex(). This means the ordinary vertex must be set first, before the extended vertices can be set.
Definition at line 223 of file nurbsSurfaceEvaluator.I.
References NurbsVertex::set_extended_vertex().
void NurbsSurfaceEvaluator::set_extended_vertices | ( | int | ui, |
int | vi, | ||
int | d, | ||
const float | values[], | ||
int | num_values | ||
) |
Simultaneously sets several extended values in the slots d through (d + num_values - 1) from the num_values elements of the indicated array.
This is equivalent to calling set_extended_vertex() num_values times. See set_extended_vertex().
Definition at line 93 of file nurbsSurfaceEvaluator.cxx.
References NurbsVertex::set_extended_vertex().
void NurbsSurfaceEvaluator::set_u_knot | ( | int | i, |
float | knot | ||
) |
Sets the value of the nth knot.
Each knot value should be greater than or equal to the preceding value. If no knot values are set, a default knot vector is supplied.
Definition at line 113 of file nurbsSurfaceEvaluator.cxx.
void NurbsSurfaceEvaluator::set_u_order | ( | int | u_order | ) | [inline] |
Sets the order of the surface in the U direction.
This resets the knot vector to the default knot vector for the number of vertices.
The order must be 1, 2, 3, or 4, and the value is one more than the degree of the surface.
Definition at line 27 of file nurbsSurfaceEvaluator.I.
void NurbsSurfaceEvaluator::set_v_knot | ( | int | i, |
float | knot | ||
) |
Sets the value of the nth knot.
Each knot value should be greater than or equal to the preceding value. If no knot values are set, a default knot vector is supplied.
Definition at line 168 of file nurbsSurfaceEvaluator.cxx.
void NurbsSurfaceEvaluator::set_v_order | ( | int | v_order | ) | [inline] |
Sets the order of the surface in the V direction.
This resets the knot vector to the default knot vector for the number of vertices.
The order must be 1, 2, 3, or 4, and the value is one more than the degree of the surface.
Definition at line 55 of file nurbsSurfaceEvaluator.I.
void NurbsSurfaceEvaluator::set_vertex | ( | int | ui, |
int | vi, | ||
const LVecBase3f & | vertex, | ||
float | weight = 1.0 |
||
) | [inline] |
Sets the nth control vertex of the surface.
This flavor sets the vertex as a 3-d coordinate and a weight; the 3-d coordinate values are implicitly scaled up by the weight factor.
Definition at line 121 of file nurbsSurfaceEvaluator.I.
void NurbsSurfaceEvaluator::set_vertex | ( | int | ui, |
int | vi, | ||
const LVecBase4f & | vertex | ||
) | [inline] |
Sets the nth control vertex of the surface, as a vertex in 4-d homogeneous space.
In this form, the first three components of the vertex should already have been scaled by the fourth component, which is the homogeneous weight.
Definition at line 106 of file nurbsSurfaceEvaluator.I.
void NurbsSurfaceEvaluator::set_vertex_space | ( | int | ui, |
int | vi, | ||
const NodePath & | space | ||
) | [inline] |
Sets the coordinate space of the nth control vertex.
If this is not specified, or is set to an empty NodePath, the nth control vertex is deemed to be in the coordinate space passed to evaluate().
This specifies the space as a fixed NodePath, which is always the same NodePath. Also see setting the space as a path string, which can specify a different NodePath for different instances of the surface.
Definition at line 175 of file nurbsSurfaceEvaluator.I.
References NurbsVertex::set_space().
void NurbsSurfaceEvaluator::set_vertex_space | ( | int | ui, |
int | vi, | ||
const string & | space | ||
) | [inline] |
Sets the coordinate space of the nth control vertex.
If this is not specified, or is set to an empty string, the nth control vertex is deemed to be in the coordinate space passed to evaluate().
This specifies the space as a string, which describes the path to find the node relative to the rel_to NodePath when the surface is evaluated.
Definition at line 194 of file nurbsSurfaceEvaluator.I.
References NurbsVertex::set_space().
bool ReferenceCount::test_ref_count_integrity | ( | ) | const [inline, inherited] |
Does some easy checks to make sure that the reference count isn't completely bogus.
Returns true if ok, false otherwise.
Reimplemented in NodeReferenceCount, CachedTypedWritableReferenceCount, and NodeCachedReferenceCount.
Definition at line 236 of file referenceCount.I.
References ReferenceCount::do_test_ref_count_integrity().
Referenced by EggGroupNode::add_child(), InternalName::find_ancestor(), InternalName::get_ancestor(), ReferenceCount::get_ref_count(), InternalName::get_top(), ReferenceCount::ref(), EggVertex::test_gref_integrity(), EggVertex::test_pref_integrity(), EggNode::test_under_integrity(), EggPrimitive::test_vref_integrity(), EggGroup::test_vref_integrity(), MouseWatcher::throw_event_pattern(), ReferenceCount::unref(), and EggNode::update_under().
bool ReferenceCount::test_ref_count_nonzero | ( | ) | const [inline, inherited] |
Does some easy checks to make sure that the reference count isn't zero, or completely bogus.
Returns true if ok, false otherwise.
Definition at line 252 of file referenceCount.I.
References ReferenceCount::do_test_ref_count_nonzero().
Referenced by CopyOnWritePointer::test_ref_count_nonzero().
bool ReferenceCount::unref | ( | ) | const [inline, virtual, inherited] |
Explicitly decrements the reference count.
Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic.) However, see the helper function unref_delete().
User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically.
This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it.
The return value is true if the new reference count is nonzero, false if it is zero.
Reimplemented in GeomVertexArrayFormat, GeomVertexFormat, InternalName, RenderAttrib, RenderEffects, RenderState, and TransformState.
Definition at line 214 of file referenceCount.I.
References ReferenceCount::test_ref_count_integrity().
Referenced by CachedTypedWritableReferenceCount::cache_unref(), TypedWritable::decode_raw_from_bam_stream(), RenderEffect::finalize(), NodeCachedReferenceCount::node_unref(), NodeReferenceCount::node_unref(), TransformState::unref(), RenderState::unref(), RenderEffects::unref(), RenderAttrib::unref(), InternalName::unref(), GeomVertexFormat::unref(), and GeomVertexArrayFormat::unref().
void ReferenceCount::weak_ref | ( | WeakPointerToVoid * | ptv | ) | [inline, inherited] |
Adds the indicated PointerToVoid as a weak reference to this object.
Definition at line 321 of file referenceCount.I.
References WeakReferenceList::add_reference(), and ReferenceCount::get_weak_list().
void ReferenceCount::weak_unref | ( | WeakPointerToVoid * | ptv | ) | [inline, inherited] |
Removes the indicated PointerToVoid as a weak reference to this object.
It must have previously been added via a call to weak_ref().
Definition at line 334 of file referenceCount.I.
References WeakReferenceList::clear_reference(), and ReferenceCount::has_weak_list().