Loading...
Searching...
No Matches
OPolyMesh.h
//-*****************************************************************************
//
// 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() );
//-*************************************************************************
// 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
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::AbcCoreAbstract::ALEMBIC_VERSION_NS::ArraySample::reset
void reset()
Definition ArraySample.h:119
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OGeomBaseSchema< PolyMeshSchemaInfo >::OGeomBaseSchema
OGeomBaseSchema()
Definition OGeomBase.h:74
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::Sample
Sample(const Abc::P3fArraySample &iPos)
Definition OPolyMesh.h:68
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::Sample::Sample
Sample()
Definition OPolyMesh.h:64
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema
Definition OPolyMesh.h:54
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::getTimeSampling
AbcA::TimeSamplingPtr getTimeSampling() const
Default assignment and copy operator used.
Definition OPolyMesh.h:210
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::getNumSamples
size_t getNumSamples() const
Definition OPolyMesh.h:228
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::valid
bool valid() const
Definition OPolyMesh.h:266
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::this_type
OPolyMeshSchema this_type
Definition OPolyMesh.h:162
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::OPolyMeshSchema
OPolyMeshSchema()
Definition OPolyMesh.h:170
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::reset
void reset()
Definition OPolyMesh.h:250
Alembic::AbcGeom::ALEMBIC_VERSION_NS::OPolyMeshSchema::ALEMBIC_OVERRIDE_OPERATOR_BOOL
ALEMBIC_OVERRIDE_OPERATOR_BOOL(OPolyMeshSchema::valid())
Alembic
Alembic namespace ...
Definition ArchiveInfo.cpp:39