| 142 | } |
| 143 | |
| 144 | void DracoReader::addDimensions(PointLayoutPtr layout) |
| 145 | { |
| 146 | using namespace draco; |
| 147 | |
| 148 | |
| 149 | //iterate and collect information on draco attributes |
| 150 | for (int i=0; i < m_pc->num_attributes(); ++i) |
| 151 | { |
| 152 | const PointAttribute* attr = m_pc->GetAttributeByUniqueId(i); |
| 153 | if (attr == nullptr) |
| 154 | throw new pdal_error("Invalid draco attribute configuration"); |
| 155 | const AttributeMetadata* attr_metadata = m_pc->GetAttributeMetadataByAttributeId(i); |
| 156 | |
| 157 | //get types |
| 158 | DataType dt = attr->data_type(); |
| 159 | Dimension::Type pt = getPdalType(dt); |
| 160 | GeometryAttribute::Type at = attr->attribute_type(); |
| 161 | |
| 162 | int8_t nc = attr->num_components(); |
| 163 | log()->get(LogLevel::Debug) << "Dimension read: " |
| 164 | << GeometryAttribute::TypeToString(at) |
| 165 | << ", Data type: " << Dimension::interpretationName(pt) |
| 166 | << std::endl;; |
| 167 | std::string name; |
| 168 | if (attr_metadata) |
| 169 | { |
| 170 | attr_metadata->GetEntryString("name", &name); |
| 171 | log()->get(LogLevel::Debug) << " Generic type name: " |
| 172 | << name |
| 173 | << std::endl; |
| 174 | } |
| 175 | switch (at) |
| 176 | { |
| 177 | case GeometryAttribute::POSITION: |
| 178 | { |
| 179 | addOneDimension(Dimension::Id::X, attr, layout, i, 0); |
| 180 | addOneDimension(Dimension::Id::Y, attr, layout, i, 1); |
| 181 | addOneDimension(Dimension::Id::Z, attr, layout, i, 2); |
| 182 | break; |
| 183 | } |
| 184 | case GeometryAttribute::NORMAL: |
| 185 | { |
| 186 | addOneDimension(Dimension::Id::NormalX, attr, layout, i, 0); |
| 187 | addOneDimension(Dimension::Id::NormalY, attr, layout, i, 1); |
| 188 | addOneDimension(Dimension::Id::NormalZ, attr, layout, i, 2); |
| 189 | break; |
| 190 | } |
| 191 | case GeometryAttribute::COLOR: |
| 192 | { |
| 193 | addOneDimension(Dimension::Id::Red, attr, layout, i, 0); |
| 194 | addOneDimension(Dimension::Id::Green, attr, layout, i, 1); |
| 195 | addOneDimension(Dimension::Id::Blue, attr, layout, i, 2); |
| 196 | break; |
| 197 | } |
| 198 | case GeometryAttribute::TEX_COORD: |
| 199 | { |
| 200 | addOneDimension(Dimension::Id::TextureU, attr, layout, i, 0); |
| 201 | addOneDimension(Dimension::Id::TextureV, attr, layout, i, 1); |
nothing calls this directly
no test coverage detected