本文整理汇总了C++中DataType::getPod方法的典型用法代码示例。如果您正苦于以下问题:C++ DataType::getPod方法的具体用法?C++ DataType::getPod怎么用?C++ DataType::getPod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataType
的用法示例。
在下文中一共展示了DataType::getPod方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readSimpleProperties
void readSimpleProperties(const std::string &archiveName)
{
// Open an existing archive for reading. Indicate that we want
// Alembic to throw exceptions on errors.
IArchive archive( Alembic::AbcCoreHDF5::ReadArchive(),
archiveName, ErrorHandler::kThrowPolicy );
IObject archiveTop = archive.getTop();
// Determine the number of (top level) children the archive has
const unsigned int numChildren = archiveTop.getNumChildren();
ABCA_ASSERT( numChildren == 1, "Wrong number of children (expected 1)");
std::cout << "The archive has " << numChildren << " children:"
<< std::endl;
// Iterate through them, print out their names
IObject child( archiveTop, archiveTop.getChildHeader( 0 ).getName() );
std::cout << " " << child.getName();
std::cout << " has " << child.getNumChildren() << " children"
<< std::endl;
// Properties
ICompoundProperty props = child.getProperties();
size_t numProperties = props.getNumProperties();
std::cout << " ..and " << numProperties << " simple properties"
<< std::endl;
std::vector<std::string> propNames;
for (unsigned int pp=0; pp<numProperties; pp++)
propNames.push_back( props.getPropertyHeader(pp).getName() );
for (unsigned int jj=0; jj<numProperties; jj++)
{
std::cout << " ..named " << propNames[jj] << std::endl;
std::cout << " ..with type: ";
PropertyType pType = props.getPropertyHeader(jj).getPropertyType();
if (pType == kCompoundProperty)
{
std::cout << "compound" << std::endl;
}
else if (pType == kScalarProperty)
{
std::cout << "scalar" << std::endl;
}
else if (pType == kArrayProperty)
{
std::cout << "array" << std::endl;
}
DataType dType = props.getPropertyHeader(jj).getDataType();
std::cout << " ..with POD-type: ";
switch (dType.getPod())
{
case kBooleanPOD:
std::cout << "boolean" << std::endl;
break;
// Char/UChar
case kUint8POD:
std::cout << "unsigned char" << std::endl;
break;
case kInt8POD:
std::cout << "char" << std::endl;
break;
// Short/UShort
case kUint16POD:
std::cout << "short unsigned int" << std::endl;
break;
case kInt16POD:
std::cout << "short int" << std::endl;
break;
// Int/UInt
case kUint32POD:
std::cout << "unsigned int" << std::endl;
break;
case kInt32POD:
std::cout << "int" << std::endl;
break;
// Long/ULong
case kUint64POD:
std::cout << "unsigned long int" << std::endl;
break;
case kInt64POD:
std::cout << "long int" << std::endl;
break;
// Half/Float/Double
case kFloat16POD:
std::cout << "half" << std::endl;
break;
case kFloat32POD:
std::cout << "float" << std::endl;
break;
case kFloat64POD:
//.........这里部分代码省略.........
示例2: readProperty
void readProperty(const std::string &archiveName, bool useOgawa)
{
// Open an existing archive for reading. Indicate that we want
// Alembic to throw exceptions on errors.
std::cout << "Reading " << archiveName << std::endl;
AbcF::IFactory factory;
factory.setPolicy( ErrorHandler::kThrowPolicy );
AbcF::IFactory::CoreType coreType;
IArchive archive = factory.getArchive(archiveName, coreType);
ABCA_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) ||
(!useOgawa && coreType == AbcF::IFactory::kHDF5),
"File did not open as the expected type." );
IObject archiveTop = archive.getTop();
// Determine the number of (top level) children the archive has
const unsigned int numChildren = archiveTop.getNumChildren();
ABCA_ASSERT( numChildren == 1, "Wrong number of children (expected 1)");
std::cout << "The archive has " << numChildren << " children:"
<< std::endl;
// Iterate through them, print out their names
IObject child( archiveTop, archiveTop.getChildHeader( 0 ).getName() );
std::cout << " " << child.getName();
// Properties
ICompoundProperty props = child.getProperties();
size_t numProperties = props.getNumProperties(); // only top-level props
ABCA_ASSERT( numProperties == 1,
"Expected 1 property, found " << numProperties);
std::cout << " with one property";
std::vector<std::string> propNames(1);
propNames[0] = props.getPropertyHeader(0).getName();
std::cout << " named " << propNames[0] << std::endl;
PropertyType pType = props.getPropertyHeader(0).getPropertyType();
ABCA_ASSERT( pType == kScalarProperty,
"Expected a scalar property, but didn't find one" );
std::cout << " which is a scalar property";
DataType dType = props.getPropertyHeader(0).getDataType();
ABCA_ASSERT( dType.getPod() == kFloat64POD,
"Expected a double (kFloat64POD) property, but didn't"
" find one" );
// We know this is a scalar property (I'm eliding the if/else
// statements required to recognize this)
IDoubleProperty mass( props, propNames[0] );
size_t numSamples = mass.getNumSamples();
std::cout << ".. it has " << numSamples << " samples" << std::endl;
//ABCA_ASSERT( numSamples == 5, "Expected 5 samples, found " << numSamples );
TimeSamplingPtr ts = mass.getTimeSampling();
std::cout << "..with time/value pairs: ";
for (unsigned int ss=0; ss<numSamples; ss++)
{
ISampleSelector iss( (index_t) ss);
std::cout << ts->getSampleTime( (index_t) ss ) << "/";
printSampleValue( mass, iss );
std::cout << " ";
double timeDiff = ts->getSampleTime( (index_t) ss ) -
(g_startTime + (ss*(g_dt/3.0)));
ABCA_ASSERT( fabs(timeDiff) < 1e-12, "Incorrect sample time read" );
double massDiff = mass.getValue( iss ) - (1.0 + 0.1*ss);
ABCA_ASSERT( fabs(massDiff) < 1e-12, "Incorrect sample value read" );
}
ABCA_ASSERT(
archive.getMaxNumSamplesForTimeSamplingIndex(1) == (index_t) numSamples,
"Incorrect number of max samples for Time Sampling ID 1.");
std::cout << std::endl;
// Done - the archive closes itself
}
示例3: readV3fArrayProperty
void readV3fArrayProperty(const std::string &archiveName, bool useOgawa)
{
// Open an existing archive for reading. Indicate that we want
// Alembic to throw exceptions on errors.
std::cout << "Reading " << archiveName << std::endl;
AbcF::IFactory factory;
factory.setPolicy( ErrorHandler::kThrowPolicy );
AbcF::IFactory::CoreType coreType;
IArchive archive = factory.getArchive(archiveName, coreType);
TESTING_ASSERT( (useOgawa && coreType == AbcF::IFactory::kOgawa) ||
(!useOgawa && coreType == AbcF::IFactory::kHDF5) );
IObject archiveTop = archive.getTop();
// Determine the number of (top level) children the archive has
const unsigned int numChildren = archiveTop.getNumChildren();
ABCA_ASSERT( numChildren == 1, "Wrong number of children (expected 1)");
std::cout << "The archive has " << numChildren << " children:"
<< std::endl;
// Iterate through them, print out their names
IObject child( archiveTop, archiveTop.getChildHeader(0).getName() );
std::cout << " named '" << child.getName() << "'";
// Properties
ICompoundProperty props = child.getProperties();
size_t numProperties = props.getNumProperties(); // only top-level props
ABCA_ASSERT( numProperties == 1,
"Expected 1 property, found " << numProperties);
std::cout << " with one property";
std::vector<std::string> propNames(1);
propNames[0] = props.getPropertyHeader(0).getName();
std::cout << " named '" << propNames[0] << "'" << std::endl;
PropertyType pType = props.getPropertyHeader(0).getPropertyType();
ABCA_ASSERT( pType == kArrayProperty,
"Expected an array property, but didn't find one" );
std::cout << " which is an array property";
DataType dType = props.getPropertyHeader(0).getDataType();
ABCA_ASSERT( dType.getPod() == kFloat32POD,
"Expected an v3f property, but didn't find one" );
// We know this is an array property (I'm eliding the if/else
// statements required to recognize and handle this properly)
IV3fArrayProperty positions( props, propNames[0] );
size_t numSamples = positions.getNumSamples();
std::cout << ".. it has " << numSamples << " samples" << std::endl;
ABCA_ASSERT( numSamples == 5, "Expected 5 samples, found " << numSamples );
TimeSamplingPtr ts = positions.getTimeSampling();
std::cout << "..with time/value pairs: " << std::endl;;
for (unsigned int ss=0; ss<numSamples; ss++)
{
std::cout << " ";
ISampleSelector iss( (index_t) ss);
std::cout << ts->getSampleTime( (index_t) ss ) << " / ";
V3fArraySamplePtr samplePtr;
positions.get( samplePtr, iss );
std::cout << "[ ";
size_t numPoints = samplePtr->size();
for ( size_t jj=0 ; jj<numPoints ; jj++ )
std::cout << (*samplePtr)[jj] << " ";
std::cout << "]" << std::endl;
if (ss == 2) // no entries in sample #2
{
ABCA_ASSERT( numPoints == 0,
"Expected an empty sample, but found " << numPoints
<< " entries." );
}
else
{
for ( size_t jj=0 ; jj<numPoints ; jj++ )
ABCA_ASSERT( (*samplePtr)[jj] == g_vectors[jj],
"Incorrect value read from archive." );
}
}
ABCA_ASSERT(
archive.getMaxNumSamplesForTimeSamplingIndex(1) == (index_t) numSamples,
"Incorrect number of max samples in readV3fArrayProperty." );
std::cout << std::endl;
// Done - the archive closes itself
double start, end;
GetArchiveStartAndEndTime( archive, start, end );
TESTING_ASSERT( almostEqual(start, 123.0) );
TESTING_ASSERT( almostEqual(end, 123.0 + 4.0 / 24.0) );
}