IECore::PrimitiveEvaluator Class Reference

#include <PrimitiveEvaluator.h>

Inheritance diagram for IECore::PrimitiveEvaluator:

IECore::RunTimeTyped IECore::RefCounted IECore::CurvesPrimitiveEvaluator IECore::ImagePrimitiveEvaluator IECore::MeshPrimitiveEvaluator IECore::PointsPrimitiveEvaluator IECore::SpherePrimitiveEvaluator

List of all members.

Classes

struct  Description
class  Result

Public Types

typedef PrimitiveEvaluatorPtr(* CreatorFn )(ConstPrimitivePtr)

Public Member Functions

 IE_CORE_DECLARERUNTIMETYPED (PrimitiveEvaluator, RunTimeTyped)
 IE_CORE_DECLAREPTR (Result)
virtual ~PrimitiveEvaluator ()
virtual ResultPtr createResult () const =0
 Create a result instance which is suitable for passing to one of the query methods.
virtual ConstPrimitivePtr primitive () const =0
 Returns the primitive which we're currently evaluating.
virtual void validateResult (const ResultPtr &result) const =0
Query Functions
The ResultPtr passed to each of the methods below must previously have been created by a call to the createResult() method on the same evaluator instance as is being called - passing any other result will cause undefined behaviour.
Threading:
Query implementations should ensure that they may be called from multiple concurrent threads provided that a unique Result instance is used per thread. This implies that all query data must be stored in the Result and not in the PrimitiveEvaluator itself.


virtual bool signedDistance (const Imath::V3f &p, float &distance) const
virtual float surfaceArea () const =0
 Computes the surface area of the primitive.
virtual float volume () const =0
 Computes the volume of the primitive. The result is undefined if the primitive is not closed, or self intersects.
virtual Imath::V3f centerOfGravity () const =0
 Computes the primitive's center of gravity. The result is undefined if the primitive is not closed, or self intersects.
virtual bool closestPoint (const Imath::V3f &p, const ResultPtr &result) const =0
virtual bool pointAtUV (const Imath::V2f &uv, const ResultPtr &result) const =0
virtual bool intersectionPoint (const Imath::V3f &origin, const Imath::V3f &direction, const ResultPtr &result, float maxDistance=Imath::limits< float >::max()) const =0
virtual int intersectionPoints (const Imath::V3f &origin, const Imath::V3f &direction, std::vector< ResultPtr > &results, float maxDistance=Imath::limits< float >::max()) const =0

Static Public Member Functions

static PrimitiveEvaluatorPtr create (ConstPrimitivePtr primitive)


Detailed Description

Primitive evaluators permit spatial queries on primitives, such as determing the closest point, or retrieving the position from a given UV coordinate, etc. Individual primitive types derive their own evaluators from this interface, and register them by creating static instances of PrimitiveEvaluator::Description. The evaluator takes an internal copy of the primitive, so subsequent changes to it will not be reflected in the evaluator's results.

Member Typedef Documentation

typedef PrimitiveEvaluatorPtr( * IECore::PrimitiveEvaluator::CreatorFn)(ConstPrimitivePtr)


Constructor & Destructor Documentation

PrimitiveEvaluator::~PrimitiveEvaluator (  )  [virtual]


Member Function Documentation

virtual Imath::V3f IECore::PrimitiveEvaluator::centerOfGravity (  )  const [pure virtual]

Computes the primitive's center of gravity. The result is undefined if the primitive is not closed, or self intersects.

Implemented in IECore::CurvesPrimitiveEvaluator, IECore::ImagePrimitiveEvaluator, IECore::MeshPrimitiveEvaluator, IECore::PointsPrimitiveEvaluator, and IECore::SpherePrimitiveEvaluator.

virtual bool IECore::PrimitiveEvaluator::closestPoint ( const Imath::V3f &  p,
const ResultPtr &  result 
) const [pure virtual]

Find the closest point on the primitive to the given query point. Returns true on success.

Todo:
Extend this to pass a maximum distance past which results are no longer interesting.

: use a raw pointer rather than a reference to a smart pointer

Referenced by signedDistance().

PrimitiveEvaluatorPtr PrimitiveEvaluator::create ( ConstPrimitivePtr  primitive  )  [static]

Returns a primitive evaluator which is compatible with the given primitive, from those evaluator types which have been registered.

Reimplemented in IECore::CurvesPrimitiveEvaluator, IECore::ImagePrimitiveEvaluator, IECore::MeshPrimitiveEvaluator, IECore::PointsPrimitiveEvaluator, and IECore::SpherePrimitiveEvaluator.

virtual ResultPtr IECore::PrimitiveEvaluator::createResult (  )  const [pure virtual]

Create a result instance which is suitable for passing to one of the query methods.

Implemented in IECore::CurvesPrimitiveEvaluator, IECore::ImagePrimitiveEvaluator, IECore::MeshPrimitiveEvaluator, IECore::PointsPrimitiveEvaluator, and IECore::SpherePrimitiveEvaluator.

Referenced by signedDistance().

IECore::PrimitiveEvaluator::IE_CORE_DECLAREPTR ( Result   ) 

IECore::PrimitiveEvaluator::IE_CORE_DECLARERUNTIMETYPED ( PrimitiveEvaluator  ,
RunTimeTyped   
)

virtual bool IECore::PrimitiveEvaluator::intersectionPoint ( const Imath::V3f &  origin,
const Imath::V3f &  direction,
const ResultPtr &  result,
float  maxDistance = Imath::limits< float >::max() 
) const [pure virtual]

Finds the closest intersection point for the given ray. Optionally specify a maximum distance of interest. Returns true if an intersection was found.

Todo:
: use a raw pointer rather than a reference to a smart pointer

virtual int IECore::PrimitiveEvaluator::intersectionPoints ( const Imath::V3f &  origin,
const Imath::V3f &  direction,
std::vector< ResultPtr > &  results,
float  maxDistance = Imath::limits< float >::max() 
) const [pure virtual]

Finds all intersection points for the given ray. Optionally specify a maximum distance of interest. Returns the number of interections found.

virtual bool IECore::PrimitiveEvaluator::pointAtUV ( const Imath::V2f &  uv,
const ResultPtr &  result 
) const [pure virtual]

Find the point on the primitive at the given query UV. Returns true on success

Todo:
: use a raw pointer rather than a reference to a smart pointer

virtual ConstPrimitivePtr IECore::PrimitiveEvaluator::primitive (  )  const [pure virtual]

bool PrimitiveEvaluator::signedDistance ( const Imath::V3f &  p,
float &  distance 
) const [virtual]

Computes the signed distance between the given point and the primitive. By default this is just the signed distance between the point, and the plane specified by the closest point and normal, but derived class are free to override it as they see fit. Returns true on success.

Todo:
: pass a result to this method in major version 6

Reimplemented in IECore::MeshPrimitiveEvaluator.

References closestPoint(), createResult(), and IECore::sign().

virtual float IECore::PrimitiveEvaluator::surfaceArea (  )  const [pure virtual]

virtual void IECore::PrimitiveEvaluator::validateResult ( const ResultPtr &  result  )  const [pure virtual]

Throws an exception if the passed result type is not compatible with the current evaluator

Todo:
: use a raw pointer rather than a reference to a smart pointer

virtual float IECore::PrimitiveEvaluator::volume (  )  const [pure virtual]

Computes the volume of the primitive. The result is undefined if the primitive is not closed, or self intersects.

Implemented in IECore::CurvesPrimitiveEvaluator, IECore::ImagePrimitiveEvaluator, IECore::MeshPrimitiveEvaluator, IECore::PointsPrimitiveEvaluator, and IECore::SpherePrimitiveEvaluator.


The documentation for this class was generated from the following files:

Generated on Mon Jan 24 11:13:26 2011 for Cortex by doxygen 1.5.8