本文整理汇总了C++中UT_String::buffer方法的典型用法代码示例。如果您正苦于以下问题:C++ UT_String::buffer方法的具体用法?C++ UT_String::buffer怎么用?C++ UT_String::buffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UT_String
的用法示例。
在下文中一共展示了UT_String::buffer方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: s
// When mantra determines that the bounding box needs to be rendered, the
// render method is called. At this point, the procedural can either
// generate geometry (VRAY_Procedural::openGeometryObject()) or it can
// generate further procedurals (VRAY_Procedural::openProceduralObject()).
void
VRAY_ieProcedural::render()
{
initialisePython();
ParameterisedProceduralPtr parameterisedProcedural = 0;
ScopedGILLock giLock;
try
{
object ieCore = g_mainModuleNamespace["IECore"];
object classLoader = ieCore.attr( "ClassLoader" ).attr( "defaultProceduralLoader" )();
object procedural = classLoader.attr( "load" )( m_className.buffer(), m_classVersion )();
boost::python::list params;
UT_WorkArgs argv;
if (m_parameterString.tokenize(argv, ","))
{
// The Cortex Mantra Inject otl parses the parameters of a
// SOP_ProceduralHolder and replaces empty values with a '!'
// character to make them easier to parse here.
//
// This hack is upsetting, a pure python procedural in the style
// of IECoreRI iePython.dso could parse these parameters correctly
// like python/IECoreRI/ExecuteProcedural.py
for (int i = 0; i < argv.getArgc(); i++)
{
std::string s(argv[i]);
if (s == "!")
{
params.append(std::string(""));
}
else
{
params.append(s);
}
}
}
object parameterParser = ieCore.attr( "ParameterParser" )();
parameterParser.attr( "parse" )( params, procedural.attr( "parameters" )() );
parameterisedProcedural = extract<ParameterisedProceduralPtr>( procedural );
}
catch( const error_already_set &e )
{
PyErr_Print();
}
catch( const std::exception &e )
{
msg( Msg::Error, "VRAY_ieProcedural", e.what() );
}
catch( ... )
{
msg( Msg::Error, "VRAY_ieProcedural", "Caught unknown exception" );
}
if( parameterisedProcedural )
{
IECoreMantra::RendererPtr renderer = new IECoreMantra::Renderer( this );
parameterisedProcedural->render( renderer.get(), false, false, true, true );
}
}
示例2: format
// The initialize method is called when the procedural is created.
// Returning zero (failure) will abort the rendering of this procedural.
// The bounding box passed in is the user defined bounding box.
// If the user didn't specify a bounding box, then the box will be NULL
int
VRAY_ieWorld::initialize(const UT_BoundingBox *box)
{
if ( box )
{
m_bound = convert<Imath::Box3f> ( *box );
}
import( "ieworldfile", m_worldFileName);
import( "ieworldremove", &m_remove, 1);
if( access( m_worldFileName.buffer(), R_OK|F_OK ) == -1 )
{
msg( Msg::Warning, "VRAY_ieWorld", format("Failed to find ieworld cache file: %s") % m_worldFileName.buffer() );
return 0;
}
return 1;
}
示例3: if
ratReader::ratReader(Read *r, int fd): Reader(r)
{
// Init:
buffer = NULL;
loaded = false;
rat = NULL;
use_scanline_engine = true;
parms = new IMG_FileParms();
// Read knobs:
ratReaderFormat* rrf = dynamic_cast<ratReaderFormat*>(r->handler());
if (rrf)
{
if (rrf->reverse_scanlines())
parms->orientImage(IMG_ORIENT_LEFT_FIRST, IMG_ORIENT_TOP_FIRST);
use_scanline_engine = rrf->use_scanline_engine();
}
else
parms->orientImage(IMG_ORIENT_LEFT_FIRST, IMG_ORIENT_Y_NONE);
// Set some of the settings, which are assumed currently by both ::engines.
// Leaving them as they are would require some serious switches in logic bellow.
parms->setDataType(IMG_FLOAT);
parms->setInterleaved(IMG_INTERLEAVED);
parms->setComponentOrder(IMG_COMPONENT_RGBA);
// Create and open rat file, get stats:
rat = IMG_File::open(r->filename(), parms);
// TODO: Meta data attempt:
#if defined(DEBUG)
UT_String info;
rat->getAdditionalInfo(info);
iop->warning("Rat info: %s\n", info.buffer());
for (int i = 0; i < rat->getNumOptions(); i++)
{
iop->warning("%s: %s", rat->getOptionName(i), rat->getOptionValue(i));
}
UT_SharedPtr<UT_Options> opt;
UT_WorkBuffer wbuf;
if (opt = rat->imageTextureOptions())
{
wbuf.strcpy("DSM Options: ");
opt->appendPyDictionary(wbuf);
iop->warning("Options %i: %s\n", opt->getNumOptions(), wbuf.buffer());
}
#endif
if (!rat)
{
iop->error("Failed to open .rat file.");
}
const IMG_Stat &stat = rat->getStat();
depth = 0;
#if defined(DEBUG)
iop->warning("Rat opened: %s", r->filename());
#endif
// Since RAT can store varying bitdepth per plane, pixel-byte algebra doesn't
// help in finding out a number of channels. We need to iterate over planes.
for (int i = 0; i < stat.getNumPlanes(); i++)
{
IMG_Plane *plane = stat.getPlane(i);
// The easiest yet not unequivocal way to determine 2d versus deep RAT files:
if (!strcmp(plane->getName(), "Depth-Complexity"))
iop->warning("ratReader will treat DCM files as a 2d images. (ignoring deep pixels)");
#if defined(DEBUG)
iop->warning("Plane name: %s", plane->getName());
#endif
depth += IMGvectorSize(plane->getColorModel());
}
ChannelSet mask;
for (int i = 0; i < stat.getNumPlanes(); i++)
{
IMG_Plane *plane = stat.getPlane(i);
const int nchan = IMGvectorSize(plane->getColorModel());
for (int j = 0; j < nchan; j++)
{
std::string chan = std::string(plane->getComponentName(j) ? plane->getComponentName(j): "r");
if (chan == "r") chan = "red";
else if (chan == "g") chan = "green";
else if (chan == "b") chan = "blue";
else if (chan == "a") chan = "alpha";
std::string chan_name = std::string(plane->getName()) + std::string(".") + chan;
std::set<Channel> channels;
lookupChannels(channels, chan_name.c_str());
if (!channels.empty())
{
for (std::set<Channel>::iterator it = channels.begin(); it != channels.end(); it++)
{
Channel channel = *it;
channel_map[channel]= chan_name.c_str();
std::pair<int, int> idx(i, j);
//.........这里部分代码省略.........
示例4: cookMySop
// the bit that does all the work
OP_ERROR SOP_rmanPtc::cookMySop(OP_Context &context)
{
// get some useful bits & bobs
UT_Interrupt *boss;
float now = context.myTime;
UT_String ptcFile = getPtcFile(now);
int loadPercentage = getLoadPercentage(now);
int displayPercentage = getDisplayPercentage(now);
float pointSize = getPointSize(now);
int useDisk = getUseDisk(now);
int boundOnLoad = getBoundOnLoad(now);
int displayChannel = getDisplayChannel(now);
int onlyOutputDisplayChannel = getOnlyOutputDisplayChannel(now);
/*
float nearDensity = getNearDensity(now);
float farDensity = getFarDensity(now);
UT_String cullCamera = getCullCamera(now);
*/
// lock out inputs
if ( lockInputs(context) >= UT_ERROR_ABORT)
error();
// Check to see that there hasn't been a critical error in cooking the SOP.
if (error() < UT_ERROR_ABORT)
{
boss = UTgetInterrupt();
// here we make sure our detail is an instance of rmanPtcDetail
rmanPtcDetail *ptc_gdp = dynamic_cast<rmanPtcSop::rmanPtcDetail *>(gdp);
if ( !ptc_gdp )
ptc_gdp = allocateNewDetail();
// clear our gdp
ptc_gdp->clearAndDestroy();
// start our work
boss->opStart("Loading point cloud");
// get our bbox
bool has_bbox = false;
const GU_Detail *input_geo = inputGeo( 0, context );
updateBBox( input_geo );
// pass information to our detail
ptc_gdp->point_size = pointSize;
ptc_gdp->use_disk = useDisk;
ptc_gdp->cull_bbox = mBBox;
ptc_gdp->use_cull_bbox = (mHasBBox&&(!mBoundOnLoad))?true:false;
ptc_gdp->display_probability = displayPercentage/100.f;
ptc_gdp->display_channel = displayChannel;
if ( onlyOutputDisplayChannel )
ptc_gdp->display_channel = 0;
// here we load our ptc
if ( mReload )
{
// clear everything
mChannelNames.clear();
cachePoints.clear();
cacheNormals.clear();
cacheRadius.clear();
cacheData.clear();
mRedraw = true;
// open the point cloud
PtcPointCloud ptc = PtcSafeOpenPointCloudFile(
const_cast<char*>(ptcFile.buffer()) );
if ( !ptc )
{
UT_String msg( "Unable to open input file: " );
msg += ptcFile;
addError( SOP_MESSAGE, msg);
boss->opEnd();
return error();
}
// get some information from the ptc
ptc_gdp->path = std::string(ptcFile.fileName());
char **vartypes, **varnames;
PtcGetPointCloudInfo( ptc, const_cast<char*>("npoints"),
&ptc_gdp->nPoints );
PtcGetPointCloudInfo( ptc, const_cast<char*>("npointvars"),
&ptc_gdp->nChannels );
PtcGetPointCloudInfo( ptc, const_cast<char*>("pointvartypes"),
&vartypes );
PtcGetPointCloudInfo( ptc, const_cast<char*>("pointvarnames"),
&varnames );
PtcGetPointCloudInfo( ptc, const_cast<char*>("datasize"),
&ptc_gdp->datasize );
PtcGetPointCloudInfo( ptc, const_cast<char*>("bbox"),
ptc_gdp->bbox );
// process our channel names
ptc_gdp->types.clear();
ptc_gdp->names.clear();
for ( unsigned int i=0; i<ptc_gdp->nChannels; ++i )
{
ptc_gdp->types.push_back( std::string(vartypes[i]) );
//.........这里部分代码省略.........
示例5: readTags
void HoudiniScene::readTags( NameList &tags, bool includeChildren ) const
{
tags.clear();
const OP_Node *node = retrieveNode();
if ( !node )
{
return;
}
// add user supplied tags if we're not inside a SOP
if ( !m_contentIndex && node->hasParm( pTags.getToken() ) )
{
UT_String parmTagStr;
node->evalString( parmTagStr, pTags.getToken(), 0, 0 );
if ( !parmTagStr.equal( UT_String::getEmptyString() ) )
{
UT_WorkArgs tokens;
parmTagStr.tokenize( tokens, " " );
for ( int i = 0; i < tokens.getArgc(); ++i )
{
tags.push_back( tokens[i] );
}
}
}
// add tags from the registered tag readers
std::vector<CustomTagReader> &tagReaders = customTagReaders();
for ( std::vector<CustomTagReader>::const_iterator it = tagReaders.begin(); it != tagReaders.end(); ++it )
{
NameList values;
it->m_read( node, values, includeChildren );
tags.insert( tags.end(), values.begin(), values.end() );
}
// add tags based on primitive groups
OBJ_Node *contentNode = retrieveNode( true )->castToOBJNode();
if ( contentNode && contentNode->getObjectType() == OBJ_GEOMETRY && m_splitter )
{
GU_DetailHandle newHandle = m_splitter->split( contentPathValue() );
if ( !newHandle.isNull() )
{
GU_DetailHandleAutoReadLock readHandle( newHandle );
if ( const GU_Detail *geo = readHandle.getGdp() )
{
GA_Range prims = geo->getPrimitiveRange();
for ( GA_GroupTable::iterator<GA_ElementGroup> it=geo->primitiveGroups().beginTraverse(); !it.atEnd(); ++it )
{
GA_PrimitiveGroup *group = static_cast<GA_PrimitiveGroup*>( it.group() );
if ( group->getInternal() || group->isEmpty() )
{
continue;
}
const UT_String &groupName = group->getName();
if ( groupName.startsWith( tagGroupPrefix ) && group->containsAny( prims ) )
{
UT_String tag;
groupName.substr( tag, tagGroupPrefix.length() );
tag.substitute( "_", ":" );
tags.push_back( tag.buffer() );
}
}
}
}
}
}
示例6: SaveData
void SOP_Scallop::SaveData(float time)
{
OP_Context context(time);
bool clip = (lockInputs(context) < UT_ERROR_ABORT);
UT_BoundingBox bbox;
if(clip)
{
const GU_Detail* input = inputGeo(0,context);
if(input != NULL)
{
int res = input->getBBox(&bbox);
if(res == 0) clip = false;
}
else clip = false;
unlockInputs();
};
UT_String file;
STR_PARM(file,"path", 8, 0, time);
FILE* fp = fopen(file.buffer(),"wb");
if(fp == NULL) return;
float& now=time;
//////////////////////////////////////////////////////////////////////////
UT_Ramp ramp;
float rampout[4];
bool useRamp = (evalInt("parmcolor",0,now)!=0);
if(useRamp)
{
//PRM_Template *rampTemplate = PRMgetRampTemplate ("ramp", PRM_MULTITYPE_RAMP_RGB, NULL, NULL);
if (ramp.getNodeCount () < 2)
{
ramp.addNode (0, UT_FRGBA (0, 0, 0, 1));
ramp.addNode (1, UT_FRGBA (1, 1, 1, 1));
};
updateRampFromMultiParm(now, getParm("ramp"), ramp);
};
Daemon::now=now;
Daemon::bias = evalFloat("bias",0,now);
int cnt = evalInt("daemons", 0, now);
Daemon* daemons=new Daemon[cnt];
float weights = 0;
int totd=0;
for(int i=1;i<=cnt;i++)
{
bool skip = (evalIntInst("enabled#",&i,0,now)==0);
if(skip) continue;
Daemon& d = daemons[totd];
UT_String path = "";
evalStringInst("obj#", &i, path, 0, now);
if(path == "") continue;
SOP_Node* node = getSOPNode(path);
OBJ_Node* obj = dynamic_cast<OBJ_Node*>(node->getParent());
if(obj == NULL) continue;
obj->getWorldTransform(d.xform,context);
d.weight = evalFloatInst("weight#",&i,0,now);
d.c[0] = evalFloatInst("color#",&i,0,now);
d.c[1] = evalFloatInst("color#",&i,1,now);
d.c[2] = evalFloatInst("color#",&i,2,now);
int mth = evalIntInst("model#",&i,0,now);
switch(mth)
{
case 1:
d.method = Methods::Spherical;
break;
case 2:
d.method = Methods::Polar;
break;
case 3:
d.method = Methods::Swirl;
break;
case 4:
d.method = Methods::Trigonometric;
break;
//.........这里部分代码省略.........
示例7: SaveDivMap
//.........这里部分代码省略.........
// BoundBox::medial = (evalInt("mapmedial",0,now)!=0);
// float boxb[6];
// memcpy(boxb,bbox.minvec().vec,12);
// memcpy(boxb+3,bbox.maxvec().vec,12);
// Box.Organize(boxb);
//};
for(int i=-50;i<total;i++)
{
bool ok = false;
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(medial)
//{
float P[4] = { current.x(), current.y(), current.z(), R };
O.Insert(P);
//}
//else
//{
// Box.CheckPoint(current.vec);
//}
};
delete [] daemons;
//////////////////////////////////////////////////////////////////////////
int ita[3] = {-1,-1,-1};
//if(medial)
//{
int count = 0;
OctreeBox::at = det.addPrimAttrib("count",4,GB_ATTRIB_INT,&count);
det.addVariableName("count","COUNT");
float radius = 0.0f;
OctreeBox::rt = det.addAttrib("radius",4,GB_ATTRIB_FLOAT,&radius);
det.addVariableName("radius","RADIUS");
OctreeBox::it = det.addPrimAttrib("mask",12,GB_ATTRIB_INT,ita);
det.addVariableName("mask","MASK");
float box[6] = {bbox.xmin(),bbox.xmax(),bbox.ymin(),bbox.ymax(),bbox.zmin(),bbox.zmax()};
det.addAttrib("bbox",24,GB_ATTRIB_FLOAT,box);
O.maxlevel = 0x01<<mapdiv;
O.parentbbox = bbox;
O.Build(det);
//}
//else Box.Build(det);
det.save(file.buffer(),1,NULL);
// ...SAVE ATLAS
{
UT_String atlas =file;
atlas+=".atlas";
FILE* fa = fopen(atlas.buffer(),"wb");
GEO_PrimList& pl = det.primitives();
int cnt = pl.entries();
fwrite(&cnt,sizeof(int),1,fa);
float bb[6] = { bbox.xmin(), bbox.xmax(), bbox.ymin(), bbox.ymax(), bbox.zmin(), bbox.zmax() };
fwrite(bb,sizeof(float),6,fa);
fwrite(&(O.maxlevel),sizeof(int),1,fa);
fwrite(&(O.maxlevel),sizeof(int),1,fa);
fwrite(&(O.maxlevel),sizeof(int),1,fa);
for(int i=0;i<cnt;i++)
{
const GEO_PrimVolume* v = dynamic_cast<const GEO_PrimVolume*>(pl[i]);
UT_BoundingBox b;
v->getBBox(&b);
float _bb[6] = { b.xmin(), b.xmax(), b.ymin(), b.ymax(), b.zmin(), b.zmax() };
fwrite(_bb,sizeof(float),6,fa);
// MASK
fwrite(v->castAttribData<int>(OctreeBox::it),sizeof(int),3,fa);
}
fclose(fa);
}
};