本文整理汇总了C++中UT_Interrupt::opInterrupt方法的典型用法代码示例。如果您正苦于以下问题:C++ UT_Interrupt::opInterrupt方法的具体用法?C++ UT_Interrupt::opInterrupt怎么用?C++ UT_Interrupt::opInterrupt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UT_Interrupt
的用法示例。
在下文中一共展示了UT_Interrupt::opInterrupt方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: cookMySop
OP_ERROR SOP_SceneCacheSource::cookMySop( OP_Context &context )
{
// make sure the state is valid
if ( boost::indeterminate( m_static ) )
{
sceneChanged();
}
flags().setTimeDep( bool( !m_static ) );
std::string file;
if ( !ensureFile( file ) )
{
addError( SOP_ATTRIBUTE_INVALID, ( file + " is not a valid .scc" ).c_str() );
gdp->clearAndDestroy();
return error();
}
std::string path = getPath();
Space space = getSpace();
GeometryType geometryType = (GeometryType)this->evalInt( pGeometryType.getToken(), 0, 0 );
UT_String shapeFilterStr;
evalString( shapeFilterStr, pShapeFilter.getToken(), 0, 0 );
UT_StringMMPattern shapeFilter;
shapeFilter.compile( shapeFilterStr );
UT_String p( "P" );
UT_String attributeFilter;
evalString( attributeFilter, pAttributeFilter.getToken(), 0, 0 );
if ( !p.match( attributeFilter ) )
{
attributeFilter += " P";
}
ConstSceneInterfacePtr scene = this->scene( file, path );
if ( !scene )
{
addError( SOP_ATTRIBUTE_INVALID, ( path + " is not a valid location in " + file ).c_str() );
gdp->clearAndDestroy();
return error();
}
MurmurHash hash;
hash.append( file );
hash.append( path );
hash.append( space );
hash.append( shapeFilterStr );
hash.append( attributeFilter );
hash.append( geometryType );
hash.append( getObjectOnly() );
if ( !m_loaded || m_hash != hash )
{
gdp->clearAndDestroy();
}
Imath::M44d transform = ( space == World ) ? worldTransform( file, path, context.getTime() ) : Imath::M44d();
SceneInterface::Path rootPath;
scene->path( rootPath );
UT_Interrupt *progress = UTgetInterrupt();
if ( !progress->opStart( ( "Cooking objects for " + getPath() ).c_str() ) )
{
addError( SOP_ATTRIBUTE_INVALID, "Cooking interrupted before it started" );
gdp->clearAndDestroy();
return error();
}
loadObjects( scene, transform, context.getTime(), space, shapeFilter, attributeFilter.toStdString(), geometryType, rootPath.size() );
if ( progress->opInterrupt( 100 ) )
{
addError( SOP_ATTRIBUTE_INVALID, "Cooking interrupted" );
gdp->clearAndDestroy();
m_loaded = false;
m_hash = MurmurHash();
}
else
{
m_loaded = true;
m_hash = hash;
}
progress->opEnd();
return error();
}
示例2: loadObjects
void SOP_SceneCacheSource::loadObjects( const IECore::SceneInterface *scene, Imath::M44d transform, double time, Space space, const UT_StringMMPattern &shapeFilter, const std::string &attributeFilter, GeometryType geometryType, size_t rootSize )
{
UT_Interrupt *progress = UTgetInterrupt();
progress->setLongOpText( ( "Loading " + scene->name().string() ).c_str() );
if ( progress->opInterrupt() )
{
return;
}
if ( scene->hasObject() && UT_String( scene->name() ).multiMatch( shapeFilter ) )
{
// \todo See if there are ways to avoid the Object copy below.
ObjectPtr object = scene->readObject( time )->copy();
std::string name = relativePath( scene, rootSize );
bool hasAnimatedTopology = scene->hasAttribute( SceneCache::animatedObjectTopologyAttribute );
bool hasAnimatedPrimVars = scene->hasAttribute( SceneCache::animatedObjectPrimVarsAttribute );
std::vector<InternedString> animatedPrimVars;
if ( hasAnimatedPrimVars )
{
const ConstObjectPtr animatedPrimVarObj = scene->readAttribute( SceneCache::animatedObjectPrimVarsAttribute, 0 );
const InternedStringVectorData *animatedPrimVarData = IECore::runTimeCast<const InternedStringVectorData>( animatedPrimVarObj );
if ( animatedPrimVarData )
{
const std::vector<InternedString> &values = animatedPrimVarData->readable();
animatedPrimVars.resize( values.size() );
std::copy( values.begin(), values.end(), animatedPrimVars.begin() );
}
}
modifyObject( object, name, attributeFilter, hasAnimatedTopology, hasAnimatedPrimVars, animatedPrimVars );
Imath::M44d currentTransform;
if ( space == Local )
{
currentTransform = scene->readTransformAsMatrix( time );
}
else if ( space != Object )
{
currentTransform = transform;
}
// transform the object unless its an identity
if ( currentTransform != Imath::M44d() )
{
transformObject( object, currentTransform, hasAnimatedTopology, hasAnimatedPrimVars, animatedPrimVars );
}
// load the Cortex object directly
if ( geometryType == Cortex )
{
holdObject( object, name, hasAnimatedTopology, hasAnimatedPrimVars, animatedPrimVars );
}
else
{
// convert the object to Houdini
if ( !convertObject( object, name, attributeFilter, geometryType, hasAnimatedTopology, hasAnimatedPrimVars, animatedPrimVars ) )
{
std::string fullName;
SceneInterface::Path path;
scene->path( path );
SceneInterface::pathToString( path, fullName );
addWarning( SOP_MESSAGE, ( "Could not convert " + fullName + " to houdini" ).c_str() );
}
}
}
if ( evalInt( pObjectOnly.getToken(), 0, 0 ) )
{
return;
}
SceneInterface::NameList children;
scene->childNames( children );
for ( SceneInterface::NameList::const_iterator it=children.begin(); it != children.end(); ++it )
{
ConstSceneInterfacePtr child = scene->child( *it );
loadObjects( child, child->readTransformAsMatrix( time ) * transform, time, space, shapeFilter, attributeFilter, geometryType, rootSize );
}
}
示例3: loadObjects
void SOP_SceneCacheSource::loadObjects( const IECore::SceneInterface *scene, Imath::M44d transform, double time, Space space, Parameters ¶ms, size_t rootSize )
{
UT_Interrupt *progress = UTgetInterrupt();
progress->setLongOpText( ( "Loading " + scene->name().string() ).c_str() );
if ( progress->opInterrupt() )
{
return;
}
if ( scene->hasObject() && UT_String( scene->name() ).multiMatch( params.shapeFilter ) && tagged( scene, params.tagFilter ) )
{
std::string name = relativePath( scene, rootSize );
Imath::M44d currentTransform;
if ( space == Local )
{
currentTransform = scene->readTransformAsMatrix( time );
}
else if ( space != Object )
{
currentTransform = transform;
}
ConstObjectPtr object = 0;
if ( params.geometryType == BoundingBox )
{
Imath::Box3d bound = scene->readBound( time );
object = MeshPrimitive::createBox( Imath::Box3f( bound.min, bound.max ) );
params.hasAnimatedTopology = false;
params.hasAnimatedPrimVars = true;
params.animatedPrimVars.clear();
params.animatedPrimVars.push_back( "P" );
}
else if ( params.geometryType == PointCloud )
{
std::vector<Imath::V3f> point( 1, scene->readBound( time ).center() );
PointsPrimitivePtr points = new PointsPrimitive( new V3fVectorData( point ) );
std::vector<Imath::V3f> basis1( 1, Imath::V3f( currentTransform[0][0], currentTransform[0][1], currentTransform[0][2] ) );
std::vector<Imath::V3f> basis2( 1, Imath::V3f( currentTransform[1][0], currentTransform[1][1], currentTransform[1][2] ) );
std::vector<Imath::V3f> basis3( 1, Imath::V3f( currentTransform[2][0], currentTransform[2][1], currentTransform[2][2] ) );
points->variables["basis1"] = PrimitiveVariable( PrimitiveVariable::Vertex, new V3fVectorData( basis1 ) );
points->variables["basis2"] = PrimitiveVariable( PrimitiveVariable::Vertex, new V3fVectorData( basis2 ) );
points->variables["basis3"] = PrimitiveVariable( PrimitiveVariable::Vertex, new V3fVectorData( basis3 ) );
params.hasAnimatedTopology = false;
params.hasAnimatedPrimVars = true;
params.animatedPrimVars.clear();
params.animatedPrimVars.push_back( "P" );
params.animatedPrimVars.push_back( "basis1" );
params.animatedPrimVars.push_back( "basis2" );
params.animatedPrimVars.push_back( "basis3" );
object = points;
}
else
{
object = scene->readObject( time );
params.hasAnimatedTopology = scene->hasAttribute( SceneCache::animatedObjectTopologyAttribute );
params.hasAnimatedPrimVars = scene->hasAttribute( SceneCache::animatedObjectPrimVarsAttribute );
if ( params.hasAnimatedPrimVars )
{
const ConstObjectPtr animatedPrimVarObj = scene->readAttribute( SceneCache::animatedObjectPrimVarsAttribute, 0 );
const InternedStringVectorData *animatedPrimVarData = IECore::runTimeCast<const InternedStringVectorData>( animatedPrimVarObj.get() );
if ( animatedPrimVarData )
{
const std::vector<InternedString> &values = animatedPrimVarData->readable();
params.animatedPrimVars.clear();
params.animatedPrimVars.resize( values.size() );
std::copy( values.begin(), values.end(), params.animatedPrimVars.begin() );
}
}
}
// modify the object if necessary
object = modifyObject( object.get(), params );
// transform the object unless its an identity
if ( currentTransform != Imath::M44d() )
{
object = transformObject( object.get(), currentTransform, params );
}
// convert the object to Houdini
if ( !convertObject( object.get(), name, scene, params ) )
{
std::string fullName;
SceneInterface::Path path;
scene->path( path );
SceneInterface::pathToString( path, fullName );
addWarning( SOP_MESSAGE, ( "Could not convert " + fullName + " to Houdini" ).c_str() );
}
}
if ( evalInt( pObjectOnly.getToken(), 0, 0 ) )
{
return;
}
//.........这里部分代码省略.........
示例4: cookMySop
//.........这里部分代码省略.........
{
addError( SOP_ATTRIBUTE_INVALID, ( path + " is not a valid location in " + file ).c_str() );
gdp->clearAndDestroy();
return error();
}
MurmurHash hash;
hash.append( file );
hash.append( path );
hash.append( space );
hash.append( tagFilterStr );
hash.append( shapeFilterStr );
hash.append( attributeFilter );
hash.append( attributeCopy );
hash.append( fullPathName );
hash.append( geometryType );
hash.append( getObjectOnly() );
if ( !m_loaded || m_hash != hash )
{
gdp->clearAndDestroy();
}
double readTime = time( context );
Imath::M44d transform = ( space == World ) ? worldTransform( file, path, readTime ) : Imath::M44d();
SceneInterface::Path rootPath;
scene->path( rootPath );
UT_Interrupt *progress = UTgetInterrupt();
if ( !progress->opStart( ( "Cooking objects for " + getPath() ).c_str() ) )
{
addError( SOP_ATTRIBUTE_INVALID, "Cooking interrupted before it started" );
gdp->clearAndDestroy();
return error();
}
Parameters params;
UT_String attribFilter;
getAttributeFilter( attribFilter );
params.attributeFilter = attribFilter.toStdString();
params.attributeCopy = attributeCopy.toStdString();
params.fullPathName = fullPathName.toStdString();
params.geometryType = getGeometryType();
getShapeFilter( params.shapeFilter );
getTagFilter( params.tagFilter );
// Building a map from shape name to primitive range, which will be used during
// convertObject() to do a lazy update of animated primvars where possible, and
// to destroy changing topology shapes when necessary.
GA_ROAttributeRef nameAttrRef = gdp->findStringTuple( GA_ATTRIB_PRIMITIVE, "name" );
if ( nameAttrRef.isValid() )
{
const GA_Attribute *attr = nameAttrRef.getAttribute();
const GA_AIFSharedStringTuple *tuple = attr->getAIFSharedStringTuple();
std::map<std::string, GA_OffsetList> offsets;
GA_Range primRange = gdp->getPrimitiveRange();
for ( GA_Iterator it = primRange.begin(); !it.atEnd(); ++it )
{
std::string current = "";
if ( const char *value = tuple->getString( attr, it.getOffset() ) )
{
current = value;
}
std::map<std::string, GA_OffsetList>::iterator oIt = offsets.find( current );
if ( oIt == offsets.end() )
{
oIt = offsets.insert( std::pair<std::string, GA_OffsetList>( current, GA_OffsetList() ) ).first;
}
oIt->second.append( it.getOffset() );
}
for ( std::map<std::string, GA_OffsetList>::iterator oIt = offsets.begin(); oIt != offsets.end(); ++oIt )
{
params.namedRanges[oIt->first] = GA_Range( gdp->getPrimitiveMap(), oIt->second );
}
}
loadObjects( scene.get(), transform, readTime, space, params, rootPath.size() );
if ( progress->opInterrupt( 100 ) )
{
addError( SOP_ATTRIBUTE_INVALID, "Cooking interrupted" );
gdp->clearAndDestroy();
m_loaded = false;
m_hash = MurmurHash();
}
else
{
m_loaded = true;
m_hash = hash;
}
progress->opEnd();
return error();
}
示例5: cookMySop
//.........这里部分代码省略.........
// what percentage of points should we load?
float load_probability = loadPercentage/100.f;
// load points into memory
float point[3], normal[3];
float radius;
float data[ptc_gdp->datasize];
srand(0);
for ( unsigned int i=0; i<ptc_gdp->nPoints; ++i )
{
PtcReadDataPoint( ptc, point, normal, &radius, data );
// bound on load
if ( boundOnLoad )
{
UT_Vector3 pt( point[0], point[1], point[2] );
if ( !mBBox.isInside(pt) )
continue;
}
// discard a percentage of our points
if ( rand()/(float)RAND_MAX>load_probability )
continue;
// put points into our cache
cachePoints.push_back( point );
cacheNormals.push_back( normal );
cacheRadius.push_back( radius );
for ( unsigned int j=0; j<ptc_gdp->datasize; ++j )
cacheData.push_back( data[j] );
// break for the interrupt handler (i.e. press ESC)
if ( boss->opInterrupt() )
break;
}
ptc_gdp->nLoaded = cachePoints.size();
// mark our detail as valid and close our ptc
PtcClosePointCloudFile( ptc );
mReload = false;
// force update on channel parameter
getParm("chan").revertToDefaults(now);
}
// build a new primitive
GU_PrimParticle::build( ptc_gdp, cachePoints.size(), 0 );
// create our output geometry using the output % parameter
// this is the same variable as GR_ uses to preview
std::vector<UT_Vector3>::const_iterator pos_it = cachePoints.begin();
std::vector<UT_Vector3>::const_iterator norm_it = cacheNormals.begin();
std::vector<float>::const_iterator rad_it = cacheRadius.begin();
std::vector<float>::const_iterator data_it = cacheData.begin();
// add some standard attributes
GB_AttributeRef n_attrib = ptc_gdp->addPointAttrib( "N", sizeof(UT_Vector3),
GB_ATTRIB_VECTOR, 0 );
GB_AttributeRef r_attrib = ptc_gdp->addPointAttrib( "radius", sizeof(float),
GB_ATTRIB_FLOAT, 0 );
ptc_gdp->N_attrib = n_attrib;
ptc_gdp->R_attrib = r_attrib;
// process the rest of our data attributes
std::vector<GB_AttribType> data_types;
示例6: doExpandChildren
void OBJ_SceneCacheTransform::doExpandChildren( const SceneInterface *scene, OP_Network *parent, const Parameters ¶ms )
{
UT_Interrupt *progress = UTgetInterrupt();
progress->setLongOpText( ( "Expanding " + scene->name().string() ).c_str() );
if ( progress->opInterrupt() )
{
return;
}
OP_Network *inputNode = parent;
if ( params.hierarchy == Parenting )
{
parent = parent->getParent();
}
SceneInterface::NameList children;
scene->childNames( children );
for ( SceneInterface::NameList::const_iterator it=children.begin(); it != children.end(); ++it )
{
ConstSceneInterfacePtr child = scene->child( *it );
OBJ_Node *childNode = 0;
if ( params.hierarchy == SubNetworks )
{
childNode = doExpandChild( child.get(), parent, params );
if ( params.depth == AllDescendants && child->hasObject() && tagged( child.get(), params.tagFilter ) )
{
Parameters childParams( params );
childParams.depth = Children;
doExpandObject( child.get(), childNode, childParams );
}
}
else if ( params.hierarchy == Parenting )
{
if ( child->hasObject() )
{
Parameters childParams( params );
childParams.depth = Children;
childNode = doExpandObject( child.get(), parent, childParams );
}
else
{
childNode = doExpandChild( child.get(), parent, params );
}
childNode->setInput( 0, inputNode );
}
if ( params.depth == AllDescendants )
{
if ( params.hierarchy == SubNetworks && !tagged( child.get(), params.tagFilter ) )
{
// we don't expand non-tagged children for SubNetwork mode, but we
// do for Parenting mode, because otherwise the hierarchy would be
// stuck in an un-expandable state.
continue;
}
doExpandChildren( child.get(), childNode, params );
childNode->setInt( pExpanded.getToken(), 0, 0, 1 );
}
}
OP_Layout layout( parent );
#if UT_MAJOR_VERSION_INT >= 16
OP_SubnetIndirectInput *parentInput = parent->getParentInput( 0 );
layout.addLayoutItem( parentInput->getInputItem() );
for ( int i=0; i < parent->getNchildren(); ++i )
{
layout.addLayoutItem( parent->getChild( i ) );
}
#else
layout.addLayoutOp( parent->getParentInput( 0 ) );
for ( int i=0; i < parent->getNchildren(); ++i )
{
layout.addLayoutOp( parent->getChild( i ) );
}
#endif
layout.layoutOps( OP_LAYOUT_TOP_TO_BOT, parent, parent->getParentInput( 0 ) );
}
示例7: cookMySop
//.........这里部分代码省略.........
}
float base = 0.0;
for(int i=0;i<totd;i++)
{
Daemon& d = daemons[i];
d.range[0]=base;
d.range[1] = base+d.weight/weights;
base=d.range[1];
};
int total = evalInt("count",0,now);
int degr = evalInt("degr",0,now);
total >>= degr;
GA_RWHandleI cntt(gdp->addIntTuple(GA_ATTRIB_POINT, "count", 4, GA_Defaults(1.0)));
GB_AttributeRef dt(gdp->addDiffuseAttribute(GEO_POINT_DICT));
gdp->addVariableName("Cd","Cd");
UT_Vector3 current(0,0,0);
float C[3] = { 0,0,0 };
float R=1.0f;
bool trackRadii = (evalInt("trackradii",0,now)!=0);
float rScale = evalFloat("radiiscale",0,now);
GB_AttributeRef rt;
if(trackRadii)
{
float one=1.0f;
rt = gdp->addPointAttrib("width",4,GB_ATTRIB_FLOAT,&one);
if(!GBisAttributeRefValid(rt)) trackRadii=false;
else gdp->addVariableName("width","WIDTH");
};
float zero=0.0f;
GB_AttributeRef pt = gdp->addPointAttrib("parameter",4,GB_ATTRIB_FLOAT,&zero);
if(GBisAttributeRefValid(pt)) gdp->addVariableName("parameter","PARAMETER");
float param=0.0f;
srand(0);
UT_Interrupt* boss = UTgetInterrupt();
boss->opStart("Computing...");
for(int i=-50;i<total;i++)
{
bool ok = false;
if (boss->opInterrupt()) break;
float w = double(rand())/double(RAND_MAX);
for(int j=0;j<totd;j++)
{
ok = daemons[j].Transform(w,current,C,R,param);
if(ok) break;
};
if(i<0) continue;
if(clip)
{
if(!bbox.isInside(current)) continue;
};
if(ok)
{
GEO_Point* p = gdp->appendPoint();
p->setPos(current);
float* Cd=p->castAttribData<float>(dt);
if(useRamp)
{
ramp.rampLookup(param,C);
}
memcpy(Cd,C,12);
if(trackRadii)
{
float* _R = p->castAttribData<float>(rt);
*_R=rScale*R;
};
if(GBisAttributeRefValid(pt))
{
float* _p = p->castAttribData<float>(pt);
*_p=param;
}
};
};
boss->opEnd();
delete [] daemons;
return error();
};