本文整理汇总了C++中Box3f::extendBy方法的典型用法代码示例。如果您正苦于以下问题:C++ Box3f::extendBy方法的具体用法?C++ Box3f::extendBy怎么用?C++ Box3f::extendBy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Box3f
的用法示例。
在下文中一共展示了Box3f::extendBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ReadParticles
//-*****************************************************************************
void ReadParticles( const std::string &iFileName )
{
IArchive archive( Alembic::AbcCoreOgawa::ReadArchive(),
iFileName );
IObject topObj( archive, kTop );
IPoints points( topObj, "simpleParticles" );
IPointsSchema& pointsSchema = points.getSchema();
index_t numSamps = pointsSchema.getNumSamples();
std::cout << "\n\nReading points back in. Num frames: "
<< numSamps << std::endl;
IV3fArrayProperty velProp( pointsSchema, "velocity" );
IC3fArrayProperty rgbProp( pointsSchema, "Cs" );
IFloatArrayProperty ageProp( pointsSchema, "age" );
for ( index_t samp = 0; samp < numSamps; ++samp )
{
IPointsSchema::Sample psamp;
pointsSchema.get( psamp, samp );
Box3f bounds;
bounds.makeEmpty();
size_t numPoints = psamp.getPositions()->size();
for ( size_t p = 0; p < numPoints; ++p )
{
bounds.extendBy( (*(psamp.getPositions()))[p] );
}
std::cout << "Sample: " << samp << ", numPoints: " << numPoints
<< ", bounds: " << bounds.min
<< " to " << bounds.max << std::endl;
}
}
示例2: scopedContext
Imath::Box3f SceneNode::unionOfTransformedChildBounds( const ScenePath &path, const ScenePlug *out, const IECore::InternedStringVectorData *childNamesData ) const
{
ConstInternedStringVectorDataPtr computedChildNames;
if( !childNamesData )
{
computedChildNames = out->childNames( path );
childNamesData = computedChildNames.get();
}
const vector<InternedString> &childNames = childNamesData->readable();
Box3f result;
if( childNames.size() )
{
ContextPtr tmpContext = new Context( *Context::current(), Context::Borrowed );
Context::Scope scopedContext( tmpContext.get() );
ScenePath childPath( path );
childPath.push_back( InternedString() ); // room for the child name
for( vector<InternedString>::const_iterator it = childNames.begin(); it != childNames.end(); it++ )
{
childPath[path.size()] = *it;
tmpContext->set( ScenePlug::scenePathContextName, childPath );
Box3f childBound = out->boundPlug()->getValue();
childBound = transform( childBound, out->transformPlug()->getValue() );
result.extendBy( childBound );
}
}
return result;
}
示例3: frame
void BackdropNodeGadget::frame( const std::vector<Gaffer::Node *> &nodes )
{
GraphGadget *graph = ancestor<GraphGadget>();
if( !graph )
{
return;
}
Box3f b;
for( std::vector<Node *>::const_iterator it = nodes.begin(), eIt = nodes.end(); it != eIt; ++it )
{
NodeGadget *nodeGadget = graph->nodeGadget( *it );
if( nodeGadget )
{
b.extendBy( nodeGadget->transformedBound( NULL ) );
}
}
if( b.isEmpty() )
{
return;
}
graph->setNodePosition( node(), V2f( b.center().x, b.center().y ) );
V2f s( b.size().x / 2.0f, b.size().y / 2.0f );
boundPlug()->setValue(
Box2f(
V2f( -s ) - V2f( g_margin ),
V2f( s ) + V2f( g_margin + 2.0f * g_margin )
)
);
}
示例4: scopedContext
Imath::Box3f Instancer::computeBranchBound( const ScenePath &parentPath, const ScenePath &branchPath, const Gaffer::Context *context ) const
{
ContextPtr ic = instanceContext( context, branchPath );
if( ic )
{
Context::Scope scopedContext( ic );
return instancePlug()->boundPlug()->getValue();
}
// branchPath == "/"
Box3f result;
ConstV3fVectorDataPtr p = sourcePoints( parentPath );
if( p )
{
ScenePath branchChildPath( branchPath );
branchChildPath.push_back( InternedString() ); // where we'll place the instance index
for( size_t i=0; i<p->readable().size(); i++ )
{
/// \todo We could have a very fast InternedString( int ) constructor rather than all this lexical cast nonsense
branchChildPath[branchChildPath.size()-1] = boost::lexical_cast<string>( i );
Box3f branchChildBound = computeBranchBound( parentPath, branchChildPath, context );
branchChildBound = transform( branchChildBound, computeBranchTransform( parentPath, branchChildPath, context ) );
result.extendBy( branchChildBound );
}
}
return result;
}
示例5: namePlug
Imath::Box3f Group::computeBound( const ScenePath &path, const Gaffer::Context *context, const ScenePlug *parent ) const
{
std::string groupName = namePlug()->getValue();
if( path.size() <= 1 )
{
// either / or /groupName
Box3f combinedBound;
for( ScenePlugIterator it( inPlugs() ); it != it.end(); ++it )
{
// we don't need to transform these bounds, because the SceneNode
// guarantees that the transform for root nodes is always identity.
Box3f bound = (*it)->bound( ScenePath() );
combinedBound.extendBy( bound );
}
if( path.size() == 0 )
{
combinedBound = transform( combinedBound, transformPlug()->matrix() );
}
return combinedBound;
}
else
{
const ScenePlug *sourcePlug = 0;
ScenePath source = sourcePath( path, groupName, &sourcePlug );
return sourcePlug->bound( source );
}
}
示例6: scopedTimeContext
Imath::Box3f SceneProcedural::bound() const
{
/// \todo I think we should be able to remove this exception handling in the future.
/// Either when we do better error handling in ValuePlug computations, or when
/// the bug in IECoreGL that caused the crashes in SceneProceduralTest.testComputationErrors
/// is fixed.
try
{
ContextPtr timeContext = new Context( *m_context );
Context::Scope scopedTimeContext( timeContext );
/// \todo This doesn't take account of the unfortunate fact that our children may have differing
/// numbers of segments than ourselves. To get an accurate bound we would need to know the different sample
/// times the children may be using and evaluate a bound at those times as well. We don't want to visit
/// the children to find the sample times out though, because that defeats the entire point of deferred loading.
///
/// Here are some possible approaches :
///
/// 1) Add a new attribute called boundSegments, which defines the number of segments used to calculate
/// the bounding box. It would be the responsibility of the user to set this to an appropriate value
/// at the parent levels, so that the parents calculate bounds appropriate for the children.
/// This seems like a bit too much burden on the user.
///
/// 2) Add a global option called "maxSegments" - this will clamp the number of segments used on anything
/// and will be set to 1 by default. The user will need to increase it to allow the leaf level attributes
/// to take effect, and all bounding boxes everywhere will be calculated using that number of segments
/// (actually I think it'll be that number of segments and all nondivisible smaller numbers). This should
/// be accurate but potentially slower, because we'll be doing the extra work everywhere rather than only
/// where needed. It still places a burden on the user (increasing the global clamp appropriately),
/// but not quite such a bad one as they don't have to figure anything out and only have one number to set.
///
/// 3) Have the StandardOptions node secretly compute a global "maxSegments" behind the scenes. This would
/// work as for 2) but remove the burden from the user. However, it would mean preventing any expressions
/// or connections being used on the segments attributes, because they could be used to cheat the system.
/// It could potentially be faster than 2) because it wouldn't have to do all nondivisible numbers - it
/// could know exactly which numbers of segments were in existence. It still suffers from the
/// "pay the price everywhere" problem.
std::set<float> times;
motionTimes( ( m_options.deformationBlur && m_attributes.deformationBlur ) ? m_attributes.deformationBlurSegments : 0, times );
motionTimes( ( m_options.transformBlur && m_attributes.transformBlur ) ? m_attributes.transformBlurSegments : 0, times );
Box3f result;
for( std::set<float>::const_iterator it = times.begin(), eIt = times.end(); it != eIt; it++ )
{
timeContext->setFrame( *it );
Box3f b = m_scenePlug->boundPlug()->getValue();
M44f t = m_scenePlug->transformPlug()->getValue();
result.extendBy( transform( b, t ) );
}
return result;
}
catch( const std::exception &e )
{
IECore::msg( IECore::Msg::Error, "SceneProcedural::bound()", e.what() );
}
return Box3f();
}
示例7: rr
static Box3fDataPtr bound3( const P *pData, const R *rData, float rMult, typename V::ConstPtr vData, float vMult )
{
typedef typename P::ValueType::value_type Point;
typedef typename V::ValueType::value_type Vector;
typedef typename R::ValueType::value_type Radius;
Box3f result;
const typename P::ValueType &pVector = pData->readable();
size_t vLength = 0;
const Vector *v = 0;
if( vData && vData->readable().size() )
{
vLength = vData->readable().size();
v = &(vData->readable()[0]);
}
size_t rLength = 0;
const Radius *r = 0;
if( rData && rData->readable().size() )
{
rLength = rData->readable().size();
r = &(rData->readable()[0]);
}
size_t i = 0;
for( typename P::ValueType::const_iterator pIt = pVector.begin(); pIt!=pVector.end(); pIt++ )
{
Box3f b;
b.extendBy( *pIt );
if( v && i<vLength )
{
b.extendBy( *pIt + v[i] * vMult );
}
if( r && i<rLength )
{
Point rr( r[i] * rMult );
b.min -= rr;
b.max += rr;
}
result.extendBy( b );
i++;
}
return new Box3fData( result );
}
示例8:
Imath::Box3f StandardConnectionGadget::bound() const
{
const_cast<StandardConnectionGadget *>( this )->setPositionsFromNodules();
Box3f r;
r.extendBy( m_srcPos );
r.extendBy( m_dstPos );
return r;
}
示例9: buildWalk
void SimpleSubsurface::buildWalk( Tree::NodeIndex nodeIndex )
{
const Tree::Node &node = m_privateData->tree.node( nodeIndex );
if( node.isLeaf() )
{
float totalWeight = 0;
Color3f nodeColor( 0 );
V3f centroid( 0 );
Box3f bound;
vector<V3f>::const_iterator pointsBegin = m_privateData->points->readable().begin();
for( Tree::Iterator *p = node.permFirst(); p!=node.permLast(); p++ )
{
const Color3f &c = m_privateData->colors->readable()[*p - pointsBegin];
float weight = luminance( c );
nodeColor += c;
centroid += **p * weight;
totalWeight += weight;
bound.extendBy( **p );
}
m_privateData->nodeCentroids[nodeIndex] = centroid / ( totalWeight > 0.0f ? totalWeight : 1.0f );
m_privateData->nodeColors[nodeIndex] = nodeColor;
m_privateData->nodeBounds[nodeIndex] = bound;
}
else
{
Tree::NodeIndex lowIndex = m_privateData->tree.lowChildIndex( nodeIndex );
Tree::NodeIndex highIndex = m_privateData->tree.highChildIndex( nodeIndex );
buildWalk( lowIndex );
buildWalk( highIndex );
Box3f bound;
bound.extendBy( m_privateData->nodeBounds[lowIndex] );
bound.extendBy( m_privateData->nodeBounds[highIndex] );
m_privateData->nodeBounds[nodeIndex] = bound;
float wLow = luminance( m_privateData->nodeColors[lowIndex] );
float wHigh = luminance( m_privateData->nodeColors[highIndex] );
float wSum = wLow + wHigh;
m_privateData->nodeCentroids[nodeIndex] = ( wLow * m_privateData->nodeCentroids[lowIndex] + wHigh * m_privateData->nodeCentroids[highIndex] ) / ( wSum > 0.0f ? wSum : 1.0f );
m_privateData->nodeColors[nodeIndex] = m_privateData->nodeColors[lowIndex] + m_privateData->nodeColors[highIndex];
}
}
示例10: transform
Imath::Box3f Group::bound() const
{
Box3f result;
for( ChildContainer::const_iterator it=children().begin(); it!=children().end(); it++ )
{
result.extendBy( (*it)->bound() );
}
return transform( result, m_transform );
}
示例11: AiNode
void IECoreArnold::RendererImplementation::procedural( IECore::Renderer::ProceduralPtr proc )
{
Box3f bound = proc->bound();
if( bound.isEmpty() )
{
return;
}
AtNode *procedural = AiNode( "procedural" );
if( ExternalProcedural *externalProc = dynamic_cast<ExternalProcedural *>( proc.get() ) )
{
AiNodeSetStr( procedural, "dso", externalProc->fileName().c_str() );
ParameterAlgo::setParameters( procedural, externalProc->parameters() );
applyTransformToNode( procedural );
}
else
{
// we have to transform the bound, as we're not applying the current transform to the
// procedural node, but instead applying absolute transforms to the shapes the procedural
// generates.
if( bound != Procedural::noBound )
{
Box3f transformedBound;
for( size_t i = 0, e = m_transformStack.numSamples(); i < e; ++i )
{
transformedBound.extendBy( transform( bound, m_transformStack.sample( i ) ) );
}
bound = transformedBound;
}
AiNodeSetPtr( procedural, "funcptr", (void *)procLoader );
ProceduralData *data = new ProceduralData;
data->procedural = proc;
data->renderer = new IECoreArnold::Renderer( new RendererImplementation( *this ) );
AiNodeSetPtr( procedural, "userptr", data );
}
if( bound != Procedural::noBound )
{
AiNodeSetPnt( procedural, "min", bound.min.x, bound.min.y, bound.min.z );
AiNodeSetPnt( procedural, "max", bound.max.x, bound.max.y, bound.max.z );
}
else
{
// No bound available - expand procedural immediately.
AiNodeSetBool( procedural, "load_at_init", true );
}
// we call addNode() rather than addShape() as we don't want to apply transforms and
// shaders and attributes to procedurals. if we do, they override the things we set
// on the nodes generated by the procedurals, which is frankly useless.
addNode( procedural );
}
示例12: run
void run() {
PackageManagerPtr myPackageManager( new PackageManager );
ScenePtr myScene = Scene::createStubs(myPackageManager);
dom::NodePtr myMaterial = createColorMaterial(myScene, Vector4f(0.8f,0.8f,0.6f,1.0f));
Box3f myVoxelBox;
myVoxelBox.makeEmpty();
myVoxelBox.extendBy( Point3f(0.0f, 0.0f, 0.0f));
//myVoxelBox.extendBy( Point3f(10.0, 20.0, 30.0f)); // 10x20x30 voxels
myVoxelBox.extendBy( Point3f(1.0f, 1.0f, 1.0f)); // 1x2x4 voxels
Vector3i myVolumeSize(10, 10, 10);
Matrix4f myModelMatrix;
Matrix4f myCameraMatrix;
float mySampleRate = 1.0f;
VectorOfVector3f myReference;
VectorOfVector3f myCandidate;
myModelMatrix.makeIdentity();
myCameraMatrix.makeIdentity();
dom::NodePtr myShape = createVoxelProxyGeometry(myScene, myVoxelBox,
myModelMatrix, myCameraMatrix, myVolumeSize, mySampleRate,
myMaterial->getAttributeString(ID_ATTRIB), "VoxelProxy");
ENSURE(extractPositions(myShape, myReference));
myCameraMatrix.makeXRotating( static_cast<float>(asl::PI/2) );
myShape = createVoxelProxyGeometry(myScene, myVoxelBox, myModelMatrix, myCameraMatrix,
myVolumeSize, mySampleRate, myMaterial->getAttributeString(ID_ATTRIB),
"VoxelProxy");
ENSURE(extractPositions(myShape, myCandidate));
//ENSURE(positionsEqual(myCandidate, myReference, myCameraMatrixf));
//myModelViewMatrix.rotateY(asl::PI * 0.125);
//DPRINT( * myShape );
//dom::NodePtr myBody = createBody(myScene->getWorldRoot(), myShape->getAttributeString(ID_ATTRIBf));
//myScene->save("proxy.x60", false);
}
示例13: computeBounds
Imath::Box3f computeBounds(const float* vertices, size_t numVertices)
{
using namespace Imath;
Box3f bounds;
bounds.makeEmpty();
V3f vertex;
for(size_t v=0; v < numVertices; ++v)
{
vertex.x = vertices[3 * v + 0];
vertex.y = vertices[3 * v + 1];
vertex.z = vertices[3 * v + 2];
bounds.extendBy(vertex);
}
return bounds;
}
示例14: selectionBound
Box3f selectionBound() const
{
if( m_selected )
{
return m_bound;
}
else
{
Box3f childSelectionBound;
for( std::vector<SceneGraph *>::const_iterator it = m_children.begin(), eIt = m_children.end(); it != eIt; ++it )
{
const Box3f childBound = transform( (*it)->selectionBound(), (*it)->m_transform );
childSelectionBound.extendBy( childBound );
}
return childSelectionBound;
}
}
示例15:
Imath::Box3f Gadget::bound() const
{
Box3f result;
for( ChildContainer::const_iterator it=children().begin(); it!=children().end(); it++ )
{
// cast is safe because of the guarantees acceptsChild() gives us
const Gadget *c = static_cast<const Gadget *>( it->get() );
if( !c->getVisible() )
{
continue;
}
Imath::Box3f b = c->bound();
b = Imath::transform( b, c->getTransform() );
result.extendBy( b );
}
return result;
}