Cortex  10.0.0-a4
Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | List of all members
IECore::MeshPrimitiveEvaluator Class Reference

#include <MeshPrimitiveEvaluator.h>

+ Inheritance diagram for IECore::MeshPrimitiveEvaluator:

Public Types

typedef MeshPrimitive PrimitiveType
 
- Public Types inherited from IECore::PrimitiveEvaluator
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 (MeshPrimitiveEvaluator, PrimitiveEvaluator)
 
 IE_CORE_DECLAREPTR (Result)
 
 MeshPrimitiveEvaluator (ConstMeshPrimitivePtr mesh)
 
ConstPrimitivePtr primitive () const override
 Returns the primitive which we're currently evaluating.
 
MeshPrimitive::ConstPtr mesh () const
 
PrimitiveEvaluator::ResultPtr createResult () const override
 Create a result instance which is suitable for passing to one of the query methods.
 
void validateResult (PrimitiveEvaluator::Result *result) const override
 Throws an exception if the passed result type is not compatible with the current evaluator.
 
bool closestPoint (const Imath::V3f &p, PrimitiveEvaluator::Result *result) const override
 
bool pointAtUV (const Imath::V2f &uv, PrimitiveEvaluator::Result *result) const override
 Find the point on the primitive at the given query UV. Returns true on success.
 
bool intersectionPoint (const Imath::V3f &origin, const Imath::V3f &direction, PrimitiveEvaluator::Result *result, float maxDistance=Imath::limits< float >::max()) const override
 
int intersectionPoints (const Imath::V3f &origin, const Imath::V3f &direction, std::vector< PrimitiveEvaluator::ResultPtr > &results, float maxDistance=Imath::limits< float >::max()) const override
 
bool barycentricPosition (unsigned int triangleIndex, const Imath::V3f &barycentricCoordinates, PrimitiveEvaluator::Result *result) const
 A query specific to the MeshPrimitiveEvaluator, this just chooses a barycentric position on a specific triangle.
 
bool signedDistance (const Imath::V3f &p, float &distance, PrimitiveEvaluator::Result *result) const override
 
float volume () const override
 Computes the volume of the primitive. The result is undefined if the primitive is not closed, or self intersects.
 
Imath::V3f centerOfGravity () const override
 Computes the primitive's center of gravity. The result is undefined if the primitive is not closed, or self intersects.
 
float surfaceArea () const override
 Computes the surface area of the primitive.
 
const Imath::Box2f uvBound () const
 Returns a bounding box covering all the uv coordinates of the mesh.
 
- Public Member Functions inherited from IECore::PrimitiveEvaluator
 IE_CORE_DECLARERUNTIMETYPED (PrimitiveEvaluator, RunTimeTyped)
 
 IE_CORE_DECLAREPTR (Result)
 
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::PrimitiveEvaluator
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.
 

Protected Types

typedef tbb::mutex NormalsMutex
 
typedef int VertexIndex
 
typedef int TriangleIndex
 
typedef std::pair< VertexIndex, VertexIndex > Edge
 
typedef std::map< Edge, Imath::V3f > EdgeAverageNormals
 
- 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
 

Protected Member Functions

bool pointAtUVWalk (UVBoundTree::NodeIndex nodeIndex, const Imath::V2f &targetUV, Result *result) const
 
void closestPointWalk (TriangleBoundTree::NodeIndex nodeIndex, const Imath::V3f &p, float &closestDistanceSqrd, Result *result) const
 
bool intersectionPointWalk (TriangleBoundTree::NodeIndex nodeIndex, const Imath::Line3f &ray, float &maxDistSqrd, Result *result, bool &hit) const
 
void intersectionPointsWalk (TriangleBoundTree::NodeIndex nodeIndex, const Imath::Line3f &ray, float maxDistSqrd, std::vector< PrimitiveEvaluator::ResultPtr > &results) const
 
void calculateMassProperties () const
 
void calculateAverageNormals () const
 
void triangleUVs (size_t triangleIndex, const Imath::V3i &vertexIds, Imath::V2f uv[3]) const
 

Protected Attributes

ConstMeshPrimitivePtr m_mesh
 
ConstV3fVectorDataPtr m_verts
 
const std::vector< int > * m_meshVertexIds
 
TriangleBoundVector m_triangles
 
TriangleBoundTreem_tree
 
UVBoundVector m_uvTriangles
 
UVBoundTreem_uvTree
 
PrimitiveVariable m_uv
 
bool m_haveMassProperties
 
float m_volume
 
Imath::V3f m_centerOfGravity
 
Imath::M33f m_inertia
 
bool m_haveSurfaceArea
 
float m_surfaceArea
 
NormalsMutex m_normalsMutex
 
bool m_haveAverageNormals
 
EdgeAverageNormals m_edgeAverageNormals
 
V3fVectorDataPtr m_vertexAngleWeightedNormals
 

Internal KDTrees.

The MeshPrimitiveEvaluator uses internal KDTrees to perform many of its queries. Const access is provided to these so that clients can use them in implementing their own algorithms.

typedef Imath::Box3f TriangleBound
 A type for storing the bounding box for a triangle.
 
typedef std::vector< TriangleBoundTriangleBoundVector
 A type for storing an array of bounding boxes, one per triangle.
 
typedef BoundedKDTree< TriangleBoundVector::iterator > TriangleBoundTree
 A BoundedKDTree providing accelerated lookups of triangles using their bounding boxes.
 
typedef Imath::Box2f UVBound
 A type for storing the uv bounding box for a triangle.
 
typedef std::vector< UVBoundUVBoundVector
 A type for storing an array of uv bounds, one per triangle.
 
typedef BoundedKDTree< UVBoundVector::iterator > UVBoundTree
 A BoundedKDTree providing accelerated lookups of triangles using their uv bounds.
 
const TriangleBoundVectortriangleBounds () const
 Returns a pointer to the bounding boxes for each triangle.
 
const TriangleBoundTreetriangleBoundTree () const
 
const UVBoundVectoruvBounds () const
 
const UVBoundTreeuvBoundTree () const
 

Additional Inherited Members

- 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

An implementation of PrimitiveEvaluator to allow spatial queries to be performed on MeshPrimitive instances

Member Function Documentation

bool IECore::MeshPrimitiveEvaluator::closestPoint ( const Imath::V3f &  p,
PrimitiveEvaluator::Result result 
) const
overridevirtual

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.

Implements IECore::PrimitiveEvaluator.

bool IECore::MeshPrimitiveEvaluator::intersectionPoint ( const Imath::V3f &  origin,
const Imath::V3f &  direction,
PrimitiveEvaluator::Result result,
float  maxDistance = Imath::limits< float >::max() 
) const
overridevirtual

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

Implements IECore::PrimitiveEvaluator.

bool IECore::MeshPrimitiveEvaluator::signedDistance ( const Imath::V3f &  p,
float &  distance,
PrimitiveEvaluator::Result result 
) const
overridevirtual

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 from IECore::PrimitiveEvaluator.

const TriangleBoundTree* IECore::MeshPrimitiveEvaluator::triangleBoundTree ( ) const

Returns a pointer to a tree that can be used for performing fast spacial queries. The iterators in this tree point to elements in the vector returned by triangleBounds().

const UVBoundVector* IECore::MeshPrimitiveEvaluator::uvBounds ( ) const

Returns a pointer to the uv bounding boxes for each triangle. Note that this function may return 0 in the case of the mesh not having suitable uvs.

const UVBoundTree* IECore::MeshPrimitiveEvaluator::uvBoundTree ( ) const

Returns a pointer to a tree than can be used for performing fast uv queries. The iterators in this tree point to the elements in the vector returned by uvBounds(). Note that this function may return 0 in the case of the mesh not having suitable uvs.


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