30 #include <liblas/liblas.hpp>
31 #include <liblas/point.hpp>
32 #include <liblas/reader.hpp>
34 #include "WMReadLAS.h"
35 #include "core/common/WPathHelper.h"
36 #include "core/common/WStringUtils.h"
37 #include "core/kernel/WDataModuleInputFile.h"
38 #include "core/kernel/WDataModuleInputFilterFile.h"
39 #include "core/kernel/WKernel.h"
58 return std::shared_ptr< WModule >(
new WMReadLAS() );
70 return "This module reads LAS files containing LiDAR point data.";
114 std::vector< WDataModuleInputFilter::ConstSPtr > filters;
141 boost::filesystem::path p = inputFile->getFilename();
144 ifs.open( p.string().c_str(), std::ios::in | std::ios::binary );
145 if( !ifs || ifs.bad() )
147 errorLog() <<
"Could not open file \"" << p.string() <<
"\".";
152 liblas::Reader reader =
factory.CreateWithStream( ifs );
154 size_t numPoints = reader.GetHeader().GetPointRecordsCount();
156 infoLog() <<
"LAS Header: Point Count = " << numPoints;
157 infoLog() <<
"LAS Header: Compressed = " << reader.GetHeader().Compressed();
158 infoLog() <<
"LAS Header: File Signature = " << reader.GetHeader().GetFileSignature();
160 std::shared_ptr< WProgress > progress1(
new WProgress(
"Loading" ) );
168 infoLog() <<
"Start Loading ...";
171 size_t realNumPoints = 0;
172 while( reader.ReadNextPoint() )
175 liblas::Point
const& coord = reader.GetPoint();
177 vertices->push_back( coord.GetX() );
178 vertices->push_back( coord.GetY() );
179 vertices->push_back( coord.GetZ() );
180 colors->push_back( 1.0 );
181 colors->push_back( 1.0 );
182 colors->push_back( 1.0 );
188 infoLog() <<
"Loaded " << realNumPoints <<
" points from file. Done." << bb;
191 std::shared_ptr< WDataSetPoints> newOutput(
new WDataSetPoints( vertices, colors, bb ) );
void expandBy(const WBoundingBoxImpl< VT > &bb)
Expands this bounding box to include the given bounding box.
virtual void wait() const
Wait for the condition.
void setResetable(bool resetable=true, bool autoReset=true)
Sets the resetable flag.
virtual void notify()
Notifies all waiting threads.
Base for all data loader modules.
Dataset to store a bunch of points without order or topology.
std::shared_ptr< WDataSetPoints > SPtr
Pointer to dataset.
std::shared_ptr< std::vector< float > > ColorArray
Colors for each vertex in VertexArray.
std::shared_ptr< std::vector< float > > VertexArray
List of vertex coordinates in term of components of vertices.
This module loads LAS files (point data).
virtual void handleInputChange()
Handle a newly set input.
virtual std::shared_ptr< WModule > factory() const
Due to the prototype design pattern used to build modules, this method returns a new instance of this...
virtual void moduleMain()
Entry point after loading the module.
virtual void properties()
Initialize the properties for this module.
virtual const std::string getName() const
Gives back the name of this module.
virtual const std::string getDescription() const
Gives back a description of this module.
std::shared_ptr< WModuleOutputData< WDataSetPoints > > m_output
The output connector for the filtered data.
bool m_reload
True if the load function needs to be called.
WMReadLAS()
Default constructor.
virtual ~WMReadLAS()
Destructor.
virtual void connectors()
Initialize the connectors this module is using.
virtual void load()
Load data.
virtual std::vector< WDataModuleInputFilter::ConstSPtr > getInputFilter() const
Define a list of file filters we support.
A fixed size matrix class.
Class offering an instantiate-able data connection between modules.
virtual void properties()
Initialize properties in this function.
void ready()
Call this whenever your module is ready and can react on property changes.
WConditionSet m_moduleState
The internal state of the module.
wlog::WStreamedLogger errorLog() const
Logger instance for comfortable error logging.
std::shared_ptr< WProgressCombiner > m_progress
Progress indicator used as parent for all progress' of this module.
wlog::WStreamedLogger infoLog() const
Logger instance for comfortable info logging.
virtual void connectors()
Initialize connectors in this function.
void waitRestored()
This method waits for the module to be restored completely.
Class managing progress inside of modules.
WBoolFlag m_shutdownFlag
Condition getting fired whenever the thread should quit.