本文整理汇总了C++中FileName::name方法的典型用法代码示例。如果您正苦于以下问题:C++ FileName::name方法的具体用法?C++ FileName::name怎么用?C++ FileName::name使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileName
的用法示例。
在下文中一共展示了FileName::name方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: addExtension
FileName FileName::addExtension(const QString &newExtension) const {
FileName result = *this;
if (result.extension() != newExtension) {
QString attributesStr = result.attributes();
if (attributesStr == "")
result = FileName(result.originalPath() + "/" + result.name() + "." + newExtension);
else
result = FileName(result.originalPath() + "/" + result.name() + "." + newExtension
+ "+" + attributesStr);
}
return result;
}
示例2: createCubeList
/**
* Fills the list box with the cube name list
*
* @internal
* @history 2009-01-26 Jeannie Walldren - Original version
*/
void QnetPointCubeNameFilter::createCubeList() {
// Clear the old list and update with the entire list
p_listBox->setCurrentRow(-1);
p_listBox->clear();
SerialNumberList *snList = serialNumberList();
for (int i = 0; i < snList->Size(); i++) {
FileName filename = FileName(snList->FileName(i));
QString tempFileName = filename.name();
p_listBox->insertItem(i, tempFileName);
}
}
示例3: IsisMain
void IsisMain() {
// Grab the file to import
UserInterface &ui = Application::GetUserInterface();
FileName in = ui.GetFileName("FROM");
FileName out = ui.GetFileName("TO");
// Make sure it is a Clementine EDR
bool projected;
try {
Pvl lab(in.expanded());
projected = lab.hasObject("IMAGE_MAP_PROJECTION");
QString id;
id = (QString)lab["DATA_SET_ID"];
id = id.simplified().trimmed();
if(!id.contains("CLEM")) {
QString msg = "Invalid DATA_SET_ID [" + id + "]";
throw IException(IException::Unknown, msg, _FILEINFO_);
}
}
catch(IException &e) {
QString msg = "Input file [" + in.expanded() +
"] does not appear to be " +
"in Clementine EDR format";
throw IException(IException::Unknown, msg, _FILEINFO_);
}
//Checks if in file is rdr
if(projected) {
QString msg = "[" + in.name() + "] appears to be an rdr file.";
msg += " Use pds2isis.";
throw IException(IException::User, msg, _FILEINFO_);
}
//Decompress the file
long int lines = 0;
long int samps = 0;
QString filename = in.expanded();
pdsi = PDSR(filename.toAscii().data(), &lines, &samps);
ProcessByLine p;
CubeAttributeOutput cubeAtt("+unsignedByte+1.0:254.0");
Cube *ocube = p.SetOutputCube(ui.GetFileName("TO"), cubeAtt, pdsi->image_ncols, pdsi->image_nrows);
p.StartProcess(WriteLine);
TranslateLabels(in, ocube);
p.EndProcess();
}
示例4: newVersion
FileName FileName::newVersion() const {
validateVersioningState();
FileName result = *this;
if (!isVersioned()) {
throw IException(IException::Unknown,
QObject::tr("Asked for new version of file named [%1] in [%2] but there "
"are no version sequences in the name")
.arg(name()).arg(originalPath()),
_FILEINFO_);
}
// Look for date
if (isDateVersioned()) {
result = result.version(QDate::currentDate());
}
// Look for #'s
if (isNumericallyVersioned()) {
try {
result = result.version(result.highestVersionNum() + 1);
}
catch (IException &) {
result = result.version(1);
}
}
if (result.fileExists()) {
throw IException(IException::Unknown,
QObject::tr("Could not generate unique new version of file named [%1] in "
"[%2] because the file [%3] exists")
.arg(name()).arg(originalPath()).arg(result.name()),
_FILEINFO_);
}
return result;
}
示例5: foreach
foreach (QString fileToTest, filesToTestSafely) {
cout << "Running Safe Test on [" << qPrintable(fileToTest) << "]" << endl;
TestGenericAccessors("\t", fileToTest, false);
TestExtensionChanges("\t", fileToTest, false);
}
// Test temp files thoroughly
cout << "Testing temporary file name placement" << endl;
QString tempFileNameTestStr = "$TEMPORARY/tttt.tmp";
FileName n = FileName::createTempFile(tempFileNameTestStr);
cout << "\tInput name and extension : " << tempFileNameTestStr << endl;
cout << "\tExtension: : " << n.extension() << endl;
cout << "\tOriginal Path: : " << n.originalPath() << endl;
cout << "\tExists: : " << n.fileExists() << endl;
cout << "\tName (cleaned): : " <<
QString(n.name().mid(0, 4) +
QString("%1").arg("", n.name().size() - 8, '?') +
n.name().mid(n.name().size() - 4)) << endl;
cout << endl;
if (!QFile(n.toString()).remove()) {
cout << "\t**Failed to delete temporary file [" << n.toString() << "]**" << endl;
}
{
cout << "Testing parallel temporary file name creation for atomicity" << endl;
int numToTest = QThreadPool::globalInstance()->maxThreadCount() * 20;
QStringList templateFileNames;
for (int i = 0; i < numToTest; i++)
templateFileNames.append(QString("tttt.tmp"));
示例6: IsisMain
//.........这里部分代码省略.........
std::vector<double> ephemerisTimes;
std::vector<double> exposureTimes;
std::vector< std::vector<char *> > prefix = p.DataPrefix();
for(int line = 0; line < p.Lines(); line++) {
double ephTime = swapper.Double((double *)prefix[0][line]);
double expTime = swapper.Float((float *)(prefix[0][line] + 8)) / 1000.0;
if(line > 0) {
/**
* We know how many skipped lines with this equation. We take the
* difference in the current line and the last line's time, which will
* ideally be equal to the last line's exposure duration. We divide this by
* the last line's exposure duration, and the result is the 1-based count of
* how many exposures there were between the last line and the current line.
* We subtract one in order to remove the known exposure, and the remaining should
* be the 1-based count of how many lines were skipped. Add 0.5 to round up.
*/
int skippedLines = (int)((ephTime - ephemerisTimes.back()) / exposureTimes.back() - 1.0 + 0.5);
for(int i = 0; i < skippedLines; i++) {
ephemerisTimes.push_back(ephemerisTimes.back() + exposureTimes.back());
exposureTimes.push_back(exposureTimes.back());
lineInFile.push_back(false);
}
}
ephemerisTimes.push_back(ephTime);
exposureTimes.push_back(expTime);
lineInFile.push_back(true);
}
double lastExp = 0.0;
for(unsigned int i = 0; i < ephemerisTimes.size(); i++) {
if(lastExp != exposureTimes[i]) {
lastExp = exposureTimes[i];
timesRecord[0] = ephemerisTimes[i];
timesRecord[1] = exposureTimes[i];
timesRecord[2] = (int)i + 1;
timesTable += timesRecord;
}
}
outCube->setDimensions(p.Samples(), lineInFile.size(), p.Bands());
}
else {
//Checks if in file is rdr
FileName inFile = ui.GetFileName("FROM");
QString msg = "[" + inFile.name() + "] appears to be an rdr file.";
msg += " Use pds2isis.";
throw IException(IException::User, msg, _FILEINFO_);
}
p.Progress()->SetText("Importing");
outCube->create(ui.GetFileName("TO"));
p.StartProcess(WriteOutput);
if(hasPrefix) {
outCube->write(timesTable);
}
// Get as many of the other labels as we can
Pvl otherLabels;
//p.TranslatePdsLabels (otherLabels);
TranslateHrscLabels(label, otherLabels);
if(otherLabels.hasGroup("Mapping") &&
(otherLabels.findGroup("Mapping").keywords() > 0)) {
outCube->putGroup(otherLabels.findGroup("Mapping"));
}
if(otherLabels.hasGroup("Instrument") &&
(otherLabels.findGroup("Instrument").keywords() > 0)) {
outCube->putGroup(otherLabels.findGroup("Instrument"));
}
if(otherLabels.hasGroup("BandBin") &&
(otherLabels.findGroup("BandBin").keywords() > 0)) {
outCube->putGroup(otherLabels.findGroup("BandBin"));
}
if(otherLabels.hasGroup("Archive") &&
(otherLabels.findGroup("Archive").keywords() > 0)) {
outCube->putGroup(otherLabels.findGroup("Archive"));
}
if(otherLabels.hasGroup("Kernels") &&
(otherLabels.findGroup("Kernels").keywords() > 0)) {
outCube->putGroup(otherLabels.findGroup("Kernels"));
}
p.EndProcess();
outCube->close();
delete outCube;
outCube = NULL;
lineInFile.clear();
}
示例7: importOBJ
void importOBJ(const std::shared_ptr<Node> &world, const FileName &fileName)
{
tinyobj::attrib_t attrib;
std::vector<tinyobj::shape_t> shapes;
std::vector<tinyobj::material_t> materials;
std::string err;
const std::string containingPath = fileName.path();
std::cout << "parsing OBJ input file... \n";
bool ret = tinyobj::LoadObj(&attrib,
&shapes,
&materials,
&err,
fileName.c_str(),
containingPath.c_str());
#if 0 // NOTE(jda) - enable if you want to see warnings from TinyOBJ
if (!err.empty())
std::cerr << "#ospsg: obj parsing warning(s)...\n" << err << std::endl;
#endif
if (!ret) {
std::cerr << "#ospsg: FATAL error parsing obj file, no geometry added"
<< " to the scene!" << std::endl;
return;
}
auto sgMaterials = createSgMaterials(materials, containingPath);
std::string base_name = fileName.name() + '_';
int shapeId = 0;
std::cout << "...adding found triangle groups to the scene...\n";
size_t shapeCounter = 0;
size_t numShapes = shapes.size();
size_t increment = numShapes / size_t(10);
int incrementer = 0;
#if !USE_INSTANCES
auto objInstance = createNode("instance", "Instance");
world->add(objInstance);
#endif
for (auto &shape : shapes) {
for (int numVertsInFace : shape.mesh.num_face_vertices) {
if (numVertsInFace != 3) {
std::cerr << "Warning: more thant 3 verts in face!";
PRINT(numVertsInFace);
}
}
if (shapeCounter++ > (increment * incrementer + 1))
std::cout << incrementer++ * 10 << "%\n";
auto name = base_name + std::to_string(shapeId++) + '_' + shape.name;
auto mesh = createNode(name, "TriangleMesh")->nodeAs<TriangleMesh>();
auto v = createNode("vertex", "DataVector3f")->nodeAs<DataVector3f>();
auto numSrcIndices = shape.mesh.indices.size();
v->v.reserve(numSrcIndices);
auto vi = createNode("index", "DataVector3i")->nodeAs<DataVector3i>();
vi->v.reserve(numSrcIndices / 3);
auto vn = createNode("normal", "DataVector3f")->nodeAs<DataVector3f>();
vn->v.reserve(numSrcIndices);
auto vt =
createNode("texcoord", "DataVector2f")->nodeAs<DataVector2f>();
vt->v.reserve(numSrcIndices);
for (size_t i = 0; i < shape.mesh.indices.size(); i += 3) {
auto idx0 = shape.mesh.indices[i + 0];
auto idx1 = shape.mesh.indices[i + 1];
auto idx2 = shape.mesh.indices[i + 2];
auto prim = vec3i(i + 0, i + 1, i + 2);
vi->push_back(prim);
v->push_back(vec3f(attrib.vertices[idx0.vertex_index * 3 + 0],
attrib.vertices[idx0.vertex_index * 3 + 1],
attrib.vertices[idx0.vertex_index * 3 + 2]));
v->push_back(vec3f(attrib.vertices[idx1.vertex_index * 3 + 0],
attrib.vertices[idx1.vertex_index * 3 + 1],
attrib.vertices[idx1.vertex_index * 3 + 2]));
v->push_back(vec3f(attrib.vertices[idx2.vertex_index * 3 + 0],
attrib.vertices[idx2.vertex_index * 3 + 1],
attrib.vertices[idx2.vertex_index * 3 + 2]));
// TODO create missing normals&texcoords if only some faces have them
if (!attrib.normals.empty() && idx0.normal_index != -1) {
vn->push_back(vec3f(attrib.normals[idx0.normal_index * 3 + 0],
attrib.normals[idx0.normal_index * 3 + 1],
attrib.normals[idx0.normal_index * 3 + 2]));
vn->push_back(vec3f(attrib.normals[idx1.normal_index * 3 + 0],
attrib.normals[idx1.normal_index * 3 + 1],
attrib.normals[idx1.normal_index * 3 + 2]));
vn->push_back(vec3f(attrib.normals[idx2.normal_index * 3 + 0],
attrib.normals[idx2.normal_index * 3 + 1],
//.........这里部分代码省略.........
示例8: IsisMain
//***********************************************************************
// IsisMain()
//***********************************************************************
void IsisMain() {
UserInterface &ui = Application::GetUserInterface();
FileName in = ui.GetFileName("FROM");
FileName outIr = ui.GetFileName("IR");
FileName outVis = ui.GetFileName("VIS");
Pvl lab(in.expanded());
//Checks if in file is rdr
if(lab.hasObject("IMAGE_MAP_PROJECTION")) {
QString msg = "[" + in.name() + "] appears to be an rdr file.";
msg += " Use pds2isis.";
throw IException(IException::User, msg, _FILEINFO_);
}
//Make sure it is a vims cube
try {
PvlObject qube(lab.findObject("QUBE"));
QString id;
id = (QString)qube["INSTRUMENT_ID"];
id = id.simplified().trimmed();
if(id != "VIMS") {
QString msg = "Invalid INSTRUMENT_ID [" + id + "]";
throw IException(IException::Unknown, msg, _FILEINFO_);
}
}
catch(IException &e) {
QString msg = "Input file [" + in.expanded() +
"] does not appear to be " +
"in VIMS EDR/RDR format";
throw IException(IException::Io, msg, _FILEINFO_);
}
FileName tempname(in.baseName() + ".bsq.cub");
Pvl pdsLab(in.expanded());
// It's VIMS, let's figure out if it has the suffix data or not
if(toInt(lab.findObject("QUBE")["SUFFIX_ITEMS"][0]) == 0) {
// No suffix data, we can use processimportpds
ProcessImportPds p;
p.SetPdsFile(in.expanded(), "", pdsLab);
// Set up the temporary output cube
//The temporary cube is set to Real pixeltype, regardless of input pixel type
Isis::CubeAttributeOutput outatt = CubeAttributeOutput("+Real");
p.SetOutputCube(tempname.name(), outatt);
p.StartProcess();
p.EndProcess();
}
else {
// We do it the hard way
ReadVimsBIL(in.expanded(), lab.findObject("QUBE")["SUFFIX_ITEMS"], tempname.name());
}
// Create holder for original labels
OriginalLabel origLabel(pdsLab);
//Now separate the cubes
ProcessByLine l;
PvlGroup status("Results");
//VIS cube
const PvlObject &qube = lab.findObject("Qube");
if(qube["SAMPLING_MODE_ID"][1] != "N/A") {
CubeAttributeInput inattvis = CubeAttributeInput("+1-96");
l.SetInputCube(tempname.name(), inattvis);
Cube *oviscube = l.SetOutputCube("VIS");
oviscube->write(origLabel);
l.StartProcess(ProcessCube);
TranslateVimsLabels(pdsLab, oviscube, VIS);
l.EndProcess();
status += PvlKeyword("VisCreated", "true");
}
else {
status += PvlKeyword("VisCreated", "false");
}
//IR cube
if(qube["SAMPLING_MODE_ID"][0] != "N/A") {
CubeAttributeInput inattir = CubeAttributeInput("+97-352");
l.SetInputCube(tempname.name(), inattir);
Cube *oircube = l.SetOutputCube("IR");
oircube->write(origLabel);
l.StartProcess(ProcessCube);
TranslateVimsLabels(pdsLab, oircube, IR);
l.EndProcess();
status += PvlKeyword("IrCreated", "true");
}
else {
status += PvlKeyword("IrCreated", "false");
}
Application::Log(status);
//Clean up
//.........这里部分代码省略.........