AGXDynamics  2.31.1.0
agxIO::MeshReaderOBJ Class Reference

Class for reading a Wavefront OBJ file. More...

#include <MeshReaderOBJ.h>

+ Inheritance diagram for agxIO::MeshReaderOBJ:

Public Member Functions

 MeshReaderOBJ ()
 Constructor. 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)
 OBSOLETE. More...
 
virtual size_t readStream (std::istream &stream, FileExtension::FileType fet)
 Read a specified stream containing a mesh description in some mesh format. More...
 
size_t readString (const agx::String &mesh)
 OBSOLETE. More...
 
virtual size_t readString (const agx::String &mesh, FileExtension::FileType fet)
 Read a specified string containing a mesh description in some mesh 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 ~MeshReaderOBJ ()
 
void allocateObserverVector () const
 
void clear ()
 Reset all allocated memory. More...
 
void deleteUsingDeleteHandler () const
 
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_indices
 
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

Class for reading a Wavefront OBJ file.

Data is returned as vertices (getVertices()) and indices (getIndices())

Deprecated:
Use MeshReader for reading all types of mesh files

Definition at line 30 of file MeshReaderOBJ.h.

Constructor & Destructor Documentation

◆ MeshReaderOBJ()

agxIO::MeshReaderOBJ::MeshReaderOBJ ( )
inline

Constructor.

Definition at line 35 of file MeshReaderOBJ.h.

References agxIO::readFile(), and agxIO::MeshReader::readString().

◆ ~MeshReaderOBJ()

virtual agxIO::MeshReaderOBJ::~MeshReaderOBJ ( )
inlineprotectedvirtual

Definition at line 62 of file MeshReaderOBJ.h.

Member Function Documentation

◆ allocateObserverVector()

void agx::Referenced::allocateObserverVector ( ) const
protectedinherited

◆ as() [1/2]

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(), agx::InternalData::getOrCreate(), and agx::InternalData::hasData().

◆ as() [2/2]

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

◆ asSafe() [1/2]

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

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

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

◆ asSafe() [2/2]

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

◆ clear()

void agxIO::MeshReader::clear ( )
protectedinherited

Reset all allocated memory.

◆ deleteUsingDeleteHandler()

void agx::Referenced::deleteUsingDeleteHandler ( ) const
protectedinherited

◆ getDeleteHandler()

static DeleteHandler* agx::Referenced::getDeleteHandler ( )
staticprotectedinherited
Returns
a DeleteHandler.

◆ getFileExtension()

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

◆ getFileExtensionType()

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

◆ getIndices()

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.

◆ getNormals()

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.

◆ getNumTriangles()

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.

◆ getReferenceCount()

int agx::Referenced::getReferenceCount ( ) const
inherited
Returns
the number pointers currently referencing this object.

◆ getTextureCoordinates()

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.

◆ getVertices()

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.

◆ is()

template<typename T >
bool agx::Referenced::is ( ) const
inherited

◆ readFile()

size_t agxIO::MeshReaderOBJ::readFile ( const agx::String &  filename)
virtual

OBSOLETE.

USE MeshReader instead, for any type of mesh.

Read a file.

Parameters
filenameWavefront OBJ file containing triangles
Returns
number of found triangles.

Reimplemented from agxIO::MeshReader.

◆ readShlStream()

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.

◆ readStream()

virtual size_t agxIO::MeshReader::readStream ( std::istream &  stream,
FileExtension::FileType  fet 
)
virtualinherited

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

Returns
number of found triangles.

◆ readString() [1/2]

size_t agxIO::MeshReaderOBJ::readString ( const agx::String &  mesh)

OBSOLETE.

USE MeshReader instead, for any type of mesh.

Read a file.

Parameters
mesh- Wavefront OBJ description as a string
Returns
number of found triangles.

◆ readString() [2/2]

virtual size_t agxIO::MeshReader::readString ( const agx::String &  mesh,
FileExtension::FileType  fet 
)
virtualinherited

Read a specified string containing a mesh description in some mesh format defined as a string.

Returns
number of found triangles.

Referenced by MeshReaderOBJ().

◆ reference()

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.

◆ setDeleteHandler()

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

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

◆ unreference()

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.

Referenced by agxData::EntityRef< ContactMaterialPtr >::~EntityRef().

◆ unreference_nodelete()

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.

◆ ValidateCast()

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

Member Data Documentation

◆ m_extensions

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

Definition at line 177 of file MeshReader.h.

◆ m_indices

agx::UInt32Vector agxIO::MeshReader::m_indices
protectedinherited

Definition at line 174 of file MeshReader.h.

◆ m_mutex

Mutex agx::Referenced::m_mutex
mutableprotectedinherited

Definition at line 240 of file Referenced.h.

◆ m_normals

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

Definition at line 173 of file MeshReader.h.

◆ m_observers

ObserverContainer agx::Referenced::m_observers
mutableprotectedinherited

Definition at line 239 of file Referenced.h.

◆ m_refCount

AtomicValue agx::Referenced::m_refCount
mutableprotectedinherited

Definition at line 241 of file Referenced.h.

◆ m_texCoordinates

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

Definition at line 175 of file MeshReader.h.

◆ m_vertices

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

Definition at line 172 of file MeshReader.h.


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