Commit 4613679a authored by aschwarzkopf's avatar aschwarzkopf

Commit the first conceptual prototype

parent 7553f15b
# OW Version File. This file specifies the version. The line VERSION=X.Y.Z is
# used and parsed. This file has to be here everytime. The VERSION needs to be
# set properly or CMake will fail.
#
# SYNTAX: The version string always is 1.2.3 with an optional postfix of "+hg1234".
# This is useful if building is done by scripts. If you want to automatically
# add the correct HG revision, use only +hgX without number.
#
# IMPORTANT: If you modify the file, cmake re-creates the version header. But
# it is not able to set all library version. Please re-run cmake if
# you change something here.
#
# NOTE: do not add a space after #. The current CMake script will fail.
# Examples:
#VERSION=1.2.0
#VERSION=1.2.0+hgX -> replaces the X with the current revision number
#VERSUIB=1.2.0+hg1234 -> here, revision number was set by the build scripts for example.
VERSION=0.0.1+hgX
#---------------------------------------------------------------------------
#
# Project: OpenWalnut ( http://www.openwalnut.org )
#
# Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
# For more information see http:#www.openwalnut.org/copying
#
# This file is part of OpenWalnut.
#
# OpenWalnut is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenWalnut is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with OpenWalnut. If not, see <http:#www.gnu.org/licenses/>.
#
#---------------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# General CMake Setup
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT( LiDARToolbox )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Include the OpenWalnut build system.
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# where to find our utils and cmake modules?
SET( OW_TOOLS_DIR ${PROJECT_SOURCE_DIR}/../tools )
# append search path for FindModules:
LIST( APPEND CMAKE_MODULE_PATH ${OW_TOOLS_DIR}/cmake )
# These scripts contains all the needed tools to setup the build:
# * Compiler Setup
# * Common OpenWalnut Options
# * Third-party Dependencies Setup
# * Unit Testing Setup if found
# * Doxygen Setup if found
INCLUDE( OpenWalnut )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Setup your additional dependencies and tools
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# IMPORTANT: NEVER add any commands bore the line INCLUDE( OpenWalnut ). This might cause problems!
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Setup all modules
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Here, you can add your own targets, call ADD_MODULE provided by OpenWalnut or a combination of it. When using ADD_MODULE or SETUP_MODULE, the
# OpenWalnut CMake scripts manages proper resource handling, test compilation and similar. You should use it whenever possible. More details on
# how to develop external modules, have a look at http://www.openwalnut.org. You can have a look at OpenWalnut.cmake if you want to modify
# the default behaviour.
# Please see the documentation of SETUP_MODULE as it shows how to add custom dependencies (third-party libs)
SETUP_MODULE(
${PROJECT_NAME} # use project name as module(-toolbox) name
"." # where to find the sources
"liblas.so" # no additonal dependencies
"" # no sources to exclude
)
# Tell CMake that we want to use the WToolboxVersion header in our Modules. It gets created automatically if you keep this line.
SETUP_USE_VERSION_HEADER( ${PROJECT_NAME} )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
#
# Additional Setup
#
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Add the files under ../resources/MyGlobalResources as additional, global resources
# The first parameter is the directory name, the second parameter is the component name. This is used during installation to identify to which
# install component this belongs. The name is arbitrary but must be unique.
#
# NOTE: The first parameter of SETUP_MODULE is not allowed as component name here because SETUP_MODULE already registers this component. Simply
# append some string.
SETUP_GLOBAL_RESOURCES( "MyGlobalResources" ${PROJECT_NAME}_Global )
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
// This file's purpose is to provide a list of modules and additional extensions as entry point for OpenWalnut's module loader.
// Both functAdd your modules here. If you miss this step, OpenWalnut will not be able to load your modules/extensions.
#include <boost/shared_ptr.hpp>
#include <core/kernel/WModule.h>
#include "buildingsDetection/WMBuildingsDetection.h"
#include "readLAS/WMReadLAS.h"
// #include "WToolkit.h"
/**
* This function is called by OpenWalnut, when loading your library to learn about the modules you provide. The function is called with a given
* list reference, where you add all of your modules. Modules which are not registered this way, cannot be used in OpenWalnut. As this is called
* before loading any project file or running any module, it is ensured that you can rely on the modules provided here in your project files and
* other modules.
*
* \note this function is optional. You can remove it if you do not need it.
*
* \param m the list of modules. Add you module instances into this list.
*/
extern "C" void WLoadModule( WModuleList& m ) // NOLINT
{
m.push_back( boost::shared_ptr< WModule >( new WMBuildingsDetection ) );
m.push_back( boost::shared_ptr< WModule >( new WMReadLAS ) );
}
/**
* This function is called by OpenWalnut, when loading your module to allow registration of additional classes and implementations that are not
* WModule classes. At this point, OW is completely initialized, thus allowing you to register nearly everything to the sub-systems supporting
* this. A typical example is the postprocessing meachnism in OpenWalnut. It allows you to register your own postprocessors easily. As this
* function is called on start-up, before loading project files, you can rely on additional functionality in your project files and modules.
*
* \note this function is optional. You can remove it if you do not need it.
*
* \param localPath this is the path to the toolkit. Our build system ensures, that your resources and shaders get placed there.
*/
extern "C" void WRegisterArbitrary( const boost::filesystem::path& localPath )
{
// Example for registering your own postprocessor:
// WGEPostprocessor::addPostprocessor( WGEPostprocessor::SPtr( new MyStylishPostprocessing( localPath ) ) );
wlog::info( "LiDARToolbox - Toolkit for building acquisition of LiDAR data." ) << "My resource path is: " << localPath.string();
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WTOOLKIT_H
#define WTOOLKIT_H
// nothing to do here. Have a look at WToolkit.cpp for registration of all the modules inside the toolbox.
#endif // WTOOLKIT_H
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2013 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
//Brings me at least very few forward: http://osgeo-org.1560.x6.nabble.com/Liblas-devel-c-liblas-problem-td4919064.html
#include <string>
#include <fstream> // std::ifstream
#include <iostream> // std::cout
#include <osg/Geometry>
#include "core/kernel/WModule.h"
#include "core/dataHandler/WDataSetScalar.h"
#include "core/graphicsEngine/callbacks/WGELinearTranslationCallback.h"
#include "core/graphicsEngine/shaders/WGEPropertyUniform.h"
#include "core/graphicsEngine/shaders/WGEShader.h"
#include "core/graphicsEngine/WGEGeodeUtils.h"
#include "core/graphicsEngine/WGEManagedGroupNode.h"
#include "core/kernel/WKernel.h"
#include "core/kernel/WModuleInputData.h"
#include "WMBuildingsDetection.xpm"
#include "WMBuildingsDetection.h"
// This line is needed by the module loader to actually find your module.
//W_LOADABLE_MODULE( WMBuildingsDetection )
WMBuildingsDetection::WMBuildingsDetection():
WModule(),
m_propCondition( new WCondition() )
{
}
WMBuildingsDetection::~WMBuildingsDetection()
{
}
boost::shared_ptr< WModule > WMBuildingsDetection::factory() const
{
return boost::shared_ptr< WModule >( new WMBuildingsDetection() );
}
const char** WMBuildingsDetection::getXPMIcon() const
{
return WMBuildingsDetection_xpm;
}
const std::string WMBuildingsDetection::getName() const
{
return "[ALPHA] Buildings Detection hahahahah";
}
const std::string WMBuildingsDetection::getDescription() const
{
return "Should draw values above some threshold.";
}
void WMBuildingsDetection::connectors()
{
m_input = WModuleInputData< WDataSetPoints >::createAndAdd( shared_from_this(), "input", "The mesh to display" );
m_output = boost::shared_ptr< WModuleOutputData< WTriangleMesh > >(
new WModuleOutputData< WTriangleMesh >( shared_from_this(), "output", "The loaded mesh." ) );
addConnector( m_output );
WModule::connectors();
}
void WMBuildingsDetection::properties()
{
// ---> Put the code for your properties here. See "src/modules/template/" for an extensively documented example.
m_stubSize = m_properties->addProperty( "Cutoff threshold: ",
"Value that will be replaced with a dummy value.", 2.0, m_propCondition );
m_stubSize->setMin( 0.0 );
m_stubSize->setMax( 3.0 );
WModule::properties();
}
void WMBuildingsDetection::requirements()
{
}
void WMBuildingsDetection::moduleMain()
{
infoLog() << "Thrsholding example main routine started";
// get notified about data changes
m_moduleState.setResetable( true, true );
m_moduleState.add( m_input->getDataChangedCondition() );
m_moduleState.add( m_propCondition );
ready();
// graphics setup
m_rootNode = osg::ref_ptr< WGEManagedGroupNode >( new WGEManagedGroupNode( m_active ) );
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->insert( m_rootNode );
// main loop
while( !m_shutdownFlag() )
{
//infoLog() << "Waiting ...";
m_moduleState.wait();
boost::shared_ptr< WDataSetPoints > points = m_input->getData();
std::cout << "Execute cycle\r\n";
if ( points )
{
WDataSetPoints::VertexArray verts = points->getVertices();
size_t count = verts->size()/3;
boost::shared_ptr< WTriangleMesh > tmpMesh( new WTriangleMesh( 0, 0 ) );
float a = m_stubSize->get();
setProgressSettings( count );
for ( size_t i=0; i<count; i++)
{
float x = verts->at(i*3);
float y = verts->at(i*3+1);
float z = verts->at(i*3+2);
// std::cout << "Point at\t" << x << "\t" << y << "\t" << z << "\r\n";
tmpMesh->addVertex(0+x, 0+y, 0+z);
tmpMesh->addVertex(a+x, 0+y, 0+z);
tmpMesh->addVertex(0+x, a+y, 0+z);
tmpMesh->addVertex(0+x, 0+y, a+z);
size_t o = i*4;
tmpMesh->addTriangle(0+o, 2+o, 1+o);
tmpMesh->addTriangle(0+o, 1+o, 3+o);
tmpMesh->addTriangle(0+o, 3+o, 2+o);
tmpMesh->addTriangle(1+o, 2+o, 3+o);
m_progressStatus->increment( 1 );
}
m_output->updateData(tmpMesh);
m_progressStatus->finish();
}
// woke up since the module is requested to finish?
if ( m_shutdownFlag() )
{
break;
}
boost::shared_ptr< WDataSetPoints > points2 = m_input->getData();
if ( !points2 )
{
continue;
}
// ---> Insert code doing the real stuff here
}
WKernel::getRunningKernel()->getGraphicsEngine()->getScene()->remove( m_rootNode );
}
void WMBuildingsDetection::setProgressSettings( size_t steps )
{
m_progress->removeSubProgress( m_progressStatus );
std::string headerText = "Loading data";
m_progressStatus = boost::shared_ptr< WProgress >( new WProgress( headerText, steps ) );
m_progress->addSubProgress( m_progressStatus );
}
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2013 OpenWalnut Community, BSV-Leipzig and CNCF-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WMBUILDINGSDETECTION_H
#define WMBUILDINGSDETECTION_H
#include <liblas/liblas.hpp>
#include <string>
#include <fstream> // std::ifstream
#include <iostream> // std::cout
#include "core/kernel/WModule.h"
#include "core/graphicsEngine/WGEManagedGroupNode.h"
#include "core/graphicsEngine/shaders/WGEShader.h"
#include "core/graphicsEngine/WTriangleMesh.h"
#include "core/kernel/WModule.h"
#include <osg/ShapeDrawable>
#include <osg/Geode>
#include "core/dataHandler/WDataSetPoints.h"
//!.Unnecessary imports
#include "core/common/WItemSelection.h"
#include "core/common/WItemSelector.h"
#include "core/kernel/WModuleOutputData.h"
#include <osg/Group>
#include <osg/Material>
#include <osg/StateAttribute>
#include "core/kernel/WKernel.h"
#include "core/common/exceptions/WFileNotFound.h"
#include "core/common/WColor.h"
#include "core/common/WPathHelper.h"
#include "core/common/WPropertyHelper.h"
#include "core/common/WItemSelectionItem.h"
#include "core/common/WItemSelectionItemTyped.h"
#include "core/graphicsEngine/WGEUtils.h"
#include "core/graphicsEngine/WGERequirement.h"
// forward declarations to reduce compile dependencies
template< class T > class WModuleInputData;
class WDataSetScalar;
class WGEManagedGroupNode;
/**Draws cubes where a value is at least as big as the preset ISO value
* \ingroup modules*/
class WMBuildingsDetection: public WModule
{
public:
/**Creates the module for drawing contour lines.*/
WMBuildingsDetection();
/**Destroys this module.*/
virtual ~WMBuildingsDetection();
/**Gives back the name of this module.
* \return the module's name.*/
virtual const std::string getName() const;
/**Gives back a description of this module.
* \return description to module.*/
virtual const std::string getDescription() const;
/**Due to the prototype design pattern used to build modules, this method returns a new instance of this method. NOTE: it
* should never be initialized or modified in some other way. A simple new instance is required.
* \return the prototype used to create every module in OpenWalnut.*/
virtual boost::shared_ptr< WModule > factory() const;
/**Get the icon for this module in XPM format.
* \return The icon.*/
virtual const char** getXPMIcon() const;
protected:
/**Entry point after loading the module. Runs in separate thread.*/
virtual void moduleMain();
/**Initialize the connectors this module is using.*/
virtual void connectors();
/**Initialize the properties for this module.*/
virtual void properties();
/**Initialize requirements for this module.*/
virtual void requirements();
private:
void setProgressSettings( size_t steps );
boost::shared_ptr< WModuleInputData< WDataSetPoints > > m_input;
boost::shared_ptr< WModuleOutputData< WTriangleMesh > > m_output; //!< Output connector provided by this module.
/**The OSG root node for this module. All other geodes or OSG nodes will be attached on this single node.*/
osg::ref_ptr< WGEManagedGroupNode > m_rootNode;
/**Needed for recreating the geometry, incase when resolution changes.*/
boost::shared_ptr< WCondition > m_propCondition;
/**Shader unit for drawing. */
WGEShader::RefPtr m_shader;
/**Below that ISO value vertices should be count off */
WPropInt m_cutoffThreshold;
/**Voxel count that is cut off and kept regarding the ISO value. */
WPropDouble m_stubSize;
/**Instance for applying drawable geoms. */
osg::ref_ptr< osg::Geode > m_geode;
boost::shared_ptr< WProgress > m_progressStatus;
/**Drawing color. */
WPropColor m_aColor;
};
#endif // WMBUILDINGSDETECTION_H
/* XPM */
static const char * WMBuildingsDetection_xpm[] = {
"32 32 312 2",
" c None",
". c #FCAF60",
"+ c #F8A859",
"@ c #F6A555",
"# c #F5A351",
"$ c #F4A14E",
"% c #F29F4C",
"& c #F19E4B",
"* c #F09C48",
"= c #F09C47",
"- c #EF9A46",
"; c #EE9945",
"> c #EE9843",
", c #ED9742",
"' c #ED9741",
") c #ED9640",
"! c #EC9640",
"~ c #EB953F",
"{ c #EC953F",
"] c #EC953E",
"^ c #EB953E",
"/ c #EB953D",
"( c #EA943D",
"_ c #EB943D",
": c #EB933D",
"< c #EA923C",
"[ c #E8923C",
"} c #E7913C",
"| c #F8A959",
"1 c #0000FF",
"2 c #F3A14F",
"3 c #F3A04D",
"4 c #F19E4A",
"5 c #F09C49",
"6 c #F09B47",
"7 c #EF9A44",
"8 c #ED9843",
"9 c #EC9741",
"0 c #EC9641",
"a c #EC963F",
"b c #EA943E",
"c c #EA933D",
"d c #E5903C",
"e c #F29F4D",
"f c #F29E4B",
"g c #0604F8",
"h c #2417E0",
"i c #7B4D99",
"j c #E8923F",
"k c #EB943E",
"l c #E9933D",
"m c #E8923D",
"n c #E5913B",
"o c #E38F3B",
"p c #F39F4C",
"q c #F29E4A",
"r c #F19D49",
"s c #EE9944",
"t c #E29045",
"u c #B77369",
"v c #2E1DD8",
"w c #7D4E97",
"x c #E7923C",
"y c #E28F3B",
"z c #E08D3A",
"A c #F4A14F",
"B c #EF9C47",
"C c #EF9944",
"D c #ED9944",
"E c #BE7861",
"F c #2316E0",
"G c #E8933D",
"H c #E08D3B",
"I c #DD8B3A",
"J c #F09D49",
"K c #EF9C48",
"L c #EF9B46",
"M c #E18F44",
"N c #0805F7",
"O c #E5913C",
"P c #DE8C3A",
"Q c #DB8A39",
"R c #EF9B48",