AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
agxIO::MeshReaderAssimp Class Reference

Data is returned as vertices (getVertices()) and indices (getIndices()) Some formats supports non-triangle primitives. More...

#include <MeshReaderAssimp.h>

+ Inheritance diagram for agxIO::MeshReaderAssimp:

Public Member Functions

 MeshReaderAssimp ()
 Default Constructor. More...
 
 MeshReaderAssimp (agx::Vec3Vector &vertices, agx::Vec3Vector &normals, agx::UInt32Vector &indices, agx::Vec2Vector &texCoordinates)
 Constructor that use references for data where the read data will be added. More...
 
template<typename T >
T * as ()
 Subclass casting. More...
 
template<typename T >
const T * as () const
 
template<typename T >
T * asSafe ()
 Safe subclass casting, return nullptr if template type does not match. More...
 
template<typename T >
const T * asSafe () const
 
const agx::UInt32Vector & getIndices () const
 Get indices from previously read mesh file. More...
 
const agx::Vec3Vector & getNormals () const
 Get normals from previously read mesh file. More...
 
size_t getNumTriangles () const
 Get number of triangles from previously read mesh file. More...
 
int getReferenceCount () const
 
const agx::Vec2Vector & getTextureCoordinates () const
 Get texture coordinates from previously read mesh file. More...
 
const agx::Vec3Vector & getVertices () const
 Get vertices from previously read mesh file. More...
 
template<typename T >
bool is () const
 Subclass test. More...
 
size_t readFile (const agx::String &fileName) override
 Read a mesh file using the Assimp loader. More...
 
size_t readStream (std::istream &stream, FileExtension::FileType fet) override
 Parse a mesh model from an input stream of a specific format. More...
 
size_t readString (const agx::String &meshString, FileExtension::FileType fet) override
 Parse a mesh model from a string of a specific format defined as a string. More...
 
void reference (void *ptr=nullptr) const
 Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it. More...
 
void unreference (void *ptr=nullptr) const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 
void unreference_nodelete () const
 Decrement the reference count by one, indicating that a pointer to this object is referencing it. More...
 

Static Public Member Functions

static agx::String getFileExtension (FileExtension::FileType type)
 Convert a filetype enum to a string with the file extension (without '. More...
 
static FileExtension::FileType getFileExtensionType (const agx::String &fileName)
 Convert a filename to a known (or unknown) file extension enum. More...
 
template<typename T >
static bool ValidateCast (const Referenced *object)
 

Protected Member Functions

virtual ~MeshReaderAssimp ()
 
void allocateObserverVector () const
 
void clear ()
 Reset all allocated memory. More...
 
void deleteUsingDeleteHandler () const
 
size_t importModel (std::stringstream &stream, const agx::String &fileName, FileExtension::FileType fet, Assimp::Importer &importer)
 
size_t readShlStream (std::istream &stream)
 Read a specified stream containing a mesh description in SHL format. More...
 

Static Protected Member Functions

static DeleteHandler * getDeleteHandler ()
 
static void setDeleteHandler (DeleteHandler *handler)
 Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to. More...
 

Protected Attributes

agx::UInt32Vector & m_assimp_indices
 
agx::Vec3Vector & m_assimp_normals
 
agx::Vec2Vector & m_assimp_texCoordinates
 
agx::Vec3Vector & m_assimp_vertices
 
agx::UInt32Vector m_indices
 
agx::ref_ptr< agx::Referenced > m_logger
 
Mutex m_mutex
 
agx::Vec3Vector m_normals
 
ObserverContainer m_observers
 
AtomicValue m_refCount
 
agx::Vec2Vector m_texCoordinates
 
agx::Vec3Vector m_vertices
 

Static Protected Attributes

static agx::StringVector m_extensions
 

Detailed Description

Data is returned as vertices (getVertices()) and indices (getIndices()) Some formats supports non-triangle primitives.

These shapes will be ignored. However, the vertices for this data will still be part of the read data.

Definition at line 37 of file MeshReaderAssimp.h.

Constructor & Destructor Documentation

agxIO::MeshReaderAssimp::MeshReaderAssimp ( )

Default Constructor.

agxIO::MeshReaderAssimp::MeshReaderAssimp ( agx::Vec3Vector &  vertices,
agx::Vec3Vector &  normals,
agx::UInt32Vector &  indices,
agx::Vec2Vector &  texCoordinates 
)

Constructor that use references for data where the read data will be added.

virtual agxIO::MeshReaderAssimp::~MeshReaderAssimp ( )
protectedvirtual

Member Function Documentation

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited
template<typename T >
T* agx::Referenced::as ( )
inherited

Subclass casting.

Template type must match actual type, dynamic_cast assertion will fail otherwise.

Referenced by agx::InternalData::get(), agxVehicle::Track::getNode(), and agx::InternalData::getOrCreate().

template<typename T >
const T* agx::Referenced::as ( ) const
inherited
template<typename T >
T* agx::Referenced::asSafe ( )
inherited

Safe subclass casting, return nullptr if template type does not match.

Referenced by agxUtil::CollectBodiesAndWiresVisitor::visit().

template<typename T >
const T* agx::Referenced::asSafe ( ) const
inherited
void agxIO::MeshReader::clear ( )
protectedinherited

Reset all allocated memory.

void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited
static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.
static agx::String agxIO::MeshReader::getFileExtension ( FileExtension::FileType  type)
staticinherited

Convert a filetype enum to a string with the file extension (without '.

')

Parameters
type- Enum with the filetype to be returned as a string
Returns
a string with the file type without '.'
static FileExtension::FileType agxIO::MeshReader::getFileExtensionType ( const agx::String &  fileName)
staticinherited

Convert a filename to a known (or unknown) file extension enum.

Parameters
fileName- filename including extension of a mesh file
Returns
enum defining the filetype of the filename
const agx::UInt32Vector & agxIO::MeshReader::getIndices ( ) const
inlineinherited

Get indices from previously read mesh file.

Note
Must be called after the readFile() method
Returns
a const reference to a vector containing indices found in the model data.

Definition at line 185 of file MeshReader.h.

References agxIO::MeshReader::m_indices.

const agx::Vec3Vector & agxIO::MeshReader::getNormals ( ) const
inlineinherited

Get normals from previously read mesh file.

Note
Must be called after the readFile() method
Returns
a const reference to a vector containing normals found in the model data.

Definition at line 190 of file MeshReader.h.

References agxIO::MeshReader::m_normals.

size_t agxIO::MeshReader::getNumTriangles ( ) const
inlineinherited

Get number of triangles from previously read mesh file.

Note
Must be called after the readFile() method
Returns
number of triangles.

Definition at line 201 of file MeshReader.h.

References agxIO::MeshReader::m_indices, and agx::Container::size().

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.
const agx::Vec2Vector & agxIO::MeshReader::getTextureCoordinates ( ) const
inlineinherited

Get texture coordinates from previously read mesh file.

Note
Must be called after the readFile() method
Returns
a const reference to a vector containing texture coordinates normals found in the model data

Definition at line 195 of file MeshReader.h.

References agxIO::MeshReader::m_texCoordinates.

const agx::Vec3Vector & agxIO::MeshReader::getVertices ( ) const
inlineinherited

Get vertices from previously read mesh file.

Note
Must be called after the readFile() method
Returns
a const reference to a vector containing vertices found in the model data.

Definition at line 180 of file MeshReader.h.

References agxIO::MeshReader::m_vertices.

size_t agxIO::MeshReaderAssimp::importModel ( std::stringstream &  stream,
const agx::String &  fileName,
FileExtension::FileType  fet,
Assimp::Importer &  importer 
)
protected
template<typename T >
bool agx::Referenced::is ( ) const
inherited
size_t agxIO::MeshReaderAssimp::readFile ( const agx::String &  fileName)
overridevirtual

Read a mesh file using the Assimp loader.

Any format (Collada) that supports hierarchical models will be merged into one single mesh.

Parameters
fileName- Path to a mesh file
Returns
number of triangles read.

Reimplemented from agxIO::MeshReader.

size_t agxIO::MeshReader::readShlStream ( std::istream &  stream)
protectedinherited

Read a specified stream containing a mesh description in SHL format.

Returns
number of found triangles.
size_t agxIO::MeshReaderAssimp::readStream ( std::istream &  stream,
FileExtension::FileType  fet 
)
overridevirtual

Parse a mesh model from an input stream of a specific format.

Parameters
stream- input stream from which we will read the data
fet- Mesh format of the input stream

Reimplemented from agxIO::MeshReader.

size_t agxIO::MeshReaderAssimp::readString ( const agx::String &  meshString,
FileExtension::FileType  fet 
)
overridevirtual

Parse a mesh model from a string of a specific format defined as a string.

Parameters
meshString- string containing the mesh model
fet- Mesh format of the string data

Reimplemented from agxIO::MeshReader.

void agx::Referenced::reference ( void *  ptr = nullptr) const
inherited

Explicitly increment the reference count by one, indicating that this object has another pointer which is referencing it.

This method should be used with care, always balanced with the same number of calls to unreference.

Referenced by agxData::Val< UInt >::Val().

static void agx::Referenced::setDeleteHandler ( DeleteHandler *  handler)
staticprotectedinherited

Internal: Set a DeleteHandler to which deletion of all referenced counted objects will be delegated to.

void agx::Referenced::unreference ( void *  ptr = nullptr) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

If the reference count goes to zero, it is assumed that this object is no longer referenced and is automatically deleted.

This method should be used with care, always balanced with the same number of calls to reference.

void agx::Referenced::unreference_nodelete ( ) const
inherited

Decrement the reference count by one, indicating that a pointer to this object is referencing it.

However, do not delete it, even if ref count goes to 0. Warning, unref_nodelete() should only be called if the user knows exactly who will be responsible for, one should prefer unref() over unref_nodelete() as the later can lead to memory leaks.

template<typename T >
static bool agx::Referenced::ValidateCast ( const Referenced *  object)
staticinherited

Member Data Documentation

agx::UInt32Vector& agxIO::MeshReaderAssimp::m_assimp_indices
protected

Definition at line 83 of file MeshReaderAssimp.h.

agx::Vec3Vector& agxIO::MeshReaderAssimp::m_assimp_normals
protected

Definition at line 82 of file MeshReaderAssimp.h.

agx::Vec2Vector& agxIO::MeshReaderAssimp::m_assimp_texCoordinates
protected

Definition at line 84 of file MeshReaderAssimp.h.

agx::Vec3Vector& agxIO::MeshReaderAssimp::m_assimp_vertices
protected

Definition at line 81 of file MeshReaderAssimp.h.

agx::StringVector agxIO::MeshReader::m_extensions
staticprotectedinherited

Definition at line 177 of file MeshReader.h.

agx::UInt32Vector agxIO::MeshReader::m_indices
protectedinherited
agx::ref_ptr<agx::Referenced> agxIO::MeshReaderAssimp::m_logger
protected

Definition at line 79 of file MeshReaderAssimp.h.

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

agx::Vec3Vector agxIO::MeshReader::m_normals
protectedinherited

Definition at line 173 of file MeshReader.h.

Referenced by agxIO::MeshReader::getNormals().

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.

agx::Vec2Vector agxIO::MeshReader::m_texCoordinates
protectedinherited

Definition at line 175 of file MeshReader.h.

Referenced by agxIO::MeshReader::getTextureCoordinates().

agx::Vec3Vector agxIO::MeshReader::m_vertices
protectedinherited

Definition at line 172 of file MeshReader.h.

Referenced by agxIO::MeshReader::getVertices().


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