| 141 | |
| 142 | |
| 143 | MetadataNode DeltaKernel::dump(PointViewPtr& srcView, PointViewPtr& candView, |
| 144 | KD3Index& index, DimIndexMap& dims) |
| 145 | { |
| 146 | MetadataNode root; |
| 147 | |
| 148 | for (PointId id = 0; id < srcView->size(); ++id) |
| 149 | { |
| 150 | PointRef point = srcView->point(id); |
| 151 | PointId candId = index.neighbor(point); |
| 152 | |
| 153 | // It may be faster to put in a special case to avoid having to |
| 154 | // fetch X, Y and Z, more than once but this is simpler and |
| 155 | // I'm thinking in most cases it will make no practical difference. |
| 156 | for (auto di = dims.begin(); di != dims.end(); ++di) |
| 157 | { |
| 158 | DimIndex& d = di->second; |
| 159 | double sv = srcView->getFieldAs<double>(d.m_srcId, id); |
| 160 | double cv = candView->getFieldAs<double>(d.m_candId, candId); |
| 161 | accumulate(d, sv - cv); |
| 162 | } |
| 163 | } |
| 164 | |
| 165 | root.add("source", m_sourceFile); |
| 166 | root.add("candidate", m_candidateFile); |
| 167 | for (auto dpair : dims) |
| 168 | { |
| 169 | DimIndex& d = dpair.second; |
| 170 | |
| 171 | MetadataNode dimNode = root.add(d.m_name); |
| 172 | dimNode.add("min", d.m_min); |
| 173 | dimNode.add("max", d.m_max); |
| 174 | dimNode.add("mean", d.m_avg); |
| 175 | } |
| 176 | return root; |
| 177 | } |
| 178 | |
| 179 | |
| 180 | void DeltaKernel::accumulate(DimIndex& d, double v) |