/* ---- This file is part of SECONDO. Copyright (C) 2019, Faculty of Mathematics and Computer Science, Database Systems for New Applications. SECONDO is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. SECONDO is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with SECONDO; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA ---- //[<] [\ensuremath{<}] //[>] [\ensuremath{>}] \setcounter{tocdepth}{3} \tableofcontents 1 The DbScanPoint class */ #include "DbScanPoint.h" using namespace pointcloud2; template void DbScanPoint::initialize(bool isLastInSeq /* = true */) { // no need to set _coords at this point _clusterId = SCAN_UNCLASSIFIED; _isLastInSeq = isLastInSeq; } template void DbScanPoint::clearCoords() { for (size_t d = 0; d < dim; ++d) { _coords[d] = 0.0; } } template void DbScanPoint::setCoords(const double coords[dim]) { for (size_t d = 0; d < dim; ++d) { _coords[d] = coords[d]; } } template std::string DbScanPoint::toString() const { std::stringstream sb; sb << "("; for (unsigned d = 0; d < dim; ++d) { if (d > 0) sb << ", "; sb << _coords[d]; } sb << ") | "; if (_clusterId == SCAN_NOISE) sb << "Noise "; else if (_clusterId == SCAN_UNCLASSIFIED) sb << "Cluster UNCLASSIFIED"; else sb << "Cluster " << _clusterId; return sb.str(); } template Rectangle DbScanPoint::getBoundingBox(double expand) const { double minMax[2 * dim]; for (unsigned d = 0; d < dim; ++d) { minMax[2 * d] = _coords[d] - expand; minMax[2 * d + 1] = _coords[d] + expand; } return Rectangle(true, minMax); } template Rectangle2 DbScanPoint::getBoundingBox2(double expand) const { double minMax[2 * dim]; for (unsigned d = 0; d < dim; ++d) { minMax[2 * d] = _coords[d] - expand; minMax[2 * d + 1] = _coords[d] + expand; } return Rectangle2(minMax); } template double DbScanPoint::calculateDistanceSquare( const DbScanPoint& other) const { // TODO: Distanzberechnung vom Referenzsystem abhängig machen? double result = 0.0; for (unsigned d = 0; d < dim; ++d) { double diff = _coords[d] - other._coords[d]; result += diff * diff; } return result; } template void DbScanPoint::copyCoordsFrom(const DbScanPoint& source) { for (unsigned d = 0; d < dim; ++d) _coords[d] = source._coords[d]; } template std::string DbScanPoint::getStringForBBox(const Rectangle& bbox) { std::stringstream sb; for (unsigned d = 0; d < dim; ++d) { if (d > 0) sb << ", "; sb << bbox.MinD(d) << " - " << bbox.MaxD(d); } sb << ")" << endl; return sb.str(); } // ensure defined references for the dimensions needed namespace pointcloud2 { template struct DbScanPoint<3>; template struct DbScanPoint<4>; template struct DbScanPoint<5>; template struct DbScanPoint<6>; }