本文整理汇总了C++中TextStream::nextLineAsDoubles方法的典型用法代码示例。如果您正苦于以下问题:C++ TextStream::nextLineAsDoubles方法的具体用法?C++ TextStream::nextLineAsDoubles怎么用?C++ TextStream::nextLineAsDoubles使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextStream
的用法示例。
在下文中一共展示了TextStream::nextLineAsDoubles方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseGridData
void Cube::parseGridData(TextStream& textStream)
{
QList<double> data;
while (!textStream.atEnd()) {
data += textStream.nextLineAsDoubles();
}
QList<Data::Geometry*> geometryList(m_dataBank.findData<Data::Geometry>());
if (geometryList.isEmpty()) {
m_errors.append("Geometry data not found in cube file");
return;
}
try {
Data::SurfaceType type(Data::SurfaceType::CubeData);
Data::GridSize size(m_origin, m_delta, m_nx, m_ny, m_nz);
Data::CubeData* cube(new Data::CubeData(*(geometryList.last()),size, type, data));
m_dataBank.append(cube);
QFileInfo info(m_filePath);
cube->setLabel(info.completeBaseName());
} catch (std::out_of_range const& err) {
m_errors.append("Invalid grid data in cube file");
}
}
示例2: parse
// Note the grid data is read in as bohr, but converted to angstroms in the
// Grid constructor
bool QChemPlot::parse(TextStream& textStream)
{
QList<double> values;
QList<Data::SurfaceType> surfaceTypes(parseForProperties(textStream));
unsigned nProperties(surfaceTypes.size());
if (nProperties < 1) goto error;
values = textStream.nextLineAsDoubles();
if ((unsigned)values.size() != 3 + nProperties) goto error;
{/**/
double xMin(values[0]);
double yMin(values[1]);
double zMin(values[2]);
double xMax(xMin);
double yMax(yMin);
double zMax(zMin);
typedef QList<double> List;
List* data = new List[nProperties];
for (unsigned i = 0; i < nProperties; ++i) {
data[i].append(values[i+3]);
}
unsigned nx(1), ny(1), nz(1);
while (!textStream.atEnd()) {
if ((unsigned)values.size() == 3 + nProperties) {
if (values[0] > xMax) { xMax = values[0]; ++nx; }
if (values[1] > yMax) { yMax = values[1]; ++ny; }
if (values[2] > zMax) { zMax = values[2]; ++nz; }
for (unsigned i = 0; i < nProperties; ++i) {
data[i].append(values[i+3]);
}
}
values = textStream.nextLineAsDoubles();
}
qglviewer::Vec delta((xMax-xMin)/nx, (yMax-yMin)/ny, (zMax-zMin)/nz);
qglviewer::Vec origin(xMin, yMin, zMin);
Data::GridDataList* gridList(new Data::GridDataList);
try {
for (unsigned i = 0; i < nProperties; ++i) {
Data::GridSize size(origin, delta, nx, ny, nz);
gridList->append(new Data::GridData(size, surfaceTypes[i]));
}
m_dataBank.append(gridList);
} catch (...) {
m_errors.append("Problem creating QChem plot data");
delete gridList;
}
delete[] data;
}/**/
return m_errors.isEmpty();
error:
QString msg("Problem parsing QChem plot data, line ");
m_errors.append(msg += QString::number(textStream.lineNumber()));
return false;
}