MCPcopy Create free account
hub / github.com/ErrorAtLine0/infinipaint / readInputFromFile

Function readInputFromFile

include/CDT/tests/cdt.test.cpp:92–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

90
91template <typename T>
92std::pair<Vertices<T>, std::vector<Edge> >
93readInputFromFile(const std::string& fileName)
94{
95 std::ifstream f(fileName);
96 if(!f.is_open())
97 {
98 ENHANCED_THROW(
99 std::runtime_error, "Could not open file '" + fileName + '\'');
100 }
101 f.precision(std::numeric_limits<T>::digits10 + 1);
102 IndexSizeType nVerts;
103 IndexSizeType nEdges;
104 f >> nVerts >> nEdges;
105
106 // Read vertices
107 Vertices<T> vv;
108 vv.reserve(nVerts);
109 for(std::size_t i = 0; i < nVerts; ++i)
110 {
111 T x, y;
112 f >> x >> y;
113 vv.emplace_back(x, y);
114 }
115 // Read edges
116 std::vector<Edge> ee;
117 for(std::size_t i = 0; i < nEdges; ++i)
118 {
119 VertInd v1, v2;
120 f >> v1 >> v2;
121 ee.emplace_back(v1, v2);
122 }
123 return std::make_pair(vv, ee);
124}
125
126template <typename T>
127void saveInputToFile(

Callers

nothing calls this directly

Calls 2

precisionMethod · 0.45
reserveMethod · 0.45

Tested by

no test coverage detected