本文整理汇总了C++中DataPtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ DataPtr::get方法的具体用法?C++ DataPtr::get怎么用?C++ DataPtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataPtr
的用法示例。
在下文中一共展示了DataPtr::get方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: put
void OStream::put(const DataPtr &value)
{
write_byte( (Byte8) Data );
write(value.get(), value.length());
}
示例2: transferAttribValues
void ToHoudiniGeometryConverter::transferAttribValues(
const Primitive *primitive, GU_Detail *geo,
const GA_Range &points, const GA_Range &prims,
PrimitiveVariable::Interpolation vertexInterpolation,
PrimitiveVariable::Interpolation primitiveInterpolation,
PrimitiveVariable::Interpolation pointInterpolation,
PrimitiveVariable::Interpolation detailInterpolation
) const
{
GA_OffsetList offsets;
if ( prims.isValid() )
{
const GA_PrimitiveList &primitives = geo->getPrimitiveList();
for ( GA_Iterator it=prims.begin(); !it.atEnd(); ++it )
{
const GA_Primitive *prim = primitives.get( it.getOffset() );
size_t numPrimVerts = prim->getVertexCount();
for ( size_t v=0; v < numPrimVerts; v++ )
{
if ( prim->getTypeId() == GEO_PRIMPOLY )
{
offsets.append( prim->getVertexOffset( numPrimVerts - 1 - v ) );
}
else
{
offsets.append( prim->getVertexOffset( v ) );
}
}
}
}
GA_Range vertRange( geo->getVertexMap(), offsets );
UT_String filter( attributeFilterParameter()->getTypedValue() );
bool convertStandardAttributes = m_convertStandardAttributesParameter->getTypedValue();
// process all primvars with UV interpretation
for ( const auto &it : primitive->variables)
{
if ( !UT_String( it.first ).multiMatch( filter ) )
{
continue;
}
if (const V2fVectorData *uvData = runTimeCast<const V2fVectorData> ( it.second.data.get() ) )
{
if ( uvData->getInterpretation() != GeometricData::UV )
{
continue;
}
PrimitiveVariable::IndexedView<Imath::V2f> uvIndexedView ( it.second );
// Houdini prefers a V3f uvw rather than V2f uv,
// though they advise setting the 3rd component to 0.
std::vector<Imath::V3f> uvw;
uvw.reserve( uvIndexedView.size() );
for ( size_t i=0; i < uvIndexedView.size(); ++i )
{
uvw.emplace_back( uvIndexedView[i][0], uvIndexedView[i][1], 0 );
}
GA_Range range = vertRange;
if ( it.second.interpolation == pointInterpolation )
{
range = points;
}
V3fVectorData::Ptr uvwData = new V3fVectorData( uvw );
uvwData->setInterpretation( GeometricData::UV );
ToHoudiniAttribConverterPtr converter = ToHoudiniAttribConverter::create( uvwData.get() );
converter->convert( it.first, geo, range );
filter += " ^" + it.first;
}
}
UT_StringMMPattern attribFilter;
attribFilter.compile( filter );
// add the primitive variables to the various GEO_AttribDicts based on interpolation type
for ( PrimitiveVariableMap::const_iterator it=primitive->variables.begin() ; it != primitive->variables.end(); it++ )
{
if( !primitive->isPrimitiveVariableValid( it->second ) )
{
IECore::msg( IECore::MessageHandler::Warning, "ToHoudiniGeometryConverter", "PrimitiveVariable " + it->first + " is invalid. Ignoring." );
continue;
}
UT_String varName( it->first );
if ( !varName.multiMatch( attribFilter ) )
{
continue;
}
PrimitiveVariable primVar = processPrimitiveVariable( primitive, it->second );
//.........这里部分代码省略.........
示例3: BoolData
Imath::Box3f SceneGadget::selectionBound() const
{
DataPtr d = m_renderer->command( "gl:queryBound", { { "selection", new BoolData( true ) } } );
return static_cast<Box3fData *>( d.get() )->readable();
}
示例4: Record
inline Record::Record (const RecordIdentifier & rid, char * ptr, size_t sz) {
_id = rid;
_size = sz;
_pData = DataPtr (new char[_size] ( ));
memcpy_s (_pData.get ( ), _size, ptr, _size);
}
示例5: GetData
inline RETCODE Record::GetData (char * & pData) const {
pData = _pData.get();
return RETCODE::COMPLETE;
}
示例6: sizeof
inline char * Page::GetDataRawPtr ( ) const {
return _pData.get ( ) + sizeof (PageHeader);
}
示例7: GetData
inline RETCODE Page::GetData (char * & pData) const {
pData = _pData.get ( ) + sizeof (PageHeader);
return RETCODE::COMPLETE;
}
示例8: resamplePrimitiveVariable
void resamplePrimitiveVariable( const CurvesPrimitive *curves, PrimitiveVariable &primitiveVariable, PrimitiveVariable::Interpolation interpolation )
{
if ( interpolation == primitiveVariable.interpolation)
{
return;
}
DataPtr dstData = nullptr;
DataPtr srcData = nullptr;
if( primitiveVariable.indices )
{
if( primitiveVariable.interpolation == PrimitiveVariable::Vertex && ( interpolation == PrimitiveVariable::Varying || interpolation == PrimitiveVariable::FaceVarying ) )
{
// \todo: fix CurvesVertexToVarying so it works with arbitrary PrimitiveVariables
// rather than requiring the variables exist on the input CurvesPrimitive.
throw InvalidArgumentException( "CurvesAlgo::resamplePrimitiveVariable : Resampling indexed Vertex variables to FaceVarying/Varying is not currently supported. Expand indices first." );
}
else if( ( primitiveVariable.interpolation == PrimitiveVariable::Varying || primitiveVariable.interpolation == PrimitiveVariable::FaceVarying ) && interpolation == PrimitiveVariable::Vertex )
{
// \todo: fix CurvesVaryingToVertex so it works with arbitrary PrimitiveVariables
// rather than requiring the variables exist on the input CurvesPrimitive.
throw InvalidArgumentException( "CurvesAlgo::resamplePrimitiveVariable : Resampling indexed FaceVarying/Varying variables to Vertex is not currently supported. Expand indices first." );
}
else if( primitiveVariable.interpolation < interpolation )
{
// upsampling can be a resampling of indices
srcData = primitiveVariable.indices;
}
else if( primitiveVariable.interpolation == PrimitiveVariable::FaceVarying && interpolation == PrimitiveVariable::Varying )
{
// FaceVarying and Varying are the same for CurvesPrimitives
srcData = primitiveVariable.indices;
}
else
{
// downsampling forces index expansion to
// simplify the algorithms.
// \todo: allow indices to be maintained.
srcData = primitiveVariable.expandedData();
primitiveVariable.indices = nullptr;
}
}
else
{
// with no indices we can just resample the data
srcData = primitiveVariable.data;
}
if ( interpolation == PrimitiveVariable::Constant )
{
Detail::AverageValueFromVector fn;
dstData = despatchTypedData<Detail::AverageValueFromVector, Detail::IsArithmeticVectorTypedData>( const_cast< Data * >( srcData.get() ), fn );
}
else if ( primitiveVariable.interpolation == PrimitiveVariable::Constant )
{
DataPtr arrayData = Detail::createArrayData(primitiveVariable, curves, interpolation);
if (arrayData)
{
dstData = arrayData;
}
}
else if ( interpolation == PrimitiveVariable::Uniform )
{
if ( primitiveVariable.interpolation == PrimitiveVariable::Vertex )
{
CurvesVertexToUniform fn( curves );
dstData = despatchTypedData<CurvesVertexToUniform, Detail::IsArithmeticVectorTypedData>( const_cast< Data * >( srcData.get() ), fn );
}
else if ( primitiveVariable.interpolation == PrimitiveVariable::Varying || primitiveVariable.interpolation == PrimitiveVariable::FaceVarying )
{
CurvesVaryingToUniform fn( curves );
dstData = despatchTypedData<CurvesVaryingToUniform, Detail::IsArithmeticVectorTypedData>( const_cast< Data * >( srcData.get() ), fn );
}
}
else if ( interpolation == PrimitiveVariable::Vertex )
{
if ( primitiveVariable.interpolation == PrimitiveVariable::Uniform )
{
CurvesUniformToVertex fn( curves->verticesPerCurve()->readable() );
dstData = despatchTypedData<CurvesUniformToVertex, TypeTraits::IsNumericBasedVectorTypedData>( const_cast< Data * >( srcData.get() ), fn );
}
else if ( primitiveVariable.interpolation == PrimitiveVariable::Varying || primitiveVariable.interpolation == PrimitiveVariable::FaceVarying )
{
CurvesVaryingToVertex fn( curves );
dstData = despatchTypedData<CurvesVaryingToVertex, IsPrimitiveEvaluatableTypedData>( const_cast< Data * >( srcData.get() ), fn );
}
}
else if ( interpolation == PrimitiveVariable::Varying || interpolation == PrimitiveVariable::FaceVarying )
{
if ( primitiveVariable.interpolation == PrimitiveVariable::Uniform )
{
CurvesUniformToVarying fn( curves );
dstData = despatchTypedData<CurvesUniformToVarying, TypeTraits::IsNumericBasedVectorTypedData>( const_cast< Data * >( srcData.get()), fn );
}
else if ( primitiveVariable.interpolation == PrimitiveVariable::Vertex )
{
CurvesVertexToVarying fn( curves );
dstData = despatchTypedData<CurvesVertexToVarying, IsPrimitiveEvaluatableTypedData>( const_cast< Data * >( srcData.get() ), fn );
//.........这里部分代码省略.........
示例9: writeImage
void DPXImageWriter::writeImage( const vector<string> &names, const ImagePrimitive *image, const Box2i &dataWindow ) const
{
// write the dpx in the standard 10bit log format
ofstream out;
out.open(fileName().c_str());
if ( !out.is_open() )
{
throw IOException( "DPXImageWriter: Error writing to " + fileName() );
}
/// We'd like RGB to be at the front, in that order, because it seems that not all readers support the channel identifiers!
vector<string> desiredChannelOrder;
desiredChannelOrder.push_back( "R" );
desiredChannelOrder.push_back( "G" );
desiredChannelOrder.push_back( "B" );
vector<string> namesCopy = names;
vector<string> filteredNames;
for ( vector<string>::const_iterator it = desiredChannelOrder.begin(); it != desiredChannelOrder.end(); ++it )
{
vector<string>::iterator res = find( namesCopy.begin(), namesCopy.end(), *it );
if ( res != namesCopy.end() )
{
namesCopy.erase( res );
filteredNames.push_back( *it );
}
}
for ( vector<string>::const_iterator it = namesCopy.begin(); it != namesCopy.end(); ++it )
{
filteredNames.push_back( *it );
}
assert( names.size() == filteredNames.size() );
Box2i displayWindow = image->getDisplayWindow();
int displayWidth = 1 + displayWindow.size().x;
int displayHeight = 1 + displayWindow.size().y;
// build the header
DPXFileInformation fi;
memset(&fi, 0, sizeof(fi));
DPXImageInformation ii;
memset(&ii, 0, sizeof(ii));
DPXImageOrientation ioi;
memset(&ioi, 0, sizeof(ioi));
DPXMotionPictureFilm mpf;
memset(&mpf, 0, sizeof(mpf));
DPXTelevisionHeader th;
memset(&th, 0, sizeof(th));
fi.magic = asBigEndian<>( 0x53445058 );
// compute data offsets
fi.gen_hdr_size = sizeof(fi) + sizeof(ii) + sizeof(ioi);
fi.gen_hdr_size = asBigEndian<>(fi.gen_hdr_size);
fi.ind_hdr_size = sizeof(mpf) + sizeof(th);
fi.ind_hdr_size = asBigEndian<>(fi.ind_hdr_size);
int header_size = sizeof(fi) + sizeof(ii) + sizeof(ioi) + sizeof(mpf) + sizeof(th);
fi.image_data_offset = header_size;
fi.image_data_offset = asBigEndian<>(fi.image_data_offset);
strcpy((char *) fi.vers, "V2.0");
strncpy( (char *) fi.file_name, fileName().c_str(), sizeof( fi.file_name ) );
// compute the current date and time
boost::posix_time::ptime utc = boost::posix_time::second_clock::universal_time();
boost::gregorian::date date = utc.date();
boost::posix_time::time_duration time = utc.time_of_day();
snprintf((char *) fi.create_time, sizeof( fi.create_time ), "%04d:%02d:%02d:%02d:%02d:%02d:%s",
static_cast<int>( date.year() ),
static_cast<int>( date.month() ),
static_cast<int>( date.day() ),
time.hours(),
time.minutes(),
time.seconds(),
"UTC"
);
snprintf((char *) fi.creator, sizeof( fi.creator ), "cortex");
snprintf((char *) fi.project, sizeof( fi.project ), "cortex");
snprintf((char *) fi.copyright, sizeof( fi.copyright ), "Unknown");
ii.orientation = 0; // left-to-right, top-to-bottom
ii.element_number = 1;
ii.pixels_per_line = displayWidth;
ii.lines_per_image_ele = displayHeight;
ii.element_number = asBigEndian<>(ii.element_number);
ii.pixels_per_line = asBigEndian<>(ii.pixels_per_line);
//.........这里部分代码省略.........
示例10: open
MStatus ImageFile::open( MString pathName, MImageFileInfo* info )
{
ImagePrimitivePtr image;
ImageReaderPtr reader;
try
{
reader = runTimeCast<ImageReader>( Reader::create( pathName.asChar() ) );
if (!reader)
{
return MS::kFailure;
}
image = runTimeCast< ImagePrimitive >( reader->read() );
if (!image)
{
return MS::kFailure;
}
if (!reader->isComplete())
{
return MS::kFailure;
}
}
catch ( std::exception &e )
{
return MS::kFailure;
}
m_width = image->getDataWindow().size().x + 1;
m_height = image->getDataWindow().size().y + 1;
std::vector<std::string> channelNames;
image->channelNames( channelNames );
if ( std::find( channelNames.begin(), channelNames.end(), "R" ) == channelNames.end()
|| std::find( channelNames.begin(), channelNames.end(), "G" ) == channelNames.end()
|| std::find( channelNames.begin(), channelNames.end(), "B" ) == channelNames.end() )
{
return MS::kFailure;
}
m_numChannels = 3;
if ( std::find( channelNames.begin(), channelNames.end(), "A" ) != channelNames.end() )
{
m_numChannels = 4;
}
assert( m_numChannels == 3 || m_numChannels == 4 );
try
{
ChannelConverter converter;
converter.m_pathName = pathName.asChar();
DataPtr rData = image->variables["R"].data;
if (! rData )
{
return MS::kFailure;
}
converter.m_channelName = "R";
m_rData = despatchTypedData<
ChannelConverter,
TypeTraits::IsNumericVectorTypedData,
ChannelConverter::ErrorHandler
>( rData.get(), converter );
DataPtr gData = image->variables["G"].data;
if (! gData )
{
return MS::kFailure;
}
converter.m_channelName = "G";
m_gData = despatchTypedData<
ChannelConverter,
TypeTraits::IsNumericVectorTypedData,
ChannelConverter::ErrorHandler
>( gData.get(), converter );
DataPtr bData = image->variables["B"].data;
if (! bData )
{
return MS::kFailure;
}
converter.m_channelName = "B";
m_bData = despatchTypedData<
ChannelConverter,
TypeTraits::IsNumericVectorTypedData,
ChannelConverter::ErrorHandler
>( bData.get(), converter );
if ( m_numChannels == 4 )
{
DataPtr aData = image->variables["A"].data;
if (! aData )
{
//.........这里部分代码省略.........