Cortex  10.0.0-a4
Classes | Public Types | Public Member Functions | Static Public Member Functions | List of all members
IECore::PrimitiveEvaluator Class Referenceabstract

#include <PrimitiveEvaluator.h>

+ Inheritance diagram for IECore::PrimitiveEvaluator:

Classes

struct  Description
 
class  Result
 

Public Types

typedef PrimitiveEvaluatorPtr(* CreatorFn) (ConstPrimitivePtr)
 
- Public Types inherited from IECore::RunTimeTyped
typedef RefCounted BaseClass
 A typedef for the class this class derives from. All RunTimeTyped classes define this typedef.
 
- Public Types inherited from IECore::RefCounted
typedef size_t RefCount
 

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, Result *result) 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
 
- Public Member Functions inherited from IECore::RunTimeTyped
 IE_CORE_DECLAREMEMBERPTR (RunTimeTyped)
 
virtual TypeId typeId () const
 
virtual const char * typeName () const
 
virtual bool isInstanceOf (TypeId typeId) const
 
virtual bool isInstanceOf (const char *typeName) const
 
- Public Member Functions inherited from IECore::RefCounted
 IE_CORE_DECLAREMEMBERPTR (RefCounted)
 
void addRef () const
 Add a reference to the current object.
 
void removeRef () const
 Remove a reference from the current object.
 
RefCount refCount () const
 Returns the current reference count.
 

Static Public Member Functions

static PrimitiveEvaluatorPtr create (ConstPrimitivePtr primitive)
 
- Static Public Member Functions inherited from IECore::RunTimeTyped
static TypeId staticTypeId ()
 Returns the TypeId for this class, without needing an instance.
 
static const char * staticTypeName ()
 Returns the type name for this class, without needing an instance.
 
static TypeId baseTypeId ()
 
static const char * baseTypeName ()
 
static bool inheritsFrom (TypeId typeId)
 Returns true if this class inherits from the specified type.
 
static bool inheritsFrom (const char *typeName)
 Returns true if this class inherits from the specified type.
 
static bool inheritsFrom (TypeId type, TypeId baseType)
 Returns true if type inherits from baseType.
 
static bool inheritsFrom (const char *typeName, const char *baseTypeName)
 Returns true if typeName inherits from baseTypeName.
 
static TypeId baseTypeId (TypeId typeId)
 Returns the base type of the given type, or InvalidTypeId if no such base exists.
 
static const std::vector< TypeId > & baseTypeIds (TypeId typeId)
 
static const std::set< TypeId > & derivedTypeIds (TypeId typeId)
 
static TypeId typeIdFromTypeName (const char *typeName)
 
static const char * typeNameFromTypeId (TypeId typeId)
 
static void registerType (TypeId derivedTypeId, const char *derivedTypeName, TypeId baseTypeId)
 Allows external modules to register their own type ids.
 

Additional Inherited Members

- Protected Types inherited from IECore::RunTimeTyped
typedef std::map< TypeId, TypeIdBaseTypeRegistryMap
 
typedef std::map< TypeId, std::vector< TypeId > > BaseTypesRegistryMap
 
typedef std::map< TypeId, std::set< TypeId > > DerivedTypesRegistryMap
 
typedef tbb::spin_rw_mutex Mutex
 
typedef std::map< TypeId, std::string > TypeIdsToTypeNamesMap
 
typedef std::map< std::string, TypeIdTypeNamesToTypeIdsMap
 
- Static Protected Member Functions inherited from IECore::RunTimeTyped
static BaseTypeRegistryMap & baseTypeRegistry ()
 
static DerivedTypesRegistryMap & derivedTypesRegistry ()
 
static BaseTypesRegistryMap & completeBaseTypesRegistry ()
 
static DerivedTypesRegistryMap & completeDerivedTypesRegistry ()
 
static void derivedTypeIdsWalk (TypeId typeId, std::set< TypeId > &)
 
static TypeIdsToTypeNamesMap & typeIdsToTypeNames ()
 
static TypeNamesToTypeIdsMap & typeNamesToTypeIds ()
 
- Static Protected Attributes inherited from IECore::RunTimeTyped
static Mutex g_baseTypeIdsMutex
 
static Mutex g_derivedTypeIdsMutex
 

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

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::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,
Result result 
) 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.

Reimplemented in IECore::MeshPrimitiveEvaluator.


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