Skip to content

Commit

Permalink
Gestion fichiers LAS
Browse files Browse the repository at this point in the history
  • Loading branch information
fbecir committed Mar 7, 2024
1 parent 2eba14f commit 1156f7a
Show file tree
Hide file tree
Showing 23 changed files with 154 additions and 111 deletions.
Binary file modified IGNMap/Builds/LinuxMakefile/build/IGNMap
Binary file not shown.
Binary file modified IGNMap/Builds/VisualStudio2022/x64/Release/App/IGNMap.exe
Binary file not shown.
5 changes: 3 additions & 2 deletions IGNMap/Source/GeoBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -325,15 +325,16 @@ bool GeoLAS::Open(std::string filename)
bool GeoLAS::ReadAttributes(std::vector<std::string>& Att)
{
Att.clear();
if (m_Header == nullptr)
if (!ReOpen())
return false;
Att.push_back("Software"); Att.push_back(m_Header->generating_software);
Att.push_back("Version"); Att.push_back(std::to_string(m_Header->version_major) + "." + std::to_string(m_Header->version_minor));
Att.push_back("Point format"); Att.push_back(std::to_string(m_Header->point_data_format));
Att.push_back("Global encoding"); Att.push_back(std::to_string(m_Header->global_encoding));
Att.push_back("Date"); Att.push_back(std::to_string(m_Header->file_creation_day) + "/" + std::to_string(m_Header->file_creation_year));
Att.push_back("Nb Points"); Att.push_back(std::to_string(NbLasPoints()));


CloseIfNeeded();
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion IGNMap/Source/ImageOptionsViewer.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class PixelValuesModel : public juce::TableListBoxModel {
~PixelValuesModel() { ClearPixels(); }

virtual void paintCell(juce::Graphics&, int rowNumber, int columnId, int width, int height, bool rowIsSelected) override;
virtual void paintRowBackground(juce::Graphics&, int rowNumber, int width, int height, bool rowIsSelected) override { ; }
virtual void paintRowBackground(juce::Graphics&, int /*rowNumber*/, int /*width*/, int /*height*/, bool /*rowIsSelected*/) override { ; }
virtual int getNumRows() override { return 2 * WinSize + 1; }
virtual void cellDoubleClicked(int rowNumber, int columnId, const juce::MouseEvent&) override;
virtual juce::String getCellTooltip(int rowNumber, int columnId) override { return GetText(rowNumber, columnId); }
Expand Down
15 changes: 7 additions & 8 deletions IGNMap/Source/MainComponent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ juce::StringArray MainComponent::getMenuBarNames()
return { juce::translate("File"), juce::translate("Edit"), juce::translate("Tools"), juce::translate("View"), "?" };
}

juce::PopupMenu MainComponent::getMenuForIndex(int menuIndex, const juce::String& menuName)
juce::PopupMenu MainComponent::getMenuForIndex(int menuIndex, const juce::String& /*menuName*/)
{
juce::PopupMenu menu;

Expand Down Expand Up @@ -242,7 +242,7 @@ juce::PopupMenu MainComponent::getMenuForIndex(int menuIndex, const juce::String
return menu;
}

void MainComponent::menuItemSelected(int menuItemID, int topLevelMenuIndex)
void MainComponent::menuItemSelected(int menuItemID, int /*topLevelMenuIndex*/)
{
if (menuItemID == 1000)
Test();
Expand Down Expand Up @@ -739,7 +739,6 @@ void MainComponent::Clear()
//==============================================================================
void MainComponent::NewWindow()
{
juce::ToolbarButton* button;
Clear();
sendActionMessage("NewWindow");
juce::Component* component = m_Toolbar.get()->getChildComponent(MainComponentToolbarFactory::Move);
Expand All @@ -755,8 +754,8 @@ void MainComponent::NewWindow()
//==============================================================================
void MainComponent::AboutIGNMap()
{
juce::String version = "0.0.3";
juce::String info = "28/02/2024";
juce::String version = "0.0.4";
juce::String info = "07/03/2024";
juce::String message = "IGNMap 3 Version : " + version + "\n" + info + "\n";
message += "JUCE Version : " + juce::String(JUCE_MAJOR_VERSION) + "."
+ juce::String(JUCE_MINOR_VERSION) + "." + juce::String(JUCE_BUILDNUMBER);
Expand Down Expand Up @@ -874,7 +873,7 @@ void MainComponent::ImportDtmFolder()
juce::String folderName = AppUtil::OpenFolder("DtmFolderPath");
if (folderName.isEmpty())
return;
XGeoClass* C = ImportDataFolder(folderName, XGeoVector::DTM);
ImportDataFolder(folderName, XGeoVector::DTM);
m_DtmViewer.get()->SetBase(&m_GeoBase);
m_MapView.get()->RenderMap(false, false, true, false, false, true);
}
Expand Down Expand Up @@ -973,6 +972,7 @@ XGeoClass* MainComponent::ImportDataFolder(juce::String folderName, XGeoVector::
continue;
}
V = las;
las->CloseIfNeeded(); // Pour eviter d'utiliser trop de descripteurs de fichiers
}
if (type == XGeoVector::DTM) {
GeoDTM* dtm = new GeoDTM;
Expand Down Expand Up @@ -1051,9 +1051,9 @@ bool MainComponent::ImportLasFile(juce::String lasfile)
return false;
}

m_LasViewer.get()->SetBase(&m_GeoBase);
m_MapView.get()->SetFrame(m_GeoBase.Frame());
m_MapView.get()->RenderMap(false, false, false, false, true, true);
m_LasViewer.get()->SetBase(&m_GeoBase);

return true;
}
Expand Down Expand Up @@ -1156,7 +1156,6 @@ bool MainComponent::ExportLas()
{
m_MapView.get()->StopThread();
XFrame F = m_MapView.get()->GetSelectionFrame();
double gsd = m_MapView.get()->GetGsd();
ExportLasDlg* dlg = new ExportLasDlg(&m_GeoBase, XRint(F.Xmin), XRint(F.Ymin), XRint(F.Xmax), XRint(F.Ymax));
juce::DialogWindow::LaunchOptions options;
options.content.setOwned(dlg);
Expand Down
2 changes: 1 addition & 1 deletion IGNMap/Source/MainComponentToolbarFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class SliderToolbarButton : public juce::ToolbarButton, public juce::Slider::Lis
slider->setSize(400, 50);
slider->setChangeNotificationOnlyOnRelease(true);
slider->addListener(this);
juce::CallOutBox& box = juce::CallOutBox::launchAsynchronously(std::move(slider), getScreenBounds(), nullptr);
juce::CallOutBox::launchAsynchronously(std::move(slider), getScreenBounds(), nullptr);
}

void sliderValueChanged(juce::Slider* slider)
Expand Down
77 changes: 41 additions & 36 deletions IGNMap/Source/MapThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,9 @@ bool MapThread::Draw(juce::Graphics& g, int x0, int y0)
g.fillAll(juce::Colours::white);
g.drawImageAt(m_Raster, x0, y0);

g.setOpacity(DtmShader::m_dOpacity * 0.01f);
g.setOpacity((float)DtmShader::m_dOpacity * 0.01f);
g.drawImageAt(m_Dtm, x0, y0);
g.setOpacity(LasShader::Opacity() * 0.01f);
g.setOpacity((float)LasShader::Opacity() * 0.01f);
g.drawImageAt(m_Las, x0, y0);
g.drawImageAt(m_Vector, x0, y0);
g.drawImageAt(m_Overlay, x0, y0);
Expand Down Expand Up @@ -355,9 +355,9 @@ bool MapThread::DrawGeometry(XGeoVector* V)
bool MapThread::DrawPoint(XGeoVector* G)
{
XPt2D P = G->Pt(0);
double X = (P.X - m_dX0) / m_dGsd;
double Y = (m_dY0 - P.Y) / m_dGsd;
double d = 3;
float X = (float)((P.X - m_dX0) / m_dGsd);
float Y = (float)((m_dY0 - P.Y) / m_dGsd);
float d = 3.f;
m_Path.startNewSubPath(X, Y);
m_Path.addEllipse(X - d, Y - d, 2 * d, 2 * d);
return true;
Expand All @@ -373,9 +373,9 @@ bool MapThread::DrawPolyline(XGeoVector* G)
XPt* P = G->Pt();
if (P == nullptr)
return false;
m_Path.startNewSubPath((P[0].X - m_dX0) / m_dGsd, (m_dY0 - P[0].Y) / m_dGsd);
m_Path.startNewSubPath((float)((P[0].X - m_dX0) / m_dGsd), (float)((m_dY0 - P[0].Y) / m_dGsd));
for (uint32_t i = 1; i < G->NbPt(); i++)
m_Path.lineTo((P[i].X - m_dX0) / m_dGsd, (m_dY0 - P[i].Y) / m_dGsd);
m_Path.lineTo((float)((P[i].X - m_dX0) / m_dGsd), (float)((m_dY0 - P[i].Y) / m_dGsd));
return true;
}

Expand All @@ -402,17 +402,17 @@ bool MapThread::DrawMultiLine(XGeoVector* G)
if ((P == nullptr) || (Parts == nullptr))
return false;

m_Path.startNewSubPath((P[0].X - m_dX0) / m_dGsd, (m_dY0 - P[0].Y) / m_dGsd);
m_Path.startNewSubPath((float)((P[0].X - m_dX0) / m_dGsd), (float)((m_dY0 - P[0].Y) / m_dGsd));
bool new_ring = false;
for (uint32_t i = 1; i < G->NbPt(); i++) {
for (uint32_t j = 1; j < G->NbPart(); j++) {
if (i == G->Part(j))
new_ring = true;
}
if (new_ring)
m_Path.startNewSubPath((P[i].X - m_dX0) / m_dGsd, (m_dY0 - P[i].Y) / m_dGsd);
m_Path.startNewSubPath((float)((P[i].X - m_dX0) / m_dGsd), (float)((m_dY0 - P[i].Y) / m_dGsd));
else {
m_Path.lineTo((P[i].X - m_dX0) / m_dGsd, (m_dY0 - P[i].Y) / m_dGsd);
m_Path.lineTo((float)((P[i].X - m_dX0) / m_dGsd), (float)((m_dY0 - P[i].Y) / m_dGsd));
}
new_ring = false;
}
Expand All @@ -431,7 +431,7 @@ bool MapThread::DrawMultiPolygon(XGeoVector* G)
if ((P == nullptr)||(Parts == nullptr))
return false;

m_Path.startNewSubPath((P[0].X - m_dX0) / m_dGsd, (m_dY0 - P[0].Y) / m_dGsd);
m_Path.startNewSubPath((float)((P[0].X - m_dX0) / m_dGsd), (float)((m_dY0 - P[0].Y) / m_dGsd));
bool new_ring = false;
for (uint32_t i = 1; i < G->NbPt(); i++) {
for (uint32_t j = 1; j < G->NbPart(); j++) {
Expand All @@ -440,9 +440,9 @@ bool MapThread::DrawMultiPolygon(XGeoVector* G)
}
if (new_ring) {
m_Path.closeSubPath();
m_Path.startNewSubPath((P[i].X - m_dX0) / m_dGsd, (m_dY0 - P[i].Y) / m_dGsd);
m_Path.startNewSubPath((float)((P[i].X - m_dX0) / m_dGsd), (float)((m_dY0 - P[i].Y) / m_dGsd));
} else {
m_Path.lineTo((P[i].X - m_dX0) / m_dGsd, (m_dY0 - P[i].Y) / m_dGsd);
m_Path.lineTo((float)((P[i].X - m_dX0) / m_dGsd), (float)((m_dY0 - P[i].Y) / m_dGsd));
}
new_ring = false;
}
Expand All @@ -457,18 +457,18 @@ bool MapThread::DrawMultiPoint(XGeoVector* G)
{
XPt* P = G->Pt();
XPt M, N;
double d = 3.;
float d = 3.f;
M.X = (P[0].X - m_dX0) / m_dGsd;
M.Y = (m_dY0 - P[0].Y) / m_dGsd;
m_Path.startNewSubPath(M.X, M.Y);
m_Path.addEllipse(M.X - d, M.Y - d, 2 * d, 2 * d);
m_Path.startNewSubPath((float)M.X, (float)M.Y);
m_Path.addEllipse((float)M.X - d, (float)M.Y - d, 2 * d, 2 * d);
for (uint32_t i = 1; i < G->NbPt(); i++) {
N.X = (P[i].X - m_dX0) / m_dGsd;
N.Y = (m_dY0 - P[i].Y) / m_dGsd;
if ((fabs(N.X - M.X) < 2.) && (fabs(N.Y - M.Y) < 2.))
continue;
m_Path.startNewSubPath(N.X, N.Y);
m_Path.addEllipse(N.X - d, N.Y - d, 2 * d, 2 * d);
m_Path.startNewSubPath((float)N.X, (float)N.Y);
m_Path.addEllipse((float)N.X - d, (float)N.Y - d, 2 * d, 2 * d);
M = N;
}
return true;
Expand Down Expand Up @@ -528,7 +528,7 @@ void MapThread::DrawSelection()
float last_text_X = 0., last_text_Y = 0.;
while (iter.next()) {
numPoint++;
if (!clipR.contains(iter.x1, iter.y1))
if (!clipR.contains((int)iter.x1, (int)iter.y1))
continue;
g.setColour(juce::Colours::black);
g.drawRect(iter.x1 - dim, iter.y1 - dim, 2.f * dim, 2.f * dim);
Expand All @@ -538,12 +538,12 @@ void MapThread::DrawSelection()
if ((fabs(last_text_X - iter.x1) < 10) && (fabs(last_text_Y - iter.y1) < 10))
continue;
if ((!m_bFill) || (iter.elementType != juce::Path::Iterator::startNewSubPath)) {
g.drawSingleLineText(juce::String(numPoint), iter.x1 + 4, iter.y1);
g.drawSingleLineText(juce::String(numPoint), iter.x1 + 6, iter.y1);
g.drawSingleLineText(juce::String(numPoint), iter.x1 + 5, iter.y1 + 1);
g.drawSingleLineText(juce::String(numPoint), iter.x1 + 5, iter.y1 - 1);
g.drawSingleLineText(juce::String(numPoint), (int)iter.x1 + 4, (int)iter.y1);
g.drawSingleLineText(juce::String(numPoint), (int)iter.x1 + 6, (int)iter.y1);
g.drawSingleLineText(juce::String(numPoint), (int)iter.x1 + 5, (int)iter.y1 + 1);
g.drawSingleLineText(juce::String(numPoint), (int)iter.x1 + 5, (int)iter.y1 - 1);
g.setColour(juce::Colours::black);
g.drawSingleLineText(juce::String(numPoint), iter.x1 + 5, iter.y1);
g.drawSingleLineText(juce::String(numPoint), (int)iter.x1 + 5, (int)iter.y1);
last_text_X = iter.x1;
last_text_Y = iter.y1;
}
Expand Down Expand Up @@ -817,12 +817,16 @@ bool MapThread::DrawLas(GeoLAS* las)
juce::Graphics g(m_Las);
g.setColour(juce::Colours::lightpink);
g.fillRect((int)floor((F.Xmin - m_dX0) / m_dGsd), (int)floor((m_dY0 - F.Ymax) / m_dGsd), W, H);
g.setColour(juce::Colours::mediumvioletred);
g.drawRect((int)floor((F.Xmin - m_dX0) / m_dGsd), (int)floor((m_dY0 - F.Ymax) / m_dGsd), W, H);
m_nNumObjects++;
return true;
}

juce::Image::BitmapData bitmap(m_Las, juce::Image::BitmapData::readWrite);

if (!las->ReOpen())
return false;
laszip_I64 npoints = las->NbLasPoints();
laszip_POINTER reader = las->GetReader();
laszip_header* header = las->GetHeader();
Expand Down Expand Up @@ -871,19 +875,19 @@ bool MapThread::DrawLas(GeoLAS* las)
switch (shader.Mode()) {
case LasShader::ShaderMode::Altitude :
Z = point->Z * header->z_scale_factor + header->z_offset;
col = shader.AltiColor( (Z - Z0) * 255 / deltaZ );
col = shader.AltiColor( (uint8_t)((Z - Z0) * 255 / deltaZ));
*data_ptr = (uint32_t)col.getARGB();
break;
case LasShader::ShaderMode::RGB:
data[0] = point->rgb[2] / 256;
data[1] = point->rgb[1] / 256;
data[2] = point->rgb[0] / 256;
data[0] = (uint8_t)(point->rgb[2] / 256);
data[1] = (uint8_t)(point->rgb[1] / 256);
data[2] = (uint8_t)(point->rgb[0] / 256);
// data[3] = 255; // deja fixe dans l'initialisation de data
break;
case LasShader::ShaderMode::IRC:
data[0] = point->rgb[1] / 256;
data[1] = point->rgb[0] / 256;
data[2] = point->rgb[3] / 256;
data[0] = (uint8_t)(point->rgb[1] / 256);
data[1] = (uint8_t)(point->rgb[0] / 256);
data[2] = (uint8_t)(point->rgb[3] / 256);
// data[3] = 255; // deja fixe dans l'initialisation de data
break;
case LasShader::ShaderMode::Classification:
Expand All @@ -896,19 +900,19 @@ bool MapThread::DrawLas(GeoLAS* las)
break;
case LasShader::ShaderMode::Angle:
if (point->extended_scan_angle < 0) { // Angle en degree = extended_scan_angle * 0.006
data[2] = 255 - point->extended_scan_angle * (-0.0085); // Normalise sur [0; 255]
data[2] = (uint8_t)(255 - point->extended_scan_angle * (-0.0085)); // Normalise sur [0; 255]
data[1] = 0;
data[0] = 255 - data[0];
data[0] = (uint8_t)(255 - data[0]);
}
else {
data[2] = 0;
data[1] = 255 - point->extended_scan_angle * (0.0085); // Normalise sur [0; 255]
data[0] = 255 - data[1];
data[1] = (uint8_t)(255 - point->extended_scan_angle * (0.0085)); // Normalise sur [0; 255]
data[0] = (uint8_t)(255 - data[1]);
}
break;
}

ptr = bitmap.getPixelPointer(X, Y);
ptr = bitmap.getPixelPointer((int)X, (int)Y);
memcpy(ptr, &data, sizeof(uint32_t));
//bitmap.setPixelColour(X, Y, col);
//g.drawRect((float)X-1.f, (float)Y-1.f, 2.f, 2.f);
Expand All @@ -917,6 +921,7 @@ bool MapThread::DrawLas(GeoLAS* las)
}
laszip_seek_point(reader, 0);
m_nNumObjects++;
las->CloseIfNeeded();

return true;
}
4 changes: 3 additions & 1 deletion IGNMap/Source/MapView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,9 @@ void MapView::SetFrame(XFrame F)
ComputeCartoScale(10000);
}
m_Frame = F;
CenterView(X, Y);
m_dX0 = X - b.getWidth() * 0.5 * m_dScale;
m_dY0 = Y + b.getHeight() * 0.5 * m_dScale;
//CenterView(X, Y);
}

//==============================================================================
Expand Down
3 changes: 3 additions & 0 deletions IGNMap/Source/OGL3DViewer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -568,6 +568,8 @@ void OGLWidget::DrawLas(GeoLAS* las)
{
const juce::ScopedLock lock(m_Mutex);
using namespace ::juce::gl;
if (!las->ReOpen())
return;

openGLContext.extensions.glBindBuffer(GL_ARRAY_BUFFER, m_LasBufferID);
Vertex* ptr_vertex = (Vertex*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
Expand Down Expand Up @@ -673,6 +675,7 @@ void OGLWidget::DrawLas(GeoLAS* las)
break;
}
laszip_seek_point(reader, 0);
las->CloseIfNeeded();
glUnmapBuffer(GL_ARRAY_BUFFER);
}

Expand Down
2 changes: 1 addition & 1 deletion XTool/XGeoPoint.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class XGeoPoint3D : public XGeoPoint2D {

virtual eTypeVector TypeVector () const { return PointZ;}

virtual double Z(uint32_t i) { return m_Z;}
virtual double Z(uint32_t /*i*/) { return m_Z; }
virtual bool Is3D() const { return true;}

virtual inline double Zmin() const { return m_Z;}
Expand Down
Loading

0 comments on commit 1156f7a

Please sign in to comment.