mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-28 21:20:46 +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
|
uses
|
||||||
Classes, SysUtils, FileUtil, OpenGLContext, Forms, Controls, Graphics,
|
Classes, SysUtils, FileUtil, OpenGLContext, Forms, Controls, Graphics,
|
||||||
Dialogs, EditBtn, StdCtrls, fpvectorial, gl, glu, lasvectorialreader;
|
Dialogs, EditBtn, StdCtrls, fpvectorial, gl, glu, FPimage, lasvectorialreader;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
|
||||||
@ -53,6 +53,7 @@ var
|
|||||||
lPoint1, lPoint2, lPoint3: TvPoint;
|
lPoint1, lPoint2, lPoint3: TvPoint;
|
||||||
lEntity: TvEntity;
|
lEntity: TvEntity;
|
||||||
lPos1, lPos2, lPos3: T3DPoint;
|
lPos1, lPos2, lPos3: T3DPoint;
|
||||||
|
lColor: TFPColor;
|
||||||
begin
|
begin
|
||||||
glClearColor(1.0, 1.0, 1.0, 1.0);
|
glClearColor(1.0, 1.0, 1.0, 1.0);
|
||||||
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
|
||||||
@ -131,10 +132,11 @@ begin
|
|||||||
lPoint3 := lEntity as TvPoint;
|
lPoint3 := lEntity as TvPoint;
|
||||||
|
|
||||||
glBegin(GL_TRIANGLES); // Drawing Using Triangles
|
glBegin(GL_TRIANGLES); // Drawing Using Triangles
|
||||||
lPos1 := lPoint1.GetNormalizedPos(VecPage);
|
lPos1 := lPoint1.GetNormalizedPos(VecPage, -1, 1);
|
||||||
lPos2 := lPoint2.GetNormalizedPos(VecPage);
|
lPos2 := lPoint2.GetNormalizedPos(VecPage, -1, 1);
|
||||||
lPos3 := lPoint3.GetNormalizedPos(VecPage);
|
lPos3 := lPoint3.GetNormalizedPos(VecPage, -1, 1);
|
||||||
glColor3f(0.0,0.0,1.0); // Set The Color To Blue
|
lColor := lPoint1.Pen.Color;
|
||||||
|
glColor3f(lColor.Red / $FFFF, lColor.Green / $FFFF, lColor.Blue / $FFFF);
|
||||||
glVertex3f(lPos1.X, lPos1.Y, lPos1.Z);
|
glVertex3f(lPos1.X, lPos1.Y, lPos1.Z);
|
||||||
glVertex3f(lPos2.X, lPos2.Y, lPos2.Z);
|
glVertex3f(lPos2.X, lPos2.Y, lPos2.Z);
|
||||||
glVertex3f(lPos3.X, lPos3.Y, lPos3.Z);
|
glVertex3f(lPos3.X, lPos3.Y, lPos3.Z);
|
||||||
|
@ -304,7 +304,7 @@ type
|
|||||||
|
|
||||||
TvPoint = class(TvEntityWithPen)
|
TvPoint = class(TvEntityWithPen)
|
||||||
public
|
public
|
||||||
function GetNormalizedPos(APage: TvVectorialPage): T3DPoint;
|
function GetNormalizedPos(APage: TvVectorialPage; ANewMin, ANewMax: Double): T3DPoint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TvVectorialDocument }
|
{ TvVectorialDocument }
|
||||||
@ -403,7 +403,7 @@ type
|
|||||||
// Dimensions
|
// Dimensions
|
||||||
procedure AddAlignedDimension(BaseLeft, BaseRight, DimLeft, DimRight: T3DPoint);
|
procedure AddAlignedDimension(BaseLeft, BaseRight, DimLeft, DimRight: T3DPoint);
|
||||||
//
|
//
|
||||||
procedure AddPoint(AX, AY, AZ: Double);
|
function AddPoint(AX, AY, AZ: Double): TvPoint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{@@ TvVectorialReader class reference type }
|
{@@ TvVectorialReader class reference type }
|
||||||
@ -559,11 +559,11 @@ end;
|
|||||||
|
|
||||||
{ TvPoint }
|
{ TvPoint }
|
||||||
|
|
||||||
function TvPoint.GetNormalizedPos(APage: TvVectorialPage): T3DPoint;
|
function TvPoint.GetNormalizedPos(APage: TvVectorialPage; ANewMin, ANewMax: Double): T3DPoint;
|
||||||
begin
|
begin
|
||||||
Result.X := (X - APage.MinX) / (APage.MaxX - APage.MinX);
|
Result.X := (X - APage.MinX) * (ANewMax - ANewMin) / (APage.MaxX - APage.MinX) + ANewMin;
|
||||||
Result.Y := (Y - APage.MinY) / (APage.MaxY - APage.MinY);
|
Result.Y := (Y - APage.MinY) * (ANewMax - ANewMin) / (APage.MaxY - APage.MinY) + ANewMin;
|
||||||
Result.Z := (Z - APage.MinZ) / (APage.MaxZ - APage.MinZ);
|
Result.Z := (Z - APage.MinZ) * (ANewMax - ANewMin) / (APage.MaxZ - APage.MinZ) + ANewMin;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TvEntityWithPen.Create;
|
constructor TvEntityWithPen.Create;
|
||||||
@ -959,7 +959,7 @@ begin
|
|||||||
AddEntity(lDim);
|
AddEntity(lDim);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TvVectorialPage.AddPoint(AX, AY, AZ: Double);
|
function TvVectorialPage.AddPoint(AX, AY, AZ: Double): TvPoint;
|
||||||
var
|
var
|
||||||
lPoint: TvPoint;
|
lPoint: TvPoint;
|
||||||
begin
|
begin
|
||||||
@ -968,6 +968,7 @@ begin
|
|||||||
lPoint.Y := AY;
|
lPoint.Y := AY;
|
||||||
lPoint.Z := AZ;
|
lPoint.Z := AZ;
|
||||||
AddEntity(lPoint);
|
AddEntity(lPoint);
|
||||||
|
Result := lPoint;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TvText }
|
{ TvText }
|
||||||
|
@ -27,6 +27,7 @@ interface
|
|||||||
|
|
||||||
uses
|
uses
|
||||||
Classes, SysUtils,
|
Classes, SysUtils,
|
||||||
|
fpcanvas, fpimage,
|
||||||
//avisozlib,
|
//avisozlib,
|
||||||
fpvectorial;
|
fpvectorial;
|
||||||
|
|
||||||
@ -230,6 +231,9 @@ var
|
|||||||
lRecord0: TLASPointDataRecordFormat0;
|
lRecord0: TLASPointDataRecordFormat0;
|
||||||
lRecord1: TLASPointDataRecordFormat1;
|
lRecord1: TLASPointDataRecordFormat1;
|
||||||
lFirstPoint: Boolean = True;
|
lFirstPoint: Boolean = True;
|
||||||
|
lPoint: TvPoint;
|
||||||
|
lClassification: Integer = -1;
|
||||||
|
lColor: TFPColor;
|
||||||
begin
|
begin
|
||||||
// Clear and add the first page
|
// Clear and add the first page
|
||||||
AData.Clear;
|
AData.Clear;
|
||||||
@ -264,44 +268,70 @@ begin
|
|||||||
|
|
||||||
// Read the point data
|
// Read the point data
|
||||||
AStream.Position := InitialPos + PublicHeaderBlock_1_0.OffsetToPointData;
|
AStream.Position := InitialPos + PublicHeaderBlock_1_0.OffsetToPointData;
|
||||||
|
while AStream.Position < AStream.Size do
|
||||||
|
begin
|
||||||
case PublicHeaderBlock_1_0.PointDataFormatID of
|
case PublicHeaderBlock_1_0.PointDataFormatID of
|
||||||
0:
|
0:
|
||||||
begin
|
|
||||||
while AStream.Position < AStream.Size do
|
|
||||||
begin
|
begin
|
||||||
AStream.ReadBuffer(lRecord0, SizeOf(TLASPointDataRecordFormat0));
|
AStream.ReadBuffer(lRecord0, SizeOf(TLASPointDataRecordFormat0));
|
||||||
lPage.AddPoint(lRecord0.X, lRecord0.Y, lRecord0.Z);
|
lClassification := lRecord0.Classification;
|
||||||
end;
|
lPoint := lPage.AddPoint(lRecord0.X, lRecord0.Y, lRecord0.Z);
|
||||||
end;
|
end;
|
||||||
1:
|
1:
|
||||||
begin
|
|
||||||
while AStream.Position < AStream.Size do
|
|
||||||
begin
|
begin
|
||||||
AStream.ReadBuffer(lRecord1, SizeOf(TLASPointDataRecordFormat1));
|
AStream.ReadBuffer(lRecord1, SizeOf(TLASPointDataRecordFormat1));
|
||||||
lPage.AddPoint(lRecord1.X, lRecord1.Y, lRecord1.Z);
|
lClassification := lRecord1.Classification;
|
||||||
|
lPoint := lPage.AddPoint(lRecord1.X, lRecord1.Y, lRecord1.Z);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
// Correct the min and max
|
||||||
if lFirstPoint then
|
if lFirstPoint then
|
||||||
begin
|
begin
|
||||||
// Correct the min and max
|
lPage.MinX := lPoint.X;
|
||||||
lPage.MinX := lRecord1.X;
|
lPage.MinY := lPoint.Y;
|
||||||
lPage.MinY := lRecord1.Y;
|
lPage.MinZ := lPoint.Z;
|
||||||
lPage.MinZ := lRecord1.Z;
|
lPage.MaxX := lPoint.X;
|
||||||
lPage.MaxX := lRecord1.X;
|
lPage.MaxY := lPoint.Y;
|
||||||
lPage.MaxY := lRecord1.Y;
|
lPage.MaxZ := lPoint.Z;
|
||||||
lPage.MaxZ := lRecord1.Z;
|
|
||||||
|
|
||||||
lFirstPoint := False;
|
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;
|
end;
|
||||||
|
|
||||||
// Correct the min and max
|
// Set a color if desired
|
||||||
if lPage.MinX > lRecord1.X then lPage.MinX := lRecord1.X;
|
case lClassification of
|
||||||
if lPage.MinY > lRecord1.Y then lPage.MinY := lRecord1.Y;
|
// Table 4.9 - ASPRS Standard LIDAR Point Classes
|
||||||
if lPage.MinZ > lRecord1.Z then lPage.MinZ := lRecord1.Z;
|
// Classification Value
|
||||||
if lPage.MaxX < lRecord1.X then lPage.MaxX := lRecord1.X;
|
// 0 Created, never classified
|
||||||
if lPage.MaxY < lRecord1.Y then lPage.MaxY := lRecord1.Y;
|
// 1 Unclassified1
|
||||||
if lPage.MaxZ < lRecord1.Z then lPage.MaxZ := lRecord1.Z;
|
// 2 Ground
|
||||||
end;
|
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;
|
end;
|
||||||
|
|
||||||
|
lPoint.Pen.Color := lColor;
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user