本文整理汇总了C++中FloatVectorDataPtr类的典型用法代码示例。如果您正苦于以下问题:C++ FloatVectorDataPtr类的具体用法?C++ FloatVectorDataPtr怎么用?C++ FloatVectorDataPtr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FloatVectorDataPtr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: assert
IECore::ConstFloatVectorDataPtr Shape::computeChannelData( const std::string &channelName, const Imath::V2i &tileOrigin, const Gaffer::Context *context, const ImagePlug *parent ) const
{
assert( parent == shapePlug() );
if( channelName == g_shapeChannelName )
{
// Private channel we use for caching the shape but don't advertise via channelNames.
return computeShapeChannelData( tileOrigin, context );
}
else
{
ConstFloatVectorDataPtr shape = parent->channelData( g_shapeChannelName, context->get<V2i>( ImagePlug::tileOriginContextName ) );
const float c = channelValue( parent, channelName );
if( c == 1 )
{
return shape;
}
else
{
FloatVectorDataPtr resultData = shape->copy();
vector<float> &result = resultData->writable();
for( vector<float>::iterator it = result.begin(), eIt = result.end(); it != eIt; ++it )
{
*it *= c;
}
return resultData;
}
}
}
示例2: formatPlug
IECore::ImagePrimitivePtr ImagePlug::image() const
{
Format format = formatPlug()->getValue();
Box2i dataWindow = dataWindowPlug()->getValue();
Box2i newDataWindow( Imath::V2i(0) );
if( dataWindow.isEmpty() )
{
dataWindow = Box2i( Imath::V2i(0) );
}
else
{
newDataWindow = format.yDownToFormatSpace( dataWindow );
}
ImagePrimitivePtr result = new ImagePrimitive( newDataWindow, format.getDisplayWindow() );
ConstStringVectorDataPtr channelNamesData = channelNamesPlug()->getValue();
const vector<string> &channelNames = channelNamesData->readable();
vector<float *> imageChannelData;
for( vector<string>::const_iterator it = channelNames.begin(), eIt = channelNames.end(); it!=eIt; it++ )
{
FloatVectorDataPtr cd = new FloatVectorData;
vector<float> &c = cd->writable();
c.resize( result->variableSize( PrimitiveVariable::Vertex ), 0.0f );
result->variables[*it] = PrimitiveVariable( PrimitiveVariable::Vertex, cd );
imageChannelData.push_back( &(c[0]) );
}
parallel_for( blocked_range2d<size_t>( 0, dataWindow.size().x+1, tileSize(), 0, dataWindow.size().y+1, tileSize() ),
GafferImage::Detail::CopyTiles( imageChannelData, channelNames, channelDataPlug(), dataWindow, Context::current(), tileSize()) );
return result;
}
示例3: IntVectorData
void FromHoudiniPolygonsConverter::convertCorners( MeshPrimitive *mesh ) const
{
// Houdini stores corners via a Point Attrib (which has been converted to a Vertex PrimitiveVariable)
const auto *cornerWeightData = mesh->variableData<FloatVectorData>( g_cornerWeightAttrib, PrimitiveVariable::Vertex );
if( !cornerWeightData )
{
return;
}
IntVectorDataPtr cornerIdsData = new IntVectorData();
auto &cornerIds = cornerIdsData->writable();
FloatVectorDataPtr cornerSharpnessesData = new FloatVectorData();
auto &cornerSharpnesses = cornerSharpnessesData->writable();
const auto &cornerWeights = cornerWeightData->readable();
for( size_t i = 0; i < cornerWeights.size(); ++i )
{
if( cornerWeights[i] > 0.0f )
{
cornerIds.push_back( i );
cornerSharpnesses.push_back( cornerWeights[i] );
}
}
if( !cornerIds.empty() )
{
mesh->setCorners( cornerIdsData.get(), cornerSharpnessesData.get() );
mesh->variables.erase( g_cornerWeightAttrib );
}
}
示例4: binding
IECore::ImagePrimitivePtr DepthTexture::imagePrimitive() const
{
ScopedBinding binding( *this );
GLint width = 0;
GLint height = 0;
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_WIDTH, &width );
glGetTexLevelParameteriv( GL_TEXTURE_2D, 0, GL_TEXTURE_HEIGHT, &height );
vector<float> data( width * height );
glGetTexImage( GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, GL_FLOAT, &data[0] );
FloatVectorDataPtr zd = new FloatVectorData();
vector<float> &z = zd->writable();
z.resize( width * height );
unsigned int i = 0;
for( int y=height-1; y>=0; y-- )
{
float *rz = &z[y*width];
for( int x=0; x<width; x++ )
{
rz[x] = data[i++];
}
}
Box2i imageExtents( V2i( 0, 0 ), V2i( width-1, height-1 ) );
ImagePrimitivePtr image = new ImagePrimitive( imageExtents, imageExtents );
image->variables["Z"] = PrimitiveVariable( PrimitiveVariable::Vertex, zd );
return image;
}
示例5: parseFloats
static IECore::FloatVectorDataPtr parseFloats( const std::string &value )
{
FloatVectorDataPtr result = new FloatVectorData;
string::const_iterator first = value.begin();
bool r = qi::phrase_parse(
first, value.end(),
/////////////////
qi::omit[ -qi::char_( '{' ) ] >>
(
qi::float_ % ','
) >>
qi::omit[ -qi::char_( '}' ) ]
,
/////////////////
ascii::space,
result->writable()
);
if( !r || first != value.end() )
{
return 0;
}
return result;
}
示例6: colorIndex
IECore::ConstFloatVectorDataPtr Constant::computeChannelData( const std::string &channelName, const Imath::V2i &tileOrigin, const Gaffer::Context *context, const ImagePlug *parent ) const
{
const int channelIndex = colorIndex( context->get<std::string>( ImagePlug::channelNameContextName ) );
const float value = colorPlug()->getChild( channelIndex )->getValue();
FloatVectorDataPtr result = new FloatVectorData;
result->writable().resize( ImagePlug::tileSize() * ImagePlug::tileSize(), value );
return result;
}
示例7: imageData
virtual void imageData( const Imath::Box2i &box, const float *data, size_t dataSize )
{
Box2i yUpBox = m_gafferFormat.yDownToFormatSpace( box );
const V2i boxMinTileOrigin = ImagePlug::tileOrigin( yUpBox.min );
const V2i boxMaxTileOrigin = ImagePlug::tileOrigin( yUpBox.max );
for( int tileOriginY = boxMinTileOrigin.y; tileOriginY <= boxMaxTileOrigin.y; tileOriginY += ImagePlug::tileSize() )
{
for( int tileOriginX = boxMinTileOrigin.x; tileOriginX <= boxMaxTileOrigin.x; tileOriginX += ImagePlug::tileSize() )
{
for( int channelIndex = 0, numChannels = channelNames().size(); channelIndex < numChannels; ++channelIndex )
{
const V2i tileOrigin( tileOriginX, tileOriginY );
ConstFloatVectorDataPtr tileData = getTile( tileOrigin, channelIndex );
if( !tileData )
{
// we've been sent data outside of the data window
continue;
}
// we must create a new object to hold the updated tile data,
// because the old one might well have been returned from
// computeChannelData and be being held in the cache.
FloatVectorDataPtr updatedTileData = tileData->copy();
vector<float> &updatedTile = updatedTileData->writable();
const Box2i tileBound( tileOrigin, tileOrigin + Imath::V2i( GafferImage::ImagePlug::tileSize() - 1 ) );
const Box2i transferBound = IECore::boxIntersection( tileBound, yUpBox );
for( int y = transferBound.min.y; y<=transferBound.max.y; ++y )
{
int srcY = m_gafferFormat.formatToYDownSpace( y );
size_t srcIndex = ( ( srcY - box.min.y ) * ( box.size().x + 1 ) * numChannels ) + ( transferBound.min.x - box.min.x ) + channelIndex;
size_t dstIndex = ( y - tileBound.min.y ) * ImagePlug::tileSize() + transferBound.min.x - tileBound.min.x;
const size_t srcEndIndex = srcIndex + transferBound.size().x * numChannels;
while( srcIndex <= srcEndIndex )
{
updatedTile[dstIndex] = data[srcIndex];
srcIndex += numChannels;
dstIndex++;
}
}
setTile( tileOrigin, channelIndex, updatedTileData );
}
}
}
dataReceivedSignal()( this, box );
}
示例8: processChannelData
void Grade::processChannelData( const Gaffer::Context *context, const ImagePlug *parent, const std::string &channel, FloatVectorDataPtr outData ) const
{
// Calculate the valid data window that we are to merge.
const int dataWidth = ImagePlug::tileSize()*ImagePlug::tileSize();
// Do some pre-processing.
float A, B, gamma;
bool whiteClamp, blackClamp;
{
GradeParametersScope s( context );
parameters( std::max( 0, ImageAlgo::colorIndex( channel ) ), A, B, gamma );
whiteClamp = whiteClampPlug()->getValue();
blackClamp = blackClampPlug()->getValue();
}
const float invGamma = 1. / gamma;
// Get some useful pointers.
float *outPtr = &(outData->writable()[0]);
const float *END = outPtr + dataWidth;
while (outPtr != END)
{
// Calculate the colour of the graded pixel.
float colour = *outPtr; // As the input has been copied to outData, grab the input colour from there.
const float c = A * colour + B;
colour = ( c >= 0.f && invGamma != 1.f ? (float)pow( c, invGamma ) : c );
// Clamp the white and blacks if necessary.
if ( blackClamp && colour < 0.f ) colour = 0.f;
if ( whiteClamp && colour > 1.f ) colour = 1.f;
// Write back the result.
*outPtr++ = colour;
}
}
示例9: processChannelData
void Unpremultiply::processChannelData( const Gaffer::Context *context, const ImagePlug *parent, const std::string &channel, FloatVectorDataPtr outData ) const
{
std::string alphaChannel = alphaChannelPlug()->getValue();
if ( channel == alphaChannel )
{
return;
}
ConstStringVectorDataPtr inChannelNamesPtr = inPlug()->channelNamesPlug()->getValue();
const std::vector<std::string> &inChannelNames = inChannelNamesPtr->readable();
if ( std::find( inChannelNames.begin(), inChannelNames.end(), alphaChannel ) == inChannelNames.end() )
{
std::ostringstream channelError;
channelError << "Channel '" << alphaChannel << "' does not exist";
throw( IECore::Exception( channelError.str() ) );
}
ContextPtr tmpContext = new Context( *context, Context::Borrowed );
tmpContext->set( ImagePlug::channelNameContextName, alphaChannel );
Context::Scope scopedContext( tmpContext.get() );
const std::vector<float> &a = inPlug()->channelDataPlug()->getValue()->readable();
std::vector<float> &out = outData->writable();
std::vector<float>::const_iterator aIt = a.begin();
for ( std::vector<float>::iterator outIt = out.begin(), outItEnd = out.end(); outIt != outItEnd; ++outIt, ++aIt )
{
if ( *aIt != 0.0f )
{
*outIt /= *aIt;
}
}
}
示例10: c
IECore::ConstFloatVectorDataPtr CopyChannels::computeChannelData( const std::string &channelName, const Imath::V2i &tileOrigin, const Gaffer::Context *context, const ImagePlug *parent ) const
{
ConstCompoundObjectPtr mapping;
{
ImagePlug::GlobalScope c( context );
mapping = mappingPlug()->getValue();
}
if( const IntData *i = mapping->member<const IntData>( channelName ) )
{
const ImagePlug *inputImage = inPlugs()->getChild<ImagePlug>( i->readable() );
const V2i tileOrigin = context->get<V2i>( ImagePlug::tileOriginContextName );
const Box2i tileBound( tileOrigin, tileOrigin + V2i( ImagePlug::tileSize() ) );
Box2i inputDataWindow;
{
ImagePlug::GlobalScope c( context );
inputDataWindow = inputImage->dataWindowPlug()->getValue();
}
const Box2i validBound = BufferAlgo::intersection( tileBound, inputDataWindow );
if( validBound == tileBound )
{
return inputImage->channelDataPlug()->getValue();
}
else
{
FloatVectorDataPtr resultData = new FloatVectorData;
vector<float> &result = resultData->writable();
result.resize( ImagePlug::tileSize() * ImagePlug::tileSize(), 0.0f );
if( !BufferAlgo::empty( validBound ) )
{
ConstFloatVectorDataPtr inputData = inputImage->channelDataPlug()->getValue();
copyRegion(
&inputData->readable().front(),
tileBound,
validBound,
&result.front(),
tileBound,
validBound.min
);
}
return resultData;
}
}
else
{
return ImagePlug::blackTile();
}
}
示例11: computeChannelData
IECore::ConstFloatVectorDataPtr Constant::computeChannelData( const std::string &channelName, const Imath::V2i &tileOrigin, const Gaffer::Context *context, const ImagePlug *parent ) const
{
FloatVectorDataPtr resultData = new FloatVectorData;
vector<float> &result = resultData->writable();
result.resize( ImagePlug::tileSize() * ImagePlug::tileSize() );
int idx = channelName == "R" ? 0 : channelName == "G" ? 1 : channelName == "B" ? 2 : 3;
const float v = colorPlug()->getValue()[idx];
float *ptr = &result[0];
for( int i = 0; i < ImagePlug::tileSize() * ImagePlug::tileSize(); i++ )
{
*ptr++ = v;
}
return resultData;
}
示例12: msg
void DisplayDriverServer::Session::handleReadDataParameters( const boost::system::error_code& error )
{
if (error)
{
msg( Msg::Error, "DisplayDriverServer::Session::handleReadDataParameters", error.message().c_str() );
m_socket.close();
return;
}
// sanity check: check DisplayDriver object
if (! m_displayDriver )
{
msg( Msg::Error, "DisplayDriverServer::Session::handleReadDataParameters", "No display drivers!" );
m_socket.close();
return;
}
// get imageData parameters
Box2iDataPtr box;
FloatVectorDataPtr data;
try
{
MemoryIndexedIOPtr io = new MemoryIndexedIO( m_buffer, IndexedIO::rootPath, IndexedIO::Exclusive | IndexedIO::Read );
box = staticPointerCast<Box2iData>( Object::load( io, "box" ) );
data = staticPointerCast<FloatVectorData>( Object::load( io, "data" ) );
// call imageData passing the data
m_displayDriver->imageData( box->readable(), &(data->readable()[0]), data->readable().size() );
// prepare for getting more imageData packages or a imageClose.
boost::asio::async_read( m_socket,
boost::asio::buffer( m_header.buffer(), m_header.headerLength),
boost::bind(
&DisplayDriverServer::Session::handleReadHeader, SessionPtr(this),
boost::asio::placeholders::error
)
);
}
catch( std::exception &e )
{
msg( Msg::Error, "DisplayDriverServer::Session::handleReadDataParameters", e.what() );
m_socket.close();
return;
}
}
示例13: formatPlug
IECore::ImagePrimitivePtr ImagePlug::image() const
{
Format format = formatPlug()->getValue();
Box2i dataWindow = dataWindowPlug()->getValue();
Box2i newDataWindow( Imath::V2i(0) );
if( dataWindow.isEmpty() )
{
dataWindow = Box2i( Imath::V2i(0) );
}
else
{
newDataWindow = format.yDownToFormatSpace( dataWindow );
}
// use the default format if we don't have an explicit one.
/// \todo: remove this once FormatPlug is handling it for
/// us during ExecutableNode::execute (see issue #887).
if( format.getDisplayWindow().isEmpty() )
{
format = Context::current()->get<Format>( Format::defaultFormatContextName, Format() );
}
ImagePrimitivePtr result = new ImagePrimitive( newDataWindow, format.getDisplayWindow() );
ConstCompoundObjectPtr metadata = metadataPlug()->getValue();
compoundObjectToCompoundData( metadata.get(), result->blindData() );
ConstStringVectorDataPtr channelNamesData = channelNamesPlug()->getValue();
const vector<string> &channelNames = channelNamesData->readable();
vector<float *> imageChannelData;
for( vector<string>::const_iterator it = channelNames.begin(), eIt = channelNames.end(); it!=eIt; it++ )
{
FloatVectorDataPtr cd = new FloatVectorData;
vector<float> &c = cd->writable();
c.resize( result->variableSize( PrimitiveVariable::Vertex ), 0.0f );
result->variables[*it] = PrimitiveVariable( PrimitiveVariable::Vertex, cd );
imageChannelData.push_back( &(c[0]) );
}
parallel_for( blocked_range3d<size_t>( 0, imageChannelData.size(), 1, 0, dataWindow.size().x+1, tileSize(), 0, dataWindow.size().y+1, tileSize() ),
GafferImage::Detail::CopyTiles( imageChannelData, channelNames, channelDataPlug(), dataWindow, Context::current(), tileSize()) );
return result;
}
示例14: shade
IECore::CompoundDataPtr IECoreRI::SXRendererImplementation::shadePlane( const V2i &resolution ) const
{
IECore::CompoundDataPtr points = new IECore::CompoundData();
V3fVectorDataPtr pData = new IECore::V3fVectorData();
V3fVectorDataPtr nData = new IECore::V3fVectorData();
FloatVectorDataPtr sData = new IECore::FloatVectorData();
FloatVectorDataPtr tData = new IECore::FloatVectorData();
std::vector<V3f> &p = pData->writable();
std::vector<V3f> &n = nData->writable();
std::vector<float> &s = sData->writable();
std::vector<float> &t = tData->writable();
unsigned numPoints = resolution[0] * resolution[1];
p.resize( numPoints );
n.resize( numPoints );
s.resize( numPoints );
t.resize( numPoints );
unsigned xResMinus1 = resolution[0] - 1;
unsigned yResMinus1 = resolution[1] - 1;
unsigned i = 0;
for( int y = 0; y < resolution[1]; y++ )
{
for( int x = 0; x < resolution[0]; x++ )
{
p[i] = V3f( float(x) / xResMinus1 , float(y) / yResMinus1, 0.0 );
s[i] = p[i][0];
t[i] = p[i][1];
n[i] = V3f( 0.0f, 0.0f, 1.0f );
i++;
}
}
points->writable()[ "P" ] = pData;
points->writable()[ "N" ] = nData;
points->writable()[ "s" ] = sData;
points->writable()[ "t" ] = tData;
return shade( points, resolution );
}
示例15: fileNamePlug
IECore::ConstFloatVectorDataPtr ImageReader::computeChannelData( const std::string &channelName, const Imath::V2i &tileOrigin, const Gaffer::Context *context, const ImagePlug *parent ) const
{
std::string fileName = fileNamePlug()->getValue();
ustring uFileName( fileName.c_str() );
const ImageSpec *spec = imageCache()->imagespec( uFileName );
vector<string>::const_iterator channelIt = find( spec->channelnames.begin(), spec->channelnames.end(), channelName );
if( channelIt == spec->channelnames.end() )
{
{
return parent->channelDataPlug()->defaultValue();
}
}
Format format( Imath::Box2i( Imath::V2i( spec->full_x, spec->full_y ), Imath::V2i( spec->full_width + spec->full_x - 1, spec->full_height + spec->full_y - 1 ) ) );
const int newY = format.formatToYDownSpace( tileOrigin.y + ImagePlug::tileSize() - 1 );
std::vector<float> channelData( ImagePlug::tileSize() * ImagePlug::tileSize() );
size_t channelIndex = channelIt - spec->channelnames.begin();
imageCache()->get_pixels(
uFileName,
0, 0, // subimage, miplevel
tileOrigin.x, tileOrigin.x + ImagePlug::tileSize(),
newY, newY + ImagePlug::tileSize(),
0, 1,
channelIndex, channelIndex + 1,
TypeDesc::FLOAT,
&(channelData[0])
);
// Create the output data buffer.
FloatVectorDataPtr resultData = new FloatVectorData;
vector<float> &result = resultData->writable();
result.resize( ImagePlug::tileSize() * ImagePlug::tileSize() );
// Flip the tile in the Y axis to convert it to our internal image data representation.
for( int y = 0; y < ImagePlug::tileSize(); ++y )
{
memcpy( &(result[ ( ImagePlug::tileSize() - y - 1 ) * ImagePlug::tileSize() ]), &(channelData[ y * ImagePlug::tileSize() ]), sizeof(float)*ImagePlug::tileSize() );
}
return resultData;
}