Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • LidarView/lidarview-core
  • nick.laurenson/lidarview-core
  • aerezarang/lidarview-core
3 results
Show changes
Commits on Source (22)
Showing
with 199 additions and 552 deletions
......@@ -55,6 +55,10 @@ void lqLidarCameraReaction::onTriggered()
case pqCameraReaction::Mode::ROTATE_CAMERA_CCW:
this->rotateCamera(90.0);
break;
case pqCameraReaction::Mode::APPLY_ISOMETRIC_VIEW:
this->applyIsometricView();
break;
}
}
......
......@@ -57,7 +57,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#include <pqView.h>
#include <vtkFieldData.h>
#include <vtkPVConfig.h> // needed for PARAVIEW_VERSION
#include <vtkPVVersion.h> // needed for PARAVIEW_VERSION
#include <vtkSMParaViewPipelineControllerWithRendering.h>
#include <vtkSMPropertyHelper.h>
#include <vtkSMProxyManager.h>
......
......@@ -121,7 +121,7 @@ lqPlayerControlsToolbar::lqPlayerControlsToolbar(QWidget* parentObject,
QObject::connect(
this->Controller, SIGNAL(frameRanges(int, int)), this, SLOT(setFrameRanges(int, int)));
QObject::connect(this->Controller, SIGNAL(loop(bool)), ui.actionVCRLoop, SLOT(setChecked(bool)));
QObject::connect(this->Controller, SIGNAL(playing(bool)), this, SLOT(onPlaying(bool)));
QObject::connect(this->Controller, SIGNAL(playing(bool, bool)), this, SLOT(onPlaying(bool, bool)));
// CUSTOM
QObject::connect(
......@@ -242,7 +242,7 @@ void lqPlayerControlsToolbar::setFrameRanges(int min, int max)
this->UI->frameQSpinBox->setMaximum(max);
}
//-----------------------------------------------------------------------------
void lqPlayerControlsToolbar::onPlaying(bool playing)
void lqPlayerControlsToolbar::onPlaying(bool playing, bool reversed)
{
// PV code, set custom Play/Pause icons
if (playing)
......@@ -315,11 +315,11 @@ void lqPlayerControlsToolbar::onSetLiveMode(bool liveModeEnabled)
{
// Make LiveSource are running
pqLiveSourceBehavior::resume();
this->onPlaying(true);
this->onPlaying(true, false);
}
else
{
this->onPlaying(false);
this->onPlaying(false, false);
}
}
......
......@@ -57,7 +57,7 @@ public:
protected Q_SLOTS:
// UI Updates
void setTimeRanges(double, double); // VCR Controller default, updates time ranges
void onPlaying(bool); // VCR Controller default
void onPlaying(bool, bool); // VCR Controller default
void setFrameRanges(int, int); // updates frames ranges
void onSpeedChanged(double speed); // Update UI on speed change
......
......@@ -238,6 +238,7 @@ void lqRulerReaction::destroyState()
mouseCC->SetClientData(nullptr);
mouseCC->SetCallback(nullptr);
mouseCC->Delete();
mouseCC = nullptr;
}
// Reset 'started' state
......@@ -315,7 +316,8 @@ QList<QVariant> lqRulerReaction::get3DPoint(QPoint coord)
// int the Mode::BETWEEN_3D_POINTS, we will lock for an existing 3D points that project to the mouse coordinate
// For more information look at the vtkSMRenderViewProxy::ConvertDisplayToPointOnSurface function
int display3DPoint[2] = {coord.x(), coord.y()};
if (!viewProxy->ConvertDisplayToPointOnSurface(display3DPoint, position, true))
double normal[3] = {0, 0, 0};
if (!viewProxy->ConvertDisplayToPointOnSurface(display3DPoint, position, normal, true))
{
return QList<QVariant>();
}
......
......@@ -17,8 +17,15 @@ namespace
{
bool isStream(pqPipelineSource* src)
{
return (src != nullptr && src->getProxy() != nullptr &&
src->getProxy()->GetClientSideObject()->IsA("vtkLidarStream"));
if (src != nullptr && src->getProxy() != nullptr)
{
vtkObjectBase* objectBased = src->getProxy()->GetClientSideObject();
if (objectBased != nullptr)
{
return objectBased->IsA("vtkLidarStream");
}
}
return false;
}
bool isLastStream(pqPipelineSource* src)
......
......@@ -35,13 +35,15 @@ variables:
sb_cmake_option_USE_SYSTEM_qt5: # Most of our Platforms use qt5 with offline Installers
value: '-DUSE_SYSTEM_qt5=True'
sb_cmake_option_ENABLE_ceres:
value: '-DENABLE_ceres=True'
value: '-DENABLE_ceres=False'
sb_cmake_option_ENABLE_nanoflann:
value: '-DENABLE_nanoflann=True'
value: '-DENABLE_nanoflann=False'
sb_cmake_option_ENABLE_pcl:
value: '-DENABLE_pcl=True'
value: '-DENABLE_pcl=False'
sb_cmake_option_LIDARVIEW_BUILD_SLAM:
value: '-DLIDARVIEW_BUILD_SLAM=True'
value: '-DLIDARVIEW_BUILD_SLAM=False'
sb_cmake_option_INTERPRETER_ENABLE_Hesai:
value: '' # Keep it empty as only LidarView use it
stages:
- superbuild
......@@ -112,7 +114,7 @@ workflow:
- cmake -E remove_directory $LV_PROJECT_BSB_PATH
- cmake -E make_directory $LV_PROJECT_SRC_PATH
- cmake -E make_directory $LV_PROJECT_BSB_PATH
- echo "CI SB OPTIONS= $sb_cmake_option_USE_SYSTEM_qt5 $sb_cmake_option_ENABLE_ceres $sb_cmake_option_ENABLE_nanoflann $sb_cmake_option_ENABLE_pcl $sb_cmake_option_LIDARVIEW_BUILD_SLAM"
- echo "CI SB OPTIONS= $sb_cmake_option_USE_SYSTEM_qt5 $sb_cmake_option_ENABLE_ceres $sb_cmake_option_ENABLE_nanoflann $sb_cmake_option_ENABLE_pcl $sb_cmake_option_LIDARVIEW_BUILD_SLAM $sb_cmake_option_INTERPRETER_ENABLE_Hesai"
- cd $LV_PROJECT_SRC_PATH # First Fetch Master
- echo "Using SB_CI_AUTH=$SB_CI_AUTH" # Optional auth for private repositories e.g "gitlab-ci-token:[masked]@"
- git clone -j 8 https://$SB_CI_AUTH$CI_SERVER_HOST/$CI_PROJECT_PATH.git . # Clone in Place, no submodules, no recursive, smudged
......@@ -144,6 +146,7 @@ workflow:
$sb_cmake_option_ENABLE_nanoflann
$sb_cmake_option_ENABLE_pcl
$sb_cmake_option_LIDARVIEW_BUILD_SLAM
$sb_cmake_option_INTERPRETER_ENABLE_Hesai
$SB_ADDITIONAL_PARAMS
-DBUILD_TESTING=ON
-Dsuperbuild_download_location="../downloads"
......
......@@ -16,7 +16,7 @@
# Ship Qt5
foreach (qt5_opengl_lib IN ITEMS opengl32sw libEGL libGLESv2 libEGLd
Qt5Core Qt5Gui Qt5Help Qt5PrintSupport Qt5Sql Qt5Svg Qt5Widgets)
Qt5Core Qt5Gui Qt5Help Qt5PrintSupport Qt5Sql Qt5Svg Qt5Widgets Qt5Network)
install(FILES "${Qt5_DIR}/../../../bin/${qt5_opengl_lib}.dll"
DESTINATION "bin"
)
......
......@@ -46,7 +46,7 @@ The specific version of the following tools may or may not be available in your
- **Microsoft Visual Studio 2019** Only the 2019 MSVC version is supported.
- **Qt 5.12.9** You must get it through the offline installer (Building Qt5 from source is a lengthy process)
- **Qt 5.15.7** You must get it through the offline installer (Building Qt5 from source is a lengthy process)
For more details, see [Additional Instructions](#qt-installer).
......@@ -92,7 +92,7 @@ The specific version of the following tools may or may not be available in your
`cd <work-directory>\build`
`cmake <work-directory>\src\Superbuild -GNinja -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_qt5=True -DQt5_DIR="C:/Qt/Qt5.12.9/5.12.9/msvc2017_64/lib/cmake/Qt5"`
`cmake <work-directory>\src\Superbuild -GNinja -DCMAKE_BUILD_TYPE=Release -DUSE_SYSTEM_qt5=True -DQt5_DIR="C:/Qt/5.15.7/msvc2019_64/lib/cmake/Qt5"`
`cmake --build . -j`
......@@ -121,7 +121,7 @@ The specific version of the following tools may or may not be available in your
Qt5 is built automatically by the Superbuild, however to speed up the build process, you can opt to use built-binaries with the following options:
- If you system's package manager offers Qt5 with version 5.12.9 or higher (e.g Ubuntu20.04) use:
- If you system's package manager offers Qt5 with version 5.15.7 or higher (e.g Ubuntu20.04) use:
`qt5-default qtmultimedia5-dev qtbase5-private-dev libqt5x11extras5-dev libqt5svg5-dev libqt5xmlpatterns5 qttools5-dev qtxmlpatterns5-dev-tools`
......@@ -246,9 +246,9 @@ Detailed Instructions to run LidarView-based app Tests: [LidarView Testing Guide
## Additional instructions <a name="additional-instructions"></a>
- **Get QT5.12.9 From Installer** <a name="qt-installer"></a>
- **Get QT5.15.7 From Installer** <a name="qt-installer"></a>
Qt5.12.9 - [Offline Installer](https://download.qt.io/official_releases/qt/5.12/5.12.9/)
Qt5.15.7 - [Offline Installer](https://www.qt.io/download-open-source#contributing)
Run the installer offline to alleviate the need to register
......@@ -267,9 +267,9 @@ Detailed Instructions to run LidarView-based app Tests: [LidarView Testing Guide
**Always forward slashes, UNIX style, on all platforms**
e.g If installed in `/opt`: `-DQt5_DIR=/opt/Qt5.12.9/5.12.9/gcc_64/lib/cmake/Qt5`
e.g If installed in `/opt`: `-DQt5_DIR=/opt/Qt5.15.7/5.15.7/gcc_64/lib/cmake/Qt5`
e.g If installed in `C:\` : `-DQt5_DIR=C:/Qt/Qt5.12.9/5.12.9/msvc2017_64/lib/cmake/Qt5`
e.g If installed in `C:\` : `-DQt5_DIR=C:/Qt/5.15.7/msvc2019_64/lib/cmake/Qt5`
## Troubleshooting / FAQ <a name="faq-instructions"></a>
......
......@@ -10,7 +10,6 @@ include(CMakeDependentOption)
message(AUTHOR_WARNING "Until the 'Speedup interpolator' merge request is integrated to VTK, we provide the patch")
set(interpolator_pach_until_vtk_update
vtkPatch/vtkCustomPiecewiseFunction.cxx
vtkPatch/vtkCustomQuaternionInterpolator.cxx
vtkPatch/vtkCustomTupleInterpolator.cxx
)
......
......@@ -18,7 +18,7 @@
#include "vtkObjectFactory.h"
#include "vtkProp3D.h"
#include "vtkQuaternion.h"
#include "vtkPatch/vtkCustomQuaternionInterpolator.h"
#include "vtkQuaternionInterpolator.h"
#include "vtkTransform.h"
#include "vtkPatch/vtkCustomTupleInterpolator.h"
#include <list>
......@@ -124,7 +124,7 @@ vtkCustomTransformInterpolator::vtkCustomTransformInterpolator()
// Spline interpolation
this->PositionInterpolator = vtkCustomTupleInterpolator::New();
this->ScaleInterpolator = vtkCustomTupleInterpolator::New();
this->RotationInterpolator = vtkCustomQuaternionInterpolator::New();
this->RotationInterpolator = vtkQuaternionInterpolator::New();
// Quaternion interpolation
this->TransformList = new vtkTransformList;
......@@ -357,7 +357,7 @@ void vtkCustomTransformInterpolator::SetScaleInterpolator(vtkCustomTupleInterpol
}
//----------------------------------------------------------------------------
void vtkCustomTransformInterpolator::SetRotationInterpolator(vtkCustomQuaternionInterpolator* ri)
void vtkCustomTransformInterpolator::SetRotationInterpolator(vtkQuaternionInterpolator* ri)
{
if (this->RotationInterpolator != ri)
{
......@@ -395,7 +395,7 @@ void vtkCustomTransformInterpolator::InitializeInterpolation()
}
if (!this->RotationInterpolator)
{
this->RotationInterpolator = vtkCustomQuaternionInterpolator::New();
this->RotationInterpolator = vtkQuaternionInterpolator::New();
}
if (this->InterpolationType == INTERPOLATION_TYPE_LINEAR
......
......@@ -56,7 +56,7 @@ class vtkTransform;
class vtkMatrix4x4;
class vtkProp3D;
class vtkCustomTupleInterpolator;
class vtkCustomQuaternionInterpolator;
class vtkQuaternionInterpolator;
class vtkTransformList;
struct vtkQTransform;
......@@ -166,8 +166,8 @@ public:
// of the transformation matrix. Note that you can modify the behavior of
// the interpolator (linear vs spline interpolation; change spline basis)
// by manipulating the interpolator instances.
virtual void SetRotationInterpolator(vtkCustomQuaternionInterpolator*);
vtkGetObjectMacro(RotationInterpolator, vtkCustomQuaternionInterpolator);
virtual void SetRotationInterpolator(vtkQuaternionInterpolator*);
vtkGetObjectMacro(RotationInterpolator, vtkQuaternionInterpolator);
// Description:
// Override GetMTime() because we depend on the interpolators which may be
......@@ -185,7 +185,7 @@ protected:
// Interpolators
vtkCustomTupleInterpolator* PositionInterpolator;
vtkCustomTupleInterpolator* ScaleInterpolator;
vtkCustomQuaternionInterpolator* RotationInterpolator;
vtkQuaternionInterpolator* RotationInterpolator;
// Initialize the interpolating splines
int Initialized;
......
#include "GPSProjectionUtils.h"
#include <sstream>
#include <cassert>
#include <sstream>
#include <vtkObject.h>
#include <vtkSetGet.h>
//------------------------------------------------------------------------------
int LatLongToZone(double lat, double lon)
{
......@@ -46,35 +45,32 @@ UTMProjector::~UTMProjector()
{
if (this->IsInitialized())
{
pj_free(this->pj_utm);
proj_destroy(this->pj_utm);
}
}
//------------------------------------------------------------------------------
void UTMProjector::Project(double lat, double lon, double &easting, double &northing)
void UTMProjector::Project(double lat, double lon, double& easting, double& northing)
{
if (!this->IsInitialized())
{
this->Init(lat, lon);
}
projUV lp;
lp.u = DEG_TO_RAD * lon;
lp.v = DEG_TO_RAD * lat;
PJ_COORD coords = proj_coord(lat, lon, 0, 0);
projUV xy;
xy = pj_fwd(lp, pj_utm);
if (pj_utm->ctx->last_errno != 0 && this->ShouldWarnOnWeirdGPSData)
PJ_COORD result = proj_trans(this->pj_utm, PJ_FWD, coords);
if (proj_errno(this->pj_utm) != 0 && this->ShouldWarnOnWeirdGPSData)
{
vtkGenericWarningMacro("Error : WGS84 projection failed, this will create a GPS error. "
"Please check the latitude and longitude inputs");
}
// I checked the correspondence between xy.u/v and easting, northing
// I checked the correspondence between result.enu.e/n and easting, northing
// against a reliable converter for point: lat=4.613473, longitude=41.080385
// (easting increases when you go east, northing increases when you go north)
easting = xy.u;
northing = xy.v;
easting = result.enu.e;
northing = result.enu.n;
}
//------------------------------------------------------------------------------
......@@ -86,11 +82,11 @@ bool UTMProjector::IsInitialized()
//------------------------------------------------------------------------------
void UTMProjector::Init(double initial_lat, double initial_lon)
{
assert(!pj_utm);
assert(!this->pj_utm);
const int unsignedZone = LatLongToZone(initial_lat, initial_lon);
if (initial_lat < 0)
{
this->SignedUTMZone = - unsignedZone;
this->SignedUTMZone = -unsignedZone;
}
else
{
......@@ -112,5 +108,5 @@ void UTMProjector::Init(double initial_lat, double initial_lon)
utmparams << "+ellps=WGS84 ";
utmparams << "+units=m ";
utmparams << "+no_defs ";
pj_utm = pj_init_plus(utmparams.str().c_str());
this->pj_utm = proj_create_crs_to_crs(0, "EPSG:4326", utmparams.str().c_str(), nullptr);
}
......@@ -25,12 +25,13 @@
int LIDARCORE_EXPORT LatLongToZone(double lat, double lon);
class LIDARCORE_EXPORT UTMProjector
{
public:
public:
UTMProjector(bool shouldWarnOnWeirdGPSData = false)
: ShouldWarnOnWeirdGPSData(shouldWarnOnWeirdGPSData) {}
: ShouldWarnOnWeirdGPSData(shouldWarnOnWeirdGPSData)
{
}
~UTMProjector();
......@@ -39,13 +40,13 @@ class LIDARCORE_EXPORT UTMProjector
// SignedUTMZone: > 0 means northern hemisphere, < 0 southern
int SignedUTMZone = 0;
private:
private:
bool IsInitialized();
void Init(double initial_lat, double initial_lon);
bool ShouldWarnOnWeirdGPSData = true;
projPJ pj_utm = nullptr;
PJ* pj_utm = nullptr;
std::string UTMString;
};
......
......@@ -34,7 +34,7 @@ int SignedUTMToEPSG(int signedUTM)
}
else
{
return 32700 + (- signedUTM);
return 32700 + (-signedUTM);
}
}
......@@ -46,7 +46,7 @@ int EPSGToSignedUTM(int EPSG)
}
else if (EPSG >= 32701 && EPSG <= 32760)
{
return - (EPSG - 32700);
return -(EPSG - 32700);
}
else
{
......@@ -55,39 +55,27 @@ int EPSGToSignedUTM(int EPSG)
}
//-----------------------------------------------------------------------------
projPJ ProjFromEPSG(int epsg)
PJ* ProjFromEPSG(int epsg)
{
std::ostringstream ss;
ss << "+init=epsg:" << epsg << " ";
return pj_init_plus(ss.str().c_str());
return proj_create(0, ss.str().c_str());
}
//-----------------------------------------------------------------------------
Eigen::Vector3d ConvertGcs(Eigen::Vector3d p, projPJ inProj, projPJ outProj)
Eigen::Vector3d ConvertGcs(Eigen::Vector3d p, PJ* inProj, PJ* outProj)
{
if (pj_is_latlong(inProj))
{
p[0] *= DEG_TO_RAD;
p[1] *= DEG_TO_RAD;
}
double* const data = p.data();
//std::cout << "position in : [" << p[0] << ";" << p[1] << ";" << p[2] << "]" << std::endl;
int last_errno = pj_transform(inProj, outProj, 1, 1, data + 0, data + 1, data + 2);
//std::cout << "position out : [" << p[0] << ";" << p[1] << ";" << p[2] << "]" << std::endl << std::endl;
PJ* transformPJ = proj_create_crs_to_crs_from_pj(0, inProj, outProj, nullptr, nullptr);
if (last_errno != 0)
{
vtkGenericWarningMacro("Error : CRS conversion failed with error: " << last_errno);
}
PJ_COORD coord = proj_coord(p[0], p[1], p[2], 0);
PJ_COORD result = proj_trans(transformPJ, PJ_FWD, coord);
if (pj_is_latlong(outProj))
if (proj_errno(transformPJ) != 0)
{
p[0] *= RAD_TO_DEG;
p[1] *= RAD_TO_DEG;
vtkGenericWarningMacro("Error : CRS conversion failed with error: " << proj_errno(transformPJ));
}
return p;
return Eigen::Vector3d(result.enu.n, result.enu.e, result.enu.u);;
}
}
......@@ -151,13 +139,13 @@ void LASFileWriter::Close()
if (this->InProj != nullptr)
{
pj_free(this->InProj);
proj_destroy(this->InProj);
this->InProj = nullptr;
}
if (this->OutProj != nullptr)
{
pj_free(this->OutProj);
proj_destroy(this->OutProj);
this->OutProj = nullptr;
}
}
......@@ -211,11 +199,11 @@ void LASFileWriter::SetOrigin(double easting, double northing, double height)
srs.SetFromUserInput(ss.str());
this->header.SetSRS(srs);
}
catch (std::logic_error &e)
catch (std::logic_error& e)
{
std::cerr << "failed to set SRS (logic_error): " << e.what() << std::endl;
}
catch (std::runtime_error &e)
catch (std::runtime_error& e)
{
std::cerr << "failed to set SRS (runtime_error): " << e.what() << std::endl;
}
......@@ -229,8 +217,8 @@ void LASFileWriter::SetOrigin(double easting, double northing, double height)
//-----------------------------------------------------------------------------
void LASFileWriter::SetGeoConversionEPSG(int inEPSG, int outEPSG)
{
pj_free(this->InProj);
pj_free(this->OutProj);
proj_destroy(this->InProj);
proj_destroy(this->OutProj);
this->InProj = ProjFromEPSG(inEPSG);
this->OutProj = ProjFromEPSG(outEPSG);
......@@ -254,7 +242,7 @@ void LASFileWriter::SetGeoConversionUTM(int inOutSignedUTMZone, bool useLatLonFo
utmparamsIn << "+datum=WGS84 ";
utmparamsIn << "+units=m ";
utmparamsIn << "+no_defs ";
this->InProj = pj_init_plus(utmparamsIn.str().c_str());
this->InProj = proj_create(0, utmparamsIn.str().c_str());
std::cout << "init In : " << utmparamsIn.str() << std::endl;
if (useLatLonForOut)
......@@ -264,7 +252,7 @@ void LASFileWriter::SetGeoConversionUTM(int inOutSignedUTMZone, bool useLatLonFo
utmparamsOut << "+ellps=WGS84 ";
utmparamsOut << "+datum=WGS84 ";
utmparamsOut << "+no_defs ";
this->OutProj = pj_init_plus(utmparamsOut.str().c_str());
this->OutProj = proj_create(0, utmparamsOut.str().c_str());
std::cout << "init Out : " << utmparamsOut.str() << std::endl;
// 4326 is EPSG ID code for lat-long-alt coordinates
this->OutGcsEPSG = 4326;
......@@ -284,7 +272,7 @@ void LASFileWriter::SetGeoConversionUTM(int inOutSignedUTMZone, bool useLatLonFo
utmparamsOut << "+ellps=WGS84 ";
utmparamsOut << "+datum=WGS84 ";
utmparamsOut << "+no_defs ";
this->OutProj = pj_init_plus(utmparamsOut.str().c_str());
this->OutProj = proj_create(0, utmparamsOut.str().c_str());
this->OutGcsEPSG = SignedUTMToEPSG(inOutSignedUTMZone);
}
......@@ -292,11 +280,11 @@ void LASFileWriter::SetGeoConversionUTM(int inOutSignedUTMZone, bool useLatLonFo
std::cout << "OutProj created : " << this->OutProj << std::endl;
if (this->InProj)
{
std::cout << "inProj datum_type : [" << this->InProj->datum_type << "]" << std::endl;
std::cout << "inProj datum_type : [" << proj_get_type(this->InProj) << "]" << std::endl;
}
if (this->OutProj)
{
std::cout << "outProj datum_type : [" << this->OutProj->datum_type << "]" << std::endl;
std::cout << "outProj datum_type : [" << proj_get_type(this->OutProj) << "]" << std::endl;
}
}
......@@ -325,17 +313,17 @@ void LASFileWriter::WriteFrame(vtkPolyData* data)
vtkDataArray* laserIdData = data->GetPointData()->GetArray("laser_id");
vtkDataArray* timestampData = data->GetPointData()->GetArray("adjustedtime");
double timeToSec = 1e-6;
if(timestampData == nullptr)
if (timestampData == nullptr)
{
timestampData = data->GetPointData()->GetArray("Raw Timestamp");
timeToSec = 1e-9;
}
if(intensityData == nullptr)
if (intensityData == nullptr)
{
intensityData = data->GetPointData()->GetArray("Signal Photons");
}
if(laserIdData == nullptr)
if (laserIdData == nullptr)
{
laserIdData = data->GetPointData()->GetArray("Channel");
}
......@@ -345,7 +333,8 @@ void LASFileWriter::WriteFrame(vtkPolyData* data)
const vtkIdType numPoints = points->GetNumberOfPoints();
for (vtkIdType n = 0; n < numPoints; ++n)
{
const double time = timestampData == nullptr ? 0.0 : timestampData->GetComponent(n, 0) * timeToSec;
const double time =
timestampData == nullptr ? 0.0 : timestampData->GetComponent(n, 0) * timeToSec;
// This test implements the time-clamping feature
if (time >= this->MinTime && time <= this->MaxTime)
{
......@@ -360,17 +349,17 @@ void LASFileWriter::WriteFrame(vtkPolyData* data)
liblas::Point p(&this->Writer->GetHeader());
p.SetCoordinates(pos[0], pos[1], pos[2]);
p.SetIntensity(static_cast<uint16_t>(intensityData == nullptr ? 0.0 : intensityData->GetComponent(n, 0)));
p.SetIntensity(
static_cast<uint16_t>(intensityData == nullptr ? 0.0 : intensityData->GetComponent(n, 0)));
p.SetReturnNumber(1);
p.SetNumberOfReturns(1);
p.SetUserData(static_cast<uint8_t>(laserIdData == nullptr ? 0.0 : laserIdData->GetComponent(n, 0)));
p.SetUserData(
static_cast<uint8_t>(laserIdData == nullptr ? 0.0 : laserIdData->GetComponent(n, 0)));
if (this->WriteColor && colorData != nullptr)
{
liblas::Color color = liblas::Color(
static_cast<uint32_t>(colorData->GetComponent(n, 0)),
static_cast<uint32_t>(colorData->GetComponent(n, 1)),
static_cast<uint32_t>(colorData->GetComponent(n, 2))
);
liblas::Color color = liblas::Color(static_cast<uint32_t>(colorData->GetComponent(n, 0)),
static_cast<uint32_t>(colorData->GetComponent(n, 1)),
static_cast<uint32_t>(colorData->GetComponent(n, 2)));
p.SetColor(color);
}
p.SetTime(time);
......@@ -394,7 +383,7 @@ void LASFileWriter::UpdateMetaData(vtkPolyData* data)
vtkPoints* const points = data->GetPoints();
vtkDataArray* timestampData = data->GetPointData()->GetArray("timestamp");
double timeToSec = 1e-6;
if(timestampData == nullptr)
if (timestampData == nullptr)
{
timestampData = data->GetPointData()->GetArray("Raw Timestamp");
timeToSec = 1e-9;
......@@ -403,7 +392,8 @@ void LASFileWriter::UpdateMetaData(vtkPolyData* data)
const vtkIdType numPoints = points->GetNumberOfPoints();
for (vtkIdType n = 0; n < numPoints; ++n)
{
const double time = timestampData == nullptr ? 0.0 : timestampData->GetComponent(n, 0) * timeToSec;
const double time =
timestampData == nullptr ? 0.0 : timestampData->GetComponent(n, 0) * timeToSec;
if (time >= this->MinTime && time <= this->MaxTime)
{
Eigen::Vector3d pos;
......
......@@ -110,8 +110,8 @@ private:
liblas::Header header;
projPJ InProj; // used to intepret the polyDatas points
projPJ OutProj; // used to project the points into coordinates used inside LAS
PJ* InProj; // used to intepret the polyDatas points
PJ* OutProj; // used to project the points into coordinates used inside LAS
int OutGcsEPSG; // used to tell in the LAS header which projection is used
// Obviously, OutGcsEPSG should be coherent with OutProj
......
/*=========================================================================
Program: Visualization Toolkit
Module: vtkCustomQuaternionInterpolator.cxx
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
#include "vtkMath.h"
#include "vtkObjectFactory.h"
#include "vtkQuaternion.h"
#include "vtkCustomQuaternionInterpolator.h"
#include <vector>
vtkStandardNewMacro(vtkCustomQuaternionInterpolator);
//----------------------------------------------------------------------------
// PIMPL STL encapsulation for list of quaternions. The list is sorted on
// the spline parameter T (or Time) using a STL list.
// Here we define a quaternion class that includes extra information including
// a unit quaternion representation.
struct TimedQuaternion
{
double Time;
vtkQuaterniond Q; //VTK's quaternion: unit rotation axis with angles in degrees
TimedQuaternion()
: Q(0.0)
{
this->Time = 0.0;
}
TimedQuaternion(double t, vtkQuaterniond q)
{
this->Time = t;
this->Q = q;
}
};
// The list is arranged in increasing order in T
class vtkCustomQuaternionList : public std::vector<TimedQuaternion> {};
typedef vtkCustomQuaternionList::iterator QuaternionListIterator;
//----------------------------------------------------------------------------
vtkCustomQuaternionInterpolator::vtkCustomQuaternionInterpolator()
{
// Set up the interpolation
this->QuaternionList = new vtkCustomQuaternionList;
this->InterpolationType = INTERPOLATION_TYPE_SPLINE;
}
//----------------------------------------------------------------------------
vtkCustomQuaternionInterpolator::~vtkCustomQuaternionInterpolator()
{
this->Initialize();
delete this->QuaternionList;
}
//----------------------------------------------------------------------------
int vtkCustomQuaternionInterpolator::GetNumberOfQuaternions()
{
return static_cast<int>(this->QuaternionList->size());
}
//----------------------------------------------------------------------------
double vtkCustomQuaternionInterpolator::GetMinimumT()
{
if (this->QuaternionList->size() > 0)
{
return this->QuaternionList->front().Time;
}
else
{
return 0.0;
}
}
//----------------------------------------------------------------------------
double vtkCustomQuaternionInterpolator::GetMaximumT()
{
if (this->QuaternionList->size() > 0)
{
return this->QuaternionList->back().Time;
}
else
{
return 0.0;
}
}
//----------------------------------------------------------------------------
void vtkCustomQuaternionInterpolator::Initialize()
{
// Wipe out old data
this->QuaternionList->clear();
}
//----------------------------------------------------------------------------
void vtkCustomQuaternionInterpolator::AddQuaternion(double t, double q[4])
{
vtkQuaterniond quat(q);
this->AddQuaternion(t, quat);
}
//----------------------------------------------------------------------------
void vtkCustomQuaternionInterpolator::AddQuaternion(double t,
const vtkQuaterniond& q)
{
int size = static_cast<int>(this->QuaternionList->size());
// Check special cases: t at beginning or end of list
if ( size <= 0 || t < this->QuaternionList->front().Time )
{
this->QuaternionList->insert(this->QuaternionList->begin(),TimedQuaternion(t,q));
return;
}
else if ( t > this->QuaternionList->back().Time )
{
this->QuaternionList->push_back(TimedQuaternion(t,q));
return;
}
else if ( size == 1 && t == this->QuaternionList->front().Time )
{
this->QuaternionList->front() = TimedQuaternion(t,q);
return;
}
// Okay, insert in sorted order
QuaternionListIterator iter = this->QuaternionList->begin();
QuaternionListIterator nextIter = iter + 1;
for (int i=0; i < (size-1); i++, ++iter, ++nextIter)
{
if ( t == iter->Time )
{
(*iter) = TimedQuaternion(t,q); //overwrite
break;
}
else if ( t > iter->Time && t < nextIter->Time )
{
this->QuaternionList->insert(nextIter, TimedQuaternion(t,q));
break;
}
}//for not in the right spot
this->Modified();
}
//----------------------------------------------------------------------------
void vtkCustomQuaternionInterpolator::RemoveQuaternion(double t)
{
if ( t < this->QuaternionList->front().Time ||
t > this->QuaternionList->back().Time )
{
return;
}
QuaternionListIterator iter = this->QuaternionList->begin();
for ( ; iter->Time != t && iter != this->QuaternionList->end(); ++iter )
{
}
if ( iter != this->QuaternionList->end() )
{
this->QuaternionList->erase(iter);
}
this->Modified();
}
//----------------------------------------------------------------------------
void vtkCustomQuaternionInterpolator::InterpolateQuaternion(double t, double q[4])
{
vtkQuaterniond quat(q);
this->InterpolateQuaternion(t, quat);
for (int i = 0; i < 4; ++i)
{
q[i] = quat[i];
}
}
//----------------------------------------------------------------------------
void vtkCustomQuaternionInterpolator::InterpolateQuaternion(double t,
vtkQuaterniond& q)
{
// The quaternion may be clamped if it is outside the range specified
if ( t <= this->QuaternionList->front().Time )
{
TimedQuaternion &Q = this->QuaternionList->front();
q = Q.Q;
return;
}
else if ( t >= this->QuaternionList->back().Time )
{
TimedQuaternion &Q = this->QuaternionList->front();
q = Q.Q;
return;
}
// Depending on the interpolation type we do the right thing.
// The code above guarantees that there are at least two quaternions defined.
int numQuats = this->GetNumberOfQuaternions();
if ( this->InterpolationType == INTERPOLATION_TYPE_LINEAR || numQuats < 3 )
{
QuaternionListIterator iter = this->QuaternionList->begin();
QuaternionListIterator nextIter = iter + 1;
for ( ; nextIter != this->QuaternionList->end(); ++iter, ++nextIter)
{
if ( iter->Time <= t && t <= nextIter->Time )
{
double T = (t - iter->Time) / (nextIter->Time - iter->Time);
q = iter->Q.Slerp(T,nextIter->Q);
break;
}
}
}//if linear quaternion interpolation
else // this->InterpolationType == INTERPOLATION_TYPE_SPLINE
{
QuaternionListIterator iter = this->QuaternionList->begin();
QuaternionListIterator nextIter = iter + 1;
QuaternionListIterator iter0, iter1, iter2, iter3;
//find the interval
double T=0.0;
int i;
for (i=0; nextIter != this->QuaternionList->end(); ++iter, ++nextIter, ++i)
{
if ( iter->Time <= t && t <= nextIter->Time )
{
T = (t - iter->Time) / (nextIter->Time - iter->Time);
break;
}
}
vtkQuaterniond ai, bi, qc, qd;
if ( i == 0 ) //initial interval
{
iter1 = iter;
iter2 = nextIter;
iter3 = nextIter + 1;
ai = iter1->Q.Normalized(); //just duplicate first quaternion
vtkQuaterniond q1 = iter1->Q.Normalized();
bi = q1.InnerPoint(iter2->Q.Normalized(), iter3->Q.Normalized());
}
else if ( i == (numQuats-2) ) //final interval
{
iter0 = iter - 1;
iter1 = iter;
iter2 = nextIter;
vtkQuaterniond q0 = iter0->Q.Normalized();
ai = q0.InnerPoint(iter1->Q.Normalized(), iter2->Q.Normalized());
bi = iter2->Q.Normalized(); //just duplicate last quaternion
}
else //in a middle interval somewhere
{
iter0 = iter - 1;
iter1 = iter;
iter2 = nextIter;
iter3 = nextIter + 1;
vtkQuaterniond q0 = iter0->Q.Normalized();
ai = q0.InnerPoint(iter1->Q.Normalized(), iter2->Q.Normalized());
vtkQuaterniond q1 = iter1->Q.Normalized();
bi = q1.InnerPoint(iter2->Q.Normalized(), iter3->Q.Normalized());
}
// These three Slerp operations implement a Squad interpolation
vtkQuaterniond q1 = iter1->Q.Normalized();
qc = q1.Slerp(T,iter2->Q.Normalized());
qd = ai.Slerp(T,bi);
q = qc.Slerp(2.0*T*(1.0-T),qd);
q.NormalizeWithAngleInDegrees();
}
return;
}
//----------------------------------------------------------------------------
void vtkCustomQuaternionInterpolator::PrintSelf(ostream& os, vtkIndent indent)
{
this->Superclass::PrintSelf(os, indent);
os << indent << "QuaternionList: " << this->QuaternionList->size()
<< " quaternions to interpolate\n";
os << indent << "InterpolationType: "
<< (this->InterpolationType == INTERPOLATION_TYPE_LINEAR ?
"Linear\n" : "Spline\n");
}
/*=========================================================================
Program: Visualization Toolkit
Module: vtkCustomQuaternionInterpolator.h
Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
All rights reserved.
See Copyright.txt or http://www.kitware.com/Copyright.htm for details.
This software is distributed WITHOUT ANY WARRANTY; without even
the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// .NAME vtkCustomQuaternionInterpolator - interpolate a quaternion
// .SECTION Description
// This class is used to interpolate a series of quaternions representing
// the rotations of a 3D object. The interpolation may be linear in form
// (using spherical linear interpolation SLERP), or via spline interpolation
// (using SQUAD). In either case the interpolation is specialized to
// quaternions since the interpolation occurs on the surface of the unit
// quaternion sphere.
//
// To use this class, specify at least two pairs of (t,q[4]) with the
// AddQuaternion() method. Next interpolate the tuples with the
// InterpolateQuaternion(t,q[4]) method, where "t" must be in the range of
// (t_min,t_max) parameter values specified by the AddQuaternion() method (t
// is clamped otherwise), and q[4] is filled in by the method.
//
// There are several important background references. Ken Shoemake described
// the practical application of quaternions for the interpolation of rotation
// (K. Shoemake, "Animating rotation with quaternion curves", Computer
// Graphics (Siggraph '85) 19(3):245--254, 1985). Another fine reference
// (available on-line) is E. B. Dam, M. Koch, and M. Lillholm, Technical
// Report DIKU-TR-98/5, Dept. of Computer Science, University of Copenhagen,
// Denmark.
//
// .SECTION Caveats
// Note that for two or less quaternions, Slerp (linear) interpolation is
// performed even if spline interpolation is requested. Also, the tangents to
// the first and last segments of spline interpolation are (arbitrarily)
// defined by repeating the first and last quaternions.
//
// There are several methods particular to quaternions (norms, products,
// etc.) implemented interior to this class. These may be moved to a separate
// quaternion class at some point.
//
// .SECTION See also
// vtkMasterMindQuaternion
#ifndef vtkCustomQuaternionInterpolator_h
#define vtkCustomQuaternionInterpolator_h
#include "vtkCommonMathModule.h" // For export macro
#include "vtkObject.h"
class vtkQuaterniond;
class vtkCustomQuaternionList;
class vtkCustomQuaternionInterpolator : public vtkObject
{
public:
vtkTypeMacro(vtkCustomQuaternionInterpolator, vtkObject);
void PrintSelf(ostream& os, vtkIndent indent) override;
// Description:
// Instantiate the class.
static vtkCustomQuaternionInterpolator* New();
// Description:
// Return the number of quaternions in the list of quaternions to be
// interpolated.
int GetNumberOfQuaternions();
// Description:
// Obtain some information about the interpolation range. The numbers
// returned (corresponding to parameter t, usually thought of as time)
// are undefined if the list of transforms is empty. This is a convenience
// method for interpolation.
double GetMinimumT();
double GetMaximumT();
// Description:
// Reset the class so that it contains no data; i.e., the array of (t,q[4])
// information is discarded.
void Initialize();
// Description:
// Add another quaternion to the list of quaternions to be interpolated.
// Note that using the same time t value more than once replaces the
// previous quaternion at t. At least one quaternions must be added to
// define an interpolation functios.
void AddQuaternion(double t, const vtkQuaterniond& q);
void AddQuaternion(double t, double q[4]);
// Description:
// Delete the quaternion at a particular parameter t. If there is no
// quaternion tuple defined at t, then the method does nothing.
void RemoveQuaternion(double t);
// Description:
// Interpolate the list of quaternions and determine a new quaternion
// (i.e., fill in the quaternion provided). If t is outside the range of
// (min,max) values, then t is clamped to lie within the range.
void InterpolateQuaternion(double t, vtkQuaterniond& q);
void InterpolateQuaternion(double t, double q[4]);
//BTX
// Description:
// Enums to control the type of interpolation to use.
enum {INTERPOLATION_TYPE_LINEAR=0,
INTERPOLATION_TYPE_SPLINE
};
//ETX
// Description:
// Specify which type of function to use for interpolation. By default
// (SetInterpolationFunctionToSpline()), cubic spline interpolation using a
// modifed Kochanek basis is employed. Otherwise, if
// SetInterpolationFunctionToLinear() is invoked, linear spherical interpolation
// is used between each pair of quaternions.
vtkSetClampMacro(InterpolationType,int,INTERPOLATION_TYPE_LINEAR,
INTERPOLATION_TYPE_SPLINE);
vtkGetMacro(InterpolationType,int);
void SetInterpolationTypeToLinear()
{this->SetInterpolationType(INTERPOLATION_TYPE_LINEAR);}
void SetInterpolationTypeToSpline()
{this->SetInterpolationType(INTERPOLATION_TYPE_SPLINE);}
protected:
vtkCustomQuaternionInterpolator();
virtual ~vtkCustomQuaternionInterpolator();
// Specify the type of interpolation to use
int InterpolationType;
// Internal variables for interpolation functions
vtkCustomQuaternionList *QuaternionList; //used for linear quaternion interpolation
private:
vtkCustomQuaternionInterpolator(const vtkCustomQuaternionInterpolator&); // Not implemented.
void operator=(const vtkCustomQuaternionInterpolator&); // Not implemented.
};
#endif
"""
Delete all render windows views and recreate a default one
"""
from paraview.simple import *
import lidarview.applogic as lv
# Get sources
reader = lv.getReader()
measurementGrid = FindSource('Measurement Grid')
# Get views
views = GetViews()
layout = GetLayout()
# Deletes all views
for view in views:
idx = layout.GetViewLocation(view)
Delete(view)
del view
layout.Collapse(idx)
# Create and assign a new one
renderView = CreateView('RenderView')
layout.AssignView(0, renderView)
# Show measurement grid and reader
if reader:
display = Show(reader[0], renderView)
ColorBy(display, ('POINTS', 'intensity'))
Show(measurementGrid, renderView)
# Reset Camera
lv.resetCameraToForwardView()
"""
Split the view in multiple rend windows and change display Properties for each
"""
from paraview.simple import *
import lidarview.applogic as lv
# Get sources
reader = lv.getReader()
measurementGrid = FindSource('Measurement Grid')
# Get views
renderView1 = GetActiveView()
layout1 = GetLayout()
# Split cells
layout1.SplitHorizontal(0, 0.5)
layout1.SplitVertical(1, 0.5)
layout1.SplitVertical(2, 0.5)
# Create a new 'Render View'
renderView2 = CreateView('RenderView')
renderView2.Background = [0.05, 0.43, 0.32]
renderView3 = CreateView('RenderView')
renderView3.Background = [0.43, 0.05, 0.34]
renderView4 = CreateView('RenderView')
renderView4.Background = [0.32, 0.34, 0.05]
# Place view in the layout
layout1.AssignView(4, renderView2)
layout1.AssignView(5, renderView3)
layout1.AssignView(6, renderView4)
# Show data in the 2 renderview
if reader:
display1 = Show(reader[0], renderView1)
ColorBy(display1, ('POINTS', 'azimuth'))
display2 = Show(reader[0], renderView2)
ColorBy(display2, ('POINTS', 'intensity'))
display3 = Show(reader[0], renderView3)
ColorBy(display3, ('POINTS', 'azimuth'))
display4 = Show(reader[0], renderView4)
ColorBy(display4, ('POINTS', 'intensity'))
# Show measurement grid
Show(measurementGrid, renderView1)
Show(measurementGrid, renderView2)
Show(measurementGrid, renderView3)
Show(measurementGrid, renderView4)
# Add camera links
AddCameraLink(renderView1, renderView2, "link_1")
AddCameraLink(renderView3, renderView4, "link_2")
# Change camera position
renderView1.CameraPosition = [-15, 150, 30]
renderView1.CameraViewUp = [0, 0, 1]
renderView3.CameraPosition = [-15, -150, 30]
renderView3.CameraViewUp = [0, 0, 1]
\ No newline at end of file