本文整理汇总了C++中Scalar::size方法的典型用法代码示例。如果您正苦于以下问题:C++ Scalar::size方法的具体用法?C++ Scalar::size怎么用?C++ Scalar::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Scalar
的用法示例。
在下文中一共展示了Scalar::size方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: read_label
void read_label (const std::string& path, VertexList& vertices, Scalar& scalar)
{
vertices.clear();
scalar.resize(0);
std::ifstream in (path.c_str(), std::ios_base::in);
if (!in)
throw Exception ("Error opening input file!");
std::string line;
std::getline (in, line);
if (line.substr(0, 13) != "#!ascii label")
throw Exception ("Error parsing FreeSurfer label file \"" + Path::basename (path) + "\": Bad first line identifier");
std::getline (in, line);
uint32_t num_vertices = 0;
try {
num_vertices = to<size_t> (line);
} catch (Exception& e) {
throw Exception (e, "Error parsing FreeSurfer label file \"" + Path::basename (path) + "\": Bad second line vertex count");
}
for (size_t i = 0; i != num_vertices; ++i) {
std::getline (in, line);
uint32_t index = std::numeric_limits<uint32_t>::max();
default_type x = NaN, y = NaN, z = NaN, value = NaN;
sscanf (line.c_str(), "%u %lf %lf %lf %lf", &index, &x, &y, &z, &value);
if (index == std::numeric_limits<uint32_t>::max())
throw Exception ("Error parsing FreeSurfer label file \"" + Path::basename (path) + "\": Malformed line");
if (index >= scalar.size()) {
scalar.conservativeResizeLike (Scalar::Base::Constant (index+1, NaN));
vertices.resize (index+1, Vertex (NaN, NaN, NaN));
}
if (std::isfinite (scalar[index]))
throw Exception ("Error parsing FreeSurfer label file \"" + Path::basename (path) + "\": Duplicated index (" + str(scalar[index]) + ")");
scalar[index] = value;
vertices[index] = Vertex (x, y, z);
}
if (!in.good())
throw Exception ("Error parsing FreeSurfer label file \"" + Path::basename (path) + "\": End of file reached");
scalar.set_name (path);
}