Loading...
Searching...
No Matches
OPolyMesh.h
Go to the documentation of this file.
//-*****************************************************************************
//
// Copyright (c) 2009-2013,
// Sony Pictures Imageworks, Inc. and
// Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd.
//
// All rights reserved.
//
// Redistribution and use in source and binary forms, with or without
// modification, are permitted provided that the following conditions are
// met:
// * Redistributions of source code must retain the above copyright
// notice, this list of conditions and the following disclaimer.
// * Redistributions in binary form must reproduce the above
// copyright notice, this list of conditions and the following disclaimer
// in the documentation and/or other materials provided with the
// distribution.
// * Neither the name of Sony Pictures Imageworks, nor
// Industrial Light & Magic nor the names of their contributors may be used
// to endorse or promote products derived from this software without specific
// prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
//-*****************************************************************************
#ifndef Alembic_AbcGeom_OPolyMesh_h
#define Alembic_AbcGeom_OPolyMesh_h
#include <Alembic/Util/Export.h>
#include <Alembic/AbcGeom/Foundation.h>
#include <Alembic/AbcGeom/SchemaInfoDeclarations.h>
#include <Alembic/AbcGeom/OFaceSet.h>
#include <Alembic/AbcGeom/OGeomParam.h>
#include <Alembic/AbcGeom/OGeomBase.h>
namespace Alembic {
namespace AbcGeom {
namespace ALEMBIC_VERSION_NS {
//-*****************************************************************************
class ALEMBIC_EXPORT OPolyMeshSchema
: public OGeomBaseSchema<PolyMeshSchemaInfo>
{
public:
//-*************************************************************************
// POLY MESH SCHEMA SAMPLE TYPE
//-*************************************************************************
class Sample
{
public:
Sample() { reset(); }
Sample( const Abc::P3fArraySample &iPos )
: m_positions( iPos ) {}
Sample( const Abc::P3fArraySample &iPos,
const Abc::Int32ArraySample &iInd,
const Abc::Int32ArraySample &iCnt,
const OV2fGeomParam::Sample &iUVs = OV2fGeomParam::Sample(),
const ON3fGeomParam::Sample &iNormals = ON3fGeomParam::Sample() )
: m_positions( iPos )
, m_indices( iInd )
, m_counts( iCnt )
, m_uvs( iUVs )
, m_normals( iNormals )
{}
const Abc::P3fArraySample &getPositions() const { return m_positions; }
void setPositions( const Abc::P3fArraySample &iSmp )
{ m_positions = iSmp; }
// velocities accessor
const Abc::V3fArraySample &getVelocities() const { return m_velocities; }
void setVelocities( const Abc::V3fArraySample &iVelocities )
{ m_velocities = iVelocities; }
const Abc::Int32ArraySample &getFaceIndices() const { return m_indices; }
void setFaceIndices( const Abc::Int32ArraySample &iSmp )
{ m_indices = iSmp; }
const Abc::Int32ArraySample &getFaceCounts() const { return m_counts; }
void setFaceCounts( const Abc::Int32ArraySample &iCnt )
{ m_counts = iCnt; }
const Abc::Box3d &getSelfBounds() const { return m_selfBounds; }
void setSelfBounds( const Abc::Box3d &iBnds )
{ m_selfBounds = iBnds; }
const OV2fGeomParam::Sample &getUVs() const { return m_uvs; }
void setUVs( const OV2fGeomParam::Sample &iUVs )
{ m_uvs = iUVs; }
const ON3fGeomParam::Sample &getNormals() const { return m_normals; }
void setNormals( const ON3fGeomParam::Sample &iNormals )
{ m_normals = iNormals; }
void reset()
{
m_positions.reset();
m_indices.reset();
m_counts.reset();
m_selfBounds.makeEmpty();
m_velocities.reset();
m_uvs.reset();
m_normals.reset();
}
bool isPartialSample() const
{
if( !m_positions.getData() && !m_indices.getData() && !m_counts.getData() )
{
if( m_uvs.getVals() || m_normals.getVals() || m_velocities.getData() )
{
return true;
}
}
return false;
}
protected:
Abc::P3fArraySample m_positions;
Abc::Int32ArraySample m_indices;
Abc::Int32ArraySample m_counts;
Abc::Box3d m_selfBounds;
Abc::V3fArraySample m_velocities;
OV2fGeomParam::Sample m_uvs;
ON3fGeomParam::Sample m_normals;
};
//-*************************************************************************
// POLY MESH SCHEMA
//-*************************************************************************
public:
typedef OPolyMeshSchema this_type;
//-*************************************************************************
// CONSTRUCTION, DESTRUCTION, ASSIGNMENT
//-*************************************************************************
OPolyMeshSchema()
{
m_selectiveExport = false;
m_numSamples = 0;
m_timeSamplingIndex = 0;
}
OPolyMeshSchema( AbcA::CompoundPropertyWriterPtr iParent,
const std::string &iName,
const Abc::Argument &iArg0 = Abc::Argument(),
const Abc::Argument &iArg1 = Abc::Argument(),
const Abc::Argument &iArg2 = Abc::Argument(),
const Abc::Argument &iArg3 = Abc::Argument() );
OPolyMeshSchema( Abc::OCompoundProperty iParent,
const std::string &iName,
const Abc::Argument &iArg0 = Abc::Argument(),
const Abc::Argument &iArg1 = Abc::Argument(),
const Abc::Argument &iArg2 = Abc::Argument() );
OPolyMeshSchema( const OPolyMeshSchema& iCopy )
: OGeomBaseSchema<PolyMeshSchemaInfo>()
{
*this = iCopy;
}
//-*************************************************************************
// SCHEMA STUFF
//-*************************************************************************
AbcA::TimeSamplingPtr getTimeSampling() const
{
if( m_positionsProperty.valid() )
{
return m_positionsProperty.getTimeSampling();
}
else
{
return getObject().getArchive().getTimeSampling( 0 );
}
}
//-*************************************************************************
// SAMPLE STUFF
//-*************************************************************************
size_t getNumSamples() const
{ return m_numSamples; }
void set( const Sample &iSamp );
void setFromPrevious();
void setTimeSampling( uint32_t iIndex );
void setTimeSampling( AbcA::TimeSamplingPtr iTime );
//-*************************************************************************
// ABC BASE MECHANISMS
// These functions are used by Abc to deal with errors, validity,
// and so on.
//-*************************************************************************
void reset()
{
m_positionsProperty.reset();
m_velocitiesProperty.reset();
m_indicesProperty.reset();
m_countsProperty.reset();
m_uvsParam.reset();
m_normalsParam.reset();
m_faceSets.clear();
OGeomBaseSchema<PolyMeshSchemaInfo>::reset();
}
bool valid() const
{
return ( ( OGeomBaseSchema<PolyMeshSchemaInfo>::valid() &&
m_positionsProperty.valid() &&
m_indicesProperty.valid() &&
m_countsProperty.valid() ) ) ||
m_selectiveExport;
}
// FaceSet stuff
OFaceSet & createFaceSet( const std::string &iFaceSetName );
void getFaceSetNames (std::vector <std::string> & oFaceSetNames);
OFaceSet getFaceSet( const std::string &iFaceSetName );
bool hasFaceSet( const std::string &iFaceSetName );
void setUVSourceName(const std::string & iName);
ALEMBIC_OVERRIDE_OPERATOR_BOOL( OPolyMeshSchema::valid() );
private:
void init( uint32_t iTsIdx, bool isSparse );
void selectiveSet( const Sample &iSamp );
Abc::OP3fArrayProperty m_positionsProperty;
Abc::OV3fArrayProperty m_velocitiesProperty;
Abc::OInt32ArrayProperty m_indicesProperty;
Abc::OInt32ArrayProperty m_countsProperty;
// FaceSets created on this PolyMesh
std::map <std::string, OFaceSet> m_faceSets;
OV2fGeomParam m_uvsParam;
ON3fGeomParam m_normalsParam;
// optional source name for the UVs
std::string m_uvSourceName;
// Write out only some properties (UVs, normals).
// This is to export data to layer into another file later.
bool m_selectiveExport;
// Number of times OPolyMeshSchema::set() has been called
size_t m_numSamples;
uint32_t m_timeSamplingIndex;
void createPositionsProperty();
void createVelocitiesProperty();
void createUVsProperty( const Sample &iSamp );
void createNormalsProperty( const Sample &iSamp );
// self and child bounds and ArbGeomParams and UserProperties
// all come from OGeomBaseSchema
};
//-*****************************************************************************
// SCHEMA OBJECT
//-*****************************************************************************
typedef Abc::OSchemaObject<OPolyMeshSchema> OPolyMesh;
typedef Util::shared_ptr< OPolyMesh > OPolyMeshPtr;
} // End namespace ALEMBIC_VERSION_NS
using namespace ALEMBIC_VERSION_NS;
} // End namespace AbcGeom
} // End namespace Alembic
#endif
Foundation.h
SchemaInfoDeclarations.h
Export.h
ALEMBIC_EXPORT
#define ALEMBIC_EXPORT
Definition Export.h:51
OFaceSet.h
OGeomBase.h
OGeomParam.h
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema< PolyMeshSchemaInfo >::OGeomBaseSchema
OGeomBaseSchema()
Definition OGeomBase.h:74
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::reset
virtual void reset()
Definition OGeomBase.h:110
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema::valid
virtual bool valid() const
Definition OGeomBase.h:119
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample
Definition OPolyMesh.h:60
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::Sample
Sample(const Abc::P3fArraySample &iPos, const Abc::Int32ArraySample &iInd, const Abc::Int32ArraySample &iCnt, const OV2fGeomParam::Sample &iUVs=OV2fGeomParam::Sample(), const ON3fGeomParam::Sample &iNormals=ON3fGeomParam::Sample())
Definition OPolyMesh.h:77
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::isPartialSample
bool isPartialSample() const
Definition OPolyMesh.h:131
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::Sample
Sample(const Abc::P3fArraySample &iPos)
Definition OPolyMesh.h:68
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::setFaceCounts
void setFaceCounts(const Abc::Int32ArraySample &iCnt)
Definition OPolyMesh.h:103
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::getNormals
const ON3fGeomParam::Sample & getNormals() const
Definition OPolyMesh.h:114
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::reset
void reset()
Definition OPolyMesh.h:118
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::m_selfBounds
Abc::Box3d m_selfBounds
Definition OPolyMesh.h:149
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::getFaceIndices
const Abc::Int32ArraySample & getFaceIndices() const
Definition OPolyMesh.h:98
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::getPositions
const Abc::P3fArraySample & getPositions() const
Definition OPolyMesh.h:89
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::getFaceCounts
const Abc::Int32ArraySample & getFaceCounts() const
Definition OPolyMesh.h:102
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::setNormals
void setNormals(const ON3fGeomParam::Sample &iNormals)
Definition OPolyMesh.h:115
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::getVelocities
const Abc::V3fArraySample & getVelocities() const
Definition OPolyMesh.h:94
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::m_uvs
OV2fGeomParam::Sample m_uvs
Definition OPolyMesh.h:152
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::setFaceIndices
void setFaceIndices(const Abc::Int32ArraySample &iSmp)
Definition OPolyMesh.h:99
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::setUVs
void setUVs(const OV2fGeomParam::Sample &iUVs)
Definition OPolyMesh.h:111
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::Sample
Sample()
Definition OPolyMesh.h:64
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::getSelfBounds
const Abc::Box3d & getSelfBounds() const
Definition OPolyMesh.h:106
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::setPositions
void setPositions(const Abc::P3fArraySample &iSmp)
Definition OPolyMesh.h:90
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::m_counts
Abc::Int32ArraySample m_counts
Definition OPolyMesh.h:147
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::m_normals
ON3fGeomParam::Sample m_normals
Definition OPolyMesh.h:153
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::setSelfBounds
void setSelfBounds(const Abc::Box3d &iBnds)
Definition OPolyMesh.h:107
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::m_positions
Abc::P3fArraySample m_positions
Definition OPolyMesh.h:145
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::getUVs
const OV2fGeomParam::Sample & getUVs() const
Definition OPolyMesh.h:110
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::setVelocities
void setVelocities(const Abc::V3fArraySample &iVelocities)
Definition OPolyMesh.h:95
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::m_velocities
Abc::V3fArraySample m_velocities
Definition OPolyMesh.h:151
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::m_indices
Abc::Int32ArraySample m_indices
Definition OPolyMesh.h:146
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::getTimeSampling
AbcA::TimeSamplingPtr getTimeSampling() const
Default assignment operator used.
Definition OPolyMesh.h:217
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::OPolyMeshSchema
OPolyMeshSchema(const OPolyMeshSchema &iCopy)
Copy constructor.
Definition OPolyMesh.h:203
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::createFaceSet
OFaceSet & createFaceSet(const std::string &iFaceSetName)
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::setFromPrevious
void setFromPrevious()
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::getNumSamples
size_t getNumSamples() const
Definition OPolyMesh.h:235
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::getFaceSetNames
void getFaceSetNames(std::vector< std::string > &oFaceSetNames)
Appends the names of any FaceSets for this PolyMesh.
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::set
void set(const Sample &iSamp)
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::valid
bool valid() const
Definition OPolyMesh.h:273
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::getFaceSet
OFaceSet getFaceSet(const std::string &iFaceSetName)
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::setUVSourceName
void setUVSourceName(const std::string &iName)
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::setTimeSampling
void setTimeSampling(AbcA::TimeSamplingPtr iTime)
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::this_type
OPolyMeshSchema this_type
Definition OPolyMesh.h:162
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::OPolyMeshSchema
OPolyMeshSchema(AbcA::CompoundPropertyWriterPtr iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument(), const Abc::Argument &iArg2=Abc::Argument(), const Abc::Argument &iArg3=Abc::Argument())
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::OPolyMeshSchema
OPolyMeshSchema()
Definition OPolyMesh.h:170
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::reset
void reset()
Definition OPolyMesh.h:257
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::setTimeSampling
void setTimeSampling(uint32_t iIndex)
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::ALEMBIC_OVERRIDE_OPERATOR_BOOL
ALEMBIC_OVERRIDE_OPERATOR_BOOL(OPolyMeshSchema::valid())
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::hasFaceSet
bool hasFaceSet(const std::string &iFaceSetName)
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::OPolyMeshSchema
OPolyMeshSchema(Abc::OCompoundProperty iParent, const std::string &iName, const Abc::Argument &iArg0=Abc::Argument(), const Abc::Argument &iArg1=Abc::Argument(), const Abc::Argument &iArg2=Abc::Argument())
Alembic::Abc::ALEMBIC_VERSION_NS::Argument
Definition Argument.h:120
Alembic::Abc::ALEMBIC_VERSION_NS::OBasePropertyT< AbcA::CompoundPropertyWriterPtr >::getObject
OObject getObject() const
Definition OBaseProperty.h:225
Alembic::Abc::ALEMBIC_VERSION_NS::OCompoundProperty
Definition OCompoundProperty.h:53
Alembic::Abc::ALEMBIC_VERSION_NS::OSchemaObject
Definition OSchemaObject.h:54
Alembic::AbcGeom::ALEMBIC_VERSION_NS
Definition ArchiveBounds.h:45
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMesh
Abc::OSchemaObject< OPolyMeshSchema > OPolyMesh
Definition OPolyMesh.h:343
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OFaceSet
Abc::OSchemaObject< OFaceSetSchema > OFaceSet
Definition OFaceSet.h:220
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OV2fGeomParam
OTypedGeomParam< V2fTPTraits > OV2fGeomParam
Definition OGeomParam.h:396
Alembic::AbcGeom::ALEMBIC_VERSION_NS::ON3fGeomParam
OTypedGeomParam< N3fTPTraits > ON3fGeomParam
Definition OGeomParam.h:443
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshPtr
Util::shared_ptr< OPolyMesh > OPolyMeshPtr
Definition OPolyMesh.h:345
Alembic::AbcGeom
Definition ArchiveBounds.h:44
Alembic::Abc::ALEMBIC_VERSION_NS::V3fArraySample
TypedArraySample< V3fTPTraits > V3fArraySample
Definition TypedArraySample.h:171
Alembic::Abc::ALEMBIC_VERSION_NS::OInt32ArrayProperty
OTypedArrayProperty< Int32TPTraits > OInt32ArrayProperty
Definition OTypedArrayProperty.h:249
Alembic::Abc::ALEMBIC_VERSION_NS::P3fArraySample
TypedArraySample< P3fTPTraits > P3fArraySample
Definition TypedArraySample.h:181
Alembic::Abc::ALEMBIC_VERSION_NS::Int32ArraySample
TypedArraySample< Int32TPTraits > Int32ArraySample
Definition TypedArraySample.h:155
Alembic::Abc::ALEMBIC_VERSION_NS::OP3fArrayProperty
OTypedArrayProperty< P3fTPTraits > OP3fArrayProperty
Definition OTypedArrayProperty.h:275
Alembic::Abc::ALEMBIC_VERSION_NS::OV3fArrayProperty
OTypedArrayProperty< V3fTPTraits > OV3fArrayProperty
Definition OTypedArrayProperty.h:265
Alembic
Alembic namespace ...
Definition ArchiveInfo.h:46