diff --git a/LidarCore/Filters/Temporal/vtkTemporalTransformsApplier.cxx b/LidarCore/Filters/Temporal/vtkTemporalTransformsApplier.cxx index 2b548ebb698509e8fb9bf9da126e1bcc1bc6af0c..3b83f7fa334f47ded60ddf19ef7879085e3b062d 100644 --- a/LidarCore/Filters/Temporal/vtkTemporalTransformsApplier.cxx +++ b/LidarCore/Filters/Temporal/vtkTemporalTransformsApplier.cxx @@ -1,16 +1,17 @@ -// Copyright 2019 Kitware SAS. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/*========================================================================= + + Program: LidarView + Module: vtkTemporalTransformApplier.cxx + + Copyright (c) Kitware Inc. + 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 "vtkTemporalTransformsApplier.h" @@ -47,24 +48,28 @@ vtkMTimeType vtkTemporalTransformsApplier::GetMTime() //----------------------------------------------------------------------------- int vtkTemporalTransformsApplier::RequestData(vtkInformation* vtkNotUsed(request), - vtkInformationVector** inputVector, - vtkInformationVector* outputVector) + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) { // Get the input - vtkPolyData* pointcloud = vtkPolyData::GetData(inputVector[1]->GetInformationObject(0)); - vtkPolyData* input = vtkPolyData::GetData(inputVector[0]->GetInformationObject(0)); + vtkPolyData* pointcloud = vtkPolyData::GetData(inputVector[0]->GetInformationObject(0)); + vtkPolyData* input = vtkPolyData::GetData(inputVector[1]->GetInformationObject(0)); auto trajectory = vtkTemporalTransforms::CreateFromPolyData(input); + if (!trajectory) + { + vtkErrorMacro(<< "Invalid trajectory."); + return 0; + } // Fill the interpolator if (this->Interpolator->GetNumberOfTransforms() == 0) { - auto type = this->Interpolator->GetInterpolationType(); + auto type = this->Interpolator->GetInterpolationType(); this->Interpolator = trajectory->CreateInterpolator(); this->Interpolator->SetInterpolationType(type); } - // Copy the input and create some new points vtkPolyData* output = vtkPolyData::GetData(outputVector); output->ShallowCopy(pointcloud); @@ -77,21 +82,21 @@ int vtkTemporalTransformsApplier::RequestData(vtkInformation* vtkNotUsed(request if (!this->InterpolateEachPoint) { // get timestamp - vtkInformation *inInfo = inputVector[0]->GetInformationObject(0); + vtkInformation* inInfo = inputVector[0]->GetInformationObject(0); double currentTimestamp = inInfo->Get(vtkStreamingDemandDrivenPipeline::UPDATE_TIME_STEP()); // get the right transform auto transform = vtkSmartPointer::New(); - this->Interpolator->InterpolateTransform(currentTimestamp,transform); + this->Interpolator->InterpolateTransform(currentTimestamp, transform); transform->Update(); // apply the transform for (vtkIdType i = 0; i < pointcloud->GetNumberOfPoints(); i++) { - float* inputPoint = reinterpret_cast - (pointcloud->GetPoints()->GetData()->WriteVoidPointer(3*i,1)); - float* outputPoint = reinterpret_cast - (output->GetPoints()->GetData()->WriteVoidPointer(3*i,1)); + float* inputPoint = + reinterpret_cast(pointcloud->GetPoints()->GetData()->WriteVoidPointer(3 * i, 1)); + float* outputPoint = + reinterpret_cast(output->GetPoints()->GetData()->WriteVoidPointer(3 * i, 1)); transform->InternalTransformPoint(inputPoint, outputPoint); } } @@ -102,8 +107,8 @@ int vtkTemporalTransformsApplier::RequestData(vtkInformation* vtkNotUsed(request auto timestamp = this->GetInputArrayToProcess(0, inputVector); if (!timestamp) { - vtkErrorMacro(<<"No TimeStamp array selected."); - return 1; + vtkErrorMacro(<< "No TimeStamp array selected."); + return 0; } for (vtkIdType i = 0; i < pointcloud->GetNumberOfPoints(); i++) { @@ -112,29 +117,28 @@ int vtkTemporalTransformsApplier::RequestData(vtkInformation* vtkNotUsed(request // get the right transform auto transform = vtkSmartPointer::New(); - this->Interpolator->InterpolateTransform(currentTimestamp,transform); + this->Interpolator->InterpolateTransform(currentTimestamp, transform); transform->Update(); // apply the transform - float* inputPoint = reinterpret_cast - (pointcloud->GetPoints()->GetData()->WriteVoidPointer(3*i,1)); - float* outputPoint = reinterpret_cast - (output->GetPoints()->GetData()->WriteVoidPointer(3*i,1)); + float* inputPoint = + reinterpret_cast(pointcloud->GetPoints()->GetData()->WriteVoidPointer(3 * i, 1)); + float* outputPoint = + reinterpret_cast(output->GetPoints()->GetData()->WriteVoidPointer(3 * i, 1)); transform->InternalTransformPoint(inputPoint, outputPoint); } } - return 1; } //----------------------------------------------------------------------------- int vtkTemporalTransformsApplier::RequestInformation(vtkInformation* vtkNotUsed(request), - vtkInformationVector** inputVector, - vtkInformationVector* outputVector) + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) { // indicate that this filter produce continuous timstep in the interpolator range vtkInformation* outInfo = outputVector->GetInformationObject(0); - double timeRange[2] = {this->Interpolator->GetMinimumT(), this->Interpolator->GetMaximumT()}; + double timeRange[2] = { this->Interpolator->GetMinimumT(), this->Interpolator->GetMaximumT() }; outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_RANGE(), timeRange, 2); // Propagate the information that steps are available: @@ -147,6 +151,7 @@ int vtkTemporalTransformsApplier::RequestInformation(vtkInformation* vtkNotUsed( { timesteps.push_back(inInfo->Get(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), i)); } - outInfo->Set(vtkStreamingDemandDrivenPipeline::TIME_STEPS(), ×teps.front(), timesteps.size()); + outInfo->Set( + vtkStreamingDemandDrivenPipeline::TIME_STEPS(), ×teps.front(), timesteps.size()); return 1; } diff --git a/LidarCore/Filters/Temporal/vtkTemporalTransformsApplier.h b/LidarCore/Filters/Temporal/vtkTemporalTransformsApplier.h index 090247c6f59e5717e84af2432e9927f495a56e4a..39453598d026a22d660be1945fc6be3346c57161 100644 --- a/LidarCore/Filters/Temporal/vtkTemporalTransformsApplier.h +++ b/LidarCore/Filters/Temporal/vtkTemporalTransformsApplier.h @@ -1,19 +1,20 @@ -// Copyright 2019 Kitware SAS. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -#ifndef TemporalTransformsAPPLIER_H -#define TemporalTransformsAPPLIER_H +/*========================================================================= + + Program: LidarView + Module: vtkTemporalTransformApplier.h + + Copyright (c) Kitware Inc. + 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. + +=========================================================================*/ + +#ifndef vtkTemporalTransformApplier_h +#define vtkTemporalTransformApplier_h #include #include @@ -32,11 +33,17 @@ class LVFILTERSTEMPORAL_EXPORT vtkTemporalTransformsApplier : public vtkPolyData { public: static vtkTemporalTransformsApplier* New(); - vtkTypeMacro(vtkTemporalTransformsApplier,vtkPolyDataAlgorithm) + vtkTypeMacro(vtkTemporalTransformsApplier, vtkPolyDataAlgorithm); + + /** + * Override GetMTime() because we depend on the TransformInterpolator + * which may be modified outside of this class. + */ + vtkMTimeType GetMTime() override; //@{ /** - * @copydoc vtkTemporalTransformsApplier::InterpolationType + * Interpolator used to get the right transform */ int GetInterpolationType() { return this->Interpolator->GetInterpolationType(); } void SetInterpolationType(int value) { this->Interpolator->SetInterpolationType(value); }; @@ -44,48 +51,41 @@ public: //@{ /** - * @copydoc vtkTemporalTransformsApplier::InterpolateEachPoint + * Indicate if a different transform should be apply to each point, + * or if the same transform should be apply to the whole point cloud. + * In the first case you must specify the array from the pointcloud containing the + * timestamp with 'SetInputArrayToProcess' */ - vtkGetMacro(InterpolateEachPoint, bool) - vtkSetMacro(InterpolateEachPoint, bool) + vtkGetMacro(InterpolateEachPoint, bool); + vtkSetMacro(InterpolateEachPoint, bool); //@} + //@{ /** - * @brief Override GetMTime() because we depend on the TransformInterpolator - * which may be modified outside of this class. + * Convert time in second default is for data in microsecond */ - vtkMTimeType GetMTime() override; - - vtkGetMacro(ConversionFactorToSecond, double) - vtkSetMacro(ConversionFactorToSecond, double) + vtkGetMacro(ConversionFactorToSecond, double); + vtkSetMacro(ConversionFactorToSecond, double); + //@} protected: vtkTemporalTransformsApplier(); int RequestInformation(vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector) override; + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) override; int RequestData(vtkInformation* request, - vtkInformationVector** inputVector, - vtkInformationVector* outputVector) override; + vtkInformationVector** inputVector, + vtkInformationVector* outputVector) override; private: - //! Indicate if a different transform should be apply to each point, - //! or if the same transform should be apply to the whole point cloud. - //! In the first case you must specify the array from the pointcloud containing the - //! timestamp with 'SetInputArrayToProcess' bool InterpolateEachPoint; - - //! Interpolator used to get the right transform vtkSmartPointer Interpolator; - - //! double to convert time in second, - //! default is for data in microsecond double ConversionFactorToSecond = 1e-6; vtkTemporalTransformsApplier(const vtkTemporalTransformsApplier&) /*= delete*/; - void operator =(const vtkTemporalTransformsApplier&) /*= delete*/; + void operator=(const vtkTemporalTransformsApplier&) /*= delete*/; }; -#endif // TemporalTransformsAPPLIER_H +#endif // vtkTemporalTransformApplier_h diff --git a/Plugins/LidarCorePlugin/Filters/TemporalTransformsApplier.xml b/Plugins/LidarCorePlugin/Filters/TemporalTransformsApplier.xml index c467170ae359d3993d03a85daaa89213770091a1..5663edaae1afe950ff5ff9287d951b252de45e16 100644 --- a/Plugins/LidarCorePlugin/Filters/TemporalTransformsApplier.xml +++ b/Plugins/LidarCorePlugin/Filters/TemporalTransformsApplier.xml @@ -1,102 +1,110 @@ - - + + + Using LiDAR frames and a SLAM trajectory, this filter applies the current transform corresponding to either the pipeline time or the current points time. - - - - - - - - - - Set the input trajectory - - + + + + + + + + + + Set the input point cloud + + - - - - - - - - - - Set the input point cloud - - + + + + + + + + + + Set the input trajectory + + - - - - - - - - - - This property indicates which type of interpolation will be used. - - + + + + + + + + + + The type of interpolation to use. + + - - - - This property indicates if each point will be interpolate independanly according to its timestamp - - + + + + Indicates if each point should be interpolated independently according to its timestamp or + if the same transform should be applied to the whole point cloud. + + - - - - - - - - - - + + + + + + + + Select the corresponding time array name. + + + + + - - - Double to convert Time unit in second, default is microsecond - - + + + Factor to convert Time unit in second, default is microsecond. + + + + + - +