diff --git a/src/Mod/Points/App/PointsAlgos.cpp b/src/Mod/Points/App/PointsAlgos.cpp index e832964855..d8b66bb765 100644 --- a/src/Mod/Points/App/PointsAlgos.cpp +++ b/src/Mod/Points/App/PointsAlgos.cpp @@ -1336,11 +1336,21 @@ public: return colors; } + std::vector getItensity() const + { + return intensity; + } + const PointKernel& getPoints() const { return points; } + const std::vector& getNormals() const + { + return normals; + } + private: void readData3D(const e57::VectorNode& data3D) { @@ -1361,12 +1371,17 @@ private: bool inty = false; bool inv_state = false; unsigned cnt_xyz = 0; + unsigned cnt_nor = 0; unsigned cnt_rgb = 0; std::vector xData; std::vector yData; std::vector zData; + std::vector xNormal; + std::vector yNormal; + std::vector zNormal; + std::vector redData; std::vector greenData; std::vector blueData; @@ -1388,6 +1403,9 @@ private: if ((node.type() == e57::E57_FLOAT) || (node.type() == e57::E57_SCALED_INTEGER)) { if (readCartesian(node, proto)) { + } + else if (readNormal(node, proto)) { + } else if (readItensity(node, proto)) { @@ -1457,6 +1475,51 @@ private: return false; } + bool readNormal(const e57::Node& node, Proto& proto) + { + if (node.elementName() == "nor:normalX") { + proto.cnt_nor++; + proto.sdb.emplace_back( + imfi + , node.elementName() + , proto.xNormal.data() + , buf_size + , true + , true + + ); + return true; + } + else if (node.elementName() == "nor:normalY") { + proto.cnt_nor++; + proto.sdb.emplace_back( + imfi + , node.elementName() + , proto.yNormal.data() + , buf_size + , true + , true + + ); + return true; + } + else if (node.elementName() == "nor:normalZ") { + proto.cnt_nor++; + proto.sdb.emplace_back( + imfi + , node.elementName() + , proto.zNormal.data() + , buf_size + , true + , true + + ); + return true; + } + + return false; + } + bool readCartesianInvalidState(const e57::Node& node, Proto& proto) { if (node.elementName() == "cartesianInvalidState") { @@ -1563,6 +1626,8 @@ private: Base::Vector3d pt, last; e57::CompressedVectorReader cvr(cvn.reader(proto.sdb)); bool hasColor = (proto.cnt_rgb == 3) && useColor; + bool hasItensity = proto.inty; + bool hasNormal = (proto.cnt_nor == 3); bool hasState = proto.inv_state && checkState; bool filter = false; @@ -1587,6 +1652,12 @@ private: if (hasColor) { colors.push_back(getColor(proto, i)); } + if (hasItensity) { + intensity.push_back(proto.intensity[i]); + } + if (hasNormal) { + normals.push_back(getNormal(proto, i, hasPlacement, plm.getRotation())); + } } } } @@ -1604,15 +1675,24 @@ private: return pt; } + Base::Vector3f getNormal(const Proto& proto, size_t index, bool hasPlacement, const Base::Rotation& rot) const + { + Base::Vector3f pt; + pt.x = proto.xNormal[index]; + pt.y = proto.yNormal[index]; + pt.z = proto.zNormal[index]; + if (hasPlacement) { + rot.multVec(pt, pt); + } + return pt; + } + App::Color getColor(const Proto& proto, size_t index) const { App::Color c; c.r = static_cast(proto.redData[index]) / 255.0f; c.g = static_cast(proto.greenData[index]) / 255.0f; c.b = static_cast(proto.blueData[index]) / 255.0f; - if (proto.inty) { - c.a = proto.intensity[index]; - } return c; } @@ -1622,6 +1702,10 @@ private: proto.yData.resize(buf_size); proto.zData.resize(buf_size); + proto.xNormal.resize(buf_size); + proto.yNormal.resize(buf_size); + proto.zNormal.resize(buf_size); + proto.redData.resize(buf_size); proto.greenData.resize(buf_size); proto.blueData.resize(buf_size); @@ -1668,7 +1752,9 @@ private: double minDistance; const size_t buf_size = 1024; std::vector colors; + std::vector intensity; PointKernel points; + std::vector normals; }; } @@ -1689,7 +1775,9 @@ void E57Reader::read(const std::string& filename) E57ReaderImp reader(filename, useColor, checkState, minDistance); reader.read(); points = reader.getPoints(); + normals = reader.getNormals(); colors = reader.getColors(); + intensity = reader.getItensity(); } catch (const Base::BadFormatError&) { throw;