本文整理汇总了C++中Var类的典型用法代码示例。如果您正苦于以下问题:C++ Var类的具体用法?C++ Var怎么用?C++ Var使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Var类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BinaryFactor
Factor BinaryFactor( const Var &n, Real field ) {
DAI_ASSERT( n.states() == 2 );
Real buf[2];
buf[0] = std::exp(-field);
buf[1] = std::exp(field);
return Factor(n, &buf[0]);
}
示例2: createFactorIsing
Factor createFactorIsing( const Var &n, Real h ) {
DAI_ASSERT( n.states() == 2 );
Real buf[2];
buf[0] = std::exp(-h);
buf[1] = std::exp(h);
return Factor(n, &buf[0]);
}
示例3: processVert
void DepthOutHLSL::processVert( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
// Grab the output vert.
Var *outPosition = (Var*)LangElement::find( "hpos" );
// Grab our output depth.
Var *outDepth = connectComp->getElement( RT_TEXCOORD );
outDepth->setName( "depth" );
outDepth->setStructName( "OUT" );
outDepth->setType( "float" );
output = new GenOp( " @ = @.z / @.w;\r\n", outDepth, outPosition, outPosition );
}
示例4: name
Var* TerrainFeatHLSL::_getDetailIdStrengthParallax()
{
String name( String::ToString( "detailIdStrengthParallax%d", getProcessIndex() ) );
Var *detailInfo = (Var*)LangElement::find( name );
if ( !detailInfo )
{
detailInfo = new Var;
detailInfo->setType( "float3" );
detailInfo->setName( name );
detailInfo->uniform = true;
detailInfo->constSortPos = cspPotentialPrimitive;
}
return detailInfo;
}
示例5: readDouble
static void readDouble(const File& file,
const string& name,
const array<size_t, dimension>& start,
const array<size_t, dimension>& count,
Type* values,
PropertyType Type::*property,
const Converter& converter) {
size_t size = accumulate(count.begin(), count.end(), 1, [](size_t n, size_t m) { return n*m; });
vector<double> v(size);
const Var var(file.var(name));
var.get(start, count, v.data());
size_t n = 0;
for (auto it = v.begin(); it != v.end(); ++it, ++n) {
values[n].*property = converter(*it);
}
}
示例6: getInTexCoord
void TerrainBaseMapFeatHLSL::processPix( Vector<ShaderComponent*> &componentList,
const MaterialFeatureData &fd )
{
// grab connector texcoord register
Var *texCoord = getInTexCoord( "texCoord", "float3", true, componentList );
// create texture var
Var *diffuseMap = new Var;
diffuseMap->setType( "sampler2D" );
diffuseMap->setName( "baseTexMap" );
diffuseMap->uniform = true;
diffuseMap->sampler = true;
diffuseMap->constNum = Var::getTexUnitNum(); // used as texture unit num here
MultiLine *meta = new MultiLine;
Var *baseColor = new Var;
baseColor->setType( "float4" );
baseColor->setName( "baseColor" );
if (mIsDirect3D11)
{
diffuseMap->setType("SamplerState");
Var *diffuseTex = new Var;
diffuseTex->setType("Texture2D");
diffuseTex->setName("baseTexture");
diffuseTex->uniform = true;
diffuseTex->texture = true;
diffuseTex->constNum = diffuseMap->constNum;
meta->addStatement(new GenOp(" @ = @.Sample( @, @.xy );\r\n", new DecOp(baseColor), diffuseTex, diffuseMap, texCoord));
}
else
{
meta->addStatement(new GenOp(" @ = tex2D( @, @.xy );\r\n", new DecOp(baseColor), diffuseMap, texCoord));
}
meta->addStatement(new GenOp(" @ = toLinear(@);\r\n", baseColor, baseColor));
ShaderFeature::OutputTarget target = ShaderFeature::DefaultTarget;
if (fd.features.hasFeature(MFT_isDeferred))
{
target= ShaderFeature::RenderTarget1;
}
meta->addStatement( new GenOp( " @;\r\n", assignColor( baseColor, Material::Mul,NULL,target ) ) );
output = meta;
}
示例7: blockCurrentSol
void Engine::blockCurrentSol() {
if (outputs.size() == 0) NOT_SUPPORTED;
Clause& c = *Reason_new(outputs.size());
bool root_failure = true;
for (int i = 0; i < outputs.size(); i++) {
Var *v = (Var*) outputs[i];
if (v->getType() == BOOL_VAR) {
c[i] = ((BoolView*) outputs[i])->getValLit();
} else {
c[i] = ((IntVar*) outputs[i])->getValLit();
}
if (!sat.isRootLevel(var(c[i]))) root_failure = false;
assert(sat.value(c[i]) == l_False);
}
if (root_failure) sat.btToLevel(0);
sat.confl = &c;
}
示例8: name
Var* TerrainFeatGLSL::_getInDetailCoord( Vector<ShaderComponent*> &componentList )
{
String name( String::ToString( "outDetCoord%d", getProcessIndex() ) );
Var *inDet = (Var*)LangElement::find( name );
if ( !inDet )
{
ShaderConnector *connectComp = dynamic_cast<ShaderConnector *>( componentList[C_CONNECTOR] );
inDet = connectComp->getElement( RT_TEXCOORD );
inDet->setName( name );
inDet->setType( "vec4" );
inDet->mapsToSampler = true;
}
return inDet;
}
示例9: print
// class PathExpressionPrinter
void PathExpressionPrinter::print(const Var &v) {
simit_iassert(v.defined()) << "attempting to print undefined var";
std::string name;
if (util::contains(names, v)) {
name = names.at(v);
}
else {
if (v.getName() != "") {
name = nameGenerator.getName(v.getName());
}
else {
name = nameGenerator.getName("e");
}
names[v] = name;
}
os << name;
}
示例10: name
Var* TerrainFeatGLSL::_getNormalMapTex()
{
String name( String::ToString( "normalMap%d", getProcessIndex() ) );
Var *normalMap = (Var*)LangElement::find( name );
if ( !normalMap )
{
normalMap = new Var;
normalMap->setType( "sampler2D" );
normalMap->setName( name );
normalMap->uniform = true;
normalMap->sampler = true;
normalMap->constNum = Var::getTexUnitNum();
}
return normalMap;
}
示例11: qDebug
void Var::append(Var var)
{
if(Type=="list")
{
if(var.getType()=="list")
{
for(int i=0;i<var.size();i++)
List.append(var[i]);
}
else
{
List.append(var);
}
}
else
qDebug()<<"Var::append - type is not list; Name = "<<Name<<"Type = "<<Type;
}
示例12: DecOp
Var* GBufferConditionerGLSL::_unconditionInput( Var *conditionedInput, MultiLine *meta )
{
Var *retVar = new Var;
retVar->setType("vec4");
retVar->setName("_gbUnconditionedInput");
LangElement *outputDecl = new DecOp( retVar );
switch(mNormalStorageType)
{
case CartesianXYZ:
meta->addStatement( new GenOp( " // g-buffer unconditioner: vec4(normal.xyz, depth)\r\n" ) );
meta->addStatement( new GenOp( " @ = vec4(@, @.a);\r\n", outputDecl,
_posnegDecode(new GenOp("@.xyz", conditionedInput)), conditionedInput ) );
break;
case CartesianXY:
meta->addStatement( new GenOp( " // g-buffer unconditioner: vec4(normal.xy, depth Hi + z-sign, depth Lo)\r\n" ) );
meta->addStatement( new GenOp( " @ = vec4(@, @.a);\r\n", outputDecl,
_posnegDecode(new GenOp("@.xyz", conditionedInput)), conditionedInput ) );
meta->addStatement( new GenOp( " @.z *= sqrt(1.0 - dot(@.xy, @.xy));\r\n", retVar, retVar, retVar ) );
break;
case Spherical:
meta->addStatement( new GenOp( " // g-buffer unconditioner: vec4(normal.theta, normal.phi, depth Hi, depth Lo)\r\n" ) );
meta->addStatement( new GenOp( " vec2 spGPUAngles = @;\r\n", _posnegDecode(new GenOp("@.xy", conditionedInput)) ) );
meta->addStatement( new GenOp( " vec2 sincosTheta;\r\n" ) );
meta->addStatement( new GenOp( " sincosTheta.x = sin(spGPUAngles.x * 3.14159265358979323846);\r\n" ) );
meta->addStatement( new GenOp( " sincosTheta.y = cos(spGPUAngles.x * 3.14159265358979323846);\r\n" ) );
meta->addStatement( new GenOp( " vec2 sincosPhi = vec2(sqrt(1.0 - spGPUAngles.y * spGPUAngles.y), spGPUAngles.y);\r\n" ) );
meta->addStatement( new GenOp( " @ = vec4(sincosTheta.y * sincosPhi.x, sincosTheta.x * sincosPhi.x, sincosPhi.y, @.a);\r\n", outputDecl, conditionedInput ) );
break;
}
// Recover depth from encoding
if(mNormalStorageType != CartesianXYZ)
{
const U64 maxValPerChannel = 1 << mBitsPerChannel;
meta->addStatement( new GenOp( " \r\n // Decode depth\r\n" ) );
meta->addStatement( new GenOp( avar( " @.w = dot( @.zw, vec2(1.0, 1.0/%llu.0));\r\n", maxValPerChannel - 1 ),
retVar, conditionedInput ) );
}
AssertFatal( retVar != NULL, avar( "Cannot uncondition input from buffer format: %s", GFXStringTextureFormat[getBufferFormat()] ) );
return retVar;
}
示例13: setValue
void ParseHandler::setValue(const Var& value)
{
Var parent = _stack.top();
if ( parent.type() == typeid(Array::Ptr) )
{
Array::Ptr arr = parent.extract<Array::Ptr>();
arr->add(value);
}
else if ( parent.type() == typeid(Object::Ptr) )
{
poco_assert_dbg(!_key.empty());
Object::Ptr obj = parent.extract<Object::Ptr>();
obj->set(_key, value);
_key.clear();
}
}
示例14: writeVarLargeEncodingExpression
static void writeVarLargeEncodingExpression(Var& var, FILE* fp)
{
const char* varname = var.name().c_str();
fprintf(fp, "\tstream->writeFully(&__size_%s,4);\n", varname);
if (var.nullAllowed()) {
fprintf(fp, "\tif (%s != NULL) ", varname);
} else {
fprintf(fp, "\t");
}
if (var.writeExpression() != "") {
fprintf(fp, "%s", var.writeExpression().c_str());
} else {
fprintf(fp, "stream->writeFully(%s, __size_%s)", varname, varname);
}
fprintf(fp, ";\n");
}
示例15: foreach
std::vector<std::map<size_t, int> > AnyPositionCnfCompress::createCounts(size_t &gndFactor, VarSet &superVarSet) {
// create zero entries for each position
map<long, map<size_t, int> > countMap;
foreach (const dai::BipartiteGraph::Neighbor &tmpVar, _cfg.nbF(gndFactor)) {
Var liftedVar = _varRepr[_varColorVec[tmpVar]];
size_t pos = find(_cfg.factor(gndFactor).sigma().begin(), _cfg.factor(gndFactor).sigma().end(), tmpVar.iter) - _cfg.factor(gndFactor).sigma().begin();
countMap[liftedVar.label()][pos] = 0;
}
vector<map<size_t, int> > counts;
size_t posCount;
size_t negCount;
for (vector<Var>::const_iterator iter = superVarSet.begin(); iter < superVarSet.end(); iter++) {
posCount = 0;
negCount = 0;
foreach(const dai::BipartiteGraph::Neighbor tmpFac, _cfg.nbV(_cfg.findVar(*iter))) {
if (_facRepr[_facColorVec[tmpFac]] == gndFactor) {
size_t pos = find(_cfg.factor(tmpFac).sigma().begin(), _cfg.factor(tmpFac).sigma().end(), tmpFac.dual) - _cfg.factor(tmpFac).sigma().begin();
double res = log(_cfg.factor(tmpFac).states() - _zeroStates[tmpFac]) / log(2);
size_t nrPosLiterals = size_t(res);
bool sign = (pos < nrPosLiterals);
if (sign) {
posCount++;
} else {
negCount++;
}
}
}
map<size_t, int>::iterator posIter=countMap[iter->label()].begin();
if (posCount > 0) {
posIter->second = posCount;
}
if (negCount > 0) {
for (size_t j=0;j<posCount; j++, posIter++) {}
posIter->second = negCount;
}
counts.push_back(countMap[iter->label()]);
}
return counts;
}