MCPcopy Create free account
hub / github.com/Kitware/VTK / ReadPointRecordData

Method ReadPointRecordData

IO/LAS/vtkLASReader.cxx:80–156  ·  view source on GitHub ↗

------------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

78
79//------------------------------------------------------------------------------
80void vtkLASReader::ReadPointRecordData(liblas::Reader& reader, vtkPolyData* pointsPolyData)
81{
82 vtkNew<vtkPoints> points;
83 // scalars associated with points
84 vtkNew<vtkUnsignedShortArray> color;
85 color->SetName("color");
86 color->SetNumberOfComponents(3);
87 vtkNew<vtkUnsignedShortArray> classification;
88 classification->SetName("classification");
89 classification->SetNumberOfComponents(1);
90 vtkNew<vtkUnsignedShortArray> intensity;
91 intensity->SetName("intensity");
92 intensity->SetNumberOfComponents(1);
93
94 liblas::Header header = liblas::Header(reader.GetHeader());
95 std::valarray<double> scale = { header.GetScaleX(), header.GetScaleY(), header.GetScaleZ() };
96 std::valarray<double> offset = { header.GetOffsetX(), header.GetOffsetY(), header.GetOffsetZ() };
97 liblas::PointFormatName pointFormat = header.GetDataFormatId();
98 int pointRecordsCount = header.GetPointRecordsCount();
99
100 for (int i = 0; i < pointRecordsCount && reader.ReadNextPoint(); i++)
101 {
102 liblas::Point const& p = reader.GetPoint();
103 std::valarray<double> lasPoint = { p.GetX(), p.GetY(), p.GetZ() };
104 points->InsertNextPoint(&lasPoint[0]);
105 // std::valarray<double> point = lasPoint * scale + offset;
106 // We have seen a file where the scaled points were much smaller than the offset
107 // So, all points ended up in the same place.
108 std::valarray<double> point = lasPoint * scale;
109 switch (pointFormat)
110 {
111 case liblas::ePointFormat2:
112 case liblas::ePointFormat3:
113 case liblas::ePointFormat5:
114 {
115 unsigned short c[3];
116 c[0] = p.GetColor().GetRed();
117 c[1] = p.GetColor().GetGreen();
118 c[2] = p.GetColor().GetBlue();
119 color->InsertNextTypedTuple(c);
120 intensity->InsertNextValue(p.GetIntensity());
121 }
122 break;
123
124 case liblas::ePointFormat0:
125 case liblas::ePointFormat1:
126 classification->InsertNextValue(p.GetClassification().GetClass());
127 intensity->InsertNextValue(p.GetIntensity());
128 break;
129
130 case liblas::ePointFormatUnknown:
131 default:
132 intensity->InsertNextValue(p.GetIntensity());
133 break;
134 }
135 }
136
137 pointsPolyData->SetPoints(points);

Callers 1

RequestDataMethod · 0.95

Calls 14

GetHeaderMethod · 0.80
GetZMethod · 0.80
GetClassificationMethod · 0.80
HeaderClass · 0.70
SetNameMethod · 0.45
SetNumberOfComponentsMethod · 0.45
GetPointMethod · 0.45
GetXMethod · 0.45
InsertNextPointMethod · 0.45
GetColorMethod · 0.45
InsertNextValueMethod · 0.45
SetPointsMethod · 0.45

Tested by

no test coverage detected