Cortex 6.0.0
Classes | Public Types | Public Member Functions | Static Public Member Functions

IECore::PrimitiveEvaluator Class Reference

#include <PrimitiveEvaluator.h>

Inheritance diagram for IECore::PrimitiveEvaluator:

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 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 (Result *result) const =0
 Throws an exception if the passed result type is not compatible with the current evaluator.
Query Functions

The Result 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, Result *result) const =0
virtual bool pointAtUV (const Imath::V2f &uv, Result *result) const =0
 Find the point on the primitive at the given query UV. Returns true on success.
virtual bool intersectionPoint (const Imath::V3f &origin, const Imath::V3f &direction, Result *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 Function Documentation

virtual bool IECore::PrimitiveEvaluator::closestPoint ( const Imath::V3f &  p,
Result 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.

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

static PrimitiveEvaluatorPtr IECore::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 bool IECore::PrimitiveEvaluator::intersectionPoint ( const Imath::V3f &  origin,
const Imath::V3f &  direction,
Result 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.

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

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::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.


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends