当前位置: 首页>>代码示例>>C++>>正文


C++ VertexList::clear方法代码示例

本文整理汇总了C++中VertexList::clear方法的典型用法代码示例。如果您正苦于以下问题:C++ VertexList::clear方法的具体用法?C++ VertexList::clear怎么用?C++ VertexList::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在VertexList的用法示例。


在下文中一共展示了VertexList::clear方法的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);
      }
开发者ID:MRtrix3,项目名称:mrtrix3,代码行数:42,代码来源:freesurfer.cpp


注:本文中的VertexList::clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。