MCPcopy Create free account
hub / github.com/PDAL/PDAL / _fillMinMaxData

Function _fillMinMaxData

plugins/e57/libE57Format/src/E57SimpleWriter.cpp:42–139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

40 /// - time stamps
41 template <typename COORDTYPE>
42 void _fillMinMaxData( e57::Data3D &ioData3DHeader,
43 const e57::Data3DPointsData_t<COORDTYPE> &inBuffers )
44 {
45 static_assert( std::is_floating_point<COORDTYPE>::value, "Floating point type required." );
46
47 auto &pointFields = ioData3DHeader.pointFields;
48
49 constexpr COORDTYPE cMin = std::numeric_limits<COORDTYPE>::lowest();
50 constexpr COORDTYPE cMax = std::numeric_limits<COORDTYPE>::max();
51
52 // IF we are using scaled ints for cartesian points
53 // AND we haven't set either min or max
54 // THEN calculate them from the points
55 auto pointRangeMinimum = cMax;
56 auto pointRangeMaximum = cMin;
57
58 const bool writePointRange =
59 ( pointFields.pointRangeNodeType == e57::NumericalNodeType::ScaledInteger ) &&
60 ( pointFields.pointRangeMinimum == cMin ) && ( pointFields.pointRangeMaximum == cMax );
61
62 // IF we are using scaled ints for spherical angles
63 // AND we haven't set either min or max
64 // THEN calculate them from the points
65 auto angleMinimum = cMax;
66 auto angleMaximum = cMin;
67
68 const bool writeAngle =
69 ( pointFields.angleNodeType == e57::NumericalNodeType::ScaledInteger ) &&
70 ( pointFields.angleMinimum == cMin ) && ( pointFields.angleMaximum == cMax );
71
72 // IF we are using scaled ints for timestamps
73 // AND we haven't set either min or max
74 // THEN calculate them from the points
75 double timeMinimum = std::numeric_limits<double>::max();
76 double timeMaximum = std::numeric_limits<double>::lowest();
77
78 const bool writeTimeStamp =
79 pointFields.timeStampField &&
80 ( pointFields.timeNodeType == e57::NumericalNodeType::ScaledInteger ) &&
81 ( pointFields.timeMinimum == cMin ) && ( pointFields.timeMaximum == cMax );
82
83 // Now run through the points and set the things we need to
84 for ( size_t i = 0; i < ioData3DHeader.pointCount; ++i )
85 {
86 if ( writePointRange && pointFields.cartesianXField )
87 {
88 pointRangeMinimum = std::min( inBuffers.cartesianX[i], pointRangeMinimum );
89 pointRangeMinimum = std::min( inBuffers.cartesianY[i], pointRangeMinimum );
90 pointRangeMinimum = std::min( inBuffers.cartesianZ[i], pointRangeMinimum );
91
92 pointRangeMaximum = std::max( inBuffers.cartesianX[i], pointRangeMaximum );
93 pointRangeMaximum = std::max( inBuffers.cartesianY[i], pointRangeMaximum );
94 pointRangeMaximum = std::max( inBuffers.cartesianZ[i], pointRangeMaximum );
95 }
96
97 if ( writePointRange && pointFields.sphericalRangeField )
98 {
99 // Note that the writer code uses pointRangeMinimum/pointRangeMaximum

Callers 1

WriteData3DDataMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected