mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-27 19:01:43 +02:00
fpvectorial: Improves the code visualize LAS classifications via colors and makes it more common for all LAS format records
git-svn-id: trunk@35065 -
This commit is contained in:
parent
d273b4fcd8
commit
c5deaceba8
@ -6,7 +6,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils, FileUtil, OpenGLContext, Forms, Controls, Graphics,
|
||||
Dialogs, EditBtn, StdCtrls, fpvectorial, gl, glu, lasvectorialreader;
|
||||
Dialogs, EditBtn, StdCtrls, fpvectorial, gl, glu, FPimage, lasvectorialreader;
|
||||
|
||||
type
|
||||
|
||||
@ -53,6 +53,7 @@ var
|
||||
lPoint1, lPoint2, lPoint3: TvPoint;
|
||||
lEntity: TvEntity;
|
||||
lPos1, lPos2, lPos3: T3DPoint;
|
||||
lColor: TFPColor;
|
||||
begin
|
||||
glClearColor(1.0, 1.0, 1.0, 1.0);
|
||||
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
|
||||
@ -131,10 +132,11 @@ begin
|
||||
lPoint3 := lEntity as TvPoint;
|
||||
|
||||
glBegin(GL_TRIANGLES); // Drawing Using Triangles
|
||||
lPos1 := lPoint1.GetNormalizedPos(VecPage);
|
||||
lPos2 := lPoint2.GetNormalizedPos(VecPage);
|
||||
lPos3 := lPoint3.GetNormalizedPos(VecPage);
|
||||
glColor3f(0.0,0.0,1.0); // Set The Color To Blue
|
||||
lPos1 := lPoint1.GetNormalizedPos(VecPage, -1, 1);
|
||||
lPos2 := lPoint2.GetNormalizedPos(VecPage, -1, 1);
|
||||
lPos3 := lPoint3.GetNormalizedPos(VecPage, -1, 1);
|
||||
lColor := lPoint1.Pen.Color;
|
||||
glColor3f(lColor.Red / $FFFF, lColor.Green / $FFFF, lColor.Blue / $FFFF);
|
||||
glVertex3f(lPos1.X, lPos1.Y, lPos1.Z);
|
||||
glVertex3f(lPos2.X, lPos2.Y, lPos2.Z);
|
||||
glVertex3f(lPos3.X, lPos3.Y, lPos3.Z);
|
||||
|
@ -304,7 +304,7 @@ type
|
||||
|
||||
TvPoint = class(TvEntityWithPen)
|
||||
public
|
||||
function GetNormalizedPos(APage: TvVectorialPage): T3DPoint;
|
||||
function GetNormalizedPos(APage: TvVectorialPage; ANewMin, ANewMax: Double): T3DPoint;
|
||||
end;
|
||||
|
||||
{ TvVectorialDocument }
|
||||
@ -403,7 +403,7 @@ type
|
||||
// Dimensions
|
||||
procedure AddAlignedDimension(BaseLeft, BaseRight, DimLeft, DimRight: T3DPoint);
|
||||
//
|
||||
procedure AddPoint(AX, AY, AZ: Double);
|
||||
function AddPoint(AX, AY, AZ: Double): TvPoint;
|
||||
end;
|
||||
|
||||
{@@ TvVectorialReader class reference type }
|
||||
@ -559,11 +559,11 @@ end;
|
||||
|
||||
{ TvPoint }
|
||||
|
||||
function TvPoint.GetNormalizedPos(APage: TvVectorialPage): T3DPoint;
|
||||
function TvPoint.GetNormalizedPos(APage: TvVectorialPage; ANewMin, ANewMax: Double): T3DPoint;
|
||||
begin
|
||||
Result.X := (X - APage.MinX) / (APage.MaxX - APage.MinX);
|
||||
Result.Y := (Y - APage.MinY) / (APage.MaxY - APage.MinY);
|
||||
Result.Z := (Z - APage.MinZ) / (APage.MaxZ - APage.MinZ);
|
||||
Result.X := (X - APage.MinX) * (ANewMax - ANewMin) / (APage.MaxX - APage.MinX) + ANewMin;
|
||||
Result.Y := (Y - APage.MinY) * (ANewMax - ANewMin) / (APage.MaxY - APage.MinY) + ANewMin;
|
||||
Result.Z := (Z - APage.MinZ) * (ANewMax - ANewMin) / (APage.MaxZ - APage.MinZ) + ANewMin;
|
||||
end;
|
||||
|
||||
constructor TvEntityWithPen.Create;
|
||||
@ -959,7 +959,7 @@ begin
|
||||
AddEntity(lDim);
|
||||
end;
|
||||
|
||||
procedure TvVectorialPage.AddPoint(AX, AY, AZ: Double);
|
||||
function TvVectorialPage.AddPoint(AX, AY, AZ: Double): TvPoint;
|
||||
var
|
||||
lPoint: TvPoint;
|
||||
begin
|
||||
@ -968,6 +968,7 @@ begin
|
||||
lPoint.Y := AY;
|
||||
lPoint.Z := AZ;
|
||||
AddEntity(lPoint);
|
||||
Result := lPoint;
|
||||
end;
|
||||
|
||||
{ TvText }
|
||||
|
@ -27,6 +27,7 @@ interface
|
||||
|
||||
uses
|
||||
Classes, SysUtils,
|
||||
fpcanvas, fpimage,
|
||||
//avisozlib,
|
||||
fpvectorial;
|
||||
|
||||
@ -230,6 +231,9 @@ var
|
||||
lRecord0: TLASPointDataRecordFormat0;
|
||||
lRecord1: TLASPointDataRecordFormat1;
|
||||
lFirstPoint: Boolean = True;
|
||||
lPoint: TvPoint;
|
||||
lClassification: Integer = -1;
|
||||
lColor: TFPColor;
|
||||
begin
|
||||
// Clear and add the first page
|
||||
AData.Clear;
|
||||
@ -264,44 +268,70 @@ begin
|
||||
|
||||
// Read the point data
|
||||
AStream.Position := InitialPos + PublicHeaderBlock_1_0.OffsetToPointData;
|
||||
case PublicHeaderBlock_1_0.PointDataFormatID of
|
||||
while AStream.Position < AStream.Size do
|
||||
begin
|
||||
case PublicHeaderBlock_1_0.PointDataFormatID of
|
||||
0:
|
||||
begin
|
||||
while AStream.Position < AStream.Size do
|
||||
begin
|
||||
AStream.ReadBuffer(lRecord0, SizeOf(TLASPointDataRecordFormat0));
|
||||
lPage.AddPoint(lRecord0.X, lRecord0.Y, lRecord0.Z);
|
||||
end;
|
||||
AStream.ReadBuffer(lRecord0, SizeOf(TLASPointDataRecordFormat0));
|
||||
lClassification := lRecord0.Classification;
|
||||
lPoint := lPage.AddPoint(lRecord0.X, lRecord0.Y, lRecord0.Z);
|
||||
end;
|
||||
1:
|
||||
begin
|
||||
while AStream.Position < AStream.Size do
|
||||
begin
|
||||
AStream.ReadBuffer(lRecord1, SizeOf(TLASPointDataRecordFormat1));
|
||||
lPage.AddPoint(lRecord1.X, lRecord1.Y, lRecord1.Z);
|
||||
|
||||
if lFirstPoint then
|
||||
begin
|
||||
// Correct the min and max
|
||||
lPage.MinX := lRecord1.X;
|
||||
lPage.MinY := lRecord1.Y;
|
||||
lPage.MinZ := lRecord1.Z;
|
||||
lPage.MaxX := lRecord1.X;
|
||||
lPage.MaxY := lRecord1.Y;
|
||||
lPage.MaxZ := lRecord1.Z;
|
||||
|
||||
lFirstPoint := False;
|
||||
end;
|
||||
|
||||
// Correct the min and max
|
||||
if lPage.MinX > lRecord1.X then lPage.MinX := lRecord1.X;
|
||||
if lPage.MinY > lRecord1.Y then lPage.MinY := lRecord1.Y;
|
||||
if lPage.MinZ > lRecord1.Z then lPage.MinZ := lRecord1.Z;
|
||||
if lPage.MaxX < lRecord1.X then lPage.MaxX := lRecord1.X;
|
||||
if lPage.MaxY < lRecord1.Y then lPage.MaxY := lRecord1.Y;
|
||||
if lPage.MaxZ < lRecord1.Z then lPage.MaxZ := lRecord1.Z;
|
||||
end;
|
||||
AStream.ReadBuffer(lRecord1, SizeOf(TLASPointDataRecordFormat1));
|
||||
lClassification := lRecord1.Classification;
|
||||
lPoint := lPage.AddPoint(lRecord1.X, lRecord1.Y, lRecord1.Z);
|
||||
end;
|
||||
end;
|
||||
|
||||
// Correct the min and max
|
||||
if lFirstPoint then
|
||||
begin
|
||||
lPage.MinX := lPoint.X;
|
||||
lPage.MinY := lPoint.Y;
|
||||
lPage.MinZ := lPoint.Z;
|
||||
lPage.MaxX := lPoint.X;
|
||||
lPage.MaxY := lPoint.Y;
|
||||
lPage.MaxZ := lPoint.Z;
|
||||
|
||||
lFirstPoint := False;
|
||||
end
|
||||
else
|
||||
begin
|
||||
if lPage.MinX > lPoint.X then lPage.MinX := lPoint.X;
|
||||
if lPage.MinY > lPoint.Y then lPage.MinY := lPoint.Y;
|
||||
if lPage.MinZ > lPoint.Z then lPage.MinZ := lPoint.Z;
|
||||
if lPage.MaxX < lPoint.X then lPage.MaxX := lPoint.X;
|
||||
if lPage.MaxY < lPoint.Y then lPage.MaxY := lPoint.Y;
|
||||
if lPage.MaxZ < lPoint.Z then lPage.MaxZ := lPoint.Z;
|
||||
end;
|
||||
|
||||
// Set a color if desired
|
||||
case lClassification of
|
||||
// Table 4.9 - ASPRS Standard LIDAR Point Classes
|
||||
// Classification Value
|
||||
// 0 Created, never classified
|
||||
// 1 Unclassified1
|
||||
// 2 Ground
|
||||
2: lColor := colMaroon;
|
||||
// 3 Low Vegetation
|
||||
3: lColor := colGreen;
|
||||
// 4 Medium Vegetation
|
||||
4: lColor := colGreen;
|
||||
// 5 High Vegetation
|
||||
5: lColor := colDkGreen;
|
||||
// 6 Building
|
||||
6: lColor := colGray;
|
||||
// 7 Low Point (noise)
|
||||
// 8 Model Key-point (mass point)
|
||||
// 9 Water
|
||||
9: lColor := colBlue;
|
||||
else
|
||||
lColor := colBlack;
|
||||
end;
|
||||
|
||||
lPoint.Pen.Color := lColor;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user