本文整理汇总了C++中ConfigFile::addOption方法的典型用法代码示例。如果您正苦于以下问题:C++ ConfigFile::addOption方法的具体用法?C++ ConfigFile::addOption怎么用?C++ ConfigFile::addOption使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConfigFile
的用法示例。
在下文中一共展示了ConfigFile::addOption方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GenerateMassSpringSystem
int MassSpringSystemFromTetMeshConfigFile::GenerateMassSpringSystem(const char * configFilename, MassSpringSystem ** massSpringSystem, MassSpringSystemTetMeshConfiguration * massSpringSystemTetMeshConfiguration)
{
char tetMeshFilename[4096];
char surfaceMeshFilename[4096];
double density, tensileStiffness, damping;
int addGravity;
printf("Parsing configuration file %s...\n", configFilename);
ConfigFile configFile;
configFile.addOption("tetMeshFilename", tetMeshFilename);
configFile.addOptionOptional("surfaceMeshFilename", surfaceMeshFilename, "__none");
configFile.addOption("density", &density);
configFile.addOption("tensileStiffness", &tensileStiffness);
configFile.addOption("damping", &damping);
configFile.addOption("addGravity", &addGravity);
if (configFile.parseOptions(configFilename) != 0)
{
printf("Error parsing options.\n");
return 1;
}
// the config variables have now been loaded with their specified values
// informatively print the variables (with assigned values) that were just parsed
configFile.printOptions();
TetMesh * tetMesh;
try
{
tetMesh = new TetMesh(tetMeshFilename);
}
catch(int eCode)
{
printf("Error: unable to load mesh from %s. Code: %d\n", tetMeshFilename, eCode);
return 1;
};
printf("Tet mesh loaded.\n");
MassSpringSystemFromTetMesh massSpringSystemFromTetMesh;
int code = massSpringSystemFromTetMesh.GenerateMassSpringSystem(tetMesh, massSpringSystem, density, tensileStiffness, damping, addGravity);
delete(tetMesh);
if (massSpringSystemTetMeshConfiguration != NULL)
{
massSpringSystemTetMeshConfiguration->tetMeshFilename = DuplicateString(tetMeshFilename);
massSpringSystemTetMeshConfiguration->surfaceMeshFilename = DuplicateString(surfaceMeshFilename);
massSpringSystemTetMeshConfiguration->density = density;
massSpringSystemTetMeshConfiguration->tensileStiffness = tensileStiffness;
massSpringSystemTetMeshConfiguration->damping = damping;
massSpringSystemTetMeshConfiguration->addGravity = addGravity;
}
return code;
}
示例2: initConfigurations
void initConfigurations()
{
ConfigFile configFile;
// specify the entries of the config file
configFile.addOptionOptional("windowWidth",&windowWidth,800);
configFile.addOptionOptional("windowHeight",&windowHeight,800);
configFile.addOption("deformableObjectFilename",deformableObjectFilename);
configFile.addOptionOptional("modesFilename",modesFilename,"__none");
configFile.addOptionOptional("cubicPolynomialFilename",cubicPolynomialFilename,"__none");
configFile.addOption("dampingMassCoef",&dampingMassCoef);
configFile.addOption("dampingStiffnessCoef",&dampingStiffnessCoef);
configFile.addOptionOptional("plasticThreshold", &plasticThreshold, plasticThreshold);
configFile.addOption("deformableObjectCompliance",&deformableObjectCompliance);
configFile.addOption("frequencyScaling",&frequencyScaling);
configFile.addOptionOptional("cameraRadius",&cameraRadius,17.5);
configFile.addOptionOptional("focusPositionX",&focusPositionX,0.0);
configFile.addOptionOptional("focusPositionY",&focusPositionY,0.0);
configFile.addOptionOptional("focusPositionZ",&focusPositionZ,0.0);
configFile.addOptionOptional("cameraLongitude",&cameraLongitude,-60.0);
configFile.addOptionOptional("cameraLattitude",&cameraLattitude,20.0);
configFile.addOptionOptional("renderWireframe",&renderWireframe,1);
configFile.addOptionOptional("extraSceneGeometry",extraSceneGeometryFilename,"__none");
configFile.addOptionOptional("enableTextures",&enableTextures,enableTextures);
configFile.addOptionOptional("backgroundColor",backgroundColorString, backgroundColorString);
string lightingConfigFilenameDefault = configFilesDir + "default.lighting";
configFile.addOptionOptional("lightingConfigFilename",lightingConfigFilename,
(char*) lightingConfigFilenameDefault.c_str());
configFile.addOptionOptional("substepsPerTimeStep",
&substepsPerTimeStep, substepsPerTimeStep);
configFile.addOptionOptional("renderOnGPU", &renderOnGPU, 1);
// parse the configuration file
if (configFile.parseOptions((char*)configFilename.c_str()) != 0)
{
printf("Error: unable to load the configuration file.\n");
exit(1);
}
// the config variables have now been loaded with their specified values
// informatively print the variables (with assigned values) that were just parsed
configFile.printOptions();
}
示例3: GenerateMassSpringSystem
int MassSpringSystemFromObjMeshConfigFile::GenerateMassSpringSystem(char * configFilename, MassSpringSystem ** massSpringSystem, MassSpringSystemObjMeshConfiguration * massSpringSystemObjConfiguration)
{
char massSpringMeshFilename[4096];
double surfaceDensity, tensileStiffness, shearStiffness, bendStiffness, damping;
int addGravity;
printf("Parsing configuration file %s...\n", configFilename);
ConfigFile configFile;
configFile.addOption("massSpringMeshFilename", massSpringMeshFilename);
configFile.addOption("surfaceDensity", &surfaceDensity);
configFile.addOption("tensileStiffness", &tensileStiffness);
configFile.addOption("shearStiffness", &shearStiffness);
configFile.addOption("bendStiffness", &bendStiffness);
configFile.addOption("damping", &damping);
configFile.addOption("addGravity", &addGravity);
if (configFile.parseOptions(configFilename) != 0)
{
printf("Error parsing options.\n");
return 1;
}
// the config variables have now been loaded with their specified values
// informatively print the variables (with assigned values) that were just parsed
configFile.printOptions();
ObjMesh * quadMesh;
try
{
quadMesh = new ObjMesh(massSpringMeshFilename);
}
catch(int eCode)
{
printf("Error: unable to load mesh from %s. Code: %d\n", massSpringMeshFilename, eCode);
return 1;
};
MassSpringSystemFromObjMesh massSpringSystemFromObjMesh;
int code = massSpringSystemFromObjMesh.GenerateMassSpringSystem(quadMesh, massSpringSystem, surfaceDensity, tensileStiffness, shearStiffness, bendStiffness, damping, addGravity);
delete(quadMesh);
if (massSpringSystemObjConfiguration != NULL)
{
massSpringSystemObjConfiguration->massSpringMeshFilename = DuplicateString(massSpringMeshFilename);
massSpringSystemObjConfiguration->surfaceDensity = surfaceDensity;
massSpringSystemObjConfiguration->tensileStiffness = tensileStiffness;
massSpringSystemObjConfiguration->shearStiffness = shearStiffness;
massSpringSystemObjConfiguration->bendStiffness = bendStiffness;
massSpringSystemObjConfiguration->damping = damping;
massSpringSystemObjConfiguration->addGravity = addGravity;
}
return code;
}
示例4: run
void run()
{
if (_arguments.count() == 1) {
printf("Usage: image_resample <config file path>\n");
return;
}
ConfigFile config;
List<StructuredType::Member> vectorMembers;
vectorMembers.add(StructuredType::Member(String("x"), Type::integer));
vectorMembers.add(StructuredType::Member(String("y"), Type::integer));
StructuredType vectorType(String("Vector"), vectorMembers);
config.addType(vectorType);
config.addOption("inputPicture", Type::string);
config.addOption("outputSize", vectorType);
config.addOption("subpixels", Type::boolean);
config.addOption("tripleResolution", Type::boolean);
config.addOption("outputPicture", Type::string);
config.load(_arguments[1]);
Bitmap<SRGB> input;
input.load(File(config.get<String>("inputPicture")));
Bitmap<Vector3<float> > linearInput(input.size());
input.convert(linearInput, ConvertSRGBToLinear());
Array<Any> sizeArray = config.get<List<Any> >("outputSize");
Vector size(sizeArray[0].value<int>(), sizeArray[1].value<int>());
Bitmap<Vector3<float> > linearOutput(size);
if (config.get<bool>("subpixels"))
linearInput.subPixelResample(&linearOutput,
config.get<bool>("tripleResolution"));
else
linearInput.resample(&linearOutput);
Bitmap<SRGB> output(linearOutput.size());
linearOutput.convert(output, ConvertLinearToSRGB());
output.save(File(config.get<String>("outputPicture")));
}