Changes between Version 4 and Version 5 of Processing/lagdevelopersfaq


Ignore:
Timestamp:
Jul 2, 2012, 6:10:32 PM (12 years ago)
Author:
jaho
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Processing/lagdevelopersfaq

    v4 v5  
    11= LAG Developers FAQ =
    2 [#q1 What is LAG?] \\
     2[#q1 1. What is LAG?] \\
     3[#q2 2. What are major components of LAG?] \\
     4[#q3 3. How do I edit the GUI?] \\
     5[#q4 4. What are LAS files?] \\
     6[#q5 5. What do I need to know about laslib?] \\
     7[#q6 6. How do I make laslib a shared library?] \\
     8
    39[#q5 Why is LAG's code so messy?] \\
    410[#q5 How can I make it better?] \\
    5 [#q2 What are major components of LAG?] \\
    611[#q2 How do I edit the GUI?] \\
    712[#q3 What are LAS files?] \\
     
    1520[#q5 What are some major issues with LAG that need work?] \\
    1621[#q5 What are some additional features that can be added to LAG?] \\
     22[#q5 What tools are there to help me with LAG development?] \\
     23[#q5 Question X?] \\
     24[#q5 Question X?] \\
     25[#q5 Question X?] \\
    1726[#q5 Question X?] \\
    1827
    19 == What is LAG [=#q1] ==
     28== 1. What is LAG? [=#q1] ==
    2029
    21 The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.
     30LAG stands for [http://en.wikipedia.org/wiki/LIDAR LiDAR] Analysis GUI. It is a software which provides graphical user interface for processing and visualisation of LiDAR [http://en.wikipedia.org/wiki/Point_cloud point cloud] data. LAG is written in C++ and uses Gtk ([http://www.gtkmm.org/en/ gtkmm]) for its GUI, and [http://www.opengl.org/ OpenGL] for rendering.
    2231
    23 The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.
     32== 2. What are major components of LAG [=#q2] ==
    2433
    25 == Question 2 [=#q2] ==
     34LAG consist of the main GUI application and a Lidar Quadtree library used for storing and querying the data.
    2635
    27 The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.
     36== 3. How do I edit the GUI? [=#q3] ==
    2837
    29 == Question 3 [=#q3] ==
     38The GUI layout is stored in //lag.ui// [http://glade.gnome.org/ Glade] file which is in plain xml. This allows editing the interface without the need for recompiling the source code every time a change is made. The //lag.ui// file can be opened in Glade User Interface Designer which can by run with //glade-3// command.
    3039
    31 The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.
     40The interface of the application is created from xml using Gtk::Builder object, which is instantiated in lag.cpp and then passed by Glib::RefPtr to each of the classes that handle the GUI. All of these classes are located under src/ui folder and each of them has two common methods: //void load_xml(builder)// and //void connect_signals()// which are called in their constructors.
    3241
    33 == Question 4 [=#q4] ==
     42The //load_xml(const Glib::RefPtr<Gtk::Builder>& builder)// method gets widgets from the builder file and assigns them to the class members (pointers). Widgets instantiated by Gtk::Builder have to be deleted manually. In fact, according to documentation, this only applies to top-level widgets (windows and dialogs), but LAG's authors seem to prefer to delete every single one anyway.
    3443
    35 The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.
     44The //connect_signals()// method is responsible for connecting various input signals to class methods. An example lifetime of a Gtk Widget then looks like this:
    3645
    37 == Question 5 [=#q5] ==
     46{{{
     47#!div style="font-size: 100%"
     48  {{{#!c++
     49  // Declare a pointer to the widget (as class member)
     50  class MyClass {
     51    Gtk::Button* my_button;
     52    void on_my_button_clicked();
     53  }
    3854
    39 The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.The following guide provides an overview of LAG features and offers some hints on how to utilize them for the best processing efficiency. Some of these are just convenient methods of doing things while other can offer a significant performance improvement. Most of the values discussed below have been set up for optimal performance by default, however different data sets and tasks can benefit from different configurations.
     55  // Load the widget from xml (in MyClass::load_xml(const Glib::RefPtr<Gtk::Builder>& builder))
     56  builder->get_widget("mybutton", my_button);
     57
     58  // Connect some method to it (in MyClass::connect_signals())
     59  my_button->signal_clicked().connect(sigc::mem_fun(*this, &MyClass::on_my_button_clicked));
     60
     61  // Delete the widget (in the class destructor)
     62  delete my_button;
     63  }}}
     64}}}
     65
     66Modifying the GUI is just as simple as adding new widgets to the Glade file and then handling them in the ui classes.
     67
     68== 4. What are LAS files? [=#q4] ==
     69
     70LAS is a binary, public file format designed to hold LiDAR point data. An alternative to LAS are ASCII files, which are however much less efficient in terms of both processing time and file size.
     71
     72LAS files consist of several parts: Public Header Block, Variable Length Records, Point Records and in format 1.3 and later Waveform Records.
     73
     74A detailed LAS format specification can be found at:
     75[http://www.asprs.org/Committee-General/LASer-LAS-File-Format-Exchange-Activities.html http://www.asprs.org/Committee-General/LASer-LAS-File-Format-Exchange-Activities.html]
     76
     77== 5. What do I need to know about laslib? [=#q5] ==
     78
     79[http://www.cs.unc.edu/~isenburg/lastools/ Laslib] is a library for handling various LiDAR file formats including LAS. LAG makes use of laslib for loading and saving points.
     80
     81There is no official documentation for laslib API, however it is a fairly well written C++ which provides an easy to use interface. The best way to learn laslib is to study the source code of programs included in lastools.
     82
     83The main classes of our interest are LASreader and LASwriter. A simple program that reads points from a file, filters out points with classification 7 (noise), prints points' coordinates and then saves them to another file may look like this (note there's no error checking or exception handling for simplicity, but you should always include it the real code):
     84{{{
     85#!div style="font-size: 100%"
     86  {{{#!c++
     87  #include <iostream>
     88  #include "laslib/lasreader.hpp"
     89  #include "laslib/laswriter.hpp"
     90  #include "laslib/lasdefinitions.hpp"
     91
     92  int main(int argc, char** argv)
     93  {
     94    // Assume that's correct for simplicity
     95    std::string filename = argv[1];
     96    std::string file_out = argv[2];
     97 
     98    LASreadOpener lasreadopener;
     99    LASwriteOpener laswriteopener;
     100    lasreadopener.set_file_name(filename.c_str());
     101    laswriteopener.set_file_name(file_out.c_str());
     102
     103    // Filter out points with classification 7
     104    std::vecor<char*> filter_args;                 // this simulates a command line arguments for parse() function further down
     105    filter_args.push_back("filter");               // a dummy first argument
     106    filter_args.push_back("-drop_classification");
     107    filter_args.push_back("7");
     108    filter_args.push_back(0);                      // null termination
     109 
     110    lasreadopener.parse(args.size(), &args[0]);    // &args[0] = *args so we're passing char** args instead of a vector<char*>
     111
     112    // Declare lasreader
     113    LASreader* lasreader;
     114
     115    // Open the file
     116    lasreader = lasreadopener.open();
     117 
     118    //  Create and open the writer
     119    LASwriter* laswriter = laswriteopener.open(&lasreader->header);
     120
     121    // Loop through the points (note they will already be filtered)
     122    while (lasreader->read_point())
     123    {
     124      // Show coordinates
     125      std::cout << lasreader->point.get_x() << ", " << lareader->point.get_y() << ", " << lasreader->point.get_z() << std::endl;
     126   
     127      // Write point
     128      laswriter->write_point(&lasreader->point);
     129
     130      // Add it to the inventory (keeps track of min/max values for the header)
     131      laswriter->update_inventory(&lasreader->point);
     132    }
     133
     134    laswriter->update_header(&lasreader->header, TRUE);
     135
     136    laswriter->close();
     137    lasreader->close();
     138
     139    delete laswriter();
     140    delete lasreader();
     141  }
     142  }}}
     143}}}
     144
     145== 6. Ho do I make laslib a shared library? [=#q6] ==
     146
     147It seems that laslib is mainly developed for Windows users so there are no targets for shared libraries in the Makefiles by default. At the same time shared libraries are needed by LAG to work correctly. To fix this you're going to need to modify the Makefiles and add -fPIC option to the compiler. You'll also have to change the name of the library from laslib to //liblaslib// for the linker to detect it.
     148
     149You'll normally find modified Makefiles somewhere around, so you can copy them after downloading a new version of laslib and hopefully they will work. If this is not the case, below is the part that needs to be added to the Makefile inside laslib/src folder.
     150
     151{{{
     152#!div style="font-size: 100%"
     153  {{{#!sh
     154all: static shared
     155
     156# these targets set the output directory for the object
     157# files and then call make again with the appropriate library targets. 
     158# This is done so that the fpic flag is set correctly for the library
     159# we're building.
     160static:
     161        test -d static || mkdir static
     162        $(MAKE) liblaslib.a OBJDIR=static
     163
     164shared:
     165        test -d shared || mkdir shared
     166        $(MAKE) liblaslib.so.${VERSION} OBJDIR=shared EXTRA_COPTS=-fPIC
     167
     168liblaslib.a: ${TARGET_OBJS}
     169        $(AR) $@ ${TARGET_OBJS}
     170        cp -p $@ ../lib
     171
     172liblaslib.so.${VERSION}: ${TARGET_OBJS}
     173        ${COMPILER} -shared -Wl,-soname,liblaslib.so.1 -o \
     174        liblaslib.so.${VERSION} ${TARGET_OBJS}
     175        cp -p $@ ../lib
     176
     177${TARGET_OBJS}: ${OBJDIR}/%.o: %.cpp
     178        ${COMPILER} ${BITS} -c ${COPTS} ${EXTRA_COPTS} ${INCLUDE} $< -o $@
     179
     180  }}}
     181}}}
     182
     183You're not likely to have to alter this part and if a newly downloaded version of laslib fails to build with modified Makefiles, the first thing to check is if OBJ_LAS (the list of object files) hasn't changed since the previous release.