#include "ct_abstractlaspointformat.h" #include "ct_iterator/ct_pointiterator.h" CT_AbstractLASPointFormat::CT_AbstractLASPointFormat() { m_lasHeader = NULL; } CT_AbstractLASPointFormat::~CT_AbstractLASPointFormat() { clearInfos(); } void CT_AbstractLASPointFormat::setHeader(const CT_LASHeader *header) { m_lasHeader = (CT_LASHeader*)header; } void CT_AbstractLASPointFormat::setAttributes(const QHash &attributes) { m_attributes = attributes; } const QHash &CT_AbstractLASPointFormat::attributes() const { return m_attributes; } bool CT_AbstractLASPointFormat::initWrite() { clearInfos(); // get type of attribute to search for point format X (from derivated class) QList types = typesToSearch(); QListIterator itT(types); // for each type of attribute while(itT.hasNext()) { CT_LasDefine::LASPointAttributesType type = itT.next(); // get it in the attributes map CT_AbstractPointAttributesScalar *scalar = m_attributes.value(type, NULL); // if exist if(scalar != NULL) { // get the point cloud index const CT_AbstractPointCloudIndex *indexes = scalar->getPointCloudIndex(); if(indexes != NULL) { size_t pIndex = 0; CT_PointIterator it(indexes); // for each index while(it.hasNext()) { // get info for this global point index CT_LasPointInfo *info = m_infos.value(it.next().cIndex(), NULL); // if info doesn't already exist if(info == NULL) { // create it info = new CT_LasPointInfo(); // insert in the info map m_infos.insert(it.cIndex(), info); } // and set it the attribute info->setAttribute(type, scalar, pIndex); ++pIndex; } } } } return true; } void CT_AbstractLASPointFormat::clearInfos() { qDeleteAll(m_infos.begin(), m_infos.end()); m_infos.clear(); }