Skip to content

Instantly share code, notes, and snippets.

@melund
Created December 19, 2019 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save melund/95fc8a0824fd31c9a2807d2e8fd2cbd5 to your computer and use it in GitHub Desktop.
Save melund/95fc8a0824fd31c9a2807d2e8fd2cbd5 to your computer and use it in GitHub Desktop.
Update to BTK since 3.0 release
This file has been truncated, but you can view the full file.
From 3169f41cfba3a3287b2674b3175b13830815f848 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Arnaud=20Barre=CC=81?= <arnaud.barre@gmail.com>
Date: Fri, 10 Jan 2014 22:07:34 +0100
Subject: [PATCH 1/2] Updates since 3.0
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
[UPD] CMake option BTK_EXTRA_COMPILER_WARNINGS works also with the Clang compiler.
Clang warnings: Unused variables.
Update the code of Open3DMotion to the commit c74cde4528 (part 1/2).
Update the code of Open3DMotion to the commit c74cde4528 (part 2/2).
Clang complains about signed/unsigned comparison.
Some unit tests failed under Linux 32-bit (compiled from a 64-bit machine) due to some round off errors. Adding the flag -ffloat-store solved most of the problems. The tolerance of one unit test had to be changed (from 1e-14 to 5e-14). It is not known if this fix is necessary if the code is built with a true 32-bit processor.
Update the code of Open3DMotion to the commit 21033cdb1a (part 1/3).
Update the code of Open3DMotion to the commit 21033cdb1a (part 2/3).
Update the code of Open3DMotion to the commit 21033cdb1a (part 3/3).
Copyright years updated.
New methods to extract signed/unsigned 64-bit integer from a binary file stream.
New predefined analog gain +/-1.65V.
Cleanup related to the predefined analog gains. Some predefined gains were removed from the C3D writer as they are not defined in the specification of the file format.
New method btk::Analog::SetGainFromValue.
Cleanup in the Delsys EMG file reader to use the method btk::Analog::SetGainFromValue.
[ENH] New reader for the Delsys file format HPF.
BTKCore set to the development version number “0.4dev”.
[FIX] Issue #76 (Crash of the acquisition reader when a MDF file has no marker).
The team behind Travis may update the build environment under MacOS X as CMake is now installed by default (see build 47 -- https://travis-ci.org/Biomechanical-ToolKit/BTKCore/builds/18427607).
Compiler error with GCC when the CMake option BTK_EXTRA_COMPILER_WARNINGS is activated.
[FIX] In case of a merging (and not a concatenation), the values for the points and the analog channels are not always correctly written (wrong number of frames to write).
[FIX] Bug in the OT XLS reader when the number of column's data is greater than the number of labels. Fix also an issue when the spatiotemporal parameters are empty as well as the events.
Because it seems GCC 4.7 does not like the Eigen::Matrix::isApprox method and because this method is not exactly what we want (we want to compare the value of each coefficient and not the Hilbert-Schmidt norm), the use of this function was replaced by some adapted code.
Following the commit 26a6af3, the unit tests are adapted to not use the method Eigen::Matrix::isApprox.
[FIX] Missing a test to know if the given corner's coordinate is equal than the stored one.
[FIX] Issue 77: "btkGetPoints has an error as pointsInfo.residuals returns an empty structure"
[UPD] FindMatlab updated to detected Matlab r2013(a|b) versions.
[UPD] FindMatlab updated to detected Matlab r2014a version.
[UPD] The analog offset is now stored as a double floating-point instead of an integer. This gives the possibility to store "fake" offset for digital sensors. The C3D file format was adapted in consequence to write the parameter ANALOG:OFFSET with the format Real if necessary.
The Python wrapping of the class btk::C3DFileIO was not adapted in the commit f5890c1.
Files reordered alphabetically.
[FIX] Wrong type use in the reinterpret_cast function.
Format HPF not listed in the table of supported acquisition file formats.
Some code in the IO module refactorized to be able later to create other binary stream/device (buffer, serial port, etc).
Macro btkChooseNativeBinaryFileStream renamed _btk_choose_native_binary_file_stream as it is only for internal usages.
Second part of the code factorization to read/write data into selected binary byte order stream outside of the class btk::BinaryFileStream.
Exception messages detailed to distinguish when it happens during the reading or the writing of a C3D file.
The code related the method btk::mmfilebuf::is_eob is removed as the logic behind this buffer cannot never reach this state.
Reuse of the variable 'n'.
It seems not necessary to remap the file buffer if the location of the written bytes goes afterwards exactly to the end of the buffer (position + number == buffer size).
Members related to a (random access) binary stream moved into the class btk::BinaryStream.
[UPD] TRB file reader improved to extract unnamed marker. This modification also resolves a crash related to the storage of unknown markers.
[FIX] The Matlab function btkCropAcquistion throws an error when the acquisition has no analog channel to crop (Luca Modenese).
This checks seems to be necessary because if the frames are calculated elsewhere in Matlab numFrames and startAt are generally integer numbers in "double" format. The original btkCropAcquisition function gives an error if index are not in integer format.
a fix to my wrong fix :-)
a fix to my wrong fix :-)
Added check on input variables
CMake seems no more installed by default in MacOS X environment. Plus, the gcc compiler entry was removed as it is not installed by default.
Commit 40ab4d7 breaks a unit test. The code was shifted in consequence.
[FIX] Wrong data extraction in the header of the Kistler DAT file format. The proposed modifications might be wrong as the comprehension of the bytes in header are not all known.
Upgrade eigen to the latest version. The previous version does not build with MSVC.
---
.travis.yml | 3 +-
CMake/FindMatlab.cmake | 10 +-
CMake/FindNumPy.cmake | 2 +-
CMake/FindOctave.cmake | 2 +-
CMake/btkExtraCompilerFlags.cmake | 18 +-
CMake/btkLinuxCompilerFlags.cmake | 11 +
CMakeLists.txt | 3 +-
.../btkAcquisitionUnitConverter.cpp | 2 +-
.../btkAcquisitionUnitConverter.h | 2 +-
Code/BasicFilters/btkAnalogOffsetRemover.cpp | 2 +-
Code/BasicFilters/btkAnalogOffsetRemover.h | 2 +-
Code/BasicFilters/btkCollectionAssembly.h | 2 +-
Code/BasicFilters/btkDownsampleFilter.h | 5 +-
.../btkForcePlatformWrenchFilter.cpp | 2 +-
.../btkForcePlatformWrenchFilter.h | 2 +-
.../btkForcePlatformsExtractor.cpp | 2 +-
.../BasicFilters/btkForcePlatformsExtractor.h | 2 +-
.../btkGroundReactionWrenchFilter.cpp | 2 +-
.../btkGroundReactionWrenchFilter.h | 2 +-
Code/BasicFilters/btkIMUsExtractor.cpp | 2 +-
Code/BasicFilters/btkIMUsExtractor.h | 2 +-
Code/BasicFilters/btkMeasureFrameExtractor.h | 2 +-
.../btkMergeAcquisitionFilter.cpp | 19 +-
Code/BasicFilters/btkMergeAcquisitionFilter.h | 4 +-
.../btkSeparateKnownVirtualMarkersFilter.cpp | 2 +-
.../btkSeparateKnownVirtualMarkersFilter.h | 2 +-
.../btkSpecializedPointsExtractor.cpp | 2 +-
.../btkSpecializedPointsExtractor.h | 2 +-
Code/BasicFilters/btkSubAcquisitionFilter.cpp | 2 +-
Code/BasicFilters/btkSubAcquisitionFilter.h | 2 +-
...alGroundReactionForceGaitEventDetector.cpp | 2 +-
...icalGroundReactionForceGaitEventDetector.h | 2 +-
.../btkWrenchDirectionAngleFilter.cpp | 2 +-
.../btkWrenchDirectionAngleFilter.h | 2 +-
Code/Common/btkAcquisition.cpp | 2 +-
Code/Common/btkAcquisition.h | 2 +-
Code/Common/btkAnalog.cpp | 50 +-
Code/Common/btkAnalog.h | 11 +-
Code/Common/btkAnalogCollection.h | 2 +-
Code/Common/btkCollection.h | 2 +-
Code/Common/btkConvert.h | 2 +-
Code/Common/btkCriticalSection_p.cpp | 2 +-
Code/Common/btkCriticalSection_p.h | 2 +-
Code/Common/btkDataObject.cpp | 2 +-
Code/Common/btkDataObject.h | 2 +-
Code/Common/btkEvent.cpp | 2 +-
Code/Common/btkEvent.h | 2 +-
Code/Common/btkEventCollection.h | 2 +-
Code/Common/btkException.h | 2 +-
Code/Common/btkForcePlatform.cpp | 37 +-
Code/Common/btkForcePlatform.h | 2 +-
Code/Common/btkForcePlatformCollection.h | 2 +-
Code/Common/btkForcePlatformTypes.h | 2 +-
Code/Common/btkIMU.cpp | 4 +-
Code/Common/btkIMU.h | 2 +-
Code/Common/btkIMUCollection.h | 2 +-
Code/Common/btkIMUTypes.h | 2 +-
Code/Common/btkLogger.cpp | 2 +-
Code/Common/btkLogger.h | 2 +-
Code/Common/btkMacro.h | 2 +-
Code/Common/btkMeasure.h | 2 +-
Code/Common/btkMetaData.cpp | 2 +-
Code/Common/btkMetaData.h | 2 +-
Code/Common/btkMetaDataInfo.cpp | 2 +-
Code/Common/btkMetaDataInfo.h | 2 +-
Code/Common/btkMetaDataInfo_p.h | 2 +-
Code/Common/btkMetaDataUtils.cpp | 2 +-
Code/Common/btkMetaDataUtils.h | 4 +-
Code/Common/btkNullPtr.h | 2 +-
Code/Common/btkObject.cpp | 2 +-
Code/Common/btkObject.h | 2 +-
Code/Common/btkPoint.cpp | 2 +-
Code/Common/btkPoint.h | 2 +-
Code/Common/btkPointCollection.h | 2 +-
Code/Common/btkProcessObject.cpp | 2 +-
Code/Common/btkProcessObject.h | 2 +-
Code/Common/btkSharedPtr.h | 2 +-
Code/Common/btkTriangleMesh.cpp | 2 +-
Code/Common/btkTriangleMesh.h | 2 +-
Code/Common/btkWrench.cpp | 2 +-
Code/Common/btkWrench.h | 2 +-
Code/Common/btkWrenchCollection.h | 2 +-
Code/IO/CMakeLists.txt | 5 +-
Code/IO/btkANBFileIO.cpp | 2 +-
Code/IO/btkANBFileIO.h | 2 +-
Code/IO/btkANCFileIO.cpp | 2 +-
Code/IO/btkANCFileIO.h | 2 +-
Code/IO/btkANGFileIO.cpp | 2 +-
Code/IO/btkANGFileIO.h | 2 +-
Code/IO/btkASCIIFileWriter.cpp | 2 +-
Code/IO/btkASCIIFileWriter.h | 2 +-
Code/IO/btkAcquisitionFileIO.cpp | 2 +-
Code/IO/btkAcquisitionFileIO.h | 2 +-
Code/IO/btkAcquisitionFileIOFactory.cpp | 2 +-
Code/IO/btkAcquisitionFileIOFactory.h | 2 +-
Code/IO/btkAcquisitionFileIOFactory_p.h | 2 +-
...kAcquisitionFileIOFactory_registration.cpp | 30 +-
Code/IO/btkAcquisitionFileIOHandle.h | 2 +-
Code/IO/btkAcquisitionFileIORegister.h | 2 +-
Code/IO/btkAcquisitionFileReader.cpp | 2 +-
Code/IO/btkAcquisitionFileReader.h | 2 +-
Code/IO/btkAcquisitionFileWriter.cpp | 2 +-
Code/IO/btkAcquisitionFileWriter.h | 2 +-
Code/IO/btkBSFFileIO.cpp | 12 +-
Code/IO/btkBSFFileIO.h | 2 +-
Code/IO/btkBinaryByteOrderFormat.h | 890 ++++++++++++++
Code/IO/btkBinaryFileStream.cpp | 1038 +----------------
Code/IO/btkBinaryFileStream.h | 241 ++--
Code/IO/btkBinaryFileStream.tpp | 182 +++
Code/IO/btkBinaryFileStream_mmfstream.cpp | 21 +-
Code/IO/btkBinaryFileStream_mmfstream.h | 5 +-
Code/IO/btkBinaryStream.h | 155 +++
Code/IO/btkBinaryStream.tpp | 698 +++++++++++
Code/IO/btkC3DFileIO.cpp | 91 +-
Code/IO/btkC3DFileIO.h | 10 +-
Code/IO/btkCALForcePlateFileIO.cpp | 2 +-
Code/IO/btkCALForcePlateFileIO.h | 2 +-
Code/IO/btkCLBFileIO.cpp | 34 +-
Code/IO/btkCLBFileIO.h | 2 +-
Code/IO/btkCodamotionFileIOUtils_p.cpp | 56 +-
Code/IO/btkCodamotionFileIOUtils_p.h | 2 +-
Code/IO/btkDelsysEMGFileIO.cpp | 28 +-
Code/IO/btkDelsysEMGFileIO.h | 2 +-
Code/IO/btkEMFFileIO.cpp | 2 +-
Code/IO/btkEMFFileIO.h | 2 +-
Code/IO/btkEMxFileIO.cpp | 2 +-
Code/IO/btkEMxFileIO.h | 2 +-
Code/IO/btkEliteFileIOUtils_p.cpp | 2 +-
Code/IO/btkEliteFileIOUtils_p.h | 2 +-
Code/IO/btkGRxFileIO.cpp | 2 +-
Code/IO/btkGRxFileIO.h | 2 +-
Code/IO/btkHPFFileIO.cpp | 341 ++++++
Code/IO/btkHPFFileIO.h | 79 ++
Code/IO/btkKistlerDATFileIO.cpp | 48 +-
Code/IO/btkKistlerDATFileIO.h | 2 +-
Code/IO/btkMDFFileIO.cpp | 2 +-
Code/IO/btkMDFFileIO.h | 2 +-
Code/IO/btkMOMFileIO.cpp | 2 +-
Code/IO/btkMOMFileIO.h | 2 +-
Code/IO/btkMotionAnalysisFileIOUtils.cpp | 2 +-
Code/IO/btkMotionAnalysisFileIOUtils.h | 2 +-
Code/IO/btkMotionAnalysisFileIOUtils_p.cpp | 35 +-
Code/IO/btkMotionAnalysisFileIOUtils_p.h | 2 +-
Code/IO/btkMultiSTLFileWriter.cpp | 2 +-
Code/IO/btkMultiSTLFileWriter.h | 2 +-
Code/IO/btkPWRFileIO.cpp | 2 +-
Code/IO/btkPWRFileIO.h | 2 +-
Code/IO/btkRAxFileIO.cpp | 2 +-
Code/IO/btkRAxFileIO.h | 2 +-
Code/IO/btkRICFileIO.cpp | 2 +-
Code/IO/btkRICFileIO.h | 2 +-
Code/IO/btkTDFFileIO.cpp | 2 +-
Code/IO/btkTDFFileIO.h | 2 +-
Code/IO/btkTRBFileIO.cpp | 26 +-
Code/IO/btkTRBFileIO.h | 2 +-
Code/IO/btkTRCFileIO.cpp | 2 +-
Code/IO/btkTRCFileIO.h | 2 +-
Code/IO/btkXLSOrthoTrakFileIO.cpp | 29 +-
Code/IO/btkXLSOrthoTrakFileIO.h | 2 +-
Code/IO/btkXMOVEFileIO.cpp | 2 +-
Code/IO/btkXMOVEFileIO.h | 2 +-
Copyright.txt | 2 +-
Documentation/API/FileFormatSupported.dox | 7 +
Documentation/Readme/License.dox.part | 2 +-
Documentation/Wrapping/Matlab/Web/FAQ.dox | 2 +-
.../btkGetForcePlatformWrenches.m | 2 +-
.../btkGetGroundReactionWrenches.m | 2 +-
.../btk/@BasicFilters/btkMergeAcquisitions.m | 2 +-
.../Matlab/btk/@Common/btkAppendAnalog.m | 2 +-
.../btk/@Common/btkAppendAnalysisParameter.m | 2 +-
.../Matlab/btk/@Common/btkAppendEvent.m | 2 +-
.../Matlab/btk/@Common/btkAppendMetaData.m | 2 +-
.../Matlab/btk/@Common/btkAppendPoint.m | 2 +-
.../Matlab/btk/@Common/btkClearAnalogs.m | 2 +-
.../Matlab/btk/@Common/btkClearAnalysis.m | 2 +-
.../Matlab/btk/@Common/btkClearEvents.m | 2 +-
.../Matlab/btk/@Common/btkClearMetaData.m | 2 +-
.../Matlab/btk/@Common/btkClearPoints.m | 2 +-
.../Matlab/btk/@Common/btkCloneAcquisition.m | 2 +-
.../Matlab/btk/@Common/btkDeleteAcquisition.m | 2 +-
.../Matlab/btk/@Common/btkGetAnalog.m | 2 +-
.../btk/@Common/btkGetAnalogFrameNumber.m | 2 +-
.../Matlab/btk/@Common/btkGetAnalogNumber.m | 2 +-
.../btk/@Common/btkGetAnalogResolution.m | 2 +-
.../btkGetAnalogSampleNumberPerFrame.m | 2 +-
.../Matlab/btk/@Common/btkGetAnalogs.m | 2 +-
.../Matlab/btk/@Common/btkGetAnalogsValues.m | 2 +-
.../Matlab/btk/@Common/btkGetAnalysis.m | 2 +-
.../Matlab/btk/@Common/btkGetAngles.m | 2 +-
.../Matlab/btk/@Common/btkGetAnglesValues.m | 2 +-
.../Matlab/btk/@Common/btkGetEvents.m | 2 +-
.../Matlab/btk/@Common/btkGetEventsValues.m | 2 +-
.../Matlab/btk/@Common/btkGetFirstFrame.m | 2 +-
.../Matlab/btk/@Common/btkGetForcePlatforms.m | 2 +-
.../Matlab/btk/@Common/btkGetForces.m | 2 +-
.../Matlab/btk/@Common/btkGetForcesValues.m | 2 +-
.../Matlab/btk/@Common/btkGetMarkers.m | 2 +-
.../Matlab/btk/@Common/btkGetMarkersValues.m | 2 +-
.../btk/@Common/btkGetMaxInterpolationGap.m | 2 +-
.../Matlab/btk/@Common/btkGetMetaData.m | 2 +-
.../Matlab/btk/@Common/btkGetMoments.m | 2 +-
.../Matlab/btk/@Common/btkGetMomentsValues.m | 2 +-
.../Wrapping/Matlab/btk/@Common/btkGetPoint.m | 2 +-
.../btk/@Common/btkGetPointFrameNumber.m | 2 +-
.../Matlab/btk/@Common/btkGetPointFrequency.m | 2 +-
.../Matlab/btk/@Common/btkGetPointNumber.m | 2 +-
.../Matlab/btk/@Common/btkGetPoints.m | 2 +-
.../btk/@Common/btkGetPointsResiduals.m | 2 +-
.../Matlab/btk/@Common/btkGetPointsUnit.m | 2 +-
.../Matlab/btk/@Common/btkGetPointsValues.m | 2 +-
.../Matlab/btk/@Common/btkGetPowers.m | 2 +-
.../Matlab/btk/@Common/btkGetPowersValues.m | 2 +-
.../Matlab/btk/@Common/btkGetScalars.m | 2 +-
.../Matlab/btk/@Common/btkGetScalarsValues.m | 2 +-
.../Matlab/btk/@Common/btkNewAcquisition.m | 2 +-
.../Matlab/btk/@Common/btkRemoveAnalog.m | 2 +-
.../btk/@Common/btkRemoveAnalysisParameter.m | 2 +-
.../Matlab/btk/@Common/btkRemoveEvent.m | 2 +-
.../Matlab/btk/@Common/btkRemoveMetaData.m | 2 +-
.../Matlab/btk/@Common/btkRemovePoint.m | 2 +-
.../btk/@Common/btkSetAnalogDescription.m | 2 +-
.../Matlab/btk/@Common/btkSetAnalogGain.m | 2 +-
.../Matlab/btk/@Common/btkSetAnalogLabel.m | 2 +-
.../Matlab/btk/@Common/btkSetAnalogNumber.m | 2 +-
.../Matlab/btk/@Common/btkSetAnalogOffset.m | 2 +-
.../btk/@Common/btkSetAnalogResolution.m | 2 +-
.../btkSetAnalogSampleNumberPerFrame.m | 2 +-
.../Matlab/btk/@Common/btkSetAnalogScale.m | 2 +-
.../Matlab/btk/@Common/btkSetAnalogUnit.m | 2 +-
.../Matlab/btk/@Common/btkSetAnalogValues.m | 2 +-
.../Matlab/btk/@Common/btkSetAnalogsValues.m | 2 +-
.../Matlab/btk/@Common/btkSetAnglesValues.m | 2 +-
.../btk/@Common/btkSetEventDescription.m | 2 +-
.../Matlab/btk/@Common/btkSetEventId.m | 2 +-
.../Matlab/btk/@Common/btkSetEventLabel.m | 2 +-
.../Matlab/btk/@Common/btkSetEventSubject.m | 2 +-
.../Matlab/btk/@Common/btkSetEventTime.m | 2 +-
.../Matlab/btk/@Common/btkSetFirstFrame.m | 2 +-
.../Matlab/btk/@Common/btkSetForcesValues.m | 2 +-
.../Matlab/btk/@Common/btkSetFrameNumber.m | 2 +-
.../Matlab/btk/@Common/btkSetFrequency.m | 2 +-
.../Matlab/btk/@Common/btkSetMarkersValues.m | 2 +-
.../btk/@Common/btkSetMaxInterpolationGap.m | 2 +-
.../btk/@Common/btkSetMetaDataDescription.m | 2 +-
.../btk/@Common/btkSetMetaDataDimensions.m | 2 +-
.../Matlab/btk/@Common/btkSetMetaDataFormat.m | 2 +-
.../Matlab/btk/@Common/btkSetMetaDataLabel.m | 2 +-
.../Matlab/btk/@Common/btkSetMetaDataUnlock.m | 2 +-
.../Matlab/btk/@Common/btkSetMetaDataValue.m | 2 +-
.../Matlab/btk/@Common/btkSetMomentsValues.m | 2 +-
.../Wrapping/Matlab/btk/@Common/btkSetPoint.m | 2 +-
.../btk/@Common/btkSetPointDescription.m | 2 +-
.../Matlab/btk/@Common/btkSetPointLabel.m | 2 +-
.../Matlab/btk/@Common/btkSetPointNumber.m | 2 +-
.../Matlab/btk/@Common/btkSetPointResiduals.m | 2 +-
.../Matlab/btk/@Common/btkSetPointType.m | 2 +-
.../Matlab/btk/@Common/btkSetPointValues.m | 2 +-
.../btk/@Common/btkSetPointsResiduals.m | 2 +-
.../Matlab/btk/@Common/btkSetPointsUnit.m | 2 +-
.../Matlab/btk/@Common/btkSetPointsValues.m | 2 +-
.../Matlab/btk/@Common/btkSetPowersValues.m | 2 +-
.../Matlab/btk/@Common/btkSetScalarsValues.m | 2 +-
.../Matlab/btk/@IO/btkReadAcquisition.m | 2 +-
.../Matlab/btk/@IO/btkWriteAcquisition.m | 2 +-
.../Wrapping/Matlab/btk/Contents.m.in | 2 +-
.../Matlab/btk/btkAppendForcePlatformType2.m | 2 +-
.../Wrapping/Matlab/btk/btkCloseAcquisition.m | 2 +-
.../Wrapping/Matlab/btk/btkCropAcquisition.m | 18 +-
.../Wrapping/Matlab/btk/btkEmulateC3Dserver.m | 2 +-
.../Wrapping/Matlab/btk/btkFindMetaData.m | 2 +-
.../Matlab/btk/btkGetAnalogsResolution.m | 2 +-
.../Wrapping/Matlab/btk/btkGetEventNumber.m | 2 +-
.../Wrapping/Matlab/btk/btkGetLastFrame.m | 2 +-
.../Wrapping/Matlab/btk/btkGetVersion.m.in | 2 +-
.../Wrapping/Matlab/btk/btkMetaDataInfo.m | 2 +-
.../Matlab/btk/btkSetAnalogsResolution.m | 2 +-
.../Wrapping/Matlab/btk/btkSetMetaData.m | 2 +-
.../Matlab/btk/btkSetMetaDataValues.m | 2 +-
.../btk/btkTransformTDFToViconC3DFile.m | 2 +-
.../Wrapping/Matlab/btk/tocbtkbasicfilters.m | 2 +-
.../Wrapping/Matlab/btk/tocbtkcommon.m | 2 +-
Documentation/Wrapping/Matlab/btk/tocbtkio.m | 2 +-
.../Wrapping/Python/btkCommonSwig.dox | 4 +
Documentation/Wrapping/Scilab/btk/license.txt | 2 +-
Examples/AcquisitionConverter/main.cpp | 2 +-
Readme.html | 2 +-
Testing/C++/AcquisitionUnitConverterTest.h | 24 +-
Testing/C++/C3DFileWriterTest.h | 57 +-
Testing/C++/CLBFileReaderTest.h | 2 +-
Testing/C++/DelsysEMGFileReaderTest.h | 3 +
Testing/C++/EigenIIRFilterDesignTest.h | 6 +-
Testing/C++/ForcePlatformsExtractorTest.h | 34 +-
Testing/C++/HPFFileIOTest.h | 31 +
Testing/C++/HPFFileReaderTest.h | 279 +++++
Testing/C++/KistlerDATFileReaderTest.h | 29 +-
Testing/C++/MDFFileReaderTest.h | 17 +
Testing/C++/MergeAcquisitionFilterTest.h | 115 +-
Testing/C++/TRBFileReaderTest.h | 33 +
Testing/C++/XLSOrthoTrakFileReaderTest.h | 45 +
Testing/C++/_TDDConfigure.h.in | 5 +
Testing/C++/_TDDIO.cpp | 2 +
Testing/Matlab/testBTKCommon.m | 13 +
Testing/Matlab/testBTKIO.m | 2 +-
.../generator/macro/cxxtest/TestGenerator.h | 2 +-
Utilities/Doxygen/Doxyfile_API.in | 2 +-
Utilities/EasyInstall/EasyInstall.java | 2 +-
Utilities/Open3DMotion/README-BTK.txt | 2 +-
.../Bindings/Python/BinMemFactoryPython.cpp | 16 +
.../Bindings/Python/BinMemFactoryPython.h | 24 +
.../Bindings/Python/MemoryHandlerPython.cpp | 62 +
.../Bindings/Python/MemoryHandlerPython.h | 51 +
.../Bindings/Python/PythonConvert.cpp | 201 ++++
.../Bindings/Python/PythonConvert.h | 30 +
.../Algorithms/ForceCalculator.cpp | 2 +-
.../Biomechanics/Algorithms/ForceCalculator.h | 2 +-
.../Biomechanics/Algorithms/Interpolate.cpp | 340 ++++++
.../Biomechanics/Algorithms/Interpolate.h | 34 +
.../Algorithms/MOSHFIT/RigidBodyShape.cpp | 296 +++++
.../Algorithms/MOSHFIT/RigidBodyShape.h | 137 +++
.../MOSHFIT/RigidBodyShapeCollection.cpp | 380 ++++++
.../MOSHFIT/RigidBodyShapeCollection.h | 124 ++
.../Biomechanics/Trial/EventGroup.cpp | 2 +-
.../Biomechanics/Trial/EventGroup.h | 2 +-
.../Biomechanics/Trial/TSFactory.cpp | 2 +-
.../Biomechanics/Trial/TSFactory.h | 33 +-
.../Biomechanics/Trial/TimeSequence.cpp | 9 +-
.../Biomechanics/Trial/TimeSequence.h | 8 +-
.../src/Open3DMotion/Maths/LinearSolve3.cpp | 4 -
.../src/Open3DMotion/Maths/Matrix3x3.cpp | 18 +-
.../src/Open3DMotion/MotionBundle/MOBL.cpp | 4 +-
.../src/Open3DMotion/MotionBundle/MOBL.h | 5 +-
.../MotionFile/Formats/C3D/C3DMachine.h | 2 +-
.../MotionFile/Formats/C3D/C3DRecord.h | 2 +-
.../MotionFile/Formats/C3D/FileFormatC3D.cpp | 3 +-
.../MotionFile/Formats/C3D/FileFormatC3D.h | 2 +-
.../Formats/CODAText/FileFormatCODAText.cpp | 2 +-
.../Formats/CODAText/FileFormatCODAText.h | 2 +-
.../Formats/CODAText/MATextInputStream.cpp | 1 +
.../Formats/CODAText/MATextReader.cpp | 8 +-
.../Formats/CODAText/MATextReader.h | 4 +-
.../MotionFile/Formats/MDF/FileFormatMDF.cpp | 112 +-
.../MotionFile/Formats/MDF/FileFormatMDF.h | 2 +-
.../MotionFile/Formats/MDF/ForcePlateMDF.cpp | 46 +-
.../MotionFile/Formats/MDF/MDFDescriptor.cpp | 4 +-
.../Formats/MoXie/FileFormatMoXie.cpp | 4 +-
.../Formats/MoXie/FileFormatMoXie.h | 2 +-
.../Formats/XMove/FileFormatXMove.cpp | 70 +-
.../Formats/XMove/FileFormatXMove.h | 8 +-
.../Formats/XMove/XMLReadingMachineLegacy.cpp | 6 +-
.../Formats/XMove/XMLReadingMachineLegacy.h | 4 +-
.../Formats/XMove/XMLWritingMachineLegacy.cpp | 2 +-
.../MotionFile/MotionFileException.h | 2 +-
.../MotionFile/MotionFileFormat.cpp | 4 +-
.../MotionFile/MotionFileFormat.h | 2 +-
.../MotionFile/MotionFileHandler.cpp | 15 +-
.../MotionFile/MotionFileHandler.h | 5 +-
.../OpenORM/Branches/TreeCompound.h | 7 +-
.../src/Open3DMotion/OpenORM/ClassName.h | 40 +
.../OpenORM/IO/BSON/BSONInputStreamGZ.cpp | 4 +-
.../OpenORM/IO/BSON/BSONInputStreamSTL.cpp | 3 +-
.../OpenORM/IO/BSON/BSONObjectIdHolder.cpp | 1 +
.../OpenORM/IO/BSON/BSONReader.cpp | 14 +-
.../Open3DMotion/OpenORM/IO/BSON/BSONReader.h | 9 +-
.../OpenORM/IO/BSON/BSONReaderMOBL.cpp | 11 +-
.../OpenORM/IO/BSON/BSONReaderMOBL.h | 4 +-
.../OpenORM/IO/XML/ReadWriteXMLBinary.cpp | 21 +-
.../OpenORM/IO/XML/ReadWriteXMLBool.cpp | 4 +-
.../OpenORM/IO/XML/ReadWriteXMLCompound.cpp | 2 +-
.../OpenORM/IO/XML/ReadWriteXMLFloat64.cpp | 4 +-
.../OpenORM/IO/XML/ReadWriteXMLInt32.cpp | 2 +-
.../OpenORM/IO/XML/ReadWriteXMLList.cpp | 2 +-
.../OpenORM/IO/XML/XMLReadingMachine.cpp | 5 +-
.../OpenORM/IO/XML/XMLReadingMachine.h | 12 +-
.../OpenORM/IO/XML/XMLWritingMachine.h | 3 +-
.../OpenORM/Leaves/MemoryHandler.cpp | 5 +-
.../OpenORM/Leaves/MemoryHandler.h | 5 +-
.../OpenORM/Leaves/MemoryHandlerBasic.cpp | 4 +-
.../OpenORM/Leaves/MemoryHandlerBasic.h | 3 +-
.../OpenORM/Leaves/MemoryHandlerNull.cpp | 4 +-
.../OpenORM/Leaves/MemoryHandlerNull.h | 3 +-
.../Open3DMotion/OpenORM/Leaves/TreeBinary.h | 7 +-
.../OpenORM/Leaves/TreeSimpleValue.h | 2 +-
.../OpenORM/Leaves/TreeString.cpp | 5 +
.../Open3DMotion/OpenORM/Leaves/TreeString.h | 2 +
.../OpenORM/Mappings/MapArrayCompound.h | 2 +-
.../OpenORM/Mappings/MapArrayFloat64.h | 2 +-
.../OpenORM/Mappings/MapElement.h | 2 +-
.../OpenORM/Mappings/RichBinary/BinIter.h | 2 +-
.../Mappings/RichBinary/BinMemFactory.h | 6 +-
.../RichBinary/BinMemFactoryDefault.cpp | 7 +-
.../RichBinary/BinMemFactoryDefault.h | 4 +-
.../Mappings/RichBinary/BinaryStructure.h | 2 +-
.../Mappings/RichBinary/RichBinary.cpp | 25 +-
.../OpenORM/Mappings/RichBinary/RichBinary.h | 5 +-
.../RichBinary/RichBinaryConvertFloat.cpp | 10 +-
.../RichBinary/RichBinaryConvertFloat.h | 4 +-
.../src/Open3DMotion/OpenORM/TreeValue.cpp | 12 +-
.../src/Open3DMotion/OpenORM/TreeValue.h | 28 +-
.../src/Open3DMotion/OpenORM/Types.h | 8 +
Utilities/SWIG/eigen.i | 2 +-
Utilities/eigen3/Eigen/Core | 6 +-
Utilities/eigen3/Eigen/Eigen2Support | 15 +-
Utilities/eigen3/Eigen/SparseCore | 2 +-
Utilities/eigen3/Eigen/src/Cholesky/LDLT.h | 109 +-
Utilities/eigen3/Eigen/src/Cholesky/LLT.h | 10 +-
Utilities/eigen3/Eigen/src/Cholesky/LLT_MKL.h | 2 +-
.../Eigen/src/CholmodSupport/CholmodSupport.h | 33 +-
Utilities/eigen3/Eigen/src/Core/Array.h | 17 +-
Utilities/eigen3/Eigen/src/Core/ArrayBase.h | 4 +-
.../eigen3/Eigen/src/Core/ArrayWrapper.h | 10 +
Utilities/eigen3/Eigen/src/Core/Assign.h | 15 +-
Utilities/eigen3/Eigen/src/Core/Block.h | 7 +-
.../eigen3/Eigen/src/Core/BooleanRedux.h | 8 +-
.../eigen3/Eigen/src/Core/CommaInitializer.h | 11 +
.../eigen3/Eigen/src/Core/CwiseBinaryOp.h | 3 +-
.../eigen3/Eigen/src/Core/CwiseUnaryOp.h | 2 +-
Utilities/eigen3/Eigen/src/Core/DenseBase.h | 28 +-
.../eigen3/Eigen/src/Core/DenseStorage.h | 271 +++--
Utilities/eigen3/Eigen/src/Core/Diagonal.h | 8 +-
.../eigen3/Eigen/src/Core/DiagonalProduct.h | 5 +-
Utilities/eigen3/Eigen/src/Core/EigenBase.h | 30 -
Utilities/eigen3/Eigen/src/Core/Functors.h | 45 +-
.../eigen3/Eigen/src/Core/GeneralProduct.h | 14 +-
Utilities/eigen3/Eigen/src/Core/IO.h | 9 +-
Utilities/eigen3/Eigen/src/Core/MapBase.h | 13 +-
.../eigen3/Eigen/src/Core/MathFunctions.h | 2 +-
Utilities/eigen3/Eigen/src/Core/Matrix.h | 17 +-
Utilities/eigen3/Eigen/src/Core/MatrixBase.h | 72 +-
.../eigen3/Eigen/src/Core/PermutationMatrix.h | 37 +-
.../eigen3/Eigen/src/Core/PlainObjectBase.h | 48 +-
Utilities/eigen3/Eigen/src/Core/ProductBase.h | 14 +-
Utilities/eigen3/Eigen/src/Core/Redux.h | 5 +-
Utilities/eigen3/Eigen/src/Core/Ref.h | 43 +-
Utilities/eigen3/Eigen/src/Core/Replicate.h | 4 +-
.../eigen3/Eigen/src/Core/ReturnByValue.h | 11 +
.../eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h | 10 +-
Utilities/eigen3/Eigen/src/Core/StableNorm.h | 27 +-
Utilities/eigen3/Eigen/src/Core/Transpose.h | 4 +-
.../eigen3/Eigen/src/Core/TriangularMatrix.h | 29 +-
.../eigen3/Eigen/src/Core/VectorwiseOp.h | 10 +-
.../eigen3/Eigen/src/Core/arch/NEON/Complex.h | 2 +-
.../Eigen/src/Core/arch/NEON/PacketMath.h | 20 +-
.../Eigen/src/Core/arch/SSE/MathFunctions.h | 25 +-
.../Eigen/src/Core/arch/SSE/PacketMath.h | 11 +-
.../src/Core/products/CoeffBasedProduct.h | 79 +-
.../Core/products/GeneralBlockPanelKernel.h | 6 +
.../src/Core/products/GeneralMatrixVector.h | 15 +-
.../Eigen/src/Core/products/Parallelizer.h | 17 +-
.../Core/products/SelfadjointMatrixVector.h | 6 +-
.../products/TriangularMatrixMatrix_MKL.h | 4 +-
.../Core/products/TriangularSolverMatrix.h | 9 +-
.../eigen3/Eigen/src/Core/util/Constants.h | 13 +
.../Eigen/src/Core/util/ForwardDeclarations.h | 3 +
.../eigen3/Eigen/src/Core/util/MKL_support.h | 51 +-
Utilities/eigen3/Eigen/src/Core/util/Macros.h | 47 +-
Utilities/eigen3/Eigen/src/Core/util/Memory.h | 40 +-
.../eigen3/Eigen/src/Core/util/StaticAssert.h | 4 +-
.../eigen3/Eigen/src/Core/util/XprHelper.h | 10 +-
.../Eigen/src/Eigen2Support/LeastSquares.h | 1 -
.../eigen3/Eigen/src/Eigen2Support/SVD.h | 3 +-
.../src/Eigenvalues/ComplexEigenSolver.h | 8 +
.../Eigen/src/Eigenvalues/EigenSolver.h | 9 +
.../src/Eigenvalues/GeneralizedEigenSolver.h | 9 +
.../eigen3/Eigen/src/Eigenvalues/RealQZ.h | 14 +-
.../eigen3/Eigen/src/Eigenvalues/RealSchur.h | 12 +-
.../src/Eigenvalues/SelfAdjointEigenSolver.h | 227 ++--
.../eigen3/Eigen/src/Geometry/AlignedBox.h | 85 +-
.../eigen3/Eigen/src/Geometry/AngleAxis.h | 6 +-
.../eigen3/Eigen/src/Geometry/EulerAngles.h | 2 +-
.../eigen3/Eigen/src/Geometry/Homogeneous.h | 2 +-
.../eigen3/Eigen/src/Geometry/Hyperplane.h | 12 +-
.../eigen3/Eigen/src/Geometry/Quaternion.h | 61 +-
.../eigen3/Eigen/src/Geometry/Rotation2D.h | 7 +-
.../eigen3/Eigen/src/Geometry/Transform.h | 37 +-
Utilities/eigen3/Eigen/src/Geometry/Umeyama.h | 10 +-
.../Eigen/src/Householder/BlockHouseholder.h | 2 +-
.../BasicPreconditioners.h | 4 +-
.../src/IterativeLinearSolvers/BiCGSTAB.h | 24 +-
.../ConjugateGradient.h | 33 +-
.../IterativeLinearSolvers/IncompleteLUT.h | 25 +-
.../IterativeSolverBase.h | 48 +-
Utilities/eigen3/Eigen/src/LU/FullPivLU.h | 21 +-
Utilities/eigen3/Eigen/src/LU/PartialPivLU.h | 8 +
.../eigen3/Eigen/src/OrderingMethods/Amd.h | 19 +-
.../Eigen/src/OrderingMethods/Ordering.h | 12 +-
.../Eigen/src/PardisoSupport/PardisoSupport.h | 2 +-
.../eigen3/Eigen/src/QR/ColPivHouseholderQR.h | 37 +-
.../Eigen/src/QR/FullPivHouseholderQR.h | 61 +-
Utilities/eigen3/Eigen/src/QR/HouseholderQR.h | 98 +-
.../eigen3/Eigen/src/QR/HouseholderQR_MKL.h | 30 +-
.../src/SPQRSupport/SuiteSparseQRSupport.h | 72 +-
Utilities/eigen3/Eigen/src/SVD/JacobiSVD.h | 131 ++-
.../src/SparseCholesky/SimplicialCholesky.h | 42 +-
.../eigen3/Eigen/src/SparseCore/AmbiVector.h | 4 +-
.../Eigen/src/SparseCore/CompressedStorage.h | 8 +-
.../ConservativeSparseSparseProduct.h | 34 +-
.../Eigen/src/SparseCore/MappedSparseMatrix.h | 2 +
.../eigen3/Eigen/src/SparseCore/SparseBlock.h | 140 ++-
.../Eigen/src/SparseCore/SparseColEtree.h | 6 +-
.../src/SparseCore/SparseCwiseBinaryOp.h | 7 +-
.../Eigen/src/SparseCore/SparseDenseProduct.h | 48 +-
.../Eigen/src/SparseCore/SparseMatrix.h | 38 +-
.../Eigen/src/SparseCore/SparseMatrixBase.h | 48 +-
.../Eigen/src/SparseCore/SparsePermutation.h | 6 +-
.../Eigen/src/SparseCore/SparseProduct.h | 5 +-
.../SparseSparseProductWithPruning.h | 13 +-
.../Eigen/src/SparseCore/SparseTranspose.h | 10 +-
.../eigen3/Eigen/src/SparseCore/SparseUtil.h | 9 +-
.../Eigen/src/SparseCore/SparseVector.h | 1 +
.../Eigen/src/SparseCore/TriangularSolver.h | 2 +-
.../eigen3/Eigen/src/SparseLU/SparseLU.h | 98 +-
.../eigen3/Eigen/src/SparseLU/SparseLUImpl.h | 2 +
.../Eigen/src/SparseLU/SparseLU_Memory.h | 45 +-
.../src/SparseLU/SparseLU_SupernodalMatrix.h | 12 +-
.../Eigen/src/SparseLU/SparseLU_column_bmod.h | 4 +-
.../Eigen/src/SparseLU/SparseLU_kernel_bmod.h | 4 +-
.../Eigen/src/SparseLU/SparseLU_panel_bmod.h | 8 +-
.../Eigen/src/SparseLU/SparseLU_pivotL.h | 13 +-
.../eigen3/Eigen/src/SparseQR/SparseQR.h | 198 ++--
.../eigen3/Eigen/src/StlSupport/StdDeque.h | 2 +-
.../eigen3/Eigen/src/StlSupport/StdList.h | 2 +-
.../eigen3/Eigen/src/StlSupport/StdVector.h | 2 +-
.../Eigen/src/UmfPackSupport/UmfPackSupport.h | 112 +-
.../Eigen/src/plugins/ArrayCwiseBinaryOps.h | 54 +-
.../Eigen/src/plugins/ArrayCwiseUnaryOps.h | 16 -
.../eigen3/Eigen/src/plugins/BlockMethods.h | 240 ++--
.../Eigen/src/plugins/MatrixCwiseBinaryOps.h | 21 +-
.../Eigen/src/plugins/MatrixCwiseUnaryOps.h | 15 -
Utilities/eigen3/btkEigen/Core/Cumtrapz.h | 2 +-
.../eigen3/btkEigen/Interpolation/Interp1.h | 2 +-
.../btkEigen/Interpolation/interp1_base.h | 2 +-
.../btkEigen/Interpolation/interp1_linear.h | 2 +-
.../btkEigen/Interpolation/interp1_pchip.h | 2 +-
Utilities/eigen3/btkEigen/Optimization/NM.h | 2 +-
.../eigen3/btkEigen/Plugin/DenseBaseAddons.h | 2 +-
.../btkEigen/Plugin/ForwardDeclarations.h | 2 +-
Utilities/eigen3/btkEigen/Plugin/Functors.h | 2 +-
.../eigen3/btkEigen/Plugin/VectorOpAddons.h | 2 +-
.../btkEigen/SignalProcessing/FiltFilt.h | 2 +-
.../eigen3/btkEigen/SignalProcessing/Filter.h | 2 +-
.../SignalProcessing/IIRFilterDesign.h | 2 +-
.../eigen3/signature_of_eigen3_matrix_library | 1 +
.../eigen3/unsupported/Eigen/AdolcForward | 156 +++
.../eigen3/unsupported/Eigen/AlignedVector3 | 190 +++
.../eigen3/unsupported/Eigen/ArpackSupport | 31 +
Utilities/eigen3/unsupported/Eigen/AutoDiff | 40 +
Utilities/eigen3/unsupported/Eigen/BVH | 95 ++
Utilities/eigen3/unsupported/Eigen/FFT | 418 +++++++
.../eigen3/unsupported/Eigen/IterativeSolvers | 45 +
.../eigen3/unsupported/Eigen/KroneckerProduct | 34 +
.../unsupported/Eigen/LevenbergMarquardt | 45 +
.../eigen3/unsupported/Eigen/MPRealSupport | 203 ++++
.../eigen3/unsupported/Eigen/MatrixFunctions | 447 +++++++
.../unsupported/Eigen/MoreVectorization | 24 +
.../unsupported/Eigen/NonLinearOptimization | 134 +++
.../eigen3/unsupported/Eigen/NumericalDiff | 56 +
.../eigen3/unsupported/Eigen/OpenGLSupport | 322 +++++
.../eigen3/unsupported/Eigen/Polynomials | 138 +++
Utilities/eigen3/unsupported/Eigen/Skyline | 39 +
.../eigen3/unsupported/Eigen/SparseExtra | 56 +
Utilities/eigen3/unsupported/Eigen/Splines | 31 +
.../Eigen/src/AutoDiff/AutoDiffJacobian.h | 83 ++
.../Eigen/src/AutoDiff/AutoDiffScalar.h | 642 ++++++++++
.../Eigen/src/AutoDiff/AutoDiffVector.h | 220 ++++
.../unsupported/Eigen/src/BVH/BVAlgorithms.h | 293 +++++
.../eigen3/unsupported/Eigen/src/BVH/KdBVH.h | 222 ++++
.../ArpackSelfAdjointEigenSolver.h | 805 +++++++++++++
.../unsupported/Eigen/src/FFT/ei_fftw_impl.h | 261 +++++
.../Eigen/src/FFT/ei_kissfft_impl.h | 420 +++++++
.../IterativeSolvers/ConstrainedConjGrad.h | 189 +++
.../Eigen/src/IterativeSolvers/DGMRES.h | 542 +++++++++
.../Eigen/src/IterativeSolvers/GMRES.h | 371 ++++++
.../src/IterativeSolvers/IncompleteCholesky.h | 278 +++++
.../Eigen/src/IterativeSolvers/IncompleteLU.h | 113 ++
.../IterativeSolvers/IterationController.h | 154 +++
.../Eigen/src/IterativeSolvers/MINRES.h | 311 +++++
.../Eigen/src/IterativeSolvers/Scaling.h | 185 +++
.../KroneckerProduct/KroneckerTensorProduct.h | 244 ++++
.../Eigen/src/LevenbergMarquardt/LMcovar.h | 85 ++
.../Eigen/src/LevenbergMarquardt/LMonestep.h | 202 ++++
.../Eigen/src/LevenbergMarquardt/LMpar.h | 160 +++
.../Eigen/src/LevenbergMarquardt/LMqrsolv.h | 189 +++
.../LevenbergMarquardt/LevenbergMarquardt.h | 377 ++++++
.../src/MatrixFunctions/MatrixExponential.h | 451 +++++++
.../src/MatrixFunctions/MatrixFunction.h | 591 ++++++++++
.../MatrixFunctions/MatrixFunctionAtomic.h | 131 +++
.../src/MatrixFunctions/MatrixLogarithm.h | 486 ++++++++
.../Eigen/src/MatrixFunctions/MatrixPower.h | 508 ++++++++
.../src/MatrixFunctions/MatrixSquareRoot.h | 466 ++++++++
.../Eigen/src/MatrixFunctions/StemFunction.h | 105 ++
.../src/MoreVectorization/MathFunctions.h | 95 ++
.../HybridNonLinearSolver.h | 601 ++++++++++
.../LevenbergMarquardt.h | 650 +++++++++++
.../Eigen/src/NonLinearOptimization/chkder.h | 66 ++
.../Eigen/src/NonLinearOptimization/covar.h | 70 ++
.../Eigen/src/NonLinearOptimization/dogleg.h | 107 ++
.../Eigen/src/NonLinearOptimization/fdjac1.h | 79 ++
.../Eigen/src/NonLinearOptimization/lmpar.h | 298 +++++
.../Eigen/src/NonLinearOptimization/qrsolv.h | 91 ++
.../Eigen/src/NonLinearOptimization/r1mpyq.h | 30 +
.../Eigen/src/NonLinearOptimization/r1updt.h | 99 ++
.../Eigen/src/NonLinearOptimization/rwupdt.h | 49 +
.../Eigen/src/NumericalDiff/NumericalDiff.h | 130 +++
.../Eigen/src/Polynomials/Companion.h | 276 +++++
.../Eigen/src/Polynomials/PolynomialSolver.h | 389 ++++++
.../Eigen/src/Polynomials/PolynomialUtils.h | 143 +++
.../Eigen/src/Skyline/SkylineInplaceLU.h | 352 ++++++
.../Eigen/src/Skyline/SkylineMatrix.h | 862 ++++++++++++++
.../Eigen/src/Skyline/SkylineMatrixBase.h | 212 ++++
.../Eigen/src/Skyline/SkylineProduct.h | 295 +++++
.../Eigen/src/Skyline/SkylineStorage.h | 259 ++++
.../Eigen/src/Skyline/SkylineUtil.h | 89 ++
.../SparseExtra/BlockOfDynamicSparseMatrix.h | 122 ++
.../src/SparseExtra/DynamicSparseMatrix.h | 357 ++++++
.../Eigen/src/SparseExtra/MarketIO.h | 273 +++++
.../src/SparseExtra/MatrixMarketIterator.h | 232 ++++
.../Eigen/src/SparseExtra/RandomSetter.h | 327 ++++++
.../unsupported/Eigen/src/Splines/Spline.h | 474 ++++++++
.../Eigen/src/Splines/SplineFitting.h | 156 +++
.../unsupported/Eigen/src/Splines/SplineFwd.h | 86 ++
Utilities/maths/comb.h | 2 +-
Utilities/maths/gammaln.h | 2 +-
Utilities/maths/sign.h | 2 +-
Wrapping/Matlab/btkASCIIConverter.h | 2 +-
Wrapping/Matlab/btkAppendAnalog.cpp | 2 +-
.../Matlab/btkAppendAnalysisParameter.cpp | 2 +-
Wrapping/Matlab/btkAppendEvent.cpp | 2 +-
Wrapping/Matlab/btkAppendMetaData.cpp | 2 +-
Wrapping/Matlab/btkAppendPoint.cpp | 2 +-
Wrapping/Matlab/btkClearAnalogs.cpp | 2 +-
Wrapping/Matlab/btkClearAnalysis.cpp | 2 +-
Wrapping/Matlab/btkClearEvents.cpp | 2 +-
Wrapping/Matlab/btkClearMetaData.cpp | 2 +-
Wrapping/Matlab/btkClearPoints.cpp | 2 +-
Wrapping/Matlab/btkCloneAcquisition.cpp | 2 +-
Wrapping/Matlab/btkDeleteAcquisition.cpp | 2 +-
Wrapping/Matlab/btkGetAnalog.cpp | 2 +-
Wrapping/Matlab/btkGetAnalogFrameNumber.cpp | 2 +-
Wrapping/Matlab/btkGetAnalogFrequency.cpp | 2 +-
Wrapping/Matlab/btkGetAnalogNumber.cpp | 2 +-
Wrapping/Matlab/btkGetAnalogResolution.cpp | 2 +-
.../btkGetAnalogSampleNumberPerFrame.cpp | 2 +-
Wrapping/Matlab/btkGetAnalogs.cpp | 2 +-
Wrapping/Matlab/btkGetAnalogsValues.cpp | 2 +-
Wrapping/Matlab/btkGetAnalysis.cpp | 2 +-
Wrapping/Matlab/btkGetAngles.cpp | 2 +-
Wrapping/Matlab/btkGetAnglesValues.cpp | 2 +-
Wrapping/Matlab/btkGetEvents.cpp | 2 +-
Wrapping/Matlab/btkGetEventsValues.cpp | 2 +-
Wrapping/Matlab/btkGetFirstFrame.cpp | 2 +-
.../Matlab/btkGetForcePlatformWrenches.cpp | 2 +-
Wrapping/Matlab/btkGetForcePlatforms.cpp | 2 +-
Wrapping/Matlab/btkGetForces.cpp | 2 +-
Wrapping/Matlab/btkGetForcesValues.cpp | 2 +-
.../Matlab/btkGetGroundReactionWrenches.cpp | 2 +-
Wrapping/Matlab/btkGetMarkers.cpp | 2 +-
Wrapping/Matlab/btkGetMarkersResiduals.cpp | 2 +-
Wrapping/Matlab/btkGetMarkersValues.cpp | 2 +-
Wrapping/Matlab/btkGetMaxInterpolationGap.cpp | 2 +-
Wrapping/Matlab/btkGetMetaData.cpp | 2 +-
Wrapping/Matlab/btkGetMoments.cpp | 2 +-
Wrapping/Matlab/btkGetMomentsValues.cpp | 2 +-
Wrapping/Matlab/btkGetPoint.cpp | 2 +-
Wrapping/Matlab/btkGetPointFrameNumber.cpp | 2 +-
Wrapping/Matlab/btkGetPointFrequency.cpp | 2 +-
Wrapping/Matlab/btkGetPointNumber.cpp | 2 +-
Wrapping/Matlab/btkGetPoints.cpp | 2 +-
Wrapping/Matlab/btkGetPointsResiduals.cpp | 2 +-
Wrapping/Matlab/btkGetPointsUnit.cpp | 2 +-
Wrapping/Matlab/btkGetPointsValues.cpp | 2 +-
Wrapping/Matlab/btkGetPowers.cpp | 2 +-
Wrapping/Matlab/btkGetPowersValues.cpp | 2 +-
Wrapping/Matlab/btkGetScalars.cpp | 2 +-
Wrapping/Matlab/btkGetScalarsValues.cpp | 2 +-
Wrapping/Matlab/btkMEXClassID.h | 2 +-
Wrapping/Matlab/btkMEXDebugLogToPrintf.h | 2 +-
Wrapping/Matlab/btkMEXLoggerRedirection.h | 2 +-
Wrapping/Matlab/btkMEXObjectHandle.h | 2 +-
Wrapping/Matlab/btkMEXStreambufToPrintf.h | 2 +-
Wrapping/Matlab/btkMEXStreambufToWarnMsgTxt.h | 2 +-
Wrapping/Matlab/btkMEXWarnLogToWarnMsgTxt.h | 2 +-
Wrapping/Matlab/btkMXAnalog.cxx | 2 +-
Wrapping/Matlab/btkMXAnalog.h | 2 +-
Wrapping/Matlab/btkMXAnalysis.cxx | 2 +-
Wrapping/Matlab/btkMXAnalysis.h | 2 +-
Wrapping/Matlab/btkMXEvent.cxx | 2 +-
Wrapping/Matlab/btkMXEvent.h | 2 +-
Wrapping/Matlab/btkMXMeasure.h | 2 +-
Wrapping/Matlab/btkMXMetaData.cxx | 2 +-
Wrapping/Matlab/btkMXMetaData.h | 2 +-
Wrapping/Matlab/btkMXPoint.cxx | 4 +-
Wrapping/Matlab/btkMXPoint.h | 2 +-
Wrapping/Matlab/btkMXSpecializedPoint.cxx | 2 +-
Wrapping/Matlab/btkMXSpecializedPoint.h | 2 +-
Wrapping/Matlab/btkMergeAcquisitions.cpp | 2 +-
Wrapping/Matlab/btkMex.h | 2 +-
Wrapping/Matlab/btkNewAcquisition.cpp | 2 +-
Wrapping/Matlab/btkReadAcquisition.cpp | 2 +-
Wrapping/Matlab/btkRemoveAnalog.cpp | 2 +-
.../Matlab/btkRemoveAnalysisParameter.cpp | 2 +-
Wrapping/Matlab/btkRemoveEvent.cpp | 2 +-
Wrapping/Matlab/btkRemoveMetaData.cpp | 2 +-
Wrapping/Matlab/btkRemovePoint.cpp | 2 +-
Wrapping/Matlab/btkSetAnalogDescription.cpp | 2 +-
Wrapping/Matlab/btkSetAnalogGain.cpp | 2 +-
Wrapping/Matlab/btkSetAnalogLabel.cpp | 2 +-
Wrapping/Matlab/btkSetAnalogNumber.cpp | 2 +-
Wrapping/Matlab/btkSetAnalogOffset.cpp | 4 +-
Wrapping/Matlab/btkSetAnalogResolution.cpp | 2 +-
.../btkSetAnalogSampleNumberPerFrame.cpp | 2 +-
Wrapping/Matlab/btkSetAnalogScale.cpp | 2 +-
Wrapping/Matlab/btkSetAnalogUnit.cpp | 2 +-
Wrapping/Matlab/btkSetAnalogValues.cpp | 2 +-
Wrapping/Matlab/btkSetAnalogsValues.cpp | 2 +-
Wrapping/Matlab/btkSetAnglesValues.cpp | 2 +-
Wrapping/Matlab/btkSetEventDescription.cpp | 2 +-
Wrapping/Matlab/btkSetEventId.cpp | 2 +-
Wrapping/Matlab/btkSetEventLabel.cpp | 2 +-
Wrapping/Matlab/btkSetEventSubject.cpp | 2 +-
Wrapping/Matlab/btkSetEventTime.cpp | 2 +-
Wrapping/Matlab/btkSetFirstFrame.cpp | 2 +-
Wrapping/Matlab/btkSetForcesValues.cpp | 2 +-
Wrapping/Matlab/btkSetFrameNumber.cpp | 2 +-
Wrapping/Matlab/btkSetFrequency.cpp | 2 +-
Wrapping/Matlab/btkSetMarkersResiduals.cpp | 2 +-
Wrapping/Matlab/btkSetMarkersValues.cpp | 2 +-
Wrapping/Matlab/btkSetMaxInterpolationGap.cpp | 2 +-
Wrapping/Matlab/btkSetMetaDataDescription.cpp | 2 +-
Wrapping/Matlab/btkSetMetaDataDimensions.cpp | 2 +-
Wrapping/Matlab/btkSetMetaDataFormat.cpp | 2 +-
Wrapping/Matlab/btkSetMetaDataLabel.cpp | 2 +-
Wrapping/Matlab/btkSetMetaDataUnlock.cpp | 2 +-
Wrapping/Matlab/btkSetMetaDataValue.cpp | 2 +-
Wrapping/Matlab/btkSetMomentsValues.cpp | 2 +-
Wrapping/Matlab/btkSetPoint.cpp | 2 +-
Wrapping/Matlab/btkSetPointDescription.cpp | 2 +-
Wrapping/Matlab/btkSetPointLabel.cpp | 2 +-
Wrapping/Matlab/btkSetPointNumber.cpp | 2 +-
Wrapping/Matlab/btkSetPointResiduals.cpp | 2 +-
Wrapping/Matlab/btkSetPointType.cpp | 2 +-
Wrapping/Matlab/btkSetPointValues.cpp | 2 +-
Wrapping/Matlab/btkSetPointsResiduals.cpp | 2 +-
Wrapping/Matlab/btkSetPointsUnit.cpp | 2 +-
Wrapping/Matlab/btkSetPointsValues.cpp | 2 +-
Wrapping/Matlab/btkSetPowersValues.cpp | 2 +-
Wrapping/Matlab/btkSetScalarsValues.cpp | 2 +-
Wrapping/Matlab/btkWriteAcquisition.cpp | 2 +-
.../BasicFilters/btkBasicFiltersSwig_Filter.h | 2 +-
.../Python/Common/btkCommonSwig_Acquisition.h | 2 +-
Wrapping/Python/Common/btkCommonSwig_Analog.h | 2 +-
.../Python/Common/btkCommonSwig_Collection.h | 2 +-
Wrapping/Python/Common/btkCommonSwig_Event.h | 2 +-
.../Common/btkCommonSwig_ForcePlatform.h | 2 +-
Wrapping/Python/Common/btkCommonSwig_IMU.h | 2 +-
.../Python/Common/btkCommonSwig_MetaData.h | 2 +-
Wrapping/Python/Common/btkCommonSwig_Point.h | 2 +-
Wrapping/Python/Common/btkCommonSwig_Wrench.h | 2 +-
.../Python/IO/btkIOSwig_AcquisitionFile.h | 2 +-
Wrapping/Python/btkBasicFiltersSwig.cpp | 2 +-
Wrapping/Python/btkBasicFiltersSwig.h | 2 +-
Wrapping/Python/btkBasicFiltersSwig.i | 2 +-
.../Python/btkBasicFiltersSwig_docstring.i | 2 +-
Wrapping/Python/btkCommonSwig.cpp | 2 +-
Wrapping/Python/btkCommonSwig.h | 2 +-
Wrapping/Python/btkCommonSwig.i | 6 +-
Wrapping/Python/btkCommonSwig_docstring.i | 9 +-
Wrapping/Python/btkIOSwig.cpp | 2 +-
Wrapping/Python/btkIOSwig.h | 2 +-
Wrapping/Python/btkIOSwig.i | 14 +-
Wrapping/Python/btkIOSwig_docstring.i | 2 +-
Wrapping/Python/btkSwig.i | 2 +-
Wrapping/Python/btkSwigMacros.h | 2 +-
Wrapping/Python/btkSwigUtils.h | 2 +-
btkConfigure.h.in | 2 +-
774 files changed, 27400 insertions(+), 3466 deletions(-)
create mode 100644 CMake/btkLinuxCompilerFlags.cmake
create mode 100644 Code/IO/btkBinaryByteOrderFormat.h
create mode 100644 Code/IO/btkBinaryFileStream.tpp
create mode 100644 Code/IO/btkBinaryStream.h
create mode 100644 Code/IO/btkBinaryStream.tpp
create mode 100644 Code/IO/btkHPFFileIO.cpp
create mode 100644 Code/IO/btkHPFFileIO.h
create mode 100644 Testing/C++/HPFFileIOTest.h
create mode 100644 Testing/C++/HPFFileReaderTest.h
create mode 100644 Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/BinMemFactoryPython.cpp
create mode 100644 Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/BinMemFactoryPython.h
create mode 100644 Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/MemoryHandlerPython.cpp
create mode 100644 Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/MemoryHandlerPython.h
create mode 100644 Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/PythonConvert.cpp
create mode 100644 Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/PythonConvert.h
create mode 100644 Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/Interpolate.cpp
create mode 100644 Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/Interpolate.h
create mode 100644 Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShape.cpp
create mode 100644 Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShape.h
create mode 100644 Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShapeCollection.cpp
create mode 100644 Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShapeCollection.h
create mode 100644 Utilities/Open3DMotion/src/Open3DMotion/OpenORM/ClassName.h
create mode 100644 Utilities/eigen3/signature_of_eigen3_matrix_library
create mode 100644 Utilities/eigen3/unsupported/Eigen/AdolcForward
create mode 100644 Utilities/eigen3/unsupported/Eigen/AlignedVector3
create mode 100644 Utilities/eigen3/unsupported/Eigen/ArpackSupport
create mode 100644 Utilities/eigen3/unsupported/Eigen/AutoDiff
create mode 100644 Utilities/eigen3/unsupported/Eigen/BVH
create mode 100644 Utilities/eigen3/unsupported/Eigen/FFT
create mode 100644 Utilities/eigen3/unsupported/Eigen/IterativeSolvers
create mode 100644 Utilities/eigen3/unsupported/Eigen/KroneckerProduct
create mode 100644 Utilities/eigen3/unsupported/Eigen/LevenbergMarquardt
create mode 100644 Utilities/eigen3/unsupported/Eigen/MPRealSupport
create mode 100644 Utilities/eigen3/unsupported/Eigen/MatrixFunctions
create mode 100644 Utilities/eigen3/unsupported/Eigen/MoreVectorization
create mode 100644 Utilities/eigen3/unsupported/Eigen/NonLinearOptimization
create mode 100644 Utilities/eigen3/unsupported/Eigen/NumericalDiff
create mode 100644 Utilities/eigen3/unsupported/Eigen/OpenGLSupport
create mode 100644 Utilities/eigen3/unsupported/Eigen/Polynomials
create mode 100644 Utilities/eigen3/unsupported/Eigen/Skyline
create mode 100644 Utilities/eigen3/unsupported/Eigen/SparseExtra
create mode 100644 Utilities/eigen3/unsupported/Eigen/Splines
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffJacobian.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffScalar.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/AutoDiff/AutoDiffVector.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/BVH/BVAlgorithms.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/BVH/KdBVH.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/Eigenvalues/ArpackSelfAdjointEigenSolver.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/FFT/ei_fftw_impl.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/FFT/ei_kissfft_impl.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/IterativeSolvers/ConstrainedConjGrad.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/IterativeSolvers/DGMRES.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/IterativeSolvers/GMRES.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/IterativeSolvers/IncompleteCholesky.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/IterativeSolvers/IncompleteLU.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/IterativeSolvers/IterationController.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/IterativeSolvers/MINRES.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/IterativeSolvers/Scaling.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/KroneckerProduct/KroneckerTensorProduct.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMcovar.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMonestep.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMpar.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LMqrsolv.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/LevenbergMarquardt/LevenbergMarquardt.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixExponential.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixFunction.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixFunctionAtomic.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixLogarithm.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixPower.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/MatrixFunctions/MatrixSquareRoot.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/MatrixFunctions/StemFunction.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/MoreVectorization/MathFunctions.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/NonLinearOptimization/HybridNonLinearSolver.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/NonLinearOptimization/LevenbergMarquardt.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/NonLinearOptimization/chkder.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/NonLinearOptimization/covar.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/NonLinearOptimization/dogleg.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/NonLinearOptimization/fdjac1.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/NonLinearOptimization/lmpar.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/NonLinearOptimization/qrsolv.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/NonLinearOptimization/r1mpyq.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/NonLinearOptimization/r1updt.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/NonLinearOptimization/rwupdt.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/NumericalDiff/NumericalDiff.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/Polynomials/Companion.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/Polynomials/PolynomialSolver.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/Polynomials/PolynomialUtils.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/Skyline/SkylineInplaceLU.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/Skyline/SkylineMatrix.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/Skyline/SkylineMatrixBase.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/Skyline/SkylineProduct.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/Skyline/SkylineStorage.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/Skyline/SkylineUtil.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/SparseExtra/BlockOfDynamicSparseMatrix.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/SparseExtra/DynamicSparseMatrix.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/SparseExtra/MarketIO.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/SparseExtra/MatrixMarketIterator.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/SparseExtra/RandomSetter.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/Splines/Spline.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/Splines/SplineFitting.h
create mode 100644 Utilities/eigen3/unsupported/Eigen/src/Splines/SplineFwd.h
diff --git a/.travis.yml b/.travis.yml
index c53c865a..e3293a7c 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,7 +6,7 @@ before_install:
# To install any prerequisites or dependencies necessary to run your build
install:
- - brew install cmake swig
+ - brew install swig cmake
# To prepare your build for testing
before_script:
@@ -23,7 +23,6 @@ script:
compiler:
- clang
- - gcc
env:
matrix:
diff --git a/CMake/FindMatlab.cmake b/CMake/FindMatlab.cmake
index a0919b9b..7568b120 100644
--- a/CMake/FindMatlab.cmake
+++ b/CMake/FindMatlab.cmake
@@ -3,7 +3,7 @@
# a macro to help the build of MEX-functions.
#
# This module detects a Matlab's version between Matlab 7.0 (R14)
-# and Matlab 8.0 (r2012b).
+# and Matlab 8.3 (r2014a).
#
# This module defines:
# MATLAB_ROOT: Matlab installation path
@@ -22,7 +22,7 @@
# - C/C++ source files;
# - third libraries required.
-# Copyright (c) 2009-2013 Arnaud Barré <arnaud.barre@gmail.com>
+# Copyright (c) 2009-2014 Arnaud Barré <arnaud.barre@gmail.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
@@ -34,6 +34,9 @@ ENDIF(MATLAB_ROOT AND MATLAB_EXECUTABLE AND MATLAB_INCLUDE_DIR AND MATLAB_LIBRAR
IF(WIN32)
# Default paths
SET(MATLAB_PATHS
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\8.3;MATLABROOT]"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\8.2;MATLABROOT]"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\8.1;MATLABROOT]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\8.0;MATLABROOT]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.15;MATLABROOT]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\MathWorks\\MATLAB\\7.14;MATLABROOT]"
@@ -55,6 +58,9 @@ IF(WIN32)
# Paths for Matlab 32-bit under Windows 64-bit
IF(NOT MATLAB_ROOT)
SET(MATLAB_PATHS
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MathWorks\\MATLAB\\8.3;MATLABROOT]"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MathWorks\\MATLAB\\8.2;MATLABROOT]"
+ "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MathWorks\\MATLAB\\8.1;MATLABROOT]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MathWorks\\MATLAB\\8.0;MATLABROOT]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MathWorks\\MATLAB\\7.15;MATLABROOT]"
"[HKEY_LOCAL_MACHINE\\SOFTWARE\\Wow6432Node\\MathWorks\\MATLAB\\7.14;MATLABROOT]"
diff --git a/CMake/FindNumPy.cmake b/CMake/FindNumPy.cmake
index 0ada8200..31b0d052 100644
--- a/CMake/FindNumPy.cmake
+++ b/CMake/FindNumPy.cmake
@@ -3,7 +3,7 @@
# This module defines:
# NUMPY_INCLUDE_DIR: include path for arrayobject.h
-# Copyright (c) 2009-2013 Arnaud Barré <arnaud.barre@gmail.com>
+# Copyright (c) 2009-2014 Arnaud Barré <arnaud.barre@gmail.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
diff --git a/CMake/FindOctave.cmake b/CMake/FindOctave.cmake
index f52a315b..673af780 100644
--- a/CMake/FindOctave.cmake
+++ b/CMake/FindOctave.cmake
@@ -16,7 +16,7 @@
# - C/C++ source files;
# - third libraries required.
-# Copyright (c) 2009-2013 Arnaud Barré <arnaud.barre@gmail.com>
+# Copyright (c) 2009-2014 Arnaud Barré <arnaud.barre@gmail.com>
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.
diff --git a/CMake/btkExtraCompilerFlags.cmake b/CMake/btkExtraCompilerFlags.cmake
index c1024a39..3679c537 100644
--- a/CMake/btkExtraCompilerFlags.cmake
+++ b/CMake/btkExtraCompilerFlags.cmake
@@ -1,17 +1,21 @@
# Based on the file vtkCompilerExtras.cmake
-IF(CMAKE_COMPILER_IS_GNUCXX)
+IF(CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
INCLUDE(CheckCXXCompilerFlag)
- # Addtional warnings for GCC
+ # Compatible flags between GCC and Clang
# -Wshadow has been removed due to eigen
- SET(CMAKE_CXX_FLAGS_WARN "-Wnon-virtual-dtor -Wno-long-long -ansi -Wcast-align -Wchar-subscripts -Wall -Wextra -Wpointer-arith -Wformat-security -Woverloaded-virtual -Wunused-parameter -fno-check-new -fno-common")
+ SET(CMAKE_CXX_FLAGS_WARN "-Wnon-virtual-dtor -Wno-long-long -Wcast-align -Wchar-subscripts -Wall -Wextra -Wpointer-arith -Wformat-security -Woverloaded-virtual -Wunused-parameter -fno-common")
+ # Addtional warnings for GCC
+ IF(CMAKE_COMPILER_IS_GNUCXX)
+ SET(CMAKE_CXX_FLAGS_WARN "${CMAKE_CXX_FLAGS_WARN} -fno-check-new -ansi")
+ ENDIF(CMAKE_COMPILER_IS_GNUCXX)
# This flag is useful as not returning from a non-void function is an error
# with MSVC, but it is not supported on all GCC compiler versions
- CHECK_CXX_COMPILER_FLAG(-Werror=return-type HAVE_GCC_ERROR_RETURN_TYPE)
- IF(HAVE_GCC_ERROR_RETURN_TYPE)
+ CHECK_CXX_COMPILER_FLAG(-Werror=return-type HAVE_COMPILER_ERROR_RETURN_TYPE)
+ IF(HAVE_COMPILER_ERROR_RETURN_TYPE)
SET(CMAKE_CXX_FLAGS_ERROR "-Werror=return-type")
- ENDIF(HAVE_GCC_ERROR_RETURN_TYPE)
+ ENDIF(HAVE_COMPILER_ERROR_RETURN_TYPE)
# Set up the debug CXX_FLAGS for extra warnings
OPTION(BTK_EXTRA_COMPILER_WARNINGS "Add compiler flags to do stricter checking when building debug." OFF)
@@ -37,4 +41,4 @@ IF(CMAKE_COMPILER_IS_GNUCXX)
SET(CMAKE_OLD_CXX_FLAGS_DEBUG 0 CACHE STRING "" FORCE)
ENDIF(CMAKE_OLD_CXX_FLAGS_DEBUG)
ENDIF(BTK_EXTRA_COMPILER_WARNINGS)
-ENDIF(CMAKE_COMPILER_IS_GNUCXX)
\ No newline at end of file
+ENDIF(CMAKE_COMPILER_IS_GNUCXX OR (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
diff --git a/CMake/btkLinuxCompilerFlags.cmake b/CMake/btkLinuxCompilerFlags.cmake
new file mode 100644
index 00000000..8b2d0991
--- /dev/null
+++ b/CMake/btkLinuxCompilerFlags.cmake
@@ -0,0 +1,11 @@
+# When the code is compiled under Linux 32-bit from a 64-bit machine, some unit test fails
+# due to some rounding errors. The most important issue is when the code is compiled in
+# Release mode. The number of frames computed for ANC files is sometimes wrong. This error
+# does not happen when the code is compiled in Debug mode.
+# Adding the flag -ffloat-store to CMAKE_CXX_FLAGS solves the problem. All the unit tests
+# passed after that.
+IF( (${CMAKE_SYSTEM_NAME} MATCHES "Linux") AND (CMAKE_SIZEOF_VOID_P EQUAL 4) )
+ MESSAGE(STATUS "\nFlag -ffloat-store added to CMAKE_CXX_FLAGS to fix possible round off errors under Linux 32-bit.\n")
+ SET(CMAKE_CXX_FLAGS "-ffloat-store")
+ SET(BTK_REQUIRED_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+ENDIF( (${CMAKE_SYSTEM_NAME} MATCHES "Linux") AND (CMAKE_SIZEOF_VOID_P EQUAL 4) )
\ No newline at end of file
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7bb8c570..c9f2c0fa 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -6,7 +6,7 @@ PROJECT(BTK)
# BTK version number.
SET(BTK_VERSION_MAJOR 0)
-SET(BTK_VERSION_MINOR 3)
+SET(BTK_VERSION_MINOR 4dev)
SET(BTK_VERSION_PATCH 0)
SET(BTK_VERSION_STRING "${BTK_VERSION_MAJOR}.${BTK_VERSION_MINOR}.${BTK_VERSION_PATCH}")
# The major.minor is enough to distinguish available features of the toolkit. Moreover,
@@ -38,6 +38,7 @@ SET(CMAKE_MODULE_PATH "${BTK_CMAKE_MODULE_PATH}")
# Load some macros.
INCLUDE(${BTK_CMAKE_MODULE_PATH}/btkMacCompilerFlags.cmake)
+INCLUDE(${BTK_CMAKE_MODULE_PATH}/btkLinuxCompilerFlags.cmake)
INCLUDE(CMakeDependentOption)
INCLUDE(CheckIncludeFile)
INCLUDE(CheckIncludeFileCXX)
diff --git a/Code/BasicFilters/btkAcquisitionUnitConverter.cpp b/Code/BasicFilters/btkAcquisitionUnitConverter.cpp
index 262c74e4..61861dc6 100644
--- a/Code/BasicFilters/btkAcquisitionUnitConverter.cpp
+++ b/Code/BasicFilters/btkAcquisitionUnitConverter.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkAcquisitionUnitConverter.h b/Code/BasicFilters/btkAcquisitionUnitConverter.h
index 7312ae2b..84dfa29e 100644
--- a/Code/BasicFilters/btkAcquisitionUnitConverter.h
+++ b/Code/BasicFilters/btkAcquisitionUnitConverter.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkAnalogOffsetRemover.cpp b/Code/BasicFilters/btkAnalogOffsetRemover.cpp
index 2d1183e2..3b7584cb 100644
--- a/Code/BasicFilters/btkAnalogOffsetRemover.cpp
+++ b/Code/BasicFilters/btkAnalogOffsetRemover.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkAnalogOffsetRemover.h b/Code/BasicFilters/btkAnalogOffsetRemover.h
index 693fbd10..54c00978 100644
--- a/Code/BasicFilters/btkAnalogOffsetRemover.h
+++ b/Code/BasicFilters/btkAnalogOffsetRemover.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkCollectionAssembly.h b/Code/BasicFilters/btkCollectionAssembly.h
index 202e12fc..fc92a311 100644
--- a/Code/BasicFilters/btkCollectionAssembly.h
+++ b/Code/BasicFilters/btkCollectionAssembly.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkDownsampleFilter.h b/Code/BasicFilters/btkDownsampleFilter.h
index 5d9a0627..4460d9c3 100644
--- a/Code/BasicFilters/btkDownsampleFilter.h
+++ b/Code/BasicFilters/btkDownsampleFilter.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -209,6 +209,9 @@ namespace btk
template <class T>
inline void DownsampleData(int ratio, btkSharedPtr<T> input, btkSharedPtr<T> output)
{
+ btkNotUsed(ratio);
+ btkNotUsed(input);
+ btkNotUsed(output);
btkErrorMacro("Generic method. Please specialize it.");
};
diff --git a/Code/BasicFilters/btkForcePlatformWrenchFilter.cpp b/Code/BasicFilters/btkForcePlatformWrenchFilter.cpp
index 41f6f0fa..ab84acc4 100644
--- a/Code/BasicFilters/btkForcePlatformWrenchFilter.cpp
+++ b/Code/BasicFilters/btkForcePlatformWrenchFilter.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkForcePlatformWrenchFilter.h b/Code/BasicFilters/btkForcePlatformWrenchFilter.h
index c1265db2..786f279d 100644
--- a/Code/BasicFilters/btkForcePlatformWrenchFilter.h
+++ b/Code/BasicFilters/btkForcePlatformWrenchFilter.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkForcePlatformsExtractor.cpp b/Code/BasicFilters/btkForcePlatformsExtractor.cpp
index fa05b1f0..7c2452b6 100644
--- a/Code/BasicFilters/btkForcePlatformsExtractor.cpp
+++ b/Code/BasicFilters/btkForcePlatformsExtractor.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkForcePlatformsExtractor.h b/Code/BasicFilters/btkForcePlatformsExtractor.h
index cc36c0ff..863fd400 100644
--- a/Code/BasicFilters/btkForcePlatformsExtractor.h
+++ b/Code/BasicFilters/btkForcePlatformsExtractor.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkGroundReactionWrenchFilter.cpp b/Code/BasicFilters/btkGroundReactionWrenchFilter.cpp
index d0278f84..abc42bad 100644
--- a/Code/BasicFilters/btkGroundReactionWrenchFilter.cpp
+++ b/Code/BasicFilters/btkGroundReactionWrenchFilter.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkGroundReactionWrenchFilter.h b/Code/BasicFilters/btkGroundReactionWrenchFilter.h
index 1b0199f4..47996bad 100644
--- a/Code/BasicFilters/btkGroundReactionWrenchFilter.h
+++ b/Code/BasicFilters/btkGroundReactionWrenchFilter.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkIMUsExtractor.cpp b/Code/BasicFilters/btkIMUsExtractor.cpp
index c6378625..15e46420 100644
--- a/Code/BasicFilters/btkIMUsExtractor.cpp
+++ b/Code/BasicFilters/btkIMUsExtractor.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkIMUsExtractor.h b/Code/BasicFilters/btkIMUsExtractor.h
index 09a0d28a..2578d789 100644
--- a/Code/BasicFilters/btkIMUsExtractor.h
+++ b/Code/BasicFilters/btkIMUsExtractor.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkMeasureFrameExtractor.h b/Code/BasicFilters/btkMeasureFrameExtractor.h
index d6f18572..b7659825 100644
--- a/Code/BasicFilters/btkMeasureFrameExtractor.h
+++ b/Code/BasicFilters/btkMeasureFrameExtractor.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkMergeAcquisitionFilter.cpp b/Code/BasicFilters/btkMergeAcquisitionFilter.cpp
index bf89fa21..c6ddb56b 100644
--- a/Code/BasicFilters/btkMergeAcquisitionFilter.cpp
+++ b/Code/BasicFilters/btkMergeAcquisitionFilter.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -367,6 +367,7 @@ namespace btk
bool mergeData = false;
// First frame
int diffFF = output->GetFirstFrame() - input->GetFirstFrame();
+ int oldInputNumFrames = input->GetPointFrameNumber();
if ((diffFF < 0) && (input->GetPointFrameNumber() != 0))
{
if (abs(diffFF) == output->GetLastFrame())
@@ -421,7 +422,7 @@ namespace btk
}
}
if (mergeData)
- this->MergeData(output, input, diffFF);
+ this->MergeData(output, input, diffFF, oldInputNumFrames);
else
this->ConcatData(output, input);
@@ -513,25 +514,25 @@ namespace btk
}
};
- void MergeAcquisitionFilter::MergeData(Acquisition::Pointer output, Acquisition::Pointer input, int frameNumber) const
+ void MergeAcquisitionFilter::MergeData(Acquisition::Pointer output, Acquisition::Pointer input, int diffFF, int oldInputNumFrames) const
{
int startFrame = 0;
- if (frameNumber < 0)
- startFrame = abs(frameNumber);
+ if (diffFF < 0)
+ startFrame = abs(diffFF);
else
startFrame = output->GetFirstFrame() - 1;
-
+
for (Acquisition::PointIterator it = input->BeginPoint() ; it != input->EndPoint() ; ++it)
{
Point::Pointer p = *(output->FindPoint((*it)->GetLabel()));
- p->GetValues().block(startFrame, 0, abs(frameNumber), 3) = (*it)->GetValues().block(startFrame, 0, abs(frameNumber), 3);
- p->GetResiduals().block(startFrame, 0, abs(frameNumber), 1) = (*it)->GetResiduals().block(startFrame, 0, abs(frameNumber), 1);
+ p->GetValues().block(startFrame, 0, oldInputNumFrames, 3) = (*it)->GetValues().block(startFrame, 0, oldInputNumFrames, 3);
+ p->GetResiduals().block(startFrame, 0, oldInputNumFrames, 1) = (*it)->GetResiduals().block(startFrame, 0, oldInputNumFrames, 1);
}
// Analog
for (Acquisition::AnalogIterator it = input->BeginAnalog() ; it != input->EndAnalog() ; ++it)
{
Analog::Pointer ac = *(output->FindAnalog((*it)->GetLabel()));
- ac->GetValues().block(startFrame * input->GetNumberAnalogSamplePerFrame(), 0, abs(frameNumber), 1) = (*it)->GetValues().block(startFrame, 0, abs(frameNumber), 1);
+ ac->GetValues().block(startFrame * input->GetNumberAnalogSamplePerFrame(), 0, oldInputNumFrames * input->GetNumberAnalogSamplePerFrame(), 1) = (*it)->GetValues().block(startFrame * input->GetNumberAnalogSamplePerFrame(), 0, oldInputNumFrames * input->GetNumberAnalogSamplePerFrame(), 1);
}
};
diff --git a/Code/BasicFilters/btkMergeAcquisitionFilter.h b/Code/BasicFilters/btkMergeAcquisitionFilter.h
index 264ed2d7..a31892b2 100644
--- a/Code/BasicFilters/btkMergeAcquisitionFilter.h
+++ b/Code/BasicFilters/btkMergeAcquisitionFilter.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -71,7 +71,7 @@ namespace btk
private:
void MergeAcquisition(int idx, Acquisition::Pointer out);
- void MergeData(Acquisition::Pointer output, Acquisition::Pointer input, int frameNumber) const;
+ void MergeData(Acquisition::Pointer output, Acquisition::Pointer input, int diffFF, int oldInputNumFrames) const;
void ConcatData(Acquisition::Pointer output, Acquisition::Pointer input) const;
void RemoveDeprecatedMetaData(MetaData::Pointer in, bool pointScreenToRemove = false) const;
void CleanMetaData(MetaData::Pointer in) const;
diff --git a/Code/BasicFilters/btkSeparateKnownVirtualMarkersFilter.cpp b/Code/BasicFilters/btkSeparateKnownVirtualMarkersFilter.cpp
index c7bd26b3..2ad4c303 100644
--- a/Code/BasicFilters/btkSeparateKnownVirtualMarkersFilter.cpp
+++ b/Code/BasicFilters/btkSeparateKnownVirtualMarkersFilter.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkSeparateKnownVirtualMarkersFilter.h b/Code/BasicFilters/btkSeparateKnownVirtualMarkersFilter.h
index 995a152b..11c3c2c2 100644
--- a/Code/BasicFilters/btkSeparateKnownVirtualMarkersFilter.h
+++ b/Code/BasicFilters/btkSeparateKnownVirtualMarkersFilter.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkSpecializedPointsExtractor.cpp b/Code/BasicFilters/btkSpecializedPointsExtractor.cpp
index b3853c45..9b71376c 100644
--- a/Code/BasicFilters/btkSpecializedPointsExtractor.cpp
+++ b/Code/BasicFilters/btkSpecializedPointsExtractor.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkSpecializedPointsExtractor.h b/Code/BasicFilters/btkSpecializedPointsExtractor.h
index d44e3237..acf73292 100644
--- a/Code/BasicFilters/btkSpecializedPointsExtractor.h
+++ b/Code/BasicFilters/btkSpecializedPointsExtractor.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkSubAcquisitionFilter.cpp b/Code/BasicFilters/btkSubAcquisitionFilter.cpp
index f4891256..9c960798 100644
--- a/Code/BasicFilters/btkSubAcquisitionFilter.cpp
+++ b/Code/BasicFilters/btkSubAcquisitionFilter.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkSubAcquisitionFilter.h b/Code/BasicFilters/btkSubAcquisitionFilter.h
index f2288eaa..6599b731 100644
--- a/Code/BasicFilters/btkSubAcquisitionFilter.h
+++ b/Code/BasicFilters/btkSubAcquisitionFilter.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkVerticalGroundReactionForceGaitEventDetector.cpp b/Code/BasicFilters/btkVerticalGroundReactionForceGaitEventDetector.cpp
index 236e4ed1..9587d001 100644
--- a/Code/BasicFilters/btkVerticalGroundReactionForceGaitEventDetector.cpp
+++ b/Code/BasicFilters/btkVerticalGroundReactionForceGaitEventDetector.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkVerticalGroundReactionForceGaitEventDetector.h b/Code/BasicFilters/btkVerticalGroundReactionForceGaitEventDetector.h
index 514a6495..9754b6e5 100644
--- a/Code/BasicFilters/btkVerticalGroundReactionForceGaitEventDetector.h
+++ b/Code/BasicFilters/btkVerticalGroundReactionForceGaitEventDetector.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkWrenchDirectionAngleFilter.cpp b/Code/BasicFilters/btkWrenchDirectionAngleFilter.cpp
index edecae27..d005f9ed 100644
--- a/Code/BasicFilters/btkWrenchDirectionAngleFilter.cpp
+++ b/Code/BasicFilters/btkWrenchDirectionAngleFilter.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/BasicFilters/btkWrenchDirectionAngleFilter.h b/Code/BasicFilters/btkWrenchDirectionAngleFilter.h
index 93a65803..f34b6431 100644
--- a/Code/BasicFilters/btkWrenchDirectionAngleFilter.h
+++ b/Code/BasicFilters/btkWrenchDirectionAngleFilter.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkAcquisition.cpp b/Code/Common/btkAcquisition.cpp
index 82f22b5d..5a4d371a 100644
--- a/Code/Common/btkAcquisition.cpp
+++ b/Code/Common/btkAcquisition.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkAcquisition.h b/Code/Common/btkAcquisition.h
index 8e128cf1..258bb2a9 100644
--- a/Code/Common/btkAcquisition.h
+++ b/Code/Common/btkAcquisition.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkAnalog.cpp b/Code/Common/btkAnalog.cpp
index 49eabe7e..c4416b5d 100644
--- a/Code/Common/btkAnalog.cpp
+++ b/Code/Common/btkAnalog.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -80,6 +80,10 @@ namespace btk
* @var Analog::Gain Analog::PlusMinus2Dot5
* +/- 2.5 volts.
*/
+ /**
+ * @var Analog::Gain Analog::PlusMinus1Dot65
+ * +/- 1.65 volts.
+ */
/**
* @var Analog::Gain Analog::PlusMinus1Dot25
* +/- 1.25 volts.
@@ -199,16 +203,48 @@ namespace btk
};
/**
- * @fn int Analog::GetOffset() const
- * Returns the analog offset value in bit which represents the 0 value.
+ * Try to set gain from the given value @a g.
+ * The input must represent one of the value associated with the enum Analog::Gain.
+ * These value can be interpreted as the half ot voltage range expressed in mV.
+ */
+ void Analog::SetGainFromValue(int g)
+ {
+ switch(g)
+ {
+ case Analog::PlusMinus10:
+ case Analog::PlusMinus5:
+ case Analog::PlusMinus2Dot5:
+ case Analog::PlusMinus1Dot65:
+ case Analog::PlusMinus1Dot25:
+ case Analog::PlusMinus1:
+ case Analog::PlusMinus0Dot5:
+ case Analog::PlusMinus0Dot25:
+ case Analog::PlusMinus0Dot1:
+ case Analog::PlusMinus0Dot05:
+ this->SetGain(static_cast<Analog::Gain>(g));
+ break;
+ default:
+ btkWarningMacro("Unknown gain. Replaced by a gain of +/- 10 volts.");
+ this->SetGain(Analog::PlusMinus10);
+ break;
+ }
+ };
+
+ /**
+ * @fn double Analog::GetOffset() const
+ * Returns the analog offset value in bit which represents the 0 value for a digital to analog converter (DAC).
+ *
+ * Since BTK 0.4, it is possible to store the offset as a real instead of an integer.
+ * This does not has a physical meaning in term of DAC converter (as you cannot remove a fractionnal part of a bit).
+ * However, this has the benefit to give the possibility to convert digital sensor measure to analog sensor measure.
*/
/**
* Sets the analog offset.
*/
- void Analog::SetOffset(int o)
+ void Analog::SetOffset(double o)
{
- if (this->m_Offset == o)
+ if (fabs(this->m_Offset - o) <= std::numeric_limits<double>::epsilon())
return;
this->m_Offset = o;
this->Modified();
@@ -247,7 +283,7 @@ namespace btk
: Measure<Analog>(label, desc), m_Unit("V")
{
this->m_Gain = Unknown;
- this->m_Offset = 0;
+ this->m_Offset = 0.0;
this->m_Scale = 1.0;
};
@@ -258,7 +294,7 @@ namespace btk
: Measure<Analog>(label, frameNumber), m_Unit("V")
{
this->m_Gain = g;
- this->m_Offset = 0;
+ this->m_Offset = 0.0;
this->m_Scale = 1.0;
};
diff --git a/Code/Common/btkAnalog.h b/Code/Common/btkAnalog.h
index cf0b419a..c50fb319 100644
--- a/Code/Common/btkAnalog.h
+++ b/Code/Common/btkAnalog.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -80,7 +80,7 @@ namespace btk
typedef enum {Unknown = 0,
PlusMinus10 = 10000, PlusMinus5 = 5000, PlusMinus2Dot5 = 2500,
- PlusMinus1Dot25 = 1250, PlusMinus1 = 1000, PlusMinus0Dot5 = 500,
+ PlusMinus1Dot65 = 1650, PlusMinus1Dot25 = 1250, PlusMinus1 = 1000, PlusMinus0Dot5 = 500,
PlusMinus0Dot25 = 250, PlusMinus0Dot1 = 100, PlusMinus0Dot05 = 50} Gain;
typedef btkSharedPtr<Analog> Pointer;
@@ -99,8 +99,9 @@ namespace btk
BTK_COMMON_EXPORT void SetUnit(const std::string& u);
Gain GetGain() const {return this->m_Gain;};
BTK_COMMON_EXPORT void SetGain(Gain g);
- int GetOffset() const {return this->m_Offset;};
- BTK_COMMON_EXPORT void SetOffset(int o);
+ BTK_COMMON_EXPORT void SetGainFromValue(int g);
+ double GetOffset() const {return this->m_Offset;};
+ BTK_COMMON_EXPORT void SetOffset(double o);
double GetScale() const {return this->m_Scale;};
BTK_COMMON_EXPORT void SetScale(double s);
@@ -118,7 +119,7 @@ namespace btk
std::string m_Unit;
Gain m_Gain;
- int m_Offset;
+ double m_Offset;
double m_Scale;
};
diff --git a/Code/Common/btkAnalogCollection.h b/Code/Common/btkAnalogCollection.h
index d73552af..326d3853 100644
--- a/Code/Common/btkAnalogCollection.h
+++ b/Code/Common/btkAnalogCollection.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkCollection.h b/Code/Common/btkCollection.h
index 97c08fbe..605ba28b 100644
--- a/Code/Common/btkCollection.h
+++ b/Code/Common/btkCollection.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkConvert.h b/Code/Common/btkConvert.h
index cc7eb400..e0dd5f30 100644
--- a/Code/Common/btkConvert.h
+++ b/Code/Common/btkConvert.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkCriticalSection_p.cpp b/Code/Common/btkCriticalSection_p.cpp
index 500c3a92..ca0aa31d 100644
--- a/Code/Common/btkCriticalSection_p.cpp
+++ b/Code/Common/btkCriticalSection_p.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkCriticalSection_p.h b/Code/Common/btkCriticalSection_p.h
index 787680d9..69ed0552 100644
--- a/Code/Common/btkCriticalSection_p.h
+++ b/Code/Common/btkCriticalSection_p.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkDataObject.cpp b/Code/Common/btkDataObject.cpp
index d4b86c9a..8a4aed25 100644
--- a/Code/Common/btkDataObject.cpp
+++ b/Code/Common/btkDataObject.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkDataObject.h b/Code/Common/btkDataObject.h
index 0a80baa8..af78776b 100644
--- a/Code/Common/btkDataObject.h
+++ b/Code/Common/btkDataObject.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkEvent.cpp b/Code/Common/btkEvent.cpp
index a0e6110f..befc4afd 100644
--- a/Code/Common/btkEvent.cpp
+++ b/Code/Common/btkEvent.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkEvent.h b/Code/Common/btkEvent.h
index 56b98818..9f00e4a8 100644
--- a/Code/Common/btkEvent.h
+++ b/Code/Common/btkEvent.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkEventCollection.h b/Code/Common/btkEventCollection.h
index a16fc023..d38a7b0a 100644
--- a/Code/Common/btkEventCollection.h
+++ b/Code/Common/btkEventCollection.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkException.h b/Code/Common/btkException.h
index 3f27b097..b2ee1ea6 100644
--- a/Code/Common/btkException.h
+++ b/Code/Common/btkException.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkForcePlatform.cpp b/Code/Common/btkForcePlatform.cpp
index 6fcc768b..04a5f1d0 100644
--- a/Code/Common/btkForcePlatform.cpp
+++ b/Code/Common/btkForcePlatform.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -187,13 +187,13 @@ namespace btk
*/
void ForcePlatform::SetOrigin(double x, double y, double z)
{
- if ((this->m_Origin.x() == x)
- && (this->m_Origin.y() == y)
- && (this->m_Origin.z() == z))
+ if ((std::fabs(this->m_Origin.coeff(0) - x) <= Eigen::NumTraits<Corner::Scalar>::dummy_precision())
+ && (std::fabs(this->m_Origin.coeff(1) - y) <= Eigen::NumTraits<Corner::Scalar>::dummy_precision())
+ && (std::fabs(this->m_Origin.coeff(2) - z) <= Eigen::NumTraits<Corner::Scalar>::dummy_precision()))
return;
- this->m_Origin.x() = x;
- this->m_Origin.y() = y;
- this->m_Origin.z() = z;
+ this->m_Origin.coeffRef(0) = x;
+ this->m_Origin.coeffRef(1) = y;
+ this->m_Origin.coeffRef(2) = z;
this->Modified();
};
@@ -202,7 +202,7 @@ namespace btk
*/
void ForcePlatform::SetOrigin(const Origin& o)
{
- if (this->m_Origin.isApprox(o))
+ if ((this->m_Origin - o).cwiseAbs().maxCoeff() <= Eigen::NumTraits<Origin::Scalar>::dummy_precision())
return;
this->m_Origin = o;
this->Modified();
@@ -225,7 +225,10 @@ namespace btk
{
if ((row > 3) || (col > 4))
throw OutOfRangeException("ForcePlatform::SetCorner");
+ if (std::fabs(this->m_Corners.coeff(row, col) - v) <= Eigen::NumTraits<Corner::Scalar>::dummy_precision())
+ return;
this->m_Corners.coeffRef(row, col) = v;
+ this->Modified();
};
@@ -236,10 +239,9 @@ namespace btk
{
if (idx >= 4)
throw OutOfRangeException("ForcePlatform::SetCorner");
- Corner c = this->m_Corners.col(idx);
- if ((c.x() == x)
- && (c.y() == y)
- && (c.z() == z))
+ if ((std::fabs(this->m_Corners.coeff(0, idx) - x) <= Eigen::NumTraits<Corner::Scalar>::dummy_precision())
+ && (std::fabs(this->m_Corners.coeff(1, idx) - y) <= Eigen::NumTraits<Corner::Scalar>::dummy_precision())
+ && (std::fabs(this->m_Corners.coeff(2, idx) - z) <= Eigen::NumTraits<Corner::Scalar>::dummy_precision()))
return;
this->m_Corners.coeffRef(0, idx) = x;
this->m_Corners.coeffRef(1, idx) = y;
@@ -252,12 +254,7 @@ namespace btk
*/
void ForcePlatform::SetCorner(int idx, const Corner& c)
{
- if (idx >= 4)
- throw OutOfRangeException("ForcePlatform::SetCorner");
- if (this->m_Corners.col(idx).isApprox(c))
- return;
- this->m_Corners.col(idx) = c;
- this->Modified();
+ this->SetCorner(idx,c.x(),c.y(),c.z());
};
/**
@@ -277,7 +274,7 @@ namespace btk
*/
void ForcePlatform::SetCorners(const Corners& c)
{
- if (this->m_Corners.isApprox(c))
+ if ((this->m_Corners - c).cwiseAbs().maxCoeff() <= Eigen::NumTraits<Corners::Scalar>::dummy_precision())
return;
this->m_Corners = c;
this->Modified();
@@ -300,7 +297,7 @@ namespace btk
*/
void ForcePlatform::SetCalMatrix(const CalMatrix& cal)
{
- if (this->m_CalMatrix.isApprox(cal))
+ if ((this->m_CalMatrix - cal).cwiseAbs().maxCoeff() <= Eigen::NumTraits<CalMatrix::Scalar>::dummy_precision())
return;
this->m_CalMatrix = cal;
this->Modified();
diff --git a/Code/Common/btkForcePlatform.h b/Code/Common/btkForcePlatform.h
index 987683e9..93ab5744 100644
--- a/Code/Common/btkForcePlatform.h
+++ b/Code/Common/btkForcePlatform.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkForcePlatformCollection.h b/Code/Common/btkForcePlatformCollection.h
index 947c6535..8209a2bc 100644
--- a/Code/Common/btkForcePlatformCollection.h
+++ b/Code/Common/btkForcePlatformCollection.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkForcePlatformTypes.h b/Code/Common/btkForcePlatformTypes.h
index b0cca393..8c7e2195 100644
--- a/Code/Common/btkForcePlatformTypes.h
+++ b/Code/Common/btkForcePlatformTypes.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkIMU.cpp b/Code/Common/btkIMU.cpp
index d03a13c4..8b72944e 100644
--- a/Code/Common/btkIMU.cpp
+++ b/Code/Common/btkIMU.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -288,7 +288,7 @@ namespace btk
*/
void IMU::SetCalMatrix(const CalMatrix& cal)
{
- if ((this->m_CalMatrix.data() != 0) && (this->m_CalMatrix.isApprox(cal)))
+ if ((this->m_CalMatrix.data() != 0) && ((this->m_CalMatrix - cal).cwiseAbs().maxCoeff() <= Eigen::NumTraits<CalMatrix::Scalar>::dummy_precision()))
return;
this->m_CalMatrix = cal;
this->Modified();
diff --git a/Code/Common/btkIMU.h b/Code/Common/btkIMU.h
index a1b5bbed..41778bed 100644
--- a/Code/Common/btkIMU.h
+++ b/Code/Common/btkIMU.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkIMUCollection.h b/Code/Common/btkIMUCollection.h
index c667f0bf..8d9492d4 100644
--- a/Code/Common/btkIMUCollection.h
+++ b/Code/Common/btkIMUCollection.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkIMUTypes.h b/Code/Common/btkIMUTypes.h
index 523d1de6..75082e9b 100644
--- a/Code/Common/btkIMUTypes.h
+++ b/Code/Common/btkIMUTypes.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkLogger.cpp b/Code/Common/btkLogger.cpp
index 6e042474..83f03faa 100644
--- a/Code/Common/btkLogger.cpp
+++ b/Code/Common/btkLogger.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkLogger.h b/Code/Common/btkLogger.h
index 98b7ab1f..d8250a2e 100644
--- a/Code/Common/btkLogger.h
+++ b/Code/Common/btkLogger.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkMacro.h b/Code/Common/btkMacro.h
index 0546eaa0..e0963949 100644
--- a/Code/Common/btkMacro.h
+++ b/Code/Common/btkMacro.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkMeasure.h b/Code/Common/btkMeasure.h
index 0001f835..92dd5502 100644
--- a/Code/Common/btkMeasure.h
+++ b/Code/Common/btkMeasure.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkMetaData.cpp b/Code/Common/btkMetaData.cpp
index eef2e7b4..68aa45ab 100644
--- a/Code/Common/btkMetaData.cpp
+++ b/Code/Common/btkMetaData.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkMetaData.h b/Code/Common/btkMetaData.h
index 65c463d1..77eca20f 100644
--- a/Code/Common/btkMetaData.h
+++ b/Code/Common/btkMetaData.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkMetaDataInfo.cpp b/Code/Common/btkMetaDataInfo.cpp
index 3dce7314..b136d468 100644
--- a/Code/Common/btkMetaDataInfo.cpp
+++ b/Code/Common/btkMetaDataInfo.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkMetaDataInfo.h b/Code/Common/btkMetaDataInfo.h
index b75ad7a9..3a34caa3 100644
--- a/Code/Common/btkMetaDataInfo.h
+++ b/Code/Common/btkMetaDataInfo.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkMetaDataInfo_p.h b/Code/Common/btkMetaDataInfo_p.h
index b7b6362b..8b568640 100644
--- a/Code/Common/btkMetaDataInfo_p.h
+++ b/Code/Common/btkMetaDataInfo_p.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkMetaDataUtils.cpp b/Code/Common/btkMetaDataUtils.cpp
index ec115b22..a5589b2c 100644
--- a/Code/Common/btkMetaDataUtils.cpp
+++ b/Code/Common/btkMetaDataUtils.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkMetaDataUtils.h b/Code/Common/btkMetaDataUtils.h
index d859a8b9..e5273989 100644
--- a/Code/Common/btkMetaDataUtils.h
+++ b/Code/Common/btkMetaDataUtils.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -50,6 +50,8 @@ namespace btk
std::vector<T>& values,
MetaDataInfo::ConstPointer info)
{
+ btkNotUsed(values);
+ btkNotUsed(info);
btkErrorMacro("Error during metadata's value collapsing. Generic method used.");
};
diff --git a/Code/Common/btkNullPtr.h b/Code/Common/btkNullPtr.h
index 5bc6bc8b..837e4415 100644
--- a/Code/Common/btkNullPtr.h
+++ b/Code/Common/btkNullPtr.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkObject.cpp b/Code/Common/btkObject.cpp
index 14b396b2..7fd98c25 100644
--- a/Code/Common/btkObject.cpp
+++ b/Code/Common/btkObject.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkObject.h b/Code/Common/btkObject.h
index 7d432975..839b69de 100644
--- a/Code/Common/btkObject.h
+++ b/Code/Common/btkObject.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkPoint.cpp b/Code/Common/btkPoint.cpp
index cefad822..f5156a5b 100644
--- a/Code/Common/btkPoint.cpp
+++ b/Code/Common/btkPoint.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkPoint.h b/Code/Common/btkPoint.h
index 33cc41c0..73ace6ad 100644
--- a/Code/Common/btkPoint.h
+++ b/Code/Common/btkPoint.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkPointCollection.h b/Code/Common/btkPointCollection.h
index c54223f6..45e99db5 100644
--- a/Code/Common/btkPointCollection.h
+++ b/Code/Common/btkPointCollection.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkProcessObject.cpp b/Code/Common/btkProcessObject.cpp
index 2cb9a5d3..8121d0d4 100644
--- a/Code/Common/btkProcessObject.cpp
+++ b/Code/Common/btkProcessObject.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkProcessObject.h b/Code/Common/btkProcessObject.h
index 6e477ea2..dbc25feb 100644
--- a/Code/Common/btkProcessObject.h
+++ b/Code/Common/btkProcessObject.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkSharedPtr.h b/Code/Common/btkSharedPtr.h
index a0426ead..14f915c9 100644
--- a/Code/Common/btkSharedPtr.h
+++ b/Code/Common/btkSharedPtr.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkTriangleMesh.cpp b/Code/Common/btkTriangleMesh.cpp
index f60ac2c2..4f9b86bd 100644
--- a/Code/Common/btkTriangleMesh.cpp
+++ b/Code/Common/btkTriangleMesh.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkTriangleMesh.h b/Code/Common/btkTriangleMesh.h
index d83b8258..029c4889 100644
--- a/Code/Common/btkTriangleMesh.h
+++ b/Code/Common/btkTriangleMesh.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkWrench.cpp b/Code/Common/btkWrench.cpp
index 13c7dd98..2e6d646b 100644
--- a/Code/Common/btkWrench.cpp
+++ b/Code/Common/btkWrench.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkWrench.h b/Code/Common/btkWrench.h
index 9b3ab537..a0796429 100644
--- a/Code/Common/btkWrench.h
+++ b/Code/Common/btkWrench.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/Common/btkWrenchCollection.h b/Code/Common/btkWrenchCollection.h
index 28bcc975..f96dc910 100644
--- a/Code/Common/btkWrenchCollection.h
+++ b/Code/Common/btkWrenchCollection.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/CMakeLists.txt b/Code/IO/CMakeLists.txt
index 06ed17ea..7cc7d4e5 100644
--- a/Code/IO/CMakeLists.txt
+++ b/Code/IO/CMakeLists.txt
@@ -25,12 +25,13 @@ SET(BTKIO_SRCS
btkEMFFileIO.cpp
btkEMxFileIO.cpp
btkGRxFileIO.cpp
+ btkHPFFileIO.cpp
btkKistlerDATFileIO.cpp
btkPWRFileIO.cpp
- btkRAxFileIO.cpp
- btkRICFileIO.cpp
btkMDFFileIO.cpp
btkMOMFileIO.cpp
+ btkRAxFileIO.cpp
+ btkRICFileIO.cpp
btkTDFFileIO.cpp
btkTRBFileIO.cpp
btkTRCFileIO.cpp
diff --git a/Code/IO/btkANBFileIO.cpp b/Code/IO/btkANBFileIO.cpp
index fd4204ca..415e9b03 100644
--- a/Code/IO/btkANBFileIO.cpp
+++ b/Code/IO/btkANBFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkANBFileIO.h b/Code/IO/btkANBFileIO.h
index f0c36eff..10d557f4 100644
--- a/Code/IO/btkANBFileIO.h
+++ b/Code/IO/btkANBFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkANCFileIO.cpp b/Code/IO/btkANCFileIO.cpp
index edec9206..6d97330a 100644
--- a/Code/IO/btkANCFileIO.cpp
+++ b/Code/IO/btkANCFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkANCFileIO.h b/Code/IO/btkANCFileIO.h
index e98a9d0d..e66fd0d5 100644
--- a/Code/IO/btkANCFileIO.h
+++ b/Code/IO/btkANCFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkANGFileIO.cpp b/Code/IO/btkANGFileIO.cpp
index 3a622def..cf87b2fb 100644
--- a/Code/IO/btkANGFileIO.cpp
+++ b/Code/IO/btkANGFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkANGFileIO.h b/Code/IO/btkANGFileIO.h
index 85add071..e913efb9 100644
--- a/Code/IO/btkANGFileIO.h
+++ b/Code/IO/btkANGFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkASCIIFileWriter.cpp b/Code/IO/btkASCIIFileWriter.cpp
index 9b261127..1bb55817 100644
--- a/Code/IO/btkASCIIFileWriter.cpp
+++ b/Code/IO/btkASCIIFileWriter.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkASCIIFileWriter.h b/Code/IO/btkASCIIFileWriter.h
index c94eee5b..b4de21da 100644
--- a/Code/IO/btkASCIIFileWriter.h
+++ b/Code/IO/btkASCIIFileWriter.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkAcquisitionFileIO.cpp b/Code/IO/btkAcquisitionFileIO.cpp
index b3685439..d0599480 100644
--- a/Code/IO/btkAcquisitionFileIO.cpp
+++ b/Code/IO/btkAcquisitionFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkAcquisitionFileIO.h b/Code/IO/btkAcquisitionFileIO.h
index 4d0fbc17..1625e014 100644
--- a/Code/IO/btkAcquisitionFileIO.h
+++ b/Code/IO/btkAcquisitionFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkAcquisitionFileIOFactory.cpp b/Code/IO/btkAcquisitionFileIOFactory.cpp
index 9a71a279..f9325495 100644
--- a/Code/IO/btkAcquisitionFileIOFactory.cpp
+++ b/Code/IO/btkAcquisitionFileIOFactory.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkAcquisitionFileIOFactory.h b/Code/IO/btkAcquisitionFileIOFactory.h
index a673c3ca..955677b6 100644
--- a/Code/IO/btkAcquisitionFileIOFactory.h
+++ b/Code/IO/btkAcquisitionFileIOFactory.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkAcquisitionFileIOFactory_p.h b/Code/IO/btkAcquisitionFileIOFactory_p.h
index 78e5034b..1315bb7e 100644
--- a/Code/IO/btkAcquisitionFileIOFactory_p.h
+++ b/Code/IO/btkAcquisitionFileIOFactory_p.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkAcquisitionFileIOFactory_registration.cpp b/Code/IO/btkAcquisitionFileIOFactory_registration.cpp
index 4abb505f..99ec9393 100644
--- a/Code/IO/btkAcquisitionFileIOFactory_registration.cpp
+++ b/Code/IO/btkAcquisitionFileIOFactory_registration.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -44,21 +44,17 @@
// C3D File IO
#include "btkC3DFileIO.h"
-// Motion Analysis Corp IOs
-#include "btkANBFileIO.h"
-#include "btkANCFileIO.h"
-#include "btkCALForcePlateFileIO.h"
-#include "btkTRBFileIO.h"
-#include "btkTRCFileIO.h"
-#include "btkXLSOrthoTrakFileIO.h"
+// AMTI
+#include "btkBSFFileIO.h"
// Codamotion
#include "btkMDFFileIO.h"
#include "btkXMOVEFileIO.h"
-// BTS IO
+// BTS
#include "btkTDFFileIO.h"
-// Delsys IO
+// Delsys
#include "btkDelsysEMGFileIO.h"
-// Elite IOs
+#include "btkHPFFileIO.h"
+// Elite
#include "btkANGFileIO.h"
#include "btkEMxFileIO.h"
#include "btkGRxFileIO.h"
@@ -66,10 +62,15 @@
#include "btkPWRFileIO.h"
#include "btkRAxFileIO.h"
#include "btkRICFileIO.h"
-// AMTI
-#include "btkBSFFileIO.h"
// Kistler
#include "btkKistlerDATFileIO.h"
+// Motion Analysis Corp IOs
+#include "btkANBFileIO.h"
+#include "btkANCFileIO.h"
+#include "btkCALForcePlateFileIO.h"
+#include "btkTRBFileIO.h"
+#include "btkTRCFileIO.h"
+#include "btkXLSOrthoTrakFileIO.h"
// Others
#include "btkEMFFileIO.h"
#include "btkCLBFileIO.h"
@@ -98,10 +99,11 @@ namespace btk
BTK_REGISTER_ACQUISITION_FILE_IO(MDFFileIO)
BTK_REGISTER_ACQUISITION_FILE_IO(XMOVEFileIO)
-
+
BTK_REGISTER_ACQUISITION_FILE_IO(TDFFileIO)
BTK_REGISTER_ACQUISITION_FILE_IO(DelsysEMGFileIO) // MUST BE BEFORE EMxFileIO
+ BTK_REGISTER_ACQUISITION_FILE_IO(HPFFileIO)
BTK_REGISTER_ACQUISITION_FILE_IO(ANGFileIO)
BTK_REGISTER_ACQUISITION_FILE_IO(EMxFileIO)
diff --git a/Code/IO/btkAcquisitionFileIOHandle.h b/Code/IO/btkAcquisitionFileIOHandle.h
index 4ae267e9..8b814418 100644
--- a/Code/IO/btkAcquisitionFileIOHandle.h
+++ b/Code/IO/btkAcquisitionFileIOHandle.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkAcquisitionFileIORegister.h b/Code/IO/btkAcquisitionFileIORegister.h
index 07d169f2..ab785e16 100644
--- a/Code/IO/btkAcquisitionFileIORegister.h
+++ b/Code/IO/btkAcquisitionFileIORegister.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkAcquisitionFileReader.cpp b/Code/IO/btkAcquisitionFileReader.cpp
index 219f01fe..2c7809a2 100644
--- a/Code/IO/btkAcquisitionFileReader.cpp
+++ b/Code/IO/btkAcquisitionFileReader.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkAcquisitionFileReader.h b/Code/IO/btkAcquisitionFileReader.h
index 868ec47e..50f6ae07 100644
--- a/Code/IO/btkAcquisitionFileReader.h
+++ b/Code/IO/btkAcquisitionFileReader.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkAcquisitionFileWriter.cpp b/Code/IO/btkAcquisitionFileWriter.cpp
index 16085821..9db323f9 100644
--- a/Code/IO/btkAcquisitionFileWriter.cpp
+++ b/Code/IO/btkAcquisitionFileWriter.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkAcquisitionFileWriter.h b/Code/IO/btkAcquisitionFileWriter.h
index 4575a420..4911320c 100644
--- a/Code/IO/btkAcquisitionFileWriter.h
+++ b/Code/IO/btkAcquisitionFileWriter.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkBSFFileIO.cpp b/Code/IO/btkBSFFileIO.cpp
index c3b68e9e..4ec7acb9 100644
--- a/Code/IO/btkBSFFileIO.cpp
+++ b/Code/IO/btkBSFFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -149,12 +149,21 @@ namespace btk
// Main header (SMnHeaderTag)
if (bifs.ReadI32() != 100)
throw BSFFileIOException("Invalid BSF file.");
+#if 1
+ bifs.SeekRead(4, BinaryFileStream::Current);
+#else
int32_t headerSize = bifs.ReadI32();
+#endif
int32_t numberOfActivePlatforms = bifs.ReadI32();
int32_t numberOfActiveInstruments = bifs.ReadI32();
std::string subjectName = btkTrimString(bifs.ReadString(100));
std::string testDate = btkTrimString(bifs.ReadString(12));
std::string subjectDateOfBirth = btkTrimString(bifs.ReadString(12));
+#if 1
+ bifs.SeekRead(24, BinaryFileStream::Current);
+ double totaleTimeTrial = bifs.ReadDouble(); // seconds
+ bifs.SeekRead(36, BinaryFileStream::Current);
+#else
double weight = bifs.ReadDouble();
double height = bifs.ReadDouble();
std::string sex = btkTrimString(bifs.ReadString(1));
@@ -169,6 +178,7 @@ namespace btk
int32_t preTriggerValue = bifs.ReadI32();
int32_t postTriggerValue = bifs.ReadI32();
double triggerValue = bifs.ReadDouble();
+#endif
bifs.SeekRead(4, BinaryFileStream::Current); // FIXME: There is 4 extra bytes in the file used to test this reader! What are they?
int32_t rate = bifs.ReadI32();
std::string protocol = btkTrimString(bifs.ReadString(150));
diff --git a/Code/IO/btkBSFFileIO.h b/Code/IO/btkBSFFileIO.h
index 7e9a0b7f..c3ff3d8f 100644
--- a/Code/IO/btkBSFFileIO.h
+++ b/Code/IO/btkBSFFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkBinaryByteOrderFormat.h b/Code/IO/btkBinaryByteOrderFormat.h
new file mode 100644
index 00000000..f3799f98
--- /dev/null
+++ b/Code/IO/btkBinaryByteOrderFormat.h
@@ -0,0 +1,890 @@
+/*
+ * The Biomechanical ToolKit
+ * Copyright (c) 2009-2014, Arnaud Barré
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name(s) of the copyright holders nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __btkByteOrderFormat_h
+#define __btkByteOrderFormat_h
+
+// Check if the processor is supported
+#if defined _MSC_VER
+ #if defined _M_IX86 || defined _M_X64
+ #define PROCESSOR_TYPE 1 /* IEEE_LittleEndian */
+ #elif defined _M_ALPHA
+ #define PROCESSOR_TYPE 2 /* VAX_LittleEndian */
+ #elif defined _M_MRX000 || defined _M_PPC
+ #define PROCESSOR_TYPE 3 /* IEEE_BigEndian */
+ #else
+ #error Processor not supported
+ #endif
+#elif defined __GNUC__
+ #if defined __i386__ || defined __x86_64__
+ #define PROCESSOR_TYPE 1 /* IEEE_LittleEndian */
+ #elif defined __vax__
+ #define PROCESSOR_TYPE 2 /* VAX_LittleEndian */
+ #elif defined __mips__ || defined __ppc__
+ #define PROCESSOR_TYPE 3 /* IEEE_BigEndian */
+ #else
+ #error Processor not supported
+ #endif
+#else
+ #error Development platform not supported
+#endif
+
+// MSVC doesn't have the header stdint.h
+#ifdef _MSC_VER
+ #include "Utilities/stdint.h"
+#else
+ #include <stdint.h>
+#endif
+
+namespace btk
+{
+ class VAXLittleEndianFormat
+ {
+ public:
+ template<class Stream> static int16_t ReadI16(Stream* src);
+ template<class Stream> static uint16_t ReadU16(Stream* src);
+ template<class Stream> static int32_t ReadI32(Stream* src);
+ template<class Stream> static uint32_t ReadU32(Stream* src);
+ template<class Stream> static int64_t ReadI64(Stream* src);
+ template<class Stream> static uint64_t ReadU64(Stream* src);
+ template<class Stream> static float ReadFloat(Stream* src);
+ template<class Stream> static double ReadDouble(Stream* src);
+
+ template<class Stream> static void Write(int16_t val, Stream* dest);
+ template<class Stream> static void Write(uint16_t val, Stream* dest);
+ template<class Stream> static void Write(int32_t val, Stream* dest);
+ template<class Stream> static void Write(uint32_t val, Stream* dest);
+ template<class Stream> static void Write(int64_t val, Stream* dest);
+ template<class Stream> static void Write(uint64_t val, Stream* dest);
+ template<class Stream> static void Write(float val, Stream* dest);
+
+ private:
+ VAXLittleEndianFormat(); // Not implemented.
+ ~VAXLittleEndianFormat(); // Not implemented.
+ VAXLittleEndianFormat(const VAXLittleEndianFormat& ); // Not implemented.
+ VAXLittleEndianFormat& operator=(const VAXLittleEndianFormat& ); // Not implemented.
+ };
+
+ class IEEELittleEndianFormat
+ {
+ public:
+ template<class Stream> static int16_t ReadI16(Stream* src);
+ template<class Stream> static uint16_t ReadU16(Stream* src);
+ template<class Stream> static int32_t ReadI32(Stream* src);
+ template<class Stream> static uint32_t ReadU32(Stream* src);
+ template<class Stream> static int64_t ReadI64(Stream* src);
+ template<class Stream> static uint64_t ReadU64(Stream* src);
+ template<class Stream> static float ReadFloat(Stream* src);
+ template<class Stream> static double ReadDouble(Stream* src);
+
+ template<class Stream> static void Write(int16_t val, Stream* dest);
+ template<class Stream> static void Write(uint16_t val, Stream* dest);
+ template<class Stream> static void Write(int32_t val, Stream* dest);
+ template<class Stream> static void Write(uint32_t val, Stream* dest);
+ template<class Stream> static void Write(int64_t val, Stream* dest);
+ template<class Stream> static void Write(uint64_t val, Stream* dest);
+ template<class Stream> static void Write(float val, Stream* dest);
+
+ private:
+ IEEELittleEndianFormat(); // Not implemented.
+ ~IEEELittleEndianFormat(); // Not implemented.
+ IEEELittleEndianFormat(const IEEELittleEndianFormat& ); // Not implemented.
+ IEEELittleEndianFormat& operator=(const IEEELittleEndianFormat& ); // Not implemented.
+ };
+
+ class IEEEBigEndianFormat
+ {
+ public:
+ template<class Stream> static int16_t ReadI16(Stream* src);
+ template<class Stream> static uint16_t ReadU16(Stream* src);
+ template<class Stream> static int32_t ReadI32(Stream* src);
+ template<class Stream> static uint32_t ReadU32(Stream* src);
+ template<class Stream> static int64_t ReadI64(Stream* src);
+ template<class Stream> static uint64_t ReadU64(Stream* src);
+ template<class Stream> static float ReadFloat(Stream* src);
+ template<class Stream> static double ReadDouble(Stream* src);
+
+ template<class Stream> static void Write(int16_t val, Stream* dest);
+ template<class Stream> static void Write(uint16_t val, Stream* dest);
+ template<class Stream> static void Write(int32_t val, Stream* dest);
+ template<class Stream> static void Write(uint32_t val, Stream* dest);
+ template<class Stream> static void Write(int64_t val, Stream* dest);
+ template<class Stream> static void Write(uint64_t val, Stream* dest);
+ template<class Stream> static void Write(float val, Stream* dest);
+
+ private:
+ IEEEBigEndianFormat(); // Not implemented.
+ ~IEEEBigEndianFormat(); // Not implemented.
+ IEEEBigEndianFormat(const IEEEBigEndianFormat& ); // Not implemented.
+ IEEEBigEndianFormat& operator=(const IEEEBigEndianFormat& ); // Not implemented.
+ };
+
+ // ----------------------------------------------------------------------- //
+
+ /**
+ * @class VAXLittleEndianFormat btkBinaryByteOrderFormat.h
+ * @brief Class to read and write data encoded from a VAX (LE) processor
+ * to a VAX (LE) and IEEE (LE, BE) processor.
+ *
+ * @sa IEEELittleEndianFormat, IEEEBigEndianFormat
+ */
+
+ /**
+ * Extracts one signed 16-bit integer.
+ */
+ template <class Stream>
+ int16_t VAXLittleEndianFormat::ReadI16(Stream* src)
+ {
+ char byteptr[2] = {0};
+ src->read(byteptr, 2);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[2] = {byteptr[1], byteptr[0]};
+ return *reinterpret_cast<int16_t const*>(foo);
+#else
+ return *reinterpret_cast<int16_t const*>(byteptr);
+#endif
+ };
+
+ /**
+ * Extracts one unsigned 16-bit integer.
+ */
+ template <class Stream>
+ uint16_t VAXLittleEndianFormat::ReadU16(Stream* src)
+ {
+ char byteptr[2] = {0};
+ src->read(byteptr, 2);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[2] = {byteptr[1], byteptr[0]};
+ return *reinterpret_cast<uint16_t const*>(foo);
+#else
+ return *reinterpret_cast<uint16_t const*>(byteptr);
+#endif
+ };
+
+ /**
+ * Extracts one signed 32-bit integer.
+ */
+ template <class Stream>
+ int32_t VAXLittleEndianFormat::ReadI32(Stream* src)
+ {
+ char byteptr[4] = {0};
+ src->read(byteptr, 4);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
+ return *reinterpret_cast<int32_t const*>(foo);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ return *reinterpret_cast<int32_t const*>(byteptr);
+#else
+ char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
+ return *reinterpret_cast<int32_t const*>(foo);
+#endif
+ };
+
+ /**
+ * Extracts one unsigned 32-bit integer.
+ */
+ template <class Stream>
+ uint32_t VAXLittleEndianFormat::ReadU32(Stream* src)
+ {
+ char byteptr[4] = {0};
+ src->read(byteptr, 4);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
+ return *reinterpret_cast<uint32_t const*>(foo);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ return *reinterpret_cast<uint32_t const*>(byteptr);
+#else
+ char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
+ return *reinterpret_cast<uint32_t const*>(foo);
+#endif
+ };
+
+ /**
+ * Extracts one signed 64-bit integer.
+ */
+ template <class Stream>
+ int64_t VAXLittleEndianFormat::ReadI64(Stream* src)
+ {
+ char byteptr[8] = {0};
+ src->read(byteptr, 8);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[8] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2], byteptr[5], byteptr[4], byteptr[7], byteptr[6]};
+ return *reinterpret_cast<int64_t const*>(foo);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ return *reinterpret_cast<int64_t const*>(byteptr);
+#else
+ char foo[8] = {byteptr[6], byteptr[7], byteptr[4], byteptr[5], byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
+ return *reinterpret_cast<int64_t const*>(foo);
+#endif
+ };
+
+ /**
+ * Extracts one unsigned 64-bit integer.
+ */
+ template <class Stream>
+ uint64_t VAXLittleEndianFormat::ReadU64(Stream* src)
+ {
+ char byteptr[8] = {0};
+ src->read(byteptr, 8);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[8] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2], byteptr[5], byteptr[4], byteptr[7], byteptr[6]};
+ return *reinterpret_cast<uint64_t const*>(foo);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ return *reinterpret_cast<uint64_t const*>(byteptr);
+#else
+ char foo[8] = {byteptr[6], byteptr[7], byteptr[4], byteptr[5], byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
+ return *reinterpret_cast<uint64_t const*>(foo);
+#endif
+ };
+
+ /**
+ * Extracts one float.
+ */
+ template <class Stream>
+ float VAXLittleEndianFormat::ReadFloat(Stream* src)
+ {
+ char byteptr[4] = {0};
+ src->read(byteptr, 4);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[4] = {byteptr[1] - 1 * (byteptr[1] == 0 ? 0 : 1), byteptr[0], byteptr[3], byteptr[2]};
+ return *reinterpret_cast<float const*>(foo);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ return *reinterpret_cast<float const*>(byteptr);
+#else
+ char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1] - 1 * (byteptr[1] == 0 ? 0 : 1)};
+ return *reinterpret_cast<float const*>(foo);
+#endif
+ };
+
+ /**
+ * Extracts one double.
+ */
+ template <class Stream>
+ double VAXLittleEndianFormat::ReadDouble(Stream* src)
+ {
+ char byteptr[8] = {0};
+ src->read(byteptr, 8);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[8] = {byteptr[1] - 1 * (byteptr[1] == 0 ? 0 : 1), byteptr[0], byteptr[3], byteptr[2], byteptr[5], byteptr[4], byteptr[7], byteptr[6]};
+ return *reinterpret_cast<double const*>(foo);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ return *reinterpret_cast<double const*>(byteptr);
+#else
+ char foo[8] = {byteptr[6], byteptr[7], byteptr[4], byteptr[5], byteptr[2], byteptr[3], byteptr[0], byteptr[1] - 1 * (byteptr[1] == 0 ? 0 : 1)};
+ return *reinterpret_cast<double const*>(foo);
+#endif
+ };
+
+ /**
+ * Writes the signed 16-bit integer @a i16 in the give stream @a dest.
+ */
+ template <class Stream>
+ void VAXLittleEndianFormat::Write(int16_t val, Stream* dest)
+ {
+ char byteptr[2] = {0};
+ memcpy(&byteptr, &val, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[2] = {byteptr[1], byteptr[0]};
+ dest->write(foo, 2);
+#else
+ dest->write(byteptr, 2);
+#endif
+ };
+
+ /**
+ * Writes the unsigned 16-bit integer @a u16 in the give stream @a dest.
+ */
+ template <class Stream>
+ void VAXLittleEndianFormat::Write(uint16_t val, Stream* dest)
+ {
+ char byteptr[2] = {0};
+ memcpy(&byteptr, &val, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[2] = {byteptr[1], byteptr[0]};
+ dest->write(foo, 2);
+#else
+ dest->write(byteptr, 2);
+#endif
+ };
+
+ /**
+ * Write the 32-bit signed integer @a val in the give stream @a dest.
+ */
+ template <class Stream>
+ void VAXLittleEndianFormat::Write(int32_t val, Stream* dest)
+ {
+ char byteptr[4] = {0};
+ memcpy(&byteptr, &val, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
+ dest->write(foo, 4);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ dest->write(byteptr, 4);
+#else
+ char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
+ dest->write(foo, 4);
+#endif
+ };
+
+ /**
+ * Write the 32-bit unsigned integer @a val in the give stream @a dest.
+ */
+ template <class Stream>
+ void VAXLittleEndianFormat::Write(uint32_t val, Stream* dest)
+ {
+ char byteptr[4] = {0};
+ memcpy(&byteptr, &val, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
+ dest->write(foo, 4);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ dest->write(byteptr, 4);
+#else
+ char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
+ dest->write(foo, 4);
+#endif
+ };
+
+ /**
+ * Writes the float @a f in the give stream @a dest.
+ */
+ template <class Stream>
+ void VAXLittleEndianFormat::Write(float val, Stream* dest)
+ {
+ char byteptr[4] = {0};
+ memcpy(&byteptr, &val, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[4] = {byteptr[1], byteptr[0] + 1 * (byteptr[0] == 0 ? 0 : 1), byteptr[3], byteptr[2]};
+ dest->write(foo, 4);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ dest->write(byteptr, 4);
+#else
+ char foo[4] = {byteptr[2], byteptr[3] + 1 * (byteptr[3] == 0 ? 0 : 1), byteptr[0], byteptr[1]};
+ dest->write(foo, 4);
+#endif
+ };
+
+ // ----------------------------------------------------------------------- //
+
+ /**
+ * @class IEEEBigEndianFormat btkBinaryByteOrderFormat.h
+ * @brief Class to read and write data encoded from a IEEE (BE) to a
+ * VAX (LE) and IEEE (LE, BE) processor
+ *
+ * @sa VAXLittleEndianFormat, IEEELittleEndianFormat
+ */
+
+ /**
+ * Extracts one signed 16-bit integer.
+ */
+ template <class Stream>
+ int16_t IEEEBigEndianFormat::ReadI16(Stream* src)
+ {
+ char byteptr[2] = {0};
+ src->read(byteptr, 2);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ return *reinterpret_cast<int16_t const*>(byteptr);
+#else
+ char foo[2] = {byteptr[1], byteptr[0]};
+ return *reinterpret_cast<int16_t const*>(foo);
+#endif
+ };
+
+ /**
+ * Extracts one unsigned 16-bit integer.
+ */
+ template <class Stream>
+ uint16_t IEEEBigEndianFormat::ReadU16(Stream* src)
+ {
+ char byteptr[2] = {0};
+ src->read(byteptr, 2);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ return *reinterpret_cast<uint16_t const*>(byteptr);
+#else
+ char foo[2] = {byteptr[1], byteptr[0]};
+ return *reinterpret_cast<uint16_t const*>(foo);
+#endif
+ };
+
+ /**
+ * Extracts one signed 32-bit integer.
+ */
+ template <class Stream>
+ int32_t IEEEBigEndianFormat::ReadI32(Stream* src)
+ {
+ char byteptr[4] = {0};
+ src->read(byteptr, 4);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ return *reinterpret_cast<int32_t const*>(byteptr);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
+ return *reinterpret_cast<int32_t const*>(foo);
+#else
+ char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ return *reinterpret_cast<int32_t const*>(foo);
+#endif
+ };
+
+ /**
+ * Extracts one unsigned 32-bit integer.
+ */
+ template <class Stream>
+ uint32_t IEEEBigEndianFormat::ReadU32(Stream* src)
+ {
+ char byteptr[4] = {0};
+ src->read(byteptr, 4);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ return *reinterpret_cast<uint32_t const*>(byteptr);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
+ return *reinterpret_cast<uint32_t const*>(foo);
+#else
+ char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ return *reinterpret_cast<uint32_t const*>(foo);
+#endif
+ };
+
+ /**
+ * Extracts one signed 64-bit integer.
+ */
+ template <class Stream>
+ int64_t IEEEBigEndianFormat::ReadI64(Stream* src)
+ {
+ char byteptr[8] = {0};
+ src->read(byteptr, 8);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ return *reinterpret_cast<int64_t const*>(byteptr);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[8] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2], byteptr[5], byteptr[4], byteptr[7], byteptr[6]};
+ return *reinterpret_cast<int64_t const*>(foo);
+#else
+ char foo[8] = {byteptr[7], byteptr[6], byteptr[5], byteptr[4], byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ return *reinterpret_cast<int64_t const*>(foo);
+#endif
+ };
+
+ /**
+ * Extracts one unsigned 64-bit integer.
+ */
+ template <class Stream>
+ uint64_t IEEEBigEndianFormat::ReadU64(Stream* src)
+ {
+ char byteptr[8] = {0};
+ src->read(byteptr, 8);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ return *reinterpret_cast<uint64_t const*>(byteptr);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[8] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2], byteptr[5], byteptr[4], byteptr[7], byteptr[6]};
+ return *reinterpret_cast<uint64_t const*>(foo);
+#else
+ char foo[8] = {byteptr[7], byteptr[6], byteptr[5], byteptr[4], byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ return *reinterpret_cast<uint64_t const*>(foo);
+#endif
+ };
+
+ /**
+ * Extracts one float.
+ */
+ template <class Stream>
+ float IEEEBigEndianFormat::ReadFloat(Stream* src)
+ {
+ char byteptr[4] = {0};
+ src->read(byteptr, 4);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ return *reinterpret_cast<float const*>(byteptr);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[4] = {byteptr[1], byteptr[0] + 1 * (byteptr[0] == 0 ? 0 : 1), byteptr[3], byteptr[2]};
+ return *reinterpret_cast<float const*>(foo);
+#else
+ char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ return *reinterpret_cast<float const*>(foo);
+#endif
+ };
+
+ /**
+ * Extracts one double.
+ */
+ template <class Stream>
+ double IEEEBigEndianFormat::ReadDouble(Stream* src)
+ {
+ char byteptr[8] = {0};
+ src->read(byteptr, 8);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ return *reinterpret_cast<double const*>(byteptr);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[8] = {byteptr[1], byteptr[0] + 1 * (byteptr[0] == 0 ? 0 : 1), byteptr[3], byteptr[2], byteptr[5], byteptr[4], byteptr[7], byteptr[6]};
+ return *reinterpret_cast<double const*>(foo);
+#else
+ char foo[8] = {byteptr[7], byteptr[6], byteptr[5], byteptr[4], byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ return *reinterpret_cast<double const*>(foo);
+#endif
+ };
+
+ /**
+ * Writes the signed 16-bit integer @a i16 in the give stream @a dest.
+ */
+ template <class Stream>
+ void IEEEBigEndianFormat::Write(int16_t i16, Stream* dest)
+ {
+ char byteptr[2] = {0};
+ memcpy(&byteptr, &i16, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ dest->write(byteptr, 2);
+#else
+ char foo[2] = {byteptr[1], byteptr[0]};
+ dest->write(foo, 2);
+#endif
+ };
+
+ /**
+ * Writes the unsigned 16-bit integer @a u16 in the give stream @a dest.
+ */
+ template <class Stream>
+ void IEEEBigEndianFormat::Write(uint16_t u16, Stream* dest)
+ {
+ char byteptr[2] = {0};
+ memcpy(&byteptr, &u16, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ dest->write(byteptr, 2);
+#else
+ char foo[2] = {byteptr[1], byteptr[0]};
+ dest->write(foo, 2);
+#endif
+ };
+
+ /**
+ * Write the 32-bit signed integer @a val in the give stream @a dest.
+ */
+ template <class Stream>
+ void IEEEBigEndianFormat::Write(int32_t val, Stream* dest)
+ {
+ char byteptr[4] = {0};
+ memcpy(&byteptr, &val, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ dest->write(byteptr, 4);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
+ dest->write(foo, 4);
+#else
+ char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ dest->write(foo, 4);
+#endif
+ };
+
+ /**
+ * Write the 32-bit unsigned integer @a val in the give stream @a dest.
+ */
+ template <class Stream>
+ void IEEEBigEndianFormat::Write(uint32_t val, Stream* dest)
+ {
+ char byteptr[4] = {0};
+ memcpy(&byteptr, &val, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ dest->write(byteptr, 4);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
+ dest->write(foo, 4);
+#else
+ char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ dest->write(foo, 4);
+#endif
+ };
+
+ /**
+ * Writes the float @a val in the give stream @a dest.
+ */
+ template <class Stream>
+ void IEEEBigEndianFormat::Write(float val, Stream* dest)
+ {
+ char byteptr[4] = {0};
+ memcpy(&byteptr, &val, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ dest->write(byteptr, 4);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[4] = {byteptr[1] - 1 * (byteptr[1] == 0 ? 0 : 1), byteptr[0], byteptr[3], byteptr[2]};
+ dest->write(foo, 4);
+#else
+ char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ dest->write(foo, 4);
+#endif
+ };
+
+ // ----------------------------------------------------------------------- //
+
+ /**
+ * @class IEEELittleEndianFormat btkBinaryByteOrderFormat.h
+ * @brief Class to read and write data encoded from a IEEE (LE) to a
+ * VAX (LE) and IEEE (LE, BE) processor.
+ *
+ * @sa VAXLittleEndianFormat, IEEEBigEndianFormat
+ */
+
+ /**
+ * Extracts one signed 16-bit integer.
+ */
+ template <class Stream>
+ int16_t IEEELittleEndianFormat::ReadI16(Stream* src)
+ {
+ char byteptr[2] = {0};
+ src->read(byteptr, 2);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[2] = {byteptr[1], byteptr[0]};
+ return *reinterpret_cast<int16_t const*>(foo);
+#else
+ return *reinterpret_cast<int16_t const*>(byteptr);
+#endif
+ };
+
+ /**
+ * Extracts one unsigned 16-bit integer.
+ */
+ template <class Stream>
+ uint16_t IEEELittleEndianFormat::ReadU16(Stream* src)
+ {
+ char byteptr[2] = {0};
+ src->read(byteptr, 2);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[2] = {byteptr[1], byteptr[0]};
+ return *reinterpret_cast<uint16_t const*>(foo);
+#else
+ return *reinterpret_cast<uint16_t const*>(byteptr);
+#endif
+ };
+
+ /**
+ * Extracts one signed 32-bit integer.
+ */
+ template <class Stream>
+ int32_t IEEELittleEndianFormat::ReadI32(Stream* src)
+ {
+ char byteptr[4] = {0};
+ src->read(byteptr, 4);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ return *reinterpret_cast<int32_t const*>(foo);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
+ return *reinterpret_cast<int32_t const*>(foo);
+#else
+ return *reinterpret_cast<int32_t const*>(byteptr);
+#endif
+ };
+
+ /**
+ * Extracts one unsigned 32-bit integer.
+ */
+ template <class Stream>
+ uint32_t IEEELittleEndianFormat::ReadU32(Stream* src)
+ {
+ char byteptr[4] = {0};
+ src->read(byteptr, 4);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ return *reinterpret_cast<uint32_t const*>(foo);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
+ return *reinterpret_cast<uint32_t const*>(foo);
+#else
+ return *reinterpret_cast<uint32_t const*>(byteptr);
+#endif
+ };
+
+ /**
+ * Extracts one signed 64-bit integer.
+ */
+ template <class Stream>
+ int64_t IEEELittleEndianFormat::ReadI64(Stream* src)
+ {
+ char byteptr[8] = {0};
+ src->read(byteptr, 8);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[8] = {byteptr[7], byteptr[6], byteptr[5], byteptr[6], byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ return *reinterpret_cast<int64_t const*>(foo);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[8] = {byteptr[6], byteptr[7], byteptr[4], byteptr[5], byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
+ return *reinterpret_cast<int64_t const*>(foo);
+#else
+ return *reinterpret_cast<int64_t const*>(byteptr);
+#endif
+ };
+
+ /**
+ * Extracts one unsigned 64-bit integer.
+ */
+ template <class Stream>
+ uint64_t IEEELittleEndianFormat::ReadU64(Stream* src)
+ {
+ char byteptr[8] = {0};
+ src->read(byteptr, 8);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[8] = {byteptr[7], byteptr[6], byteptr[5], byteptr[6], byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ return *reinterpret_cast<uint64_t const*>(foo);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[8] = {byteptr[6], byteptr[7], byteptr[4], byteptr[5], byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
+ return *reinterpret_cast<uint64_t const*>(foo);
+#else
+ return *reinterpret_cast<uint64_t const*>(byteptr);
+#endif
+ };
+
+ /**
+ * Extracts one float.
+ */
+ template <class Stream>
+ float IEEELittleEndianFormat::ReadFloat(Stream* src)
+ {
+ char byteptr[4] = {0};
+ src->read(byteptr, 4);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ return *reinterpret_cast<float const*>(foo);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[4] = {byteptr[2], byteptr[3] + 1 * (byteptr[3] == 0 ? 0 : 1), byteptr[0], byteptr[1]};
+ return *reinterpret_cast<float const*>(foo);
+#else
+ return *reinterpret_cast<float const*>(byteptr);
+#endif
+ };
+
+ /**
+ * Extracts one float.
+ */
+ template <class Stream>
+ double IEEELittleEndianFormat::ReadDouble(Stream* src)
+ {
+ char byteptr[8] = {0};
+ src->read(byteptr, 8);
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[8] = {byteptr[7], byteptr[6], byteptr[5], byteptr[4], byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ return *reinterpret_cast<double const*>(foo);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[8] = {byteptr[6], byteptr[7] + 1 * (byteptr[7] == 0 ? 0 : 1), byteptr[4], byteptr[5], byteptr[2], byteptr[3], byteptr[1], byteptr[0]};
+ return *reinterpret_cast<double const*>(foo);
+#else
+ return *reinterpret_cast<double const*>(byteptr);
+#endif
+ };
+
+ /**
+ * Writes the signed 16-bit integer @a i16 in the give stream @a dest.
+ */
+ template <class Stream>
+ void IEEELittleEndianFormat::Write(int16_t i16, Stream* dest)
+ {
+ char byteptr[2] = {0};
+ memcpy(&byteptr, &i16, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[2] = {byteptr[1], byteptr[0]};
+ dest->write(foo, 2);
+#else
+ dest->write(byteptr, 2);
+#endif
+ };
+
+ /**
+ * Writes the unsigned 16-bit integer @a u16 in the give stream @a dest.
+ */
+ template <class Stream>
+ void IEEELittleEndianFormat::Write(uint16_t u16, Stream* dest)
+ {
+ char byteptr[2] = {0};
+ memcpy(&byteptr, &u16, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[2] = {byteptr[1], byteptr[0]};
+ dest->write(foo, 2);
+#else
+ dest->write(byteptr, 2);
+#endif
+ };
+
+ /**
+ * Write the 32-bit signed integer @a val in the give stream @a dest.
+ */
+ template <class Stream>
+ void IEEELittleEndianFormat::Write(int32_t val, Stream* dest)
+ {
+ char byteptr[4] = {0};
+ memcpy(&byteptr, &val, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ dest->write(foo, 4);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
+ dest->write(foo, 4);
+#else
+ dest->write(byteptr, 4);
+#endif
+ };
+
+ /**
+ * Write the 32-bit unsigned integer @a val in the give stream @a dest
+ */
+ template <class Stream>
+ void IEEELittleEndianFormat::Write(uint32_t val, Stream* dest)
+ {
+ char byteptr[4] = {0};
+ memcpy(&byteptr, &val, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ dest->write(foo, 4);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
+ dest->write(foo, 4);
+#else
+ dest->write(byteptr, 4);
+#endif
+ };
+
+ /**
+ * Writes the float @a val in the give stream @a dest.
+ */
+ template <class Stream>
+ void IEEELittleEndianFormat::Write(float val, Stream* dest)
+ {
+ char byteptr[4] = {0};
+ memcpy(&byteptr, &val, sizeof(byteptr));
+#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
+ char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
+ dest->write(foo, 4);
+#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
+ char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1] - 1 * (byteptr[1] == 0 ? 0 : 1)};
+ dest->write(foo, 4);
+#else
+ dest->write(byteptr, 4);
+#endif
+ };
+};
+
+#endif // __btkByteOrderFormat_h
\ No newline at end of file
diff --git a/Code/IO/btkBinaryFileStream.cpp b/Code/IO/btkBinaryFileStream.cpp
index 7b13bf57..f222534e 100644
--- a/Code/IO/btkBinaryFileStream.cpp
+++ b/Code/IO/btkBinaryFileStream.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -85,7 +85,7 @@ namespace btk
* ifs.SetExceptions (btk::BinaryFileStream::EndFileBit | btk::BinaryFileStream::FailBit | btk::BinaryFileStream::BadBit);
* @endcode
*
- * @sa VAXLittleEndianBinaryFileStream, IEEELittleEndianBinaryFileStream, IEEEBigEndianBinaryFileStream, NativeBinaryFileStream
+ * @sa ByteOrderBinaryFileStream, IEEELittleEndianBinaryFileStream, IEEEBigEndianBinaryFileStream, NativeBinaryFileStream
*
* @ingroup BTKIO
*/
@@ -93,42 +93,14 @@ namespace btk
* @typedef BinaryFileStreamFailure
* Exception for the BinaryFileStream class and inherited classes.
*/
- /**
- * @typedef BinaryFileStream::IOState
- * Bitmask type to represent stream error state flags.
- */
/**
* @typedef BinaryFileStream::OpenMode
* Flags describing the requested I/O mode for the file.
*/
- /**
- * @typedef BinaryFileStream::SeekDir
- * Flags representing the seeking direction of a stream seeking operation.
- */
- /**
- * @typedef BinaryFileStream::StreamPosition
- * Type to represent positions in a stream.
- */
- /**
- * @typedef BinaryFileStream::StreamOffset
- * Type to represent position offsets in a stream.
- */
/**
* @var BinaryFileStream::EndFileBit
* End-of-File reached while performing an extracting operation on an input stream.
*/
- /**
- * @var BinaryFileStream::FailBit
- * The last input operation failed because of an error related to the internal logic of the operation itself.
- */
- /**
- * @var BinaryFileStream::BadBit
- * Error due to the failure of an input/output operation on the stream buffer.
- */
- /**
- * @var BinaryFileStream::GoodBit
- * No error. Represents the absence of all the above (the value zero).
- */
/**
* @var BinaryFileStream::In
* Allows input operations on the stream.
@@ -141,18 +113,6 @@ namespace btk
* @var BinaryFileStream::Truncate
* Any content is erased.The file is assumed to be zero-length.
*/
- /**
- * @var BinaryFileStream::Begin
- * Beginning of the stream buffer.
- */
- /**
- * @var BinaryFileStream::Current
- * Current position in the stream buffer.
- */
- /**
- * @var BinaryFileStream::End
- * End of the stream buffer.
- */
/**
* @var BinaryFileStream::mp_Stream
* Binary stream which read/write data.
@@ -251,35 +211,6 @@ namespace btk
return *byteptr;
};
- /**
- * @fn std::vector<char> BinaryFileStream::ReadChar(size_t nb)
- * Extracts @a nb characters and return them as a vector.
- */
-
-
- /**
- * @fn void BinaryFileStream::ReadChar(std::vector<char>& values)
- * Extracts exactly the number of elements set in the vector @a values
- *
- * @note In case you want to assign only a part of the vector, you can use the method using an array.
- * For example;
- * @code
- * std::vector<char> val(45,0);
- * bfs.ReadChar(10, &(val[0])); // assign value #0-9
- * // ...
- * bfs.ReadChar(5, &(val[40])); // assign value #41-45
- * @endcode
- */
-
- /**
- * Extracts @a nb chars and set them in the array @a values.
- */
- void BinaryFileStream::ReadChar(size_t nb, char* values)
- {
- for (size_t i = 0 ; i < nb ; ++i)
- values[i] = this->ReadU8();
- };
-
/**
* Extracts one signed 8-bit integer.
*/
@@ -290,34 +221,6 @@ namespace btk
return *byteptr;
};
- /**
- * @fn std::vector<int8_t> BinaryFileStream::ReadI8(size_t nb)
- * Extracts @a nb signed 8-bit integers and return them as a vector.
- */
-
- /**
- * @fn void BinaryFileStream::ReadI8(std::vector<int8_t>& values)
- * Extracts exactly the number of elements set in the vector @a values
- *
- * @note In case you want to assign only a part of the vector, you can use the method using an array.
- * For example;
- * @code
- * std::vector<int8_t> val(45,0);
- * bfs.ReadI8(10, &(val[0])); // assign value #0-9
- * // ...
- * bfs.ReadI8(5, &(val[40])); // assign value #41-45
- * @endcode
- */
-
- /**
- * Extracts @a nb signed 8-bit integers and set them in the array @a values.
- */
- void BinaryFileStream::ReadI8(size_t nb, int8_t* values)
- {
- for (size_t i = 0 ; i < nb ; ++i)
- values[i] = this->ReadI8();
- };
-
/**
* Extracts one unsigned 8-bit integer.
*/
@@ -328,232 +231,46 @@ namespace btk
return *byteptr;
};
- /**
- * @fn std::vector<uint8_t> BinaryFileStream::ReadU8(size_t nb)
- * Extracts @a nb unsigned 8-bit integers and return them as a vector.
- */
-
- /**
- * @fn void BinaryFileStream::ReadU8(std::vector<uint8_t>& values)
- * Extracts exactly the number of elements set in the vector @a values
- *
- * @note In case you want to assign only a part of the vector, you can use the method using an array.
- * For example;
- * @code
- * std::vector<uint8_t> val(45,0);
- * bfs.ReadU8(10, &(val[0])); // assign value #0-9
- * // ...
- * bfs.ReadU8(5, &(val[40])); // assign value #41-45
- * @endcode
- */
-
- /**
- * Extracts @a nb unsigned 8-bit integers and set them in the array @a values.
- */
- void BinaryFileStream::ReadU8(size_t nb, uint8_t* values)
- {
- for (size_t i = 0 ; i < nb ; ++i)
- values[i] = this->ReadU8();
- };
-
/**
* @fn int16_t BinaryFileStream::ReadI16() = 0
* Extracts one signed 16-bit integer.
*/
- /**
- * @fn std::vector<int16_t> BinaryFileStream::ReadI16(size_t nb)
- * Extracts @a nb signed 16-bit integers and return them as a vector.
- */
-
- /**
- * @fn void BinaryFileStream::ReadI16(std::vector<int16_t>& values)
- * Extracts exactly the number of elements set in the vector @a values
- *
- * @note In case you want to assign only a part of the vector, you can use the method using an array.
- * For example;
- * @code
- * std::vector<int16_t> val(45,0);
- * bfs.ReadI16(10, &(val[0])); // assign value #0-9
- * // ...
- * bfs.ReadI16(5, &(val[40])); // assign value #41-45
- * @endcode
- */
-
- /**
- * Extracts @a nb signed 16-bit integers and set them in the array @a values.
- */
- void BinaryFileStream::ReadI16(size_t nb, int16_t* values)
- {
- for (size_t i = 0 ; i < nb ; ++i)
- values[i] = this->ReadI16();
- };
-
/**
* @fn uint16_t BinaryFileStream::ReadU16() = 0
* Extracts one unsigned 16-bit integer.
*/
- /**
- * @fn std::vector<uint16_t> BinaryFileStream::ReadU16(size_t nb)
- * Extracts @a nb unsigned 16-bit integers and return them as a vector.
- */
-
- /**
- * @fn void BinaryFileStream::ReadU16(std::vector<uint16_t>& values)
- * Extracts exactly the number of elements set in the vector @a values
- *
- * @note In case you want to assign only a part of the vector, you can use the method using an array.
- * For example;
- * @code
- * std::vector<uint16_t> val(45,0);
- * bfs.ReadU16(10, &(val[0])); // assign value #0-9
- * // ...
- * bfs.ReadU16(5, &(val[40])); // assign value #41-45
- * @endcode
- */
-
- /**
- * Extracts @a nb unsigned 16-bit integers and set them in the array @a values.
- */
- void BinaryFileStream::ReadU16(size_t nb, uint16_t* values)
- {
- for (size_t i = 0 ; i < nb ; ++i)
- values[i] = this->ReadU16();
- };
-
/**
* @fn int32_t BinaryFileStream::ReadI32() = 0
* Extracts one signed 32-bit integer.
*/
- /**
- * @fn std::vector<int32_t> BinaryFileStream::ReadI32(size_t nb)
- * Extracts @a nb signed 32-bit integers and return them as a vector.
- */
-
- /**
- * @fn void BinaryFileStream::ReadI32(std::vector<int32_t>& values)
- * Extracts exactly the number of elements set in the vector @a values
- *
- * @note In case you want to assign only a part of the vector, you can use the method using an array.
- * For example;
- * @code
- * std::vector<int32_t> val(45,0);
- * bfs.ReadI32(10, &(val[0])); // assign value #0-9
- * // ...
- * bfs.ReadI32(5, &(val[40])); // assign value #41-45
- * @endcode
- */
-
- /**
- * Extracts @a nb signed 32-bit integers and set them in the array @a values.
- */
- void BinaryFileStream::ReadI32(size_t nb, int32_t* values)
- {
- for (size_t i = 0 ; i < nb ; ++i)
- values[i] = this->ReadI32();
- };
-
/**
* @fn uint32_t BinaryFileStream::ReadU32() = 0
* Extracts one unsigned 32-bit integer.
*/
/**
- * @fn std::vector<uint32_t> BinaryFileStream::ReadU32(size_t nb)
- * Extracts @a nb unsigned 32-bit integers and return them as a vector.
- */
-
- /**
- * @fn void BinaryFileStream::ReadU32(std::vector<uint32_t>& values)
- * Extracts exactly the number of elements set in the vector @a values
- *
- * @note In case you want to assign only a part of the vector, you can use the method using an array.
- * For example;
- * @code
- * std::vector<uint32_t> val(45,0);
- * bfs.ReadU32(10, &(val[0])); // assign value #0-9
- * // ...
- * bfs.ReadU32(5, &(val[40])); // assign value #41-45
- * @endcode
+ * @fn int64_t BinaryFileStream::ReadI64() = 0
+ * Extracts one signed 64-bit integer.
*/
- /**
- * Extracts @a nb unsigned 32-bit integers and set them in the array @a values.
+ /**
+ * @fn uint64_t BinaryFileStream::ReadU64() = 0
+ * Extracts one unsigned 64-bit integer.
*/
- void BinaryFileStream::ReadU32(size_t nb, uint32_t* values)
- {
- for (size_t i = 0 ; i < nb ; ++i)
- values[i] = this->ReadU32();
- };
/**
* @fn float BinaryFileStream::ReadFloat() = 0
* Extracts one float.
*/
- /**
- * @fn std::vector<float> BinaryFileStream::ReadFloat(size_t nb)
- * Extracts @a nb floats and return them as a vector.
- */
-
- /**
- * @fn void BinaryFileStream::ReadFloat(std::vector<float>& values)
- * Extracts exactly the number of elements set in the vector @a values
- *
- * @note In case you want to assign only a part of the vector, you can use the method using an array.
- * For example;
- * @code
- * std::vector<float> val(45,0);
- * bfs.ReadFloat(10, &(val[0])); // assign value #0-9
- * // ...
- * bfs.ReadFloat(5, &(val[40])); // assign value #41-45
- * @endcode
- */
-
- /**
- * Extracts @a nb floats and set them in the array @a values.
- */
- void BinaryFileStream::ReadFloat(size_t nb, float* values)
- {
- for (size_t i = 0 ; i < nb ; ++i)
- values[i] = this->ReadFloat();
- };
-
/**
* @fn float BinaryFileStream::ReadDouble() = 0
* Extracts one double.
*/
- /**
- * @fn std::vector<double> BinaryFileStream::ReadDouble(size_t nb)
- * Extracts @a nb doubles and return them as a vector.
- */
-
- /**
- * @fn void BinaryFileStream::ReadDouble(std::vector<double>& values)
- * Extracts exactly the number of elements set in the vector @a values
- *
- * @note In case you want to assign only a part of the vector, you can use the method using an array.
- * For example;
- * @code
- * std::vector<double> val(45,0);
- * bfs.ReadDouble(10, &(val[0])); // assign value #0-9
- * // ...
- * bfs.ReadDouble(5, &(val[40])); // assign value #41-45
- * @endcode
- */
-
- /**
- * Extracts @a nb doubles and set them in the array @a values.
- */
- void BinaryFileStream::ReadDouble(size_t nb, double* values)
- {
- for (size_t i = 0 ; i < nb ; ++i)
- values[i] = this->ReadDouble();
- };
-
/**
* Extracts one string with @a nbChar characters.
*/
@@ -574,34 +291,6 @@ namespace btk
return sFs;
};
- /**
- * @fn std::vector<std::string> BinaryFileStream::ReadString(size_t nb, size_t nbChar)
- * Extracts @a nb strings with @a nb Charcharacters and return them as a vector.
- */
-
- /**
- * @fn void BinaryFileStream::ReadString(size_t nbChar, std::vector<std::string>& values)
- * Extracts exactly the number of elements set in the vector @a values
- *
- * @note In case you want to assign only a part of the vector, you can use the method using an array.
- * For example;
- * @code
- * std::vector<uint8_t> val(45,0);
- * bfs.ReadU8(10, &(val[0])); // assign value #0-9
- * // ...
- * bfs.ReadU8(5, &(val[40])); // assign value #41-45
- * @endcode
- */
-
- /**
- * Extracts @a nb unsigned 8-bit integers and set them in the array @a values.
- */
- void BinaryFileStream::ReadString(size_t nb, size_t nbChar, std::string* values)
- {
- for (size_t i = 0 ; i < nb ; ++i)
- values[i] = this->ReadString(nbChar);
- };
-
/**
* @fn void BinaryFileStream::SeekRead(StreamOffset offset, SeekDir dir)
* Moves the get pointer by @a nb bytes in the seeking direction @a dir.
@@ -627,7 +316,7 @@ namespace btk
* Moves the set pointer by @a nb bytes in the seeking direction @a dir.
*/
- /**
+ /*
* Writes the character @a c in the stream an return its size.
*/
/*
@@ -637,161 +326,62 @@ namespace btk
return 1;
};
*/
- /*
- * Writes the vector of characters @a rVectorChar in the stream an return its size.
- */
- /*
- size_t BinaryFileStream::Write(const std::vector<char>& rVectorChar)
- {
- size_t inc = 0;
- while (inc < rVectorChar.size())
- this->Write(rVectorChar[inc++]);
- return rVectorChar.size() * 1;
- };
- */
+
/**
- * Writes the signed 8-bit integer @a i8 in the stream an return its size.
+ * Writes the signed 8-bit integer @a value in the stream an return its size.
*/
- size_t BinaryFileStream::Write(int8_t i8)
+ size_t BinaryFileStream::Write(int8_t value)
{
- char c = static_cast<char>(i8);
+ char c = static_cast<char>(value);
this->mp_Stream->write(&c, 1);
return 1;
};
/**
- * Writes the vector of signed 8-bit integers @a rVectorI8 in the stream an return its size.
+ * Writes the unsigned 8-bit integer @a value in the stream an return its size.
*/
- size_t BinaryFileStream::Write(const std::vector<int8_t>& rVectorI8)
+ size_t BinaryFileStream::Write(uint8_t value)
{
- size_t inc = 0;
- while (inc < rVectorI8.size())
- this->Write(rVectorI8[inc++]);
- return rVectorI8.size() * 1;
- };
-
- /**
- * Writes the unsigned 8-bit integer @a u8 in the stream an return its size.
- */
- size_t BinaryFileStream::Write(uint8_t u8)
- {
- char c = static_cast<char>(u8);
+ char c = static_cast<char>(value);
this->mp_Stream->write(&c, 1);
return 1;
};
/**
- * Writes the vector of unsigned 8-bit integers @a rVectorU8 in the stream an return its size.
- */
- size_t BinaryFileStream::Write(const std::vector<uint8_t>& rVectorU8)
- {
- size_t inc = 0;
- while (inc < rVectorU8.size())
- this->Write(rVectorU8[inc++]);
- return rVectorU8.size() * 1;
- };
-
- /**
- * @fn size_t BinaryFileStream::Write(int16_t i16) = 0
+ * @fn size_t BinaryFileStream::Write(int16_t value) = 0
* Extracts one signed 16-bit integer.
*/
/**
- * Writes the vector of signed 16-bit integers @a rVectorI16 in the stream an return its size.
- */
- size_t BinaryFileStream::Write(const std::vector<int16_t>& rVectorI16)
- {
- size_t inc = 0;
- while (inc < rVectorI16.size())
- this->Write(rVectorI16[inc++]);
- return rVectorI16.size() * 2;
- };
-
- /**
- * @fn size_t BinaryFileStream::Write(uint16_t u16) = 0
+ * @fn size_t BinaryFileStream::Write(uint16_t value) = 0
* Extracts one unsigned 16-bit integer.
*/
/**
- * Writes the vector of unsigned 16-bit integers @a rVectorU16 in the stream an return its size.
- */
- size_t BinaryFileStream::Write(const std::vector<uint16_t>& rVectorU16)
- {
- size_t inc = 0;
- while (inc < rVectorU16.size())
- this->Write(rVectorU16[inc++]);
- return rVectorU16.size() * 2;
- };
-
- /**
- * @fn size_t BinaryFileStream::Write(int32_t i32) = 0;
+ * @fn size_t BinaryFileStream::Write(int32_t value) = 0;
* Write one 32-bit signed integer
*/
- /**
- * Writes the vector of signed 32-bit integers @a rVectorI32 in the stream an return its size.
- */
- size_t BinaryFileStream::Write(const std::vector<int32_t>& rVectorI32)
- {
- size_t inc = 0;
- while (inc < rVectorI32.size())
- this->Write(rVectorI32[inc++]);
- return rVectorI32.size() * 2;
- };
-
/**
- * @fn size_t BinaryFileStream::Write(uint32_t u32) = 0;
+ * @fn size_t BinaryFileStream::Write(uint32_t value) = 0;
* Write one 32-bit unsigned integer
*/
- /**
- * Writes the vector of unsigned 32-bit integers @a rVectorU32 in the stream an return its size.
- */
- size_t BinaryFileStream::Write(const std::vector<uint32_t>& rVectorU32)
- {
- size_t inc = 0;
- while (inc < rVectorU32.size())
- this->Write(rVectorU32[inc++]);
- return rVectorU32.size() * 2;
- };
-
/**
- * @fn size_t BinaryFileStream::Write(float f) = 0
+ * @fn size_t BinaryFileStream::Write(float value) = 0
* Write one float.
*/
- /**
- * Writes the vector of floats @a rVectorFloat in the stream an return its size.
- */
- size_t BinaryFileStream::Write(const std::vector<float>& rVectorFloat)
- {
- size_t inc = 0;
- while (inc < rVectorFloat.size())
- this->Write(rVectorFloat[inc++]);
- return rVectorFloat.size() * 4;
- };
-
/**
* Writes the string @a rString in the stream an return its size.
*/
- size_t BinaryFileStream::Write(const std::string& rString)
- {
- this->mp_Stream->write(rString.c_str(), rString.length());
- return rString.length();
- };
-
- /**
- * Writes the vector of strings @a rVectorString in the stream an return its size.
- */
- size_t BinaryFileStream::Write(const std::vector<std::string>& rVectorString)
+ size_t BinaryFileStream::Write(const std::string& value)
{
- size_t inc = 0;
- size_t writedBytes = 0;
- while (inc < rVectorString.size())
- writedBytes += this->Write(rVectorString[inc++]);
- return writedBytes;
+ this->mp_Stream->write(value.c_str(), value.length());
+ return value.length();
};
+ // ----------------------------------------------------------------------- //
/**
* @class VAXLittleEndianBinaryFileStream btkBinaryFileStream.h
@@ -813,197 +403,7 @@ namespace btk
* If the opening is not successfull, then the FailBit is set. You can check its state by using the method Fail().
*/
- /**
- * Extracts one signed 16-bit integer.
- */
- int16_t VAXLittleEndianBinaryFileStream::ReadI16()
- {
- char byteptr[2] = {0};
- this->mp_Stream->read(byteptr, 2);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[2] = {byteptr[1], byteptr[0]};
- return *reinterpret_cast<int16_t const*>(foo);
-#else
- return *reinterpret_cast<int16_t const*>(byteptr);
-#endif
- };
-
- /**
- * Extracts one unsigned 16-bit integer.
- */
- uint16_t VAXLittleEndianBinaryFileStream::ReadU16()
- {
- char byteptr[2] = {0};
- this->mp_Stream->read(byteptr, 2);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[2] = {byteptr[1], byteptr[0]};
- return *reinterpret_cast<uint16_t const*>(foo);
-#else
- return *reinterpret_cast<uint16_t const*>(byteptr);
-#endif
- };
-
- /**
- * Extracts one signed 32-bit integer.
- */
- int32_t VAXLittleEndianBinaryFileStream::ReadI32()
- {
- char byteptr[4] = {0};
- this->mp_Stream->read(byteptr, 4);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
- return *reinterpret_cast<int32_t const*>(foo);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- return *reinterpret_cast<int32_t const*>(byteptr);
-#else
- char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
- return *reinterpret_cast<int32_t const*>(foo);
-#endif
- };
-
- /**
- * Extracts one unsigned 32-bit integer.
- */
- uint32_t VAXLittleEndianBinaryFileStream::ReadU32()
- {
- char byteptr[4] = {0};
- this->mp_Stream->read(byteptr, 4);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
- return *reinterpret_cast<uint32_t const*>(foo);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- return *reinterpret_cast<uint32_t const*>(byteptr);
-#else
- char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
- return *reinterpret_cast<uint32_t const*>(foo);
-#endif
- };
-
- /**
- * Extracts one float.
- */
- float VAXLittleEndianBinaryFileStream::ReadFloat()
- {
- char byteptr[4] = {0};
- this->mp_Stream->read(byteptr, 4);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[4] = {byteptr[1] - 1 * (byteptr[1] == 0 ? 0 : 1), byteptr[0], byteptr[3], byteptr[2]};
- return *reinterpret_cast<float const*>(foo);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- return *reinterpret_cast<float const*>(byteptr);
-#else
- char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1] - 1 * (byteptr[1] == 0 ? 0 : 1)};
- return *reinterpret_cast<float const*>(foo);
-#endif
- };
-
- /**
- * Extracts one double.
- */
- double VAXLittleEndianBinaryFileStream::ReadDouble()
- {
- char byteptr[8] = {0};
- this->mp_Stream->read(byteptr, 8);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[8] = {byteptr[1] - 1 * (byteptr[1] == 0 ? 0 : 1), byteptr[0], byteptr[3], byteptr[2], byteptr[5], byteptr[4], byteptr[7], byteptr[6]};
- return *reinterpret_cast<double const*>(foo);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- return *reinterpret_cast<double const*>(byteptr);
-#else
- char foo[8] = {byteptr[6], byteptr[7], byteptr[4], byteptr[5], byteptr[2], byteptr[3], byteptr[0], byteptr[1] - 1 * (byteptr[1] == 0 ? 0 : 1)};
- return *reinterpret_cast<double const*>(foo);
-#endif
- };
-
- /**
- * Writes the signed 16-bit integer @a i16 in the stream an return its size.
- */
- size_t VAXLittleEndianBinaryFileStream::Write(int16_t i16)
- {
- char byteptr[2] = {0};
- memcpy(&byteptr, &i16, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[2] = {byteptr[1], byteptr[0]};
- this->mp_Stream->write(foo, 2);
-#else
- this->mp_Stream->write(byteptr, 2);
-#endif
- return 2;
- };
-
- /**
- * Writes the unsigned 16-bit integer @a u16 in the stream an return its size.
- */
- size_t VAXLittleEndianBinaryFileStream::Write(uint16_t u16)
- {
- char byteptr[2] = {0};
- memcpy(&byteptr, &u16, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[2] = {byteptr[1], byteptr[0]};
- this->mp_Stream->write(foo, 2);
-#else
- this->mp_Stream->write(byteptr, 2);
-#endif
- return 2;
- };
-
- /**
- * Write the 32-bit signed integer @a i32 and return its size.
- */
- size_t VAXLittleEndianBinaryFileStream::Write(int32_t i32)
- {
- char byteptr[4] = {0};
- memcpy(&byteptr, &i32, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
- this->mp_Stream->write(foo, 4);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- this->mp_Stream->write(byteptr, 4);
-#else
- char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
- this->mp_Stream->write(foo, 4);
-#endif
- return 4;
- };
-
- /**
- * Write the 32-bit unsigned integer @a u32 and return its size
- */
- size_t VAXLittleEndianBinaryFileStream::Write(uint32_t u32)
- {
- char byteptr[4] = {0};
- memcpy(&byteptr, &u32, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
- this->mp_Stream->write(foo, 4);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- this->mp_Stream->write(byteptr, 4);
-#else
- char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
- this->mp_Stream->write(foo, 4);
-#endif
- return 4;
- };
-
- /**
- * Writes the float @a f in the stream an return its size.
- */
- size_t VAXLittleEndianBinaryFileStream::Write(float f)
- {
- char byteptr[4] = {0};
- memcpy(&byteptr, &f, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[4] = {byteptr[1], byteptr[0] + 1 * (byteptr[0] == 0 ? 0 : 1), byteptr[3], byteptr[2]};
- this->mp_Stream->write(foo, 4);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- this->mp_Stream->write(byteptr, 4);
-#else
- char foo[4] = {byteptr[2], byteptr[3] + 1 * (byteptr[3] == 0 ? 0 : 1), byteptr[0], byteptr[1]};
- this->mp_Stream->write(foo, 4);
-#endif
- return 4;
- };
-
+ // ----------------------------------------------------------------------- //
/**
* @class IEEEBigEndianBinaryFileStream btkBinaryFileStream.h
@@ -1025,197 +425,7 @@ namespace btk
* If the opening is not successfull, then the FailBit is set. You can check its state by using the method Fail().
*/
- /**
- * Extracts one signed 16-bit integer.
- */
- int16_t IEEEBigEndianBinaryFileStream::ReadI16()
- {
- char byteptr[2] = {0};
- this->mp_Stream->read(byteptr, 2);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- return *reinterpret_cast<int16_t const*>(byteptr);
-#else
- char foo[2] = {byteptr[1], byteptr[0]};
- return *reinterpret_cast<int16_t const*>(foo);
-#endif
- };
-
- /**
- * Extracts one unsigned 16-bit integer.
- */
- uint16_t IEEEBigEndianBinaryFileStream::ReadU16()
- {
- char byteptr[2] = {0};
- this->mp_Stream->read(byteptr, 2);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- return *reinterpret_cast<uint16_t const*>(byteptr);
-#else
- char foo[2] = {byteptr[1], byteptr[0]};
- return *reinterpret_cast<uint16_t const*>(foo);
-#endif
- };
-
- /**
- * Extracts one signed 32-bit integer.
- */
- int32_t IEEEBigEndianBinaryFileStream::ReadI32()
- {
- char byteptr[4] = {0};
- this->mp_Stream->read(byteptr, 4);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- return *reinterpret_cast<int32_t const*>(byteptr);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
- return *reinterpret_cast<int32_t const*>(foo);
-#else
- char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- return *reinterpret_cast<int32_t const*>(foo);
-#endif
- };
-
- /**
- * Extracts one unsigned 32-bit integer.
- */
- uint32_t IEEEBigEndianBinaryFileStream::ReadU32()
- {
- char byteptr[4] = {0};
- this->mp_Stream->read(byteptr, 4);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- return *reinterpret_cast<uint32_t const*>(byteptr);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
- return *reinterpret_cast<uint32_t const*>(foo);
-#else
- char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- return *reinterpret_cast<uint32_t const*>(foo);
-#endif
- };
-
- /**
- * Extracts one float.
- */
- float IEEEBigEndianBinaryFileStream::ReadFloat()
- {
- char byteptr[4] = {0};
- this->mp_Stream->read(byteptr, 4);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- return *reinterpret_cast<float const*>(byteptr);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[4] = {byteptr[1], byteptr[0] + 1 * (byteptr[0] == 0 ? 0 : 1), byteptr[3], byteptr[2]};
- return *reinterpret_cast<float const*>(foo);
-#else
- char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- return *reinterpret_cast<float const*>(foo);
-#endif
- };
-
- /**
- * Extracts one double.
- */
- double IEEEBigEndianBinaryFileStream::ReadDouble()
- {
- char byteptr[8] = {0};
- this->mp_Stream->read(byteptr, 8);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- return *reinterpret_cast<double const*>(byteptr);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[8] = {byteptr[1], byteptr[0] + 1 * (byteptr[0] == 0 ? 0 : 1), byteptr[3], byteptr[2], byteptr[5], byteptr[4], byteptr[7], byteptr[6]};
- return *reinterpret_cast<double const*>(foo);
-#else
- char foo[8] = {byteptr[7], byteptr[6], byteptr[5], byteptr[4], byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- return *reinterpret_cast<double const*>(foo);
-#endif
- };
-
- /**
- * Writes the signed 16-bit integer @a i16 in the stream an return its size.
- */
- size_t IEEEBigEndianBinaryFileStream::Write(int16_t i16)
- {
- char byteptr[2] = {0};
- memcpy(&byteptr, &i16, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- this->mp_Stream->write(byteptr, 2);
-#else
- char foo[2] = {byteptr[1], byteptr[0]};
- this->mp_Stream->write(foo, 2);
-#endif
- return 2;
- };
-
- /**
- * Writes the unsigned 16-bit integer @a u16 in the stream an return its size.
- */
- size_t IEEEBigEndianBinaryFileStream::Write(uint16_t u16)
- {
- char byteptr[2] = {0};
- memcpy(&byteptr, &u16, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- this->mp_Stream->write(byteptr, 2);
-#else
- char foo[2] = {byteptr[1], byteptr[0]};
- this->mp_Stream->write(foo, 2);
-#endif
- return 2;
- };
-
- /**
- * Write the 32-bit signed integer @a i32 and return its size.
- */
- size_t IEEEBigEndianBinaryFileStream::Write(int32_t i32)
- {
- char byteptr[4] = {0};
- memcpy(&byteptr, &i32, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- this->mp_Stream->write(byteptr, 4);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
- this->mp_Stream->write(foo, 4);
-#else
- char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- this->mp_Stream->write(foo, 4);
-#endif
- return 4;
- };
-
- /**
- * Write the 32-bit unsigned integer @a u32 and return its size
- */
- size_t IEEEBigEndianBinaryFileStream::Write(uint32_t u32)
- {
- char byteptr[4] = {0};
- memcpy(&byteptr, &u32, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- this->mp_Stream->write(byteptr, 4);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[4] = {byteptr[1], byteptr[0], byteptr[3], byteptr[2]};
- this->mp_Stream->write(foo, 4);
-#else
- char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- this->mp_Stream->write(foo, 4);
-#endif
- return 4;
- };
-
- /**
- * Writes the float @a f in the stream an return its size.
- */
- size_t IEEEBigEndianBinaryFileStream::Write(float f)
- {
- char byteptr[4] = {0};
- memcpy(&byteptr, &f, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- this->mp_Stream->write(byteptr, 4);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[4] = {byteptr[1] - 1 * (byteptr[1] == 0 ? 0 : 1), byteptr[0], byteptr[3], byteptr[2]};
- this->mp_Stream->write(foo, 4);
-#else
- char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- this->mp_Stream->write(foo, 4);
-#endif
- return 4;
- };
-
+ // ----------------------------------------------------------------------- //
/**
* @class IEEELittleEndianBinaryFileStream btkBinaryFileStream.h
@@ -1237,200 +447,8 @@ namespace btk
* If the opening is not successfull, then the FailBit is set. You can check its state by using the method Fail().
*/
- /**
- * Extracts one signed 16-bit integer.
- */
- int16_t IEEELittleEndianBinaryFileStream::ReadI16()
- {
- char byteptr[2] = {0};
- this->mp_Stream->read(byteptr, 2);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[2] = {byteptr[1], byteptr[0]};
- return *reinterpret_cast<int16_t const*>(foo);
-#else
- return *reinterpret_cast<uint16_t const*>(byteptr);
-#endif
- };
-
- /**
- * Extracts one unsigned 16-bit integer.
- */
- uint16_t IEEELittleEndianBinaryFileStream::ReadU16()
- {
- char byteptr[2] = {0};
- this->mp_Stream->read(byteptr, 2);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[2] = {byteptr[1], byteptr[0]};
- return *reinterpret_cast<uint16_t const*>(foo);
-#else
- return *reinterpret_cast<uint16_t const*>(byteptr);
-#endif
- };
-
- /**
- * Extracts one signed 32-bit integer.
- */
- int32_t IEEELittleEndianBinaryFileStream::ReadI32()
- {
- char byteptr[4] = {0};
- this->mp_Stream->read(byteptr, 4);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- return *reinterpret_cast<int32_t const*>(foo);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
- return *reinterpret_cast<int32_t const*>(foo);
-#else
- return *reinterpret_cast<int32_t const*>(byteptr);
-#endif
- };
-
-
- /**
- * Extracts one unsigned 32-bit integer.
- */
- uint32_t IEEELittleEndianBinaryFileStream::ReadU32()
- {
- char byteptr[4] = {0};
- this->mp_Stream->read(byteptr, 4);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- return *reinterpret_cast<uint32_t const*>(foo);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
- return *reinterpret_cast<uint32_t const*>(foo);
-#else
- return *reinterpret_cast<uint32_t const*>(byteptr);
-#endif
- };
-
-
- /**
- * Extracts one float.
- */
- float IEEELittleEndianBinaryFileStream::ReadFloat()
- {
- char byteptr[4] = {0};
- this->mp_Stream->read(byteptr, 4);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- return *reinterpret_cast<float const*>(foo);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[4] = {byteptr[2], byteptr[3] + 1 * (byteptr[3] == 0 ? 0 : 1), byteptr[0], byteptr[1]};
- return *reinterpret_cast<float const*>(foo);
-#else
- return *reinterpret_cast<float const*>(byteptr);
-#endif
- };
-
- /**
- * Extracts one float.
- */
- double IEEELittleEndianBinaryFileStream::ReadDouble()
- {
- char byteptr[8] = {0};
- this->mp_Stream->read(byteptr, 8);
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[8] = {byteptr[7], byteptr[6], byteptr[5], byteptr[4], byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- return *reinterpret_cast<double const*>(foo);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[8] = {byteptr[6], byteptr[7] + 1 * (byteptr[7] == 0 ? 0 : 1), byteptr[4], byteptr[5], byteptr[2], byteptr[3], byteptr[1], byteptr[0]};
- return *reinterpret_cast<double const*>(foo);
-#else
- return *reinterpret_cast<double const*>(byteptr);
-#endif
- };
-
- /**
- * Writes the signed 16-bit integer @a i16 in the stream an return its size.
- */
- size_t IEEELittleEndianBinaryFileStream::Write(int16_t i16)
- {
- char byteptr[2] = {0};
- memcpy(&byteptr, &i16, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[2] = {byteptr[1], byteptr[0]};
- this->mp_Stream->write(foo, 2);
-#else
- this->mp_Stream->write(byteptr, 2);
-#endif
- return 2;
- };
-
- /**
- * Writes the unsigned 16-bit integer @a u16 in the stream an return its size.
- */
- size_t IEEELittleEndianBinaryFileStream::Write(uint16_t u16)
- {
- char byteptr[2] = {0};
- memcpy(&byteptr, &u16, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[2] = {byteptr[1], byteptr[0]};
- this->mp_Stream->write(foo, 2);
-#else
- this->mp_Stream->write(byteptr, 2);
-#endif
- return 2;
-
- };
-
- /**
- * Write the 32-bit signed integer @a i32 and return its size.
- */
- size_t IEEELittleEndianBinaryFileStream::Write(int32_t i32)
- {
- char byteptr[4] = {0};
- memcpy(&byteptr, &i32, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- this->mp_Stream->write(foo, 4);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
- this->mp_Stream->write(foo, 4);
-#else
- this->mp_Stream->write(byteptr, 4);
-#endif
- return 4;
- };
-
- /**
- * Write the 32-bit unsigned integer @a u32 and return its size
- */
- size_t IEEELittleEndianBinaryFileStream::Write(uint32_t u32)
- {
- char byteptr[4] = {0};
- memcpy(&byteptr, &u32, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- this->mp_Stream->write(foo, 4);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1]};
- this->mp_Stream->write(foo, 4);
-#else
- this->mp_Stream->write(byteptr, 4);
-#endif
- return 4;
- };
-
- /**
- * Writes the float @a f in the stream an return its size.
- */
- size_t IEEELittleEndianBinaryFileStream::Write(float f)
- {
- char byteptr[4] = {0};
- memcpy(&byteptr, &f, sizeof(byteptr));
-#if PROCESSOR_TYPE == 3 /* IEEE_BigEndian */
- char foo[4] = {byteptr[3], byteptr[2], byteptr[1], byteptr[0]};
- this->mp_Stream->write(foo, 4);
-#elif PROCESSOR_TYPE == 2 /* VAX_LittleEndian */
- char foo[4] = {byteptr[2], byteptr[3], byteptr[0], byteptr[1] - 1 * (byteptr[1] == 0 ? 0 : 1)};
- this->mp_Stream->write(foo, 4);
-#else
- this->mp_Stream->write(byteptr, 4);
-#endif
- return 4;
- };
+ // ----------------------------------------------------------------------- //
/**
* @class NativeBinaryFileStream btkBinaryFileStream.h
@@ -1441,7 +459,7 @@ namespace btk
* - the IEEE Little Endian file stream
* - the IEEE Big Endian file stream
*
- * @sa BinaryFileStream, VAXLittleEndianBinaryFileStream, IEEELittleEndianBinaryFileStream, IEEEBigEndianBinaryFileStream
+ * @sa BinaryFileStream, ByteOrderBinaryFileStream, IEEELittleEndianBinaryFileStream, IEEEBigEndianBinaryFileStream
*/
/**
diff --git a/Code/IO/btkBinaryFileStream.h b/Code/IO/btkBinaryFileStream.h
index 9454b600..ce82e5be 100644
--- a/Code/IO/btkBinaryFileStream.h
+++ b/Code/IO/btkBinaryFileStream.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -38,30 +38,8 @@
#include "btkConfigure.h"
-// Check if the processor is supported
-#if defined _MSC_VER
- #if defined _M_IX86 || defined _M_X64
- #define PROCESSOR_TYPE 1 /* IEEE_LittleEndian */
- #elif defined _M_ALPHA
- #define PROCESSOR_TYPE 2 /* VAX_LittleEndian */
- #elif defined _M_MRX000 || defined _M_PPC
- #define PROCESSOR_TYPE 3 /* IEEE_BigEndian */
- #else
- #error Processor not supported
- #endif
-#elif defined __GNUC__
- #if defined __i386__ || defined __x86_64__
- #define PROCESSOR_TYPE 1 /* IEEE_LittleEndian */
- #elif defined __vax__
- #define PROCESSOR_TYPE 2 /* VAX_LittleEndian */
- #elif defined __mips__ || defined __ppc__
- #define PROCESSOR_TYPE 3 /* IEEE_BigEndian */
- #else
- #error Processor not supported
- #endif
-#else
- #error Development platform not supported
-#endif
+#include "btkBinaryStream.h"
+#include "btkBinaryByteOrderFormat.h"
// Check if we can use the memory mapped file stream system
#if defined HAVE_SYS_MMAP || defined _MSC_VER
@@ -83,13 +61,13 @@
#include <stdint.h>
#endif
-// btkChooseNativeBinaryFileStream macro
+// _btk_choose_native_binary_file_stream macro
#if PROCESSOR_TYPE == 1
- #define btkChooseNativeBinaryFileStream IEEELittleEndianBinaryFileStream
+ #define _btk_choose_native_binary_file_stream IEEELittleEndianBinaryFileStream
#elif PROCESSOR_TYPE == 2
- #define btkChooseNativeBinaryFileStream VAXLittleEndianBinaryFileStream
+ #define _btk_choose_native_binary_file_stream VAXLittleEndianBinaryFileStream
#elif PROCESSOR_TYPE == 3
- #define btkChooseNativeBinaryFileStream IEEEBigEndianBinaryFileStream
+ #define _btk_choose_native_binary_file_stream IEEEBigEndianBinaryFileStream
#else
#error Unknown processor type
#endif
@@ -98,28 +76,16 @@ namespace btk
{
typedef RawFileStream::failure BinaryFileStreamFailure;
- class BinaryFileStream
+ class BinaryFileStream : public BinaryStream<BinaryFileStream>
{
public:
- typedef std::ios_base::iostate IOState;
static const IOState EndFileBit = std::ios_base::eofbit;
- static const IOState FailBit = std::ios_base::failbit;
- static const IOState BadBit = std::ios_base::badbit;
- static const IOState GoodBit = std::ios_base::goodbit;
typedef std::ios_base::openmode OpenMode;
static const OpenMode In = std::ios_base::in;
static const OpenMode Out = std::ios_base::out;
static const OpenMode Truncate = std::ios_base::trunc;
- typedef std::ios_base::seekdir SeekDir;
- static const SeekDir Begin = std::ios_base::beg;
- static const SeekDir Current = std::ios_base::cur;
- static const SeekDir End = std::ios_base::end;
-
- typedef std::streampos StreamPosition;
- typedef std::streamoff StreamOffset;
-
virtual ~BinaryFileStream()
{
if (this->mp_Stream->is_open())
@@ -142,71 +108,56 @@ namespace btk
BTK_IO_EXPORT void SwapStream(BinaryFileStream* toSwap);
BTK_IO_EXPORT char ReadChar();
- BTK_IO_EXPORT void ReadChar(size_t nb, char* values);
- void ReadChar(std::vector<char>& values) {if (values.empty()) return; this->ReadChar(values.size(), &(values[0]));};
- std::vector<char> ReadChar(size_t nb) {std::vector<char> values(nb); this->ReadChar(values); return values;};
+ using BinaryStream::ReadChar;
+
BTK_IO_EXPORT int8_t ReadI8();
- BTK_IO_EXPORT void ReadI8(size_t nb, int8_t* values);
- void ReadI8(std::vector<int8_t>& values) {if (values.empty()) return; this->ReadI8(values.size(), &(values[0]));};
- std::vector<int8_t> ReadI8(size_t nb) {std::vector<int8_t> values(nb); this->ReadI8(values); return values;};
+ using BinaryStream::ReadI8;
+
BTK_IO_EXPORT uint8_t ReadU8();
- BTK_IO_EXPORT void ReadU8(size_t nb, uint8_t* values);
- void ReadU8(std::vector<uint8_t>& values) {if (values.empty()) return; this->ReadU8(values.size(), &(values[0]));};
- std::vector<uint8_t> ReadU8(size_t nb) {std::vector<uint8_t> values(nb); this->ReadU8(values); return values;};
+ using BinaryStream::ReadU8;
+
virtual int16_t ReadI16() = 0;
- BTK_IO_EXPORT void ReadI16(size_t nb, int16_t* values);
- void ReadI16(std::vector<int16_t>& values) {if (values.empty()) return; this->ReadI16(values.size(), &(values[0]));};
- std::vector<int16_t> ReadI16(size_t nb) {std::vector<int16_t> values(nb); this->ReadI16(values); return values;};
+ using BinaryStream::ReadI16;
+
virtual uint16_t ReadU16() = 0;
- BTK_IO_EXPORT void ReadU16(size_t nb, uint16_t* values);
- void ReadU16(std::vector<uint16_t>& values) {if (values.empty()) return; this->ReadU16(values.size(), &(values[0]));};
- std::vector<uint16_t> ReadU16(size_t nb) {std::vector<uint16_t> values(nb); this->ReadU16(values); return values;};
+ using BinaryStream::ReadU16;
+
virtual int32_t ReadI32() = 0;
- BTK_IO_EXPORT void ReadI32(size_t nb, int32_t* values);
- void ReadI32(std::vector<int32_t>& values) {if (values.empty()) return; this->ReadI32(values.size(), &(values[0]));};
- std::vector<int32_t> ReadI32(size_t nb) {std::vector<int32_t> values(nb); this->ReadI32(values); return values;};
+ using BinaryStream::ReadI32;
+
virtual uint32_t ReadU32() = 0;
- BTK_IO_EXPORT void ReadU32(size_t nb, uint32_t* values);
- void ReadU32(std::vector<uint32_t>& values) {if (values.empty()) return; this->ReadU32(values.size(), &(values[0]));};
- std::vector<uint32_t> ReadU32(size_t nb) {std::vector<uint32_t> values(nb); this->ReadU32(values); return values;};
+ using BinaryStream::ReadU32;
+
+ virtual int64_t ReadI64() = 0;
+ using BinaryStream::ReadI64;
+
+ virtual uint64_t ReadU64() = 0;
+ using BinaryStream::ReadU64;
+
virtual float ReadFloat() = 0;
- BTK_IO_EXPORT void ReadFloat(size_t nb, float* values);
- void ReadFloat(std::vector<float>& values) {if (values.empty()) return; this->ReadFloat(values.size(), &(values[0]));};
- std::vector<float> ReadFloat(size_t nb) {std::vector<float> values(nb); this->ReadFloat(values); return values;};
+ using BinaryStream::ReadFloat;
+
virtual double ReadDouble() = 0;
- BTK_IO_EXPORT void ReadDouble(size_t nb, double* values);
- void ReadDouble(std::vector<double>& values) {if (values.empty()) return; this->ReadDouble(values.size(), &(values[0]));};
- std::vector<double> ReadDouble(size_t nb) {std::vector<double> values(nb); this->ReadDouble(values); return values;};
+ using BinaryStream::ReadDouble;
+
BTK_IO_EXPORT std::string ReadString(size_t nbChar);
- BTK_IO_EXPORT void ReadString(size_t nb, size_t nbChar, std::string* values);
- void ReadString(size_t nbChar, std::vector<std::string>& values) {if (values.empty()) return; this->ReadString(values.size(), nbChar, &(values[0]));};
- std::vector<std::string> ReadString(size_t nb, size_t nbChar) {std::vector<std::string> values(nb); this->ReadString(nbChar, values); return values;};
+ using BinaryStream::ReadString;
void SeekRead(StreamOffset offset, SeekDir dir) {this->mp_Stream->seekg(offset, dir);};
StreamPosition TellRead() const {return this->mp_Stream->tellg();};
BTK_IO_EXPORT size_t Fill(size_t nb);
void SeekWrite(StreamOffset offset, SeekDir dir) {this->mp_Stream->seekp(offset, dir);};
- // Note: MSVC doesn't like the following commented methods.
- // char and int8_t are the same for it...
- //virtual size_t Write(char c);
- //virtual size_t Write(const std::vector<char>& rVectorChar);
- BTK_IO_EXPORT size_t Write(int8_t i8);
- BTK_IO_EXPORT size_t Write(const std::vector<int8_t>& rVectorI8);
- BTK_IO_EXPORT size_t Write(uint8_t u8);
- BTK_IO_EXPORT size_t Write(const std::vector<uint8_t>& rVectorU8);
- virtual size_t Write(int16_t i16) = 0;
- BTK_IO_EXPORT size_t Write(const std::vector<int16_t>& rVectorI16);
- virtual size_t Write(uint16_t u16) = 0;
- BTK_IO_EXPORT size_t Write(const std::vector<uint16_t>& rVectorU16);
- virtual size_t Write(int32_t i32) = 0;
- BTK_IO_EXPORT size_t Write(const std::vector<int32_t>& rVectorI32);
- virtual size_t Write(uint32_t u32) = 0;
- BTK_IO_EXPORT size_t Write(const std::vector<uint32_t>& rVectorU32);
- virtual size_t Write(float f) = 0;
- BTK_IO_EXPORT size_t Write(const std::vector<float>& rVectorFloat);
- BTK_IO_EXPORT size_t Write(const std::string& rString);
- BTK_IO_EXPORT size_t Write(const std::vector<std::string>& rVectorString);
+
+ BTK_IO_EXPORT size_t Write(int8_t value);
+ BTK_IO_EXPORT size_t Write(uint8_t value);
+ virtual size_t Write(int16_t value) = 0;
+ virtual size_t Write(uint16_t value) = 0;
+ virtual size_t Write(int32_t value) = 0;
+ virtual size_t Write(uint32_t value) = 0;
+ virtual size_t Write(float value) = 0;
+ BTK_IO_EXPORT size_t Write(const std::string& value);
+ using BinaryStream::Write;
protected:
BinaryFileStream() {this->mp_Stream = new RawFileStream();};
@@ -219,12 +170,13 @@ namespace btk
BinaryFileStream& operator=(const BinaryFileStream& ); // Not implemented.
};
- class VAXLittleEndianBinaryFileStream : public BinaryFileStream
- {
+ template <class Format>
+ class ByteOrderBinaryFileStream : public BinaryFileStream
+ {
public:
- VAXLittleEndianBinaryFileStream() : BinaryFileStream() {};
- VAXLittleEndianBinaryFileStream(const std::string& filename, OpenMode mode) : BinaryFileStream(filename, mode) {};
- // ~VAXLittleEndianBinaryFileStream(); // Implicit.
+ ByteOrderBinaryFileStream() : BinaryFileStream() {};
+ ByteOrderBinaryFileStream(const std::string& filename, OpenMode mode) : BinaryFileStream(filename, mode) {};
+ // ~ByteOrderBinaryFileStream(); // Implicit.
BTK_IO_EXPORT virtual int16_t ReadI16();
using BinaryFileStream::ReadI16;
BTK_IO_EXPORT virtual uint16_t ReadU16();
@@ -233,87 +185,64 @@ namespace btk
using BinaryFileStream::ReadI32;
BTK_IO_EXPORT virtual uint32_t ReadU32();
using BinaryFileStream::ReadU32;
+ BTK_IO_EXPORT virtual int64_t ReadI64();
+ using BinaryFileStream::ReadI64;
+ BTK_IO_EXPORT virtual uint64_t ReadU64();
+ using BinaryFileStream::ReadU64;
BTK_IO_EXPORT virtual float ReadFloat();
using BinaryFileStream::ReadFloat;
BTK_IO_EXPORT virtual double ReadDouble();
using BinaryFileStream::ReadDouble;
- BTK_IO_EXPORT virtual size_t Write(int16_t i16);
- BTK_IO_EXPORT virtual size_t Write(uint16_t u16);
- BTK_IO_EXPORT virtual size_t Write(int32_t i32);
- BTK_IO_EXPORT virtual size_t Write(uint32_t u32);
- BTK_IO_EXPORT virtual size_t Write(float f);
+ BTK_IO_EXPORT virtual size_t Write(int16_t value);
+ BTK_IO_EXPORT virtual size_t Write(uint16_t value);
+ BTK_IO_EXPORT virtual size_t Write(int32_t value);
+ BTK_IO_EXPORT virtual size_t Write(uint32_t value);
+ BTK_IO_EXPORT virtual size_t Write(float value);
using BinaryFileStream::Write;
private:
- VAXLittleEndianBinaryFileStream(const VAXLittleEndianBinaryFileStream& ); // Not implemented.
- VAXLittleEndianBinaryFileStream& operator=(const VAXLittleEndianBinaryFileStream& ); // Not implemented.
+ ByteOrderBinaryFileStream(const ByteOrderBinaryFileStream& ); // Not implemented.
+ ByteOrderBinaryFileStream& operator=(const ByteOrderBinaryFileStream& ); // Not implemented.
};
- class IEEELittleEndianBinaryFileStream : public BinaryFileStream
- {
+ class VAXLittleEndianBinaryFileStream : public ByteOrderBinaryFileStream<VAXLittleEndianFormat>
+ {
public:
- IEEELittleEndianBinaryFileStream() : BinaryFileStream() {};
- IEEELittleEndianBinaryFileStream(const std::string& filename, OpenMode mode) : BinaryFileStream(filename, mode) {};
- // ~IEEELittleEndianBinaryFileStream(); // Implicit.
- BTK_IO_EXPORT virtual int16_t ReadI16();
- using BinaryFileStream::ReadI16;
- BTK_IO_EXPORT virtual uint16_t ReadU16();
- using BinaryFileStream::ReadU16;
- BTK_IO_EXPORT virtual int32_t ReadI32();
- using BinaryFileStream::ReadI32;
- BTK_IO_EXPORT virtual uint32_t ReadU32();
- using BinaryFileStream::ReadU32;
- BTK_IO_EXPORT virtual float ReadFloat();
- using BinaryFileStream::ReadFloat;
- BTK_IO_EXPORT virtual double ReadDouble();
- using BinaryFileStream::ReadDouble;
- BTK_IO_EXPORT virtual size_t Write(int16_t i16);
- BTK_IO_EXPORT virtual size_t Write(uint16_t u16);
- BTK_IO_EXPORT virtual size_t Write(int32_t i32);
- BTK_IO_EXPORT virtual size_t Write(uint32_t u32);
- BTK_IO_EXPORT virtual size_t Write(float f);
- using BinaryFileStream::Write;
+ VAXLittleEndianBinaryFileStream() : ByteOrderBinaryFileStream<VAXLittleEndianFormat>() {};
+ VAXLittleEndianBinaryFileStream(const std::string& filename, OpenMode mode) : ByteOrderBinaryFileStream<VAXLittleEndianFormat>(filename, mode) {};
+ // ~ByteOrderBinaryFileStream(); // Implicit.
+ private:
+ VAXLittleEndianBinaryFileStream(const VAXLittleEndianBinaryFileStream& ); // Not implemented.
+ VAXLittleEndianBinaryFileStream& operator=(const VAXLittleEndianBinaryFileStream& ); // Not implemented.
+ };
+ class IEEELittleEndianBinaryFileStream : public ByteOrderBinaryFileStream<IEEELittleEndianFormat>
+ {
+ public:
+ IEEELittleEndianBinaryFileStream() : ByteOrderBinaryFileStream<IEEELittleEndianFormat>() {};
+ IEEELittleEndianBinaryFileStream(const std::string& filename, OpenMode mode) : ByteOrderBinaryFileStream<IEEELittleEndianFormat>(filename, mode) {};
+ // ~ByteOrderBinaryFileStream(); // Implicit.
private:
IEEELittleEndianBinaryFileStream(const IEEELittleEndianBinaryFileStream& ); // Not implemented.
IEEELittleEndianBinaryFileStream& operator=(const IEEELittleEndianBinaryFileStream& ); // Not implemented.
};
- class IEEEBigEndianBinaryFileStream : public BinaryFileStream
- {
+ class IEEEBigEndianBinaryFileStream : public ByteOrderBinaryFileStream<IEEEBigEndianFormat>
+ {
public:
- IEEEBigEndianBinaryFileStream() : BinaryFileStream() {};
- IEEEBigEndianBinaryFileStream(const std::string& filename, OpenMode mode) : BinaryFileStream(filename, mode) {};
- // ~IEEEBigEndianBinaryFileStream(); // Implicit.
- BTK_IO_EXPORT virtual int16_t ReadI16();
- using BinaryFileStream::ReadI16;
- BTK_IO_EXPORT virtual uint16_t ReadU16();
- using BinaryFileStream::ReadU16;
- BTK_IO_EXPORT virtual int32_t ReadI32();
- using BinaryFileStream::ReadI32;
- BTK_IO_EXPORT virtual uint32_t ReadU32();
- using BinaryFileStream::ReadU32;
- BTK_IO_EXPORT virtual float ReadFloat();
- using BinaryFileStream::ReadFloat;
- BTK_IO_EXPORT virtual double ReadDouble();
- using BinaryFileStream::ReadDouble;
- BTK_IO_EXPORT virtual size_t Write(int16_t i16);
- BTK_IO_EXPORT virtual size_t Write(uint16_t u16);
- BTK_IO_EXPORT virtual size_t Write(int32_t i32);
- BTK_IO_EXPORT virtual size_t Write(uint32_t u32);
- BTK_IO_EXPORT virtual size_t Write(float f);
- using BinaryFileStream::Write;
-
+ IEEEBigEndianBinaryFileStream() : ByteOrderBinaryFileStream<IEEEBigEndianFormat>() {};
+ IEEEBigEndianBinaryFileStream(const std::string& filename, OpenMode mode) : ByteOrderBinaryFileStream<IEEEBigEndianFormat>(filename, mode) {};
+ // ~ByteOrderBinaryFileStream(); // Implicit.
private:
IEEEBigEndianBinaryFileStream(const IEEEBigEndianBinaryFileStream& ); // Not implemented.
IEEEBigEndianBinaryFileStream& operator=(const IEEEBigEndianBinaryFileStream& ); // Not implemented.
};
-
- class NativeBinaryFileStream : public btkChooseNativeBinaryFileStream
+
+ class NativeBinaryFileStream : public _btk_choose_native_binary_file_stream
{
public:
- NativeBinaryFileStream() : btkChooseNativeBinaryFileStream() {};
- NativeBinaryFileStream(const std::string& filename, OpenMode mode) : btkChooseNativeBinaryFileStream(filename, mode) {};
+ NativeBinaryFileStream() : _btk_choose_native_binary_file_stream() {};
+ NativeBinaryFileStream(const std::string& filename, OpenMode mode) : _btk_choose_native_binary_file_stream(filename, mode) {};
// ~NativeBinaryFileStream(); // Implicit.
private:
NativeBinaryFileStream(const NativeBinaryFileStream& ); // Not implemented.
@@ -321,4 +250,6 @@ namespace btk
};
};
+#include "btkBinaryFileStream.tpp"
+
#endif // __btkBinaryFileStream_h
diff --git a/Code/IO/btkBinaryFileStream.tpp b/Code/IO/btkBinaryFileStream.tpp
new file mode 100644
index 00000000..1daa5722
--- /dev/null
+++ b/Code/IO/btkBinaryFileStream.tpp
@@ -0,0 +1,182 @@
+/*
+ * The Biomechanical ToolKit
+ * Copyright (c) 2009-2014, Arnaud Barré
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name(s) of the copyright holders nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "btkBinaryFileStream.h"
+
+namespace btk
+{
+ /**
+ * @class ByteOrderBinaryFileStream btkBinaryFile.h
+ * @brief Template class to read and write binary file encoded from any support byte order format.
+ * @tparam Format Format of the byte order to use to read/write data.
+ *
+ * @sa BinaryFileStream, IEEELittleEndianBinaryFileStream, IEEEBigEndianBinaryFileStream, NativeBinaryFileStream
+ */
+
+ /**
+ * @fn template <class Format> ByteOrderBinaryFileStream<Format>::ByteOrderBinaryFileStream()
+ * Creates a new default binary file stream.
+ */
+
+ /**
+ * @fn ByteOrderBinaryFileStream<Format>::ByteOrderBinaryFileStream(const std::string& filename, OpenMode mode)
+ * Creates a new binary file stream and associates the file with the filename @a filename using the option @a mode.
+ *
+ * If the opening is not successfull, then the FailBit is set. You can check its state by using the method Fail().
+ */
+
+ /**
+ * Extracts one signed 16-bit integer.
+ */
+ template <class Format>
+ int16_t ByteOrderBinaryFileStream<Format>::ReadI16()
+ {
+ return Format::ReadI16(this->mp_Stream);
+ };
+
+ /**
+ * Extracts one unsigned 16-bit integer.
+ */
+ template <class Format>
+ uint16_t ByteOrderBinaryFileStream<Format>::ReadU16()
+ {
+ return Format::ReadU16(this->mp_Stream);
+ };
+
+ /**
+ * Extracts one signed 32-bit integer.
+ */
+ template <class Format>
+ int32_t ByteOrderBinaryFileStream<Format>::ReadI32()
+ {
+ return Format::ReadI32(this->mp_Stream);
+ };
+
+ /**
+ * Extracts one unsigned 32-bit integer.
+ */
+ template <class Format>
+ uint32_t ByteOrderBinaryFileStream<Format>::ReadU32()
+ {
+ return Format::ReadU32(this->mp_Stream);
+ };
+
+ /**
+ * Extracts one signed 64-bit integer.
+ */
+ template <class Format>
+ int64_t ByteOrderBinaryFileStream<Format>::ReadI64()
+ {
+ return Format::ReadI64(this->mp_Stream);
+ };
+
+ /**
+ * Extracts one unsigned 64-bit integer.
+ */
+ template <class Format>
+ uint64_t ByteOrderBinaryFileStream<Format>::ReadU64()
+ {
+ return Format::ReadU64(this->mp_Stream);
+ };
+
+ /**
+ * Extracts one float.
+ */
+ template <class Format>
+ float ByteOrderBinaryFileStream<Format>::ReadFloat()
+ {
+ return Format::ReadFloat(this->mp_Stream);
+ };
+
+ /**
+ * Extracts one double.
+ */
+ template <class Format>
+ double ByteOrderBinaryFileStream<Format>::ReadDouble()
+ {
+ return Format::ReadDouble(this->mp_Stream);
+ };
+
+ /**
+ * Writes the signed 16-bit integer @a i16 in the stream an return its size.
+ */
+ template <class Format>
+ size_t ByteOrderBinaryFileStream<Format>::Write(int16_t value)
+ {
+ Format::Write(value, this->mp_Stream);
+ return 2;
+ };
+
+ /**
+ * Writes the unsigned 16-bit integer @a u16 in the stream an return its size.
+ */
+ template <class Format>
+ size_t ByteOrderBinaryFileStream<Format>::Write(uint16_t value)
+ {
+ Format::Write(value, this->mp_Stream);
+ return 2;
+ };
+
+ /**
+ * Write the 32-bit signed integer @a i32 and return its size.
+ */
+ template <class Format>
+ size_t ByteOrderBinaryFileStream<Format>::Write(int32_t value)
+ {
+ Format::Write(value, this->mp_Stream);
+ return 4;
+ };
+
+ /**
+ * Write the 32-bit unsigned integer @a u32 and return its size
+ */
+ template <class Format>
+ size_t ByteOrderBinaryFileStream<Format>::Write(uint32_t value)
+ {
+ Format::Write(value, this->mp_Stream);
+ return 4;
+ };
+
+ /**
+ * Writes the float @a f in the stream an return its size.
+ */
+ template <class Format>
+ size_t ByteOrderBinaryFileStream<Format>::Write(float value)
+ {
+ Format::Write(value, this->mp_Stream);
+ return 4;
+ };
+
+};
\ No newline at end of file
diff --git a/Code/IO/btkBinaryFileStream_mmfstream.cpp b/Code/IO/btkBinaryFileStream_mmfstream.cpp
index 961a7623..6b3191a6 100644
--- a/Code/IO/btkBinaryFileStream_mmfstream.cpp
+++ b/Code/IO/btkBinaryFileStream_mmfstream.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -235,12 +235,7 @@ namespace btk
return this;
};
-
- /**
- * @fn bool mmfilebuf::is_eob() const
- * Check if the position of the pointer on the data is at the end of the buffer.
- */
-
+
/**
* @fn bool mmfilebuf::writemode() const
* Check if this file buffer is in write mode or not.
@@ -319,11 +314,11 @@ namespace btk
*/
std::streamsize mmfilebuf::sgetn(char* s, std::streamsize n)
{
- std::streamoff n_ = (((this->m_Position + n) == 0) || ((this->m_Position + n) > this->m_BufferSize)) ? ((this->m_BufferSize - this->m_Position - 1) > 0 ? this->m_BufferSize - this->m_Position - 1 : 0) : n;
- for (std::streamoff i = 0 ; i < n_ ; ++i)
+ n = (((this->m_Position + n) == 0) || ((this->m_Position + n) > this->m_BufferSize)) ? ((this->m_BufferSize - this->m_Position - 1) > 0 ? this->m_BufferSize - this->m_Position - 1 : 0) : n;
+ for (std::streamoff i = 0 ; i < n ; ++i)
s[i] = this->mp_Buffer[this->m_Position + i];
- this->m_Position += n_;
- return n_;
+ this->m_Position += n;
+ return n;
};
/**
@@ -332,7 +327,7 @@ namespace btk
*/
std::streamsize mmfilebuf::sputn(const char* s, std::streamsize n)
{
- while ((this->m_Position + n) >= this->m_BufferSize)
+ while ((this->m_Position + n) > this->m_BufferSize)
{
if (!this->resizemap())
return 0;
@@ -515,8 +510,6 @@ namespace btk
{
if (this->m_Filebuf.sgetn(s,n) != n)
this->setstate(std::ios_base::eofbit | std::ios_base::failbit);
- else if (this->m_Filebuf.is_eob())
- this->setstate(std::ios_base::eofbit);
return *this;
};
diff --git a/Code/IO/btkBinaryFileStream_mmfstream.h b/Code/IO/btkBinaryFileStream_mmfstream.h
index 34a37645..1396eaba 100644
--- a/Code/IO/btkBinaryFileStream_mmfstream.h
+++ b/Code/IO/btkBinaryFileStream_mmfstream.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -62,8 +62,7 @@ namespace btk
BTK_IO_EXPORT mmfilebuf* open(const char* s, std::ios_base::openmode mode);
bool is_open() const {return !(this->m_File == BTK_MMFILEBUF_NO_FILE);};
BTK_IO_EXPORT mmfilebuf* close();
-
- bool is_eob() const {return (this->m_Position == this->m_BufferSize + 1);}; // End of buffer
+
bool writemode() const {return this->m_Writing;};
std::streamsize size() const {return this->m_BufferSize;};
diff --git a/Code/IO/btkBinaryStream.h b/Code/IO/btkBinaryStream.h
new file mode 100644
index 00000000..15bd2ee2
--- /dev/null
+++ b/Code/IO/btkBinaryStream.h
@@ -0,0 +1,155 @@
+/*
+ * The Biomechanical ToolKit
+ * Copyright (c) 2009-2014, Arnaud Barré
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name(s) of the copyright holders nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __btkBinaryStream_h
+#define __btkBinaryStream_h
+
+#include <string>
+#include <vector>
+
+// MSVC doesn't have the header stdint.h
+#ifdef _MSC_VER
+ #include "Utilities/stdint.h"
+#else
+ #include <stdint.h>
+#endif
+
+namespace btk
+{
+ template <class Derived>
+ class BinaryStream
+ {
+ public:
+ typedef std::ios_base::iostate IOState;
+ static const IOState FailBit = std::ios_base::failbit;
+ static const IOState BadBit = std::ios_base::badbit;
+ static const IOState GoodBit = std::ios_base::goodbit;
+
+ typedef std::ios_base::seekdir SeekDir;
+ static const SeekDir Begin = std::ios_base::beg;
+ static const SeekDir Current = std::ios_base::cur;
+ static const SeekDir End = std::ios_base::end;
+
+ typedef std::streampos StreamPosition;
+ typedef std::streamoff StreamOffset;
+
+ ~BinaryStream() {};
+
+ // Read methods
+ // ------------
+
+ void ReadChar(size_t nb, char* values);
+ void ReadChar(std::vector<char>& values);
+ std::vector<char> ReadChar(size_t nb);
+
+ void ReadI8(size_t nb, int8_t* values);
+ void ReadI8(std::vector<int8_t>& values);
+ std::vector<int8_t> ReadI8(size_t nb);
+
+ void ReadU8(size_t nb, uint8_t* values);
+ void ReadU8(std::vector<uint8_t>& values);
+ std::vector<uint8_t> ReadU8(size_t nb);
+
+ void ReadI16(size_t nb, int16_t* values);
+ void ReadI16(std::vector<int16_t>& values);
+ std::vector<int16_t> ReadI16(size_t nb);
+
+ void ReadU16(size_t nb, uint16_t* values);
+ void ReadU16(std::vector<uint16_t>& values);
+ std::vector<uint16_t> ReadU16(size_t nb);
+
+ void ReadI32(size_t nb, int32_t* values);
+ void ReadI32(std::vector<int32_t>& values);
+ std::vector<int32_t> ReadI32(size_t nb);
+
+ void ReadU32(size_t nb, uint32_t* values);
+ void ReadU32(std::vector<uint32_t>& values);
+ std::vector<uint32_t> ReadU32(size_t nb);
+
+ void ReadI64(size_t nb, int64_t* values);
+ void ReadI64(std::vector<int64_t>& values);
+ std::vector<int64_t> ReadI64(size_t nb);
+
+ void ReadU64(size_t nb, uint64_t* values);
+ void ReadU64(std::vector<uint64_t>& values);
+ std::vector<uint64_t> ReadU64(size_t nb);
+
+ void ReadFloat(size_t nb, float* values);
+ void ReadFloat(std::vector<float>& values);
+ std::vector<float> ReadFloat(size_t nb);
+
+ void ReadDouble(size_t nb, double* values);
+ void ReadDouble(std::vector<double>& values);
+ std::vector<double> ReadDouble(size_t nb);
+
+ void ReadString(size_t nb, size_t nbChar, std::string* values);
+ void ReadString(size_t nbChar, std::vector<std::string>& values);
+ std::vector<std::string> ReadString(size_t nb, size_t nbChar);
+
+ // Write methods
+ // ------------
+
+ // Note: MSVC doesn't like the following commented methods.
+ // char and int8_t are the same for it...
+ //virtual size_t Write(const std::vector<char>& values);
+
+ size_t Write(const std::vector<int8_t>& values);
+
+ size_t Write(const std::vector<uint8_t>& values);
+
+ size_t Write(const std::vector<int16_t>& values);
+
+ size_t Write(const std::vector<uint16_t>& values);
+
+ size_t Write(const std::vector<int32_t>& values);
+
+ size_t Write(const std::vector<uint32_t>& values);
+
+ size_t Write(const std::vector<float>& values);
+
+ size_t Write(const std::vector<std::string>& values);
+
+ protected:
+ BinaryStream() {};
+
+ private:
+ BinaryStream(const BinaryStream& ); // Not implemented.
+ BinaryStream& operator=(const BinaryStream& ); // Not implemented.
+ };
+};
+
+#include "btkBinaryStream.tpp"
+
+#endif // __btkBinaryStream_h
diff --git a/Code/IO/btkBinaryStream.tpp b/Code/IO/btkBinaryStream.tpp
new file mode 100644
index 00000000..63d7593b
--- /dev/null
+++ b/Code/IO/btkBinaryStream.tpp
@@ -0,0 +1,698 @@
+/*
+ * The Biomechanical ToolKit
+ * Copyright (c) 2009-2014, Arnaud Barré
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name(s) of the copyright holders nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "btkBinaryStream.h"
+
+namespace btk
+{
+
+ /**
+ * @class BinaryStream btkBinaryStream.h
+ * @brief Template class to read and write binary data.
+ * @tparam Derived Children class.
+ *
+ * This class uses the Curiously Recurring Template Pattern (CRTP) to propose the basis to read/write data on any device.
+ * The @a Derived class must have the following method (pure virtual or not):
+ * - int16_t ReadI16();
+ * - uint16_t ReadIU6();
+ * - int32_t ReadI32();
+ * - uint32_t ReadU32();
+ * - int64_t ReadI64();
+ * - uint64_t ReadU64();
+ * - float ReadFloat();
+ * - double ReadDouble();
+ * - size_t Write(int16_t );
+ * - size_t Write(uint16_t );
+ * - size_t Write(int32_t );
+ * - size_t Write(uint32_t );
+ * - size_t Write(int64_t );
+ * - size_t Write(uint64_t );
+ * - size_t Write(float );
+ * - size_t Write(double );
+ *
+ * @sa BinaryFileStream, BinaryChunkBufferStream
+ */
+
+ /**
+ * @typedef BinaryStream::IOState
+ * Bitmask type to represent stream error state flags.
+ */
+ /**
+ * @typedef BinaryStream::SeekDir
+ * Flags representing the seeking direction of a stream seeking operation.
+ */
+ /**
+ * @typedef BinaryStream::StreamPosition
+ * Type to represent positions in a stream.
+ */
+ /**
+ * @typedef BinaryStream::StreamOffset
+ * Type to represent position offsets in a stream.
+ */
+ /**
+ * @var BinaryStream::FailBit
+ * The last input operation failed because of an error related to the internal logic of the operation itself.
+ */
+ /**
+ * @var BinaryStream::BadBit
+ * Error due to the failure of an input/output operation on the stream buffer.
+ */
+ /**
+ * @var BinaryStream::GoodBit
+ * No error. Represents the absence of all the above (the value zero).
+ */
+ /**
+ * @var BinaryStream::Begin
+ * Beginning of the stream buffer.
+ */
+ /**
+ * @var BinaryStream::Current
+ * Current position in the stream buffer.
+ */
+ /**
+ * @var BinaryStream::End
+ * End of the stream buffer.
+ */
+
+ /**
+ * Extracts @a nb characters and return them as a vector.
+ */
+ template <class Derived>
+ std::vector<char> BinaryStream<Derived>::ReadChar(size_t nb)
+ {
+ std::vector<char> values(nb);
+ this->ReadChar(values);
+ return values;
+ };
+
+ /**
+ * Extracts exactly the number of elements set in the vector @a values
+ *
+ * @note In case you want to assign only a part of the vector, you can use the method using an array.
+ * For example;
+ * @code
+ * std::vector<char> val(45,0);
+ * bfs.ReadChar(10, &(val[0])); // assign value #0-9
+ * // ...
+ * bfs.ReadChar(5, &(val[40])); // assign value #41-45
+ * @endcode
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadChar(std::vector<char>& values)
+ {
+ if (values.empty())
+ return;
+ this->ReadChar(values.size(), &(values[0]));
+ };
+
+ /**
+ * Extracts @a nb chars and set them in the array @a values.
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadChar(size_t nb, char* values)
+ {
+ for (size_t i = 0 ; i < nb ; ++i)
+ values[i] = static_cast<Derived*>(this)->ReadChar();
+ };
+
+ /**
+ * Extracts @a nb signed 8-bit integers and return them as a vector.
+ */
+ template <class Derived>
+ std::vector<int8_t> BinaryStream<Derived>::ReadI8(size_t nb)
+ {
+ std::vector<int8_t> values(nb);
+ this->ReadI8(values);
+ return values;
+ };
+
+ /**
+ * Extracts exactly the number of elements set in the vector @a values
+ *
+ * @note In case you want to assign only a part of the vector, you can use the method using an array.
+ * For example;
+ * @code
+ * std::vector<int8_t> val(45,0);
+ * bfs.ReadI8(10, &(val[0])); // assign value #0-9
+ * // ...
+ * bfs.ReadI8(5, &(val[40])); // assign value #41-45
+ * @endcode
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadI8(std::vector<int8_t>& values)
+ {
+ if (values.empty())
+ return;
+ this->ReadI8(values.size(), &(values[0]));
+ };
+
+ /**
+ * Extracts @a nb signed 8-bit integers and set them in the array @a values.
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadI8(size_t nb, int8_t* values)
+ {
+ for (size_t i = 0 ; i < nb ; ++i)
+ values[i] = static_cast<Derived*>(this)->ReadI8();
+ };
+
+ /**
+ * Extracts @a nb unsigned 8-bit integers and return them as a vector.
+ */
+ template <class Derived>
+ std::vector<uint8_t> BinaryStream<Derived>::ReadU8(size_t nb)
+ {
+ std::vector<uint8_t> values(nb);
+ this->ReadU8(values);
+ return values;
+ };
+
+ /**
+ * Extracts exactly the number of elements set in the vector @a values
+ *
+ * @note In case you want to assign only a part of the vector, you can use the method using an array.
+ * For example;
+ * @code
+ * std::vector<uint8_t> val(45,0);
+ * bfs.ReadU8(10, &(val[0])); // assign value #0-9
+ * // ...
+ * bfs.ReadU8(5, &(val[40])); // assign value #41-45
+ * @endcode
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadU8(std::vector<uint8_t>& values)
+ {
+ if (values.empty())
+ return;
+ this->ReadU8(values.size(), &(values[0]));
+ };
+
+ /**
+ * Extracts @a nb unsigned 8-bit integers and set them in the array @a values.
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadU8(size_t nb, uint8_t* values)
+ {
+ for (size_t i = 0 ; i < nb ; ++i)
+ values[i] = static_cast<Derived*>(this)->ReadU8();
+ };
+
+ /**
+ * Extracts @a nb signed 16-bit integers and return them as a vector.
+ */
+ template <class Derived>
+ std::vector<int16_t> BinaryStream<Derived>::ReadI16(size_t nb)
+ {
+ std::vector<int16_t> values(nb);
+ this->ReadI16(values);
+ return values;
+ };
+
+ /**
+ * Extracts exactly the number of elements set in the vector @a values
+ *
+ * @note In case you want to assign only a part of the vector, you can use the method using an array.
+ * For example;
+ * @code
+ * std::vector<int16_t> val(45,0);
+ * bfs.ReadI16(10, &(val[0])); // assign value #0-9
+ * // ...
+ * bfs.ReadI16(5, &(val[40])); // assign value #41-45
+ * @endcode
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadI16(std::vector<int16_t>& values)
+ {
+ if (values.empty())
+ return;
+ this->ReadI16(values.size(), &(values[0]));
+ };
+
+ /**
+ * Extracts @a nb signed 16-bit integers and set them in the array @a values.
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadI16(size_t nb, int16_t* values)
+ {
+ for (size_t i = 0 ; i < nb ; ++i)
+ values[i] = static_cast<Derived*>(this)->ReadI16();
+ };
+
+ /**
+ * Extracts @a nb unsigned 16-bit integers and return them as a vector.
+ */
+ template <class Derived>
+ std::vector<uint16_t> BinaryStream<Derived>::ReadU16(size_t nb)
+ {
+ std::vector<uint16_t> values(nb);
+ this->ReadU16(values);
+ return values;
+ };
+
+ /**
+ * Extracts exactly the number of elements set in the vector @a values
+ *
+ * @note In case you want to assign only a part of the vector, you can use the method using an array.
+ * For example;
+ * @code
+ * std::vector<uint16_t> val(45,0);
+ * bfs.ReadU16(10, &(val[0])); // assign value #0-9
+ * // ...
+ * bfs.ReadU16(5, &(val[40])); // assign value #41-45
+ * @endcode
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadU16(std::vector<uint16_t>& values)
+ {
+ if (values.empty())
+ return;
+ this->ReadU16(values.size(), &(values[0]));
+ };
+
+ /**
+ * Extracts @a nb unsigned 16-bit integers and set them in the array @a values.
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadU16(size_t nb, uint16_t* values)
+ {
+ for (size_t i = 0 ; i < nb ; ++i)
+ values[i] = static_cast<Derived*>(this)->ReadU16();
+ };
+
+ /**
+ * Extracts @a nb signed 32-bit integers and return them as a vector.
+ */
+ template <class Derived>
+ std::vector<int32_t> BinaryStream<Derived>::ReadI32(size_t nb)
+ {
+ std::vector<int32_t> values(nb);
+ this->ReadI32(values);
+ return values;
+ };
+
+ /**
+ * Extracts exactly the number of elements set in the vector @a values
+ *
+ * @note In case you want to assign only a part of the vector, you can use the method using an array.
+ * For example;
+ * @code
+ * std::vector<int32_t> val(45,0);
+ * bfs.ReadI32(10, &(val[0])); // assign value #0-9
+ * // ...
+ * bfs.ReadI32(5, &(val[40])); // assign value #41-45
+ * @endcode
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadI32(std::vector<int32_t>& values)
+ {
+ if (values.empty())
+ return;
+ this->ReadI32(values.size(), &(values[0]));
+ };
+
+ /**
+ * Extracts @a nb signed 32-bit integers and set them in the array @a values.
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadI32(size_t nb, int32_t* values)
+ {
+ for (size_t i = 0 ; i < nb ; ++i)
+ values[i] = static_cast<Derived*>(this)->ReadI32();
+ };
+
+ /**
+ * Extracts @a nb unsigned 32-bit integers and return them as a vector.
+ */
+ template <class Derived>
+ std::vector<uint32_t> BinaryStream<Derived>::ReadU32(size_t nb)
+ {
+ std::vector<uint32_t> values(nb);
+ this->ReadU32(values);
+ return values;
+ };
+
+
+ /**
+ * Extracts exactly the number of elements set in the vector @a values
+ *
+ * @note In case you want to assign only a part of the vector, you can use the method using an array.
+ * For example;
+ * @code
+ * std::vector<uint32_t> val(45,0);
+ * bfs.ReadU32(10, &(val[0])); // assign value #0-9
+ * // ...
+ * bfs.ReadU32(5, &(val[40])); // assign value #41-45
+ * @endcode
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadU32(std::vector<uint32_t>& values)
+ {
+ if (values.empty())
+ return;
+ this->ReadU32(values.size(), &(values[0]));
+ };
+
+ /**
+ * Extracts @a nb unsigned 32-bit integers and set them in the array @a values.
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadU32(size_t nb, uint32_t* values)
+ {
+ for (size_t i = 0 ; i < nb ; ++i)
+ values[i] = static_cast<Derived*>(this)->ReadU32();
+ };
+
+ /**
+ * Extracts @a nb signed 64-bit integers and return them as a vector.
+ */
+ template <class Derived>
+ std::vector<int64_t> BinaryStream<Derived>::ReadI64(size_t nb)
+ {
+ std::vector<int64_t> values(nb);
+ this->ReadI64(values);
+ return values;
+ };
+
+ /**
+ * Extracts exactly the number of elements set in the vector @a values
+ *
+ * @note In case you want to assign only a part of the vector, you can use the method using an array.
+ * For example;
+ * @code
+ * std::vector<int64_t> val(45,0);
+ * bfs.ReadI64(10, &(val[0])); // assign value #0-9
+ * // ...
+ * bfs.ReadI64(5, &(val[40])); // assign value #41-45
+ * @endcode
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadI64(std::vector<int64_t>& values)
+ {
+ if (values.empty())
+ return;
+ this->ReadI64(values.size(), &(values[0]));
+ };
+
+ /**
+ * Extracts @a nb signed 64-bit integers and set them in the array @a values.
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadI64(size_t nb, int64_t* values)
+ {
+ for (size_t i = 0 ; i < nb ; ++i)
+ values[i] = static_cast<Derived*>(this)->ReadI64();
+ };
+
+ /**
+ * Extracts @a nb unsigned 64-bit integers and return them as a vector.
+ */
+ template <class Derived>
+ std::vector<uint64_t> BinaryStream<Derived>::ReadU64(size_t nb)
+ {
+ std::vector<uint64_t> values(nb);
+ this->ReadU64(values);
+ return values;
+ };
+
+ /**
+ * Extracts exactly the number of elements set in the vector @a values
+ *
+ * @note In case you want to assign only a part of the vector, you can use the method using an array.
+ * For example;
+ * @code
+ * std::vector<uint64_t> val(45,0);
+ * bfs.ReadU64(10, &(val[0])); // assign value #0-9
+ * // ...
+ * bfs.ReadU64(5, &(val[40])); // assign value #41-45
+ * @endcode
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadU64(std::vector<uint64_t>& values)
+ {
+ if (values.empty())
+ return;
+ this->ReadU64(values.size(), &(values[0]));
+ };
+
+ /**
+ * Extracts @a nb unsigned 64-bit integers and set them in the array @a values.
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadU64(size_t nb, uint64_t* values)
+ {
+ for (size_t i = 0 ; i < nb ; ++i)
+ values[i] = static_cast<Derived*>(this)->ReadU64();
+ };
+
+ /**
+ * Extracts @a nb floats and return them as a vector.
+ */
+ template <class Derived>
+ std::vector<float> BinaryStream<Derived>::ReadFloat(size_t nb)
+ {
+ std::vector<float> values(nb);
+ this->ReadFloat(values);
+ return values;
+ };
+
+ /**
+ * Extracts exactly the number of elements set in the vector @a values
+ *
+ * @note In case you want to assign only a part of the vector, you can use the method using an array.
+ * For example;
+ * @code
+ * std::vector<float> val(45,0);
+ * bfs.ReadFloat(10, &(val[0])); // assign value #0-9
+ * // ...
+ * bfs.ReadFloat(5, &(val[40])); // assign value #41-45
+ * @endcode
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadFloat(std::vector<float>& values)
+ {
+ if (values.empty())
+ return;
+ this->ReadFloat(values.size(), &(values[0]));
+ };
+
+ /**
+ * Extracts @a nb floats and set them in the array @a values.
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadFloat(size_t nb, float* values)
+ {
+ for (size_t i = 0 ; i < nb ; ++i)
+ values[i] = static_cast<Derived*>(this)->ReadFloat();
+ };
+
+ /**
+ * Extracts @a nb doubles and return them as a vector.
+ */
+ template <class Derived>
+ std::vector<double> BinaryStream<Derived>::ReadDouble(size_t nb)
+ {
+ std::vector<double> values(nb);
+ this->ReadDouble(values);
+ return values;
+ };
+
+ /**
+ * Extracts exactly the number of elements set in the vector @a values
+ *
+ * @note In case you want to assign only a part of the vector, you can use the method using an array.
+ * For example;
+ * @code
+ * std::vector<double> val(45,0);
+ * bfs.ReadDouble(10, &(val[0])); // assign value #0-9
+ * // ...
+ * bfs.ReadDouble(5, &(val[40])); // assign value #41-45
+ * @endcode
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadDouble(std::vector<double>& values)
+ {
+ if (values.empty())
+ return;
+ this->ReadDouble(values.size(), &(values[0]));
+ };
+
+ /**
+ * Extracts @a nb doubles and set them in the array @a values.
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadDouble(size_t nb, double* values)
+ {
+ for (size_t i = 0 ; i < nb ; ++i)
+ values[i] = static_cast<Derived*>(this)->ReadDouble();
+ };
+
+ /**
+ * Extracts @a nb strings with @a nb Charcharacters and return them as a vector.
+ */
+ template <class Derived>
+ std::vector<std::string> BinaryStream<Derived>::ReadString(size_t nb, size_t nbChar)
+ {
+ std::vector<std::string> values(nb);
+ this->ReadString(nbChar, values);
+ return values;
+ };
+
+ /**
+ * Extracts exactly the number of elements set in the vector @a values
+ *
+ * @note In case you want to assign only a part of the vector, you can use the method using an array.
+ * For example;
+ * @code
+ * std::vector<uint8_t> val(45,0);
+ * bfs.ReadU8(10, &(val[0])); // assign value #0-9
+ * // ...
+ * bfs.ReadU8(5, &(val[40])); // assign value #41-45
+ * @endcode
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadString(size_t nbChar, std::vector<std::string>& values)
+ {
+ if (values.empty())
+ return;
+ this->ReadString(values.size(), nbChar, &(values[0]));
+ };
+
+ /**
+ * Extracts @a nb unsigned 8-bit integers and set them in the array @a values.
+ */
+ template <class Derived>
+ void BinaryStream<Derived>::ReadString(size_t nb, size_t nbChar, std::string* values)
+ {
+ for (size_t i = 0 ; i < nb ; ++i)
+ values[i] = static_cast<Derived*>(this)->ReadString(nbChar);
+ };
+
+ /**
+ * Writes the vector of signed 8-bit integers @a values in the stream an return its size.
+ */
+ template <class Derived>
+ size_t BinaryStream<Derived>::Write(const std::vector<int8_t>& values)
+ {
+ size_t inc = 0;
+ while (inc < values.size())
+ static_cast<Derived*>(this)->Write(values[inc++]);
+ return values.size() * 1;
+ };
+
+ /**
+ * Writes the vector of unsigned 8-bit integers @a values in the stream an return its size.
+ */
+ template <class Derived>
+ size_t BinaryStream<Derived>::Write(const std::vector<uint8_t>& values)
+ {
+ size_t inc = 0;
+ while (inc < values.size())
+ static_cast<Derived*>(this)->Write(values[inc++]);
+ return values.size() * 1;
+ };
+
+ /**
+ * Writes the vector of signed 16-bit integers @a values in the stream an return its size.
+ */
+ template <class Derived>
+ size_t BinaryStream<Derived>::Write(const std::vector<int16_t>& values)
+ {
+ size_t inc = 0;
+ while (inc < values.size())
+ static_cast<Derived*>(this)->Write(values[inc++]);
+ return values.size() * 2;
+ };
+
+ /**
+ * Writes the vector of unsigned 16-bit integers @a values in the stream an return its size.
+ */
+ template <class Derived>
+ size_t BinaryStream<Derived>::Write(const std::vector<uint16_t>& values)
+ {
+ size_t inc = 0;
+ while (inc < values.size())
+ static_cast<Derived*>(this)->Write(values[inc++]);
+ return values.size() * 2;
+ };
+
+ /**
+ * Writes the vector of signed 32-bit integers @a values in the stream an return its size.
+ */
+ template <class Derived>
+ size_t BinaryStream<Derived>::Write(const std::vector<int32_t>& values)
+ {
+ size_t inc = 0;
+ while (inc < values.size())
+ static_cast<Derived*>(this)->Write(values[inc++]);
+ return values.size() * 2;
+ };
+
+ /**
+ * Writes the vector of unsigned 32-bit integers @a values in the stream an return its size.
+ */
+ template <class Derived>
+ size_t BinaryStream<Derived>::Write(const std::vector<uint32_t>& values)
+ {
+ size_t inc = 0;
+ while (inc < values.size())
+ static_cast<Derived*>(this)->Write(values[inc++]);
+ return values.size() * 2;
+ };
+
+ /**
+ * Writes the vector of floats @a values in the stream an return its size.
+ */
+ template <class Derived>
+ size_t BinaryStream<Derived>::Write(const std::vector<float>& values)
+ {
+ size_t inc = 0;
+ while (inc < values.size())
+ static_cast<Derived*>(this)->Write(values[inc++]);
+ return values.size() * 4;
+ };
+
+ /**
+ * Writes the vector of strings @a values in the stream an return its size.
+ */
+ template <class Derived>
+ size_t BinaryStream<Derived>::Write(const std::vector<std::string>& values)
+ {
+ size_t inc = 0;
+ size_t writedBytes = 0;
+ while (inc < values.size())
+ writedBytes += static_cast<Derived*>(this)->Write(values[inc++]);
+ return writedBytes;
+ };
+};
\ No newline at end of file
diff --git a/Code/IO/btkC3DFileIO.cpp b/Code/IO/btkC3DFileIO.cpp
index 704ec023..c39aea9e 100644
--- a/Code/IO/btkC3DFileIO.cpp
+++ b/Code/IO/btkC3DFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -41,6 +41,7 @@
#include <algorithm>
#include <cctype>
#include <iostream>
+#include <cmath>
namespace btk
{
@@ -248,7 +249,7 @@ namespace btk
ibfs = new IEEEBigEndianBinaryFileStream();
break;
default :
- throw(C3DFileIOException("Invalid processor type"));
+ throw(C3DFileIOException("Invalid processor type - Impossible to use the right stream to read data."));
break;
};
ibfs->SwapStream(oldBFS);
@@ -664,7 +665,7 @@ namespace btk
}
}
this->m_AnalogChannelScale = std::vector<double>(analogNumber, 1.0);
- this->m_AnalogZeroOffset = std::vector<int>(analogNumber, 0);
+ this->m_AnalogZeroOffset = std::vector<double>(analogNumber, 0.0);
this->m_AnalogUniversalScale = 1.0;
if ((analogNumber != 0) && (itAnalog != root->End()))
@@ -704,11 +705,11 @@ namespace btk
// - ANALOG:OFFSET
if (this->m_AnalogIntegerFormat == Unsigned) // unsigned
{
- for (unsigned inc = 0 ; inc < this->m_AnalogZeroOffset.size() ; ++inc)
- this->m_AnalogZeroOffset[inc] = static_cast<uint16_t>(analogZeroOffset_t[inc]);
+ for (size_t inc = 0 ; inc < this->m_AnalogZeroOffset.size() ; ++inc)
+ this->m_AnalogZeroOffset[inc] = static_cast<double>(static_cast<uint16_t>(analogZeroOffset_t[inc]));
}
else // signed
- MetaDataCollapseChildrenValues<int>(this->m_AnalogZeroOffset, *itAnalog, "OFFSET", analogNumber, 0);
+ MetaDataCollapseChildrenValues<double>(this->m_AnalogZeroOffset, *itAnalog, "OFFSET", analogNumber, 0.0);
// - ANALOG:SCALE
MetaDataCollapseChildrenValues<double>(this->m_AnalogChannelScale, *itAnalog, "SCALE", analogNumber, 1.0);
// - ANALOG:GEN_SCALE
@@ -786,7 +787,7 @@ namespace btk
Acquisition::AnalogIterator itA = output->BeginAnalog();
while (itA != output->EndAnalog())
{
- (*itA)->GetValues().data()[analogFrame] = (fdf->ReadAnalog() - static_cast<double>(this->m_AnalogZeroOffset[incChannel])) * this->m_AnalogChannelScale[incChannel] * this->m_AnalogUniversalScale;
+ (*itA)->GetValues().data()[analogFrame] = (fdf->ReadAnalog() - this->m_AnalogZeroOffset[incChannel]) * this->m_AnalogChannelScale[incChannel] * this->m_AnalogUniversalScale;
++itA; ++incChannel;
if ((itA == output->EndAnalog()) && (inc < static_cast<unsigned>(numberSamplesPerAnalogChannel - 1)))
{
@@ -1037,7 +1038,7 @@ namespace btk
obfs = new IEEEBigEndianBinaryFileStream();
break;
default :
- throw(C3DFileIOException("Invalid processor type"));
+ throw(C3DFileIOException("Invalid processor type - Impossible to use the right stream to write data."));
break;
}
// File access
@@ -1483,7 +1484,7 @@ namespace btk
int analogNumber = input->GetAnalogNumber();
size_t inc = 0;
this->m_AnalogChannelScale.resize(analogNumber, 1.0);
- this->m_AnalogZeroOffset.resize(analogNumber, 0);
+ this->m_AnalogZeroOffset.resize(analogNumber, 0.0);
double minAnalogscale = 1.0;
for (Acquisition::AnalogConstIterator itAnalog = input->BeginAnalog() ; itAnalog != input->EndAnalog() ; ++itAnalog)
{
@@ -1566,24 +1567,33 @@ namespace btk
{
if ((*itAnalogOffset)->GetInfo()->GetValues().size() < analogNumber)
{
- btkWarningMacro("No enough analog offsets. Impossible to update analog offsets.");
+ btkWarningMacro("No enough analog offsets. Missing offset will be set to 0.");
}
- else
+ if (((*itAnalogOffset)->GetInfo()->GetFormat() == MetaDataInfo::Real) || this->m_AnalogIntegerFormat == Signed)
{
- if (this->m_AnalogIntegerFormat == Unsigned) // unsigned
- {
- std::vector<uint16_t> analogZeroOffset_t;
- (*itAnalogOffset)->GetInfo()->ToUInt16(analogZeroOffset_t);
- size_t mini = ((analogZeroOffset_t.size() > this->m_AnalogZeroOffset.size()) ? this->m_AnalogZeroOffset.size() : analogZeroOffset_t.size());
- for (size_t inc = 0 ; inc < mini ; ++inc)
- this->m_AnalogZeroOffset[inc] = analogZeroOffset_t[inc];
- }
- else // signed
+ (*itAnalogOffset)->GetInfo()->ToDouble(this->m_AnalogZeroOffset);
+ }
+ else
+ {
+ // Check if the casting into unsigned 16-bit integer will not remove any possible fractional part. If it is the case, print a warning message
+ std::vector<float> azo;
+ (*itAnalogOffset)->GetInfo()->ToFloat(azo);
+ size_t mini = ((azo.size() > this->m_AnalogZeroOffset.size()) ? this->m_AnalogZeroOffset.size() : azo.size());
+ for (size_t inc = 0 ; inc < mini ; ++inc)
{
- (*itAnalogOffset)->GetInfo()->ToInt(this->m_AnalogZeroOffset);
- this->m_AnalogZeroOffset.resize(analogNumber, 0);
+ double intpart = 0.0;
+ if (std::modf(azo[inc], &intpart) > 1e-5)
+ {
+ btkWarningMacro("At least one real offset will have its fractionnal part removed as you select to store them as UNSIGNED offset.");
+ break;
+ }
}
+ std::vector<uint16_t> analogZeroOffset_t;
+ (*itAnalogOffset)->GetInfo()->ToUInt16(analogZeroOffset_t);
+ for (size_t inc = 0 ; inc < mini ; ++inc)
+ this->m_AnalogZeroOffset[inc] = static_cast<double>(analogZeroOffset_t[inc]);
}
+ this->m_AnalogZeroOffset.resize(analogNumber, 0.0);
}
else
{
@@ -1726,8 +1736,19 @@ namespace btk
descs.resize(analogNumber);
std::vector<std::string> units = std::vector<std::string>(analogNumber);
std::vector<int16_t> gain = std::vector<int16_t>(analogNumber, 0);
- std::vector<int16_t> analogZeroOffset = std::vector<int16_t>(analogNumber, 0);
+ std::vector<float> analogZeroOffset_Float = std::vector<float>(analogNumber, 0.0);
+ std::vector<int16_t> analogZeroOffset_Int = std::vector<int16_t>(analogNumber, 0);
std::vector<float> analogChannelScale = std::vector<float>(analogNumber, 1.0);
+ bool analogZeroOffsetHasTrueReal = false;
+ for (size_t ijk = 0 ; ijk < this->m_AnalogZeroOffset.size() ; ++ijk)
+ {
+ double intpart = 0.0;
+ if (fabs(std::modf(this->m_AnalogZeroOffset[ijk], &intpart)) > 1e-5)
+ {
+ analogZeroOffsetHasTrueReal = true;
+ break;
+ }
+ }
inc = 0;
for (Acquisition::AnalogConstIterator itAnalog = input->BeginAnalog() ; itAnalog != input->EndAnalog() ; ++itAnalog)
{
@@ -1736,9 +1757,6 @@ namespace btk
units[inc] = (*itAnalog)->GetUnit();
switch((*itAnalog)->GetGain())
{
- case Analog::Unknown:
- gain[inc] = 0;
- break;
case Analog::PlusMinus10:
gain[inc] = 1;
break;
@@ -1754,21 +1772,13 @@ namespace btk
case Analog::PlusMinus1:
gain[inc] = 5;
break;
- case Analog::PlusMinus0Dot5:
- gain[inc] = 6;
- break;
- case Analog::PlusMinus0Dot25:
- gain[inc] = 7;
- break;
- case Analog::PlusMinus0Dot1:
- gain[inc] = 8;
- break;
- case Analog::PlusMinus0Dot05:
- gain[inc] = 9;
+ default:
+ gain[inc] = 0;
break;
}
analogChannelScale[inc] = static_cast<float>(this->m_AnalogChannelScale[inc]);
- analogZeroOffset[inc] = this->m_AnalogZeroOffset[inc];
+ analogZeroOffset_Float[inc] = this->m_AnalogZeroOffset[inc];
+ analogZeroOffset_Int[inc] = static_cast<int16_t>(this->m_AnalogZeroOffset[inc]);
++inc;
}
MetaDataCreateChild(analog, "LABELS", labels);
@@ -1776,7 +1786,10 @@ namespace btk
MetaDataCreateChild(analog, "UNITS", units);
MetaDataCreateChild(analog, "GAIN", gain);
MetaDataCreateChild(analog, "SCALE", analogChannelScale);
- MetaDataCreateChild(analog, "OFFSET", analogZeroOffset);
+ if (analogZeroOffsetHasTrueReal)
+ MetaDataCreateChild(analog, "OFFSET", analogZeroOffset_Float);
+ else
+ MetaDataCreateChild(analog, "OFFSET", analogZeroOffset_Int);
// ANALOG:GEN_SCALE
MetaDataCreateChild(analog, "GEN_SCALE", static_cast<float>(this->m_AnalogUniversalScale));
// ANALOG:RATE
diff --git a/Code/IO/btkC3DFileIO.h b/Code/IO/btkC3DFileIO.h
index 071505a2..8cb8815b 100644
--- a/Code/IO/btkC3DFileIO.h
+++ b/Code/IO/btkC3DFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -74,9 +74,9 @@ namespace btk
std::vector<double>& GetAnalogChannelScale() {return this->m_AnalogChannelScale;};
const std::vector<double>& GetAnalogChannelScale() const {return this->m_AnalogChannelScale;};
void SetAnalogChannelScale(const std::vector<double>& s) {this->m_AnalogChannelScale = s;};
- std::vector<int>& GetAnalogZeroOffset() {return this->m_AnalogZeroOffset;};
- const std::vector<int>& GetAnalogZeroOffset() const {return this->m_AnalogZeroOffset;};
- void SetAnalogZeroOffset(const std::vector<int>& s) {this->m_AnalogZeroOffset = s;};
+ std::vector<double>& GetAnalogZeroOffset() {return this->m_AnalogZeroOffset;};
+ const std::vector<double>& GetAnalogZeroOffset() const {return this->m_AnalogZeroOffset;};
+ void SetAnalogZeroOffset(const std::vector<double>& s) {this->m_AnalogZeroOffset = s;};
double GetAnalogUniversalScale() const {return this->m_AnalogUniversalScale;};
void SetAnalogUniversalScale(double s) {this->m_AnalogUniversalScale = s;};
@@ -215,7 +215,7 @@ namespace btk
double m_PointScale;
std::vector<double> m_AnalogChannelScale;
- std::vector<int> m_AnalogZeroOffset;
+ std::vector<double> m_AnalogZeroOffset;
double m_AnalogUniversalScale;
AnalogIntegerFormat m_AnalogIntegerFormat;
};
diff --git a/Code/IO/btkCALForcePlateFileIO.cpp b/Code/IO/btkCALForcePlateFileIO.cpp
index 59ab0eb5..5f4c3a35 100644
--- a/Code/IO/btkCALForcePlateFileIO.cpp
+++ b/Code/IO/btkCALForcePlateFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkCALForcePlateFileIO.h b/Code/IO/btkCALForcePlateFileIO.h
index 3343e744..88a2d2fc 100644
--- a/Code/IO/btkCALForcePlateFileIO.h
+++ b/Code/IO/btkCALForcePlateFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkCLBFileIO.cpp b/Code/IO/btkCLBFileIO.cpp
index 2389872d..330c0b74 100644
--- a/Code/IO/btkCLBFileIO.cpp
+++ b/Code/IO/btkCLBFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -153,18 +153,18 @@ namespace btk
output->Init(0,frameNumber,channelNumber);
output->SetPointFrequency(1.0e6/static_cast<double>(samplingClock));
double res = 0.0;
- int offset = 0;
+ double offset = 0.0;
switch(DACResolution)
{
case 12:
output->SetAnalogResolution(Acquisition::Bit12);
res = 4096.0;
- offset = 2048;
+ offset = 2048.0;
break;
case 16:
output->SetAnalogResolution(Acquisition::Bit16);
res = 65536.0;
- offset = 32768;
+ offset = 32768.0;
break;
default:
throw CLBFileIOException("Invalid resolution used for the digital-to-analog conversion");
@@ -263,67 +263,67 @@ namespace btk
break;
case 50: // 0V -- 10V
(*it)->SetScale(10.0/res);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
btkWarningMacro(filename, (*it)->GetLabel() + ": Unsupported gain and set to unknown.");
break;
case 51: // 0V -- 5V
(*it)->SetScale(5.0/res);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
btkWarningMacro(filename, (*it)->GetLabel() + ": Unsupported gain and set to unknown.");
break;
case 52: // 0V -- 4.095V
(*it)->SetScale(4.095/res);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
btkWarningMacro(filename, (*it)->GetLabel() + ": Unsupported gain and set to unknown.");
break;
case 53: // 0V -- 2.5V
(*it)->SetScale(2.5/res);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
btkWarningMacro(filename, (*it)->GetLabel() + ": Unsupported gain and set to unknown.");
break;
case 54: // 0V -- 1.25V
(*it)->SetScale(1.25/res);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
btkWarningMacro(filename, (*it)->GetLabel() + ": Unsupported gain and set to unknown.");
break;
case 55: // 0V -- 1V
(*it)->SetScale(1.0/res);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
btkWarningMacro(filename, (*it)->GetLabel() + ": Unsupported gain and set to unknown.");
break;
case 56: // 0V -- 0.5V
(*it)->SetScale(0.5/res);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
btkWarningMacro(filename, (*it)->GetLabel() + ": Unsupported gain and set to unknown.");
break;
case 57: // 0V -- 0.25V
(*it)->SetScale(0.25/res);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
btkWarningMacro(filename, (*it)->GetLabel() + ": Unsupported gain and set to unknown.");
break;
case 58: // 0V -- 0.1V
(*it)->SetScale(0.1/res);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
btkWarningMacro(filename, (*it)->GetLabel() + ": Unsupported gain and set to unknown.");
break;
case 59: // 0V -- 0.05V
(*it)->SetScale(0.05/res);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
btkWarningMacro(filename, (*it)->GetLabel() + ": Unsupported gain and set to unknown.");
break;
case 60: // 0V -- 0.025V
(*it)->SetScale(0.025/res);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
btkWarningMacro(filename, (*it)->GetLabel() + ": Unsupported gain and set to unknown.");
break;
case 61: // 0V -- 0.0125V
(*it)->SetScale(0.0125/res);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
btkWarningMacro(filename, (*it)->GetLabel() + ": Unsupported gain and set to unknown.");
break;
case 100: // 0V -- 20mA
(*it)->SetScale(20.0/res);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
(*it)->SetUnit("mA");
btkWarningMacro(filename, (*it)->GetLabel() + ": Unsupported gain and set to unknown.");
break;
diff --git a/Code/IO/btkCLBFileIO.h b/Code/IO/btkCLBFileIO.h
index e18fdee9..59174b3e 100644
--- a/Code/IO/btkCLBFileIO.h
+++ b/Code/IO/btkCLBFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkCodamotionFileIOUtils_p.cpp b/Code/IO/btkCodamotionFileIOUtils_p.cpp
index f0296912..07ede356 100644
--- a/Code/IO/btkCodamotionFileIOUtils_p.cpp
+++ b/Code/IO/btkCodamotionFileIOUtils_p.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -56,11 +56,11 @@ namespace btk
// frequency. The number of frames can be different too. In this second case, the maximum
// number of frames is taken and the extra frame for some markers will be set as invalid
// NOTE: From the code of Open3DMotion, it seems that unit for markers is the millimeter.
- int numPointFrames = (o3dm_markers.size() == 0) ? 0 : o3dm_markers[0]->NumFrames();
+ size_t numPointFrames = (o3dm_markers.size() == 0) ? 0 : o3dm_markers[0]->NumFrames();
double pointFrequency = (o3dm_markers.size() == 0) ? 0.0 : o3dm_markers[0]->Rate;
int firstFrame = (o3dm_markers.size() == 0) ? 1 : (static_cast<int>(o3dm_markers[0]->Start * o3dm_markers[0]->Rate) + 1);
double pointStart = (o3dm_markers.size() == 0) ? 0.0 : o3dm_markers[0]->Start;
- bool mixedPointNumFrames = false;
+ bool mixedNumFrames = false;
for (size_t i = 0 ; i < o3dm_markers.size() ; ++i)
{
if (fabs(o3dm_markers[i]->Rate - pointFrequency) > 1e-6)
@@ -70,13 +70,30 @@ namespace btk
if (numPointFrames != o3dm_markers[i]->NumFrames())
{
numPointFrames = numPointFrames > o3dm_markers[i]->NumFrames() ? numPointFrames : o3dm_markers[i]->NumFrames();
- mixedPointNumFrames = true;
+ mixedNumFrames = true;
}
}
- if (mixedPointNumFrames)
+ if (mixedNumFrames)
{
btkWarningMacro(filename, "The number of frames is not the same for every markers. Extra frames will be added to some markers.")
}
+ // In case there is no marker the number of frames is set to 0. We need to check the number of frames of the analog channels.
+ if (numPointFrames == 0)
+ {
+ numPointFrames = (o3dm_analogs.size() == 0) ? 0 : o3dm_analogs[0]->NumFrames();
+ for (size_t i = 0 ; i < o3dm_analogs.size() ; ++i)
+ {
+ if (numPointFrames != o3dm_analogs[i]->NumFrames())
+ {
+ numPointFrames = numPointFrames > o3dm_analogs[i]->NumFrames() ? numPointFrames : o3dm_analogs[i]->NumFrames();
+ mixedNumFrames = true;
+ }
+ }
+ if (mixedNumFrames)
+ {
+ btkWarningMacro(filename, "The number of frames is not the same for every analog channels. Extra frames will be added to some analog channels.")
+ }
+ }
// For analog channels, this is the same. The number of frames must be a multiple of the
// number of video frames (i.e. the analogs' frequency must be a multiple of the markers' frequency)
// If it is not the case, then the data are interpolated.
@@ -131,7 +148,7 @@ namespace btk
if ((pointFrequency == 0.0) && (commonAnalogFrequency == 0.0))
throw(CodamotionFileIOException("The case where there is not frame for marker and analog is not handled by BTK."));
int numAnalogSamplesPerFrame = static_cast<int>(commonAnalogFrequency / pointFrequency);
- int numAnalogFrames = numPointFrames * numAnalogSamplesPerFrame;
+ size_t numAnalogFrames = numPointFrames * numAnalogSamplesPerFrame;
// Store the markers data in the BTK Acquisition object
PointCollection::Pointer points = output->GetPoints();
@@ -141,10 +158,10 @@ namespace btk
// Get sequence & iterator (may throw exception if missing fields)
const Open3DMotion::TimeSequence* ts = o3dm_markers[i];
Open3DMotion::TSOccVector3ConstIter iter_ts(*ts);
- for (int j = 0 ; j < o3dm_markers[i]->NumFrames() ; ++j, iter_ts.Next())
- pt->SetDataSlice(j, iter_ts.Value()[0], iter_ts.Value()[1], iter_ts.Value()[2], iter_ts.Occluded() ? -1.0 : 0.0);
- for (int j = o3dm_markers[i]->NumFrames() ; j < numPointFrames ; ++j)
- pt->SetDataSlice(j, 0.0, 0.0, 0.0, -1.0); // Invalid
+ for (size_t j = 0 ; j < o3dm_markers[i]->NumFrames() ; ++j, iter_ts.Next())
+ pt->SetDataSlice((int)j, iter_ts.Value()[0], iter_ts.Value()[1], iter_ts.Value()[2], iter_ts.Occluded() ? -1.0 : 0.0);
+ for (size_t j = o3dm_markers[i]->NumFrames() ; j < numPointFrames ; ++j)
+ pt->SetDataSlice((int)j, 0.0, 0.0, 0.0, -1.0); // Invalid
points->InsertItem(pt);
}
@@ -152,11 +169,11 @@ namespace btk
AnalogCollection::Pointer analogs = output->GetAnalogs();
for (size_t i = 0 ; i < o3dm_analogs.size() ; ++i)
{
- int numFrames = numAnalogFrames < o3dm_analogs[i]->NumFrames() ? numAnalogFrames : o3dm_analogs[i]->NumFrames();
- btk::Analog::Pointer an = btk::Analog::New(o3dm_analogs[i]->Channel, numAnalogFrames);
+ size_t numFrames = numAnalogFrames < o3dm_analogs[i]->NumFrames() ? numAnalogFrames : o3dm_analogs[i]->NumFrames();
+ btk::Analog::Pointer an = btk::Analog::New(o3dm_analogs[i]->Channel, static_cast<int>(numAnalogFrames));
double offset = o3dm_analogs[i]->Offset.Value();
double scale = o3dm_analogs[i]->Scale.Value();
- an->SetOffset(static_cast<int>(offset));
+ an->SetOffset(offset);
an->SetScale(scale);
an->SetUnit(o3dm_analogs[i]->Units.Value());
// Get sequence & iterator (may throw exception if missing fields)
@@ -165,20 +182,20 @@ namespace btk
/// Extract data (without or with the need of interpolation)
if (analogs_subsample[i] == 1)
{
- for (int j = 0 ; j < numFrames ; ++j, iter_ts.Next())
- an->SetDataSlice(j, (iter_ts.Value() - offset) * scale);
+ for (size_t j = 0 ; j < numFrames ; ++j, iter_ts.Next())
+ an->SetDataSlice((int)j, (iter_ts.Value() - offset) * scale);
}
else if (numFrames > 0)
{
double val0 = (iter_ts.Value() - offset) * scale; an->SetDataSlice(0, val0); iter_ts.Next();
- for (int j = 1 ; j < numFrames ; ++j, iter_ts.Next())
+ for (size_t j = 1 ; j < numFrames ; ++j, iter_ts.Next())
{
double val1 = (iter_ts.Value() - offset) * scale;
- an->SetDataSlice(j * analogs_subsample[i], val1);
+ an->SetDataSlice(static_cast<int>(j * analogs_subsample[i]), val1);
// Linear interpolation
for (int k = 1 ; k < analogs_subsample[i] ; ++k)
{
- int frame = (j-1) * analogs_subsample[i] + k;
+ int frame = static_cast<int>(j-1) * analogs_subsample[i] + k;
double lambda = static_cast<double>(frame % analogs_subsample[i]) / static_cast<double>(analogs_subsample[i]);
an->SetDataSlice(frame, (1.0-lambda) * val0 + lambda * val1);
}
@@ -270,7 +287,8 @@ namespace btk
channelData[inc*numChannelPerPlatform + i] = static_cast<int16_t>(analogindex_zerobased + 1);
Analog::Pointer ch = output->GetAnalog(analogindex_zerobased);
// Open3DMotion stores platform' forces and not their reactions.
- ch->GetValues() *= -1.0;
+ if (numAnalogFrames != 0)
+ ch->GetValues() *= -1.0;
// By default Open3DMotion set force's label to Force1, Force2, etc.
// They are rewritten to be compatible with other file formats available in BTK.
switch (i)
diff --git a/Code/IO/btkCodamotionFileIOUtils_p.h b/Code/IO/btkCodamotionFileIOUtils_p.h
index f0b4a2aa..4c8e7129 100644
--- a/Code/IO/btkCodamotionFileIOUtils_p.h
+++ b/Code/IO/btkCodamotionFileIOUtils_p.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkDelsysEMGFileIO.cpp b/Code/IO/btkDelsysEMGFileIO.cpp
index 12d03864..aec51ef6 100644
--- a/Code/IO/btkDelsysEMGFileIO.cpp
+++ b/Code/IO/btkDelsysEMGFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -164,7 +164,7 @@ namespace btk
for (Acquisition::AnalogIterator it = output->BeginAnalog() ; it != output->EndAnalog() ; ++it)
{
(*it)->SetScale(scale);
- (*it)->SetOffset(5); // 5V
+ (*it)->SetOffset(5.0); // 5V
(*it)->SetGain(Analog::PlusMinus10);
}
}
@@ -180,7 +180,7 @@ namespace btk
for (Acquisition::AnalogIterator it = output->BeginAnalog() ; it != output->EndAnalog() ; ++it)
{
(*it)->SetScale(scale);
- (*it)->SetOffset(5); // 5V
+ (*it)->SetOffset(5.0); // 5V
(*it)->SetGain(Analog::PlusMinus10); // NOTE: Only assumed from the offset value.
}
}
@@ -239,25 +239,7 @@ namespace btk
(*it)->SetUnit(bifs.ReadString(bifs.ReadU32()));
(*it)->SetLabel(bifs.ReadString(bifs.ReadU32()));
gains[inc] = bifs.ReadDouble(); // System gain
- int gain = static_cast<int>(gains[inc]);
- switch(gain)
- {
- case Analog::PlusMinus10:
- case Analog::PlusMinus5:
- case Analog::PlusMinus2Dot5:
- case Analog::PlusMinus1Dot25:
- case Analog::PlusMinus1:
- case Analog::PlusMinus0Dot5:
- case Analog::PlusMinus0Dot25:
- case Analog::PlusMinus0Dot1:
- case Analog::PlusMinus0Dot05:
- (*it)->SetGain(static_cast<Analog::Gain>(gain));
- break;
- default:
- btkWarningMacro(filename, "Unknown gain. Contact the developer to add it in the list. Replaced by a gain of +/- 10 volts.");
- (*it)->SetGain(Analog::PlusMinus10);
- break;
- }
+ (*it)->SetGainFromValue(static_cast<int>(gains[inc]));
bifs.SeekRead(8, BinaryFileStream::Current); // AD gain
resolutions[inc] = bifs.ReadDouble();
offsets[inc] = bifs.ReadDouble();
@@ -269,7 +251,7 @@ namespace btk
bifs.SeekRead(12, BinaryFileStream::Current);
}
(*it)->SetScale(resolutions[inc] / gains[inc]);
- (*it)->SetOffset(static_cast<int>(offsets[inc] / gains[inc]));
+ (*it)->SetOffset(offsets[inc] / gains[inc]);
++inc;
}
// Data
diff --git a/Code/IO/btkDelsysEMGFileIO.h b/Code/IO/btkDelsysEMGFileIO.h
index 31b8eb82..9a2e6a06 100644
--- a/Code/IO/btkDelsysEMGFileIO.h
+++ b/Code/IO/btkDelsysEMGFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkEMFFileIO.cpp b/Code/IO/btkEMFFileIO.cpp
index 221df7f6..21d0601f 100644
--- a/Code/IO/btkEMFFileIO.cpp
+++ b/Code/IO/btkEMFFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkEMFFileIO.h b/Code/IO/btkEMFFileIO.h
index 57539c34..601e3ba6 100644
--- a/Code/IO/btkEMFFileIO.h
+++ b/Code/IO/btkEMFFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkEMxFileIO.cpp b/Code/IO/btkEMxFileIO.cpp
index 4f845160..58fe928d 100644
--- a/Code/IO/btkEMxFileIO.cpp
+++ b/Code/IO/btkEMxFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkEMxFileIO.h b/Code/IO/btkEMxFileIO.h
index 2b20367b..98341b7d 100644
--- a/Code/IO/btkEMxFileIO.h
+++ b/Code/IO/btkEMxFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkEliteFileIOUtils_p.cpp b/Code/IO/btkEliteFileIOUtils_p.cpp
index 53df67b9..6f2527ea 100644
--- a/Code/IO/btkEliteFileIOUtils_p.cpp
+++ b/Code/IO/btkEliteFileIOUtils_p.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkEliteFileIOUtils_p.h b/Code/IO/btkEliteFileIOUtils_p.h
index 8ea3e227..7958d409 100644
--- a/Code/IO/btkEliteFileIOUtils_p.h
+++ b/Code/IO/btkEliteFileIOUtils_p.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkGRxFileIO.cpp b/Code/IO/btkGRxFileIO.cpp
index 9d748d9e..8e94d855 100644
--- a/Code/IO/btkGRxFileIO.cpp
+++ b/Code/IO/btkGRxFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkGRxFileIO.h b/Code/IO/btkGRxFileIO.h
index 2a468aaa..312ff607 100644
--- a/Code/IO/btkGRxFileIO.h
+++ b/Code/IO/btkGRxFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkHPFFileIO.cpp b/Code/IO/btkHPFFileIO.cpp
new file mode 100644
index 00000000..f17462bf
--- /dev/null
+++ b/Code/IO/btkHPFFileIO.cpp
@@ -0,0 +1,341 @@
+/*
+ * The Biomechanical ToolKit
+ * Copyright (c) 2009-2014, Arnaud Barré
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name(s) of the copyright holders nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "btkHPFFileIO.h"
+#include "btkBinaryFileStream.h"
+#include "btkMetaDataUtils.h"
+#include "btkConvert.h"
+#include "btkLogger.h"
+
+#include <limits>
+
+#include <pugixml.hpp>
+
+#include <iostream>
+
+struct btk_hpf_chunk_info
+{
+ size_t position;
+ int64_t id;
+ int64_t size;
+ int32_t group;
+};
+
+namespace btk
+{
+ /**
+ * @class HPFFileIOException btkHPFFileIO.h
+ * @brief Exception class for the HPFFileIO class.
+ */
+
+ /**
+ * @fn HPFFileIOException::HPFFileIOException(const std::string& msg)
+ * Constructor.
+ */
+
+ /**
+ * @fn virtual HPFFileIOException::~HPFFileIOException()
+ * Empty destructor.
+ */
+
+ /**
+ * @class HPFFileIO btkHPFFileIO.h
+ * @brief Interface to read/write HPF files.
+ *
+ * The HPF file format is used in the software EMGWorks 4.0 (Delsys Inc., Natick, USA) and contains only analogs data.
+ *
+ * @note The reader was implemented based on the document <em>DT High Performance File Format Specification</em> (Document Number: 22760, Rev A) proposed by the company Data Translation, Inc. (Marlborough, USA).
+ * No restriction was found which could mention the prohibition of the use this documentation to implement a file reader.
+ *
+ * @ingroup BTKIO
+ */
+
+ /**
+ * @typedef HPFFileIO::Pointer
+ * Smart pointer associated with a HPFFileIO object.
+ */
+
+ /**
+ * @typedef HPFFileIO::ConstPointer
+ * Smart pointer associated with a const HPFFileIO object.
+ */
+
+ /**
+ * @fn static HPFFileIO::Pointer HPFFileIO::New()
+ * Create a HPFFileIO object an return it as a smart pointer.
+ */
+
+ /**
+ * Check if the beginning of the file starts with:
+ * - The value 0x1000 (Int64);
+ * - 8 bytes.
+ * - The string "datx".
+ */
+ bool HPFFileIO::CanReadFile(const std::string& filename)
+ {
+ bool isReadable = true;
+ IEEELittleEndianBinaryFileStream bifs(filename, BinaryFileStream::In);
+ int64_t chunkID = bifs.ReadI64();
+ bifs.SeekRead(8, BinaryFileStream::Current); // chunkSize
+ if ((chunkID != 0x1000) || (bifs.ReadString(4).compare("datx") != 0))
+ isReadable = false;
+ bifs.Close();
+ return isReadable;
+ };
+
+ /**
+ * Read the file designated by @a filename and fill @a output.
+ */
+ void HPFFileIO::Read(const std::string& filename, Acquisition::Pointer output)
+ {
+ output->Reset();
+ IEEELittleEndianBinaryFileStream bifs;
+ bifs.SetExceptions(BinaryFileStream::EndFileBit | BinaryFileStream::FailBit | BinaryFileStream::BadBit);
+ try
+ {
+ bifs.Open(filename, BinaryFileStream::In);
+ // Header
+ int64_t chunkID = bifs.ReadI64();
+ int64_t chunkSize = bifs.ReadI64();
+ if ((chunkID != 0x1000) || (bifs.ReadString(4).compare("datx") != 0))
+ throw HPFFileIOException("Invalid HPF file.");
+ int64_t fileVersion = bifs.ReadI64();
+ if (fileVersion != 0x10001)
+ throw HPFFileIOException("Unsupported version of the HPF file format.");
+ bifs.SeekRead(chunkSize, BinaryFileStream::Begin);
+ // Extract chunks information. For this, we look until the end of the file
+ // to find the type of chunks and their size.
+ // Only two types of chunk are extracted and the others are discarded:
+ // - Channel information chunk: 0x2000
+ // - Data chunk: 0x3000
+ const int64_t channelInfoChunkID = 0x2000;
+ const int64_t dataChunkID = 0x3000;
+ std::list<btk_hpf_chunk_info> chunks;
+ bifs.SetExceptions(BinaryFileStream::BadBit);
+ // EOF bit can be triggered by the Read* methods while FAIL can be triggered by the SeekRead method.
+ do
+ {
+ size_t chunkPosition = static_cast<size_t>(bifs.TellRead());
+ chunkID = bifs.ReadI64();
+ chunkSize = bifs.ReadI64();
+ int64_t already_read = 16;
+ if ((chunkID == channelInfoChunkID) || (chunkID == dataChunkID))
+ {
+ btk_hpf_chunk_info ci;
+ ci.position = chunkPosition;
+ ci.id = chunkID;
+ ci.size = chunkSize;
+ ci.group = bifs.ReadI32();
+ chunks.push_back(ci);
+ already_read += 4;
+ }
+ bifs.SeekRead(chunkSize - already_read, BinaryFileStream::Current);
+ } while (!bifs.EndFile());
+ // Check if only one Channel information chunk exists. Data with different time
+ // increments per channel is not supported in the library Biomechanical ToolKit.
+ btk_hpf_chunk_info* channelInfoChunk = 0;
+ for (std::list<btk_hpf_chunk_info>::iterator it = chunks.begin() ; it != chunks.end() ; ++it)
+ {
+ if (it->id == channelInfoChunkID)
+ {
+ if (channelInfoChunk == 0)
+ channelInfoChunk = &(*it);
+ else
+ throw HPFFileIOException("HPF file with more than one channel information chunk is not supported.");
+ }
+ }
+ if (channelInfoChunk == 0)
+ throw HPFFileIOException("No channel information chunk found. Impossible to configure the acqusition and the analog channels.");
+ // Set the IO exceptions as initially
+ bifs.Clear();
+ bifs.SetExceptions(BinaryFileStream::EndFileBit | BinaryFileStream::FailBit | BinaryFileStream::BadBit);
+ // Go to the chunk after the group ID
+ bifs.SeekRead(channelInfoChunk->position + 20, BinaryFileStream::Begin);
+ // Extract Channel Info
+ int32_t numAnalogChannels = bifs.ReadI32();
+ int32_t numAnalogChannelsParsed = 0;
+ double analogFrequency = -1.0;
+ // The remaining part of the chunk contains XML data
+ // The reading of the XML data is done with pugixml
+ // Depending of the configuration of BTK and pugixml, we try to avoid any memory allocation for the XML data
+ const size_t channelInfoChunkXmlDataOffset = 24;
+ size_t xmlBufferSize = channelInfoChunk->size - channelInfoChunkXmlDataOffset;
+ char* xmlBuffer = new char[xmlBufferSize];
+ bifs.ReadChar(xmlBufferSize, xmlBuffer);
+ std::string errmsg;
+ pugi::xml_document xmlDoc;
+ pugi::xml_parse_result xmlResult = xmlDoc.load_buffer_inplace(xmlBuffer, xmlBufferSize, pugi::parse_minimal, pugi::encoding_utf8);
+ if (xmlResult)
+ {
+ pugi::xml_node channels = xmlDoc.child("ChannelInformationData");
+ for (pugi::xml_node channel = channels.child("ChannelInformation"); channel; channel = channel.next_sibling("ChannelInformation"))
+ {
+ btk::Analog::Pointer an = btk::Analog::New();
+ an->SetLabel(channel.child_value("Name"));
+ an->SetUnit(channel.child_value("Unit"));
+ // In case the unit is set to the string 'Volts', it is replaced by 'V' as most of the file format use only the letter 'V'.
+ if (an->GetUnit().compare("Volts") == 0)
+ an->SetUnit("V");
+ double requestedPerChannelSampleRate = FromString<double>(channel.child_value("RequestedPerChannelSampleRate"));
+ // In some case (convertion from Delsys EMG file?), the RequestedPerChannelSampleRate is null but not the PerChannelSampleRate.
+ if (requestedPerChannelSampleRate == 0.0)
+ requestedPerChannelSampleRate = FromString<double>(channel.child_value("PerChannelSampleRate"));
+ // Be sure the sample frequency is the same for all the analog channels
+ if (analogFrequency == -1.0)
+ analogFrequency = requestedPerChannelSampleRate;
+ if (std::fabs(analogFrequency - requestedPerChannelSampleRate) > std::numeric_limits<double>::epsilon())
+ {
+ errmsg = "An acquisition cannot support multiple analog sample frequencies.";
+ break;
+ }
+ // Do not know if Delsys used another storage format than Float
+ if (strcmp(channel.child_value("DataType"), "Float") != 0)
+ {
+ errmsg = "Currently, the HPF file reader supports only data stored as float.";
+ break;
+ }
+ // To simplify the implementation of the reader, the data index is assumed sorted.
+ if (FromString<int32_t>(channel.child_value("DataIndex")) != numAnalogChannelsParsed)
+ {
+ errmsg = "Currently, the HPF file reader supports only data with a sorted index.";
+ break;
+ }
+ // Try to set the gain
+ float rangeMin = FromString<float>(channel.child_value("RangeMin"));
+ float rangeMax = FromString<float>(channel.child_value("RangeMax"));
+ if (std::fabs(rangeMin + rangeMax) < std::numeric_limits<float>::epsilon())
+ {
+ // In some case (convertion from Delsys EMG file?), the Range(Min|Max) values are null. The external gain is then extracted to try to set the analog gain.
+ if (rangeMax == 0.0f)
+ rangeMax = FromString<float>(channel.child_value("ExternalGain"));
+ an->SetGainFromValue(static_cast<int>(rangeMax * 1000.0f));
+ }
+ else
+ btkWarningMacro(filename, "Unsupported gain for the channel '" + an->GetLabel() + "': Unsymmetrical voltage range.");
+ // Append the configured analog channel into the acquisition
+ output->AppendAnalog(an);
+ ++numAnalogChannelsParsed;
+ }
+ }
+ else
+ errmsg = "Error during the parsing of the XML data: " + std::string(xmlResult.description());
+ if ((numAnalogChannelsParsed != numAnalogChannels) && errmsg.empty())
+ errmsg = "The number of analog channels parsed (" + ToString(numAnalogChannelsParsed) + ") is different than the number of channels stored in the configuration (" + ToString(numAnalogChannels) + ")";
+ delete[] xmlBuffer;
+ if (!errmsg.empty())
+ throw HPFFileIOException(errmsg);
+ // Extract the data
+ int64_t maxFrameNumber = 0;
+ for (std::list<btk_hpf_chunk_info>::iterator it = chunks.begin() ; it != chunks.end() ; ++it)
+ {
+ if (it->id != dataChunkID)
+ continue;
+ // Go to the chunk after the chunk size
+ bifs.SeekRead(it->position + 16, BinaryFileStream::Begin);
+ // Extract and verify the configuration of the chunk
+ // - Just in case the group ID is not not the same
+ if (bifs.ReadI32() != channelInfoChunk->group)
+ continue;
+ int64_t dataStartIndex = bifs.ReadI64();
+ int64_t channelDataCount = bifs.ReadI32();
+ // - If for some reason the the number of channels is greater than in the configuration, the value is bounded.
+ if (channelDataCount > numAnalogChannels)
+ channelDataCount = numAnalogChannels;
+ int32_t* channelDescriptor = new int32_t[2*channelDataCount];
+ bifs.ReadI32(2*channelDataCount, channelDescriptor);
+ // Read data
+ Acquisition::AnalogIterator itA = output->BeginAnalog();
+ for (int i = 0 ; i < channelDataCount ; ++i)
+ {
+ bifs.SeekRead(it->position + channelDescriptor[i*2], BinaryFileStream::Begin);
+ int32_t numFrames = channelDescriptor[i*2+1] / 4;
+ maxFrameNumber = std::max(maxFrameNumber, dataStartIndex + numFrames);
+ if ((*itA)->GetFrameNumber() < static_cast<int>(maxFrameNumber))
+ (*itA)->SetFrameNumber(static_cast<int>(maxFrameNumber));
+ for (int j = 0 ; j < numFrames ; ++j)
+ (*itA)->SetDataSlice(static_cast<int>(dataStartIndex+j), bifs.ReadFloat());
+ ++itA;
+ }
+ }
+ // Finalize the acquisition configuration
+ output->SetPointFrequency(analogFrequency);
+ output->Resize(0, static_cast<int>(maxFrameNumber), numAnalogChannels);
+ // The ADC resolution is not stored. It is assumed that it is a 16-bit ADC card.
+ output->SetAnalogResolution(Acquisition::Bit16);
+ // Add a metadata to notify that the first frame was not set.
+ MetaData::Pointer btkPointConfig = MetaDataCreateChild(output->GetMetaData(), "BTK_POINT_CONFIG");
+ MetaDataCreateChild(btkPointConfig, "NO_FIRST_FRAME", static_cast<int8_t>(1));
+ }
+ catch (BinaryFileStreamFailure& )
+ {
+ std::string excmsg;
+ if (bifs.EndFile())
+ excmsg = "Unexpected end of file.";
+ else if (!bifs.IsOpen())
+ excmsg = "Invalid file path.";
+ else if(bifs.Bad())
+ excmsg = "Loss of integrity of the file stream.";
+ else if(bifs.Fail())
+ excmsg = "Internal logic operation error on the stream associated with the file.";
+ else
+ excmsg = "Unknown error associated with the file stream.";
+
+ if (bifs.IsOpen()) bifs.Close();
+ throw(HPFFileIOException(excmsg));
+ }
+ catch (HPFFileIOException& )
+ {
+ if (bifs.IsOpen()) bifs.Close();
+ throw;
+ }
+ catch (std::exception& e)
+ {
+ if (bifs.IsOpen()) bifs.Close();
+ throw(HPFFileIOException("Unexpected exception occurred: " + std::string(e.what())));
+ }
+ catch(...)
+ {
+ if (bifs.IsOpen()) bifs.Close();
+ throw(HPFFileIOException("Unknown exception"));
+ }
+ };
+
+ /**
+ * Constructor.
+ */
+ HPFFileIO::HPFFileIO()
+ : AcquisitionFileIO(AcquisitionFileIO::Binary, AcquisitionFileIO::IEEE_LittleEndian, AcquisitionFileIO::Float)
+ {};
+};
diff --git a/Code/IO/btkHPFFileIO.h b/Code/IO/btkHPFFileIO.h
new file mode 100644
index 00000000..2173240d
--- /dev/null
+++ b/Code/IO/btkHPFFileIO.h
@@ -0,0 +1,79 @@
+/*
+ * The Biomechanical ToolKit
+ * Copyright (c) 2009-2014, Arnaud Barré
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * * Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer.
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials
+ * provided with the distribution.
+ * * Neither the name(s) of the copyright holders nor the names
+ * of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef __btkHPFFileIO_h
+#define __btkHPFFileIO_h
+
+#include "btkAcquisitionFileIO.h"
+#include "btkException.h"
+
+namespace btk
+{
+ class HPFFileIOException : public Exception
+ {
+ public:
+ explicit HPFFileIOException(const std::string& msg)
+ : Exception(msg)
+ {};
+
+ virtual ~HPFFileIOException() throw() {};
+ };
+
+ class HPFFileIO : public AcquisitionFileIO
+ {
+ BTK_FILE_IO_SUPPORTED_EXTENSIONS(Extension("HPF", "Delsys"));
+ BTK_FILE_IO_ONLY_READ_OPERATION;
+
+ public:
+ typedef btkSharedPtr<HPFFileIO> Pointer;
+ typedef btkSharedPtr<const HPFFileIO> ConstPointer;
+
+ static Pointer New() {return Pointer(new HPFFileIO());};
+
+ // ~HPFFileIO(); // Implicit.
+
+ BTK_IO_EXPORT virtual bool CanReadFile(const std::string& filename);
+ BTK_IO_EXPORT virtual void Read(const std::string& filename, Acquisition::Pointer output);
+
+ protected:
+ BTK_IO_EXPORT HPFFileIO();
+
+ private:
+ HPFFileIO(const HPFFileIO& ); // Not implemented.
+ HPFFileIO& operator=(const HPFFileIO& ); // Not implemented.
+ };
+};
+
+#endif // __btkHPFFileIO_h
diff --git a/Code/IO/btkKistlerDATFileIO.cpp b/Code/IO/btkKistlerDATFileIO.cpp
index 2d42d0dc..7792eb43 100644
--- a/Code/IO/btkKistlerDATFileIO.cpp
+++ b/Code/IO/btkKistlerDATFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -115,42 +115,52 @@ namespace btk
// General header?
// ---------------
- // FIXME: What is the meaning of the next 66 bytes?
- bifs.SeekRead(66, BinaryFileStream::Current);
- // 0x70: (int32) Number of channels
+ // FIXME: What is the meaning of the next 12 bytes?
+ bifs.SeekRead(12, BinaryFileStream::Current);
+ // FIXME: What are the next (numel+4)*4 bytes, seems to be a table.
+ int32_t tableDims[2];
+ bifs.ReadI32(2,tableDims);
+ int32_t numel = tableDims[0] * tableDims[1] * 4;
+ bifs.SeekRead(4, BinaryFileStream::Current); // Space?
+ bifs.SeekRead(numel, BinaryFileStream::Current); // Table data?
+ bifs.SeekRead(4, BinaryFileStream::Current); // Space again?
+ // FIXME: What is the meaning of the next 22 bytes?
+ bifs.SeekRead(22, BinaryFileStream::Current);
+ // The next offsets given in the comments start at 16+(numel+4)*4+22.
+ // 0x00: (int32) Number of channels
int numberOfChannels = bifs.ReadI32();
- // 0x74: (int32) Number of frames
+ // 0x04: (int32) Number of frames
int numberOfFrames = bifs.ReadI32();
- // 0x78: ??
+ // 0x08: ??
bifs.SeekRead(4, BinaryFileStream::Current);
- // 0x82: (int32) ADC resolution? Number of ADC channels on the board?
+ // 0x12: (int32) ADC resolution? Number of ADC channels on the board?
int digitalResolution = bifs.ReadI32();
- // 0x86: (double) Sample frequency
+ // 0x16: (double) Sample frequency
double sampleFrequency = bifs.ReadDouble();
- // 0x94: ??
+ // 0x24: ??
bifs.SeekRead(4, BinaryFileStream::Current);
- // 0x98: ??
+ // 0x28: ??
bifs.SeekRead(4, BinaryFileStream::Current);
- // 0x102: Normalized force (N) - SKIPPED
+ // 0x32: Normalized force (N) - SKIPPED
bifs.SeekRead(4, BinaryFileStream::Current);
- // 0x106: Normalized length (mm) - SKIPPED
+ // 0x36: Normalized length (mm) - SKIPPED
bifs.SeekRead(4, BinaryFileStream::Current);
- // 0x110: ??
+ // 0x40: ??
bifs.SeekRead(4, BinaryFileStream::Current);
- // 0x114: ??
+ // 0x44: ??
bifs.SeekRead(4, BinaryFileStream::Current);
- // 0x118: ??
+ // 0x48: ??
bifs.SeekRead(4, BinaryFileStream::Current);
- // 0x122: ?? (Could be an index)
+ // 0x52: ?? (Could be an index)
bifs.SeekRead(2, BinaryFileStream::Current);
- // 0x124: (int16_t) Number of characters (n) in the next string
- // 0x126: (string) What is this string? - SKIPPED
+ // 0x54: (int16_t) Number of characters (n) in the next string
+ // 0x56: (string) What is this string? - SKIPPED
bifs.SeekRead(bifs.ReadU16(), BinaryFileStream::Current);
// Force plate header?
// -------------------
// For simplification the adress in the description is reset to 0, but this is right after
- // the general header, so add 126+n to find the good position in a file.
+ // the general header, so add 94+(numel+4)*4+n to find the good position in a file.
// 0x00: ??
bifs.SeekRead(4, BinaryFileStream::Current);
// 0x04: ??
diff --git a/Code/IO/btkKistlerDATFileIO.h b/Code/IO/btkKistlerDATFileIO.h
index 19b8c2aa..3fa15ada 100644
--- a/Code/IO/btkKistlerDATFileIO.h
+++ b/Code/IO/btkKistlerDATFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkMDFFileIO.cpp b/Code/IO/btkMDFFileIO.cpp
index 9fe32bcc..cd09cc65 100644
--- a/Code/IO/btkMDFFileIO.cpp
+++ b/Code/IO/btkMDFFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkMDFFileIO.h b/Code/IO/btkMDFFileIO.h
index 170956fc..ea4358eb 100644
--- a/Code/IO/btkMDFFileIO.h
+++ b/Code/IO/btkMDFFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkMOMFileIO.cpp b/Code/IO/btkMOMFileIO.cpp
index 2df43992..54c05416 100644
--- a/Code/IO/btkMOMFileIO.cpp
+++ b/Code/IO/btkMOMFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkMOMFileIO.h b/Code/IO/btkMOMFileIO.h
index 6ba5dab4..e07752b8 100644
--- a/Code/IO/btkMOMFileIO.h
+++ b/Code/IO/btkMOMFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkMotionAnalysisFileIOUtils.cpp b/Code/IO/btkMotionAnalysisFileIOUtils.cpp
index 30f78169..1fdc7146 100644
--- a/Code/IO/btkMotionAnalysisFileIOUtils.cpp
+++ b/Code/IO/btkMotionAnalysisFileIOUtils.cpp
@@ -1,6 +1,6 @@
/**
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkMotionAnalysisFileIOUtils.h b/Code/IO/btkMotionAnalysisFileIOUtils.h
index bf07b093..4a175e94 100644
--- a/Code/IO/btkMotionAnalysisFileIOUtils.h
+++ b/Code/IO/btkMotionAnalysisFileIOUtils.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkMotionAnalysisFileIOUtils_p.cpp b/Code/IO/btkMotionAnalysisFileIOUtils_p.cpp
index b886a788..81e05675 100644
--- a/Code/IO/btkMotionAnalysisFileIOUtils_p.cpp
+++ b/Code/IO/btkMotionAnalysisFileIOUtils_p.cpp
@@ -1,6 +1,6 @@
/**
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -322,6 +322,8 @@ namespace btk
gain = Analog::PlusMinus1;
else if (gain <= Analog::PlusMinus1Dot25)
gain = Analog::PlusMinus1Dot25;
+ else if (gain <= Analog::PlusMinus1Dot65)
+ gain = Analog::PlusMinus1Dot65;
else if (gain <= Analog::PlusMinus2Dot5)
gain = Analog::PlusMinus2Dot5;
else if (gain <= Analog::PlusMinus5)
@@ -336,37 +338,14 @@ namespace btk
uint16_t range;
switch(gain) // range is in mV
{
- case Analog::PlusMinus10:
- range = 10000;
- break;
- case Analog::PlusMinus5:
- range = 5000;
- break;
- case Analog::PlusMinus2Dot5:
- range = 2500;
- break;
- case Analog::PlusMinus1Dot25:
- range = 1250;
- break;
- case Analog::PlusMinus1:
- range = 1000;
- break;
- case Analog::PlusMinus0Dot5:
- range = 500;
- break;
- case Analog::PlusMinus0Dot25:
- range = 250;
- break;
- case Analog::PlusMinus0Dot1:
- range = 100;
- break;
- case Analog::PlusMinus0Dot05:
- range = 50;
- break;
case Analog::Unknown:
range = ANxFileIODetectAnalogRange_p(scale, bitDepth);
btkWarningMacro("Unknown gain for channel #" + ToString(idx+1) + ". Automatically replaced by +/- " + ToString(static_cast<double>(range) / 1000) + " volts in the file. Could corrupt the data in the written file!");
break;
+ default:
+ // The given gain corresponds to the range. See the values for the Analog::Gain enumation
+ range = static_cast<uint16_t>(gain);
+ break;
}
return range;
};
diff --git a/Code/IO/btkMotionAnalysisFileIOUtils_p.h b/Code/IO/btkMotionAnalysisFileIOUtils_p.h
index e2b4b02c..d4c092d6 100644
--- a/Code/IO/btkMotionAnalysisFileIOUtils_p.h
+++ b/Code/IO/btkMotionAnalysisFileIOUtils_p.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkMultiSTLFileWriter.cpp b/Code/IO/btkMultiSTLFileWriter.cpp
index 88e778d5..f4018364 100644
--- a/Code/IO/btkMultiSTLFileWriter.cpp
+++ b/Code/IO/btkMultiSTLFileWriter.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkMultiSTLFileWriter.h b/Code/IO/btkMultiSTLFileWriter.h
index f67138d6..5449abe7 100644
--- a/Code/IO/btkMultiSTLFileWriter.h
+++ b/Code/IO/btkMultiSTLFileWriter.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkPWRFileIO.cpp b/Code/IO/btkPWRFileIO.cpp
index 0ebf03ae..44cf879a 100644
--- a/Code/IO/btkPWRFileIO.cpp
+++ b/Code/IO/btkPWRFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkPWRFileIO.h b/Code/IO/btkPWRFileIO.h
index 5d8fd7b4..1787d2a4 100644
--- a/Code/IO/btkPWRFileIO.h
+++ b/Code/IO/btkPWRFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkRAxFileIO.cpp b/Code/IO/btkRAxFileIO.cpp
index 7ced16b8..47c06b1c 100644
--- a/Code/IO/btkRAxFileIO.cpp
+++ b/Code/IO/btkRAxFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkRAxFileIO.h b/Code/IO/btkRAxFileIO.h
index ebf313bd..ec690438 100644
--- a/Code/IO/btkRAxFileIO.h
+++ b/Code/IO/btkRAxFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkRICFileIO.cpp b/Code/IO/btkRICFileIO.cpp
index 4634977d..5dd2bc9a 100644
--- a/Code/IO/btkRICFileIO.cpp
+++ b/Code/IO/btkRICFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkRICFileIO.h b/Code/IO/btkRICFileIO.h
index c39a0dd6..c74175f8 100644
--- a/Code/IO/btkRICFileIO.h
+++ b/Code/IO/btkRICFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkTDFFileIO.cpp b/Code/IO/btkTDFFileIO.cpp
index 62444f72..d77486b9 100644
--- a/Code/IO/btkTDFFileIO.cpp
+++ b/Code/IO/btkTDFFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkTDFFileIO.h b/Code/IO/btkTDFFileIO.h
index fc5e1396..71b97438 100644
--- a/Code/IO/btkTDFFileIO.h
+++ b/Code/IO/btkTDFFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkTRBFileIO.cpp b/Code/IO/btkTRBFileIO.cpp
index 436671b8..7a7d2b2e 100644
--- a/Code/IO/btkTRBFileIO.cpp
+++ b/Code/IO/btkTRBFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -40,6 +40,7 @@
#include <algorithm>
#include <cctype>
#include <vector>
+#include <map>
namespace btk
{
@@ -228,16 +229,17 @@ namespace btk
// Construct a vector of indices to facilitate the coordinates' extraction
// And set the markers' label
// All the residuals are set to -1 by default
- std::vector<int> markerIndex = std::vector<int>(numMarkers, -1);
+ std::map<int,Point::Pointer> markerIndexMap;
Point::Residuals res = Point::Residuals::Constant(numFrames,1,-1.0);
for (int i = 0 ; i < static_cast<int>(indices.size()) ; ++i)
{
Point::Pointer pt = output->GetPoint(i);
pt->SetLabel(labels[i]);
pt->SetResiduals(res);
- markerIndex[indices[i]] = i;
+ markerIndexMap.insert(std::make_pair(indices[i],pt));
}
// Extract coordinates
+ bool extraMarkerFound = false;
while (1)
{
bifs.SeekRead(6, BinaryFileStream::Current); // 0x0000 00000 06000
@@ -250,7 +252,20 @@ namespace btk
{
while (1)
{
- Point::Pointer point = output->GetPoint(markerIndex[bifs.ReadU16()-1]);
+ Point::Pointer point;
+ int idx = bifs.ReadU16()-1;
+ std::map<int,Point::Pointer>::iterator itM = markerIndexMap.find(idx);
+ if (itM == markerIndexMap.end())
+ {
+ extraMarkerFound = true;
+ point = Point::New("uname*" + ToString(idx+1), numFrames);
+ output->AppendPoint(point);
+ markerIndexMap.insert(std::make_pair(idx,point));
+ }
+ else
+ {
+ point = itM->second;
+ }
bifs.SeekRead(2, BinaryFileStream::Current); // 0x0000
point->GetValues().coeffRef(index,0) = bifs.ReadFloat(); // X
point->GetValues().coeffRef(index,1) = bifs.ReadFloat(); // Y
@@ -265,6 +280,9 @@ namespace btk
if (dataSizeBis <= 0)
break;
}
+ if (extraMarkerFound)
+ btkWarningMacro(filename, "At least one extra marker was found in the data but was not specified in the label table.");
+
}
catch (BinaryFileStreamFailure& )
{
diff --git a/Code/IO/btkTRBFileIO.h b/Code/IO/btkTRBFileIO.h
index 0038fb2b..51ca2617 100644
--- a/Code/IO/btkTRBFileIO.h
+++ b/Code/IO/btkTRBFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkTRCFileIO.cpp b/Code/IO/btkTRCFileIO.cpp
index 6b922d21..2c73ddcd 100644
--- a/Code/IO/btkTRCFileIO.cpp
+++ b/Code/IO/btkTRCFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkTRCFileIO.h b/Code/IO/btkTRCFileIO.h
index 701a1ceb..ee87db1f 100644
--- a/Code/IO/btkTRCFileIO.h
+++ b/Code/IO/btkTRCFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkXLSOrthoTrakFileIO.cpp b/Code/IO/btkXLSOrthoTrakFileIO.cpp
index 975708d2..ab572181 100644
--- a/Code/IO/btkXLSOrthoTrakFileIO.cpp
+++ b/Code/IO/btkXLSOrthoTrakFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -241,16 +241,19 @@ namespace btk
double* values = new double[valueNumber];
std::string strVal;
int i = 0;
- for (i = 0 ; i < valueNumber ; ++i)
+ for (i = 0 ; i < frameNumber ; ++i)
{
- ifs >> strVal;
- if (ifs.eof() || strVal.empty())
+ std::getline(ifs, line);
+ if (ifs.eof())
{
btkWarningMacro(filename, "File corrupted. There is not enough values to fill data. Others values will be set to 0.");
break;
}
- FromString(strVal, values[i]);
+ iss.str(line); iss.clear();
+ for (int j = 0 ; j < colNumber ; ++j)
+ iss >> values[i*colNumber+j];
}
+ i *= colNumber;
for (int j = i ; j < valueNumber ; ++j)
values[j] = 0.0;
@@ -443,12 +446,8 @@ namespace btk
std::string buf;
*iss >> buf; // label
double frame;
- do
- {
- *iss >> frame;
+ while(!iss->eof() && (*iss >> frame))
output->AppendEvent(Event::New(label, static_cast<int>(frame) + output->GetFirstFrame(), context, Event::Unknown, "", "", id));
- }
- while(!iss->eof());
};
void XLSOrthoTrakFileIO::ExtractEventDetectionFlag(Acquisition::Pointer output, std::istringstream* iss, const std::string& label, const std::string& context)
@@ -458,9 +457,8 @@ namespace btk
*iss >> buf; // label
*iss >> buf; // FP
double frame;
- do
+ while(!iss->eof() && (*iss >> frame))
{
- *iss >> frame;
for (Acquisition::EventIterator it = output->BeginEvent() ; it != output->EndEvent() ; ++it)
{
if (((*it)->GetLabel().compare(label) == 0)
@@ -472,7 +470,6 @@ namespace btk
}
}
}
- while(!iss->eof());
};
void XLSOrthoTrakFileIO::AppendSpatiotemparalParameter(MetaData::Pointer st, std::istringstream* iss, double scale)
@@ -483,12 +480,8 @@ namespace btk
std::vector<float> values;
*iss >> name;
float s = static_cast<float>(scale);
- do
- {
- *iss >> val;
+ while (!iss->eof() && (*iss >> val))
values.push_back(val * s);
- }
- while (!iss->eof());
MetaDataCreateChild(st, name, values);
};
diff --git a/Code/IO/btkXLSOrthoTrakFileIO.h b/Code/IO/btkXLSOrthoTrakFileIO.h
index 49da40b6..1a69f031 100644
--- a/Code/IO/btkXLSOrthoTrakFileIO.h
+++ b/Code/IO/btkXLSOrthoTrakFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkXMOVEFileIO.cpp b/Code/IO/btkXMOVEFileIO.cpp
index 17fcc9e6..db3cbc9b 100644
--- a/Code/IO/btkXMOVEFileIO.cpp
+++ b/Code/IO/btkXMOVEFileIO.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Code/IO/btkXMOVEFileIO.h b/Code/IO/btkXMOVEFileIO.h
index 528144ff..d891f114 100644
--- a/Code/IO/btkXMOVEFileIO.h
+++ b/Code/IO/btkXMOVEFileIO.h
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Copyright.txt b/Copyright.txt
index 1db693ea..b185ef0a 100644
--- a/Copyright.txt
+++ b/Copyright.txt
@@ -1,5 +1,5 @@
The Biomechanical ToolKit
-Copyright (c) 2009-2013, Arnaud Barré
+Copyright (c) 2009-2014, Arnaud Barré
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/Documentation/API/FileFormatSupported.dox b/Documentation/API/FileFormatSupported.dox
index 1744af98..ea295e7e 100644
--- a/Documentation/API/FileFormatSupported.dox
+++ b/Documentation/API/FileFormatSupported.dox
@@ -91,6 +91,13 @@
<td style="border: 1px solid #aaa; padding: 5px;"> <p align="center">@endhtmlonly btk::GRxFileIO @htmlonly</p> </td>
<td style="border: 1px solid #aaa; padding: 5px;"> <i>BTS Bioengineering (Elite)</i> binary file format containing force platform data. Supports only platforms of type I</td>
</tr>
+ <tr>
+ <td style="border: 1px solid #aaa; padding: 5px;"> HPF </td>
+ <td style="border: 1px solid #aaa; padding: 5px;"> <p align="center"><strong>x</strong></p> </td>
+ <td style="border: 1px solid #aaa; padding: 5px;"> </td>
+ <td style="border: 1px solid #aaa; padding: 5px;"> <p align="center">@endhtmlonly btk::HPFFileIO @htmlonly</p> </td>
+ <td style="border: 1px solid #aaa; padding: 5px;"> <i>Delsys Inc.</i> binary file format containing analog data (EMG, accelerometer)</td>
+ </tr>
<tr>
<td style="border: 1px solid #aaa; padding: 5px;"> MDF </td>
<td style="border: 1px solid #aaa; padding: 5px;"> <p align="center"><strong>x</strong></p> </td>
diff --git a/Documentation/Readme/License.dox.part b/Documentation/Readme/License.dox.part
index d91f182a..46ee820b 100644
--- a/Documentation/Readme/License.dox.part
+++ b/Documentation/Readme/License.dox.part
@@ -6,7 +6,7 @@ in commercial products. The complete text of the copyright follows.
@verbatim
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Documentation/Wrapping/Matlab/Web/FAQ.dox b/Documentation/Wrapping/Matlab/Web/FAQ.dox
index 830b884b..96afb8c9 100644
--- a/Documentation/Wrapping/Matlab/Web/FAQ.dox
+++ b/Documentation/Wrapping/Matlab/Web/FAQ.dox
@@ -27,7 +27,7 @@
@verbatim
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Documentation/Wrapping/Matlab/btk/@BasicFilters/btkGetForcePlatformWrenches.m b/Documentation/Wrapping/Matlab/btk/@BasicFilters/btkGetForcePlatformWrenches.m
index 8dc21d35..b2550b23 100644
--- a/Documentation/Wrapping/Matlab/btk/@BasicFilters/btkGetForcePlatformWrenches.m
+++ b/Documentation/Wrapping/Matlab/btk/@BasicFilters/btkGetForcePlatformWrenches.m
@@ -21,7 +21,7 @@ function FPW = btkGetForcePlatformWrenches(h, threshold) %#ok
% only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@BasicFilters/btkGetGroundReactionWrenches.m b/Documentation/Wrapping/Matlab/btk/@BasicFilters/btkGetGroundReactionWrenches.m
index e7d39683..460cf4f6 100644
--- a/Documentation/Wrapping/Matlab/btk/@BasicFilters/btkGetGroundReactionWrenches.m
+++ b/Documentation/Wrapping/Matlab/btk/@BasicFilters/btkGetGroundReactionWrenches.m
@@ -20,7 +20,7 @@ function GRW = btkGetGroundReactionWrenches(h, threshold) %#ok
% given THRESHOLD value (in newton) to the position (0,0,0).
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@BasicFilters/btkMergeAcquisitions.m b/Documentation/Wrapping/Matlab/btk/@BasicFilters/btkMergeAcquisitions.m
index dcc2b5da..b7c17763 100644
--- a/Documentation/Wrapping/Matlab/btk/@BasicFilters/btkMergeAcquisitions.m
+++ b/Documentation/Wrapping/Matlab/btk/@BasicFilters/btkMergeAcquisitions.m
@@ -41,7 +41,7 @@ function acq = btkMergeAcquisitions(acq1, acq2, ...) %#ok
% suffix (i.e. from STATIC_CALIBRATION:USED to STATIC_CALIBRATION:USED_2)
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkAppendAnalog.m b/Documentation/Wrapping/Matlab/btk/@Common/btkAppendAnalog.m
index 55b3bf03..ec7ba451 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkAppendAnalog.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkAppendAnalog.m
@@ -22,7 +22,7 @@ function btkAppendAnalog(h, label, valuesdesc) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkAppendAnalysisParameter.m b/Documentation/Wrapping/Matlab/btk/@Common/btkAppendAnalysisParameter.m
index 4d0955ed..8763496e 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkAppendAnalysisParameter.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkAppendAnalysisParameter.m
@@ -27,7 +27,7 @@ function btkAppendAnalysisParameter(h, name, context, unit, value, subject, desc
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkAppendEvent.m b/Documentation/Wrapping/Matlab/btk/@Common/btkAppendEvent.m
index 130aa0ef..cb6e5ef1 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkAppendEvent.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkAppendEvent.m
@@ -38,7 +38,7 @@ function btkAppendEvent(h, label, time, context, subject, description, id) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkAppendMetaData.m b/Documentation/Wrapping/Matlab/btk/@Common/btkAppendMetaData.m
index e67b6115..43774105 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkAppendMetaData.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkAppendMetaData.m
@@ -29,7 +29,7 @@ function btkAppendMetaData(h, label, sublabel, ..., info) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkAppendPoint.m b/Documentation/Wrapping/Matlab/btk/@Common/btkAppendPoint.m
index 3a8ce591..8c57f129 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkAppendPoint.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkAppendPoint.m
@@ -39,7 +39,7 @@ function btkAppendPoint(h, type, label, values, residuals desc) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkClearAnalogs.m b/Documentation/Wrapping/Matlab/btk/@Common/btkClearAnalogs.m
index 6786aef9..f1553af6 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkClearAnalogs.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkClearAnalogs.m
@@ -8,7 +8,7 @@ function btkClearAnalogs(h) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkClearAnalysis.m b/Documentation/Wrapping/Matlab/btk/@Common/btkClearAnalysis.m
index b4187864..350973ca 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkClearAnalysis.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkClearAnalysis.m
@@ -12,7 +12,7 @@ function btkClearAnalysis(h) %#ok
% and <a href="matlab:help btkRemoveAnalysisParameter">btkRemoveAnalysisParameter</a> to set analysis' parameters.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkClearEvents.m b/Documentation/Wrapping/Matlab/btk/@Common/btkClearEvents.m
index 17803851..69074835 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkClearEvents.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkClearEvents.m
@@ -8,7 +8,7 @@ function btkClearEvents(h) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkClearMetaData.m b/Documentation/Wrapping/Matlab/btk/@Common/btkClearMetaData.m
index 16db5709..8740e6c6 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkClearMetaData.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkClearMetaData.m
@@ -8,7 +8,7 @@ function btkClearMetaData(h) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkClearPoints.m b/Documentation/Wrapping/Matlab/btk/@Common/btkClearPoints.m
index d97ab97b..86b402ff 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkClearPoints.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkClearPoints.m
@@ -8,7 +8,7 @@ function btkClearPoints(h) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkCloneAcquisition.m b/Documentation/Wrapping/Matlab/btk/@Common/btkCloneAcquisition.m
index 2f14a367..d76d79b8 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkCloneAcquisition.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkCloneAcquisition.m
@@ -13,7 +13,7 @@ function hc = btkCloneAcquisition(ho) %#ok
% memory and an "Out of memory" error could be thrown.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkDeleteAcquisition.m b/Documentation/Wrapping/Matlab/btk/@Common/btkDeleteAcquisition.m
index e5c1171f..267a08bd 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkDeleteAcquisition.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkDeleteAcquisition.m
@@ -19,7 +19,7 @@ function btkDeleteAcquisition(h) %#ok
% btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalog.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalog.m
index 9ceb1966..b19ca809 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalog.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalog.m
@@ -25,7 +25,7 @@ function [values info] = btkGetAnalog(h) %#ok
% [VALUES, INFO] = BTKGETANALOG(H, LABEL)
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogFrameNumber.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogFrameNumber.m
index 3a228178..ad46b767 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogFrameNumber.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogFrameNumber.m
@@ -6,7 +6,7 @@ function afn = btkGetAnalogFrameNumber(h) %#ok
% btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogNumber.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogNumber.m
index 68ab57a9..8f6a5ff8 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogNumber.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogNumber.m
@@ -6,7 +6,7 @@ function an = btkGetAnalogNumber(h) %#ok
% btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogResolution.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogResolution.m
index 45c0d5c1..5cf58119 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogResolution.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogResolution.m
@@ -6,7 +6,7 @@ function ar = btkGetAnalogResolution(h) %#ok
% This handle is obtained by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogSampleNumberPerFrame.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogSampleNumberPerFrame.m
index ede2df15..86d3bb94 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogSampleNumberPerFrame.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogSampleNumberPerFrame.m
@@ -7,7 +7,7 @@ function ratio = btkGetAnalogSampleNumberPerFrame(h) %#ok
% use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogs.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogs.m
index 3e86a92b..bbe04bd6 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogs.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogs.m
@@ -27,7 +27,7 @@ function [analogs analogsInfo] = btkGetAnalogs(h) %#ok
% corresponds to adapted analog channel's label.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogsValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogsValues.m
index 9c7bf040..9fc9260e 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogsValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalogsValues.m
@@ -8,7 +8,7 @@ function av = btkGetAnalogsValues(h) %#ok
% be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalysis.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalysis.m
index a792282b..14505a34 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalysis.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnalysis.m
@@ -15,7 +15,7 @@ function [analysis analysisInfo] = btkGetAnalysis(h) %#ok
% ANALYSISINFO.UNITS contains the unit of each parameter.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAngles.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAngles.m
index ff0b0af8..0254294a 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAngles.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAngles.m
@@ -15,7 +15,7 @@ function [angles anglesInfo] = btkGetAngles(h) %#ok
% corresponds to angle's label.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnglesValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnglesValues.m
index f69e6301..dcac8e5c 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnglesValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetAnglesValues.m
@@ -9,7 +9,7 @@ function v = btkGetAnglesValues(h) %#ok
% and can be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetEvents.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetEvents.m
index 9c4183d8..6c4df6bc 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetEvents.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetEvents.m
@@ -23,7 +23,7 @@ function [events eventsInfo] = btkGetEvents(h) %#ok
% event. EVENTSINFO.UNITS contains the unit of each event.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetEventsValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetEventsValues.m
index 311bbe3b..84eef764 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetEventsValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetEventsValues.m
@@ -19,7 +19,7 @@ function [times, labels, descriptions, ids] = btkGetEventsValuesValues(h) %#ok
% the id associated with each event.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetFirstFrame.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetFirstFrame.m
index 5e026fb3..e9afc701 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetFirstFrame.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetFirstFrame.m
@@ -6,7 +6,7 @@ function ff = btkGetFirstFrame(h) %#ok
% btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetForcePlatforms.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetForcePlatforms.m
index e6a05cd4..4c21b111 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetForcePlatforms.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetForcePlatforms.m
@@ -32,7 +32,7 @@ function [forceplates forceplatesInfo] = btkGetForcePlatforms(h) %#ok
% matrix is only used with supported force platform type.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetForces.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetForces.m
index 2938d596..fa21d75e 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetForces.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetForces.m
@@ -15,7 +15,7 @@ function [forces forcesInfo] = btkGetForces(h) %#ok
% corresponds to force's label.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetForcesValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetForcesValues.m
index 0ac91475..25aa4726 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetForcesValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetForcesValues.m
@@ -9,7 +9,7 @@ function v = btkGetForcesValues(h) %#ok
% and can be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetMarkers.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetMarkers.m
index e4cfbd46..1d2058df 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetMarkers.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetMarkers.m
@@ -19,7 +19,7 @@ function [markers markersInfo] = btkGetMarkers(h) %#ok
% MARKERSRESIDUAL corresponds to a marker's label.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetMarkersValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetMarkersValues.m
index 589c0a99..e70376b5 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetMarkersValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetMarkersValues.m
@@ -9,7 +9,7 @@ function v = btkGetMarkersValues(h) %#ok
% be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetMaxInterpolationGap.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetMaxInterpolationGap.m
index 68e24b3e..d4e7b832 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetMaxInterpolationGap.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetMaxInterpolationGap.m
@@ -6,7 +6,7 @@ function gap = btkGetMaxInterpolationGap(h) %#ok
% obtained by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetMetaData.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetMetaData.m
index f6952617..7d21825b 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetMetaData.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetMetaData.m
@@ -35,7 +35,7 @@ function btkGetMetaData(h) %#ok
% By default, BTK, use two stages of metadata representing group and parameters.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetMoments.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetMoments.m
index af19f845..6c317cea 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetMoments.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetMoments.m
@@ -15,7 +15,7 @@ function [moments momentsInfo] = btkGetMoments(h) %#ok
% corresponds to moment's label.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetMomentsValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetMomentsValues.m
index 603d1fc7..1798bc27 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetMomentsValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetMomentsValues.m
@@ -9,7 +9,7 @@ function mv = btkGetMomentsValues(h) %#ok
% be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPoint.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPoint.m
index 6613d07f..ea5080f2 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPoint.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPoint.m
@@ -25,7 +25,7 @@ function btkGetPoint(h, idx_or_label) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointFrameNumber.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointFrameNumber.m
index 9661c48a..cb05c538 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointFrameNumber.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointFrameNumber.m
@@ -6,7 +6,7 @@ function pfn = btkGetPointFrameNumber(h) %#ok
% btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointFrequency.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointFrequency.m
index deb46312..2d50f001 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointFrequency.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointFrequency.m
@@ -6,7 +6,7 @@ function pf = btkGetPointFrequency(h) %#ok
% btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechafical ToolKit (BTK).
+% Copyright 2009-2014 Biomechafical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointNumber.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointNumber.m
index b837fb60..3af76ea3 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointNumber.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointNumber.m
@@ -6,7 +6,7 @@ function pn = btkGetPointNumber(h) %#ok
% btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPoints.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPoints.m
index afb3038b..0aec5c18 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPoints.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPoints.m
@@ -26,7 +26,7 @@ function [points pointsInfo] = btkGetPoints(h) %#ok
% POINTSINFO.UNITS, and POINTSINFO.RESIDUALS corresponds to point's label.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointsResiduals.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointsResiduals.m
index f1990c56..6d748f90 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointsResiduals.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointsResiduals.m
@@ -8,7 +8,7 @@ function r = btkGetPointsResiduals(h) %#ok
% and can be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointsUnit.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointsUnit.m
index f6f8800f..ac3a261e 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointsUnit.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointsUnit.m
@@ -22,7 +22,7 @@ function unit = btkGetPointsUnit(h, type) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointsValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointsValues.m
index a7c9e500..7309760d 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointsValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPointsValues.m
@@ -9,7 +9,7 @@ function v = btkGetPointsValues(h) %#ok
% and can be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPowers.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPowers.m
index a6b53a82..f2af2825 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPowers.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPowers.m
@@ -15,7 +15,7 @@ function [powers powersInfo] = btkGetPowers(h) %#ok
% corresponds to power's label.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPowersValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPowersValues.m
index 17d0c63c..dfffe9d6 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetPowersValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetPowersValues.m
@@ -9,7 +9,7 @@ function v = btkGetPowersValues(h) %#ok
% and can be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetScalars.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetScalars.m
index 2bbb0f16..9508807c 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetScalars.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetScalars.m
@@ -15,7 +15,7 @@ function [scalars scalarsInfo] = btkGetScalars(h) %#ok
% corresponds to scalar's label.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkGetScalarsValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkGetScalarsValues.m
index 7e7c7c5e..57d3b911 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkGetScalarsValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkGetScalarsValues.m
@@ -9,7 +9,7 @@ function v = btkGetScalarsValues(h) %#ok
% and can be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkNewAcquisition.m b/Documentation/Wrapping/Matlab/btk/@Common/btkNewAcquisition.m
index 4aede8e0..a3f135c4 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkNewAcquisition.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkNewAcquisition.m
@@ -40,7 +40,7 @@ function h = btkNewAcquisition(pn, fn, an, r) %#ok
% memory and an "Out of memory" error could be thrown.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveAnalog.m b/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveAnalog.m
index 43d9b0c8..d27eeb0b 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveAnalog.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveAnalog.m
@@ -24,7 +24,7 @@ function btkRemoveAnalog(h, idx_or_label) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveAnalysisParameter.m b/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveAnalysisParameter.m
index f21c7073..6983fedb 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveAnalysisParameter.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveAnalysisParameter.m
@@ -20,7 +20,7 @@ function btkRemoveAnalysisParameter(h, idx_or_context, name) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveEvent.m b/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveEvent.m
index 250c1562..f626c7f9 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveEvent.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveEvent.m
@@ -29,7 +29,7 @@ function btkRemoveEvent(h, options) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveMetaData.m b/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveMetaData.m
index 183dd445..0df5060c 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveMetaData.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkRemoveMetaData.m
@@ -28,7 +28,7 @@ function btkRemoveMetaData(h, label_idx, sublabel_idx, ...) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkRemovePoint.m b/Documentation/Wrapping/Matlab/btk/@Common/btkRemovePoint.m
index e8e366aa..2197882d 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkRemovePoint.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkRemovePoint.m
@@ -20,7 +20,7 @@ function btkRemovePoint(h, idx_or_label) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogDescription.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogDescription.m
index 9ca45480..d016cf3c 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogDescription.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogDescription.m
@@ -21,7 +21,7 @@ function btkSetAnalogDescription(h, idx_or_label, new_desc) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogGain.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogGain.m
index 639ca953..b759cbfd 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogGain.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogGain.m
@@ -27,7 +27,7 @@ function btkSetAnalogGain(h, idx_or_label, new_gain) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogLabel.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogLabel.m
index 43428175..35f79256 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogLabel.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogLabel.m
@@ -21,7 +21,7 @@ function btkSetAnalogLabel(h, idx_or_label, new_label) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogNumber.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogNumber.m
index 1886377d..c3d88ac5 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogNumber.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogNumber.m
@@ -6,7 +6,7 @@ function btkSetAnalogNumber(h, pn) %#ok
% the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogOffset.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogOffset.m
index 8f9db2a1..fbeffa03 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogOffset.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogOffset.m
@@ -22,7 +22,7 @@ function btkSetAnalogOffset(h, idx_or_label, new_offset) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogResolution.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogResolution.m
index c72385c5..94900fec 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogResolution.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogResolution.m
@@ -7,7 +7,7 @@ function btkSetAnalogResolution(h, res) %#ok
% a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogSampleNumberPerFrame.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogSampleNumberPerFrame.m
index 14b88532..e6837f22 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogSampleNumberPerFrame.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogSampleNumberPerFrame.m
@@ -9,7 +9,7 @@ function btkSetAnalogSampleNumberPerFrame(h, ratio) %#ok
% a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogScale.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogScale.m
index c1d30625..281f1a2c 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogScale.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogScale.m
@@ -22,7 +22,7 @@ function btkSetAnalogScale(h, idx_or_label, newscale) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogUnit.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogUnit.m
index b4b75c6c..7aeaae87 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogUnit.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogUnit.m
@@ -21,7 +21,7 @@ function btkSetAnalogUnit(h, idx_or_label, new_unit) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogValues.m
index 71e0a2fa..f49aec1e 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogValues.m
@@ -22,7 +22,7 @@ function btkSetAnalogValues(h, idx_or_label, values) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogsValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogsValues.m
index d1f311ba..ce462e44 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogsValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnalogsValues.m
@@ -8,7 +8,7 @@ function btkSetAnalogsValues(h, v) %#ok
% be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnglesValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnglesValues.m
index fbeea388..1535db3e 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnglesValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetAnglesValues.m
@@ -9,7 +9,7 @@ function btkSetAnglesValues(h, v) %#ok
% only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventDescription.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventDescription.m
index 42e1f0a9..e7a25ce7 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventDescription.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventDescription.m
@@ -16,7 +16,7 @@ function btkSetEventDescription(h, label, new_description) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventId.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventId.m
index 08d5ac9a..4c3bc823 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventId.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventId.m
@@ -24,7 +24,7 @@ function btkSetEventId(h, label, newid) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventLabel.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventLabel.m
index db6aa2f6..aec5b97b 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventLabel.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventLabel.m
@@ -16,7 +16,7 @@ function btkSetEventLabel(h, index, newlabel) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventSubject.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventSubject.m
index 354cb5a7..0ddc093b 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventSubject.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventSubject.m
@@ -16,7 +16,7 @@ function btkSetEventSubject(h, index, newSubject) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventTime.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventTime.m
index 7fce8d8a..0e4033dd 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventTime.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetEventTime.m
@@ -16,7 +16,7 @@ function btkSetEventTime(h, index, newtime) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetFirstFrame.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetFirstFrame.m
index fcc0d43a..3a98e89d 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetFirstFrame.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetFirstFrame.m
@@ -12,7 +12,7 @@ function btkSetFirstFrame(h, ff, adaptEvents) %#ok
% point's frequency.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetForcesValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetForcesValues.m
index 39b9964e..f26be4da 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetForcesValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetForcesValues.m
@@ -9,7 +9,7 @@ function btkSetForcesValues(h, v) %#ok
% be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetFrameNumber.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetFrameNumber.m
index a4a534f1..21391f43 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetFrameNumber.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetFrameNumber.m
@@ -11,7 +11,7 @@ function btkSetFrameNumber(h, num) %#ok
% by the product R * NUM. R must be an integer greater or equal than 1.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetFrequency.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetFrequency.m
index 8f12c05c..1440ffdc 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetFrequency.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetFrequency.m
@@ -6,7 +6,7 @@ function btkSetFrequency(h, freq) %#ok
% This handle is obtained by using a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMarkersValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMarkersValues.m
index aca238a9..52e7dd09 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMarkersValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMarkersValues.m
@@ -9,7 +9,7 @@ function btkSetMarkersValues(h, v) %#ok
% be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMaxInterpolationGap.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMaxInterpolationGap.m
index a8aae6df..e9ac88ca 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMaxInterpolationGap.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMaxInterpolationGap.m
@@ -6,7 +6,7 @@ function btkSetMaxInterpolationGap(h, gap) %#ok
% This handle must be obtained by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataDescription.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataDescription.m
index 6b97e509..190c5f6a 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataDescription.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataDescription.m
@@ -28,7 +28,7 @@ function btkSetMetaDataDescription(h, label_idx, sublabel_idx, ..., newDescripti
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataDimensions.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataDimensions.m
index 08bb66a0..2dd9dc2b 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataDimensions.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataDimensions.m
@@ -28,7 +28,7 @@ function btkSetMetaDataDimensions(h, label_idx, sublabel_idx, ..., newdims) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataFormat.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataFormat.m
index 0fc578fd..5236723e 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataFormat.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataFormat.m
@@ -39,7 +39,7 @@ function btkSetMetaDataFormat(h, label_idx, sublabel_idx, ..., newFormat) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataLabel.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataLabel.m
index c91a3a3c..381faa8e 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataLabel.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataLabel.m
@@ -32,7 +32,7 @@ function btkSetMetaDataLabel(h, label_idx, sublabel_idx, ..., newlabel) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataUnlock.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataUnlock.m
index 8e9f5796..eee64fa6 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataUnlock.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataUnlock.m
@@ -29,7 +29,7 @@ function btkSetMetaDataUnlock(h, label_idx, sublabel_idx, ..., isunlocked) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataValue.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataValue.m
index bbf32c54..9aea9c0d 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataValue.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMetaDataValue.m
@@ -32,7 +32,7 @@ function btkSetMetaDataValue(h, label_idx, sublabel_idx, ..., index, value) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMomentsValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMomentsValues.m
index 246d308f..ab7d7183 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetMomentsValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetMomentsValues.m
@@ -9,7 +9,7 @@ function btkSetMomentsValues(h. v) %#ok
% be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPoint.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPoint.m
index 970b8cf8..91c3cd4e 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPoint.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPoint.m
@@ -41,7 +41,7 @@ function btkSetPoint(h, idx_or_label, values, residuals) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointDescription.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointDescription.m
index f2dc0af2..16e6a19c 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointDescription.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointDescription.m
@@ -21,7 +21,7 @@ function btkSetPointDescription(h, idx_or_label, new_desc) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointLabel.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointLabel.m
index 507a27c1..10ebd54a 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointLabel.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointLabel.m
@@ -21,7 +21,7 @@ function btkSetPointLabel(h, idx_or_label, new_label) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointNumber.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointNumber.m
index 9c343bac..db642a1b 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointNumber.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointNumber.m
@@ -6,7 +6,7 @@ function btkSetPointNumber(h, pn) %#ok
% use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointResiduals.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointResiduals.m
index 15e67382..ad063c89 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointResiduals.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointResiduals.m
@@ -11,7 +11,7 @@ function btkSetPointResiduals(h, idx_or_abel, r) %#ok
% to modify.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointType.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointType.m
index 03afb113..86156f78 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointType.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointType.m
@@ -29,7 +29,7 @@ function btkSetPointType(h, idx_or_label, new_type) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointValues.m
index 03f34563..831f1850 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointValues.m
@@ -12,7 +12,7 @@ function btkSetPointValues(h, idx_or_label, v) %#ok
% to modify.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointsResiduals.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointsResiduals.m
index f0c7dc2d..77d7a643 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointsResiduals.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointsResiduals.m
@@ -8,7 +8,7 @@ function btkSetPointsResiduals(h. r) %#ok
% be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointsUnit.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointsUnit.m
index f62579db..336e68c3 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointsUnit.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointsUnit.m
@@ -22,7 +22,7 @@ function btkSetPointsUnit(h, type, unit) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointsValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointsValues.m
index 43650622..73ff48bc 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointsValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPointsValues.m
@@ -9,7 +9,7 @@ function btkSetPointsValues(h. v) %#ok
% be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPowersValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPowersValues.m
index 387ca336..cc11f52f 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetPowersValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetPowersValues.m
@@ -9,7 +9,7 @@ function btkSetPowersValues(h. v) %#ok
% be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@Common/btkSetScalarsValues.m b/Documentation/Wrapping/Matlab/btk/@Common/btkSetScalarsValues.m
index a5f46949..58aadb92 100644
--- a/Documentation/Wrapping/Matlab/btk/@Common/btkSetScalarsValues.m
+++ b/Documentation/Wrapping/Matlab/btk/@Common/btkSetScalarsValues.m
@@ -9,7 +9,7 @@ function btkSetScalarsValues(h, v) %#ok
% be only used with the btk* functions.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@IO/btkReadAcquisition.m b/Documentation/Wrapping/Matlab/btk/@IO/btkReadAcquisition.m
index 41fd5249..5c250dd5 100644
--- a/Documentation/Wrapping/Matlab/btk/@IO/btkReadAcquisition.m
+++ b/Documentation/Wrapping/Matlab/btk/@IO/btkReadAcquisition.m
@@ -25,7 +25,7 @@ function h = btkReadAcquisition(filename) %#ok
% - Integer
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/@IO/btkWriteAcquisition.m b/Documentation/Wrapping/Matlab/btk/@IO/btkWriteAcquisition.m
index 7bbca2f7..7f97b91a 100644
--- a/Documentation/Wrapping/Matlab/btk/@IO/btkWriteAcquisition.m
+++ b/Documentation/Wrapping/Matlab/btk/@IO/btkWriteAcquisition.m
@@ -39,7 +39,7 @@ function h = btkWriteAcquisition(filename) %#ok
% - BTKWRITEACQUISITION(acq, 'filename.c3d', 'StorageFormat', 'Integer', 'ByteOrder', 'IEEE_LittleEndian');
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% The following comment, MATLAB compiler pragma, is necessary to avoid
% compiling this M-file instead of linking against the MEX-file. Don't remove.
diff --git a/Documentation/Wrapping/Matlab/btk/Contents.m.in b/Documentation/Wrapping/Matlab/btk/Contents.m.in
index 6b9f8b02..bcf2ec4c 100644
--- a/Documentation/Wrapping/Matlab/btk/Contents.m.in
+++ b/Documentation/Wrapping/Matlab/btk/Contents.m.in
@@ -14,4 +14,4 @@
% <a href="matlab:help btkGetVersion">btkGetVersion</a> - Return the BTK release number
% <a href="matlab:help btkTransformTDFToViconC3DFile">btkTransformTDFToViconC3DFile</a> - Transform a TDF file to a C3D file compatible with Vicon
-% Copyright 2009-2013 Biomechanical ToolKit
\ No newline at end of file
+% Copyright 2009-2014 Biomechanical ToolKit
\ No newline at end of file
diff --git a/Documentation/Wrapping/Matlab/btk/btkAppendForcePlatformType2.m b/Documentation/Wrapping/Matlab/btk/btkAppendForcePlatformType2.m
index 3db53fc3..30320e6b 100644
--- a/Documentation/Wrapping/Matlab/btk/btkAppendForcePlatformType2.m
+++ b/Documentation/Wrapping/Matlab/btk/btkAppendForcePlatformType2.m
@@ -50,7 +50,7 @@ function btkAppendForcePlatformType2(h, forces, moments, corners, origin, localF
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
if (nargin < 4)
error('Missing input arguments');
diff --git a/Documentation/Wrapping/Matlab/btk/btkCloseAcquisition.m b/Documentation/Wrapping/Matlab/btk/btkCloseAcquisition.m
index 066cfe66..46879d6b 100644
--- a/Documentation/Wrapping/Matlab/btk/btkCloseAcquisition.m
+++ b/Documentation/Wrapping/Matlab/btk/btkCloseAcquisition.m
@@ -7,7 +7,7 @@ function btkCloseAcquisition(h) %#ok
% btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
btkDeleteAcquisition(h)
diff --git a/Documentation/Wrapping/Matlab/btk/btkCropAcquisition.m b/Documentation/Wrapping/Matlab/btk/btkCropAcquisition.m
index dd8083ac..ee3c326a 100644
--- a/Documentation/Wrapping/Matlab/btk/btkCropAcquisition.m
+++ b/Documentation/Wrapping/Matlab/btk/btkCropAcquisition.m
@@ -12,14 +12,16 @@ function btkCropAcquisition(h, startAt, numFrames)
% from the frame STARTAT.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
ff = btkGetFirstFrame(h);
lf = btkGetLastFrame(h);
if (nargin == 2)
numFrames = lf - ff + 1 - startAt + 1;
end
-if ((startAt < ff) || startAt > lf)
+if (mod(startAt,1) || mod(numFrames,1))
+ error('btk:CropAcquisition','Frame numbers must be real positive integers');
+elseif ((startAt < ff) || startAt > lf)
error('btk:CropAcquisiton','Invalid index.');
elseif (numFrames > lf - startAt + 1)
error('btk:CropAcquisiton','Incorrect number of frames specified.')
@@ -41,8 +43,12 @@ av = av(aidx,:);
% Resizing
btkSetFrameNumber(h, numFrames);
% Storing modifications
-btkSetPointsValues(h, pv);
-btkSetPointsResiduals(h, rv);
-btkSetAnalogsValues(h, av);
+if ~isempty(pv)
+ btkSetPointsValues(h, pv);
+ btkSetPointsResiduals(h, rv);
+end
+if ~isempty(av)
+ btkSetAnalogsValues(h, av);
+end
% Set the first frame.
-btkSetFirstFrame(h, startAt, 1); % 1: Modify also the events' frame/time
\ No newline at end of file
+btkSetFirstFrame(h, startAt, 1); % 1: Modify also the events' frame/time
diff --git a/Documentation/Wrapping/Matlab/btk/btkEmulateC3Dserver.m b/Documentation/Wrapping/Matlab/btk/btkEmulateC3Dserver.m
index 10057f71..92801a7b 100644
--- a/Documentation/Wrapping/Matlab/btk/btkEmulateC3Dserver.m
+++ b/Documentation/Wrapping/Matlab/btk/btkEmulateC3Dserver.m
@@ -77,7 +77,7 @@ function itf = btkEmulateC3Dserver()
% the command: 'warning('OFF','btk:C3Dserver:FakeMask')'.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
% TODO:
% - How to set parameter's values with the type 'Char'?
diff --git a/Documentation/Wrapping/Matlab/btk/btkFindMetaData.m b/Documentation/Wrapping/Matlab/btk/btkFindMetaData.m
index dd3542cb..d14f2d2f 100644
--- a/Documentation/Wrapping/Matlab/btk/btkFindMetaData.m
+++ b/Documentation/Wrapping/Matlab/btk/btkFindMetaData.m
@@ -15,7 +15,7 @@ function md = btkFindMetaData(h,label,varargin)
% By default, BTK, use two stages of metadata representing group and parameters.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
if (nargin < 2)
error('At least two inputs are required.');
diff --git a/Documentation/Wrapping/Matlab/btk/btkGetAnalogsResolution.m b/Documentation/Wrapping/Matlab/btk/btkGetAnalogsResolution.m
index e8509947..889b4a52 100644
--- a/Documentation/Wrapping/Matlab/btk/btkGetAnalogsResolution.m
+++ b/Documentation/Wrapping/Matlab/btk/btkGetAnalogsResolution.m
@@ -6,7 +6,7 @@ function ar = btkGetAnalogsResolution(h)
% This handle is obtained by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
warning('This function is deprecated and will be removed in a next release. Use btkGetAnalogResolution instead.');
return btkGetAnalogResolution(h);
diff --git a/Documentation/Wrapping/Matlab/btk/btkGetEventNumber.m b/Documentation/Wrapping/Matlab/btk/btkGetEventNumber.m
index fdb8ab85..b0fd6019 100644
--- a/Documentation/Wrapping/Matlab/btk/btkGetEventNumber.m
+++ b/Documentation/Wrapping/Matlab/btk/btkGetEventNumber.m
@@ -6,6 +6,6 @@ function num = btkGetEventNumber(h)
% a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
num = length(btkGetEventsValues(h));
diff --git a/Documentation/Wrapping/Matlab/btk/btkGetLastFrame.m b/Documentation/Wrapping/Matlab/btk/btkGetLastFrame.m
index e68fd066..2596e7dd 100644
--- a/Documentation/Wrapping/Matlab/btk/btkGetLastFrame.m
+++ b/Documentation/Wrapping/Matlab/btk/btkGetLastFrame.m
@@ -6,7 +6,7 @@ function lf = btkGetLastFrame(h) %#ok
% btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
lf = btkGetFirstFrame(h) + btkGetPointFrameNumber(h) - 1;
diff --git a/Documentation/Wrapping/Matlab/btk/btkGetVersion.m.in b/Documentation/Wrapping/Matlab/btk/btkGetVersion.m.in
index 101fcdd3..384dbb38 100644
--- a/Documentation/Wrapping/Matlab/btk/btkGetVersion.m.in
+++ b/Documentation/Wrapping/Matlab/btk/btkGetVersion.m.in
@@ -2,5 +2,5 @@ function v = btkGetVersion()
%V = BTKGETVERSION returns the release number of BTK.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit
+% Copyright 2009-2014 Biomechanical ToolKit
v = '${BTK_VERSION_MAJOR}.${BTK_VERSION_MINOR}.${BTK_VERSION_PATCH}';
diff --git a/Documentation/Wrapping/Matlab/btk/btkMetaDataInfo.m b/Documentation/Wrapping/Matlab/btk/btkMetaDataInfo.m
index e2d7b8cf..45f23b3b 100644
--- a/Documentation/Wrapping/Matlab/btk/btkMetaDataInfo.m
+++ b/Documentation/Wrapping/Matlab/btk/btkMetaDataInfo.m
@@ -17,7 +17,7 @@ function info = btkMetaDataInfo(format, values, numdims)
% Note: The maximum number of dimensions is set to 7.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
nd = numel(size(values));
if (nargin < 3)
diff --git a/Documentation/Wrapping/Matlab/btk/btkSetAnalogsResolution.m b/Documentation/Wrapping/Matlab/btk/btkSetAnalogsResolution.m
index ac0858bd..cfc84d52 100644
--- a/Documentation/Wrapping/Matlab/btk/btkSetAnalogsResolution.m
+++ b/Documentation/Wrapping/Matlab/btk/btkSetAnalogsResolution.m
@@ -7,7 +7,7 @@ function btkSetAnalogsResolution(h, res)
% a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
warning('This function is deprecated and will be removed in a next release. Use btkGetAnalogResolution instead.');
btkSetAnalogResolution(h,res);
diff --git a/Documentation/Wrapping/Matlab/btk/btkSetMetaData.m b/Documentation/Wrapping/Matlab/btk/btkSetMetaData.m
index 4b9eb41c..2b9cf2fe 100644
--- a/Documentation/Wrapping/Matlab/btk/btkSetMetaData.m
+++ b/Documentation/Wrapping/Matlab/btk/btkSetMetaData.m
@@ -21,7 +21,7 @@ function md = btkSetMetaData(h, varargin) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
if (nargin < 3)
error('At least three inputs are required.');
diff --git a/Documentation/Wrapping/Matlab/btk/btkSetMetaDataValues.m b/Documentation/Wrapping/Matlab/btk/btkSetMetaDataValues.m
index 2fab1b4d..81e06d77 100644
--- a/Documentation/Wrapping/Matlab/btk/btkSetMetaDataValues.m
+++ b/Documentation/Wrapping/Matlab/btk/btkSetMetaDataValues.m
@@ -7,7 +7,7 @@ function md = btkSetMetaDataValues(h, varargin) %#ok
% by the use of a btk* function.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
md = btkSetMetaData(h, varargin{:});
diff --git a/Documentation/Wrapping/Matlab/btk/btkTransformTDFToViconC3DFile.m b/Documentation/Wrapping/Matlab/btk/btkTransformTDFToViconC3DFile.m
index deebc20e..0a193297 100644
--- a/Documentation/Wrapping/Matlab/btk/btkTransformTDFToViconC3DFile.m
+++ b/Documentation/Wrapping/Matlab/btk/btkTransformTDFToViconC3DFile.m
@@ -30,7 +30,7 @@ function btkTransformTDFToViconC3DFile(TDF_INPUT, C3D_OUTPUT)
% exists really before trying to remove them.
% Author: A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit (BTK).
+% Copyright 2009-2014 Biomechanical ToolKit (BTK).
if (nargin < 2)
C3D_OUTPUT = [TDF_INPUT,'.c3d'];
diff --git a/Documentation/Wrapping/Matlab/btk/tocbtkbasicfilters.m b/Documentation/Wrapping/Matlab/btk/tocbtkbasicfilters.m
index fe885b58..11872dae 100644
--- a/Documentation/Wrapping/Matlab/btk/tocbtkbasicfilters.m
+++ b/Documentation/Wrapping/Matlab/btk/tocbtkbasicfilters.m
@@ -12,6 +12,6 @@ function tocbtkbasicfilters
% <a href="matlab:help btk">Biomechanical Toolkit TOC</a>
% Author(s): A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit
+% Copyright 2009-2014 Biomechanical ToolKit
% [EOF]
\ No newline at end of file
diff --git a/Documentation/Wrapping/Matlab/btk/tocbtkcommon.m b/Documentation/Wrapping/Matlab/btk/tocbtkcommon.m
index a8054282..ef82b99b 100644
--- a/Documentation/Wrapping/Matlab/btk/tocbtkcommon.m
+++ b/Documentation/Wrapping/Matlab/btk/tocbtkcommon.m
@@ -121,6 +121,6 @@ function tocbtkcommon
% <a href="matlab:help btk">Biomechanical Toolkit TOC</a>
% Author(s): A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit
+% Copyright 2009-2014 Biomechanical ToolKit
% [EOF]
\ No newline at end of file
diff --git a/Documentation/Wrapping/Matlab/btk/tocbtkio.m b/Documentation/Wrapping/Matlab/btk/tocbtkio.m
index 3b254300..d0bcdb55 100644
--- a/Documentation/Wrapping/Matlab/btk/tocbtkio.m
+++ b/Documentation/Wrapping/Matlab/btk/tocbtkio.m
@@ -10,6 +10,6 @@ function tocbtkio
% <a href="matlab:help btk">Biomechanical Toolkit TOC</a>
% Author(s): A. Barré
-% Copyright 2009-2013 Biomechanical ToolKit
+% Copyright 2009-2014 Biomechanical ToolKit
% [EOF]
\ No newline at end of file
diff --git a/Documentation/Wrapping/Python/btkCommonSwig.dox b/Documentation/Wrapping/Python/btkCommonSwig.dox
index 6feac99a..7fad615e 100644
--- a/Documentation/Wrapping/Python/btkCommonSwig.dox
+++ b/Documentation/Wrapping/Python/btkCommonSwig.dox
@@ -43,6 +43,10 @@ namespace btk
* @var btkAnalog::PlusMinus2Dot5
* Gain for the range +/- 2.5 volts.
*/
+/**
+ * @var btkAnalog::PlusMinus1Dot65
+ * Gain for the range +/- 1.65 volts.
+ */
/**
* @var btkAnalog::PlusMinus1Dot25
* Gain for the range +/- 1.25 volts.
diff --git a/Documentation/Wrapping/Scilab/btk/license.txt b/Documentation/Wrapping/Scilab/btk/license.txt
index 1db693ea..b185ef0a 100644
--- a/Documentation/Wrapping/Scilab/btk/license.txt
+++ b/Documentation/Wrapping/Scilab/btk/license.txt
@@ -1,5 +1,5 @@
The Biomechanical ToolKit
-Copyright (c) 2009-2013, Arnaud Barré
+Copyright (c) 2009-2014, Arnaud Barré
All rights reserved.
Redistribution and use in source and binary forms, with or without
diff --git a/Examples/AcquisitionConverter/main.cpp b/Examples/AcquisitionConverter/main.cpp
index 5f80c521..a9dab1d6 100644
--- a/Examples/AcquisitionConverter/main.cpp
+++ b/Examples/AcquisitionConverter/main.cpp
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Readme.html b/Readme.html
index 5573bc46..6baa4edc 100644
--- a/Readme.html
+++ b/Readme.html
@@ -129,7 +129,7 @@ Copyright Notice</h1>
<p>BTK use the generous open-source New BSD license. Yes, you can use BTK in commercial products. The complete text of the copyright follows.</p>
<pre class="fragment">/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Testing/C++/AcquisitionUnitConverterTest.h b/Testing/C++/AcquisitionUnitConverterTest.h
index 813219a8..cd84fb1f 100644
--- a/Testing/C++/AcquisitionUnitConverterTest.h
+++ b/Testing/C++/AcquisitionUnitConverterTest.h
@@ -205,16 +205,16 @@ CXXTEST_SUITE(AcquisitionUnitConverterTest)
btk::Wrench::Pointer grw2 = grwf2->GetOutput()->GetItem(0);
// NaN in the computation of the moment!
- TS_ASSERT(pfe2->GetOutput()->GetItem(0)->GetChannel(0)->GetValues().isApprox(pfe1->GetOutput()->GetItem(0)->GetChannel(0)->GetValues()));
- TS_ASSERT(pfe2->GetOutput()->GetItem(0)->GetChannel(1)->GetValues().isApprox(pfe1->GetOutput()->GetItem(0)->GetChannel(1)->GetValues()));
- TS_ASSERT(pfe2->GetOutput()->GetItem(0)->GetChannel(2)->GetValues().isApprox(pfe1->GetOutput()->GetItem(0)->GetChannel(2)->GetValues()));
+ TS_ASSERT_EIGEN_DELTA(pfe2->GetOutput()->GetItem(0)->GetChannel(0)->GetValues(), pfe1->GetOutput()->GetItem(0)->GetChannel(0)->GetValues(), 1e-15);
+ TS_ASSERT_EIGEN_DELTA(pfe2->GetOutput()->GetItem(0)->GetChannel(1)->GetValues(), pfe1->GetOutput()->GetItem(0)->GetChannel(1)->GetValues(), 1e-15);
+ TS_ASSERT_EIGEN_DELTA(pfe2->GetOutput()->GetItem(0)->GetChannel(2)->GetValues(), pfe1->GetOutput()->GetItem(0)->GetChannel(2)->GetValues(), 1e-15);
// Frame #21: NaN?
TS_ASSERT((pfe2->GetOutput()->GetItem(0)->GetChannel(3)->GetValues()-(pfe1->GetOutput()->GetItem(0)->GetChannel(3)->GetValues() * 0.001)).block(0,0,20,1).rowwise().norm().sum() < 1e-5);
TS_ASSERT((pfe2->GetOutput()->GetItem(0)->GetChannel(4)->GetValues()-(pfe1->GetOutput()->GetItem(0)->GetChannel(4)->GetValues() * 0.001)).block(0,0,20,1).rowwise().norm().sum() < 1e-5);
TS_ASSERT((pfe2->GetOutput()->GetItem(0)->GetChannel(5)->GetValues()-(pfe1->GetOutput()->GetItem(0)->GetChannel(5)->GetValues() * 0.001)).block(0,0,20,1).rowwise().norm().sum() < 1e-5);
TS_ASSERT((grw2->GetPosition()->GetValues() - (grw1->GetPosition()->GetValues() * 0.001)).block(0,0,20,3).rowwise().norm().sum() < 1e-5);
TS_ASSERT((grw2->GetMoment()->GetValues() - (grw1->GetMoment()->GetValues() * 0.001)).block(0,0,20,3).rowwise().norm().sum() < 1e-5);
- TS_ASSERT(grw2->GetForce()->GetValues().isApprox(grw1->GetForce()->GetValues(),1e-11));
+ TS_ASSERT_EIGEN_DELTA(grw2->GetForce()->GetValues(), grw1->GetForce()->GetValues(), 1e-9);
};
CXXTEST_TEST(ConversionFromFileCalMatrix_Type4a)
@@ -242,9 +242,9 @@ CXXTEST_SUITE(AcquisitionUnitConverterTest)
grwf2->Update();
// FP1
- TS_ASSERT(pfe2->GetOutput()->GetItem(0)->GetChannel(0)->GetValues().isApprox(pfe1->GetOutput()->GetItem(0)->GetChannel(0)->GetValues()));
- TS_ASSERT(pfe2->GetOutput()->GetItem(0)->GetChannel(1)->GetValues().isApprox(pfe1->GetOutput()->GetItem(0)->GetChannel(1)->GetValues()));
- TS_ASSERT(pfe2->GetOutput()->GetItem(0)->GetChannel(2)->GetValues().isApprox(pfe1->GetOutput()->GetItem(0)->GetChannel(2)->GetValues()));
+ TS_ASSERT_EIGEN_DELTA(pfe2->GetOutput()->GetItem(0)->GetChannel(0)->GetValues(), pfe1->GetOutput()->GetItem(0)->GetChannel(0)->GetValues(), 1e-15);
+ TS_ASSERT_EIGEN_DELTA(pfe2->GetOutput()->GetItem(0)->GetChannel(1)->GetValues(), pfe1->GetOutput()->GetItem(0)->GetChannel(1)->GetValues(), 1e-15);
+ TS_ASSERT_EIGEN_DELTA(pfe2->GetOutput()->GetItem(0)->GetChannel(2)->GetValues(), pfe1->GetOutput()->GetItem(0)->GetChannel(2)->GetValues(), 1e-15);
TS_ASSERT((pfe2->GetOutput()->GetItem(0)->GetChannel(3)->GetValues()-(pfe1->GetOutput()->GetItem(0)->GetChannel(3)->GetValues() * 0.001)).rowwise().norm().sum() < 1e-3);
TS_ASSERT((pfe2->GetOutput()->GetItem(0)->GetChannel(4)->GetValues()-(pfe1->GetOutput()->GetItem(0)->GetChannel(4)->GetValues() * 0.001)).rowwise().norm().sum() < 1e-3);
TS_ASSERT((pfe2->GetOutput()->GetItem(0)->GetChannel(5)->GetValues()-(pfe1->GetOutput()->GetItem(0)->GetChannel(5)->GetValues() * 0.001)).rowwise().norm().sum() < 1e-3);
@@ -252,12 +252,12 @@ CXXTEST_SUITE(AcquisitionUnitConverterTest)
btk::Wrench::Pointer grw2 = grwf2->GetOutput()->GetItem(0);
TS_ASSERT((grw2->GetPosition()->GetValues() - (grw1->GetPosition()->GetValues() * 0.001)).rowwise().norm().sum() < 1e-3);
TS_ASSERT((grw2->GetMoment()->GetValues() - (grw1->GetMoment()->GetValues() * 0.001)).rowwise().norm().sum() < 1e-3);
- TS_ASSERT(grw2->GetForce()->GetValues().isApprox(grw1->GetForce()->GetValues()));
+ TS_ASSERT_EIGEN_DELTA(grw2->GetForce()->GetValues(), grw1->GetForce()->GetValues(), 1e-9);
// FP2
- TS_ASSERT(pfe2->GetOutput()->GetItem(1)->GetChannel(0)->GetValues().isApprox(pfe1->GetOutput()->GetItem(1)->GetChannel(0)->GetValues()));
- TS_ASSERT(pfe2->GetOutput()->GetItem(1)->GetChannel(1)->GetValues().isApprox(pfe1->GetOutput()->GetItem(1)->GetChannel(1)->GetValues()));
- TS_ASSERT(pfe2->GetOutput()->GetItem(1)->GetChannel(2)->GetValues().isApprox(pfe1->GetOutput()->GetItem(1)->GetChannel(2)->GetValues()));
+ TS_ASSERT_EIGEN_DELTA(pfe2->GetOutput()->GetItem(1)->GetChannel(0)->GetValues(), pfe1->GetOutput()->GetItem(1)->GetChannel(0)->GetValues(), 1e-15);
+ TS_ASSERT_EIGEN_DELTA(pfe2->GetOutput()->GetItem(1)->GetChannel(1)->GetValues(), pfe1->GetOutput()->GetItem(1)->GetChannel(1)->GetValues(), 1e-15);
+ TS_ASSERT_EIGEN_DELTA(pfe2->GetOutput()->GetItem(1)->GetChannel(2)->GetValues(), pfe1->GetOutput()->GetItem(1)->GetChannel(2)->GetValues(), 1e-15);
TS_ASSERT((pfe2->GetOutput()->GetItem(1)->GetChannel(3)->GetValues()-(pfe1->GetOutput()->GetItem(1)->GetChannel(3)->GetValues() * 0.001)).rowwise().norm().sum() < 1e-3);
TS_ASSERT((pfe2->GetOutput()->GetItem(1)->GetChannel(4)->GetValues()-(pfe1->GetOutput()->GetItem(1)->GetChannel(4)->GetValues() * 0.001)).rowwise().norm().sum() < 1e-3);
TS_ASSERT((pfe2->GetOutput()->GetItem(1)->GetChannel(5)->GetValues()-(pfe1->GetOutput()->GetItem(1)->GetChannel(5)->GetValues() * 0.001)).rowwise().norm().sum() < 1e-3);
@@ -265,7 +265,7 @@ CXXTEST_SUITE(AcquisitionUnitConverterTest)
grw2 = grwf2->GetOutput()->GetItem(1);
TS_ASSERT((grw2->GetPosition()->GetValues() - (grw1->GetPosition()->GetValues() * 0.001)).rowwise().norm().sum() < 1e-3);
TS_ASSERT((grw2->GetMoment()->GetValues() - (grw1->GetMoment()->GetValues() * 0.001)).rowwise().norm().sum() < 1e-3);
- TS_ASSERT(grw2->GetForce()->GetValues().isApprox(grw1->GetForce()->GetValues()));
+ TS_ASSERT_EIGEN_DELTA(grw2->GetForce()->GetValues(), grw1->GetForce()->GetValues(), 1e-9);
};
};
diff --git a/Testing/C++/C3DFileWriterTest.h b/Testing/C++/C3DFileWriterTest.h
index 424609d7..3ddc944f 100644
--- a/Testing/C++/C3DFileWriterTest.h
+++ b/Testing/C++/C3DFileWriterTest.h
@@ -94,6 +94,8 @@ CXXTEST_SUITE(C3DFileWriterTest)
TS_ASSERT_EQUALS((int)acq->GetMetaData()->GetChild("EVENT")->GetChild("TIMES")->GetInfo()->GetDimensions().size(), 2);
TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("EVENT")->GetChild("TIMES")->GetInfo()->GetDimensions()[0], 2);
TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("EVENT")->GetChild("TIMES")->GetInfo()->GetDimensions()[1], 3);
+
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("ANALOG")->GetChild("OFFSET")->GetInfo()->GetFormat(), btk::MetaDataInfo::Integer);
};
CXXTEST_TEST(sample01_Eb015pr_rewrited)
@@ -1275,21 +1277,21 @@ CXXTEST_SUITE(C3DFileWriterTest)
analog0->SetLabel("Test#1");
analog0->SetDescription("It seems");
analog0->SetGain(btk::Analog::PlusMinus10);
- analog0->SetOffset(123);
+ analog0->SetOffset(123.0);
analog0->SetScale(1.2345);
analog0->SetUnit("N");
btk::Analog::Pointer analog1 = acq->GetAnalog(1);
analog1->SetLabel("Test#2");
analog1->SetDescription("that BTK doesn't");
analog1->SetGain(btk::Analog::PlusMinus5);
- analog1->SetOffset(456);
+ analog1->SetOffset(456.0);
analog1->SetScale(5.2341);
analog1->SetUnit("Nmm");
btk::Analog::Pointer analog2 = acq->GetAnalog(2);
analog2->SetLabel("Test#3");
analog2->SetDescription("write all properties");
analog2->SetGain(btk::Analog::PlusMinus2Dot5);
- analog2->SetOffset(789);
+ analog2->SetOffset(789.0);
analog2->SetScale(10.025);
analog2->SetUnit("Foo");
@@ -1727,7 +1729,7 @@ CXXTEST_SUITE(C3DFileWriterTest)
(*it)->SetLabel("MyAnalog#" + btk::ToString(inc++));
(*it)->SetDescription("test");
(*it)->SetScale(1.0);
- (*it)->SetOffset(0);
+ (*it)->SetOffset(0.0);
}
acq->GetMetaData()->GetChild("POINT")->GetChild("RATE")->GetInfo()->SetValues(400.0f);
@@ -1817,6 +1819,51 @@ CXXTEST_SUITE(C3DFileWriterTest)
}
TS_ASSERT(acq->GetMetaData()->FindChild("EVENT") == acq->EndMetaData());
};
+
+ CXXTEST_TEST(AnalogOffsetStoredAsReal_12Bits)
+ {
+ btk::Acquisition::Pointer acq = btk::Acquisition::New();
+ acq->Init(0,10,1);
+ acq->SetPointFrequency(50.0);
+ acq->GetAnalog(0)->SetOffset(-1.1);
+
+ btk::AcquisitionFileWriter::Pointer writer = btk::AcquisitionFileWriter::New();
+ writer->SetInput(acq);
+ writer->SetFilename(C3DFilePathOUT + "AnalogOffsetStoredAsReal_12.c3d");
+ writer->Update();
+
+ btk::AcquisitionFileReader::Pointer reader = btk::AcquisitionFileReader::New();
+ reader->SetFilename(C3DFilePathOUT + "AnalogOffsetStoredAsReal_12.c3d");
+ reader->Update();
+ acq = reader->GetOutput();
+
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("ANALOG")->GetChild("OFFSET")->GetInfo()->GetFormat(), btk::MetaDataInfo::Real);
+
+ TS_ASSERT(acq->GetAnalog(0)->GetValues().cwiseAbs().maxCoeff() <= 1e-5);
+ };
+
+ CXXTEST_TEST(AnalogOffsetStoredAsReal_16Bits)
+ {
+ btk::Acquisition::Pointer acq = btk::Acquisition::New();
+ acq->Init(0,10,1);
+ acq->SetAnalogResolution(btk::Acquisition::Bit16);
+ acq->SetPointFrequency(50.0);
+ acq->GetAnalog(0)->SetOffset(-1.1);
+
+ btk::AcquisitionFileWriter::Pointer writer = btk::AcquisitionFileWriter::New();
+ writer->SetInput(acq);
+ writer->SetFilename(C3DFilePathOUT + "AnalogOffsetStoredAsReal_16.c3d");
+ writer->Update();
+
+ btk::AcquisitionFileReader::Pointer reader = btk::AcquisitionFileReader::New();
+ reader->SetFilename(C3DFilePathOUT + "AnalogOffsetStoredAsReal_16.c3d");
+ reader->Update();
+ acq = reader->GetOutput();
+
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("ANALOG")->GetChild("OFFSET")->GetInfo()->GetFormat(), btk::MetaDataInfo::Real);
+
+ TS_ASSERT(acq->GetAnalog(0)->GetValues().cwiseAbs().maxCoeff() <= 1e-5);
+ };
};
CXXTEST_SUITE_REGISTRATION(C3DFileWriterTest)
@@ -1860,4 +1907,6 @@ CXXTEST_TEST_REGISTRATION(C3DFileWriterTest, InternalsUpdateDataBased)
CXXTEST_TEST_REGISTRATION(C3DFileWriterTest, InternalsUpdateViconCompatibleOnly)
CXXTEST_TEST_REGISTRATION(C3DFileWriterTest, InternalsUpdateUpdateMetaDataBased)
CXXTEST_TEST_REGISTRATION(C3DFileWriterTest, InternalsUpdateUpdateMetaDataBased_EventsHeader)
+CXXTEST_TEST_REGISTRATION(C3DFileWriterTest, AnalogOffsetStoredAsReal_12Bits)
+CXXTEST_TEST_REGISTRATION(C3DFileWriterTest, AnalogOffsetStoredAsReal_16Bits)
#endif
diff --git a/Testing/C++/CLBFileReaderTest.h b/Testing/C++/CLBFileReaderTest.h
index d8a57775..a53860c7 100644
--- a/Testing/C++/CLBFileReaderTest.h
+++ b/Testing/C++/CLBFileReaderTest.h
@@ -41,7 +41,7 @@ CXXTEST_SUITE(CLBFileReaderTest)
{
TS_ASSERT_EQUALS(acq->GetAnalog(i)->GetLabel().compare("Channel " + btk::ToString(i)), 0);
TS_ASSERT_EQUALS(acq->GetAnalog(i)->GetScale(), 20.0/65536.0);
- TS_ASSERT_EQUALS(acq->GetAnalog(i)->GetOffset(), 32768);
+ TS_ASSERT_EQUALS(acq->GetAnalog(i)->GetOffset(), 32768.0);
}
TS_ASSERT_EQUALS(static_cast<int>(acq->GetAnalog(0)->GetValues()(0) / acq->GetAnalog(0)->GetScale()) + acq->GetAnalog(0)->GetOffset(), 32749);
diff --git a/Testing/C++/DelsysEMGFileReaderTest.h b/Testing/C++/DelsysEMGFileReaderTest.h
index 240efa58..b42486df 100644
--- a/Testing/C++/DelsysEMGFileReaderTest.h
+++ b/Testing/C++/DelsysEMGFileReaderTest.h
@@ -34,7 +34,10 @@ CXXTEST_SUITE(DelsysEMGFileReaderTest)
TS_ASSERT_EQUALS(acq->GetAnalogFrameNumber(),60000);
TS_ASSERT_EQUALS(acq->GetAnalogFrequency(),2000);
for (int i = 0 ; i < 8; ++i)
+ {
TS_ASSERT_EQUALS(acq->GetAnalog(i)->GetLabel(), "EMG Ch" + btk::ToString(i+1));
+ TS_ASSERT_EQUALS(acq->GetAnalog(i)->GetGain(), btk::Analog::PlusMinus1);
+ }
TS_ASSERT_DELTA(acq->GetAnalog(0)->GetValues().coeff(0), 1.6327e-5, 1e-9);
TS_ASSERT_DELTA(acq->GetAnalog(2)->GetValues().coeff(29999), 3.4180e-5, 1e-9);
TS_ASSERT_DELTA(acq->GetAnalog(5)->GetValues().coeff(12000), 3.4180e-5, 1e-9)
diff --git a/Testing/C++/EigenIIRFilterDesignTest.h b/Testing/C++/EigenIIRFilterDesignTest.h
index 5307cf9d..fe8e0785 100644
--- a/Testing/C++/EigenIIRFilterDesignTest.h
+++ b/Testing/C++/EigenIIRFilterDesignTest.h
@@ -88,7 +88,7 @@ CXXTEST_SUITE(EigenIIRFilterDesignTest)
TS_ASSERT_DELTA(a(8), 0.50855151093463624 , 5e-13); // Not so accurate?
TS_ASSERT_DELTA(a(9), -2.5520129858487823e-14, 1e-13);
TS_ASSERT_DELTA(a(10), -0.14482945329972546 , 5e-13);
- TS_ASSERT_DELTA(a(11), 3.1717384177005001e-15 , 1e-14); // Note: With Eigen3 the result is negative: -3.53945e-15
+ TS_ASSERT_DELTA(a(11), 3.1717384177005001e-15 , 5e-14); // Note: With Eigen3 the result is negative: -3.53945e-15
TS_ASSERT_DELTA(a(12), 0.026252219253782492 , 1e-14);
TS_ASSERT_DELTA(a(13), -1.8499567508325164e-16, 1e-15);
TS_ASSERT_DELTA(a(14), -0.00202968024924362 , 1e-15);
@@ -170,9 +170,9 @@ CXXTEST_SUITE(EigenIIRFilterDesignTest)
double k = 1.0;
btkEigen::zpk2tf(&b, &a, z, p, k);
TS_ASSERT_EQUALS(b.rows(), b_r.rows());
- TS_ASSERT(b.isApprox(b_r, 1e-15));
+ TS_ASSERT_EIGEN_DELTA(b, b_r, 1e-15);
TS_ASSERT_EQUALS(a.rows(), a_r.rows());
- TS_ASSERT(a.isApprox(a_r, 1e-15));
+ TS_ASSERT_EIGEN_DELTA(a, a_r, 1e-15);
};
CXXTEST_TEST(Internal_zpk2tf_bis)
diff --git a/Testing/C++/ForcePlatformsExtractorTest.h b/Testing/C++/ForcePlatformsExtractorTest.h
index 3beaa675..2697e164 100644
--- a/Testing/C++/ForcePlatformsExtractorTest.h
+++ b/Testing/C++/ForcePlatformsExtractorTest.h
@@ -28,17 +28,17 @@ CXXTEST_SUITE(ForcePlatformsExtractorTest)
TS_ASSERT_EQUALS(pf1->GetChannel(4)->GetLabel(), "MY1");
TS_ASSERT_EQUALS(pf1->GetChannel(5)->GetLabel(), "MZ1");
btk::ForcePlatform::Origin o1; o1 << -4.4 , 1.9, -21.6;
- TS_ASSERT_EQUALS(pf1->GetOrigin().isApprox(o1, 0.00001), true);
+ TS_ASSERT_EIGEN_DELTA(pf1->GetOrigin(), o1, 1e-5);
btk::ForcePlatform::Corner c11; c11 << 520.0451 , 1242.1694, 0.6219;
btk::ForcePlatform::Corner c21; c21 << 57.0463 , 1243.1996, 0.6211;
- btk::ForcePlatform::Corner c31; c31 << 58.1765 , 1751.1663, 2.0812;
+ btk::ForcePlatform::Corner c31; c31 << 58.1765 , 1751.1963, 2.0812;
btk::ForcePlatform::Corner c41; c41 << 521.1754 , 1750.1661, 2.0820;
- TS_ASSERT_EQUALS(pf1->GetCorner(0).isApprox(c11, 0.0001), true);
- TS_ASSERT_EQUALS(pf1->GetCorner(1).isApprox(c21, 0.0001), true);
- TS_ASSERT_EQUALS(pf1->GetCorner(2).isApprox(c31, 0.0001), true);
- TS_ASSERT_EQUALS(pf1->GetCorner(3).isApprox(c41, 0.0001), true);
+ TS_ASSERT_EIGEN_DELTA(pf1->GetCorner(0), c11, 5e-5);
+ TS_ASSERT_EIGEN_DELTA(pf1->GetCorner(1), c21, 5e-5);
+ TS_ASSERT_EIGEN_DELTA(pf1->GetCorner(2), c31, 5e-5);
+ TS_ASSERT_EIGEN_DELTA(pf1->GetCorner(3), c41, 5e-5);
btk::ForcePlatform::Corners cs1; cs1 << c11, c21, c31, c41;
- TS_ASSERT_EQUALS(pf1->GetCorners().isApprox(cs1, 0.0001), true);
+ TS_ASSERT_EIGEN_DELTA(pf1->GetCorners(), cs1, 5e-5);
btk::ForcePlatform::Pointer pf2 = pfc->GetItem(1);
TS_ASSERT_EQUALS(pf2->GetType(), 2);
@@ -50,17 +50,17 @@ CXXTEST_SUITE(ForcePlatformsExtractorTest)
TS_ASSERT_EQUALS(pf2->GetChannel(4)->GetLabel(), "MY2");
TS_ASSERT_EQUALS(pf2->GetChannel(5)->GetLabel(), "MZ2");
btk::ForcePlatform::Origin o2; o2 << -4.06 , 3.81, -20.06;
- TS_ASSERT_EQUALS(pf2->GetOrigin().isApprox(o2, 0.00001), true);
- btk::ForcePlatform::Corner c12; c12 << 53.6655 , 1139.9977, 1.9204;
+ TS_ASSERT_EIGEN_DELTA(pf2->GetOrigin(), o2, 1e-5);
+ btk::ForcePlatform::Corner c12; c12 << 53.6555 , 1139.9977, 1.9204;
btk::ForcePlatform::Corner c22; c22 << 516.6432 , 1143.3159, 1.2880;
btk::ForcePlatform::Corner c32; c32 << 520.2825 , 635.3301, 0.1814;
btk::ForcePlatform::Corner c42; c42 << 57.2948 , 632.0118, 0.8138;
- TS_ASSERT_EQUALS(pf2->GetCorner(0).isApprox(c12, 0.0001), true);
- TS_ASSERT_EQUALS(pf2->GetCorner(1).isApprox(c22, 0.0001), true);
- TS_ASSERT_EQUALS(pf2->GetCorner(2).isApprox(c32, 0.0001), true);
- TS_ASSERT_EQUALS(pf2->GetCorner(3).isApprox(c42, 0.0001), true);
+ TS_ASSERT_EIGEN_DELTA(pf2->GetCorner(0), c12, 5e-5);
+ TS_ASSERT_EIGEN_DELTA(pf2->GetCorner(1), c22, 5e-5);
+ TS_ASSERT_EIGEN_DELTA(pf2->GetCorner(2), c32, 5e-5);
+ TS_ASSERT_EIGEN_DELTA(pf2->GetCorner(3), c42, 5e-5);
btk::ForcePlatform::Corners cs2; cs2 << c12, c22, c32, c42;
- TS_ASSERT_EQUALS(pf2->GetCorners().isApprox(cs2, 0.0001), true);
+ TS_ASSERT_EIGEN_DELTA(pf2->GetCorners(), cs2, 5e-5);
};
CXXTEST_TEST(FileSample10Type2)
@@ -84,7 +84,7 @@ CXXTEST_SUITE(ForcePlatformsExtractorTest)
TS_ASSERT_EQUALS(pf1->GetChannel(4)->GetLabel(), "MY1");
TS_ASSERT_EQUALS(pf1->GetChannel(5)->GetLabel(), "MZ1");
btk::ForcePlatform::Origin o1; o1 << -1.6 , 0.7, 37.5;
- TS_ASSERT_EQUALS(pf1->GetOrigin().isApprox(o1, 0.00001), true);
+ TS_ASSERT_EIGEN_DELTA(pf1->GetOrigin(), o1, 1e-5);
TS_ASSERT_DELTA(pf1->GetChannel(0)->GetValues()(1), 0.08843, 0.00001);
TS_ASSERT_DELTA(pf1->GetChannel(0)->GetValues()(3), -0.08843, 0.00001);
TS_ASSERT_DELTA(pf1->GetChannel(0)->GetValues()(1020), -69.59441, 0.00001);
@@ -122,9 +122,9 @@ CXXTEST_SUITE(ForcePlatformsExtractorTest)
0.0000, 0.0020, 0.0000,741.8710, -0.5390, -0.5970,
0.0020,-0.0010, 0.000, -1.6820,739.6310, 2.0420,
-0.0020,-0.0050,-0.0020, -3.2500, -0.5940,391.8790;
- TS_ASSERT_EQUALS(pf1->GetCalMatrix().isApprox(cal.transpose(), 0.0001), true);
+ TS_ASSERT_EIGEN_DELTA(pf1->GetCalMatrix(), cal.transpose(), 5e-5);
btk::ForcePlatform::Origin o1; o1 << -1.6 , 0.7, 37.5;
- TS_ASSERT_EQUALS(pf1->GetOrigin().isApprox(o1, 0.00001), true);
+ TS_ASSERT_EIGEN_DELTA(pf1->GetOrigin(), o1, 1e-5);
};
diff --git a/Testing/C++/HPFFileIOTest.h b/Testing/C++/HPFFileIOTest.h
new file mode 100644
index 00000000..6b226c0b
--- /dev/null
+++ b/Testing/C++/HPFFileIOTest.h
@@ -0,0 +1,31 @@
+#ifndef HPFFileIOTest_h
+#define HPFFileIOTest_h
+
+#include <btkHPFFileIO.h>
+
+CXXTEST_SUITE(HPFFileIOTest)
+{
+ CXXTEST_TEST(CanReadFileEmpty)
+ {
+ btk::HPFFileIO::Pointer pt = btk::HPFFileIO::New();
+ TS_ASSERT_EQUALS(pt->CanReadFile(""), false);
+ };
+
+ CXXTEST_TEST(CanReadFileFail)
+ {
+ btk::HPFFileIO::Pointer pt = btk::HPFFileIO::New();
+ TS_ASSERT_EQUALS(pt->CanReadFile(HPFFilePathIN + "Fail.hpf"), false);
+ };
+
+ CXXTEST_TEST(CanReadFileOk1)
+ {
+ btk::HPFFileIO::Pointer pt = btk::HPFFileIO::New();
+ TS_ASSERT_EQUALS(pt->CanReadFile(HPFFilePathIN + "Run_number_34_VTT_Rep_1.6.hpf"), true);
+ };
+};
+
+CXXTEST_SUITE_REGISTRATION(HPFFileIOTest)
+CXXTEST_TEST_REGISTRATION(HPFFileIOTest, CanReadFileEmpty)
+CXXTEST_TEST_REGISTRATION(HPFFileIOTest, CanReadFileFail)
+CXXTEST_TEST_REGISTRATION(HPFFileIOTest, CanReadFileOk1)
+#endif
diff --git a/Testing/C++/HPFFileReaderTest.h b/Testing/C++/HPFFileReaderTest.h
new file mode 100644
index 00000000..3684db7f
--- /dev/null
+++ b/Testing/C++/HPFFileReaderTest.h
@@ -0,0 +1,279 @@
+#ifndef HPFFileReaderTest_h
+#define HPFFileReaderTest_h
+
+#include <btkAcquisitionFileReader.h>
+#include <btkConvert.h>
+
+CXXTEST_SUITE(HPFFileReaderTest)
+{
+ CXXTEST_TEST(NoFile)
+ {
+ btk::AcquisitionFileReader::Pointer reader = btk::AcquisitionFileReader::New();
+ TS_ASSERT_THROWS_EQUALS(reader->Update(), const btk::AcquisitionFileReaderException &e, e.what(), std::string("Filename must be specified"));
+ };
+
+ CXXTEST_TEST(MisspelledFile)
+ {
+ btk::AcquisitionFileReader::Pointer reader = btk::AcquisitionFileReader::New();
+ reader->SetFilename("test.hpf");
+ TS_ASSERT_THROWS_EQUALS(reader->Update(), const btk::AcquisitionFileReaderException &e, e.what(), std::string("File doesn't exist\nFilename: test.hpf"));
+ };
+
+ CXXTEST_TEST(Run_number_34_VTT_Rep_1DOT6)
+ {
+ btk::AcquisitionFileReader::Pointer reader = btk::AcquisitionFileReader::New();
+ reader->SetFilename(HPFFilePathIN + "Run_number_34_VTT_Rep_1.6.hpf");
+ reader->Update();
+ btk::Acquisition::Pointer acq = reader->GetOutput();
+
+ TS_ASSERT_EQUALS(acq->GetFirstFrame(), 1);
+ TS_ASSERT_EQUALS(acq->GetPointFrequency(), 2000.0);
+ TS_ASSERT_EQUALS(acq->GetPointNumber(), 0);
+ TS_ASSERT_EQUALS(acq->GetPointFrameNumber(), 10752);
+ TS_ASSERT_EQUALS(acq->GetAnalogFrameNumber(), 10752);
+ TS_ASSERT_EQUALS(acq->GetAnalogFrequency(), 2000.0);
+ TS_ASSERT_EQUALS(acq->GetAnalogNumber(), 40);
+
+ TS_ASSERT_EQUALS(acq->GetAnalog(0)->GetLabel(), "R TRAPEZIUS MIDDLE FIBERS: EMG 1");
+ TS_ASSERT_EQUALS(acq->GetAnalog(1)->GetLabel(), "R TRAPEZIUS MIDDLE FIBERS: ACC X 1");
+ TS_ASSERT_EQUALS(acq->GetAnalog(2)->GetLabel(), "R TRAPEZIUS MIDDLE FIBERS: ACC Y 1");
+ TS_ASSERT_EQUALS(acq->GetAnalog(3)->GetLabel(), "R TRAPEZIUS MIDDLE FIBERS: ACC Z 1");
+ TS_ASSERT_EQUALS(acq->GetAnalog(4)->GetLabel(), "L TRAPEZIUS MIDDLE FIBERS: EMG 2");
+ TS_ASSERT_EQUALS(acq->GetAnalog(5)->GetLabel(), "L TRAPEZIUS MIDDLE FIBERS: ACC X 2");
+ TS_ASSERT_EQUALS(acq->GetAnalog(6)->GetLabel(), "L TRAPEZIUS MIDDLE FIBERS: ACC Y 2");
+ TS_ASSERT_EQUALS(acq->GetAnalog(7)->GetLabel(), "L TRAPEZIUS MIDDLE FIBERS: ACC Z 2");
+ TS_ASSERT_EQUALS(acq->GetAnalog(8)->GetLabel(), "R EXTENSOR DIGITORUM: EMG 3");
+ TS_ASSERT_EQUALS(acq->GetAnalog(9)->GetLabel(), "R EXTENSOR DIGITORUM: ACC X 3");
+ TS_ASSERT_EQUALS(acq->GetAnalog(10)->GetLabel(), "R EXTENSOR DIGITORUM: ACC Y 3");
+ TS_ASSERT_EQUALS(acq->GetAnalog(11)->GetLabel(), "R EXTENSOR DIGITORUM: ACC Z 3");
+ TS_ASSERT_EQUALS(acq->GetAnalog(12)->GetLabel(), "L EXTENSOR DIGITORUM: EMG 4");
+ TS_ASSERT_EQUALS(acq->GetAnalog(13)->GetLabel(), "L EXTENSOR DIGITORUM: ACC X 4");
+ TS_ASSERT_EQUALS(acq->GetAnalog(14)->GetLabel(), "L EXTENSOR DIGITORUM: ACC Y 4");
+ TS_ASSERT_EQUALS(acq->GetAnalog(15)->GetLabel(), "L EXTENSOR DIGITORUM: ACC Z 4");
+ TS_ASSERT_EQUALS(acq->GetAnalog(16)->GetLabel(), "R FLEXOR CARPI RADIALIS: EMG 5");
+ TS_ASSERT_EQUALS(acq->GetAnalog(17)->GetLabel(), "R FLEXOR CARPI RADIALIS: ACC X 5");
+ TS_ASSERT_EQUALS(acq->GetAnalog(18)->GetLabel(), "R FLEXOR CARPI RADIALIS: ACC Y 5");
+ TS_ASSERT_EQUALS(acq->GetAnalog(19)->GetLabel(), "R FLEXOR CARPI RADIALIS: ACC Z 5");
+ TS_ASSERT_EQUALS(acq->GetAnalog(20)->GetLabel(), "L FLEXOR CARPI RADIALIS: EMG 6");
+ TS_ASSERT_EQUALS(acq->GetAnalog(21)->GetLabel(), "L FLEXOR CARPI RADIALIS: ACC X 6");
+ TS_ASSERT_EQUALS(acq->GetAnalog(22)->GetLabel(), "L FLEXOR CARPI RADIALIS: ACC Y 6");
+ TS_ASSERT_EQUALS(acq->GetAnalog(23)->GetLabel(), "L FLEXOR CARPI RADIALIS: ACC Z 6");
+ TS_ASSERT_EQUALS(acq->GetAnalog(24)->GetLabel(), "R BICEPS BRACHII: EMG 7");
+ TS_ASSERT_EQUALS(acq->GetAnalog(25)->GetLabel(), "R BICEPS BRACHII: ACC X 7");
+ TS_ASSERT_EQUALS(acq->GetAnalog(26)->GetLabel(), "R BICEPS BRACHII: ACC Y 7");
+ TS_ASSERT_EQUALS(acq->GetAnalog(27)->GetLabel(), "R BICEPS BRACHII: ACC Z 7");
+ TS_ASSERT_EQUALS(acq->GetAnalog(28)->GetLabel(), "L BICEPS BRACHII: EMG 8");
+ TS_ASSERT_EQUALS(acq->GetAnalog(29)->GetLabel(), "L BICEPS BRACHII: ACC X 8");
+ TS_ASSERT_EQUALS(acq->GetAnalog(30)->GetLabel(), "L BICEPS BRACHII: ACC Y 8");
+ TS_ASSERT_EQUALS(acq->GetAnalog(31)->GetLabel(), "L BICEPS BRACHII: ACC Z 8");
+ TS_ASSERT_EQUALS(acq->GetAnalog(32)->GetLabel(), "R TRICEPS BRACHII: EMG 9");
+ TS_ASSERT_EQUALS(acq->GetAnalog(33)->GetLabel(), "R TRICEPS BRACHII: ACC X 9");
+ TS_ASSERT_EQUALS(acq->GetAnalog(34)->GetLabel(), "R TRICEPS BRACHII: ACC Y 9");
+ TS_ASSERT_EQUALS(acq->GetAnalog(35)->GetLabel(), "R TRICEPS BRACHII: ACC Z 9");
+ TS_ASSERT_EQUALS(acq->GetAnalog(36)->GetLabel(), "L TRICEPS BRACHII: EMG 10");
+ TS_ASSERT_EQUALS(acq->GetAnalog(37)->GetLabel(), "L TRICEPS BRACHII: ACC X 10");
+ TS_ASSERT_EQUALS(acq->GetAnalog(38)->GetLabel(), "L TRICEPS BRACHII: ACC Y 10");
+ TS_ASSERT_EQUALS(acq->GetAnalog(39)->GetLabel(), "L TRICEPS BRACHII: ACC Z 10");
+
+ TS_ASSERT_EQUALS(acq->GetAnalog(0)->GetUnit(), "V");
+ TS_ASSERT_EQUALS(acq->GetAnalog(1)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(2)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(3)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(4)->GetUnit(), "V");
+ TS_ASSERT_EQUALS(acq->GetAnalog(5)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(6)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(7)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(8)->GetUnit(), "V");
+ TS_ASSERT_EQUALS(acq->GetAnalog(9)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(10)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(11)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(12)->GetUnit(), "V");
+ TS_ASSERT_EQUALS(acq->GetAnalog(13)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(14)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(15)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(16)->GetUnit(), "V");
+ TS_ASSERT_EQUALS(acq->GetAnalog(17)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(18)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(19)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(20)->GetUnit(), "V");
+ TS_ASSERT_EQUALS(acq->GetAnalog(21)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(22)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(23)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(24)->GetUnit(), "V");
+ TS_ASSERT_EQUALS(acq->GetAnalog(25)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(26)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(27)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(28)->GetUnit(), "V");
+ TS_ASSERT_EQUALS(acq->GetAnalog(29)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(30)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(31)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(32)->GetUnit(), "V");
+ TS_ASSERT_EQUALS(acq->GetAnalog(33)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(34)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(35)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(36)->GetUnit(), "V");
+ TS_ASSERT_EQUALS(acq->GetAnalog(37)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(38)->GetUnit(), "g");
+ TS_ASSERT_EQUALS(acq->GetAnalog(39)->GetUnit(), "g");
+
+ for (btk::Acquisition::AnalogConstIterator itA = acq->BeginAnalog() ; itA != acq->EndAnalog() ; ++itA)
+ {
+ for (int i = 0 ; i < 10 ; ++i)
+ {
+ TS_ASSERT_DELTA((*itA)->GetValues().coeff(i), 0.0, 1e-5);
+ }
+ }
+
+ TS_ASSERT_DELTA(acq->GetAnalog(0)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(1)->GetValues().coeff(10), 0.3238856, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(2)->GetValues().coeff(10), 1.326369, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(3)->GetValues().coeff(10), -3.640687, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(4)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(5)->GetValues().coeff(10), -0.3735166, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(6)->GetValues().coeff(10), -1.078769, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(7)->GetValues().coeff(10), -3.737764, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(8)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(9)->GetValues().coeff(10), -2.818379, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(10)->GetValues().coeff(10), 1.680531, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(11)->GetValues().coeff(10), -1.932598, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(12)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(13)->GetValues().coeff(10), -3.235401, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(14)->GetValues().coeff(10), -0.7581546, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(15)->GetValues().coeff(10), -1.25684, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(16)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(17)->GetValues().coeff(10), -2.622296, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(18)->GetValues().coeff(10), 2.348345, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(19)->GetValues().coeff(10), 0.5745529, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(20)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(21)->GetValues().coeff(10), -2.841617, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(22)->GetValues().coeff(10), -1.628069, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(23)->GetValues().coeff(10), 0.3194182, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(24)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(25)->GetValues().coeff(10), -2.612428, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(26)->GetValues().coeff(10), 2.221158, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(27)->GetValues().coeff(10), -1.152982, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(28)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(29)->GetValues().coeff(10), -2.339089, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(30)->GetValues().coeff(10), -2.129879, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(31)->GetValues().coeff(10), -0.7680386, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(32)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(33)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(34)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(35)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(36)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(37)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(38)->GetValues().coeff(10), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(39)->GetValues().coeff(10), 0.0, 1e-5);
+
+ TS_ASSERT_DELTA(acq->GetAnalog(0)->GetValues().coeff(5135), -4.01E-05, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(1)->GetValues().coeff(5135), -0.06477713, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(2)->GetValues().coeff(5135), 0.5684439, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(3)->GetValues().coeff(5135), -0.8942038, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(4)->GetValues().coeff(5135), -1.51E-06, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(5)->GetValues().coeff(5135), -0.06225277, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(6)->GetValues().coeff(5135), -0.5076562, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(7)->GetValues().coeff(5135), -0.9666631, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(8)->GetValues().coeff(5135), 1.09E-05, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(9)->GetValues().coeff(5135), -0.7209805, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(10)->GetValues().coeff(5135), 0.1867257, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(11)->GetValues().coeff(5135), -0.4664891, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(12)->GetValues().coeff(5135), 7.22E-06, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(13)->GetValues().coeff(5135), -0.9059124, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(14)->GetValues().coeff(5135), -0.1895387, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(15)->GetValues().coeff(5135), -0.3142101, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(16)->GetValues().coeff(5135), 5.00E-05, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(17)->GetValues().coeff(5135), -0.6395844, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(18)->GetValues().coeff(5135), 0.6981567, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(19)->GetValues().coeff(5135), 0.0, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(20)->GetValues().coeff(5135), 6.88E-06, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(21)->GetValues().coeff(5135), -0.7749864, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(22)->GetValues().coeff(5135), -0.6887985, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(23)->GetValues().coeff(5135), 0.1277673, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(24)->GetValues().coeff(5135), 2.23E-05, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(25)->GetValues().coeff(5135), -0.6220067, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(26)->GetValues().coeff(5135), 0.6346164, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(27)->GetValues().coeff(5135), -0.5124366, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(28)->GetValues().coeff(5135), -7.55E-06, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(29)->GetValues().coeff(5135), -0.7386595, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(30)->GetValues().coeff(5135), -0.6454179, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(31)->GetValues().coeff(5135), -0.2560129, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(32)->GetValues().coeff(5135), 1.51E-06, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(33)->GetValues().coeff(5135), -0.6322685, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(34)->GetValues().coeff(5135), -0.1950575, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(35)->GetValues().coeff(5135), 0.5104636, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(36)->GetValues().coeff(5135), 7.17E-05, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(37)->GetValues().coeff(5135), -0.5763358, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(38)->GetValues().coeff(5135), 0.3774208, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(39)->GetValues().coeff(5135), 0.700477 , 1e-5);
+
+ TS_ASSERT_DELTA(acq->GetAnalog(0)->GetValues().coeff(10751), -2.11E-05, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(1)->GetValues().coeff(10751), -0.06477713, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(2)->GetValues().coeff(10751), 0.6316043, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(3)->GetValues().coeff(10751), -0.8942038, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(4)->GetValues().coeff(10751), 3.19E-06, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(5)->GetValues().coeff(10751), -0.06225277, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(6)->GetValues().coeff(10751), -0.4441991, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(7)->GetValues().coeff(10751), -0.9666631, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(8)->GetValues().coeff(10751), 2.52E-06, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(9)->GetValues().coeff(10751), -0.8520679, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(10)->GetValues().coeff(10751), 0.1244838, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(11)->GetValues().coeff(10751), -0.4664891, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(12)->GetValues().coeff(10751), 9.06E-06, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(13)->GetValues().coeff(10751), -0.8412044, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(14)->GetValues().coeff(10751), -0.1895387, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(15)->GetValues().coeff(10751), -0.188526, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(16)->GetValues().coeff(10751), 3.19E-05, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(17)->GetValues().coeff(10751), -0.7035428, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(18)->GetValues().coeff(10751), 0.6981567, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(19)->GetValues().coeff(10751), -0.06383921, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(20)->GetValues().coeff(10751), 6.88E-06, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(21)->GetValues().coeff(10751), -0.7104042, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(22)->GetValues().coeff(10751), -0.5635625, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(23)->GetValues().coeff(10751), 0.2555345, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(24)->GetValues().coeff(10751), 7.89E-06, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(25)->GetValues().coeff(10751), -0.746408, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(26)->GetValues().coeff(10751), 0.5076932, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(27)->GetValues().coeff(10751), -0.5124366, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(28)->GetValues().coeff(10751), -7.22E-06, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(29)->GetValues().coeff(10751), -0.6771045, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(30)->GetValues().coeff(10751), -0.5808761, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(31)->GetValues().coeff(10751), -0.1280064, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(32)->GetValues().coeff(10751), -1.43E-05, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(33)->GetValues().coeff(10751), -0.7587223, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(34)->GetValues().coeff(10751), -0.1950575, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(35)->GetValues().coeff(10751), 0.5104636, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(36)->GetValues().coeff(10751), 1.51E-06, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(37)->GetValues().coeff(10751), -0.5763358, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(38)->GetValues().coeff(10751), 0.5661312, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(39)->GetValues().coeff(10751), 0.0, 1e-5);
+ };
+
+ CXXTEST_TEST(ConvertedFromEMGv3)
+ {
+ btk::AcquisitionFileReader::Pointer reader = btk::AcquisitionFileReader::New();
+ reader->SetFilename(HPFFilePathIN + "Set1[Rep2]_v3.emg.hpf");
+ reader->Update();
+ btk::Acquisition::Pointer acq = reader->GetOutput();
+
+ TS_ASSERT_EQUALS(acq->GetAnalogNumber(),8);
+ TS_ASSERT_EQUALS(acq->GetAnalogFrameNumber(),60000);
+ TS_ASSERT_EQUALS(acq->GetAnalogFrequency(),2000);
+ for (int i = 0 ; i < 8; ++i)
+ {
+ TS_ASSERT_EQUALS(acq->GetAnalog(i)->GetLabel(), "EMG Ch" + btk::ToString(i+1) + " (V)");
+ TS_ASSERT_EQUALS(acq->GetAnalog(i)->GetUnit(), "V");
+ TS_ASSERT_EQUALS(acq->GetAnalog(i)->GetGain(), btk::Analog::PlusMinus1);
+ }
+ TS_ASSERT_DELTA(acq->GetAnalog(0)->GetValues().coeff(0), 1.6327e-5, 1e-9);
+ TS_ASSERT_DELTA(acq->GetAnalog(2)->GetValues().coeff(29999), 3.4180e-5, 1e-9);
+ TS_ASSERT_DELTA(acq->GetAnalog(5)->GetValues().coeff(12000), 3.4180e-5, 1e-9)
+ TS_ASSERT_DELTA(acq->GetAnalog(7)->GetValues().coeff(59999), 4.3945e-5, 1e-9);
+ }
+};
+
+CXXTEST_SUITE_REGISTRATION(HPFFileReaderTest)
+CXXTEST_TEST_REGISTRATION(HPFFileReaderTest, NoFile)
+CXXTEST_TEST_REGISTRATION(HPFFileReaderTest, MisspelledFile)
+CXXTEST_TEST_REGISTRATION(HPFFileReaderTest, Run_number_34_VTT_Rep_1DOT6)
+CXXTEST_TEST_REGISTRATION(HPFFileReaderTest, ConvertedFromEMGv3)
+#endif
diff --git a/Testing/C++/KistlerDATFileReaderTest.h b/Testing/C++/KistlerDATFileReaderTest.h
index 3b3c064c..cf19d3c8 100644
--- a/Testing/C++/KistlerDATFileReaderTest.h
+++ b/Testing/C++/KistlerDATFileReaderTest.h
@@ -38,7 +38,7 @@ CXXTEST_SUITE(KistlerDATFileReaderTest)
{
TS_ASSERT_EQUALS(acq->GetAnalog(i)->GetLabel().compare(labels[i]), 0);
TS_ASSERT_EQUALS(acq->GetAnalog(i)->GetScale(), 1.0);
- TS_ASSERT_EQUALS(acq->GetAnalog(i)->GetOffset(), 0);
+ TS_ASSERT_EQUALS(acq->GetAnalog(i)->GetOffset(), 0.0);
}
btk::Analog::Values Fx = acq->GetAnalog(0)->GetValues() + acq->GetAnalog(1)->GetValues();
@@ -64,6 +64,32 @@ CXXTEST_SUITE(KistlerDATFileReaderTest)
reader->SetFilename(KistlerDATFilePathIN + "Truncated.dat");
TS_ASSERT_THROWS_EQUALS(reader->Update(), const btk::Exception &e, e.what(), std::string("Unexpected end of file."));
};
+
+ CXXTEST_TEST(DLL1)
+ {
+ btk::AcquisitionFileReader::Pointer reader = btk::AcquisitionFileReader::New();
+ reader->SetFilename(KistlerDATFilePathIN + "DLL1.dat");
+ reader->Update();
+ btk::Acquisition::Pointer acq = reader->GetOutput();
+
+ TS_ASSERT_EQUALS(acq->GetFirstFrame(), 1);
+ TS_ASSERT_EQUALS(acq->GetPointFrequency(), 100);
+ TS_ASSERT_EQUALS(acq->GetPointNumber(), 0);
+ TS_ASSERT_EQUALS(acq->GetPointFrameNumber(), 500);
+ TS_ASSERT_EQUALS(acq->GetAnalogFrequency(), 100);
+ TS_ASSERT_EQUALS(acq->GetAnalogNumber(), 8);
+ TS_ASSERT_EQUALS(acq->GetPointUnit(), "mm");
+
+ TS_ASSERT_DELTA(acq->GetAnalog(0)->GetValues()(0), -0.203036, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(0)->GetValues()(1), -0.203036, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(0)->GetValues()(2), -0.203036, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(0)->GetValues()(3), -0.357869, 1e-5);
+
+ TS_ASSERT_DELTA(acq->GetAnalog(7)->GetValues()(496), -68.238548, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(7)->GetValues()(497), -68.238548, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(7)->GetValues()(498), -68.582993, 1e-5);
+ TS_ASSERT_DELTA(acq->GetAnalog(7)->GetValues()(499), -68.582993, 1e-5);
+ };
};
CXXTEST_SUITE_REGISTRATION(KistlerDATFileReaderTest)
@@ -71,4 +97,5 @@ CXXTEST_TEST_REGISTRATION(KistlerDATFileReaderTest, NoFile)
CXXTEST_TEST_REGISTRATION(KistlerDATFileReaderTest, MisspelledFile)
CXXTEST_TEST_REGISTRATION(KistlerDATFileReaderTest, BioWare17)
CXXTEST_TEST_REGISTRATION(KistlerDATFileReaderTest, Truncated)
+CXXTEST_TEST_REGISTRATION(KistlerDATFileReaderTest, DLL1)
#endif
diff --git a/Testing/C++/MDFFileReaderTest.h b/Testing/C++/MDFFileReaderTest.h
index 99293a5e..d397d2f0 100644
--- a/Testing/C++/MDFFileReaderTest.h
+++ b/Testing/C++/MDFFileReaderTest.h
@@ -64,6 +64,22 @@ CXXTEST_SUITE(MDFFileReaderTest)
for (int j = 0 ; j < acqC3D->GetAnalogFrameNumber() ; j+=10)
TS_ASSERT_DELTA(acqMDF->GetAnalog(i)->GetValues()(j), acqC3D->GetAnalog(i)->GetValues()(j), 1e-5);
};
+
+ CXXTEST_TEST(ADBHL)
+ {
+ btk::AcquisitionFileReader::Pointer reader = btk::AcquisitionFileReader::New();
+ reader->SetFilename(MDFFilePathIN + "ADBHL.mdf");
+ reader->Update();
+
+ btk::Acquisition::Pointer acq = reader->GetOutput();
+
+ TS_ASSERT_EQUALS(acq->GetFirstFrame(), 1);
+ TS_ASSERT_EQUALS(acq->GetPointNumber(), 0);
+ TS_ASSERT(acq->GetPointFrameNumber() != 0);
+ TS_ASSERT_EQUALS(acq->GetPointFrameNumber(), acq->GetAnalogFrameNumber());
+ TS_ASSERT_EQUALS(acq->GetPointFrequency(), 1000.0);
+ TS_ASSERT_EQUALS(acq->GetAnalogNumber(), 32);
+ };
};
CXXTEST_SUITE_REGISTRATION(MDFFileReaderTest)
@@ -72,4 +88,5 @@ CXXTEST_TEST_REGISTRATION(MDFFileReaderTest, MisspelledFile)
CXXTEST_TEST_REGISTRATION(MDFFileReaderTest, Gait_bilateral_1997_Kistlerx1)
CXXTEST_TEST_REGISTRATION(MDFFileReaderTest, Gait_bilateral_1997_Kistlerx1_MDF_vs_C3D_float)
CXXTEST_TEST_REGISTRATION(MDFFileReaderTest, Gait_bilateral_1997_Kistlerx1_MDF_vs_C3D_integer)
+CXXTEST_TEST_REGISTRATION(MDFFileReaderTest, ADBHL)
#endif
diff --git a/Testing/C++/MergeAcquisitionFilterTest.h b/Testing/C++/MergeAcquisitionFilterTest.h
index 4532d8d1..6490c7ef 100644
--- a/Testing/C++/MergeAcquisitionFilterTest.h
+++ b/Testing/C++/MergeAcquisitionFilterTest.h
@@ -214,13 +214,13 @@ CXXTEST_SUITE(MergeAcquisitionFilterTest)
{
TS_ASSERT_EQUALS(output->GetPoint(i)->GetLabel(), input->GetPoint(i)->GetLabel());
TS_ASSERT_EQUALS(output->GetPoint(i + input->GetPointNumber())->GetLabel(), input->GetPoint(i)->GetLabel() + "_2");
- TS_ASSERT(output->GetPoint(i)->GetValues().isApprox(output->GetPoint(i + input->GetPointNumber())->GetValues()));
+ TS_ASSERT_EIGEN_DELTA(output->GetPoint(i)->GetValues(), output->GetPoint(i + input->GetPointNumber())->GetValues(), 1e-5);
}
for (int i = 0 ; i < input->GetAnalogNumber() ; ++i)
{
TS_ASSERT_EQUALS(output->GetAnalog(i)->GetLabel(), input->GetAnalog(i)->GetLabel());
TS_ASSERT_EQUALS(output->GetAnalog(i + input->GetAnalogNumber())->GetLabel(), input->GetAnalog(i)->GetLabel() + "_2");
- TS_ASSERT(output->GetAnalog(i)->GetValues().isApprox(output->GetAnalog(i + input->GetAnalogNumber())->GetValues()));
+ TS_ASSERT_EIGEN_DELTA(output->GetAnalog(i)->GetValues(), output->GetAnalog(i + input->GetAnalogNumber())->GetValues(), 1e-5);
}
for (int i = 0 ; i < input->GetEventNumber() ; ++i)
TS_ASSERT(*(output->GetEvent(i)) == *(input->GetEvent(i)));
@@ -1759,6 +1759,116 @@ CXXTEST_SUITE(MergeAcquisitionFilterTest)
TS_ASSERT_EQUALS(pfe->GetOutput()->GetItemNumber(), 2);
};
+
+ CXXTEST_TEST(Merge_Run4)
+ {
+ btk::AcquisitionFileReader::Pointer reader = btk::AcquisitionFileReader::New();
+ reader->SetFilename(C3DFilePathIN + "merge/Run4_1.c3d");
+
+ btk::AcquisitionFileReader::Pointer reader2 = btk::AcquisitionFileReader::New();
+ reader2->SetFilename(C3DFilePathIN + "merge/Run4_2.c3d");
+
+ btk::AcquisitionFileReader::Pointer reader3 = btk::AcquisitionFileReader::New();
+ reader3->SetFilename(C3DFilePathIN + "merge/Run4_3.c3d");
+
+ btk::MergeAcquisitionFilter::Pointer merger = btk::MergeAcquisitionFilter::New();
+ merger->SetInput(0, reader->GetOutput());
+ merger->SetInput(1, reader2->GetOutput());
+ merger->SetInput(2, reader3->GetOutput());
+
+ btk::Acquisition::Pointer output = merger->GetOutput();
+ output->Update();
+
+ TS_ASSERT_EQUALS(output->GetPointFrequency(), 200);
+ TS_ASSERT_EQUALS(output->GetAnalogFrequency(), 2000);
+ TS_ASSERT_EQUALS(output->GetPointNumber(), 17);
+ TS_ASSERT_EQUALS(output->GetAnalogNumber(), 13);
+ TS_ASSERT_EQUALS(output->GetPointFrameNumber(), 54539);
+ TS_ASSERT_EQUALS(output->GetAnalogFrameNumber(), 545390);
+ TS_ASSERT_EQUALS(output->GetEventNumber(), 0);
+
+ for (int j = 0 ; j < output->GetPointNumber() ; ++j)
+ {
+ btk::Point::Pointer op = output->GetPoint(j);
+ btk::Point::Pointer ip = reader->GetOutput()->GetPoint(op->GetLabel());
+ for (int i = 0 ; i < 12000 ; i+=100)
+ {
+ TS_ASSERT_DELTA(op->GetValues()(i,0), ip->GetValues()(i,0), 1e-5);
+ TS_ASSERT_DELTA(op->GetValues()(i,1), ip->GetValues()(i,1), 1e-5);
+ TS_ASSERT_DELTA(op->GetValues()(i,2), ip->GetValues()(i,2), 1e-5);
+ }
+ ip = reader2->GetOutput()->GetPoint(op->GetLabel());
+ for (int i = 12000 ; i < 24000 ; i+=100)
+ {
+ TS_ASSERT_DELTA(op->GetValues()(i,0), ip->GetValues()(i-12000,0), 1e-5);
+ TS_ASSERT_DELTA(op->GetValues()(i,1), ip->GetValues()(i-12000,1), 1e-5);
+ TS_ASSERT_DELTA(op->GetValues()(i,2), ip->GetValues()(i-12000,2), 1e-5);
+ }
+ ip = reader3->GetOutput()->GetPoint(op->GetLabel());
+ for (int i = 24000 ; i < 54539 ; i+=100)
+ {
+ TS_ASSERT_DELTA(op->GetValues()(i,0), ip->GetValues()(i-24000,0), 1e-5);
+ TS_ASSERT_DELTA(op->GetValues()(i,1), ip->GetValues()(i-24000,1), 1e-5);
+ TS_ASSERT_DELTA(op->GetValues()(i,2), ip->GetValues()(i-24000,2), 1e-5);
+ }
+ }
+
+ for (int j = 0 ; j < output->GetAnalogNumber() ; ++j)
+ {
+ btk::Analog::Pointer oa = output->GetAnalog(j);
+ btk::Analog::Pointer ia = reader->GetOutput()->GetAnalog(oa->GetLabel());
+ for (int i = 0 ; i < 120000 ; i+=100)
+ {
+ TS_ASSERT_DELTA(oa->GetValues()(i), ia->GetValues()(i), 1e-5);
+ }
+ ia = reader2->GetOutput()->GetAnalog(oa->GetLabel());
+ for (int i = 120000 ; i < 240000 ; i+=100)
+ {
+ TS_ASSERT_DELTA(oa->GetValues()(i), ia->GetValues()(i-120000), 1e-5);
+ }
+ ia = reader3->GetOutput()->GetAnalog(oa->GetLabel());
+ for (int i = 240000 ; i < 545390 ; i+=100)
+ {
+ TS_ASSERT_DELTA(oa->GetValues()(i), ia->GetValues()(i-240000), 1e-5);
+ }
+ }
+
+ btk::AcquisitionFileWriter::Pointer c3dWriter = btk::AcquisitionFileWriter::New();
+ c3dWriter->SetFilename(C3DFilePathOUT + "Run4_merged.c3d");
+ c3dWriter->SetInput(merger->GetOutput());
+ c3dWriter->Update();
+ // Exported C3D reader
+ btk::AcquisitionFileReader::Pointer c3dReader2 = btk::AcquisitionFileReader::New();
+ c3dReader2->SetFilename(C3DFilePathOUT + "Run4_merged.c3d");
+ btk::Acquisition::Pointer acq = c3dReader2->GetOutput();
+ acq->Update();
+
+ TS_ASSERT_EQUALS(output->GetPointFrequency(), acq->GetPointFrequency());
+ TS_ASSERT_EQUALS(output->GetAnalogFrequency(), acq->GetAnalogFrequency());
+ TS_ASSERT_EQUALS(output->GetPointNumber(), acq->GetPointNumber());
+ TS_ASSERT_EQUALS(output->GetAnalogNumber(), acq->GetAnalogNumber());
+ TS_ASSERT_EQUALS(output->GetPointFrameNumber(), acq->GetPointFrameNumber());
+ TS_ASSERT_EQUALS(output->GetAnalogFrameNumber(), acq->GetAnalogFrameNumber());
+ TS_ASSERT_EQUALS(output->GetEventNumber(), acq->GetEventNumber());
+
+ for (int i = 0 ; i < output->GetPointFrameNumber() ; i+=100)
+ {
+ for (int j = 0 ; j < output->GetPointNumber() ; ++j)
+ {
+ TS_ASSERT_DELTA(output->GetPoint(j)->GetValues().coeff(i,0), acq->GetPoint(j)->GetValues().coeff(i,0), 1e-5);
+ TS_ASSERT_DELTA(output->GetPoint(j)->GetValues().coeff(i,1), acq->GetPoint(j)->GetValues().coeff(i,1), 1e-5);
+ TS_ASSERT_DELTA(output->GetPoint(j)->GetValues().coeff(i,2), acq->GetPoint(j)->GetValues().coeff(i,2), 1e-5);
+ }
+ }
+
+ for (int i = 0 ; i < output->GetAnalogFrameNumber() ; i+=100)
+ {
+ for (int j = 0 ; j < output->GetAnalogNumber() ; ++j)
+ {
+ TS_ASSERT_DELTA(output->GetAnalog(j)->GetValues().coeff(i), acq->GetAnalog(j)->GetValues().coeff(i), 1e-5);
+ }
+ }
+ };
};
CXXTEST_SUITE_REGISTRATION(MergeAcquisitionFilterTest)
@@ -1793,4 +1903,5 @@ CXXTEST_TEST_REGISTRATION(MergeAcquisitionFilterTest, C3D_Reconstructed_From_TRC
CXXTEST_TEST_REGISTRATION(MergeAcquisitionFilterTest, C3D_Reconstructed_From_CAL_ANC_TRC)
CXXTEST_TEST_REGISTRATION(MergeAcquisitionFilterTest, C3D_Reconstructed_From_ANC_CAL_TRC)
CXXTEST_TEST_REGISTRATION(MergeAcquisitionFilterTest, SH01_C3D_ANC_FP)
+CXXTEST_TEST_REGISTRATION(MergeAcquisitionFilterTest, Merge_Run4)
#endif
diff --git a/Testing/C++/TRBFileReaderTest.h b/Testing/C++/TRBFileReaderTest.h
index 59fc3a88..fd4b89dd 100644
--- a/Testing/C++/TRBFileReaderTest.h
+++ b/Testing/C++/TRBFileReaderTest.h
@@ -111,6 +111,38 @@ CXXTEST_SUITE(TRBFileReaderTest)
}
}
}
+
+ CXXTEST_TEST(Barefoot)
+ {
+ btk::AcquisitionFileReader::Pointer reader = btk::AcquisitionFileReader::New();
+ reader->SetFilename(TRBFilePathIN + "barefoot_walking1.trb");
+ reader->Update();
+ btk::Acquisition::Pointer acq = reader->GetOutput();
+
+ TS_ASSERT_EQUALS(acq->GetPointNumber(), 41);
+ TS_ASSERT_EQUALS(acq->GetPoint(0)->GetLabel(), "L.Shoulder");
+ TS_ASSERT_EQUALS(acq->GetPoint(1)->GetLabel(), "L.Scapula");
+ TS_ASSERT_EQUALS(acq->GetPoint(2)->GetLabel(), "R.Shoulder");
+ TS_ASSERT_EQUALS(acq->GetPoint(3)->GetLabel(), "L.ASIS");
+ TS_ASSERT_EQUALS(acq->GetPoint(4)->GetLabel(), "V.Sacral");
+ TS_ASSERT_EQUALS(acq->GetPoint(5)->GetLabel(), "R.ASIS");
+ TS_ASSERT_EQUALS(acq->GetPoint(6)->GetLabel(), "R.Thigh");
+ TS_ASSERT_EQUALS(acq->GetPoint(7)->GetLabel(), "R.Knee");
+ TS_ASSERT_EQUALS(acq->GetPoint(8)->GetLabel(), "R.Shank");
+ TS_ASSERT_EQUALS(acq->GetPoint(9)->GetLabel(), "R.Ankle");
+ TS_ASSERT_EQUALS(acq->GetPoint(10)->GetLabel(), "R.Heel");
+ TS_ASSERT_EQUALS(acq->GetPoint(11)->GetLabel(), "R.Toe");
+ TS_ASSERT_EQUALS(acq->GetPoint(12)->GetLabel(), "L.Thigh");
+ TS_ASSERT_EQUALS(acq->GetPoint(13)->GetLabel(), "L.Knee");
+ TS_ASSERT_EQUALS(acq->GetPoint(14)->GetLabel(), "L.Shank");
+ TS_ASSERT_EQUALS(acq->GetPoint(15)->GetLabel(), "L.Ankle");
+ TS_ASSERT_EQUALS(acq->GetPoint(16)->GetLabel(), "L.Heel");
+ TS_ASSERT_EQUALS(acq->GetPoint(17)->GetLabel(), "L.Toe");
+ TS_ASSERT_EQUALS(acq->GetPoint(18)->GetLabel(), "uname*37");
+ TS_ASSERT_EQUALS(acq->GetPoint(19)->GetLabel(), "uname*38");
+
+ TS_ASSERT_DELTA(acq->GetPoint(18)->GetValues()(56,0), 2911.218750, 1e-5);
+ }
};
CXXTEST_SUITE_REGISTRATION(TRBFileReaderTest)
@@ -119,4 +151,5 @@ CXXTEST_TEST_REGISTRATION(TRBFileReaderTest, MisspelledFile)
CXXTEST_TEST_REGISTRATION(TRBFileReaderTest, FalseFile)
CXXTEST_TEST_REGISTRATION(TRBFileReaderTest, Gait)
CXXTEST_TEST_REGISTRATION(TRBFileReaderTest, Anto_TRB_vs_TRC)
+CXXTEST_TEST_REGISTRATION(TRBFileReaderTest, Barefoot)
#endif
diff --git a/Testing/C++/XLSOrthoTrakFileReaderTest.h b/Testing/C++/XLSOrthoTrakFileReaderTest.h
index 23888da2..24b37a3b 100644
--- a/Testing/C++/XLSOrthoTrakFileReaderTest.h
+++ b/Testing/C++/XLSOrthoTrakFileReaderTest.h
@@ -129,7 +129,51 @@ CXXTEST_SUITE(XLSOrthoTrakFileReaderTest)
TS_ASSERT_DELTA(acq->GetPoint(0)->GetValues().coeff(1, 0), -0.558, 1e-4);
// Last value
TS_ASSERT_DELTA(acq->GetPoint(50)->GetValues().coeff(acq->GetPointFrameNumber()-1, 0), 25.751, 1e-4);
+ };
+
+ CXXTEST_TEST(EmptySpatialParameters)
+ {
+ btk::AcquisitionFileReader::Pointer reader = btk::AcquisitionFileReader::New();
+ reader->SetFilename(XLSOrthoTrakFilePathIN + "EmptySpatialParameters.xls");
+ reader->Update();
+ btk::Acquisition::Pointer acq = reader->GetOutput();
+
+ TS_ASSERT_EQUALS(acq->GetPointFrameNumber(), 1357);
+ TS_ASSERT_EQUALS(acq->GetPointNumber(), 15);
+
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChildNumber(), 15);
+ TS_ASSERT_DELTA(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("Avg_Step_Width")->GetInfo()->ToDouble(0), 36.53 * 10, 1e-4);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("R_Velocity")->GetInfo()->GetValues().empty(), true);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("R_Stride_Len")->GetInfo()->GetValues().empty(), true);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("R_Cadence")->GetInfo()->GetValues().empty(), true);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("L_Velocity")->GetInfo()->GetValues().empty(), true);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("L_Stride_Len")->GetInfo()->GetValues().empty(), true);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("L_Cadence")->GetInfo()->GetValues().empty(), true);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("R_Support_Time")->GetInfo()->ToDouble(0), 0.0);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("L_Support_Time")->GetInfo()->ToDouble(0), 0.0);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("R_Non_Support")->GetInfo()->ToDouble(0), 0.0);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("L_Non_Support")->GetInfo()->ToDouble(0), 0.0);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("R_Step_Len")->GetInfo()->GetValues().empty(), true);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("L_Step_Len")->GetInfo()->GetValues().empty(), true);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("R_Dbl_Support")->GetInfo()->ToDouble(0), 0.0);
+ TS_ASSERT_EQUALS(acq->GetMetaData()->GetChild("SPATIOTEMP")->GetChild("L_Dbl_Support")->GetInfo()->ToDouble(0), 0.0);
+
+ TS_ASSERT_EQUALS(acq->GetEventNumber(), 0);
+ // First frame
+ TS_ASSERT_DELTA(acq->GetPoint(0)->GetValues().coeff(0,0), 62.767, 1e-4);
+ TS_ASSERT_DELTA(acq->GetPoint(0)->GetValues().coeff(0,1), -15.171, 1e-4);
+ TS_ASSERT_DELTA(acq->GetPoint(0)->GetValues().coeff(0,2), 9.519, 1e-4);
+ TS_ASSERT_DELTA(acq->GetPoint(14)->GetValues().coeff(0,0), 13.240, 1e-4);
+ TS_ASSERT_DELTA(acq->GetPoint(14)->GetValues().coeff(0,1), -3.836, 1e-4);
+ TS_ASSERT_DELTA(acq->GetPoint(14)->GetValues().coeff(0,2), 0.000, 1e-4);
+ // Last frame
+ TS_ASSERT_DELTA(acq->GetPoint(0)->GetValues().coeff(acq->GetPointFrameNumber()-1, 0), 63.938, 1e-4);
+ TS_ASSERT_DELTA(acq->GetPoint(0)->GetValues().coeff(acq->GetPointFrameNumber()-1, 1), -13.137, 1e-4);
+ TS_ASSERT_DELTA(acq->GetPoint(0)->GetValues().coeff(acq->GetPointFrameNumber()-1, 2), 15.398, 1e-4);
+ TS_ASSERT_DELTA(acq->GetPoint(14)->GetValues().coeff(acq->GetPointFrameNumber()-1, 0), 20.452, 1e-4);
+ TS_ASSERT_DELTA(acq->GetPoint(14)->GetValues().coeff(acq->GetPointFrameNumber()-1, 1), -1.318, 1e-4);
+ TS_ASSERT_DELTA(acq->GetPoint(14)->GetValues().coeff(acq->GetPointFrameNumber()-1, 2), 0.0, 1e-4);
};
};
@@ -137,4 +181,5 @@ CXXTEST_SUITE_REGISTRATION(XLSOrthoTrakFileReaderTest)
CXXTEST_TEST_REGISTRATION(XLSOrthoTrakFileReaderTest, NoFile)
CXXTEST_TEST_REGISTRATION(XLSOrthoTrakFileReaderTest, MisspelledFile)
CXXTEST_TEST_REGISTRATION(XLSOrthoTrakFileReaderTest, Gait)
+CXXTEST_TEST_REGISTRATION(XLSOrthoTrakFileReaderTest, EmptySpatialParameters)
#endif
diff --git a/Testing/C++/_TDDConfigure.h.in b/Testing/C++/_TDDConfigure.h.in
index 191883ef..de8e6d8e 100644
--- a/Testing/C++/_TDDConfigure.h.in
+++ b/Testing/C++/_TDDConfigure.h.in
@@ -57,5 +57,10 @@
#define BSFFilePathOUT std::string(TDD_FilePathOUT) + "BSFSamples/"
#define KistlerDATFilePathIN std::string(TDD_FilePathIN) + "KistlerDATSamples/"
#define KistlerDATFilePathOUT std::string(TDD_FilePathOUT) + "KistlerDATSamples/"
+#define HPFFilePathIN std::string(TDD_FilePathIN) + "HPFSamples/"
+#define HPFFilePathOUT std::string(TDD_FilePathOUT) + "HPFSamples/"
+
+#define TS_ASSERT_EIGEN_DELTA(lhs,rhs,prec) \
+ TS_ASSERT((lhs - rhs).cwiseAbs().maxCoeff() <= prec)
#endif // _TDDConfigure_h
\ No newline at end of file
diff --git a/Testing/C++/_TDDIO.cpp b/Testing/C++/_TDDIO.cpp
index b7f7cbf4..0e2fb90f 100644
--- a/Testing/C++/_TDDIO.cpp
+++ b/Testing/C++/_TDDIO.cpp
@@ -29,6 +29,8 @@
#include "EMxFileReaderTest.h"
#include "GRxFileIOTest.h"
#include "GRxFileReaderTest.h"
+#include "HPFFileIOTest.h"
+#include "HPFFileReaderTest.h"
#include "KistlerDATFileIOTest.h"
#include "KistlerDATFileReaderTest.h"
#include "MDFFileIOTest.h"
diff --git a/Testing/Matlab/testBTKCommon.m b/Testing/Matlab/testBTKCommon.m
index f76fdc18..462c9c01 100644
--- a/Testing/Matlab/testBTKCommon.m
+++ b/Testing/Matlab/testBTKCommon.m
@@ -339,3 +339,16 @@ end
assertEqual(isempty(strfind(lasterr, 'The second input must be a matrix of real (double) values corresponding to the new analog channels values to assign.')), false);
btkDeleteAcquisition(h);
end
+
+function testGetPointsInfoResiduals(d)
+h = btkNewAcquisition(1,100);
+values = rand(100,3);
+residuals = rand(100,1);
+btkSetPointLabel(h, 1, 'Toto');
+btkSetPointValues(h, 1, values);
+btkSetPointResiduals(h, 1, residuals);
+[points, pointsInfo] = btkGetPoints(h);
+assertElementsAlmostEqual(points.Toto, values, 'absolute', 1e-15);
+assertElementsAlmostEqual(pointsInfo.residuals.Toto, residuals, 'absolute', 1e-15);
+btkDeleteAcquisition(h);
+end
diff --git a/Testing/Matlab/testBTKIO.m b/Testing/Matlab/testBTKIO.m
index eb90d645..63de187c 100644
--- a/Testing/Matlab/testBTKIO.m
+++ b/Testing/Matlab/testBTKIO.m
@@ -66,7 +66,7 @@ for i = 1:numAnalogs
btkSetAnalogLabel(h1,i,['MyAnalog#',num2str(i)]);
btkSetAnalogDescription(h1,i,'test');
btkSetAnalogScale(h1,i,1.0);
- btkSetAnalogOffset(h1,i,0);
+ btkSetAnalogOffset(h1,i,0.0);
end
btkSetMetaDataValues(h1,'POINT','RATE',btkMetaDataInfo('Real',400));
btkWriteAcquisition(h1,strcat(d.out,'/C3DSamples/InternalsUpdateUpdateMetaDataBased_Matlab.c3d'),'InternalsUpdate','MetaDataBasedUpdate');
diff --git a/Utilities/CxxTest/additional/generator/macro/cxxtest/TestGenerator.h b/Utilities/CxxTest/additional/generator/macro/cxxtest/TestGenerator.h
index f072e257..3eda5fd7 100644
--- a/Utilities/CxxTest/additional/generator/macro/cxxtest/TestGenerator.h
+++ b/Utilities/CxxTest/additional/generator/macro/cxxtest/TestGenerator.h
@@ -1,6 +1,6 @@
/*
* Additional part for CxxTest
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Utilities/Doxygen/Doxyfile_API.in b/Utilities/Doxygen/Doxyfile_API.in
index 7d4aeb05..9a879b7b 100644
--- a/Utilities/Doxygen/Doxyfile_API.in
+++ b/Utilities/Doxygen/Doxyfile_API.in
@@ -1999,7 +1999,7 @@ PREDEFINED = BTK_COMMON_EXPORT \
BTK_BASICFILTERS_EXPORT \
BTK_VISSUPPORT_EXPORT \
BTK_IO_ACQUISITON_FILE_FACTORY_INIT \
- btkChooseNativeBinaryFileStream=BinaryFileStream \
+ _btk_choose_native_binary_file_stream=BinaryFileStream \
HAVE_SYS_MMAP=1
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this
diff --git a/Utilities/EasyInstall/EasyInstall.java b/Utilities/EasyInstall/EasyInstall.java
index 676e41e1..d9c8ba45 100755
--- a/Utilities/EasyInstall/EasyInstall.java
+++ b/Utilities/EasyInstall/EasyInstall.java
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Utilities/Open3DMotion/README-BTK.txt b/Utilities/Open3DMotion/README-BTK.txt
index eedaea2f..328f1b3c 100644
--- a/Utilities/Open3DMotion/README-BTK.txt
+++ b/Utilities/Open3DMotion/README-BTK.txt
@@ -1,2 +1,2 @@
-The folder "src" contains the code found in the GitHub repository "https://github.com/Alzathar/Open3DMotion", commit fa48ae0f27c197e7016205bd9af97ccd082f1b30.
+The folder "src" contains the code found in the GitHub repository "https://github.com/Alzathar/Open3DMotion", commit 21033cdb1a88eff954a5909ce6355999a677815e.
The folder "src/btkOpen3DMotion" contains code necessary to use Open3DMotion optimally in BTK.
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/BinMemFactoryPython.cpp b/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/BinMemFactoryPython.cpp
new file mode 100644
index 00000000..8b5f2f62
--- /dev/null
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/BinMemFactoryPython.cpp
@@ -0,0 +1,16 @@
+/*--
+ Open3DMotion
+ Copyright (c) 2004-2013.
+ All rights reserved.
+ See LICENSE.txt for more information.
+--*/
+
+#include "Open3DMotion/Bindings/Python/BinMemFactoryPython.h"
+
+namespace Open3DMotion
+{
+ MemoryHandlerPython* BinMemFactoryPython::Allocate(size_t numbytes) const
+ {
+ return new MemoryHandlerPython(numbytes);
+ }
+}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/BinMemFactoryPython.h b/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/BinMemFactoryPython.h
new file mode 100644
index 00000000..5febd7c5
--- /dev/null
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/BinMemFactoryPython.h
@@ -0,0 +1,24 @@
+/*--
+ Open3DMotion
+ Copyright (c) 2004-2013.
+ All rights reserved.
+ See LICENSE.txt for more information.
+--*/
+
+#ifndef _ORMPP_BIN_MEM_FACTORY_PYTHON_H_
+#define _ORMPP_BIN_MEM_FACTORY_PYTHON_H_
+
+#include "Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactory.h"
+#include "Open3DMotion/Bindings/Python/MemoryHandlerPython.h"
+
+namespace Open3DMotion
+{
+ class BinMemFactoryPython : public BinMemFactory
+ {
+ public:
+ virtual MemoryHandlerPython* Allocate(size_t numbytes) const;
+ };
+
+}
+
+#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/MemoryHandlerPython.cpp b/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/MemoryHandlerPython.cpp
new file mode 100644
index 00000000..dcc656a2
--- /dev/null
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/MemoryHandlerPython.cpp
@@ -0,0 +1,62 @@
+/*--
+ Open3DMotion
+ Copyright (c) 2004-2013.
+ All rights reserved.
+ See LICENSE.txt for more information.
+--*/
+
+#include "MemoryHandlerPython.h"
+
+namespace Open3DMotion
+{
+ DEFINE_CLASS_NAME(MemoryHandlerPython);
+
+ MemoryHandlerPython::MemoryHandlerPython(size_t _sizebytes)
+ {
+ // Since there appears to be no 'new' method,
+ // easiest way to efficiently allocate array of correct size appears to be
+ // to make one of length 1 and then resize it
+ py_bytearray = PyByteArray_FromStringAndSize("", 1);
+ PyByteArray_Resize(py_bytearray, _sizebytes);
+ }
+
+ MemoryHandlerPython::MemoryHandlerPython(const MemoryHandlerPython& ref)
+ {
+ // Copy pointer and increment Python reference
+ py_bytearray = ref.py_bytearray;
+ Py_INCREF(py_bytearray);
+ }
+
+ MemoryHandlerPython::MemoryHandlerPython(PyObject* _py_to_acquire)
+ {
+ // Copy pointer and increment Python reference
+ py_bytearray = _py_to_acquire;
+ Py_INCREF(py_bytearray);
+ }
+
+
+ MemoryHandlerPython::~MemoryHandlerPython()
+ {
+ Py_DECREF(py_bytearray);
+ }
+
+ MemoryHandlerPython* MemoryHandlerPython::Clone() const
+ {
+ return new MemoryHandlerPython(*this);
+ }
+
+ size_t MemoryHandlerPython::SizeBytes() const
+ {
+ return PyByteArray_Size(py_bytearray);
+ }
+
+ UInt8* MemoryHandlerPython::Data() const
+ {
+ return (UInt8*) PyByteArray_AsString(py_bytearray);
+ }
+
+ size_t MemoryHandlerPython::RefCount() const
+ {
+ return py_bytearray->ob_refcnt;
+ }
+}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/MemoryHandlerPython.h b/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/MemoryHandlerPython.h
new file mode 100644
index 00000000..0d782de3
--- /dev/null
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/MemoryHandlerPython.h
@@ -0,0 +1,51 @@
+/*--
+ Open3DMotion
+ Copyright (c) 2004-2013.
+ All rights reserved.
+ See LICENSE.txt for more information.
+--*/
+
+#ifndef _OPEN3DMOTION_MEMORY_HANDLER_PYTHON_H_
+#define _OPEN3DMOTION_MEMORY_HANDLER_PYTHON_H_
+
+#include "Open3DMotion/OpenORM/Leaves/MemoryHandler.h"
+#include <Python.h>
+
+namespace Open3DMotion
+{
+ /**
+
+ A reference-counted memory handler using Python byte array
+ for memory (and the Python reference-counting mechanism).
+
+ */
+ class MemoryHandlerPython : public MemoryHandler
+ {
+ friend class PythonConvert;
+
+ public:
+ DECLARE_CLASS_NAME();
+
+ MemoryHandlerPython(size_t _sizebytes);
+
+ MemoryHandlerPython(const MemoryHandlerPython& ref);
+
+ MemoryHandlerPython(PyObject* _py_to_acquire);
+
+ virtual ~MemoryHandlerPython();
+
+ virtual MemoryHandlerPython* Clone() const;
+
+ virtual size_t SizeBytes() const;
+
+ virtual UInt8* Data() const;
+
+ virtual size_t RefCount() const;
+
+ private:
+ mutable PyObject* py_bytearray;
+ };
+
+}
+
+#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/PythonConvert.cpp b/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/PythonConvert.cpp
new file mode 100644
index 00000000..f2ec6c3e
--- /dev/null
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/PythonConvert.cpp
@@ -0,0 +1,201 @@
+/*--
+ Open3DMotion
+ Copyright (c) 2004-2013.
+ All rights reserved.
+ See LICENSE.txt for more information.
+--*/
+
+#include "PythonConvert.h"
+#include "MemoryHandlerPython.h"
+#include "Open3DMotion/OpenORM/Leaves/TreeString.h"
+#include "Open3DMotion/OpenORM/Leaves/TreeBool.h"
+#include "Open3DMotion/OpenORM/Leaves/TreeInt32.h"
+#include "Open3DMotion/OpenORM/Leaves/TreeFloat64.h"
+#include "Open3DMotion/OpenORM/Leaves/TreeBinary.h"
+#include "Open3DMotion/OpenORM/Branches/TreeList.h"
+#include "Open3DMotion/OpenORM/Branches/TreeCompound.h"
+
+namespace Open3DMotion
+{
+ const char PythonConvert::default_list_element_name[] = "ArrayItem";
+
+ PyObject* PythonConvert::FromTree(const TreeValue* value)
+ {
+ if (value == NULL)
+ {
+ Py_RETURN_NONE;
+ }
+ else if (value->ClassNameMatches(TreeString::classname))
+ {
+ const TreeString* value_string = static_cast<const TreeString*> (value);
+ std::string strcopy( value_string->Value() );
+ PyObject* py_string = PyString_FromString(&strcopy[0]);
+ return py_string;
+ }
+ else if (value->ClassNameMatches(TreeBool::classname))
+ {
+ const TreeBool* value_bool = static_cast<const TreeBool*> (value);
+ if (value_bool->Value())
+ {
+ Py_RETURN_TRUE;
+ }
+ else
+ {
+ Py_RETURN_FALSE;
+ }
+ }
+ else if (value->ClassNameMatches(TreeInt32::classname))
+ {
+ const TreeInt32* value_int32 = static_cast<const TreeInt32*> (value);
+ PyObject* py_value = PyLong_FromLong(value_int32->Value());
+ return py_value;
+ }
+ else if (value->ClassNameMatches(TreeFloat64::classname))
+ {
+ const TreeFloat64* value_float64 = static_cast<const TreeFloat64*> (value);
+ PyObject* py_value = PyFloat_FromDouble(value_float64->Value());
+ return py_value;
+ }
+ else if (value->ClassNameMatches(TreeBinary::classname))
+ {
+ const TreeBinary* bin = static_cast<const TreeBinary*> (value);
+ const MemoryHandlerPython* mem = NamedClassCast<MemoryHandler, MemoryHandlerPython> ( bin->BinMemory() );
+ if (mem)
+ {
+ PyObject* py_bytearray = mem->py_bytearray;
+ Py_INCREF(py_bytearray);
+ return py_bytearray;
+ }
+ else
+ {
+ // Only support binary memory allocated using the Python allocator
+ Py_RETURN_NONE;
+ }
+ }
+ else if (value->ClassNameMatches(TreeList::classname))
+ {
+ const TreeList* value_list = static_cast<const TreeList*> (value);
+ PyObject* py_list = PyList_New(1);
+ PyList_SetItem(py_list, 0, PyString_FromString(value_list->ElementName().c_str()));
+ const std::vector<TreeValue*>& element_array = value_list->ElementArray();
+ for (std::vector<TreeValue*>::const_iterator iter(element_array.begin()); iter != element_array.end(); iter++)
+ {
+ // Use Append here not SetItem
+ // To provide robustness to items we can't process (will just skip them)
+ PyObject* py_new_item = PythonConvert::FromTree(*iter);
+ if (py_new_item != Py_None)
+ {
+ PyList_Append(py_list, py_new_item);
+ }
+ Py_DECREF(py_new_item);
+ }
+ return py_list;
+ }
+ else if (value->ClassNameMatches(TreeCompound::classname))
+ {
+ const TreeCompound* c = static_cast<const TreeCompound*> (value);
+ PyObject* py_c = PyDict_New();
+ size_t n = c->NumElements();
+ for (size_t i = 0; i < n; i++)
+ {
+ const TreeCompoundNode* node = c->Node(i);
+ PyObject* py_new_item = PythonConvert::FromTree(node->Value());
+ if (py_new_item != Py_None)
+ {
+ PyDict_SetItemString(py_c, node->Name().c_str(), py_new_item);
+ }
+ Py_DECREF(py_new_item);
+ }
+ return py_c;
+ }
+ else
+ {
+ Py_RETURN_NONE;
+ }
+ }
+
+ TreeValue* PythonConvert::ToTree(PyObject* py_value)
+ {
+ if (py_value == NULL || py_value == Py_None)
+ {
+ return NULL;
+ }
+ else if (PyString_Check(py_value))
+ {
+ return new TreeString( PyString_AS_STRING(py_value) );
+ }
+ else if (PyBool_Check(py_value))
+ {
+ return new TreeBool( (py_value == Py_True) ? true : false );
+ }
+ else if (PyLong_Check(py_value))
+ {
+ return new TreeInt32(PyLong_AsLong(py_value));
+ }
+ else if (PyFloat_Check(py_value))
+ {
+ return new TreeFloat64(PyFloat_AsDouble(py_value));
+ }
+ else if (PyByteArray_Check(py_value))
+ {
+ MemoryHandlerPython mem( py_value );
+ return new TreeBinary( &mem );
+ }
+ else if (PyList_Check(py_value))
+ {
+ // default element name if none found at start of list
+ const char* element_name = default_list_element_name;
+
+ // if first element is a string, use it as element name
+ Py_ssize_t s = PyList_Size(py_value);
+ Py_ssize_t index(0);
+ if (s >= 1)
+ {
+ PyObject* py_obj0 = PyList_GetItem(py_value, 0);
+ if (PyString_Check(py_obj0))
+ {
+ element_name = PyString_AsString(py_obj0);
+ ++index;
+ }
+ }
+
+ // copy the rest
+ TreeList* result_list = new TreeList(element_name);
+ for (; index < s; index++)
+ {
+ PyObject* py_obj = PyList_GetItem(py_value, index);
+ TreeValue* tree_item = PythonConvert::ToTree(py_obj);
+ if (tree_item)
+ {
+ result_list->Add(tree_item);
+ }
+ }
+
+ return result_list;
+ }
+ else if (PyDict_Check(py_value))
+ {
+ TreeCompound* c = new TreeCompound;
+ PyObject* key = NULL;
+ PyObject* py_element = NULL;
+ Py_ssize_t pos = 0;
+ while (PyDict_Next(py_value, &pos, &key, &py_element))
+ {
+ if (PyString_Check(key))
+ {
+ TreeValue* element = PythonConvert::ToTree(py_element);
+ if (element != NULL)
+ {
+ const char* key_string = PyString_AsString(key);
+ c->Set(key_string, element);
+ }
+ }
+ }
+ return c;
+ }
+ else
+ {
+ return NULL;
+ }
+ }
+}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/PythonConvert.h b/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/PythonConvert.h
new file mode 100644
index 00000000..5723a189
--- /dev/null
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Bindings/Python/PythonConvert.h
@@ -0,0 +1,30 @@
+/*--
+ Open3DMotion
+ Copyright (c) 2004-2013.
+ All rights reserved.
+ See LICENSE.txt for more information.
+--*/
+
+#ifndef _OPEN3DMOTION_PYTHON_CONVERT_H_
+#define _OPEN3DMOTION_PYTHON_CONVERT_H_
+
+#include "Open3DMotion/OpenORM/TreeValue.h"
+#include <Python.h>
+
+namespace Open3DMotion
+{
+
+ class PythonConvert
+ {
+ public:
+ static const char default_list_element_name[];
+
+ static PyObject* FromTree(const TreeValue* value);
+
+ static TreeValue* ToTree(PyObject* py_value);
+
+ };
+
+}
+
+#endif
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/ForceCalculator.cpp b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/ForceCalculator.cpp
index b864c88d..1b1ee28e 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/ForceCalculator.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/ForceCalculator.cpp
@@ -113,7 +113,7 @@ namespace Open3DMotion
return true;
}
- bool ForceCalculator::Compute(TimeSequence*& force, TimeSequence*& point, TimeSequence*& freemoment, ForceMeasurementTimeSequence& mts, BinMemFactory& memfactory) const
+ bool ForceCalculator::Compute(TimeSequence*& force, TimeSequence*& point, TimeSequence*& freemoment, ForceMeasurementTimeSequence& mts, const BinMemFactory& memfactory) const
{
// initialise to NULL
force = NULL;
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/ForceCalculator.h b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/ForceCalculator.h
index 837746c5..6389ca66 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/ForceCalculator.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/ForceCalculator.h
@@ -48,7 +48,7 @@ namespace Open3DMotion
bool Compute(Vector3& force, Vector3& point, Vector3& freemoment, const ForceMeasurements& measurements, std::vector<double>& buffer_rawanalog, std::vector<double>& buffer_calanalog) const;
- bool Compute(TimeSequence*& force, TimeSequence*& point, TimeSequence*& freemoment, ForceMeasurementTimeSequence& mts, BinMemFactory& memfactory) const;
+ bool Compute(TimeSequence*& force, TimeSequence*& point, TimeSequence*& freemoment, ForceMeasurementTimeSequence& mts, const BinMemFactory& memfactory) const;
/**
Summary
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/Interpolate.cpp b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/Interpolate.cpp
new file mode 100644
index 00000000..0ca6cc52
--- /dev/null
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/Interpolate.cpp
@@ -0,0 +1,340 @@
+/*--
+ Open3DMotion
+ Copyright (c) 2004-2013.
+ All rights reserved.
+ See LICENSE.txt for more information.
+--*/
+
+#include "Open3DMotion/Biomechanics/Algorithms/Interpolate.h"
+#include "Open3DMotion/Biomechanics/Trial/TSFactory.h"
+#include "Open3DMotion/Maths/Vector3.h"
+#include <limits.h>
+
+namespace Open3DMotion
+{
+ using namespace std;
+
+ void Interpolate::Linear(TimeSequence& ts) throw(NoSuchFieldException)
+ {
+ //size_t numframes = ts.NumFrames(); // Not used
+ bool haveseen = false;
+ size_t firstvisible(SIZE_MAX);
+ size_t lastvisible(SIZE_MAX);
+ TSOccVector3Iter iresult(ts);
+ TSOccVector3ConstIter isee0(ts);
+ TSOccVector3ConstIter isee1(ts);
+ for ( ; iresult.HasFrame(); iresult.Next())
+ {
+ if (!iresult.Occluded())
+ {
+ if (!haveseen)
+ {
+ firstvisible = iresult.FrameIndex();
+ haveseen = true;
+ }
+ continue;
+ }
+
+ if (!haveseen)
+ continue;
+
+ // last seen
+ isee0.SeekTo(iresult.FrameIndex()-1);
+
+ // find next visible
+ isee1.SeekTo(iresult.FrameIndex()+1);
+ while (isee1.HasFrame() && isee1.Occluded())
+ isee1.Next();
+
+ // not found
+ if (!isee1.HasFrame())
+ {
+ lastvisible = isee0.FrameIndex();
+ break;
+ }
+
+ // interpolate to next
+ for (; iresult.FrameIndex() < isee1.FrameIndex(); iresult.Next())
+ {
+ double s = (double)(iresult.FrameIndex()-isee0.FrameIndex()) / (double)(isee1.FrameIndex()-isee0.FrameIndex());
+ Vector3::Ratio(iresult.Value(), s, isee0.Value(), isee1.Value());
+ }
+ }
+
+ //-- fill in start and end with const values
+
+ // fill in start
+ if (firstvisible != SIZE_MAX)
+ {
+ isee0.SeekTo(firstvisible);
+ for (iresult.SeekTo(0); iresult.FrameIndex() < firstvisible; iresult.Next())
+ {
+ memcpy(iresult.Value(), isee0.Value(), 3*sizeof(double));
+ iresult.Occluded() = true;
+ }
+ }
+
+ // fill in end
+ if (lastvisible != SIZE_MAX)
+ {
+ isee0.SeekTo(lastvisible);
+ for (iresult.SeekTo(lastvisible+1); iresult.HasFrame(); iresult.Next())
+ {
+ memcpy(iresult.Value(), isee0.Value(), 3*sizeof(double));
+ iresult.Occluded() = true;
+ }
+ }
+ }
+
+ void Interpolate::Cubic(TimeSequence& ts, size_t maxnumslopesamples /*=10*/) throw(NoSuchFieldException)
+ {
+ // size_t numframes = ts.NumFrames(); // Not used
+ bool haveseen = false;
+ size_t firstvisible(SIZE_MAX);
+ size_t lastvisible(SIZE_MAX);
+ TSOccVector3Iter iresult(ts);
+ TSOccVector3ConstIter isee0(ts);
+ TSOccVector3ConstIter isee1(ts);
+ TSOccVector3ConstIter isee2(ts);
+ TSOccVector3ConstIter isee3(ts);
+ while (iresult.HasFrame())
+ {
+ // find non-occluded pair of adjacent frames
+ if (!iresult.Occluded())
+ {
+ iresult.Next();
+ if (iresult.HasFrame() && !iresult.Occluded())
+ {
+ if (!haveseen)
+ {
+ firstvisible = iresult.FrameIndex() - 1;
+ haveseen = true;
+ }
+ iresult.Next();
+ continue;
+ }
+ }
+
+ // no previous pair of frames - cannot do interp until find them
+ if (!haveseen)
+ {
+ iresult.Next();
+ continue;
+ }
+
+ // last seen pair
+ isee0.SeekTo(iresult.FrameIndex()-2);
+ isee1.SeekTo(iresult.FrameIndex()-1);
+
+ // find next visible pair
+ isee2.SeekTo(iresult.FrameIndex()+1);
+ isee3.SeekTo(iresult.FrameIndex()+2);
+ while (isee2.HasFrame() && isee3.HasFrame() && (isee2.Occluded() || isee3.Occluded()))
+ {
+ isee2.Next();
+ isee3.Next();
+ }
+
+ // no subsequent pair found
+ if (!isee2.HasFrame() || !isee3.HasFrame())
+ {
+ lastvisible = isee1.FrameIndex();
+ break;
+ }
+
+ // determine max samples to use either side of gap
+ UInt32 gap = isee2.FrameIndex() - isee1.FrameIndex() + 1;
+ UInt32 numslopesamples = gap / 2;
+ if (numslopesamples < 2)
+ numslopesamples = 2;
+ else if (numslopesamples > maxnumslopesamples)
+ numslopesamples = maxnumslopesamples;
+
+ // go at least one sample left of start of occluded region
+ // up to max of numslopesamples whilst still in view
+ UInt32 islope;
+ for (islope = 1; islope < numslopesamples; islope++)
+ {
+ isee0.Prev();
+ if (!isee0.HasFrame())
+ break;
+ }
+ isee0.Next();
+
+ // next visible after that
+ for (islope = 1; islope < numslopesamples; islope++)
+ {
+ isee3.Next();
+ if (!isee3.HasFrame())
+ break;
+ }
+ isee3.Prev();
+
+ // mean value across region before
+ UInt32 numbefore = isee1.FrameIndex() - isee0.FrameIndex();
+ Vector3 mean_before(0.0);
+ for (islope = 0; islope <= numbefore; islope++, isee0.Next())
+ mean_before += isee0.Value();
+ mean_before /= (numbefore+1);
+
+ // mean value across region afterwards
+ UInt32 numafter = isee3.FrameIndex() - isee2.FrameIndex();
+ Vector3 mean_after(0.0);
+ for (islope = 0; islope <= numafter; islope++, isee3.Prev())
+ mean_after += isee3.Value();
+ mean_after /= (numafter+1);
+
+ // start and end points
+ const Vector3& p0 = isee1.Value();
+ const Vector3& p1 = isee2.Value();
+
+ // mean slope before (not really MLE estimate)
+ Vector3 m0;
+ Vector3::Sub(m0, p0, mean_before);
+ m0 /= 0.5 * numbefore;
+
+ // mean slope after (not really MLE estimate)
+ Vector3 m1;
+ Vector3::Sub(m1, mean_after, p1);
+ m1 /= 0.5 * numafter;
+
+ //-- use x, x1, dx0, dx1 to get parameters of x = a + bt + ct2 + dt3:
+ //-- (!gap must be (float) or (float)ed to avoid integer overflow of gap*gap*gap)
+ double rgap2 = 1.0 / (gap * gap);
+ double rgap3 = 1.0 / (gap * gap * gap);
+
+ // compute coeffs of cubic
+ Vector3 a, b, c, d;
+ for(UInt32 dim = 0; dim < 3; dim++)
+ {
+ double p2 = p1[dim] - p0[dim] - (m0[dim] * gap);
+ double m2 = m1[dim] - m0[dim];
+ a[dim] = p0[dim];
+ b[dim] = m0[dim];
+ c[dim] = ((3.0F * p2) - (m2 * gap)) * rgap2;
+ d[dim] = ((m2 * gap) - (2.0F * p2)) * rgap3;
+ }
+
+ // do cubic interp
+ for (; iresult.FrameIndex() < isee2.FrameIndex(); iresult.Next())
+ {
+ double t = (double)(iresult.FrameIndex()-isee1.FrameIndex());
+ double* y = iresult.Value();
+ for (UInt32 dim = 0; dim < 3; dim++)
+ y[dim] = a[dim] + t * (b[dim] + t * (c[dim] + t * d[dim]));
+ }
+ }
+
+ //-- fill in start and end with const values
+
+ // fill in start
+ if (firstvisible != SIZE_MAX)
+ {
+ isee0.SeekTo(firstvisible);
+ for (iresult.SeekTo(0); iresult.FrameIndex() < firstvisible; iresult.Next())
+ {
+ memcpy(iresult.Value(), isee0.Value(), 3*sizeof(double));
+ iresult.Occluded() = true;
+ }
+ }
+
+ // fill in end
+ if (lastvisible != SIZE_MAX)
+ {
+ isee0.SeekTo(lastvisible);
+ for (iresult.SeekTo(lastvisible+1); iresult.HasFrame(); iresult.Next())
+ {
+ memcpy(iresult.Value(), isee0.Value(), 3*sizeof(double));
+ iresult.Occluded() = true;
+ }
+ }
+ }
+
+}
+
+#if 0
+ // Archive cubic code from Codamotion Analysis
+
+ //-- cubic interpolation:
+ float p0[3] = {x, y, z};
+ float p1[3] = {x1, y1, z1};
+ float m0[3] = {0.0F, 0.0F, 0.0F};
+ float m1[3] = {0.0F, 0.0F, 0.0F};
+ float rn;
+ int e;
+
+ //-- get slopes either side of gap from average of gap/2 epochs,
+ //-- up to MaxNumSlopeSamples epochs max (more for Pelvis markers)
+ int nmax = (int)(gap * 0.5F);
+ if(nmax < 2) nmax = 2;
+ if(nmax > MaxNumSlopeSamples) nmax = MaxNumSlopeSamples;
+
+ //-- get slope at beginning of gap:
+ //-- sum points backwards n epochs, if poss:
+ float sumX = 0.0F, sumY = 0.0F, sumZ = 0.0F;
+ for(int n = 1; n <= nmax; n++)
+ {
+ e = i0 - n;
+ if(e < FirstInViewEpoch ) // || !bMarkerInView[epoch]) - OK already interpolated
+ break;
+ //-- use already-interpolated data:
+ sumX += InterpolatedData[e].Dim[0];
+ sumY += InterpolatedData[e].Dim[1];
+ sumZ += InterpolatedData[e].Dim[2];
+ }
+ if(n > 1)
+ {
+ rn = 1.0F / (float)(n - 1);
+ m0[0] = (x - sumX * rn) * rn * 2.0F;
+ m0[1] = (y - sumY * rn) * rn * 2.0F;
+ m0[2] = (z - sumZ * rn) * rn * 2.0F;
+ }
+ //else m0[] = 0
+
+ //-- get slope at end of gap:
+ //-- sum points forwards n epochs, while still in-view:
+ sumX = sumY = sumZ = 0.0F;
+ for(n = 1; n <= nmax; n++)
+ {
+ int e = epoch + n;
+ if(e >= NumEpochs || !bMarkerInView[e])
+ break;
+ sumX += FilteredData[e].Dim[0];
+ sumY += FilteredData[e].Dim[1];
+ sumZ += FilteredData[e].Dim[2];
+ }
+ if(n > 1)
+ {
+ rn = 1.0F / (float)(n - 1);
+ m1[0] = (sumX * rn - x1) * rn * 2.0F;
+ m1[1] = (sumY * rn - y1) * rn * 2.0F;
+ m1[2] = (sumZ * rn - z1) * rn * 2.0F;
+ }
+ //else m1[] = 0
+
+ //-- use x, x1, dx0, dx1 to get parameters of x = a + bt + ct2 + dt3:
+ //-- (!gap must be (float) or (float)ed to avoid integer overflow of gap*gap*gap)
+ float rgap3 = 1.0F / (gap * gap * gap);
+ float rgap2 = rgap3 * gap; //yuk? (but avoids a second division)
+
+ //-- for each of X, Y, Z:
+ for(int dim = 0; dim < 3; dim++)
+ {
+ float p2 = p1[dim] - p0[dim] - (m0[dim] * gap);
+ float m2 = m1[dim] - m0[dim];
+ float a = p0[dim];
+ float b = m0[dim];
+ float c = ((3.0F * p2) - (m2 * gap)) * rgap2;
+ float d = ((m2 * gap) - (2.0F * p2)) * rgap3;
+
+ //-- fill-in the gap:
+ int imax = epoch - i0;
+ for(i = 1; i < imax; i++)
+ {
+ //-- (!must (float) i to avoid integer overflow)
+ register float t = (float)i;
+ InterpolatedData[i0 + i].Dim[dim] = a + t * (b + t * (c + t * d));
+ }
+ }
+ }
+#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/Interpolate.h b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/Interpolate.h
new file mode 100644
index 00000000..d500bf77
--- /dev/null
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/Interpolate.h
@@ -0,0 +1,34 @@
+/*--
+ Open3DMotion
+ Copyright (c) 2004-2013.
+ All rights reserved.
+ See LICENSE.txt for more information.
+--*/
+
+#ifndef _OPEN3DMOTION_INTERPOLATE_H_
+#define _OPEN3DMOTION_INTERPOLATE_H_
+
+#include "Open3DMotion/OpenORM/Types.h"
+#include "Open3DMotion/Biomechanics/Trial/TimeSequence.h"
+
+namespace Open3DMotion
+{
+
+ // Perform linear interpolation
+ class Interpolate
+ {
+ public:
+ static const size_t cubic_default_maxnumslopesamples = 10UL;
+
+ public:
+
+ // Apply to 3D sequence (individual xyz coords treated independently)
+ static void Linear(TimeSequence& ts) throw(NoSuchFieldException);
+
+ // Apply to 3D sequence (individual xyz coords treated independently)
+ static void Cubic(TimeSequence& ts, size_t maxnumslopesamples = cubic_default_maxnumslopesamples) throw(NoSuchFieldException);
+
+ };
+}
+
+#endif
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShape.cpp b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShape.cpp
new file mode 100644
index 00000000..72541fb9
--- /dev/null
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShape.cpp
@@ -0,0 +1,296 @@
+/*--
+ Open3DMotion
+ Copyright (c) 2004-2013.
+ All rights reserved.
+ See LICENSE.txt for more information.
+--*/
+
+#include "Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShape.h"
+
+#ifndef OPEN3DMOTION_LINEAR_ALGEBRA_EIGEN
+extern "C"
+{
+#include <f2clibs/f2c.h>
+#include <clapack.h>
+}
+#else
+#include <Eigen/Dense>
+#include <Eigen/SVD>
+#endif
+
+namespace Open3DMotion
+{
+ const UInt32 RigidBodyResult::success = 0;
+ const UInt32 RigidBodyResult::timesequence_mismatch = 1;
+ const UInt32 RigidBodyResult::visibility_disconnected = 2;
+ const UInt32 RigidBodyResult::insufficient_points = 3;
+ const UInt32 RigidBodyResult::did_not_converge = 4;
+
+ RigidBodyShape::RigidBodyShape()
+ {
+ }
+
+ RigidBodyShape::RigidBodyShape(const RigidBodyShape& src)
+ {
+ *this = src;
+ }
+
+ const RigidBodyShape& RigidBodyShape::operator=(const RigidBodyShape& src)
+ {
+ marker.assign( src.marker.begin(), src.marker.end() );
+ return *this;
+ }
+
+ RigidBodyShape::~RigidBodyShape()
+ {
+ }
+
+ void RigidBodyShape::AddMarker(const double* position, bool visible)
+ {
+ marker.resize(NumMarkers()+1);
+ marker.back().position = position;
+ marker.back().visible = visible ? 1 : 0;
+ }
+
+ bool RigidBodyShape::IsVisibilitySupersetOf(const RigidBodyShape& other) const
+ {
+ if (marker.size() == other.marker.size())
+ {
+ for (std::vector<RigidBodyMarker>::const_iterator iter_this( marker.begin() ), iter_other( other.marker.begin() );
+ iter_this != marker.end(); iter_this++, iter_other++)
+ {
+ if (iter_other->visible && !iter_this->visible)
+ return false;
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ bool RigidBodyShape::IsVisibilitySubsetOf(const RigidBodyShape& other) const
+ {
+ if (marker.size() == other.marker.size())
+ {
+ for (std::vector<RigidBodyMarker>::const_iterator iter_this( marker.begin() ), iter_other( other.marker.begin() );
+ iter_this != marker.end(); iter_this++, iter_other++)
+ {
+ if (iter_this->visible && !iter_other->visible)
+ return false;
+ }
+ return true;
+ }
+ else
+ {
+ return false;
+ }
+ }
+
+ size_t RigidBodyShape::NumberOfVisibleMarkersInCommonWith(const RigidBodyShape& other) const
+ {
+ size_t count = 0;
+ if (marker.size() == other.marker.size())
+ {
+ for (std::vector<RigidBodyMarker>::const_iterator iter_this( marker.begin() ), iter_other( other.marker.begin() );
+ iter_this != marker.end(); iter_this++, iter_other++)
+ {
+ if (iter_this->visible && iter_other->visible)
+ ++count;
+ }
+ }
+ return count;
+ }
+
+ void RigidBodyShape::EvaluateNonsingularity3D(std::vector<double>& s, std::vector<double>& coords)
+ {
+ long num_points(coords.size() / 3);
+ s.resize(3);
+
+#ifndef OPEN3DMOTION_LINEAR_ALGEBRA_EIGEN
+ long three(3);
+ long lwork(256);
+ double work[256];
+ long info(0);
+
+ std::vector<double> U(9);
+ std::vector<double> VT(num_points*num_points);
+
+ // use lapack routine
+ // note coords must be column-major so first 3 elements correspond to first coord
+ dgesvd_(
+ "N", // don't actually need U
+ "N", // don't actually need VT
+ &three, // rows
+ &num_points, // cols
+ &coords[0], // input/output matrix
+ &three, // leading dimension of Acpy
+ &s[0], // singular values
+ &U[0], // left orthonormal matrix
+ &three, // leading dimension of left
+ &VT[0], // right orthonormal matrix
+ &num_points, // leading dimension of right
+ work, // workspace
+ &lwork, // size of workspace
+ &info); // returned error codes
+#else
+ Eigen::Map< Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::RowMajor> >
+ _coords(&coords[0], (int)num_points, 3);
+ Eigen::Map< Eigen::Matrix<double, 3, 1> > _s(&s[0], 3, 1);
+ Eigen::JacobiSVD< Eigen::Matrix<double, Eigen::Dynamic, 3, Eigen::RowMajor> > svd(_coords);
+ _s = svd.singularValues();
+#endif // OPEN3DMOTION_LINEAR_ALGEBRA_EIGEN
+ }
+
+
+ bool RigidBodyShape::HasUniqueFitWith(const RigidBodyShape& other, double tolerance) const
+ {
+ if (marker.size() == other.marker.size())
+ {
+ size_t num_in_common(0);
+ Vector3 common_centroid(0.0);
+ std::vector<double> common_coords;
+ common_coords.reserve(3*NumMarkers());
+ for (std::vector<RigidBodyMarker>::const_iterator iter_this( marker.begin() ), iter_other( other.marker.begin() );
+ iter_this != marker.end(); iter_this++, iter_other++)
+ {
+ if (iter_this->visible && iter_other->visible)
+ {
+ const Vector3& x = iter_this->position;
+ for (size_t j = 0; j < 3; j++)
+ common_coords.push_back(x[j]);
+ num_in_common++;
+ common_centroid += x;
+ }
+ }
+
+ if (num_in_common >= 3)
+ {
+ // subract centroid
+ common_centroid /= num_in_common;
+ double* x = &common_coords[0];
+ for (size_t j = 0; j < num_in_common; j++, x+=3)
+ {
+ Vector3::Sub(x, x, common_centroid);
+ }
+
+ // find singular values to estimate how non-colinear these points are
+ std::vector<double> s;
+ RigidBodyShape::EvaluateNonsingularity3D(s, common_coords);
+
+ // Simplified expression to test points sufficiently non-colinear
+ // (condition is sufficient but not always necessary)
+ double min_colinearity_allowed = 3.56*sqrt((double)num_in_common)*tolerance;
+ if (s[1] > min_colinearity_allowed)
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ UInt32 RigidBodyShape::ComputeFitTo(RigidTransform3& T, const RigidBodyShape& base) const
+ {
+ size_t num_points = NumMarkers();
+ if (num_points == base.NumMarkers())
+ {
+ // get centroids
+ Vector3 centroidA(0,0,0);
+ Vector3 centroidB(0,0,0);
+ const RigidBodyMarker* iter_A = &base.marker[0];
+ const RigidBodyMarker* iter_B = &marker[0];
+ size_t ipoint(0);
+ size_t num_in_common(0);
+ for (ipoint = 0; ipoint < num_points; ipoint++, iter_A++,iter_B++)
+ {
+ if (iter_A->visible && iter_B->visible)
+ {
+ Vector3::Add(centroidA.x, centroidA.x, iter_A->position);
+ Vector3::Add(centroidB.x, centroidB.x, iter_B->position);
+ ++num_in_common;
+ }
+ }
+
+ if (num_in_common >= 3)
+ {
+ // normalise
+ centroidA /= num_in_common;
+ centroidB /= num_in_common;
+
+ // correlation matrix
+ double sum_correl[9] =
+ { 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0,
+ 0.0, 0.0, 0.0
+ };
+
+ // find correlation matrix
+ iter_A = &base.marker[0];
+ iter_B = &marker[0];
+ for (ipoint = 0; ipoint < num_points; ipoint++, iter_A++, iter_B++)
+ {
+ if (iter_A->visible && iter_B->visible)
+ {
+ // input minus centroid
+ Vector3 normA;
+ Vector3::Sub(normA, iter_A->position, centroidA);
+
+ // cal minus centroid
+ Vector3 normB;
+ Vector3::Sub(normB, iter_B->position, centroidB);
+
+ // correlation (outer product)
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 3; j++)
+ sum_correl[3*i+j] += normA[i]*normB[j];
+ }
+ }
+
+ // SVD of correlation to get rotation
+ // from mean coords to this frame
+ double s[3];
+ double U[9], VT[9];
+ Matrix3x3::SVD(U, s, VT, sum_correl);
+
+ // force right-handed coord system
+ double detU = Matrix3x3::Det(U);
+ double detV = Matrix3x3::Det(VT);
+ if (detU*detV < 0.0)
+ {
+ VT[6] *= -1.0;
+ VT[7] *= -1.0;
+ VT[8] *= -1.0;
+ }
+
+ // this is the correct way round
+ Matrix3x3::Mul(T.R, U, VT);
+
+ // do post-subtraction of centroid B to get translation vector
+ double RcentroidB[3];
+ Matrix3x3::MulVec(RcentroidB, T.R, centroidB);
+ Vector3::Sub(T.t, centroidA, RcentroidB);
+
+ #if 0
+ iter_A = ptA;
+ iter_B = ptB;
+ for (ipoint = 0; ipoint < npoints; ipoint++, iter_A+=3, iter_B+=3)
+ {
+ Vector3 Tb;
+ RigidTransform3::MulVec(Tb, R, t, iter_B);
+ cerr << "x: " << iter_A[0] << " " << Tb[0] << endl;
+ cerr << "y: " << iter_A[1] << " " << Tb[1] << endl;
+ cerr << "z: " << iter_A[2] << " " << Tb[2] << endl;
+ Vector3::Sub(Tb, Tb, iter_A);
+ cerr << "Mod: " << Tb.Modulus() << endl;
+ }
+ #endif
+
+ return RigidBodyResult::success;
+ }
+ }
+
+ return RigidBodyResult::insufficient_points;
+ }
+
+}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShape.h b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShape.h
new file mode 100644
index 00000000..987ba1a0
--- /dev/null
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShape.h
@@ -0,0 +1,137 @@
+/*--
+ Open3DMotion
+ Copyright (c) 2004-2013.
+ All rights reserved.
+ See LICENSE.txt for more information.
+--*/
+
+#ifndef _OPEN3DMOTION_RIGID_BODY_SHAPE_H_
+#define _OPEN3DMOTION_RIGID_BODY_SHAPE_H_
+
+#include "Open3DMotion/Maths/Vector3.h"
+#include "Open3DMotion/Maths/RigidTransform3.h"
+#include <vector>
+
+class TestRigidBodyShape;
+
+namespace Open3DMotion
+{
+ /** Constants for possible return values from shape computations and MOSHFIT algorithm. */
+ class RigidBodyResult
+ {
+ public:
+
+ /** Computation successful. */
+ static const UInt32 success /*=0*/;
+
+ /** Problem with input time sequences. */
+ static const UInt32 timesequence_mismatch /*=1*/;
+
+ /** Visiblity graph was not fully connected. */
+ static const UInt32 visibility_disconnected /*=2*/;
+
+ /** Not enough points were used as input. */
+ static const UInt32 insufficient_points /*=3*/;
+
+ /** Convergence failure. */
+ static const UInt32 did_not_converge /*=4*/;
+ };
+
+ /** 3D point with associated visibility information. */
+ class RigidBodyMarker
+ {
+ public:
+ /** 3D location. */
+ Vector3 position;
+
+ /** Visibility flag (should be set to 1 if visible, 0 otherwise). */
+ UInt8 visible;
+ };
+
+ /** Shape defined by 3D points, each with associated visibility information. */
+ class RigidBodyShape
+ {
+ friend class ::TestRigidBodyShape;
+
+ public:
+
+ /** Construct with no points. */
+ RigidBodyShape();
+
+ /** Copy constructor.
+ @param src Shape to copy.
+ */
+ RigidBodyShape(const RigidBodyShape& src);
+
+ /** Assignment operator.
+ @param src Shape to copy.
+ */
+ const RigidBodyShape& operator=(const RigidBodyShape& src);
+
+ /** Destructor */
+ ~RigidBodyShape();
+
+ /** Add a 3D point.
+ @param position a 3-element array corresponding to 3D coordinate.
+ @param visible set to true to flag as visible, false to flag as occluded. */
+ void AddMarker(const double* position, bool visible);
+
+ /** @return Number of points in this shape. */
+ size_t NumMarkers() const
+ { return marker.size(); }
+
+ /** Retrieve one point of shape (immutable).
+ @param index Zero-based index of point.
+ @return Point at specified index.
+ */
+ const RigidBodyMarker& Marker(size_t index) const
+ { return marker[index]; }
+
+ /** Retrieve one point of shape.
+ @param index Zero-based index of point.
+ @return Point at specified index.
+ */
+ RigidBodyMarker& Marker(size_t index)
+ { return marker[index]; }
+
+ /** Determine whether visibility flags are a superset of another point collection.
+ @param other Shape to compare.
+ @return true if a superset, false otherwise.
+ */
+ bool IsVisibilitySupersetOf(const RigidBodyShape& other) const;
+
+ /** Determine whether visibility flags are a subset of another point collection.
+ @param other Shape to compare.
+ @return true if a subset, false otherwise.
+ */
+ bool IsVisibilitySubsetOf(const RigidBodyShape& other) const;
+
+ /** Count the number of visible points in common with another shape.
+ @param other Shape to compare.
+ @return Number of points in common. */
+ size_t NumberOfVisibleMarkersInCommonWith(const RigidBodyShape& other) const;
+
+ /** Determine whether there is a unique Procrustean fit to another shape, according to MOSHFIT criteria.
+ @param other Shape to compare.
+ @param distribution_tolerance Required tolerance on accuracy of input data.
+ @return true if a unique fit is guaranteed by MOSHFIT critera, false otherwise.
+ */
+ bool HasUniqueFitWith(const RigidBodyShape& other, double tolerance) const;
+
+ /** Compute the Procrustes fit using visible points.
+ @param T to be filled with the computed transformation from this shape to base shape.
+ @param base Base shape to fit.
+ @return RigidBodyResult::success if successful, error code otherwise.
+ */
+ UInt32 ComputeFitTo(RigidTransform3& T, const RigidBodyShape& base) const;
+
+ protected:
+ static void EvaluateNonsingularity3D(std::vector<double>& s, std::vector<double>& coords);
+
+ protected:
+ std::vector<RigidBodyMarker> marker;
+ };
+
+}
+
+#endif
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShapeCollection.cpp b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShapeCollection.cpp
new file mode 100644
index 00000000..b9fb78bb
--- /dev/null
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShapeCollection.cpp
@@ -0,0 +1,380 @@
+#include "Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShapeCollection.h"
+#include "Open3DMotion/Biomechanics/Trial/TSFactory.h"
+
+namespace Open3DMotion
+{
+ RigidBodyShapeCollection::RigidBodyShapeCollection()
+ {
+ }
+
+ UInt32 RigidBodyShapeCollection::CopyFromTimeSequences(const std::vector<const TimeSequence*>& input)
+ {
+ try
+ {
+ // clear any previous
+ shape.clear();
+
+ // copy if non-empty
+ size_t num_markers = input.size();
+ if (num_markers)
+ {
+ size_t num_frames = (size_t) input[0]->NumFrames();
+ shape.resize( num_frames );
+ for ( std::vector<const TimeSequence*>::const_iterator iter_input( input.begin() ); iter_input != input.end(); iter_input++)
+ {
+ if ((size_t)(*iter_input)->NumFrames() == num_frames)
+ {
+ std::vector<RigidBodyShape>::iterator iter_shape( shape.begin() );
+ for (TSOccVector3ConstIter iter_marker(**iter_input); iter_marker.HasFrame(); iter_marker.Next(), iter_shape++)
+ {
+ iter_shape->AddMarker(iter_marker.Value(), iter_marker.Occluded() ? 0 : 1);
+ }
+ }
+ else
+ {
+ return RigidBodyResult::timesequence_mismatch;
+ }
+ }
+ }
+
+ return RigidBodyResult::success;
+ }
+ catch (const NoSuchFieldException&)
+ {
+ return RigidBodyResult::timesequence_mismatch;
+ }
+ }
+
+ void RigidBodyShapeCollection::DilateVisiblity(UInt32 dilation)
+ {
+ if (shape.size())
+ {
+ size_t num_markers = shape[0].NumMarkers();
+
+ // forward dilation
+ std::vector<size_t> dilate_count_fwd(num_markers, 0);
+ for (std::vector<RigidBodyShape>::iterator iter_fwd( shape.begin() ); iter_fwd != shape.end(); iter_fwd++)
+ {
+ for (UInt8 imarker = 0; imarker < num_markers; imarker++)
+ {
+ size_t& c = dilate_count_fwd[imarker];
+ if (iter_fwd->Marker(imarker).visible == 0)
+ {
+ c = dilation;
+ }
+ else if (c)
+ {
+ --c;
+ iter_fwd->Marker(imarker).visible = 0;
+ }
+ }
+ }
+
+ // reverse dilation
+ std::vector<size_t> dilate_count_rvs(num_markers, 0);
+ for (std::vector<RigidBodyShape>::reverse_iterator iter_rvs( shape.rbegin() ); iter_rvs != shape.rend(); iter_rvs++)
+ {
+ for (UInt8 imarker = 0; imarker < num_markers; imarker++)
+ {
+ size_t& c = dilate_count_rvs[imarker];
+ if (iter_rvs->Marker(imarker).visible == 0)
+ {
+ c = dilation;
+ }
+ else if (c)
+ {
+ --c;
+ iter_rvs->Marker(imarker).visible = 0;
+ }
+ }
+ }
+ }
+ }
+
+ void RigidBodyShapeCollection::ComputeVisiblityCanon(RigidBodyVisibilityCanon& canon) const
+ {
+ std::vector< std::vector<RigidBodyShape>::const_iterator > canon_indices;
+ for (std::vector<RigidBodyShape>::const_iterator iter_shape( shape.begin() ); iter_shape != shape.end(); iter_shape++)
+ {
+ bool isnotsubcode = true;
+ for (std::vector< std::vector<RigidBodyShape>::const_iterator >::iterator iter_canon( canon_indices.begin() ); iter_canon != canon_indices.end(); iter_canon++)
+ {
+ if (*iter_canon != shape.end())
+ {
+ if (iter_shape->IsVisibilitySubsetOf( **iter_canon ))
+ {
+ isnotsubcode = false;
+ break;
+ }
+
+ if (iter_shape->IsVisibilitySupersetOf( **iter_canon ))
+ {
+ *iter_canon = shape.end();
+ }
+ }
+ }
+
+ if (isnotsubcode)
+ {
+ canon_indices.push_back( iter_shape );
+ }
+ }
+
+ canon.shape.clear();
+ for (std::vector< std::vector<RigidBodyShape>::const_iterator >::iterator iter_canon( canon_indices.begin() ); iter_canon != canon_indices.end(); iter_canon++)
+ {
+ if (*iter_canon != shape.end())
+ {
+ canon.shape.push_back( **iter_canon );
+ }
+ }
+ }
+
+ UInt32 RigidBodyShapeCollection::ComputeMeanShape(RigidBodyShape& mean, double distribution_tolerance, double convergence_accuracy) const
+ {
+ // minimal set of visiblity codes
+ RigidBodyVisibilityCanon canon;
+ ComputeVisiblityCanon(canon);
+
+ // re-order codes to ensure maximal ones go first
+ RigidBodyConnectedVisibilityCanon connected_canon;
+ UInt32 canon_result = canon.ComputeConnectedVisibilityCanon(connected_canon, distribution_tolerance);
+
+ // must be a complete covering of all points to work
+ if (canon_result != RigidBodyResult::success)
+ return canon_result;
+
+ // initialise shape
+ connected_canon.ComputeApproxMeanShape(mean);
+
+ // number of points
+ size_t num_markers = connected_canon.Shape(0).NumMarkers();
+
+ // zero vector to init markers
+ Vector3 zero(0.0);
+
+ // transform every shape to this one and update mean
+ // double previous_residual_rms = DBL_MAX;
+ for (size_t opt_count = 0; opt_count < 100; opt_count++)
+ {
+ // transform every shape and sum
+ std::vector<Vector3> point_sum(num_markers, zero);
+ std::vector<size_t> point_count(num_markers, 0);
+ // double dx2_sum = 0.0;
+ // size_t dx2_count = 0;
+ for (std::vector<RigidBodyShape>::const_iterator iter_shape( shape.begin() ); iter_shape != shape.end(); iter_shape++)
+ {
+ RigidTransform3 T;
+ iter_shape->ComputeFitTo(T, mean);
+ for (size_t marker_index = 0; marker_index < num_markers; marker_index++)
+ {
+ const RigidBodyMarker& x = iter_shape->Marker(marker_index);
+ if (x.visible)
+ {
+ // transform point to be nearest to mean as we can
+ Vector3 Tx;
+ RigidTransform3::MulVec(Tx, T, x.position);
+ point_sum[marker_index] += Tx;
+ point_count[marker_index]++;
+
+ // form sum residuals
+ // Vector3 dx;
+ // Vector3::Sub(dx, Tx, x.position);
+ // dx2_sum += dx.Modulus2();
+ // dx2_count++;
+ }
+ }
+ }
+
+ // update mean and compute max difference with previous
+ double max_difference = 0.0;
+ for (size_t marker_index = 0; marker_index < num_markers; marker_index++)
+ {
+ size_t n = point_count[marker_index];
+ if (n)
+ {
+ // compute updated marker position
+ Vector3& new_position = point_sum[marker_index];
+ new_position /= n;
+
+ // compute maximum coordinate difference with previous
+ RigidBodyMarker& m = mean.Marker(marker_index);
+ for (size_t dimension = 0; dimension < 3; dimension++)
+ {
+ double d = fabs(new_position[dimension] - m.position[dimension]);
+ if (d > max_difference)
+ max_difference = d;
+ }
+
+ // set new values
+ m.position = new_position;
+ }
+ }
+
+ // verify residuals as stopping criteria
+ // double residual_rms = sqrt( dx2_sum / dx2_count );
+ if (max_difference < convergence_accuracy)
+ {
+ // fprintf(stderr, "Iterations used: %u\n", opt_count);
+ return RigidBodyResult::success;
+ }
+ // previous_residual_rms = residual_rms;
+ }
+
+ return RigidBodyResult::did_not_converge;
+ }
+
+ const size_t RigidBodyVisibilityCanon::invalid_index = SIZE_MAX;
+
+ RigidBodyVisibilityCanon::RigidBodyVisibilityCanon()
+ {
+ }
+
+ UInt32 RigidBodyVisibilityCanon::ComputeConnectedVisibilityCanon(RigidBodyConnectedVisibilityCanon& connected, double distribution_tolerance) const
+ {
+ // init to empty
+ connected.shape.clear();
+
+ // num codes in canon
+ const size_t canon_size = shape.size();
+
+ // must have some codes
+ if (canon_size)
+ {
+ // initialise connectivity
+ std::vector< size_t > canon_sequence(canon_size, invalid_index);
+
+ // default start node is zero
+ UInt32 init_canon_index = 0;
+
+ // only the start node is on level 0
+ canon_sequence[init_canon_index] = 0;
+ connected.shape.push_back(shape[init_canon_index]);
+ bool foundnewconnections = true;
+
+ // find how many connect directly, how many connect 1-removed, etc
+ for (UInt32 ilevel = 1; foundnewconnections; ilevel++)
+ {
+ foundnewconnections = false;
+ for (UInt32 icode = 0; icode < canon_size; icode++)
+ {
+ if (canon_sequence[icode] == (ilevel-1))
+ {
+ for (UInt32 jcode = 0; jcode < canon_size; jcode++)
+ {
+ if (canon_sequence[jcode] == invalid_index)
+ {
+ // see if icode and jcode are connected
+ // - if so store the level they are on
+ // - and set foundnewconnections = true
+
+ // codes overlap - store level and set foundnewconnections
+ if (shape[icode].HasUniqueFitWith(shape[jcode], distribution_tolerance))
+ {
+ canon_sequence[jcode] = ilevel;
+ connected.shape.push_back(shape[jcode]);
+ foundnewconnections = true;
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ if (connected.shape.size() != shape.size())
+ return RigidBodyResult::timesequence_mismatch;
+
+ return RigidBodyResult::success;
+ }
+
+ RigidBodyConnectedVisibilityCanon::RigidBodyConnectedVisibilityCanon()
+ {
+ }
+
+ void RigidBodyConnectedVisibilityCanon::ComputeApproxMeanShape(RigidBodyShape& mean) const
+ {
+ if (shape.size())
+ {
+ // iterator at start of list
+ std::vector<RigidBodyShape>::const_iterator iter_shape( shape.begin() );
+
+ // initialise mean to first shape
+ mean = *iter_shape;
+
+ // add all others
+ while ((++iter_shape) != shape.end())
+ {
+ // fit this shape to mean
+ RigidTransform3 T;
+ UInt32 fit_result = iter_shape->ComputeFitTo(T, mean);
+
+ // this if statement is just defensive code
+ // - in fact the nature of the canon should guarantee sufficient points for a unique fit
+ if (fit_result == RigidBodyResult::success)
+ {
+ // loop over markers
+ for (size_t marker_index = 0; marker_index < mean.NumMarkers(); marker_index++)
+ {
+ const RigidBodyMarker& sample_marker = iter_shape->Marker(marker_index);
+ RigidBodyMarker& mean_marker = mean.Marker(marker_index);
+
+ if (!mean_marker.visible && sample_marker.visible)
+ {
+ // transform marker from this shape to mean
+ Vector3 Tx;
+ RigidTransform3::MulVec(Tx, T, sample_marker.position);
+
+ // fill in mean
+ mean_marker.position = Tx;
+ mean_marker.visible = true;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ UInt32 RigidBodyShapeCollection::MOSHFIT(std::vector<TimeSequence*>& output, double rateHz, double distribution_tolerance, double convergence_accuracy, const BinMemFactory& memfactory /*=BinMemFactoryDefault()*/) const
+ {
+ // compute mean shape
+ RigidBodyShape mean;
+ UInt32 status = ComputeMeanShape(mean, distribution_tolerance, convergence_accuracy);
+ if (status != RigidBodyResult::success)
+ return status;
+
+ // build output arrays and iterators
+ std::vector<TSOccVector3Iter> outputiter;
+ size_t num_shapes = NumShapes();
+ size_t num_markers = shape[0].NumMarkers();
+ TimeRange tr;
+ tr.Frames = num_shapes;
+ tr.Start = 0.0;
+ tr.Rate = rateHz;
+ size_t imarker;
+ for (imarker = 0; imarker < num_markers; imarker++)
+ {
+ TimeSequence* ts = TSFactoryOccValue(3).New(tr, memfactory);
+ output.push_back(ts);
+ outputiter.push_back( TSOccVector3Iter(*ts) );
+ }
+
+ // iterate over all shapes
+ for (std::vector<RigidBodyShape>::const_iterator ishape( shape.begin() ); ishape != shape.end(); ishape++)
+ {
+ // compute fit of mean to this shape
+ RigidTransform3 T;
+ mean.ComputeFitTo(T, *ishape);
+
+ // transform mean and use result
+ for (imarker = 0; imarker < num_markers; imarker++)
+ {
+ RigidTransform3::MulVec(outputiter[imarker].Value(), T, mean.Marker(imarker).position);
+ outputiter[imarker].Occluded() = 0;
+ outputiter[imarker].Next();
+ }
+ }
+
+ return RigidBodyResult::success;
+ }
+}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShapeCollection.h b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShapeCollection.h
new file mode 100644
index 00000000..a5561de6
--- /dev/null
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShapeCollection.h
@@ -0,0 +1,124 @@
+/*--
+ Open3DMotion
+ Copyright (c) 2004-2013.
+ All rights reserved.
+ See LICENSE.txt for more information.
+--*/
+
+#ifndef _OPEN3DMOTION_RIGID_BODY_SHAPE_COLLECTION_H_
+#define _OPEN3DMOTION_RIGID_BODY_SHAPE_COLLECTION_H_
+
+#include "Open3DMotion/OpenORM/Types.h"
+#include "Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactoryDefault.h"
+#include "Open3DMotion/Biomechanics/Algorithms/MOSHFIT/RigidBodyShape.h"
+#include <limits.h>
+
+namespace Open3DMotion
+{
+ // forward decl
+ class BinMemFactory;
+ class TimeSequence;
+ class RigidBodyVisibilityCanon;
+ class RigidBodyConnectedVisibilityCanon;
+
+ /** Collection of shapes of 3D points with visiblity information. */
+ class RigidBodyShapeCollection
+ {
+ public:
+
+ /** Construct empty collection. */
+ RigidBodyShapeCollection();
+
+ /** Use multiple time sequences of point data and add one shape for every frame.
+
+ @return RigidBodyResult::success if successful,
+ RigidBodyResult::timesequence_mismatch if sequences contain
+ different numbers of frames or are not point data.
+ */
+ UInt32 CopyFromTimeSequences(const std::vector<const TimeSequence*>& input);
+
+ /** @return Number of shapes */
+ size_t NumShapes() const
+ { return shape.size(); }
+
+ /** Retrieve a shape
+ @param index zero-based index of shape.
+ @return The shape at the given index.
+ */
+ const RigidBodyShape& Shape(size_t index) const
+ { return shape[index]; }
+
+ /** Determine a collection of shapes which have canonical codes as defined by the MOSHFIT algorithm.
+ @param canon To be filled with the resulting visibility codes.
+ */
+ void ComputeVisiblityCanon(RigidBodyVisibilityCanon& canon) const;
+
+ /** Apply the portion of the MOSHFIT algorithm which computes mean shape.
+ @param distribution_tolerance Required tolerance on accuracy of input data.
+ @param convergence_accuracy Numerical precision to which conversion is required.
+ @return RigidBodyResult::success if successful, error code otherwise.
+ */
+ UInt32 ComputeMeanShape(RigidBodyShape& mean, double distribution_tolerance, double convergence_accuracy) const;
+
+ /** Apply the MOSHFIT algorithm to compute mean shape and fit it to each shape in the collection.
+ @param output Collection of time seequences for reconstructed outputs.
+ @param rateHz The sample rate to specify in output time sequences.
+ @param distribution_tolerance Required tolerance on accuracy of input data.
+ @param convergence_accuracy Numerical precision to which conversion is required.
+ @param memfactory Optional selection of alternative memory allocation factory for output.
+ @return RigidBodyResult::success if successful, error code otherwise.
+ */
+ UInt32 MOSHFIT(std::vector<TimeSequence*>& output, double rateHz, double distribution_tolerance, double convergence_accuracy, const BinMemFactory& memfactory = BinMemFactoryDefault()) const;
+
+ /** Utility method to increase duration of occluded regions
+ @param dilation The number of frames to expand occluded region. */
+ void DilateVisiblity(UInt32 dilation);
+
+ private:
+ RigidBodyShapeCollection(const RigidBodyShapeCollection& src);
+ const RigidBodyShapeCollection& operator=(const RigidBodyShapeCollection& src);
+
+ protected:
+ std::vector<RigidBodyShape> shape;
+ };
+
+ /** Collection of 3D shapes corresponding to canonical visiblity codes. */
+ class RigidBodyVisibilityCanon : public RigidBodyShapeCollection
+ {
+ public:
+ /** Construct empty. Use RigidBodyShapeCollection::ComputeVisiblityCanon to construct non-empty version. */
+ RigidBodyVisibilityCanon();
+
+ /** Compute the set of codes which are shape-connected and order them according to MOSHFIT.
+ @param connected Filled with the resulting set of codes.
+ @param distribution_tolerance Required tolerance on accuracy of input data.
+ */
+ UInt32 ComputeConnectedVisibilityCanon(RigidBodyConnectedVisibilityCanon& connected, double distribution_tolerance) const;
+
+ private:
+ RigidBodyVisibilityCanon(const RigidBodyVisibilityCanon& src);
+ const RigidBodyVisibilityCanon& operator=(const RigidBodyVisibilityCanon& src);
+
+ private:
+ static const size_t invalid_index /*=SIZE_MAX*/;
+ };
+
+ /** Ordered collection of shape-connected 3D shapes as required by the MOSHFIT algorithm. */
+ class RigidBodyConnectedVisibilityCanon : public RigidBodyVisibilityCanon
+ {
+ public:
+ /** Construct empty. Use RigidBodyVisibilityCanon::ComputeConnectedVisibilityCanon to construct non-empty version. */
+ RigidBodyConnectedVisibilityCanon();
+
+ /** Use adapted generalised procrustes to compute unique mean shape.
+ @param mean Filled with resulting shape.
+ */
+ void ComputeApproxMeanShape(RigidBodyShape& mean) const;
+
+ private:
+ RigidBodyConnectedVisibilityCanon(const RigidBodyConnectedVisibilityCanon& src);
+ const RigidBodyConnectedVisibilityCanon& operator=(const RigidBodyConnectedVisibilityCanon& src);
+ };
+}
+
+#endif
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/EventGroup.cpp b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/EventGroup.cpp
index 2d355887..40f49687 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/EventGroup.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/EventGroup.cpp
@@ -27,7 +27,7 @@ namespace Open3DMotion
Register(EventMapName, &EventMap);
}
- void EventGroup::SetEvents(const EventArray& events, BinMemFactory& memfactory)
+ void EventGroup::SetEvents(const EventArray& events, const BinMemFactory& memfactory)
{
// put all names in list
// size_t num_names = events.NameMap().size();
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/EventGroup.h b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/EventGroup.h
index f447c13f..ba82eaef 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/EventGroup.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/EventGroup.h
@@ -23,7 +23,7 @@ namespace Open3DMotion
public:
- void SetEvents(const EventArray& events, BinMemFactory& memfactory);
+ void SetEvents(const EventArray& events, const BinMemFactory& memfactory);
void GetEvents(EventArray& events) const;
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TSFactory.cpp b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TSFactory.cpp
index 9770dfce..17c22eee 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TSFactory.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TSFactory.cpp
@@ -14,7 +14,7 @@ namespace Open3DMotion
const char TSFactoryValue::fieldname_value[] = "value";
const char TSFactoryOccValue::fieldname_occluded[] = "occluded";
- TimeSequence* TSFactory::New(const TimeRange& tr, BinMemFactory& memfactory) const
+ TimeSequence* TSFactory::New(const TimeRange& tr, const BinMemFactory& memfactory) const
{
TimeSequence* ts = new TimeSequence;
ts->Allocate(layout, tr, memfactory);
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TSFactory.h b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TSFactory.h
index d0555642..c2e69cca 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TSFactory.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TSFactory.h
@@ -21,7 +21,7 @@ namespace Open3DMotion
}
public:
- TimeSequence* New(const TimeRange& tr, BinMemFactory& memfactory) const;
+ TimeSequence* New(const TimeRange& tr, const BinMemFactory& memfactory) const;
protected:
void AddField(const BinaryFieldSpec& field);
@@ -158,6 +158,37 @@ namespace Open3DMotion
{ return *ValuePtr0(); }
};
+ class TSOccMatrix3x3ConstIter : public Open3DMotion::BinConstIter2<double, Open3DMotion::UInt8>
+ {
+ public:
+ TSOccMatrix3x3ConstIter(const Open3DMotion::TimeSequence& ts) throw(Open3DMotion::NoSuchFieldException) :
+ BinConstIter2<double, Open3DMotion::UInt8>(ts, Open3DMotion::TSFactoryValue::fieldname_value, 9, Open3DMotion::TSFactoryOccValue::fieldname_occluded, 1)
+ {
+ }
+
+ public:
+ const double* Value() const
+ { return ValuePtr0(); }
+
+ const Open3DMotion::UInt8& Occluded() const
+ { return *ValuePtr1(); }
+ };
+
+ class TSOccMatrix3x3Iter : public Open3DMotion::BinIter2<double, Open3DMotion::UInt8>
+ {
+ public:
+ TSOccMatrix3x3Iter(Open3DMotion::TimeSequence& ts) throw(Open3DMotion::NoSuchFieldException) :
+ BinIter2<double, Open3DMotion::UInt8>(ts, Open3DMotion::TSFactoryValue::fieldname_value, 9, Open3DMotion::TSFactoryOccValue::fieldname_occluded, 1)
+ {
+ }
+
+ public:
+ double* Value() const
+ { return ValuePtr0(); }
+
+ Open3DMotion::UInt8& Occluded() const
+ { return *ValuePtr1(); }
+ };
};
#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TimeSequence.cpp b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TimeSequence.cpp
index bd589826..4468e1a4 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TimeSequence.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TimeSequence.cpp
@@ -36,7 +36,7 @@ namespace Open3DMotion
// base class will register data members
}
- void TimeSequence::Allocate(const std::vector<BinaryFieldSpec>& layout, const TimeRange& t, BinMemFactory& memfactory)
+ void TimeSequence::Allocate(const std::vector<BinaryFieldSpec>& layout, const TimeRange& t, const BinMemFactory& memfactory)
{
// copy descriptor info
Frames = t.Frames;
@@ -47,4 +47,11 @@ namespace Open3DMotion
RichBinary::Allocate(layout, Frames.Value(), memfactory);
}
+
+ void TimeSequence::GetTimeRange(TimeRange& t) const
+ {
+ t.Start = Start;
+ t.Rate = Rate;
+ t.Frames = Frames;
+ }
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TimeSequence.h b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TimeSequence.h
index 50280ca6..00b83192 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TimeSequence.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Biomechanics/Trial/TimeSequence.h
@@ -21,7 +21,9 @@ namespace Open3DMotion
public:
- void Allocate(const std::vector<BinaryFieldSpec>& layout, const TimeRange& t, BinMemFactory& memfactory);
+ void Allocate(const std::vector<BinaryFieldSpec>& layout, const TimeRange& t, const BinMemFactory& memfactory);
+
+ void GetTimeRange(TimeRange& t) const;
public:
@@ -47,8 +49,8 @@ namespace Open3DMotion
public:
/** Immutable access to frames count */
- Int32 NumFrames() const
- { return Frames; }
+ size_t NumFrames() const
+ { return (size_t) Frames.Value(); }
private:
MapInt32 Frames;
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Maths/LinearSolve3.cpp b/Utilities/Open3DMotion/src/Open3DMotion/Maths/LinearSolve3.cpp
index 78e7d93b..52b1755f 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/Maths/LinearSolve3.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Maths/LinearSolve3.cpp
@@ -116,11 +116,7 @@ namespace Open3DMotion
Eigen::Vector3f CTd = CT * d;
// solve
-#if EIGEN_VERSION_AT_LEAST(3,0,0)
y = CTC.ldlt().solve(CTd);
-#else
- CTC.ldlt().solve(CTd, &y);
-#endif
// compute rms error if requested
if (rms)
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/Maths/Matrix3x3.cpp b/Utilities/Open3DMotion/src/Open3DMotion/Maths/Matrix3x3.cpp
index 823238b9..c665d355 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/Maths/Matrix3x3.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/Maths/Matrix3x3.cpp
@@ -13,13 +13,16 @@ extern "C"
#include <f2clibs/f2c.h>
#include <clapack.h>
}
+#else
+#include <Eigen/Dense>
+#include <Eigen/SVD>
#endif
namespace Open3DMotion
{
-#ifndef OPEN3DMOTION_LINEAR_ALGEBRA_EIGEN
void Matrix3x3::SVD(double* U, double* s, double* VT, const double* A)
{
+#ifndef OPEN3DMOTION_LINEAR_ALGEBRA_EIGEN
long three(3);
Matrix3x3 Acpy(A);
long lwork(256);
@@ -47,7 +50,18 @@ namespace Open3DMotion
work, // workspace
&lwork, // size of workspace
&info); // returned error codes
- }
+
+#else
+ Eigen::Map< const Eigen::Matrix<double, 3, 3, Eigen::RowMajor> > _A(A, 3, 3);
+ Eigen::Map< Eigen::Matrix<double, 3, 3, Eigen::RowMajor> > _U(U, 3, 3);
+ Eigen::Map< Eigen::Matrix<double, 3, 3, Eigen::RowMajor> > _VT(VT, 3, 3);
+ Eigen::Map< Eigen::Matrix<double, 3, 1> > _s(s, 3, 1);
+ Eigen::JacobiSVD< Eigen::Matrix<double, 3, 3, Eigen::RowMajor> > svd(_A, Eigen::ComputeFullU | Eigen::ComputeFullV);
+ _U = svd.matrixU();
+ _VT = svd.matrixV().transpose();
+ _s = svd.singularValues();
#endif
+
+ }
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionBundle/MOBL.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionBundle/MOBL.cpp
index 8c6e4dfb..5ff6163a 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionBundle/MOBL.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionBundle/MOBL.cpp
@@ -156,7 +156,7 @@ namespace Open3DMotion
return count;
}
- TreeValue* MOBLFormatReader::ReadTrial(UInt32 index) throw(MotionFileException)
+ TreeValue* MOBLFormatReader::ReadTrial(UInt32 index, const BinMemFactory& memfactory /*=BinMemFactoryDefault()*/) throw(MotionFileException)
{
// move to required trial
UInt32 doc_index_needed = index + 1;
@@ -169,7 +169,7 @@ namespace Open3DMotion
// read
try
{
- BSONReaderMOBL reader(*stream);
+ BSONReaderMOBL reader(*stream, memfactory);
reader.ReadDocument(*MOBLresult);
}
catch (const BSONReadException& e)
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionBundle/MOBL.h b/Utilities/Open3DMotion/src/Open3DMotion/MotionBundle/MOBL.h
index 01b4340a..8fd576a6 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionBundle/MOBL.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionBundle/MOBL.h
@@ -12,6 +12,9 @@
#include "Open3DMotion/OpenORM/Mappings/MapBool.h"
#include "Open3DMotion/OpenORM/Mappings/MapInt32.h"
#include "Open3DMotion/MotionFile/MotionFileException.h"
+#include "Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactoryDefault.h"
+
+#include <memory>
namespace Open3DMotion
{
@@ -43,7 +46,7 @@ namespace Open3DMotion
/** Read the specified trial.
@param index Zero-based index of trial to read
*/
- TreeValue* ReadTrial(UInt32 index) throw(MotionFileException);
+ TreeValue* ReadTrial(UInt32 index, const BinMemFactory& memfactory = BinMemFactoryDefault()) throw(MotionFileException);
/** Find total trials in the bundle.
@return The number of trials
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/C3DMachine.h b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/C3DMachine.h
index 28fbe0e3..14d0175e 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/C3DMachine.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/C3DMachine.h
@@ -89,4 +89,4 @@ namespace Open3DMotion
}
-#endif
+#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/C3DRecord.h b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/C3DRecord.h
index e8274e7f..b0f2edf9 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/C3DRecord.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/C3DRecord.h
@@ -510,4 +510,4 @@ namespace Open3DMotion
}
-#endif
+#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/FileFormatC3D.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/FileFormatC3D.cpp
index 9a4eb6f3..f7fa0cb4 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/FileFormatC3D.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/FileFormatC3D.cpp
@@ -14,6 +14,7 @@
#include <map>
#include <limits>
#include <sstream>
+#include <memory>
#include <stdio.h>
#include <math.h>
@@ -111,7 +112,7 @@ namespace Open3DMotion
//----------------------------------------------------------
// Read C3D
- TreeValue* FileFormatC3D::Read(const MotionFileHandler& context, istream& is, BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException)
+ TreeValue* FileFormatC3D::Read(const MotionFileHandler& context, istream& is, const BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException)
{
// parse options
FileFormatOptionsC3D c3doptions;
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/FileFormatC3D.h b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/FileFormatC3D.h
index 42081287..4c7b1c53 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/FileFormatC3D.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/C3D/FileFormatC3D.h
@@ -30,7 +30,7 @@ namespace Open3DMotion
virtual bool Probe(const MotionFileHandler& context, TreeValue*& readoptions, std::istream& is) const throw(MotionFileException);
// Read C3D
- virtual TreeValue* Read(const MotionFileHandler& context, std::istream& is, BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException) ;
+ virtual TreeValue* Read(const MotionFileHandler& context, std::istream& is, const BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException) ;
// Write C3D
virtual void Write(const MotionFileHandler& context, const TreeValue* contents, std::ostream& os, const TreeValue* writeoptions) const throw(MotionFileException);
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/FileFormatCODAText.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/FileFormatCODAText.cpp
index bcc0aa62..93afd5cf 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/FileFormatCODAText.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/FileFormatCODAText.cpp
@@ -34,7 +34,7 @@ bool FileFormatCODAText::Probe(const MotionFileHandler& /*context*/, TreeValue*&
return (strncmp(buffID, str_id, 26) == 0);
}
-TreeValue* FileFormatCODAText::Read(const MotionFileHandler& /*context*/, std::istream& is, BinMemFactory& memfactory, const TreeValue* /*readoptions*/) const throw(MotionFileException)
+TreeValue* FileFormatCODAText::Read(const MotionFileHandler& /*context*/, std::istream& is, const BinMemFactory& memfactory, const TreeValue* /*readoptions*/) const throw(MotionFileException)
{
// read it in
MATextReader reader;
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/FileFormatCODAText.h b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/FileFormatCODAText.h
index 17c062dc..a218dea0 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/FileFormatCODAText.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/FileFormatCODAText.h
@@ -28,7 +28,7 @@ namespace Open3DMotion
virtual bool Probe(const MotionFileHandler& context, TreeValue*& readoptions, std::istream& is) const throw(MotionFileException);
// Read Text
- virtual TreeValue* Read(const MotionFileHandler& context, std::istream& is, BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException) ;
+ virtual TreeValue* Read(const MotionFileHandler& context, std::istream& is, const BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException) ;
// Write Text
virtual void Write(const MotionFileHandler& context, const TreeValue* contents, std::ostream& os, const TreeValue* writeoptions) const throw(MotionFileException);
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/MATextInputStream.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/MATextInputStream.cpp
index dadfb665..3ecb3697 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/MATextInputStream.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/MATextInputStream.cpp
@@ -6,6 +6,7 @@
--*/
#include "Open3DMotion/MotionFile/Formats/CODAText/MATextInputStream.h"
+#include <stdio.h>
namespace Open3DMotion
{
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/MATextReader.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/MATextReader.cpp
index 6002ff17..183053d6 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/MATextReader.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/MATextReader.cpp
@@ -8,6 +8,8 @@
#include "Open3DMotion/MotionFile/Formats/CODAText/MATextReader.h"
#include "Open3DMotion/MotionFile/Formats/CODAText/MATextInputStream.h"
+#include <stdio.h>
+
namespace Open3DMotion
{
MATextReader::MATextReader()
@@ -120,7 +122,7 @@ namespace Open3DMotion
}
}
- TimeSequence* MATextReader::GetTSScalar(const char* groupname, const char* channelname, BinMemFactory& memfactory) const
+ TimeSequence* MATextReader::GetTSScalar(const char* groupname, const char* channelname, const BinMemFactory& memfactory) const
{
size_t index = ColumnIndex(groupname, channelname);
if (index == invalid_index)
@@ -156,7 +158,7 @@ namespace Open3DMotion
}
- TimeSequence* MATextReader::GetTSOccVector3(const char* groupname, const char* channelname, BinMemFactory& memfactory) const
+ TimeSequence* MATextReader::GetTSOccVector3(const char* groupname, const char* channelname, const BinMemFactory& memfactory) const
{
// expected channel col names
std::string channel_x = std::string(channelname) + ".X";
@@ -266,4 +268,4 @@ namespace Open3DMotion
return data[0];
}
-}
\ No newline at end of file
+}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/MATextReader.h b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/MATextReader.h
index 9696dce8..292257e0 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/MATextReader.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/CODAText/MATextReader.h
@@ -25,9 +25,9 @@ namespace Open3DMotion
bool Read(std::istream& is);
- TimeSequence* GetTSScalar(const char* groupname, const char* channelname, BinMemFactory& memfactory) const;
+ TimeSequence* GetTSScalar(const char* groupname, const char* channelname, const BinMemFactory& memfactory) const;
- TimeSequence* GetTSOccVector3(const char* groupname, const char* channelname, BinMemFactory& memfactory) const;
+ TimeSequence* GetTSOccVector3(const char* groupname, const char* channelname, const BinMemFactory& memfactory) const;
void GetChannelList3(std::vector<std::string>& channels, const char* groupname) const;
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/FileFormatMDF.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/FileFormatMDF.cpp
index b5af7cc3..58f90098 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/FileFormatMDF.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/FileFormatMDF.cpp
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -15,7 +15,7 @@
#include <sstream>
#include <memory>
-#include <cstring>
+#include <string.h>
namespace Open3DMotion
{
@@ -244,7 +244,7 @@ namespace Open3DMotion
is.read((char*)&version,2);
// store it
- mdf_options.FormatVersion = version;
+ mdf_options.FormatVersion = (version & 0x00FFUL);
// convert to tree object
readoptions = mdf_options.ToTree();
@@ -254,7 +254,7 @@ namespace Open3DMotion
}
// Read MDF
- TreeValue* FileFormatMDF::Read(const MotionFileHandler& /*context*/, std::istream& is, BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException)
+ TreeValue* FileFormatMDF::Read(const MotionFileHandler& /*context*/, std::istream& is, const BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException)
{
// get options
FileFormatOptionsMDF mdf_options;
@@ -387,12 +387,12 @@ namespace Open3DMotion
throw(MotionFileException(MotionFileException::formaterror, "Unknown frame rate for marker"));
// time resolution
- UInt16 timeres = *(UInt16*)(&data[VAR_TIME_RESOLUTION_MARKER][i][0]);
+ UInt16 timeres = *reinterpret_cast<UInt16*>(&data[VAR_TIME_RESOLUTION_MARKER][i][0]);
// scale factor
float scale(1.0);
if (i < data[VAR_POSITION_RESOLUTION_MARKER].size())
- scale = (float)1E-3 * *(Int16*)(&data[VAR_POSITION_RESOLUTION_MARKER][i][0]);
+ scale = (float)1E-3 * *reinterpret_cast<Int16*>(&data[VAR_POSITION_RESOLUTION_MARKER][i][0]);
// find name
std::string name;
@@ -418,7 +418,7 @@ namespace Open3DMotion
// find hardware number (note it is zero-based in MDF files)
Int32 hardware(i);
if (i < data[VAR_MARKER_NUMBER_HARDWARE].size())
- hardware = *(UInt16*)&(data[VAR_MARKER_NUMBER_HARDWARE][i][0]);
+ hardware = *reinterpret_cast<UInt16*>(&data[VAR_MARKER_NUMBER_HARDWARE][i][0]);
// HACK: only support 99 unique marker ID's - after that assume multi-coda mode
hardware = hardware % 100;
@@ -463,16 +463,16 @@ namespace Open3DMotion
// time resolution
UInt16 timeres(0);
if (i < data[VAR_TIME_RESOLUTION_EMG].size())
- timeres= *(UInt16*)(&data[VAR_TIME_RESOLUTION_EMG][i][0]);
+ timeres= *reinterpret_cast<UInt16*>(&data[VAR_TIME_RESOLUTION_EMG][i][0]);
else if (data[VAR_TIME_RESOLUTION_MARKER].size())
- timeres = *(UInt16*)(&data[VAR_TIME_RESOLUTION_MARKER][0][0]);
+ timeres = *reinterpret_cast<UInt16*>(&data[VAR_TIME_RESOLUTION_MARKER][0][0]);
else
throw(MotionFileException(MotionFileException::formaterror, "Unknown frame rate for force"));
// position resolution
double scale(0.0);
if (i < data[VAR_EMG_RESOLUTION].size())
- scale = *(float*)(&data[VAR_EMG_RESOLUTION][i][0]);
+ scale = *reinterpret_cast<float*>(&data[VAR_EMG_RESOLUTION][i][0]);
else
scale = MDF_OldEMGScalingConst;
@@ -509,7 +509,7 @@ namespace Open3DMotion
ts->HardwareID = hardwareID;
// copy data (unscaled)
- Int16* a = (Int16*)&(data[VAR_ANALOGUE_EMG][i][0]);
+ Int16* a = reinterpret_cast<Int16*>(&data[VAR_ANALOGUE_EMG][i][0]);
for (TSScalarIter iter_ts(*ts); iter_ts.HasFrame(); iter_ts.Next(), a++)
{
iter_ts.Value() = *a;
@@ -550,16 +550,16 @@ namespace Open3DMotion
// channel time resolution
UInt16 timeres(0);
if (data[VAR_TIME_RESOLUTION_FORCE].size())
- timeres= *(UInt16*)(&data[VAR_TIME_RESOLUTION_FORCE][0][0]);
+ timeres= *reinterpret_cast<UInt16*>(&data[VAR_TIME_RESOLUTION_FORCE][0][0]);
else if (data[VAR_TIME_RESOLUTION_MARKER].size())
- timeres = *(UInt16*)(&data[VAR_TIME_RESOLUTION_MARKER][0][0]);
+ timeres = *reinterpret_cast<UInt16*>(&data[VAR_TIME_RESOLUTION_MARKER][0][0]);
else
throw(MotionFileException(MotionFileException::formaterror, "Unknown frame rate for force"));
// channel position resolution
double scale(0.0);
if (index_file_force < data[VAR_FORCE_RESOLUTION].size())
- scale = *(float*)(&data[VAR_FORCE_RESOLUTION][index_file_force][0]);
+ scale = *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][index_file_force][0]);
else
scale = MDF_OldForceScalingConst;
@@ -604,7 +604,7 @@ namespace Open3DMotion
ts->ScaleUnits = fp_mdf.MDFChannelUnits(mdf_plate_channel);
// copy data
- Int16* a = (Int16*)&(data[VAR_ANALOGUE_FORCE][index_file_force][0]);
+ Int16* a = reinterpret_cast<Int16*>(&data[VAR_ANALOGUE_FORCE][index_file_force][0]);
for (TSScalarIter iter_ts(*ts); iter_ts.HasFrame(); iter_ts.Next(), a++)
{
iter_ts.Value() = *a;
@@ -636,7 +636,7 @@ namespace Open3DMotion
{
if (data[VAR_DATE_CREATE][0].size() == 6)
{
- const Int16* date = (Int16*)&data[VAR_DATE_CREATE][0][0];
+ const Int16* date = reinterpret_cast<Int16*>(&data[VAR_DATE_CREATE][0][0]);
trial->Acq.Date.Day = (Int32)date[0];
trial->Acq.Date.Month = (Int32)date[1];
trial->Acq.Date.Year = (Int32)date[2];
@@ -667,46 +667,46 @@ namespace Open3DMotion
if (num_subject_data >= 5)
{
// decode gender
- trial->UserInput.Subject.Gender = *(Int16*)&data[VAR_PATIENT_DATA][0][0] ? "male" : "female";
+ trial->UserInput.Subject.Gender = *reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][0][0]) ? "male" : "female";
// decode date
// TODO: compute full year from age and acquisition date
- Int32 dob = *(Int16*)&data[VAR_PATIENT_DATA][1][0];
+ Int32 dob = *reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][1][0]);
Int32 dob_month = dob / 100;
Int32 dob_year = 1900 + dob - (100*dob_month);
trial->UserInput.Subject.DateOfBirth.Month = dob_month;
trial->UserInput.Subject.DateOfBirth.Year = dob_year;
// other params
- trial->UserInput.Subject.Age = (Int32)*(Int16*)&data[VAR_PATIENT_DATA][2][0];
- trial->UserInput.Subject.Weight = (double)*(Int16*)&data[VAR_PATIENT_DATA][3][0];
- trial->UserInput.Subject.Height = (double)*(Int16*)&data[VAR_PATIENT_DATA][4][0];
+ trial->UserInput.Subject.Age = (Int32)*reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][2][0]);
+ trial->UserInput.Subject.Weight = (double)*reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][3][0]);
+ trial->UserInput.Subject.Height = (double)*reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][4][0]);
}
// segment parameters
if(num_subject_data >= 11 )
{
- trial->UserInput.Subject.PelvicWidth = (double)*(Int16*)&data[VAR_PATIENT_DATA][5][0];
- trial->UserInput.Subject.PelvicDepth = (double)*(Int16*)&data[VAR_PATIENT_DATA][6][0];
- trial->UserInput.Subject.LKneeWidth = (double)*(Int16*)&data[VAR_PATIENT_DATA][7][0];
- trial->UserInput.Subject.RKneeWidth = (double)*(Int16*)&data[VAR_PATIENT_DATA][8][0];
- trial->UserInput.Subject.LAnkleWidth = (double)*(Int16*)&data[VAR_PATIENT_DATA][9][0];
- trial->UserInput.Subject.RAnkleWidth = (double)*(Int16*)&data[VAR_PATIENT_DATA][10][0];
+ trial->UserInput.Subject.PelvicWidth = (double)*reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][5][0]);
+ trial->UserInput.Subject.PelvicDepth = (double)*reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][6][0]);
+ trial->UserInput.Subject.LKneeWidth = (double)*reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][7][0]);
+ trial->UserInput.Subject.RKneeWidth = (double)*reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][8][0]);
+ trial->UserInput.Subject.LAnkleWidth = (double)*reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][9][0]);
+ trial->UserInput.Subject.RAnkleWidth = (double)*reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][10][0]);
}
// Hip model - here for historical purposes -
// should not be used for calculation
if (num_subject_data >= 14)
{
- trial->MDF.HipOffsetRatioX = (double)*(Int16*)&data[VAR_PATIENT_DATA][11][0];
- trial->MDF.HipOffsetRatioY = (double)*(Int16*)&data[VAR_PATIENT_DATA][12][0];
- trial->MDF.HipOffsetRatioZ = (double)*(Int16*)&data[VAR_PATIENT_DATA][13][0];
+ trial->MDF.HipOffsetRatioX = (double)*reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][11][0]);
+ trial->MDF.HipOffsetRatioY = (double)*reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][12][0]);
+ trial->MDF.HipOffsetRatioZ = (double)*reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][13][0]);
}
// Sacral offset
if(num_subject_data >= 17)
{
- trial->UserInput.Subject.SacralOffset = (double)*(Int16*)&data[VAR_PATIENT_DATA][14][0];
+ trial->UserInput.Subject.SacralOffset = (double)*reinterpret_cast<Int16*>(&data[VAR_PATIENT_DATA][14][0]);
}
// Segment data
@@ -714,9 +714,9 @@ namespace Open3DMotion
if (num_segment_data >= 15)
{
// segment lengths: for some reason these are in m not mm
- const float* thighLength = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][0][0];
- const float* shankLength = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][1][0];
- const float* footLength = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][2][0];
+ const float* thighLength = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][0][0]);
+ const float* shankLength = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][1][0]);
+ const float* footLength = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][2][0]);
trial->UserInput.Subject.LThighLength = 1000.0 * (double)thighLength[0];
trial->UserInput.Subject.LShankLength = 1000.0 * (double)shankLength[0];
trial->UserInput.Subject.LFootLength = 1000.0 * (double)footLength[0];
@@ -728,9 +728,9 @@ namespace Open3DMotion
if (subjectWeight > 0.0)
{
// segment mass ratios (multiple of body mass)
- const float* thighMassRatio = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][3][0];
- const float* shankMassRatio = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][4][0];
- const float* footMassRatio = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][5][0];
+ const float* thighMassRatio = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][3][0]);
+ const float* shankMassRatio = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][4][0]);
+ const float* footMassRatio = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][5][0]);
trial->UserInput.Subject.LThighMass = thighMassRatio[0] * subjectWeight;
trial->UserInput.Subject.LShankMass = shankMassRatio[0] * subjectWeight;
trial->UserInput.Subject.LFootMass = footMassRatio[0] * subjectWeight;
@@ -741,9 +741,9 @@ namespace Open3DMotion
// 6, 7, and 8 are offset to centre of mass
// TODO: check this is not actually needed for inertial calcs
// i.e. that it cancels out
- const float* thighCR = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][6][0];
- const float* shankCR = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][7][0];
- const float* footCR = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][8][0];
+ const float* thighCR = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][6][0]);
+ const float* shankCR = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][7][0]);
+ const float* footCR = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][8][0]);
trial->MDF.COM_LThigh = (double)thighCR[0];
trial->MDF.COM_LShank = (double)shankCR[0];
trial->MDF.COM_LFoot = (double)footCR[0];
@@ -752,9 +752,9 @@ namespace Open3DMotion
trial->MDF.COM_RFoot = (double)footCR[1];
// segment radii of gyration (X = Y), loaded in metres not mm
- const float* thighRGXY = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][9][0];
- const float* shankRGXY = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][10][0];
- const float* footRGXY = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][11][0];
+ const float* thighRGXY = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][9][0]);
+ const float* shankRGXY = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][10][0]);
+ const float* footRGXY = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][11][0]);
trial->UserInput.Subject.RadGyr_LThigh_X = 1000.0 * (double)(thighRGXY[0] * thighLength[0]);
trial->UserInput.Subject.RadGyr_LThigh_Y = 1000.0 * (double)(thighRGXY[0] * thighLength[0]);
trial->UserInput.Subject.RadGyr_LShank_X = 1000.0 * (double)(shankRGXY[0] * shankLength[0]);
@@ -769,9 +769,9 @@ namespace Open3DMotion
trial->UserInput.Subject.RadGyr_RFoot_Y = 1000.0 * (double)(footRGXY[1] * footLength[1]);
// segment radii of gyration (Z), loaded in metres not mm
- const float* thighRGZ = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][12][0];
- const float* shankRGZ = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][13][0];
- const float* footRGZ = (const float*)&data[VAR_PATIENT_SEGMENT_DATA][14][0];
+ const float* thighRGZ = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][12][0]);
+ const float* shankRGZ = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][13][0]);
+ const float* footRGZ = reinterpret_cast<const float*>(&data[VAR_PATIENT_SEGMENT_DATA][14][0]);
trial->UserInput.Subject.RadGyr_LThigh_Z = 1000.0 * (double)(thighRGZ[0] * thighRGXY[0] * thighLength[0]);
trial->UserInput.Subject.RadGyr_LShank_Z = 1000.0 * (double)(shankRGZ[0] * shankRGXY[0] * shankLength[0]);
trial->UserInput.Subject.RadGyr_LFoot_Z = 1000.0 * (double)(footRGZ[0] * footRGXY[0] * footLength[0]);
@@ -790,8 +790,8 @@ namespace Open3DMotion
data[VAR_TIME_CURSOR][0].size() == 4)
{
// curors - get values
- UInt16 timeres = *(UInt16*)(&data[VAR_TIME_RESOLUTION_CURSOR][0][0]);
- Int16* ptr_time = (Int16*)&data[VAR_TIME_CURSOR][0][0];
+ UInt16 timeres = *reinterpret_cast<UInt16*>(&data[VAR_TIME_RESOLUTION_CURSOR][0][0]);
+ Int16* ptr_time = reinterpret_cast<Int16*>(&data[VAR_TIME_CURSOR][0][0]);
double t0 = (double)ptr_time[0] / (double)timeres;
double t1 = (double)ptr_time[1] / (double)timeres;
@@ -822,8 +822,8 @@ namespace Open3DMotion
continue;
// get values
- UInt16 timeres = *(UInt16*)(&data[VAR_TIME_RESOLUTION_CURSOR][ibar][0]);
- Int16* ptr_time = (Int16*)&data[VAR_TIME_CURSOR][ibar][0];
+ UInt16 timeres = *reinterpret_cast<UInt16*>(&data[VAR_TIME_RESOLUTION_CURSOR][ibar][0]);
+ Int16* ptr_time = reinterpret_cast<Int16*>(&data[VAR_TIME_CURSOR][ibar][0]);
double t0 = (double)ptr_time[0] / (double)timeres;
double t1 = (double)ptr_time[1] / (double)timeres;
@@ -849,7 +849,7 @@ namespace Open3DMotion
EventArray representative_events;
// time scale factor
- double tscale = (double)*(UInt16*)&data[VAR_TIME_RESOLUTION_CURSOR][0][0];
+ double tscale = (double)*reinterpret_cast<UInt16*>(&data[VAR_TIME_RESOLUTION_CURSOR][0][0]);
for (i = 0; i < num_gait_cycles; i++)
{
@@ -857,9 +857,9 @@ namespace Open3DMotion
continue;
// time-order the cycle events
- double hd0 = *(Int16*)&data[VAR_GAIT_CYCLES][i][0] / tscale;
- double to = *(Int16*)&data[VAR_GAIT_CYCLES][i][2] / tscale;
- double hd1 = *(Int16*)&data[VAR_GAIT_CYCLES][i][4] / tscale;
+ double hd0 = *reinterpret_cast<Int16*>(&data[VAR_GAIT_CYCLES][i][0]) / tscale;
+ double to = *reinterpret_cast<Int16*>(&data[VAR_GAIT_CYCLES][i][2]) / tscale;
+ double hd1 = *reinterpret_cast<Int16*>(&data[VAR_GAIT_CYCLES][i][4]) / tscale;
if (to >= 0.0 && hd0 > to)
std::swap(hd0,to);
if (hd1 >= 0.0 && to > hd1)
@@ -948,7 +948,7 @@ namespace Open3DMotion
const std::vector<UInt8>& channelnames = data[DataChannelNames][iCalcDataGroup];
// get scaling
- float scaling = *(float*)&(data[DataScaling][iCalcDataGroup][0]);
+ float scaling = *reinterpret_cast<float*>(&data[DataScaling][iCalcDataGroup][0]);
// retrieve each channel
std::string str_group = std::string("Calculated ") + mdf_group_name;
@@ -1003,7 +1003,7 @@ namespace Open3DMotion
ts->HardwareID = j + 1;
ts->Units = str_units;
- const Int16* value = (const Int16*)(&data[i][j][0]);
+ const Int16* value = reinterpret_cast<const Int16*>(&data[i][j][0]);
if (valuedim == 1)
{
// scalar data
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/FileFormatMDF.h b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/FileFormatMDF.h
index 03ee7338..1f75aa1d 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/FileFormatMDF.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/FileFormatMDF.h
@@ -70,7 +70,7 @@ namespace Open3DMotion
virtual bool Probe(const MotionFileHandler& context, TreeValue*& readoptions, std::istream& is) const throw(MotionFileException);
// Read MDF
- virtual TreeValue* Read(const MotionFileHandler& context, std::istream& is, BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException) ;
+ virtual TreeValue* Read(const MotionFileHandler& context, std::istream& is, const BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException) ;
// Write MDF
virtual void Write(const MotionFileHandler& context, const TreeValue* contents, std::ostream& os, const TreeValue* writeoptions) const throw(MotionFileException);
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/ForcePlateMDF.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/ForcePlateMDF.cpp
index 0402fae5..d5cf0001 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/ForcePlateMDF.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/ForcePlateMDF.cpp
@@ -88,7 +88,7 @@ namespace Open3DMotion
if (iplate < data[VAR_FORCE_PLATE_FLAGS].size() &&
data[VAR_FORCE_PLATE_FLAGS][iplate].size() >= 2)
{
- UInt16 wType = *(UInt16*)(&(data[VAR_FORCE_PLATE_FLAGS][iplate][0]));
+ UInt16 wType = *reinterpret_cast<UInt16*>(&(data[VAR_FORCE_PLATE_FLAGS][iplate][0]));
id = wType >> 8;
}
@@ -109,7 +109,7 @@ namespace Open3DMotion
if (iplate < data[VAR_FORCE_PLATE_CONSTANTS].size() &&
data[VAR_FORCE_PLATE_CONSTANTS][iplate].size() >= 6)
{
- ParseMDFSensorConstants((const Int16*)&data[VAR_FORCE_PLATE_CONSTANTS][iplate][0]);
+ ParseMDFSensorConstants(reinterpret_cast<const Int16*>(&data[VAR_FORCE_PLATE_CONSTANTS][iplate][0]));
}
// custom outline
@@ -123,7 +123,7 @@ namespace Open3DMotion
double corner_vector[3] = { 0, 0, 0 };
for (size_t j = 0; j < 3; j++)
- corner_vector[j] = 0.1 * ((const Int16*)&data[VAR_FORCE_PLATE_POSITION][4*iplate+i][0])[j];
+ corner_vector[j] = 0.1 * (reinterpret_cast<const Int16*>(&data[VAR_FORCE_PLATE_POSITION][4*iplate+i][0]))[j];
Outline[i].SetVector(corner_vector);
}
@@ -146,7 +146,7 @@ namespace Open3DMotion
}
for (size_t c = 0; c < 6; c++)
{
- kistler_params[r][c] = ((float*)&data[VAR_FORCE_PLATE_COP_COEFFS][r][0])[c];
+ kistler_params[r][c] = (reinterpret_cast<float*>(&data[VAR_FORCE_PLATE_COP_COEFFS][r][0]))[c];
}
}
@@ -187,33 +187,33 @@ namespace Open3DMotion
// get scaled inputs
float Fy = -1.0f *
- ((Int16*)&(data[VAR_ANALOGUE_FORCE][platechan0 ][0]))[index_frame]
- * *(float*)(&data[VAR_FORCE_RESOLUTION][platechan0 ][0]);
+ (reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0 ][0])))[index_frame]
+ * *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0 ][0]);
float Fx = -1.0f *
- ((Int16*)&(data[VAR_ANALOGUE_FORCE][platechan0+1][0]))[index_frame]
- * *(float*)(&data[VAR_FORCE_RESOLUTION][platechan0+1][0]);
+ (reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0+1][0])))[index_frame]
+ * *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0+1][0]);
float Fz =
- ((Int16*)&(data[VAR_ANALOGUE_FORCE][platechan0+2][0]))[index_frame]
- * *(float*)(&data[VAR_FORCE_RESOLUTION][platechan0+2][0]);
+ (reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0+2][0])))[index_frame]
+ * *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0+2][0]);
float My = 1000.0f *
- ((Int16*)&(data[VAR_ANALOGUE_FORCE][platechan0+3][0]))[index_frame]
- * *(float*)(&data[VAR_FORCE_RESOLUTION][platechan0+3][0]);
+ (reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0+3][0])))[index_frame]
+ * *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0+3][0]);
float Mx = 1000.0f *
- ((Int16*)&(data[VAR_ANALOGUE_FORCE][platechan0+4][0]))[index_frame]
- * *(float*)(&data[VAR_FORCE_RESOLUTION][platechan0+4][0]);
+ (reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0+4][0])))[index_frame]
+ * *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0+4][0]);
// Mz would be like this but not needed for these calcs
// float Mz = 1000.0f *
- // ((Int16*)&(data[FileFormatMDF::VAR_ANALOGUE_FORCE][platechan0+5][0]))[index_frame]
- // * *(float*)(&data[FileFormatMDF::VAR_FORCE_RESOLUTION][platechan0+5][0]);
+ // (reinterpret_cast<Int16*>(&data[FileFormatMDF::VAR_ANALOGUE_FORCE][platechan0+5][0]))[index_frame]
+ // * *reinterpret_cast<float*>(&data[FileFormatMDF::VAR_FORCE_RESOLUTION][platechan0+5][0]);
// centre of pressure as originally computed
float Py =
- ((Int16*)&(data[VAR_ANALOGUE_FORCE][platechan0+6][0]))[index_frame]
- * *(float*)(&data[VAR_FORCE_RESOLUTION][platechan0+6][0]);
+ (reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0+6][0])))[index_frame]
+ * *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0+6][0]);
float Px =
- ((Int16*)&(data[VAR_ANALOGUE_FORCE][platechan0+7][0]))[index_frame]
- * *(float*)(&data[VAR_FORCE_RESOLUTION][platechan0+7][0]);
+ (reinterpret_cast<Int16*>(&(data[VAR_ANALOGUE_FORCE][platechan0+7][0])))[index_frame]
+ * *reinterpret_cast<float*>(&data[VAR_FORCE_RESOLUTION][platechan0+7][0]);
if (fabs(Fz) < 1.0)
continue;
@@ -576,7 +576,7 @@ namespace Open3DMotion
size_t ForcePlateMDF::MDFChannelToRuntimeChannel(size_t mdfchannel) const
{
// get orientation
- Orientation orient = MDFOrientation();
+ int orient = static_cast<int>(MDFOrientation());
// cannot remap unless orientation 0-3
if (orient < 0 || orient >= 4)
@@ -609,7 +609,7 @@ namespace Open3DMotion
size_t ForcePlateMDF::RuntimeChannelToMDFChannel(size_t runchannel) const
{
// get orientation
- Orientation orient = MDFOrientation();
+ int orient = static_cast<int>(MDFOrientation());
// cannot remap unless orientation 0-3
if (orient < 0 || orient >= 4)
@@ -640,7 +640,7 @@ namespace Open3DMotion
double ForcePlateMDF::MDFChannelScale(size_t mdfchannel) const
{
// get orientation
- Orientation orient = MDFOrientation();
+ int orient = static_cast<int>(MDFOrientation());
// cannot remap unless orientation 0-3
if (orient < 0 || orient >= 4)
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/MDFDescriptor.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/MDFDescriptor.cpp
index 1378a3a5..42a3384e 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/MDFDescriptor.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MDF/MDFDescriptor.cpp
@@ -49,7 +49,7 @@ namespace Open3DMotion
const UInt8* inview,
float scale)
{
- const Int16* pos = (const Int16*)data;
+ const Int16* pos = reinterpret_cast<const Int16*>(data);
// Int32 num_frames = ts.NumFrames();
UInt16 wInView(0);
*(UInt8*)&wInView = *(inview+1);
@@ -101,7 +101,7 @@ namespace Open3DMotion
const UInt8* inview,
float /*scale*/)
{
- const float* pos = (const float*)data;
+ const float* pos = reinterpret_cast<const float*>(data);
UInt16 wInView;
*(UInt8*)&wInView = *(inview+1);
*((UInt8*)&wInView+1) = *inview;
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MoXie/FileFormatMoXie.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MoXie/FileFormatMoXie.cpp
index c580df70..0824ed04 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MoXie/FileFormatMoXie.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MoXie/FileFormatMoXie.cpp
@@ -16,7 +16,7 @@
#include <float.h>
#include <sstream>
#include <iomanip>
-
+#include <memory>
namespace Open3DMotion
{
const char* moxie_xml_doc = "moxie_viewer_datafile";
@@ -58,7 +58,7 @@ namespace Open3DMotion
return ProbeTextString(is, moxie_xml_doc, 1024);
}
- TreeValue* FileFormatMoXie::Read(const MotionFileHandler& /*context*/, std::istream& is, BinMemFactory& memfactory, const TreeValue* /*readoptions*/) const throw(MotionFileException)
+ TreeValue* FileFormatMoXie::Read(const MotionFileHandler& /*context*/, std::istream& is, const BinMemFactory& memfactory, const TreeValue* /*readoptions*/) const throw(MotionFileException)
{
// trial to fill
std::auto_ptr<Trial> trial(new Trial);
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MoXie/FileFormatMoXie.h b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MoXie/FileFormatMoXie.h
index 43142bb4..52ab6852 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MoXie/FileFormatMoXie.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/MoXie/FileFormatMoXie.h
@@ -33,7 +33,7 @@ namespace Open3DMotion
virtual bool Probe(const MotionFileHandler& context, TreeValue*& readoptions, std::istream& is) const throw(MotionFileException);
// Read MDF
- virtual TreeValue* Read(const MotionFileHandler& context, std::istream& is, BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException) ;
+ virtual TreeValue* Read(const MotionFileHandler& context, std::istream& is, const BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException) ;
// Write MDF
virtual void Write(const MotionFileHandler& context, const TreeValue* contents, std::ostream& os, const TreeValue* writeoptions) const throw(MotionFileException);
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/FileFormatXMove.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/FileFormatXMove.cpp
index 4be21792..2d2db8bb 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/FileFormatXMove.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/FileFormatXMove.cpp
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -20,6 +20,8 @@
namespace Open3DMotion
{
+ const char FileFormatXMove::XMLFormatDescriptorSection[] = "FileFormat";
+
FileFormatXMove::FileFormatXMove() :
MotionFileFormat("XMove", "XMove", "xmove,xml")
{
@@ -47,7 +49,7 @@ namespace Open3DMotion
return true;
}
- TreeValue* FileFormatXMove::Read(const MotionFileHandler& /*context*/, std::istream& is, BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException)
+ TreeValue* FileFormatXMove::Read(const MotionFileHandler& /*context*/, std::istream& is, const BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException)
{
// options
FileFormatOptionsXMove xmove_options;
@@ -70,12 +72,12 @@ namespace Open3DMotion
// Support legacy version of format in which
// elements of time sequence and event groups structures have assumed types
// and some naming conventions are different
- reader = std::auto_ptr<XMLReadingMachine>( new XMLReadingMachineLegacy );
+ reader = std::auto_ptr<XMLReadingMachine>( new XMLReadingMachineLegacy(memfactory) );
}
else
{
// Standard XML reader
- reader = std::auto_ptr<XMLReadingMachine>( new XMLReadingMachine );
+ reader = std::auto_ptr<XMLReadingMachine>( new XMLReadingMachine(memfactory) );
}
// find xmove node
@@ -88,7 +90,8 @@ namespace Open3DMotion
}
// parse XML tree
- TreeCompound* trial_object = TreeValueCast<TreeCompound>( reader->ReadValue(xmove_node) );
+ TreeValue* trial_tree = reader->ReadValue(xmove_node);
+ TreeCompound* trial_object = TreeValueCast<TreeCompound>( trial_tree );
// optionally replace any float32 info with float64
if (xmove_options.ConvertBinaryFloat32)
@@ -133,30 +136,28 @@ namespace Open3DMotion
writer = std::auto_ptr<XMLWritingMachine>(new XMLWritingMachine(os));
}
- // compound object for trial
- const TreeCompound* trial_object = TreeValueCast<TreeCompound> ( contents );
+ // make copy of trial so we can adjust its structure according to export options
+ std::auto_ptr<TreeCompound> export_contents( new TreeCompound );
+ const TreeCompound* input_contents = TreeValueCast<TreeCompound> ( contents );
+ if (input_contents)
+ {
+ export_contents->CopyFrom( input_contents );
+ }
+
+ // remove any existing format info - we will write a new one
+ export_contents->Remove(XMLFormatDescriptorSection);
// optionally convert 64-bit floats to 32-bit
std::auto_ptr<TreeCompound> contents_copy;
if (xmove_options.ConvertBinaryFloat32)
{
- if (trial_object)
+ // remap binary data
+ BinMemFactoryDefault memfactory;
+ for (size_t calclevel = 0; calclevel < export_contents->NumElements(); calclevel++)
{
- // copy it
- contents_copy = std::auto_ptr<TreeCompound>( trial_object->NewBlank() );
- contents_copy->CopyFrom( contents );
-
- // set pointers to copy
- contents = trial_object = contents_copy.get();
-
- // remap binary data
- BinMemFactoryDefault memfactory;
- for (size_t calclevel = 0; calclevel < trial_object->NumElements(); calclevel++)
- {
- TreeCompound* section = TreeValueCast<TreeCompound> ( contents_copy.get()->Node(calclevel)->Value() );
- ConvertListFloat64To32(section, "Sequences", TimeSequence::StructureName, memfactory);
- ConvertListFloat64To32(section, "EventGroups", EventGroup::StructureName, memfactory);
- }
+ TreeCompound* section = TreeValueCast<TreeCompound> ( export_contents->Node(calclevel)->Value() );
+ ConvertListFloat64To32(section, "Sequences", TimeSequence::StructureName, memfactory);
+ ConvertListFloat64To32(section, "EventGroups", EventGroup::StructureName, memfactory);
}
}
@@ -168,29 +169,26 @@ namespace Open3DMotion
// format descriptor
std::auto_ptr<TreeValue> descriptor_tree( descriptor.ToTree() );
- writer->WriteValue("FileFormat", descriptor_tree.get() );
+ writer->WriteValue(XMLFormatDescriptorSection, descriptor_tree.get() );
// all elements of trial, optionally excluding Calc section
- if (trial_object)
+ for (size_t element_index = 0; element_index < export_contents->NumElements(); element_index++)
{
- for (size_t element_index = 0; element_index < trial_object->NumElements(); element_index++)
- {
- const TreeCompoundNode* node = trial_object->Node(element_index);
+ const TreeCompoundNode* node = export_contents->Node(element_index);
- // optionally exclude calc
- if (xmove_options.ExcludeCalc && node->Name().compare(MEMBER_NAME(Trial::Calc)) == 0)
- continue;
+ // optionally exclude calc
+ if (xmove_options.ExcludeCalc && node->Name().compare(MEMBER_NAME(Trial::Calc)) == 0)
+ continue;
- // otherwise write the node
- writer->WriteValue(node->Name(), node->Value());
- }
+ // otherwise write the node
+ writer->WriteValue(node->Name(), node->Value());
}
os << "</" << xmove_tag << ">\n";
}
- void FileFormatXMove::ConvertListFloat32To64(TreeCompound* section, const char* listname, const char* structurename, BinMemFactory& memfactory)
+ void FileFormatXMove::ConvertListFloat32To64(TreeCompound* section, const char* listname, const char* structurename, const BinMemFactory& memfactory)
{
if (section)
{
@@ -217,7 +215,7 @@ namespace Open3DMotion
}
}
- void FileFormatXMove::ConvertListFloat64To32(TreeCompound* section, const char* listname, const char* structurename, BinMemFactory& memfactory)
+ void FileFormatXMove::ConvertListFloat64To32(TreeCompound* section, const char* listname, const char* structurename, const BinMemFactory& memfactory)
{
if (section)
{
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/FileFormatXMove.h b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/FileFormatXMove.h
index 3a3631f9..eb7e5a9c 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/FileFormatXMove.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/FileFormatXMove.h
@@ -23,20 +23,22 @@ namespace Open3DMotion
virtual ~FileFormatXMove();
+ static const char XMLFormatDescriptorSection[] /*="FileFormat"*/;
+
public:
// check id and number type
virtual bool Probe(const MotionFileHandler& context, TreeValue*& readoptions, std::istream& is) const throw(MotionFileException);
// Read MDF
- virtual TreeValue* Read(const MotionFileHandler& context, std::istream& is, BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException) ;
+ virtual TreeValue* Read(const MotionFileHandler& context, std::istream& is, const BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException) ;
// Write MDF
virtual void Write(const MotionFileHandler& context, const TreeValue* contents, std::ostream& os, const TreeValue* writeoptions) const throw(MotionFileException);
protected:
- static void ConvertListFloat32To64(TreeCompound* section, const char* listname, const char* structurename, BinMemFactory& memfactory);
- static void ConvertListFloat64To32(TreeCompound* section, const char* listname, const char* structurename, BinMemFactory& memfactory);
+ static void ConvertListFloat32To64(TreeCompound* section, const char* listname, const char* structurename, const BinMemFactory& memfactory);
+ static void ConvertListFloat64To32(TreeCompound* section, const char* listname, const char* structurename, const BinMemFactory& memfactory);
};
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/XMLReadingMachineLegacy.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/XMLReadingMachineLegacy.cpp
index 0e9e946e..2e7fd35e 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/XMLReadingMachineLegacy.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/XMLReadingMachineLegacy.cpp
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -13,11 +13,11 @@
#include "Open3DMotion/OpenORM/Branches/TreeList.h"
#include "Open3DMotion/Biomechanics/Trial/EventGroup.h"
#include <pugixml.hpp>
-#include <cstring>
namespace Open3DMotion
{
- XMLReadingMachineLegacy::XMLReadingMachineLegacy() :
+ XMLReadingMachineLegacy::XMLReadingMachineLegacy(const BinMemFactory& _memfactory) :
+ XMLReadingMachine(_memfactory),
legacy(legacy_none)
{
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/XMLReadingMachineLegacy.h b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/XMLReadingMachineLegacy.h
index e74184b0..00b4809b 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/XMLReadingMachineLegacy.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/XMLReadingMachineLegacy.h
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -17,7 +17,7 @@ namespace Open3DMotion
class XMLReadingMachineLegacy : public XMLReadingMachine
{
public:
- XMLReadingMachineLegacy();
+ XMLReadingMachineLegacy(const BinMemFactory& _memfactory);
public:
virtual TreeValue* ReadValue(const pugi::xml_node& element) throw(XMLReadException);
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/XMLWritingMachineLegacy.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/XMLWritingMachineLegacy.cpp
index a5da62ac..63c08042 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/XMLWritingMachineLegacy.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/Formats/XMove/XMLWritingMachineLegacy.cpp
@@ -8,7 +8,7 @@
#include "XMLWritingMachineLegacy.h"
#include "Open3DMotion/OpenORM/IO/XML/ReadWriteXML.h"
#include "Open3DMotion/OpenORM/Mappings/RichBinary/BinaryFieldSpec.h"
-#include "Open3DMotion/Biomechanics//Trial/Trial.h"
+#include "Open3DMotion/Biomechanics/Trial/Trial.h"
#include <pugixml.hpp>
#include <memory>
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileException.h b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileException.h
index ae42fe50..1fcdff3f 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileException.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileException.h
@@ -45,4 +45,4 @@ namespace Open3DMotion
};
}
-#endif
+#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileFormat.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileFormat.cpp
index eba76c5a..98ac4de6 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileFormat.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileFormat.cpp
@@ -1,12 +1,12 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
#include "MotionFileFormat.h"
-#include <cstring>
+#include <string.h>
namespace Open3DMotion
{
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileFormat.h b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileFormat.h
index 66587f8f..67bea06c 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileFormat.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileFormat.h
@@ -64,7 +64,7 @@ namespace Open3DMotion
virtual bool Probe(const MotionFileHandler& context, TreeValue*& readoptions, std::istream& is) const throw(MotionFileException) = 0;
// Read the file into trial object (or derived trial object)
- virtual TreeValue* Read(const MotionFileHandler& context, std::istream& is, BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException) = 0;
+ virtual TreeValue* Read(const MotionFileHandler& context, std::istream& is, const BinMemFactory& memfactory, const TreeValue* readoptions) const throw(MotionFileException) = 0;
// Write the file
virtual void Write(const MotionFileHandler& context, const TreeValue* contents, std::ostream& os, const TreeValue* writeoptions) const throw(MotionFileException) = 0;
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileHandler.cpp b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileHandler.cpp
index 961bb2cc..1ec9442c 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileHandler.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileHandler.cpp
@@ -31,7 +31,10 @@ namespace Open3DMotion
{
}
- TreeValue* MotionFileHandler::Read(const char* filename, const MotionFileFormatList& formatlist /*=MotionFileFormatListAll()*/) throw(MotionFileException)
+ TreeValue* MotionFileHandler::Read(
+ const char* filename,
+ const MotionFileFormatList& formatlist /*=MotionFileFormatListAll()*/,
+ const BinMemFactory& memfactory /*=BinMemFactoryDefault()*/ ) throw(MotionFileException)
{
#ifdef _MSC_VER
// creating a C-style file object may work better with UTF-8
@@ -45,7 +48,7 @@ namespace Open3DMotion
#endif
// read
- TreeValue* result = Read(is, formatlist);
+ TreeValue* result = Read(is, formatlist, memfactory);
// explicitly close file
is.close();
@@ -53,11 +56,11 @@ namespace Open3DMotion
return result;
}
- TreeValue* MotionFileHandler::Read(std::istream& is, const MotionFileFormatList& formatlist /*=MotionFileFormatListAll()*/) throw(MotionFileException)
+ TreeValue* MotionFileHandler::Read(
+ std::istream& is,
+ const MotionFileFormatList& formatlist /*=MotionFileFormatListAll()*/,
+ const BinMemFactory& memfactory /*=BinMemFactoryDefault()*/ ) throw(MotionFileException)
{
- // default for now
- BinMemFactoryDefault memfactory;
-
// establish the format
TreeValue* readoptions(NULL);
const MotionFileFormat* format(NULL);
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileHandler.h b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileHandler.h
index 15270a91..c74c78d8 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileHandler.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/MotionFile/MotionFileHandler.h
@@ -12,6 +12,7 @@
#include "Open3DMotion/MotionFile/MotionFileException.h"
#include "Open3DMotion/MotionFile/MotionFileFormatList.h"
#include "Open3DMotion/MotionFile/MotionFileFormatListAll.h"
+#include "Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactoryDefault.h"
namespace Open3DMotion
{
@@ -36,10 +37,10 @@ namespace Open3DMotion
{ return programversion; }
/** Read from file */
- TreeValue* Read(const char* filename, const MotionFileFormatList& formatlist = MotionFileFormatListAll()) throw(MotionFileException);
+ TreeValue* Read(const char* filename, const MotionFileFormatList& formatlist = MotionFileFormatListAll(), const BinMemFactory& memfactory = BinMemFactoryDefault()) throw(MotionFileException);
/** Read from STL stream */
- TreeValue* Read(std::istream& is, const MotionFileFormatList& formatlist = MotionFileFormatListAll()) throw(MotionFileException);
+ TreeValue* Read(std::istream& is, const MotionFileFormatList& formatlist = MotionFileFormatListAll(), const BinMemFactory& memfactory = BinMemFactoryDefault()) throw(MotionFileException);
/** Write to file */
void Write(const char* filename, const TreeValue* contents, const TreeValue* writeoptions, const MotionFileFormatList& formatlist = MotionFileFormatListAll()) throw(MotionFileException);
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Branches/TreeCompound.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Branches/TreeCompound.h
index eb2f1178..cf440091 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Branches/TreeCompound.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Branches/TreeCompound.h
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -56,10 +56,7 @@ namespace Open3DMotion
const TreeValue* t = Get(name);
if (t != NULL)
{
- if (ValueType::ClassNameMatches(t))
- {
- return static_cast<const ValueType*>( t );
- }
+ return TreeValueCast<ValueType> (t);
}
return NULL;
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/ClassName.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/ClassName.h
new file mode 100644
index 00000000..23487f0b
--- /dev/null
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/ClassName.h
@@ -0,0 +1,40 @@
+/*--
+ Open3DMotion
+ Copyright (c) 2004-2013.
+ All rights reserved.
+ See LICENSE.txt for more information.
+--*/
+
+#ifndef _ORMPP_CLASS_NAME_H_
+#define _ORMPP_CLASS_NAME_H_
+
+/** Declare abstract base class as nameable (derived class instances will contain names) */
+#define DECLARE_CLASS_NAME_ABSTRACT_BASE() \
+ bool ClassNameMatches(const char* name) const; \
+ virtual const char* ClassName() const = 0;
+
+/** Implementation required for nameable abstract base class */
+#define DEFINE_CLASS_NAME_ABSTRACT_BASE(x) \
+ bool x::ClassNameMatches(const char* name) const \
+ { return (strcmp(ClassName(), name) == 0); }
+
+/** Macro to declare a name for introspection */
+#define DECLARE_CLASS_NAME() \
+ static const char classname[]; \
+ virtual const char* ClassName() const { return classname; }
+
+/** Macro to implement a text string name for a class */
+#define DEFINE_CLASS_NAME(x) \
+ const char x::classname[] = #x
+
+namespace Open3DMotion
+{
+ template<class BaseClass, class ValueClass> const ValueClass* NamedClassCast(const BaseClass* v)
+ { return (v && v->ClassNameMatches(ValueClass::classname)) ? static_cast<const ValueClass*> (v) : 0; }
+
+ template<class BaseClass, class ValueClass> ValueClass* NamedClassCast(BaseClass* v)
+ { return (v && v->ClassNameMatches(ValueClass::classname)) ? static_cast<ValueClass*> (v) : 0; }
+}
+
+#endif
+
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONInputStreamGZ.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONInputStreamGZ.cpp
index dfadd0ee..9caff959 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONInputStreamGZ.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONInputStreamGZ.cpp
@@ -7,6 +7,8 @@
#include "BSONInputStreamGZ.h"
#include <zlib.h>
+#include <memory.h>
+#include <stdlib.h>
namespace Open3DMotion
{
@@ -19,7 +21,7 @@ namespace Open3DMotion
strm = (z_stream*)malloc(sizeof(z_stream));
input_buffer = (UInt8*)malloc(chunk_size);
output_buffer = (UInt8*)malloc(chunk_size);
- memset(strm, NULL, sizeof(z_stream));
+ memset(strm, 0, sizeof(z_stream));
inflateInit2(strm, (16UL + 15UL));
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONInputStreamSTL.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONInputStreamSTL.cpp
index c8e62931..6ed5cddc 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONInputStreamSTL.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONInputStreamSTL.cpp
@@ -16,8 +16,9 @@ namespace Open3DMotion
void BSONInputStreamSTL::SkipBytes(UInt32 count) throw(BSONReadException)
{
+ size_t start_pos = static_cast<size_t>(input.tellg());
input.seekg(count, std::ios::cur);
- if (input.fail())
+ if (input.fail() || (static_cast<size_t>(input.tellg()) != (start_pos+count)))
throw BSONReadException("error skipping bytes in BSON stream");
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONObjectIdHolder.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONObjectIdHolder.cpp
index 13788f5e..6773ac0b 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONObjectIdHolder.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONObjectIdHolder.cpp
@@ -8,6 +8,7 @@
#include "BSONObjectIdHolder.h"
#include <sstream>
#include <iomanip>
+#include <stdio.h>
namespace Open3DMotion
{
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReader.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReader.cpp
index e35446b2..b23b1714 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReader.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReader.cpp
@@ -13,14 +13,18 @@
#include "Open3DMotion/OpenORM/Leaves/TreeBinary.h"
#include "Open3DMotion/OpenORM/Leaves/TreeBool.h"
#include "Open3DMotion/OpenORM/Leaves/MemoryHandlerBasic.h"
+#include "Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactory.h"
#include "BSONObjectIdHolder.h"
#include "BSONTimestampHolder.h"
+#include <memory>
+
namespace Open3DMotion
{
- BSONReader::BSONReader(BSONInputStream& _input) :
- input(_input)
+ BSONReader::BSONReader(BSONInputStream& _input, const BinMemFactory& _memfactory) :
+ input(_input),
+ memfactory(_memfactory)
{
}
@@ -161,9 +165,9 @@ namespace Open3DMotion
UInt8 subtype(0);
ReadBinary(&numbytes, 4);
ReadBinary(&subtype, 1);
- MemoryHandlerBasic memory(numbytes);
- ReadBinary(memory.Data(), numbytes);
- return new TreeBinary(&memory);
+ std::auto_ptr<MemoryHandler> memory( memfactory.Allocate(numbytes) );
+ ReadBinary(memory->Data(), numbytes);
+ return new TreeBinary(memory.get());
}
case 0x08: // boolean
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReader.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReader.h
index a5aabebd..09ae0255 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReader.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReader.h
@@ -16,13 +16,15 @@
namespace Open3DMotion
{
+ class BinMemFactory;
+
/** Read from a stream of BSON-encoded data and translate into OpenORM++ objects */
class BSONReader
{
public:
/** Construct for given stream */
- BSONReader(BSONInputStream& _input);
+ BSONReader(BSONInputStream& _input, const BinMemFactory& _memfactory);
/** Virtual destructor */
virtual ~BSONReader();
@@ -75,8 +77,13 @@ namespace Open3DMotion
bool HaveMore()
{ return input.HaveMore(); }
+ protected:
+ const BinMemFactory& MemFactory()
+ { return memfactory; }
+
private:
BSONInputStream& input;
+ const BinMemFactory& memfactory;
};
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReaderMOBL.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReaderMOBL.cpp
index f59f299c..4db83959 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReaderMOBL.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReaderMOBL.cpp
@@ -8,6 +8,9 @@
#include "Open3DMotion/OpenORM/IO/BSON/BSONReaderMOBL.h"
#include "Open3DMotion/OpenORM/Leaves/MemoryHandlerBasic.h"
#include "Open3DMotion/OpenORM/Leaves/TreeBinary.h"
+#include "Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactory.h"
+
+#include <memory>
namespace Open3DMotion
{
@@ -27,9 +30,9 @@ namespace Open3DMotion
{
SkipBytes(4);
numbytes -= 4;
- MemoryHandlerBasic memory(numbytes);
- ReadBinary(memory.Data(), numbytes);
- return new TreeBinary(&memory);
+ std::auto_ptr<MemoryHandler> memory( MemFactory().Allocate(numbytes) );
+ ReadBinary(memory->Data(), numbytes);
+ return new TreeBinary(memory.get());
}
else
{
@@ -45,4 +48,4 @@ namespace Open3DMotion
}
}
-}
\ No newline at end of file
+}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReaderMOBL.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReaderMOBL.h
index 757c043a..169967c0 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReaderMOBL.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/BSON/BSONReaderMOBL.h
@@ -17,8 +17,8 @@ namespace Open3DMotion
class BSONReaderMOBL : public BSONReader
{
public:
- BSONReaderMOBL(BSONInputStream& _input) :
- BSONReader(_input)
+ BSONReaderMOBL(BSONInputStream& _input, const BinMemFactory& _memfactory) :
+ BSONReader(_input, _memfactory)
{
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLBinary.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLBinary.cpp
index 9ae7db40..2a4491d4 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLBinary.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLBinary.cpp
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -9,8 +9,9 @@
#include "XMLReadingMachine.h"
#include "XMLWritingMachine.h"
#include "Open3DMotion/OpenORM/Leaves/MemoryHandlerBasic.h"
+#include "Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactory.h"
#include <pugixml.hpp>
-#include <cstring>
+#include <string.h>
extern "C"
{
@@ -18,6 +19,8 @@ extern "C"
#include <b64/cdecode.h>
}
+#include <memory>
+
namespace Open3DMotion
{
void ReadWriteXMLBinary::WriteValue(XMLWritingMachine& writer, const TreeValue* value) const
@@ -49,7 +52,7 @@ namespace Open3DMotion
}
}
- TreeValue* ReadWriteXMLBinary::ReadValue(XMLReadingMachine& /*reader*/, const pugi::xml_node& element) const
+ TreeValue* ReadWriteXMLBinary::ReadValue(XMLReadingMachine& reader, const pugi::xml_node& element) const
{
// find text element with base64 encoding in it
const char* text = "";
@@ -73,11 +76,15 @@ namespace Open3DMotion
base64_init_decodestate(&state);
int decoded_length = base64_decode_block(text, textlength, (char*) &decoded_binary[0], &state);
- // copy to memory object
- MemoryHandlerBasic binary_handler((size_t)decoded_length);
- memcpy(binary_handler.Data(), &decoded_binary[0], (size_t)decoded_length);
+ // Allocate memory object with wrapper
+ // Use of auto pointer means that wrapper will be deleted, but note that inner object is
+ // unaffected
+ std::auto_ptr<MemoryHandler> binary_handler( reader.MemFactory().Allocate((size_t)decoded_length) );
+
+ // copy
+ memcpy(binary_handler->Data(), &decoded_binary[0], (size_t)decoded_length);
// done
- return new TreeBinary(&binary_handler);
+ return new TreeBinary(binary_handler.get());
}
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLBool.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLBool.cpp
index 7ead0102..a30873bb 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLBool.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLBool.cpp
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -9,7 +9,7 @@
#include "XMLReadingMachine.h"
#include "XMLWritingMachine.h"
#include <iomanip>
-#include <cstdio>
+#include <stdio.h>
#if defined(_MSC_VER)
// Disable unsafe warning (use of the function 'sscanf' instead of 'sscanf_s' for portability reasons;
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLCompound.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLCompound.cpp
index 91ba99d2..0418918f 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLCompound.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLCompound.cpp
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLFloat64.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLFloat64.cpp
index ba31770a..55963284 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLFloat64.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLFloat64.cpp
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -9,7 +9,7 @@
#include "XMLReadingMachine.h"
#include "XMLWritingMachine.h"
#include <iomanip>
-#include <cstdio>
+#include <stdio.h>
#if defined(_MSC_VER)
// Disable unsafe warning (use of the function 'sscanf' instead of 'sscanf_s' for portability reasons;
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLInt32.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLInt32.cpp
index a5bfd440..ffa9277d 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLInt32.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLInt32.cpp
@@ -9,7 +9,7 @@
#include "XMLReadingMachine.h"
#include "XMLWritingMachine.h"
#include <iomanip>
-#include <cstdio>
+#include <stdio.h>
#if defined(_MSC_VER)
// Disable unsafe warning (use of the function 'sscanf' instead of 'sscanf_s' for portability reasons;
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLList.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLList.cpp
index 3c3580c0..f267c8dd 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLList.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/ReadWriteXMLList.cpp
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/XMLReadingMachine.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/XMLReadingMachine.cpp
index 9237fb8e..07099161 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/XMLReadingMachine.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/XMLReadingMachine.cpp
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -11,7 +11,8 @@
namespace Open3DMotion
{
- XMLReadingMachine::XMLReadingMachine()
+ XMLReadingMachine::XMLReadingMachine(const BinMemFactory& _memfactory) :
+ memfactory(_memfactory)
{
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/XMLReadingMachine.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/XMLReadingMachine.h
index 9590eddb..b4b16949 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/XMLReadingMachine.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/XMLReadingMachine.h
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -19,10 +19,12 @@ namespace pugi
namespace Open3DMotion
{
+ class BinMemFactory;
+
class XMLReadingMachine : public XMLReadWriteMachine
{
public:
- XMLReadingMachine();
+ XMLReadingMachine(const BinMemFactory& _memfactory);
virtual ~XMLReadingMachine();
@@ -35,6 +37,12 @@ namespace Open3DMotion
virtual TreeValue* ReadValue(const pugi::xml_node& element) throw(XMLReadException);
virtual void ReadTextNode(std::string& node_text, const pugi::xml_node& element);
+
+ const BinMemFactory& MemFactory() const
+ { return memfactory; }
+
+ private:
+ const BinMemFactory& memfactory;
};
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/XMLWritingMachine.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/XMLWritingMachine.h
index 96899fb1..f5ce51ae 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/XMLWritingMachine.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/IO/XML/XMLWritingMachine.h
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -10,7 +10,6 @@
#include "XMLReadWriteMachine.h"
#include "Open3DMotion/OpenORM/TreeValue.h"
-
#include <ostream>
namespace Open3DMotion
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandler.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandler.cpp
index ff3372b8..5114977a 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandler.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandler.cpp
@@ -1,14 +1,17 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
#include "Open3DMotion/OpenORM/Leaves/MemoryHandler.h"
+#include <string.h>
namespace Open3DMotion
{
+ DEFINE_CLASS_NAME_ABSTRACT_BASE(MemoryHandler)
+
MemoryHandler::~MemoryHandler()
{
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandler.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandler.h
index 4559fde0..5472a551 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandler.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandler.h
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -9,6 +9,7 @@
#define _OPEN3DMOTION_MEMORY_HANDLER_H_
#include "Open3DMotion/OpenORM/Types.h"
+#include "Open3DMotion/OpenORM/ClassName.h"
namespace Open3DMotion
{
@@ -27,6 +28,8 @@ namespace Open3DMotion
virtual MemoryHandler* Clone() const = 0;
+ DECLARE_CLASS_NAME_ABSTRACT_BASE();
+
};
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerBasic.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerBasic.cpp
index 4a7c3785..27f36849 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerBasic.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerBasic.cpp
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -11,6 +11,8 @@
namespace Open3DMotion
{
+ DEFINE_CLASS_NAME(MemoryHandlerBasic);
+
MemoryHandlerBasic::MemoryHandlerBasic(size_t _sizebytes) :
sizebytes(_sizebytes),
refcount(new size_t),
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerBasic.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerBasic.h
index ac182eee..80680fcb 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerBasic.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerBasic.h
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -22,6 +22,7 @@ namespace Open3DMotion
class MemoryHandlerBasic : public MemoryHandler
{
public:
+ DECLARE_CLASS_NAME();
MemoryHandlerBasic(size_t _sizebytes);
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerNull.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerNull.cpp
index dd3f47e2..bc031343 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerNull.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerNull.cpp
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -10,6 +10,8 @@
namespace Open3DMotion
{
+ DEFINE_CLASS_NAME(MemoryHandlerNull);
+
void MemoryHandlerNull::Free()
{
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerNull.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerNull.h
index faafadc8..58d847fd 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerNull.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/MemoryHandlerNull.h
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -15,6 +15,7 @@ namespace Open3DMotion
class MemoryHandlerNull : public MemoryHandler
{
public:
+ DECLARE_CLASS_NAME();
virtual void Free();
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeBinary.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeBinary.h
index 1bad2f9e..1e9b26eb 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeBinary.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeBinary.h
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -42,8 +42,11 @@ namespace Open3DMotion
size_t SizeBytes() const
{ return binmemory->SizeBytes(); }
+ const MemoryHandler* BinMemory() const
+ { return binmemory; }
+
private:
MemoryHandler* binmemory;
};
}
-#endif
\ No newline at end of file
+#endif
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeSimpleValue.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeSimpleValue.h
index 43029e4f..d6d95bed 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeSimpleValue.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeSimpleValue.h
@@ -52,4 +52,4 @@ namespace Open3DMotion
};
}
-#endif
+#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeString.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeString.cpp
index 3500a945..abf56263 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeString.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeString.cpp
@@ -21,6 +21,11 @@ namespace Open3DMotion
{
}
+ TreeString::TreeString(const std::string& _str) :
+ TreeSimpleValue<std::string> (_str)
+ {
+ }
+
TreeString* TreeString::NewBlank() const
{
return new TreeString();
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeString.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeString.h
index 1041f2f8..e149d455 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeString.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Leaves/TreeString.h
@@ -22,6 +22,8 @@ namespace Open3DMotion
TreeString(const char* _cstr);
+ TreeString(const std::string& _str);
+
public:
virtual TreeString* NewBlank() const;
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/MapArrayCompound.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/MapArrayCompound.h
index f56e37ff..a7a07946 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/MapArrayCompound.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/MapArrayCompound.h
@@ -146,4 +146,4 @@ namespace Open3DMotion
};
}
-#endif
+#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/MapArrayFloat64.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/MapArrayFloat64.h
index 1d62af18..70683483 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/MapArrayFloat64.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/MapArrayFloat64.h
@@ -22,4 +22,4 @@ namespace Open3DMotion
}
};
}
-#endif
+#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/MapElement.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/MapElement.h
index e09fbe5c..cc373cab 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/MapElement.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/MapElement.h
@@ -49,4 +49,4 @@ namespace Open3DMotion
};
}
-#endif
+#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinIter.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinIter.h
index 2d2315d1..e12092fa 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinIter.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinIter.h
@@ -304,4 +304,4 @@ namespace Open3DMotion
};
}
-#endif
+#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactory.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactory.h
index 1917e8b9..c4bebdc9 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactory.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactory.h
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -17,9 +17,9 @@ namespace Open3DMotion
{
public:
virtual ~BinMemFactory() {};
- virtual MemoryHandler* Allocate(size_t numframes, const BinaryStructure& framestruct) = 0;
+ virtual MemoryHandler* Allocate(size_t numbytes) const = 0;
};
}
-#endif
+#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactoryDefault.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactoryDefault.cpp
index 409d3d8e..0b9ad5c3 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactoryDefault.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactoryDefault.cpp
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -10,9 +10,8 @@
namespace Open3DMotion
{
- MemoryHandlerBasic* BinMemFactoryDefault::Allocate(size_t numframes, const BinaryStructure& framestruct)
+ MemoryHandlerBasic* BinMemFactoryDefault::Allocate(size_t numbytes) const
{
- size_t datasize = numframes * framestruct.TotalBytes();
- return new MemoryHandlerBasic(datasize);
+ return new MemoryHandlerBasic(numbytes);
}
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactoryDefault.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactoryDefault.h
index e9a61637..863d5d1c 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactoryDefault.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinMemFactoryDefault.h
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -16,7 +16,7 @@ namespace Open3DMotion
class BinMemFactoryDefault : public BinMemFactory
{
public:
- virtual MemoryHandlerBasic* Allocate(size_t numframes, const BinaryStructure& framestruct);
+ virtual MemoryHandlerBasic* Allocate(size_t numbytes) const;
};
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinaryStructure.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinaryStructure.h
index 9918e666..5d70fe6c 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinaryStructure.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/BinaryStructure.h
@@ -42,4 +42,4 @@ namespace Open3DMotion
};
}
-#endif
+#endif
\ No newline at end of file
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinary.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinary.cpp
index 9255dba2..b7e25788 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinary.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinary.cpp
@@ -1,12 +1,15 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
#include "Open3DMotion/OpenORM/Mappings/RichBinary/RichBinary.h"
+#include <memory>
+#include <memory.h>
+
namespace Open3DMotion
{
const char RichBinary::BinaryName[] = "Data";
@@ -17,10 +20,26 @@ namespace Open3DMotion
Register(BinaryName, &Binary);
}
- void RichBinary::Allocate(const std::vector<BinaryFieldSpec>& layout, size_t numframes, BinMemFactory& memfactory)
+ void RichBinary::Allocate(const std::vector<BinaryFieldSpec>& layout, size_t numframes, const BinMemFactory& memfactory)
{
Structure.SetLayout(layout);
- Binary.SetData( memfactory.Allocate(numframes, Structure) );
+ size_t datasize = Structure.TotalBytes() * numframes;
+ Binary.SetData( memfactory.Allocate(datasize) );
+ }
+
+ void RichBinary::DeepCopyFrom(const RichBinary& src, const BinMemFactory& memfactory)
+ {
+ // make a shallow copy of binary data and deep copy of all meta-data
+ std::auto_ptr<TreeValue> tree_copy( src.ToTree() );
+ FromTree(tree_copy.get());
+
+ // replace data with a copy
+ if (src.DataSizeBytes())
+ {
+ Binary.SetData( memfactory.Allocate(src.DataSizeBytes()) );
+ memcpy(Data(), src.Data(), src.DataSizeBytes());
+ }
}
+
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinary.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinary.h
index 2eb97a73..5cf6492c 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinary.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinary.h
@@ -29,7 +29,10 @@ namespace Open3DMotion
public:
/** Allocate with known parameters */
- void Allocate(const std::vector<BinaryFieldSpec>& layout, size_t numframes, BinMemFactory& memfactory);
+ void Allocate(const std::vector<BinaryFieldSpec>& layout, size_t numframes, const BinMemFactory& memfactory);
+
+ /** Perform a deep copy (copy all meta-data and allocate new memory) */
+ virtual void DeepCopyFrom(const RichBinary& src, const BinMemFactory& memfactory);
public:
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinaryConvertFloat.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinaryConvertFloat.cpp
index c986215e..ca1e7c90 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinaryConvertFloat.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinaryConvertFloat.cpp
@@ -11,9 +11,9 @@
namespace Open3DMotion
{
- template<typename OutputType, typename InputType> TreeValue* RichBinaryConvertFields(const TreeValue* input, const char* structure_name, BinMemFactory& memfactory);
+ template<typename OutputType, typename InputType> TreeValue* RichBinaryConvertFields(const TreeValue* input, const char* structure_name, const BinMemFactory& memfactory);
- template<typename OutputType, typename InputType> TreeValue* RichBinaryConvertFields(const TreeValue* input, const char* structure_name, BinMemFactory& memfactory)
+ template<typename OutputType, typename InputType> TreeValue* RichBinaryConvertFields(const TreeValue* input, const char* structure_name, const BinMemFactory& memfactory)
{
// read input
RichBinary rb_input(structure_name);
@@ -65,7 +65,7 @@ namespace Open3DMotion
{
for (size_t idim = 0; idim < ndim; idim++)
{
- *(OutputType*)(ptr_output) = *(const InputType*)(ptr_input);
+ *reinterpret_cast<OutputType*>(ptr_output) = static_cast<OutputType>(*reinterpret_cast<const InputType*>(ptr_input));
ptr_input += sizeof(InputType);
ptr_output += sizeof(OutputType);
}
@@ -108,12 +108,12 @@ namespace Open3DMotion
return compound_output;
}
- TreeValue* RichBinaryConvertFloat32To64(const TreeValue* input, const char* structure_name, BinMemFactory& memfactory)
+ TreeValue* RichBinaryConvertFloat32To64(const TreeValue* input, const char* structure_name, const BinMemFactory& memfactory)
{
return RichBinaryConvertFields<double, float> (input, structure_name, memfactory);
}
- TreeValue* RichBinaryConvertFloat64To32(const TreeValue* input, const char* structure_name, BinMemFactory& memfactory)
+ TreeValue* RichBinaryConvertFloat64To32(const TreeValue* input, const char* structure_name, const BinMemFactory& memfactory)
{
return RichBinaryConvertFields<float, double> (input, structure_name, memfactory);
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinaryConvertFloat.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinaryConvertFloat.h
index bb936fea..579b13a0 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinaryConvertFloat.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Mappings/RichBinary/RichBinaryConvertFloat.h
@@ -11,8 +11,8 @@ namespace Open3DMotion
class BinMemFactory;
/** Convert 32-bit float fields of rich binary object to 64-bit. */
- TreeValue* RichBinaryConvertFloat32To64(const TreeValue* input, const char* structure_name, BinMemFactory& memfactory);
+ TreeValue* RichBinaryConvertFloat32To64(const TreeValue* input, const char* structure_name, const BinMemFactory& memfactory);
/** Convert 64-bit float fields of rich binary object to 32-bit */
- TreeValue* RichBinaryConvertFloat64To32(const TreeValue* input, const char* structure_name, BinMemFactory& memfactory);
+ TreeValue* RichBinaryConvertFloat64To32(const TreeValue* input, const char* structure_name, const BinMemFactory& memfactory);
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/TreeValue.cpp b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/TreeValue.cpp
index 82caecef..ced83e0a 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/TreeValue.cpp
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/TreeValue.cpp
@@ -1,15 +1,18 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
#include "Open3DMotion/OpenORM/TreeValue.h"
-#include <cstring>
+#include <string>
+#include <string.h>
namespace Open3DMotion
{
+ DEFINE_CLASS_NAME_ABSTRACT_BASE(TreeValue);
+
TreeValue::TreeValue()
{
}
@@ -17,9 +20,4 @@ namespace Open3DMotion
TreeValue::~TreeValue()
{
}
-
- bool TreeValue::ClassNameMatches(const char* name) const
- {
- return (strcmp(ClassName(), name) == 0);
- }
}
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/TreeValue.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/TreeValue.h
index 0f39126b..972df9a6 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/TreeValue.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/TreeValue.h
@@ -1,6 +1,6 @@
/*--
Open3DMotion
- Copyright (c) 2004-2012.
+ Copyright (c) 2004-2013.
All rights reserved.
See LICENSE.txt for more information.
--*/
@@ -9,45 +9,31 @@
#define _ORMPP_TREE_VALUE_H_
#include "Open3DMotion/OpenORM/Types.h"
+#include "Open3DMotion/OpenORM/ClassName.h"
#include <stdlib.h>
-/** Macro to declare a name for introspection */
-#define DECLARE_CLASS_NAME() \
- static const char classname[]; \
- virtual const char* ClassName() const { return classname; } \
- static bool ClassNameMatches(const TreeValue* value) \
- { return value->ClassNameMatches(classname); }
-
-/** Macro to implement a text string name for a class */
-#define DEFINE_CLASS_NAME(x) \
- const char x::classname[] = #x
-
namespace Open3DMotion
{
class TreeValue
{
- public:
- // DISALLOW_COPY_AND_ASSIGN(TreeValue);
-
public:
TreeValue();
virtual ~TreeValue();
- bool ClassNameMatches(const char* name) const;
-
- virtual const char* ClassName() const = 0;
-
virtual TreeValue* NewBlank() const = 0;
virtual void CopyFrom(const TreeValue* src) = 0;
+
+ DECLARE_CLASS_NAME_ABSTRACT_BASE();
};
template<class ValueClass> const ValueClass* TreeValueCast(const TreeValue* v)
- { return ValueClass::ClassNameMatches(v) ? static_cast<const ValueClass*> (v) : NULL; }
+ { return NamedClassCast<TreeValue, ValueClass> (v); }
template<class ValueClass> ValueClass* TreeValueCast(TreeValue* v)
- { return ValueClass::ClassNameMatches(v) ? static_cast<ValueClass*> (v) : NULL; }
+ { return NamedClassCast<TreeValue, ValueClass> (v); }
+
}
#endif
diff --git a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Types.h b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Types.h
index 73048efe..e08cc23d 100644
--- a/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Types.h
+++ b/Utilities/Open3DMotion/src/Open3DMotion/OpenORM/Types.h
@@ -20,10 +20,18 @@
#endif
#ifdef __GNUC__
+#include <string.h>
#define _stricmp strcasecmp
#define _finite isfinite
#endif
+#ifndef SIZE_MAX
+#include <limits>
+#ifndef SIZE_MAX
+#define SIZE_MAX std::numeric_limits<size_t>::max()
+#endif
+#endif
+
namespace Open3DMotion
{
#ifdef __GNUC__
diff --git a/Utilities/SWIG/eigen.i b/Utilities/SWIG/eigen.i
index c05a1f1a..0e9de254 100644
--- a/Utilities/SWIG/eigen.i
+++ b/Utilities/SWIG/eigen.i
@@ -1,6 +1,6 @@
/*
* The Biomechanical ToolKit
- * Copyright (c) 2009-2013, Arnaud Barré
+ * Copyright (c) 2009-2014, Arnaud Barré
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
diff --git a/Utilities/eigen3/Eigen/Core b/Utilities/eigen3/Eigen/Core
index 9131cc3f..509c529e 100644
--- a/Utilities/eigen3/Eigen/Core
+++ b/Utilities/eigen3/Eigen/Core
@@ -95,7 +95,7 @@
extern "C" {
// In theory we should only include immintrin.h and not the other *mmintrin.h header files directly.
// Doing so triggers some issues with ICC. However old gcc versions seems to not have this file, thus:
- #ifdef __INTEL_COMPILER
+ #if defined(__INTEL_COMPILER) && __INTEL_COMPILER >= 1110
#include <immintrin.h>
#else
#include <emmintrin.h>
@@ -123,7 +123,7 @@
#undef bool
#undef vector
#undef pixel
- #elif defined __ARM_NEON__
+ #elif defined __ARM_NEON
#define EIGEN_VECTORIZE
#define EIGEN_VECTORIZE_NEON
#include <arm_neon.h>
@@ -165,7 +165,7 @@
#endif
// required for __cpuid, needs to be included after cmath
-#if defined(_MSC_VER) && (defined(_M_IX86)||defined(_M_X64))
+#if defined(_MSC_VER) && (defined(_M_IX86)||defined(_M_X64)) && (!defined(_WIN32_WCE))
#include <intrin.h>
#endif
diff --git a/Utilities/eigen3/Eigen/Eigen2Support b/Utilities/eigen3/Eigen/Eigen2Support
index 36156d29..6aa009d2 100644
--- a/Utilities/eigen3/Eigen/Eigen2Support
+++ b/Utilities/eigen3/Eigen/Eigen2Support
@@ -14,12 +14,25 @@
#error Eigen2 support must be enabled by defining EIGEN2_SUPPORT before including any Eigen header
#endif
+#ifndef EIGEN_NO_EIGEN2_DEPRECATED_WARNING
+
+#if defined(__GNUC__) || defined(__INTEL_COMPILER) || defined(__clang__)
+#warning "Eigen2 support is deprecated in Eigen 3.2.x and it will be removed in Eigen 3.3. (Define EIGEN_NO_EIGEN2_DEPRECATED_WARNING to disable this warning)"
+#else
+#pragma message ("Eigen2 support is deprecated in Eigen 3.2.x and it will be removed in Eigen 3.3. (Define EIGEN_NO_EIGEN2_DEPRECATED_WARNING to disable this warning)")
+#endif
+
+#endif // EIGEN_NO_EIGEN2_DEPRECATED_WARNING
+
#include "src/Core/util/DisableStupidWarnings.h"
/** \ingroup Support_modules
* \defgroup Eigen2Support_Module Eigen2 support module
- * This module provides a couple of deprecated functions improving the compatibility with Eigen2.
*
+ * \warning Eigen2 support is deprecated in Eigen 3.2.x and it will be removed in Eigen 3.3.
+ *
+ * This module provides a couple of deprecated functions improving the compatibility with Eigen2.
+ *
* To use it, define EIGEN2_SUPPORT before including any Eigen header
* \code
* #define EIGEN2_SUPPORT
diff --git a/Utilities/eigen3/Eigen/SparseCore b/Utilities/eigen3/Eigen/SparseCore
index 9b5be5e1..24bcf015 100644
--- a/Utilities/eigen3/Eigen/SparseCore
+++ b/Utilities/eigen3/Eigen/SparseCore
@@ -14,7 +14,7 @@
/**
* \defgroup SparseCore_Module SparseCore module
*
- * This module provides a sparse matrix representation, and basic associatd matrix manipulations
+ * This module provides a sparse matrix representation, and basic associated matrix manipulations
* and operations.
*
* See the \ref TutorialSparse "Sparse tutorial"
diff --git a/Utilities/eigen3/Eigen/src/Cholesky/LDLT.h b/Utilities/eigen3/Eigen/src/Cholesky/LDLT.h
index d19cb396..abd30bd9 100644
--- a/Utilities/eigen3/Eigen/src/Cholesky/LDLT.h
+++ b/Utilities/eigen3/Eigen/src/Cholesky/LDLT.h
@@ -16,7 +16,10 @@
namespace Eigen {
namespace internal {
-template<typename MatrixType, int UpLo> struct LDLT_Traits;
+ template<typename MatrixType, int UpLo> struct LDLT_Traits;
+
+ // PositiveSemiDef means positive semi-definite and non-zero; same for NegativeSemiDef
+ enum SignMatrix { PositiveSemiDef, NegativeSemiDef, ZeroSign, Indefinite };
}
/** \ingroup Cholesky_Module
@@ -69,7 +72,12 @@ template<typename _MatrixType, int _UpLo> class LDLT
* The default constructor is useful in cases in which the user intends to
* perform decompositions via LDLT::compute(const MatrixType&).
*/
- LDLT() : m_matrix(), m_transpositions(), m_isInitialized(false) {}
+ LDLT()
+ : m_matrix(),
+ m_transpositions(),
+ m_sign(internal::ZeroSign),
+ m_isInitialized(false)
+ {}
/** \brief Default Constructor with memory preallocation
*
@@ -81,6 +89,7 @@ template<typename _MatrixType, int _UpLo> class LDLT
: m_matrix(size, size),
m_transpositions(size),
m_temporary(size),
+ m_sign(internal::ZeroSign),
m_isInitialized(false)
{}
@@ -93,6 +102,7 @@ template<typename _MatrixType, int _UpLo> class LDLT
: m_matrix(matrix.rows(), matrix.cols()),
m_transpositions(matrix.rows()),
m_temporary(matrix.rows()),
+ m_sign(internal::ZeroSign),
m_isInitialized(false)
{
compute(matrix);
@@ -139,7 +149,7 @@ template<typename _MatrixType, int _UpLo> class LDLT
inline bool isPositive() const
{
eigen_assert(m_isInitialized && "LDLT is not initialized.");
- return m_sign == 1;
+ return m_sign == internal::PositiveSemiDef || m_sign == internal::ZeroSign;
}
#ifdef EIGEN2_SUPPORT
@@ -153,7 +163,7 @@ template<typename _MatrixType, int _UpLo> class LDLT
inline bool isNegative(void) const
{
eigen_assert(m_isInitialized && "LDLT is not initialized.");
- return m_sign == -1;
+ return m_sign == internal::NegativeSemiDef || m_sign == internal::ZeroSign;
}
/** \returns a solution x of \f$ A x = b \f$ using the current decomposition of A.
@@ -225,6 +235,11 @@ template<typename _MatrixType, int _UpLo> class LDLT
}
protected:
+
+ static void check_template_parameters()
+ {
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
+ }
/** \internal
* Used to compute and store the Cholesky decomposition A = L D L^* = U^* D U.
@@ -235,7 +250,7 @@ template<typename _MatrixType, int _UpLo> class LDLT
MatrixType m_matrix;
TranspositionType m_transpositions;
TmpMatrixType m_temporary;
- int m_sign;
+ internal::SignMatrix m_sign;
bool m_isInitialized;
};
@@ -246,7 +261,7 @@ template<int UpLo> struct ldlt_inplace;
template<> struct ldlt_inplace<Lower>
{
template<typename MatrixType, typename TranspositionType, typename Workspace>
- static bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp, int* sign=0)
+ static bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp, SignMatrix& sign)
{
using std::abs;
typedef typename MatrixType::Scalar Scalar;
@@ -258,36 +273,19 @@ template<> struct ldlt_inplace<Lower>
if (size <= 1)
{
transpositions.setIdentity();
- if(sign)
- *sign = numext::real(mat.coeff(0,0))>0 ? 1:-1;
+ if (numext::real(mat.coeff(0,0)) > 0) sign = PositiveSemiDef;
+ else if (numext::real(mat.coeff(0,0)) < 0) sign = NegativeSemiDef;
+ else sign = ZeroSign;
return true;
}
- RealScalar cutoff(0), biggest_in_corner;
-
for (Index k = 0; k < size; ++k)
{
// Find largest diagonal element
Index index_of_biggest_in_corner;
- biggest_in_corner = mat.diagonal().tail(size-k).cwiseAbs().maxCoeff(&index_of_biggest_in_corner);
+ mat.diagonal().tail(size-k).cwiseAbs().maxCoeff(&index_of_biggest_in_corner);
index_of_biggest_in_corner += k;
- if(k == 0)
- {
- // The biggest overall is the point of reference to which further diagonals
- // are compared; if any diagonal is negligible compared
- // to the largest overall, the algorithm bails.
- cutoff = abs(NumTraits<Scalar>::epsilon() * biggest_in_corner);
- }
-
- // Finish early if the matrix is not full rank.
- if(biggest_in_corner < cutoff)
- {
- for(Index i = k; i < size; i++) transpositions.coeffRef(i) = i;
- if(sign) *sign = 0;
- break;
- }
-
transpositions.coeffRef(k) = index_of_biggest_in_corner;
if(k != index_of_biggest_in_corner)
{
@@ -318,22 +316,27 @@ template<> struct ldlt_inplace<Lower>
if(k>0)
{
- temp.head(k) = mat.diagonal().head(k).asDiagonal() * A10.adjoint();
+ temp.head(k) = mat.diagonal().real().head(k).asDiagonal() * A10.adjoint();
mat.coeffRef(k,k) -= (A10 * temp.head(k)).value();
if(rs>0)
A21.noalias() -= A20 * temp.head(k);
}
- if((rs>0) && (abs(mat.coeffRef(k,k)) > cutoff))
- A21 /= mat.coeffRef(k,k);
- if(sign)
- {
- // LDLT is not guaranteed to work for indefinite matrices, but let's try to get the sign right
- int newSign = numext::real(mat.diagonal().coeff(index_of_biggest_in_corner)) > 0;
- if(k == 0)
- *sign = newSign;
- else if(*sign != newSign)
- *sign = 0;
+ // In some previous versions of Eigen (e.g., 3.2.1), the scaling was omitted if the pivot
+ // was smaller than the cutoff value. However, soince LDLT is not rank-revealing
+ // we should only make sure we do not introduce INF or NaN values.
+ // LAPACK also uses 0 as the cutoff value.
+ RealScalar realAkk = numext::real(mat.coeffRef(k,k));
+ if((rs>0) && (abs(realAkk) > RealScalar(0)))
+ A21 /= realAkk;
+
+ if (sign == PositiveSemiDef) {
+ if (realAkk < 0) sign = Indefinite;
+ } else if (sign == NegativeSemiDef) {
+ if (realAkk > 0) sign = Indefinite;
+ } else if (sign == ZeroSign) {
+ if (realAkk > 0) sign = PositiveSemiDef;
+ else if (realAkk < 0) sign = NegativeSemiDef;
}
}
@@ -399,7 +402,7 @@ template<> struct ldlt_inplace<Lower>
template<> struct ldlt_inplace<Upper>
{
template<typename MatrixType, typename TranspositionType, typename Workspace>
- static EIGEN_STRONG_INLINE bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp, int* sign=0)
+ static EIGEN_STRONG_INLINE bool unblocked(MatrixType& mat, TranspositionType& transpositions, Workspace& temp, SignMatrix& sign)
{
Transpose<MatrixType> matt(mat);
return ldlt_inplace<Lower>::unblocked(matt, transpositions, temp, sign);
@@ -436,6 +439,8 @@ template<typename MatrixType> struct LDLT_Traits<MatrixType,Upper>
template<typename MatrixType, int _UpLo>
LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::compute(const MatrixType& a)
{
+ check_template_parameters();
+
eigen_assert(a.rows()==a.cols());
const Index size = a.rows();
@@ -444,8 +449,9 @@ LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::compute(const MatrixType& a)
m_transpositions.resize(size);
m_isInitialized = false;
m_temporary.resize(size);
+ m_sign = internal::ZeroSign;
- internal::ldlt_inplace<UpLo>::unblocked(m_matrix, m_transpositions, m_temporary, &m_sign);
+ internal::ldlt_inplace<UpLo>::unblocked(m_matrix, m_transpositions, m_temporary, m_sign);
m_isInitialized = true;
return *this;
@@ -458,7 +464,7 @@ LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::compute(const MatrixType& a)
*/
template<typename MatrixType, int _UpLo>
template<typename Derived>
-LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::rankUpdate(const MatrixBase<Derived>& w, const typename NumTraits<typename MatrixType::Scalar>::Real& sigma)
+LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::rankUpdate(const MatrixBase<Derived>& w, const typename LDLT<MatrixType,_UpLo>::RealScalar& sigma)
{
const Index size = w.rows();
if (m_isInitialized)
@@ -473,7 +479,7 @@ LDLT<MatrixType,_UpLo>& LDLT<MatrixType,_UpLo>::rankUpdate(const MatrixBase<Deri
for (Index i = 0; i < size; i++)
m_transpositions.coeffRef(i) = i;
m_temporary.resize(size);
- m_sign = sigma>=0 ? 1 : -1;
+ m_sign = sigma>=0 ? internal::PositiveSemiDef : internal::NegativeSemiDef;
m_isInitialized = true;
}
@@ -504,16 +510,21 @@ struct solve_retval<LDLT<_MatrixType,_UpLo>, Rhs>
using std::abs;
using std::max;
typedef typename LDLTType::MatrixType MatrixType;
- typedef typename LDLTType::Scalar Scalar;
typedef typename LDLTType::RealScalar RealScalar;
- const Diagonal<const MatrixType> vectorD = dec().vectorD();
- RealScalar tolerance = (max)(vectorD.array().abs().maxCoeff() * NumTraits<Scalar>::epsilon(),
- RealScalar(1) / NumTraits<RealScalar>::highest()); // motivated by LAPACK's xGELSS
+ const typename Diagonal<const MatrixType>::RealReturnType vectorD(dec().vectorD());
+ // In some previous versions, tolerance was set to the max of 1/highest and the maximal diagonal entry * epsilon
+ // as motivated by LAPACK's xGELSS:
+ // RealScalar tolerance = (max)(vectorD.array().abs().maxCoeff() *NumTraits<RealScalar>::epsilon(),RealScalar(1) / NumTraits<RealScalar>::highest());
+ // However, LDLT is not rank revealing, and so adjusting the tolerance wrt to the highest
+ // diagonal element is not well justified and to numerical issues in some cases.
+ // Moreover, Lapack's xSYTRS routines use 0 for the tolerance.
+ RealScalar tolerance = RealScalar(1) / NumTraits<RealScalar>::highest();
+
for (Index i = 0; i < vectorD.size(); ++i) {
if(abs(vectorD(i)) > tolerance)
- dst.row(i) /= vectorD(i);
+ dst.row(i) /= vectorD(i);
else
- dst.row(i).setZero();
+ dst.row(i).setZero();
}
// dst = L^-T (D^-1 L^-1 P b)
@@ -566,7 +577,7 @@ MatrixType LDLT<MatrixType,_UpLo>::reconstructedMatrix() const
// L^* P
res = matrixU() * res;
// D(L^*P)
- res = vectorD().asDiagonal() * res;
+ res = vectorD().real().asDiagonal() * res;
// L(DL^*P)
res = matrixL() * res;
// P^T (LDL^*P)
diff --git a/Utilities/eigen3/Eigen/src/Cholesky/LLT.h b/Utilities/eigen3/Eigen/src/Cholesky/LLT.h
index 2e6189f7..7c11a2dc 100644
--- a/Utilities/eigen3/Eigen/src/Cholesky/LLT.h
+++ b/Utilities/eigen3/Eigen/src/Cholesky/LLT.h
@@ -174,6 +174,12 @@ template<typename _MatrixType, int _UpLo> class LLT
LLT rankUpdate(const VectorType& vec, const RealScalar& sigma = 1);
protected:
+
+ static void check_template_parameters()
+ {
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
+ }
+
/** \internal
* Used to compute and store L
* The strict upper part is not used and even not initialized.
@@ -283,7 +289,7 @@ template<typename Scalar> struct llt_inplace<Scalar, Lower>
return k;
mat.coeffRef(k,k) = x = sqrt(x);
if (k>0 && rs>0) A21.noalias() -= A20 * A10.adjoint();
- if (rs>0) A21 *= RealScalar(1)/x;
+ if (rs>0) A21 /= x;
}
return -1;
}
@@ -384,6 +390,8 @@ template<typename MatrixType> struct LLT_Traits<MatrixType,Upper>
template<typename MatrixType, int _UpLo>
LLT<MatrixType,_UpLo>& LLT<MatrixType,_UpLo>::compute(const MatrixType& a)
{
+ check_template_parameters();
+
eigen_assert(a.rows()==a.cols());
const Index size = a.rows();
m_matrix.resize(size, size);
diff --git a/Utilities/eigen3/Eigen/src/Cholesky/LLT_MKL.h b/Utilities/eigen3/Eigen/src/Cholesky/LLT_MKL.h
index 64daa445..66675d74 100644
--- a/Utilities/eigen3/Eigen/src/Cholesky/LLT_MKL.h
+++ b/Utilities/eigen3/Eigen/src/Cholesky/LLT_MKL.h
@@ -60,7 +60,7 @@ template<> struct mkl_llt<EIGTYPE> \
lda = m.outerStride(); \
\
info = LAPACKE_##MKLPREFIX##potrf( matrix_order, uplo, size, (MKLTYPE*)a, lda ); \
- info = (info==0) ? Success : NumericalIssue; \
+ info = (info==0) ? -1 : info>0 ? info-1 : size; \
return info; \
} \
}; \
diff --git a/Utilities/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h b/Utilities/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h
index 783324b0..99dbe171 100644
--- a/Utilities/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h
+++ b/Utilities/eigen3/Eigen/src/CholmodSupport/CholmodSupport.h
@@ -58,10 +58,12 @@ cholmod_sparse viewAsCholmod(SparseMatrix<_Scalar,_Options,_Index>& mat)
res.p = mat.outerIndexPtr();
res.i = mat.innerIndexPtr();
res.x = mat.valuePtr();
+ res.z = 0;
res.sorted = 1;
if(mat.isCompressed())
{
res.packed = 1;
+ res.nz = 0;
}
else
{
@@ -76,7 +78,7 @@ cholmod_sparse viewAsCholmod(SparseMatrix<_Scalar,_Options,_Index>& mat)
{
res.itype = CHOLMOD_INT;
}
- else if (internal::is_same<_Index,UF_long>::value)
+ else if (internal::is_same<_Index,SuiteSparse_long>::value)
{
res.itype = CHOLMOD_LONG;
}
@@ -170,6 +172,7 @@ class CholmodBase : internal::noncopyable
CholmodBase()
: m_cholmodFactor(0), m_info(Success), m_isInitialized(false)
{
+ m_shiftOffset[0] = m_shiftOffset[1] = RealScalar(0.0);
cholmod_start(&m_cholmod);
}
@@ -241,7 +244,7 @@ class CholmodBase : internal::noncopyable
return internal::sparse_solve_retval<CholmodBase, Rhs>(*this, b.derived());
}
- /** Performs a symbolic decomposition on the sparcity of \a matrix.
+ /** Performs a symbolic decomposition on the sparsity pattern of \a matrix.
*
* This function is particularly useful when solving for several problems having the same structure.
*
@@ -265,7 +268,7 @@ class CholmodBase : internal::noncopyable
/** Performs a numeric decomposition of \a matrix
*
- * The given matrix must has the same sparcity than the matrix on which the symbolic decomposition has been performed.
+ * The given matrix must have the same sparsity pattern as the matrix on which the symbolic decomposition has been performed.
*
* \sa analyzePattern()
*/
@@ -302,7 +305,7 @@ class CholmodBase : internal::noncopyable
{
this->m_info = NumericalIssue;
}
- // TODO optimize this copy by swapping when possible (be carreful with alignment, etc.)
+ // TODO optimize this copy by swapping when possible (be careful with alignment, etc.)
dest = Matrix<Scalar,Dest::RowsAtCompileTime,Dest::ColsAtCompileTime>::Map(reinterpret_cast<Scalar*>(x_cd->x),b.rows(),b.cols());
cholmod_free_dense(&x_cd, &m_cholmod);
}
@@ -323,7 +326,7 @@ class CholmodBase : internal::noncopyable
{
this->m_info = NumericalIssue;
}
- // TODO optimize this copy by swapping when possible (be carreful with alignment, etc.)
+ // TODO optimize this copy by swapping when possible (be careful with alignment, etc.)
dest = viewAsEigen<DestScalar,DestOptions,DestIndex>(*x_cs);
cholmod_free_sparse(&x_cs, &m_cholmod);
}
@@ -365,8 +368,8 @@ class CholmodBase : internal::noncopyable
*
* This class allows to solve for A.X = B sparse linear problems via a simplicial LL^T Cholesky factorization
* using the Cholmod library.
- * This simplicial variant is equivalent to Eigen's built-in SimplicialLLT class. Thefore, it has little practical interest.
- * The sparse matrix A must be selfajoint and positive definite. The vectors or matrices
+ * This simplicial variant is equivalent to Eigen's built-in SimplicialLLT class. Therefore, it has little practical interest.
+ * The sparse matrix A must be selfadjoint and positive definite. The vectors or matrices
* X and B can be either dense or sparse.
*
* \tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>
@@ -392,7 +395,7 @@ class CholmodSimplicialLLT : public CholmodBase<_MatrixType, _UpLo, CholmodSimpl
CholmodSimplicialLLT(const MatrixType& matrix) : Base()
{
init();
- compute(matrix);
+ Base::compute(matrix);
}
~CholmodSimplicialLLT() {}
@@ -412,8 +415,8 @@ class CholmodSimplicialLLT : public CholmodBase<_MatrixType, _UpLo, CholmodSimpl
*
* This class allows to solve for A.X = B sparse linear problems via a simplicial LDL^T Cholesky factorization
* using the Cholmod library.
- * This simplicial variant is equivalent to Eigen's built-in SimplicialLDLT class. Thefore, it has little practical interest.
- * The sparse matrix A must be selfajoint and positive definite. The vectors or matrices
+ * This simplicial variant is equivalent to Eigen's built-in SimplicialLDLT class. Therefore, it has little practical interest.
+ * The sparse matrix A must be selfadjoint and positive definite. The vectors or matrices
* X and B can be either dense or sparse.
*
* \tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>
@@ -439,7 +442,7 @@ class CholmodSimplicialLDLT : public CholmodBase<_MatrixType, _UpLo, CholmodSimp
CholmodSimplicialLDLT(const MatrixType& matrix) : Base()
{
init();
- compute(matrix);
+ Base::compute(matrix);
}
~CholmodSimplicialLDLT() {}
@@ -458,7 +461,7 @@ class CholmodSimplicialLDLT : public CholmodBase<_MatrixType, _UpLo, CholmodSimp
* This class allows to solve for A.X = B sparse linear problems via a supernodal LL^T Cholesky factorization
* using the Cholmod library.
* This supernodal variant performs best on dense enough problems, e.g., 3D FEM, or very high order 2D FEM.
- * The sparse matrix A must be selfajoint and positive definite. The vectors or matrices
+ * The sparse matrix A must be selfadjoint and positive definite. The vectors or matrices
* X and B can be either dense or sparse.
*
* \tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>
@@ -484,7 +487,7 @@ class CholmodSupernodalLLT : public CholmodBase<_MatrixType, _UpLo, CholmodSuper
CholmodSupernodalLLT(const MatrixType& matrix) : Base()
{
init();
- compute(matrix);
+ Base::compute(matrix);
}
~CholmodSupernodalLLT() {}
@@ -501,7 +504,7 @@ class CholmodSupernodalLLT : public CholmodBase<_MatrixType, _UpLo, CholmodSuper
* \brief A general Cholesky factorization and solver based on Cholmod
*
* This class allows to solve for A.X = B sparse linear problems via a LL^T or LDL^T Cholesky factorization
- * using the Cholmod library. The sparse matrix A must be selfajoint and positive definite. The vectors or matrices
+ * using the Cholmod library. The sparse matrix A must be selfadjoint and positive definite. The vectors or matrices
* X and B can be either dense or sparse.
*
* This variant permits to change the underlying Cholesky method at runtime.
@@ -531,7 +534,7 @@ class CholmodDecomposition : public CholmodBase<_MatrixType, _UpLo, CholmodDecom
CholmodDecomposition(const MatrixType& matrix) : Base()
{
init();
- compute(matrix);
+ Base::compute(matrix);
}
~CholmodDecomposition() {}
diff --git a/Utilities/eigen3/Eigen/src/Core/Array.h b/Utilities/eigen3/Eigen/src/Core/Array.h
index 497efff6..0b9c38c8 100644
--- a/Utilities/eigen3/Eigen/src/Core/Array.h
+++ b/Utilities/eigen3/Eigen/src/Core/Array.h
@@ -124,6 +124,21 @@ class Array
}
#endif
+#ifdef EIGEN_HAVE_RVALUE_REFERENCES
+ Array(Array&& other)
+ : Base(std::move(other))
+ {
+ Base::_check_template_params();
+ if (RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic)
+ Base::_set_noalias(other);
+ }
+ Array& operator=(Array&& other)
+ {
+ other.swap(*this);
+ return *this;
+ }
+#endif
+
/** Constructs a vector or row-vector with given dimension. \only_for_vectors
*
* Note that this is only useful for dynamic-size vectors. For fixed-size vectors,
@@ -210,7 +225,7 @@ class Array
: Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols())
{
Base::_check_template_params();
- Base::resize(other.rows(), other.cols());
+ Base::_resize_to_match(other);
*this = other;
}
diff --git a/Utilities/eigen3/Eigen/src/Core/ArrayBase.h b/Utilities/eigen3/Eigen/src/Core/ArrayBase.h
index 38852600..33ff5537 100644
--- a/Utilities/eigen3/Eigen/src/Core/ArrayBase.h
+++ b/Utilities/eigen3/Eigen/src/Core/ArrayBase.h
@@ -46,9 +46,6 @@ template<typename Derived> class ArrayBase
typedef ArrayBase Eigen_BaseClassForSpecializationOfGlobalMathFuncImpl;
- using internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar,
- typename NumTraits<typename internal::traits<Derived>::Scalar>::Real>::operator*;
-
typedef typename internal::traits<Derived>::StorageKind StorageKind;
typedef typename internal::traits<Derived>::Index Index;
typedef typename internal::traits<Derived>::Scalar Scalar;
@@ -56,6 +53,7 @@ template<typename Derived> class ArrayBase
typedef typename NumTraits<Scalar>::Real RealScalar;
typedef DenseBase<Derived> Base;
+ using Base::operator*;
using Base::RowsAtCompileTime;
using Base::ColsAtCompileTime;
using Base::SizeAtCompileTime;
diff --git a/Utilities/eigen3/Eigen/src/Core/ArrayWrapper.h b/Utilities/eigen3/Eigen/src/Core/ArrayWrapper.h
index a791bc35..b4641e2a 100644
--- a/Utilities/eigen3/Eigen/src/Core/ArrayWrapper.h
+++ b/Utilities/eigen3/Eigen/src/Core/ArrayWrapper.h
@@ -29,6 +29,11 @@ struct traits<ArrayWrapper<ExpressionType> >
: public traits<typename remove_all<typename ExpressionType::Nested>::type >
{
typedef ArrayXpr XprKind;
+ // Let's remove NestByRefBit
+ enum {
+ Flags0 = traits<typename remove_all<typename ExpressionType::Nested>::type >::Flags,
+ Flags = Flags0 & ~NestByRefBit
+ };
};
}
@@ -149,6 +154,11 @@ struct traits<MatrixWrapper<ExpressionType> >
: public traits<typename remove_all<typename ExpressionType::Nested>::type >
{
typedef MatrixXpr XprKind;
+ // Let's remove NestByRefBit
+ enum {
+ Flags0 = traits<typename remove_all<typename ExpressionType::Nested>::type >::Flags,
+ Flags = Flags0 & ~NestByRefBit
+ };
};
}
diff --git a/Utilities/eigen3/Eigen/src/Core/Assign.h b/Utilities/eigen3/Eigen/src/Core/Assign.h
index 1dccc2f4..f4817317 100644
--- a/Utilities/eigen3/Eigen/src/Core/Assign.h
+++ b/Utilities/eigen3/Eigen/src/Core/Assign.h
@@ -439,19 +439,26 @@ struct assign_impl<Derived1, Derived2, SliceVectorizedTraversal, NoUnrolling, Ve
typedef typename Derived1::Index Index;
static inline void run(Derived1 &dst, const Derived2 &src)
{
- typedef packet_traits<typename Derived1::Scalar> PacketTraits;
+ typedef typename Derived1::Scalar Scalar;
+ typedef packet_traits<Scalar> PacketTraits;
enum {
packetSize = PacketTraits::size,
alignable = PacketTraits::AlignedOnScalar,
- dstAlignment = alignable ? Aligned : int(assign_traits<Derived1,Derived2>::DstIsAligned) ,
+ dstIsAligned = assign_traits<Derived1,Derived2>::DstIsAligned,
+ dstAlignment = alignable ? Aligned : int(dstIsAligned),
srcAlignment = assign_traits<Derived1,Derived2>::JointAlignment
};
+ const Scalar *dst_ptr = &dst.coeffRef(0,0);
+ if((!bool(dstIsAligned)) && (size_t(dst_ptr) % sizeof(Scalar))>0)
+ {
+ // the pointer is not aligend-on scalar, so alignment is not possible
+ return assign_impl<Derived1,Derived2,DefaultTraversal,NoUnrolling>::run(dst, src);
+ }
const Index packetAlignedMask = packetSize - 1;
const Index innerSize = dst.innerSize();
const Index outerSize = dst.outerSize();
const Index alignedStep = alignable ? (packetSize - dst.outerStride() % packetSize) & packetAlignedMask : 0;
- Index alignedStart = ((!alignable) || assign_traits<Derived1,Derived2>::DstIsAligned) ? 0
- : internal::first_aligned(&dst.coeffRef(0,0), innerSize);
+ Index alignedStart = ((!alignable) || bool(dstIsAligned)) ? 0 : internal::first_aligned(dst_ptr, innerSize);
for(Index outer = 0; outer < outerSize; ++outer)
{
diff --git a/Utilities/eigen3/Eigen/src/Core/Block.h b/Utilities/eigen3/Eigen/src/Core/Block.h
index 358b3188..82789444 100644
--- a/Utilities/eigen3/Eigen/src/Core/Block.h
+++ b/Utilities/eigen3/Eigen/src/Core/Block.h
@@ -66,8 +66,9 @@ struct traits<Block<XprType, BlockRows, BlockCols, InnerPanel> > : traits<XprTyp
: ColsAtCompileTime != Dynamic ? int(ColsAtCompileTime)
: int(traits<XprType>::MaxColsAtCompileTime),
XprTypeIsRowMajor = (int(traits<XprType>::Flags)&RowMajorBit) != 0,
- IsRowMajor = (MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1
- : (MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0
+ IsDense = is_same<StorageKind,Dense>::value,
+ IsRowMajor = (IsDense&&MaxRowsAtCompileTime==1&&MaxColsAtCompileTime!=1) ? 1
+ : (IsDense&&MaxColsAtCompileTime==1&&MaxRowsAtCompileTime!=1) ? 0
: XprTypeIsRowMajor,
HasSameStorageOrderAsXprType = (IsRowMajor == XprTypeIsRowMajor),
InnerSize = IsRowMajor ? int(ColsAtCompileTime) : int(RowsAtCompileTime),
@@ -81,7 +82,7 @@ struct traits<Block<XprType, BlockRows, BlockCols, InnerPanel> > : traits<XprTyp
&& (InnerStrideAtCompileTime == 1)
? PacketAccessBit : 0,
MaskAlignedBit = (InnerPanel && (OuterStrideAtCompileTime!=Dynamic) && (((OuterStrideAtCompileTime * int(sizeof(Scalar))) % 16) == 0)) ? AlignedBit : 0,
- FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1) ? LinearAccessBit : 0,
+ FlagsLinearAccessBit = (RowsAtCompileTime == 1 || ColsAtCompileTime == 1 || (InnerPanel && (traits<XprType>::Flags&LinearAccessBit))) ? LinearAccessBit : 0,
FlagsLvalueBit = is_lvalue<XprType>::value ? LvalueBit : 0,
FlagsRowMajorBit = IsRowMajor ? RowMajorBit : 0,
Flags0 = traits<XprType>::Flags & ( (HereditaryBits & ~RowMajorBit) |
diff --git a/Utilities/eigen3/Eigen/src/Core/BooleanRedux.h b/Utilities/eigen3/Eigen/src/Core/BooleanRedux.h
index 6e37e031..be9f48a8 100644
--- a/Utilities/eigen3/Eigen/src/Core/BooleanRedux.h
+++ b/Utilities/eigen3/Eigen/src/Core/BooleanRedux.h
@@ -29,9 +29,9 @@ struct all_unroller
};
template<typename Derived>
-struct all_unroller<Derived, 1>
+struct all_unroller<Derived, 0>
{
- static inline bool run(const Derived &mat) { return mat.coeff(0, 0); }
+ static inline bool run(const Derived &/*mat*/) { return true; }
};
template<typename Derived>
@@ -55,9 +55,9 @@ struct any_unroller
};
template<typename Derived>
-struct any_unroller<Derived, 1>
+struct any_unroller<Derived, 0>
{
- static inline bool run(const Derived &mat) { return mat.coeff(0, 0); }
+ static inline bool run(const Derived & /*mat*/) { return false; }
};
template<typename Derived>
diff --git a/Utilities/eigen3/Eigen/src/Core/CommaInitializer.h b/Utilities/eigen3/Eigen/src/Core/CommaInitializer.h
index a96867af..a036d8c3 100644
--- a/Utilities/eigen3/Eigen/src/Core/CommaInitializer.h
+++ b/Utilities/eigen3/Eigen/src/Core/CommaInitializer.h
@@ -43,6 +43,17 @@ struct CommaInitializer
m_xpr.block(0, 0, other.rows(), other.cols()) = other;
}
+ /* Copy/Move constructor which transfers ownership. This is crucial in
+ * absence of return value optimization to avoid assertions during destruction. */
+ // FIXME in C++11 mode this could be replaced by a proper RValue constructor
+ inline CommaInitializer(const CommaInitializer& o)
+ : m_xpr(o.m_xpr), m_row(o.m_row), m_col(o.m_col), m_currentBlockRows(o.m_currentBlockRows) {
+ // Mark original object as finished. In absence of R-value references we need to const_cast:
+ const_cast<CommaInitializer&>(o).m_row = m_xpr.rows();
+ const_cast<CommaInitializer&>(o).m_col = m_xpr.cols();
+ const_cast<CommaInitializer&>(o).m_currentBlockRows = 0;
+ }
+
/* inserts a scalar value in the target matrix */
CommaInitializer& operator,(const Scalar& s)
{
diff --git a/Utilities/eigen3/Eigen/src/Core/CwiseBinaryOp.h b/Utilities/eigen3/Eigen/src/Core/CwiseBinaryOp.h
index 586f77aa..519a866e 100644
--- a/Utilities/eigen3/Eigen/src/Core/CwiseBinaryOp.h
+++ b/Utilities/eigen3/Eigen/src/Core/CwiseBinaryOp.h
@@ -81,7 +81,8 @@ struct traits<CwiseBinaryOp<BinaryOp, Lhs, Rhs> >
)
),
Flags = (Flags0 & ~RowMajorBit) | (LhsFlags & RowMajorBit),
- CoeffReadCost = LhsCoeffReadCost + RhsCoeffReadCost + functor_traits<BinaryOp>::Cost
+ Cost0 = EIGEN_ADD_COST(LhsCoeffReadCost,RhsCoeffReadCost),
+ CoeffReadCost = EIGEN_ADD_COST(Cost0,functor_traits<BinaryOp>::Cost)
};
};
} // end namespace internal
diff --git a/Utilities/eigen3/Eigen/src/Core/CwiseUnaryOp.h b/Utilities/eigen3/Eigen/src/Core/CwiseUnaryOp.h
index f2de749f..f7ee60e9 100644
--- a/Utilities/eigen3/Eigen/src/Core/CwiseUnaryOp.h
+++ b/Utilities/eigen3/Eigen/src/Core/CwiseUnaryOp.h
@@ -47,7 +47,7 @@ struct traits<CwiseUnaryOp<UnaryOp, XprType> >
Flags = _XprTypeNested::Flags & (
HereditaryBits | LinearAccessBit | AlignedBit
| (functor_traits<UnaryOp>::PacketAccess ? PacketAccessBit : 0)),
- CoeffReadCost = _XprTypeNested::CoeffReadCost + functor_traits<UnaryOp>::Cost
+ CoeffReadCost = EIGEN_ADD_COST(_XprTypeNested::CoeffReadCost, functor_traits<UnaryOp>::Cost)
};
};
}
diff --git a/Utilities/eigen3/Eigen/src/Core/DenseBase.h b/Utilities/eigen3/Eigen/src/Core/DenseBase.h
index c5800f6c..4b371b07 100644
--- a/Utilities/eigen3/Eigen/src/Core/DenseBase.h
+++ b/Utilities/eigen3/Eigen/src/Core/DenseBase.h
@@ -40,15 +40,14 @@ static inline void check_DenseIndex_is_signed() {
*/
template<typename Derived> class DenseBase
#ifndef EIGEN_PARSED_BY_DOXYGEN
- : public internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar,
- typename NumTraits<typename internal::traits<Derived>::Scalar>::Real>
+ : public internal::special_scalar_op_base<Derived, typename internal::traits<Derived>::Scalar,
+ typename NumTraits<typename internal::traits<Derived>::Scalar>::Real,
+ DenseCoeffsBase<Derived> >
#else
: public DenseCoeffsBase<Derived>
#endif // not EIGEN_PARSED_BY_DOXYGEN
{
public:
- using internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar,
- typename NumTraits<typename internal::traits<Derived>::Scalar>::Real>::operator*;
class InnerIterator;
@@ -63,8 +62,9 @@ template<typename Derived> class DenseBase
typedef typename internal::traits<Derived>::Scalar Scalar;
typedef typename internal::packet_traits<Scalar>::type PacketScalar;
typedef typename NumTraits<Scalar>::Real RealScalar;
+ typedef internal::special_scalar_op_base<Derived,Scalar,RealScalar, DenseCoeffsBase<Derived> > Base;
- typedef DenseCoeffsBase<Derived> Base;
+ using Base::operator*;
using Base::derived;
using Base::const_cast_derived;
using Base::rows;
@@ -183,10 +183,6 @@ template<typename Derived> class DenseBase
/** \returns the number of nonzero coefficients which is in practice the number
* of stored coefficients. */
inline Index nonZeros() const { return size(); }
- /** \returns true if either the number of rows or the number of columns is equal to 1.
- * In other words, this function returns
- * \code rows()==1 || cols()==1 \endcode
- * \sa rows(), cols(), IsVectorAtCompileTime. */
/** \returns the outer size.
*
@@ -266,11 +262,13 @@ template<typename Derived> class DenseBase
template<typename OtherDerived>
Derived& operator=(const ReturnByValue<OtherDerived>& func);
-#ifndef EIGEN_PARSED_BY_DOXYGEN
- /** Copies \a other into *this without evaluating other. \returns a reference to *this. */
+ /** \internal Copies \a other into *this without evaluating other. \returns a reference to *this. */
template<typename OtherDerived>
Derived& lazyAssign(const DenseBase<OtherDerived>& other);
-#endif // not EIGEN_PARSED_BY_DOXYGEN
+
+ /** \internal Evaluates \a other into *this. \returns a reference to *this. */
+ template<typename OtherDerived>
+ Derived& lazyAssign(const ReturnByValue<OtherDerived>& other);
CommaInitializer<Derived> operator<< (const Scalar& s);
@@ -462,8 +460,10 @@ template<typename Derived> class DenseBase
template<int p> RealScalar lpNorm() const;
template<int RowFactor, int ColFactor>
- const Replicate<Derived,RowFactor,ColFactor> replicate() const;
- const Replicate<Derived,Dynamic,Dynamic> replicate(Index rowFacor,Index colFactor) const;
+ inline const Replicate<Derived,RowFactor,ColFactor> replicate() const;
+
+ typedef Replicate<Derived,Dynamic,Dynamic> ReplicateReturnType;
+ inline const ReplicateReturnType replicate(Index rowFacor,Index colFactor) const;
typedef Reverse<Derived, BothDirections> ReverseReturnType;
typedef const Reverse<const Derived, BothDirections> ConstReverseReturnType;
diff --git a/Utilities/eigen3/Eigen/src/Core/DenseStorage.h b/Utilities/eigen3/Eigen/src/Core/DenseStorage.h
index 3e7f9c1b..568493cb 100644
--- a/Utilities/eigen3/Eigen/src/Core/DenseStorage.h
+++ b/Utilities/eigen3/Eigen/src/Core/DenseStorage.h
@@ -24,6 +24,14 @@ namespace internal {
struct constructor_without_unaligned_array_assert {};
+template<typename T, int Size> void check_static_allocation_size()
+{
+ // if EIGEN_STACK_ALLOCATION_LIMIT is defined to 0, then no limit
+ #if EIGEN_STACK_ALLOCATION_LIMIT
+ EIGEN_STATIC_ASSERT(Size * sizeof(T) <= EIGEN_STACK_ALLOCATION_LIMIT, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
+ #endif
+}
+
/** \internal
* Static array. If the MatrixOrArrayOptions require auto-alignment, the array will be automatically aligned:
* to 16 bytes boundary if the total size is a multiple of 16 bytes.
@@ -38,12 +46,12 @@ struct plain_array
plain_array()
{
- EIGEN_STATIC_ASSERT(Size * sizeof(T) <= 128 * 128 * 8, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
+ check_static_allocation_size<T,Size>();
}
plain_array(constructor_without_unaligned_array_assert)
{
- EIGEN_STATIC_ASSERT(Size * sizeof(T) <= 128 * 128 * 8, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
+ check_static_allocation_size<T,Size>();
}
};
@@ -76,12 +84,12 @@ struct plain_array<T, Size, MatrixOrArrayOptions, 16>
plain_array()
{
EIGEN_MAKE_UNALIGNED_ARRAY_ASSERT(0xf);
- EIGEN_STATIC_ASSERT(Size * sizeof(T) <= 128 * 128 * 8, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
+ check_static_allocation_size<T,Size>();
}
plain_array(constructor_without_unaligned_array_assert)
{
- EIGEN_STATIC_ASSERT(Size * sizeof(T) <= 128 * 128 * 8, OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG);
+ check_static_allocation_size<T,Size>();
}
};
@@ -114,33 +122,41 @@ template<typename T, int Size, int _Rows, int _Cols, int _Options> class DenseSt
{
internal::plain_array<T,Size,_Options> m_data;
public:
- inline DenseStorage() {}
- inline DenseStorage(internal::constructor_without_unaligned_array_assert)
+ DenseStorage() {}
+ DenseStorage(internal::constructor_without_unaligned_array_assert)
: m_data(internal::constructor_without_unaligned_array_assert()) {}
- inline DenseStorage(DenseIndex,DenseIndex,DenseIndex) {}
- inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); }
- static inline DenseIndex rows(void) {return _Rows;}
- static inline DenseIndex cols(void) {return _Cols;}
- inline void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {}
- inline void resize(DenseIndex,DenseIndex,DenseIndex) {}
- inline const T *data() const { return m_data.array; }
- inline T *data() { return m_data.array; }
+ DenseStorage(const DenseStorage& other) : m_data(other.m_data) {}
+ DenseStorage& operator=(const DenseStorage& other)
+ {
+ if (this != &other) m_data = other.m_data;
+ return *this;
+ }
+ DenseStorage(DenseIndex,DenseIndex,DenseIndex) {}
+ void swap(DenseStorage& other) { std::swap(m_data,other.m_data); }
+ static DenseIndex rows(void) {return _Rows;}
+ static DenseIndex cols(void) {return _Cols;}
+ void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {}
+ void resize(DenseIndex,DenseIndex,DenseIndex) {}
+ const T *data() const { return m_data.array; }
+ T *data() { return m_data.array; }
};
// null matrix
template<typename T, int _Rows, int _Cols, int _Options> class DenseStorage<T, 0, _Rows, _Cols, _Options>
{
public:
- inline DenseStorage() {}
- inline DenseStorage(internal::constructor_without_unaligned_array_assert) {}
- inline DenseStorage(DenseIndex,DenseIndex,DenseIndex) {}
- inline void swap(DenseStorage& ) {}
- static inline DenseIndex rows(void) {return _Rows;}
- static inline DenseIndex cols(void) {return _Cols;}
- inline void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {}
- inline void resize(DenseIndex,DenseIndex,DenseIndex) {}
- inline const T *data() const { return 0; }
- inline T *data() { return 0; }
+ DenseStorage() {}
+ DenseStorage(internal::constructor_without_unaligned_array_assert) {}
+ DenseStorage(const DenseStorage&) {}
+ DenseStorage& operator=(const DenseStorage&) { return *this; }
+ DenseStorage(DenseIndex,DenseIndex,DenseIndex) {}
+ void swap(DenseStorage& ) {}
+ static DenseIndex rows(void) {return _Rows;}
+ static DenseIndex cols(void) {return _Cols;}
+ void conservativeResize(DenseIndex,DenseIndex,DenseIndex) {}
+ void resize(DenseIndex,DenseIndex,DenseIndex) {}
+ const T *data() const { return 0; }
+ T *data() { return 0; }
};
// more specializations for null matrices; these are necessary to resolve ambiguities
@@ -160,18 +176,29 @@ template<typename T, int Size, int _Options> class DenseStorage<T, Size, Dynamic
DenseIndex m_rows;
DenseIndex m_cols;
public:
- inline DenseStorage() : m_rows(0), m_cols(0) {}
- inline DenseStorage(internal::constructor_without_unaligned_array_assert)
+ DenseStorage() : m_rows(0), m_cols(0) {}
+ DenseStorage(internal::constructor_without_unaligned_array_assert)
: m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0), m_cols(0) {}
- inline DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) : m_rows(nbRows), m_cols(nbCols) {}
- inline void swap(DenseStorage& other)
+ DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows), m_cols(other.m_cols) {}
+ DenseStorage& operator=(const DenseStorage& other)
+ {
+ if (this != &other)
+ {
+ m_data = other.m_data;
+ m_rows = other.m_rows;
+ m_cols = other.m_cols;
+ }
+ return *this;
+ }
+ DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) : m_rows(nbRows), m_cols(nbCols) {}
+ void swap(DenseStorage& other)
{ std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); }
- inline DenseIndex rows() const {return m_rows;}
- inline DenseIndex cols() const {return m_cols;}
- inline void conservativeResize(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) { m_rows = nbRows; m_cols = nbCols; }
- inline void resize(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) { m_rows = nbRows; m_cols = nbCols; }
- inline const T *data() const { return m_data.array; }
- inline T *data() { return m_data.array; }
+ DenseIndex rows() const {return m_rows;}
+ DenseIndex cols() const {return m_cols;}
+ void conservativeResize(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) { m_rows = nbRows; m_cols = nbCols; }
+ void resize(DenseIndex, DenseIndex nbRows, DenseIndex nbCols) { m_rows = nbRows; m_cols = nbCols; }
+ const T *data() const { return m_data.array; }
+ T *data() { return m_data.array; }
};
// dynamic-size matrix with fixed-size storage and fixed width
@@ -180,17 +207,27 @@ template<typename T, int Size, int _Cols, int _Options> class DenseStorage<T, Si
internal::plain_array<T,Size,_Options> m_data;
DenseIndex m_rows;
public:
- inline DenseStorage() : m_rows(0) {}
- inline DenseStorage(internal::constructor_without_unaligned_array_assert)
+ DenseStorage() : m_rows(0) {}
+ DenseStorage(internal::constructor_without_unaligned_array_assert)
: m_data(internal::constructor_without_unaligned_array_assert()), m_rows(0) {}
- inline DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex) : m_rows(nbRows) {}
- inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }
- inline DenseIndex rows(void) const {return m_rows;}
- inline DenseIndex cols(void) const {return _Cols;}
- inline void conservativeResize(DenseIndex, DenseIndex nbRows, DenseIndex) { m_rows = nbRows; }
- inline void resize(DenseIndex, DenseIndex nbRows, DenseIndex) { m_rows = nbRows; }
- inline const T *data() const { return m_data.array; }
- inline T *data() { return m_data.array; }
+ DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_rows(other.m_rows) {}
+ DenseStorage& operator=(const DenseStorage& other)
+ {
+ if (this != &other)
+ {
+ m_data = other.m_data;
+ m_rows = other.m_rows;
+ }
+ return *this;
+ }
+ DenseStorage(DenseIndex, DenseIndex nbRows, DenseIndex) : m_rows(nbRows) {}
+ void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }
+ DenseIndex rows(void) const {return m_rows;}
+ DenseIndex cols(void) const {return _Cols;}
+ void conservativeResize(DenseIndex, DenseIndex nbRows, DenseIndex) { m_rows = nbRows; }
+ void resize(DenseIndex, DenseIndex nbRows, DenseIndex) { m_rows = nbRows; }
+ const T *data() const { return m_data.array; }
+ T *data() { return m_data.array; }
};
// dynamic-size matrix with fixed-size storage and fixed height
@@ -199,17 +236,27 @@ template<typename T, int Size, int _Rows, int _Options> class DenseStorage<T, Si
internal::plain_array<T,Size,_Options> m_data;
DenseIndex m_cols;
public:
- inline DenseStorage() : m_cols(0) {}
- inline DenseStorage(internal::constructor_without_unaligned_array_assert)
+ DenseStorage() : m_cols(0) {}
+ DenseStorage(internal::constructor_without_unaligned_array_assert)
: m_data(internal::constructor_without_unaligned_array_assert()), m_cols(0) {}
- inline DenseStorage(DenseIndex, DenseIndex, DenseIndex nbCols) : m_cols(nbCols) {}
- inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }
- inline DenseIndex rows(void) const {return _Rows;}
- inline DenseIndex cols(void) const {return m_cols;}
- inline void conservativeResize(DenseIndex, DenseIndex, DenseIndex nbCols) { m_cols = nbCols; }
- inline void resize(DenseIndex, DenseIndex, DenseIndex nbCols) { m_cols = nbCols; }
- inline const T *data() const { return m_data.array; }
- inline T *data() { return m_data.array; }
+ DenseStorage(const DenseStorage& other) : m_data(other.m_data), m_cols(other.m_cols) {}
+ DenseStorage& operator=(const DenseStorage& other)
+ {
+ if (this != &other)
+ {
+ m_data = other.m_data;
+ m_cols = other.m_cols;
+ }
+ return *this;
+ }
+ DenseStorage(DenseIndex, DenseIndex, DenseIndex nbCols) : m_cols(nbCols) {}
+ void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }
+ DenseIndex rows(void) const {return _Rows;}
+ DenseIndex cols(void) const {return m_cols;}
+ void conservativeResize(DenseIndex, DenseIndex, DenseIndex nbCols) { m_cols = nbCols; }
+ void resize(DenseIndex, DenseIndex, DenseIndex nbCols) { m_cols = nbCols; }
+ const T *data() const { return m_data.array; }
+ T *data() { return m_data.array; }
};
// purely dynamic matrix.
@@ -219,18 +266,35 @@ template<typename T, int _Options> class DenseStorage<T, Dynamic, Dynamic, Dynam
DenseIndex m_rows;
DenseIndex m_cols;
public:
- inline DenseStorage() : m_data(0), m_rows(0), m_cols(0) {}
- inline DenseStorage(internal::constructor_without_unaligned_array_assert)
+ DenseStorage() : m_data(0), m_rows(0), m_cols(0) {}
+ DenseStorage(internal::constructor_without_unaligned_array_assert)
: m_data(0), m_rows(0), m_cols(0) {}
- inline DenseStorage(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols)
+ DenseStorage(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols)
: m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_rows(nbRows), m_cols(nbCols)
{ EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN }
- inline ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); }
- inline void swap(DenseStorage& other)
+#ifdef EIGEN_HAVE_RVALUE_REFERENCES
+ DenseStorage(DenseStorage&& other)
+ : m_data(std::move(other.m_data))
+ , m_rows(std::move(other.m_rows))
+ , m_cols(std::move(other.m_cols))
+ {
+ other.m_data = nullptr;
+ }
+ DenseStorage& operator=(DenseStorage&& other)
+ {
+ using std::swap;
+ swap(m_data, other.m_data);
+ swap(m_rows, other.m_rows);
+ swap(m_cols, other.m_cols);
+ return *this;
+ }
+#endif
+ ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, m_rows*m_cols); }
+ void swap(DenseStorage& other)
{ std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); std::swap(m_cols,other.m_cols); }
- inline DenseIndex rows(void) const {return m_rows;}
- inline DenseIndex cols(void) const {return m_cols;}
- inline void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols)
+ DenseIndex rows(void) const {return m_rows;}
+ DenseIndex cols(void) const {return m_cols;}
+ void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex nbCols)
{
m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*m_cols);
m_rows = nbRows;
@@ -250,8 +314,11 @@ template<typename T, int _Options> class DenseStorage<T, Dynamic, Dynamic, Dynam
m_rows = nbRows;
m_cols = nbCols;
}
- inline const T *data() const { return m_data; }
- inline T *data() { return m_data; }
+ const T *data() const { return m_data; }
+ T *data() { return m_data; }
+ private:
+ DenseStorage(const DenseStorage&);
+ DenseStorage& operator=(const DenseStorage&);
};
// matrix with dynamic width and fixed height (so that matrix has dynamic size).
@@ -260,15 +327,30 @@ template<typename T, int _Rows, int _Options> class DenseStorage<T, Dynamic, _Ro
T *m_data;
DenseIndex m_cols;
public:
- inline DenseStorage() : m_data(0), m_cols(0) {}
- inline DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {}
- inline DenseStorage(DenseIndex size, DenseIndex, DenseIndex nbCols) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_cols(nbCols)
+ DenseStorage() : m_data(0), m_cols(0) {}
+ DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_cols(0) {}
+ DenseStorage(DenseIndex size, DenseIndex, DenseIndex nbCols) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_cols(nbCols)
{ EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN }
- inline ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); }
- inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }
- static inline DenseIndex rows(void) {return _Rows;}
- inline DenseIndex cols(void) const {return m_cols;}
- inline void conservativeResize(DenseIndex size, DenseIndex, DenseIndex nbCols)
+#ifdef EIGEN_HAVE_RVALUE_REFERENCES
+ DenseStorage(DenseStorage&& other)
+ : m_data(std::move(other.m_data))
+ , m_cols(std::move(other.m_cols))
+ {
+ other.m_data = nullptr;
+ }
+ DenseStorage& operator=(DenseStorage&& other)
+ {
+ using std::swap;
+ swap(m_data, other.m_data);
+ swap(m_cols, other.m_cols);
+ return *this;
+ }
+#endif
+ ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Rows*m_cols); }
+ void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_cols,other.m_cols); }
+ static DenseIndex rows(void) {return _Rows;}
+ DenseIndex cols(void) const {return m_cols;}
+ void conservativeResize(DenseIndex size, DenseIndex, DenseIndex nbCols)
{
m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, _Rows*m_cols);
m_cols = nbCols;
@@ -286,8 +368,11 @@ template<typename T, int _Rows, int _Options> class DenseStorage<T, Dynamic, _Ro
}
m_cols = nbCols;
}
- inline const T *data() const { return m_data; }
- inline T *data() { return m_data; }
+ const T *data() const { return m_data; }
+ T *data() { return m_data; }
+ private:
+ DenseStorage(const DenseStorage&);
+ DenseStorage& operator=(const DenseStorage&);
};
// matrix with dynamic height and fixed width (so that matrix has dynamic size).
@@ -296,15 +381,30 @@ template<typename T, int _Cols, int _Options> class DenseStorage<T, Dynamic, Dyn
T *m_data;
DenseIndex m_rows;
public:
- inline DenseStorage() : m_data(0), m_rows(0) {}
- inline DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {}
- inline DenseStorage(DenseIndex size, DenseIndex nbRows, DenseIndex) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_rows(nbRows)
+ DenseStorage() : m_data(0), m_rows(0) {}
+ DenseStorage(internal::constructor_without_unaligned_array_assert) : m_data(0), m_rows(0) {}
+ DenseStorage(DenseIndex size, DenseIndex nbRows, DenseIndex) : m_data(internal::conditional_aligned_new_auto<T,(_Options&DontAlign)==0>(size)), m_rows(nbRows)
{ EIGEN_INTERNAL_DENSE_STORAGE_CTOR_PLUGIN }
- inline ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); }
- inline void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }
- inline DenseIndex rows(void) const {return m_rows;}
- static inline DenseIndex cols(void) {return _Cols;}
- inline void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex)
+#ifdef EIGEN_HAVE_RVALUE_REFERENCES
+ DenseStorage(DenseStorage&& other)
+ : m_data(std::move(other.m_data))
+ , m_rows(std::move(other.m_rows))
+ {
+ other.m_data = nullptr;
+ }
+ DenseStorage& operator=(DenseStorage&& other)
+ {
+ using std::swap;
+ swap(m_data, other.m_data);
+ swap(m_rows, other.m_rows);
+ return *this;
+ }
+#endif
+ ~DenseStorage() { internal::conditional_aligned_delete_auto<T,(_Options&DontAlign)==0>(m_data, _Cols*m_rows); }
+ void swap(DenseStorage& other) { std::swap(m_data,other.m_data); std::swap(m_rows,other.m_rows); }
+ DenseIndex rows(void) const {return m_rows;}
+ static DenseIndex cols(void) {return _Cols;}
+ void conservativeResize(DenseIndex size, DenseIndex nbRows, DenseIndex)
{
m_data = internal::conditional_aligned_realloc_new_auto<T,(_Options&DontAlign)==0>(m_data, size, m_rows*_Cols);
m_rows = nbRows;
@@ -322,8 +422,11 @@ template<typename T, int _Cols, int _Options> class DenseStorage<T, Dynamic, Dyn
}
m_rows = nbRows;
}
- inline const T *data() const { return m_data; }
- inline T *data() { return m_data; }
+ const T *data() const { return m_data; }
+ T *data() { return m_data; }
+ private:
+ DenseStorage(const DenseStorage&);
+ DenseStorage& operator=(const DenseStorage&);
};
} // end namespace Eigen
diff --git a/Utilities/eigen3/Eigen/src/Core/Diagonal.h b/Utilities/eigen3/Eigen/src/Core/Diagonal.h
index aab8007b..68cf6d4b 100644
--- a/Utilities/eigen3/Eigen/src/Core/Diagonal.h
+++ b/Utilities/eigen3/Eigen/src/Core/Diagonal.h
@@ -190,18 +190,18 @@ MatrixBase<Derived>::diagonal() const
*
* \sa MatrixBase::diagonal(), class Diagonal */
template<typename Derived>
-inline typename MatrixBase<Derived>::template DiagonalIndexReturnType<DynamicIndex>::Type
+inline typename MatrixBase<Derived>::DiagonalDynamicIndexReturnType
MatrixBase<Derived>::diagonal(Index index)
{
- return typename DiagonalIndexReturnType<DynamicIndex>::Type(derived(), index);
+ return DiagonalDynamicIndexReturnType(derived(), index);
}
/** This is the const version of diagonal(Index). */
template<typename Derived>
-inline typename MatrixBase<Derived>::template ConstDiagonalIndexReturnType<DynamicIndex>::Type
+inline typename MatrixBase<Derived>::ConstDiagonalDynamicIndexReturnType
MatrixBase<Derived>::diagonal(Index index) const
{
- return typename ConstDiagonalIndexReturnType<DynamicIndex>::Type(derived(), index);
+ return ConstDiagonalDynamicIndexReturnType(derived(), index);
}
/** \returns an expression of the \a DiagIndex-th sub or super diagonal of the matrix \c *this
diff --git a/Utilities/eigen3/Eigen/src/Core/DiagonalProduct.h b/Utilities/eigen3/Eigen/src/Core/DiagonalProduct.h
index c03a0c2e..cc6b536e 100644
--- a/Utilities/eigen3/Eigen/src/Core/DiagonalProduct.h
+++ b/Utilities/eigen3/Eigen/src/Core/DiagonalProduct.h
@@ -34,8 +34,9 @@ struct traits<DiagonalProduct<MatrixType, DiagonalType, ProductOrder> >
_Vectorizable = bool(int(MatrixType::Flags)&PacketAccessBit) && _SameTypes && (_ScalarAccessOnDiag || (bool(int(DiagonalType::DiagonalVectorType::Flags)&PacketAccessBit))),
_LinearAccessMask = (RowsAtCompileTime==1 || ColsAtCompileTime==1) ? LinearAccessBit : 0,
- Flags = ((HereditaryBits|_LinearAccessMask) & (unsigned int)(MatrixType::Flags)) | (_Vectorizable ? PacketAccessBit : 0) | AlignedBit,//(int(MatrixType::Flags)&int(DiagonalType::DiagonalVectorType::Flags)&AlignedBit),
- CoeffReadCost = NumTraits<Scalar>::MulCost + MatrixType::CoeffReadCost + DiagonalType::DiagonalVectorType::CoeffReadCost
+ Flags = ((HereditaryBits|_LinearAccessMask|AlignedBit) & (unsigned int)(MatrixType::Flags)) | (_Vectorizable ? PacketAccessBit : 0),//(int(MatrixType::Flags)&int(DiagonalType::DiagonalVectorType::Flags)&AlignedBit),
+ Cost0 = EIGEN_ADD_COST(NumTraits<Scalar>::MulCost, MatrixType::CoeffReadCost),
+ CoeffReadCost = EIGEN_ADD_COST(Cost0,DiagonalType::DiagonalVectorType::CoeffReadCost)
};
};
}
diff --git a/Utilities/eigen3/Eigen/src/Core/EigenBase.h b/Utilities/eigen3/Eigen/src/Core/EigenBase.h
index 2b8dd1b7..fadb4585 100644
--- a/Utilities/eigen3/Eigen/src/Core/EigenBase.h
+++ b/Utilities/eigen3/Eigen/src/Core/EigenBase.h
@@ -126,36 +126,6 @@ Derived& DenseBase<Derived>::operator-=(const EigenBase<OtherDerived> &other)
return derived();
}
-/** replaces \c *this by \c *this * \a other.
- *
- * \returns a reference to \c *this
- */
-template<typename Derived>
-template<typename OtherDerived>
-inline Derived&
-MatrixBase<Derived>::operator*=(const EigenBase<OtherDerived> &other)
-{
- other.derived().applyThisOnTheRight(derived());
- return derived();
-}
-
-/** replaces \c *this by \c *this * \a other. It is equivalent to MatrixBase::operator*=().
- */
-template<typename Derived>
-template<typename OtherDerived>
-inline void MatrixBase<Derived>::applyOnTheRight(const EigenBase<OtherDerived> &other)
-{
- other.derived().applyThisOnTheRight(derived());
-}
-
-/** replaces \c *this by \c *this * \a other. */
-template<typename Derived>
-template<typename OtherDerived>
-inline void MatrixBase<Derived>::applyOnTheLeft(const EigenBase<OtherDerived> &other)
-{
- other.derived().applyThisOnTheLeft(derived());
-}
-
} // end namespace Eigen
#endif // EIGEN_EIGENBASE_H
diff --git a/Utilities/eigen3/Eigen/src/Core/Functors.h b/Utilities/eigen3/Eigen/src/Core/Functors.h
index 04fb2173..5f14c658 100644
--- a/Utilities/eigen3/Eigen/src/Core/Functors.h
+++ b/Utilities/eigen3/Eigen/src/Core/Functors.h
@@ -259,6 +259,47 @@ template<> struct functor_traits<scalar_boolean_or_op> {
};
};
+/** \internal
+ * \brief Template functors for comparison of two scalars
+ * \todo Implement packet-comparisons
+ */
+template<typename Scalar, ComparisonName cmp> struct scalar_cmp_op;
+
+template<typename Scalar, ComparisonName cmp>
+struct functor_traits<scalar_cmp_op<Scalar, cmp> > {
+ enum {
+ Cost = NumTraits<Scalar>::AddCost,
+ PacketAccess = false
+ };
+};
+
+template<ComparisonName Cmp, typename Scalar>
+struct result_of<scalar_cmp_op<Scalar, Cmp>(Scalar,Scalar)> {
+ typedef bool type;
+};
+
+
+template<typename Scalar> struct scalar_cmp_op<Scalar, cmp_EQ> {
+ EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)
+ EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return a==b;}
+};
+template<typename Scalar> struct scalar_cmp_op<Scalar, cmp_LT> {
+ EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)
+ EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return a<b;}
+};
+template<typename Scalar> struct scalar_cmp_op<Scalar, cmp_LE> {
+ EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)
+ EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return a<=b;}
+};
+template<typename Scalar> struct scalar_cmp_op<Scalar, cmp_UNORD> {
+ EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)
+ EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return !(a<=b || b<=a);}
+};
+template<typename Scalar> struct scalar_cmp_op<Scalar, cmp_NEQ> {
+ EIGEN_EMPTY_STRUCT_CTOR(scalar_cmp_op)
+ EIGEN_STRONG_INLINE bool operator()(const Scalar& a, const Scalar& b) const {return a!=b;}
+};
+
// unary functors:
/** \internal
@@ -589,7 +630,7 @@ struct linspaced_op_impl<Scalar,true>
template<typename Index>
EIGEN_STRONG_INLINE const Packet packetOp(Index i) const
- { return internal::padd(m_lowPacket, pmul(m_stepPacket, padd(pset1<Packet>(i),m_interPacket))); }
+ { return internal::padd(m_lowPacket, pmul(m_stepPacket, padd(pset1<Packet>(Scalar(i)),m_interPacket))); }
const Scalar m_low;
const Scalar m_step;
@@ -609,7 +650,7 @@ template <typename Scalar, bool RandomAccess> struct functor_traits< linspaced_o
template <typename Scalar, bool RandomAccess> struct linspaced_op
{
typedef typename packet_traits<Scalar>::type Packet;
- linspaced_op(const Scalar& low, const Scalar& high, DenseIndex num_steps) : impl((num_steps==1 ? high : low), (num_steps==1 ? Scalar() : (high-low)/(num_steps-1))) {}
+ linspaced_op(const Scalar& low, const Scalar& high, DenseIndex num_steps) : impl((num_steps==1 ? high : low), (num_steps==1 ? Scalar() : (high-low)/Scalar(num_steps-1))) {}
template<typename Index>
EIGEN_STRONG_INLINE const Scalar operator() (Index i) const { return impl(i); }
diff --git a/Utilities/eigen3/Eigen/src/Core/GeneralProduct.h b/Utilities/eigen3/Eigen/src/Core/GeneralProduct.h
index 2a59d946..0eae5299 100644
--- a/Utilities/eigen3/Eigen/src/Core/GeneralProduct.h
+++ b/Utilities/eigen3/Eigen/src/Core/GeneralProduct.h
@@ -232,7 +232,7 @@ EIGEN_DONT_INLINE void outer_product_selector_run(const ProductType& prod, Dest&
// FIXME not very good if rhs is real and lhs complex while alpha is real too
const Index cols = dest.cols();
for (Index j=0; j<cols; ++j)
- func(dest.col(j), prod.rhs().coeff(j) * prod.lhs());
+ func(dest.col(j), prod.rhs().coeff(0,j) * prod.lhs());
}
// Row major
@@ -243,7 +243,7 @@ EIGEN_DONT_INLINE void outer_product_selector_run(const ProductType& prod, Dest&
// FIXME not very good if lhs is real and rhs complex while alpha is real too
const Index rows = dest.rows();
for (Index i=0; i<rows; ++i)
- func(dest.row(i), prod.lhs().coeff(i) * prod.rhs());
+ func(dest.row(i), prod.lhs().coeff(i,0) * prod.rhs());
}
template<typename Lhs, typename Rhs>
@@ -257,7 +257,7 @@ template<typename Lhs, typename Rhs>
class GeneralProduct<Lhs, Rhs, OuterProduct>
: public ProductBase<GeneralProduct<Lhs,Rhs,OuterProduct>, Lhs, Rhs>
{
- template<typename T> struct IsRowMajor : internal::conditional<(int(T::Flags)&RowMajorBit), internal::true_type, internal::false_type>::type {};
+ template<typename T> struct is_row_major : internal::conditional<(int(T::Flags)&RowMajorBit), internal::true_type, internal::false_type>::type {};
public:
EIGEN_PRODUCT_PUBLIC_INTERFACE(GeneralProduct)
@@ -281,22 +281,22 @@ class GeneralProduct<Lhs, Rhs, OuterProduct>
template<typename Dest>
inline void evalTo(Dest& dest) const {
- internal::outer_product_selector_run(*this, dest, set(), IsRowMajor<Dest>());
+ internal::outer_product_selector_run(*this, dest, set(), is_row_major<Dest>());
}
template<typename Dest>
inline void addTo(Dest& dest) const {
- internal::outer_product_selector_run(*this, dest, add(), IsRowMajor<Dest>());
+ internal::outer_product_selector_run(*this, dest, add(), is_row_major<Dest>());
}
template<typename Dest>
inline void subTo(Dest& dest) const {
- internal::outer_product_selector_run(*this, dest, sub(), IsRowMajor<Dest>());
+ internal::outer_product_selector_run(*this, dest, sub(), is_row_major<Dest>());
}
template<typename Dest> void scaleAndAddTo(Dest& dest, const Scalar& alpha) const
{
- internal::outer_product_selector_run(*this, dest, adds(alpha), IsRowMajor<Dest>());
+ internal::outer_product_selector_run(*this, dest, adds(alpha), is_row_major<Dest>());
}
};
diff --git a/Utilities/eigen3/Eigen/src/Core/IO.h b/Utilities/eigen3/Eigen/src/Core/IO.h
index c8d5f637..8d4bc59e 100644
--- a/Utilities/eigen3/Eigen/src/Core/IO.h
+++ b/Utilities/eigen3/Eigen/src/Core/IO.h
@@ -185,21 +185,22 @@ std::ostream & print_matrix(std::ostream & s, const Derived& _m, const IOFormat&
explicit_precision = fmt.precision;
}
+ std::streamsize old_precision = 0;
+ if(explicit_precision) old_precision = s.precision(explicit_precision);
+
bool align_cols = !(fmt.flags & DontAlignCols);
if(align_cols)
{
// compute the largest width
- for(Index j = 1; j < m.cols(); ++j)
+ for(Index j = 0; j < m.cols(); ++j)
for(Index i = 0; i < m.rows(); ++i)
{
std::stringstream sstr;
- if(explicit_precision) sstr.precision(explicit_precision);
+ sstr.copyfmt(s);
sstr << m.coeff(i,j);
width = std::max<Index>(width, Index(sstr.str().length()));
}
}
- std::streamsize old_precision = 0;
- if(explicit_precision) old_precision = s.precision(explicit_precision);
s << fmt.matPrefix;
for(Index i = 0; i < m.rows(); ++i)
{
diff --git a/Utilities/eigen3/Eigen/src/Core/MapBase.h b/Utilities/eigen3/Eigen/src/Core/MapBase.h
index 6876de58..a9828f7f 100644
--- a/Utilities/eigen3/Eigen/src/Core/MapBase.h
+++ b/Utilities/eigen3/Eigen/src/Core/MapBase.h
@@ -123,7 +123,7 @@ template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
return internal::ploadt<PacketScalar, LoadMode>(m_data + index * innerStride());
}
- inline MapBase(PointerType dataPtr) : m_data(dataPtr), m_rows(RowsAtCompileTime), m_cols(ColsAtCompileTime)
+ explicit inline MapBase(PointerType dataPtr) : m_data(dataPtr), m_rows(RowsAtCompileTime), m_cols(ColsAtCompileTime)
{
EIGEN_STATIC_ASSERT_FIXED_SIZE(Derived)
checkSanity();
@@ -157,7 +157,7 @@ template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
internal::inner_stride_at_compile_time<Derived>::ret==1),
PACKET_ACCESS_REQUIRES_TO_HAVE_INNER_STRIDE_FIXED_TO_1);
eigen_assert(EIGEN_IMPLIES(internal::traits<Derived>::Flags&AlignedBit, (size_t(m_data) % 16) == 0)
- && "data is not aligned");
+ && "input pointer is not aligned on a 16 byte boundary");
}
PointerType m_data;
@@ -168,6 +168,7 @@ template<typename Derived> class MapBase<Derived, ReadOnlyAccessors>
template<typename Derived> class MapBase<Derived, WriteAccessors>
: public MapBase<Derived, ReadOnlyAccessors>
{
+ typedef MapBase<Derived, ReadOnlyAccessors> ReadOnlyMapBase;
public:
typedef MapBase<Derived, ReadOnlyAccessors> Base;
@@ -230,13 +231,17 @@ template<typename Derived> class MapBase<Derived, WriteAccessors>
Derived& operator=(const MapBase& other)
{
- Base::Base::operator=(other);
+ ReadOnlyMapBase::Base::operator=(other);
return derived();
}
- using Base::Base::operator=;
+ // In theory we could simply refer to Base:Base::operator=, but MSVC does not like Base::Base,
+ // see bugs 821 and 920.
+ using ReadOnlyMapBase::Base::operator=;
};
+#undef EIGEN_STATIC_ASSERT_INDEX_BASED_ACCESS
+
} // end namespace Eigen
#endif // EIGEN_MAPBASE_H
diff --git a/Utilities/eigen3/Eigen/src/Core/MathFunctions.h b/Utilities/eigen3/Eigen/src/Core/MathFunctions.h
index 2bfc5ebd..adf2f9c5 100644
--- a/Utilities/eigen3/Eigen/src/Core/MathFunctions.h
+++ b/Utilities/eigen3/Eigen/src/Core/MathFunctions.h
@@ -294,7 +294,7 @@ struct hypot_impl
RealScalar _x = abs(x);
RealScalar _y = abs(y);
RealScalar p = (max)(_x, _y);
- if(p==RealScalar(0)) return 0;
+ if(p==RealScalar(0)) return RealScalar(0);
RealScalar q = (min)(_x, _y);
RealScalar qp = q/p;
return p * sqrt(RealScalar(1) + qp*qp);
diff --git a/Utilities/eigen3/Eigen/src/Core/Matrix.h b/Utilities/eigen3/Eigen/src/Core/Matrix.h
index 0ba5d90c..02be142d 100644
--- a/Utilities/eigen3/Eigen/src/Core/Matrix.h
+++ b/Utilities/eigen3/Eigen/src/Core/Matrix.h
@@ -211,6 +211,21 @@ class Matrix
: Base(internal::constructor_without_unaligned_array_assert())
{ Base::_check_template_params(); EIGEN_INITIALIZE_COEFFS_IF_THAT_OPTION_IS_ENABLED }
+#ifdef EIGEN_HAVE_RVALUE_REFERENCES
+ Matrix(Matrix&& other)
+ : Base(std::move(other))
+ {
+ Base::_check_template_params();
+ if (RowsAtCompileTime!=Dynamic && ColsAtCompileTime!=Dynamic)
+ Base::_set_noalias(other);
+ }
+ Matrix& operator=(Matrix&& other)
+ {
+ other.swap(*this);
+ return *this;
+ }
+#endif
+
/** \brief Constructs a vector or row-vector with given dimension. \only_for_vectors
*
* Note that this is only useful for dynamic-size vectors. For fixed-size vectors,
@@ -304,7 +319,7 @@ class Matrix
: Base(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols())
{
Base::_check_template_params();
- Base::resize(other.rows(), other.cols());
+ Base::_resize_to_match(other);
// FIXME/CHECK: isn't *this = other.derived() more efficient. it allows to
// go for pure _set() implementations, right?
*this = other;
diff --git a/Utilities/eigen3/Eigen/src/Core/MatrixBase.h b/Utilities/eigen3/Eigen/src/Core/MatrixBase.h
index 9193b6ab..e83ef4dc 100644
--- a/Utilities/eigen3/Eigen/src/Core/MatrixBase.h
+++ b/Utilities/eigen3/Eigen/src/Core/MatrixBase.h
@@ -159,13 +159,11 @@ template<typename Derived> class MatrixBase
template<typename OtherDerived>
Derived& operator=(const ReturnByValue<OtherDerived>& other);
-#ifndef EIGEN_PARSED_BY_DOXYGEN
template<typename ProductDerived, typename Lhs, typename Rhs>
Derived& lazyAssign(const ProductBase<ProductDerived, Lhs,Rhs>& other);
template<typename MatrixPower, typename Lhs, typename Rhs>
Derived& lazyAssign(const MatrixPowerProduct<MatrixPower, Lhs,Rhs>& other);
-#endif // not EIGEN_PARSED_BY_DOXYGEN
template<typename OtherDerived>
Derived& operator+=(const MatrixBase<OtherDerived>& other);
@@ -215,7 +213,7 @@ template<typename Derived> class MatrixBase
typedef Diagonal<Derived> DiagonalReturnType;
DiagonalReturnType diagonal();
- typedef typename internal::add_const<Diagonal<const Derived> >::type ConstDiagonalReturnType;
+ typedef typename internal::add_const<Diagonal<const Derived> >::type ConstDiagonalReturnType;
ConstDiagonalReturnType diagonal() const;
template<int Index> struct DiagonalIndexReturnType { typedef Diagonal<Derived,Index> Type; };
@@ -223,16 +221,12 @@ template<typename Derived> class MatrixBase
template<int Index> typename DiagonalIndexReturnType<Index>::Type diagonal();
template<int Index> typename ConstDiagonalIndexReturnType<Index>::Type diagonal() const;
+
+ typedef Diagonal<Derived,DynamicIndex> DiagonalDynamicIndexReturnType;
+ typedef typename internal::add_const<Diagonal<const Derived,DynamicIndex> >::type ConstDiagonalDynamicIndexReturnType;
- // Note: The "MatrixBase::" prefixes are added to help MSVC9 to match these declarations with the later implementations.
- // On the other hand they confuse MSVC8...
- #if (defined _MSC_VER) && (_MSC_VER >= 1500) // 2008 or later
- typename MatrixBase::template DiagonalIndexReturnType<DynamicIndex>::Type diagonal(Index index);
- typename MatrixBase::template ConstDiagonalIndexReturnType<DynamicIndex>::Type diagonal(Index index) const;
- #else
- typename DiagonalIndexReturnType<DynamicIndex>::Type diagonal(Index index);
- typename ConstDiagonalIndexReturnType<DynamicIndex>::Type diagonal(Index index) const;
- #endif
+ DiagonalDynamicIndexReturnType diagonal(Index index);
+ ConstDiagonalDynamicIndexReturnType diagonal(Index index) const;
#ifdef EIGEN2_SUPPORT
template<unsigned int Mode> typename internal::eigen2_part_return_type<Derived, Mode>::type part();
@@ -446,6 +440,15 @@ template<typename Derived> class MatrixBase
template<typename OtherScalar>
void applyOnTheRight(Index p, Index q, const JacobiRotation<OtherScalar>& j);
+///////// SparseCore module /////////
+
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE const typename SparseMatrixBase<OtherDerived>::template CwiseProductDenseReturnType<Derived>::Type
+ cwiseProduct(const SparseMatrixBase<OtherDerived> &other) const
+ {
+ return other.cwiseProduct(derived());
+ }
+
///////// MatrixFunctions module /////////
typedef typename internal::stem_function<Scalar>::type StemFunction;
@@ -510,6 +513,51 @@ template<typename Derived> class MatrixBase
{EIGEN_STATIC_ASSERT(std::ptrdiff_t(sizeof(typename OtherDerived::Scalar))==-1,YOU_CANNOT_MIX_ARRAYS_AND_MATRICES); return *this;}
};
+
+/***************************************************************************
+* Implementation of matrix base methods
+***************************************************************************/
+
+/** replaces \c *this by \c *this * \a other.
+ *
+ * \returns a reference to \c *this
+ *
+ * Example: \include MatrixBase_applyOnTheRight.cpp
+ * Output: \verbinclude MatrixBase_applyOnTheRight.out
+ */
+template<typename Derived>
+template<typename OtherDerived>
+inline Derived&
+MatrixBase<Derived>::operator*=(const EigenBase<OtherDerived> &other)
+{
+ other.derived().applyThisOnTheRight(derived());
+ return derived();
+}
+
+/** replaces \c *this by \c *this * \a other. It is equivalent to MatrixBase::operator*=().
+ *
+ * Example: \include MatrixBase_applyOnTheRight.cpp
+ * Output: \verbinclude MatrixBase_applyOnTheRight.out
+ */
+template<typename Derived>
+template<typename OtherDerived>
+inline void MatrixBase<Derived>::applyOnTheRight(const EigenBase<OtherDerived> &other)
+{
+ other.derived().applyThisOnTheRight(derived());
+}
+
+/** replaces \c *this by \a other * \c *this.
+ *
+ * Example: \include MatrixBase_applyOnTheLeft.cpp
+ * Output: \verbinclude MatrixBase_applyOnTheLeft.out
+ */
+template<typename Derived>
+template<typename OtherDerived>
+inline void MatrixBase<Derived>::applyOnTheLeft(const EigenBase<OtherDerived> &other)
+{
+ other.derived().applyThisOnTheLeft(derived());
+}
+
} // end namespace Eigen
#endif // EIGEN_MATRIXBASE_H
diff --git a/Utilities/eigen3/Eigen/src/Core/PermutationMatrix.h b/Utilities/eigen3/Eigen/src/Core/PermutationMatrix.h
index 4fc5dd31..85ffae26 100644
--- a/Utilities/eigen3/Eigen/src/Core/PermutationMatrix.h
+++ b/Utilities/eigen3/Eigen/src/Core/PermutationMatrix.h
@@ -250,6 +250,35 @@ class PermutationBase : public EigenBase<Derived>
template<typename Other> friend
inline PlainPermutationType operator*(const Transpose<PermutationBase<Other> >& other, const PermutationBase& perm)
{ return PlainPermutationType(internal::PermPermProduct, other.eval(), perm); }
+
+ /** \returns the determinant of the permutation matrix, which is either 1 or -1 depending on the parity of the permutation.
+ *
+ * This function is O(\c n) procedure allocating a buffer of \c n booleans.
+ */
+ Index determinant() const
+ {
+ Index res = 1;
+ Index n = size();
+ Matrix<bool,RowsAtCompileTime,1,0,MaxRowsAtCompileTime> mask(n);
+ mask.fill(false);
+ Index r = 0;
+ while(r < n)
+ {
+ // search for the next seed
+ while(r<n && mask[r]) r++;
+ if(r>=n)
+ break;
+ // we got one, let's follow it until we are back to the seed
+ Index k0 = r++;
+ mask.coeffRef(k0) = true;
+ for(Index k=indices().coeff(k0); k!=k0; k=indices().coeff(k))
+ {
+ mask.coeffRef(k) = true;
+ res = -res;
+ }
+ }
+ return res;
+ }
protected:
@@ -553,8 +582,12 @@ struct permut_matrix_product_retval
template<typename Dest> inline void evalTo(Dest& dst) const
{
const Index n = Side==OnTheLeft ? rows() : cols();
-
- if(is_same<MatrixTypeNestedCleaned,Dest>::value && extract_data(dst) == extract_data(m_matrix))
+ // FIXME we need an is_same for expression that is not sensitive to constness. For instance
+ // is_same_xpr<Block<const Matrix>, Block<Matrix> >::value should be true.
+ if( is_same<MatrixTypeNestedCleaned,Dest>::value
+ && blas_traits<MatrixTypeNestedCleaned>::HasUsableDirectAccess
+ && blas_traits<Dest>::HasUsableDirectAccess
+ && extract_data(dst) == extract_data(m_matrix))
{
// apply the permutation inplace
Matrix<bool,PermutationType::RowsAtCompileTime,1,0,PermutationType::MaxRowsAtCompileTime> mask(m_permutation.size());
diff --git a/Utilities/eigen3/Eigen/src/Core/PlainObjectBase.h b/Utilities/eigen3/Eigen/src/Core/PlainObjectBase.h
index af0a479c..a4e4af4a 100644
--- a/Utilities/eigen3/Eigen/src/Core/PlainObjectBase.h
+++ b/Utilities/eigen3/Eigen/src/Core/PlainObjectBase.h
@@ -47,7 +47,10 @@ template<> struct check_rows_cols_for_overflow<Dynamic> {
}
};
-template <typename Derived, typename OtherDerived = Derived, bool IsVector = bool(Derived::IsVectorAtCompileTime)> struct conservative_resize_like_impl;
+template <typename Derived,
+ typename OtherDerived = Derived,
+ bool IsVector = bool(Derived::IsVectorAtCompileTime) && bool(OtherDerived::IsVectorAtCompileTime)>
+struct conservative_resize_like_impl;
template<typename MatrixTypeA, typename MatrixTypeB, bool SwapPointers> struct matrix_swap_impl;
@@ -434,6 +437,36 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
}
#endif
+#ifdef EIGEN_HAVE_RVALUE_REFERENCES
+ PlainObjectBase(PlainObjectBase&& other)
+ : m_storage( std::move(other.m_storage) )
+ {
+ }
+
+ PlainObjectBase& operator=(PlainObjectBase&& other)
+ {
+ using std::swap;
+ swap(m_storage, other.m_storage);
+ return *this;
+ }
+#endif
+
+ /** Copy constructor */
+ EIGEN_STRONG_INLINE PlainObjectBase(const PlainObjectBase& other)
+ : m_storage()
+ {
+ _check_template_params();
+ lazyAssign(other);
+ }
+
+ template<typename OtherDerived>
+ EIGEN_STRONG_INLINE PlainObjectBase(const DenseBase<OtherDerived> &other)
+ : m_storage()
+ {
+ _check_template_params();
+ lazyAssign(other);
+ }
+
EIGEN_STRONG_INLINE PlainObjectBase(Index a_size, Index nbRows, Index nbCols)
: m_storage(a_size, nbRows, nbCols)
{
@@ -570,6 +603,8 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type
: (rows() == other.rows() && cols() == other.cols())))
&& "Size mismatch. Automatic resizing is disabled because EIGEN_NO_AUTOMATIC_RESIZING is defined");
EIGEN_ONLY_USED_FOR_DEBUG(other);
+ if(this->size()==0)
+ resizeLike(other);
#else
resizeLike(other);
#endif
@@ -668,8 +703,10 @@ private:
enum { ThisConstantIsPrivateInPlainObjectBase };
};
+namespace internal {
+
template <typename Derived, typename OtherDerived, bool IsVector>
-struct internal::conservative_resize_like_impl
+struct conservative_resize_like_impl
{
typedef typename Derived::Index Index;
static void run(DenseBase<Derived>& _this, Index rows, Index cols)
@@ -729,11 +766,14 @@ struct internal::conservative_resize_like_impl
}
};
-namespace internal {
-
+// Here, the specialization for vectors inherits from the general matrix case
+// to allow calling .conservativeResize(rows,cols) on vectors.
template <typename Derived, typename OtherDerived>
struct conservative_resize_like_impl<Derived,OtherDerived,true>
+ : conservative_resize_like_impl<Derived,OtherDerived,false>
{
+ using conservative_resize_like_impl<Derived,OtherDerived,false>::run;
+
typedef typename Derived::Index Index;
static void run(DenseBase<Derived>& _this, Index size)
{
diff --git a/Utilities/eigen3/Eigen/src/Core/ProductBase.h b/Utilities/eigen3/Eigen/src/Core/ProductBase.h
index a494b5f8..cf74470a 100644
--- a/Utilities/eigen3/Eigen/src/Core/ProductBase.h
+++ b/Utilities/eigen3/Eigen/src/Core/ProductBase.h
@@ -85,7 +85,14 @@ class ProductBase : public MatrixBase<Derived>
public:
+#ifndef EIGEN_NO_MALLOC
+ typedef typename Base::PlainObject BasePlainObject;
+ typedef Matrix<Scalar,RowsAtCompileTime==1?1:Dynamic,ColsAtCompileTime==1?1:Dynamic,BasePlainObject::Options> DynPlainObject;
+ typedef typename internal::conditional<(BasePlainObject::SizeAtCompileTime==Dynamic) || (BasePlainObject::SizeAtCompileTime*int(sizeof(Scalar)) < int(EIGEN_STACK_ALLOCATION_LIMIT)),
+ BasePlainObject, DynPlainObject>::type PlainObject;
+#else
typedef typename Base::PlainObject PlainObject;
+#endif
ProductBase(const Lhs& a_lhs, const Rhs& a_rhs)
: m_lhs(a_lhs), m_rhs(a_rhs)
@@ -180,7 +187,12 @@ namespace internal {
template<typename Lhs, typename Rhs, int Mode, int N, typename PlainObject>
struct nested<GeneralProduct<Lhs,Rhs,Mode>, N, PlainObject>
{
- typedef PlainObject const& type;
+ typedef typename GeneralProduct<Lhs,Rhs,Mode>::PlainObject const& type;
+};
+template<typename Lhs, typename Rhs, int Mode, int N, typename PlainObject>
+struct nested<const GeneralProduct<Lhs,Rhs,Mode>, N, PlainObject>
+{
+ typedef typename GeneralProduct<Lhs,Rhs,Mode>::PlainObject const& type;
};
}
diff --git a/Utilities/eigen3/Eigen/src/Core/Redux.h b/Utilities/eigen3/Eigen/src/Core/Redux.h
index 50548fa9..9b8662a6 100644
--- a/Utilities/eigen3/Eigen/src/Core/Redux.h
+++ b/Utilities/eigen3/Eigen/src/Core/Redux.h
@@ -247,8 +247,9 @@ struct redux_impl<Func, Derived, LinearVectorizedTraversal, NoUnrolling>
}
};
-template<typename Func, typename Derived>
-struct redux_impl<Func, Derived, SliceVectorizedTraversal, NoUnrolling>
+// NOTE: for SliceVectorizedTraversal we simply bypass unrolling
+template<typename Func, typename Derived, int Unrolling>
+struct redux_impl<Func, Derived, SliceVectorizedTraversal, Unrolling>
{
typedef typename Derived::Scalar Scalar;
typedef typename packet_traits<Scalar>::type PacketScalar;
diff --git a/Utilities/eigen3/Eigen/src/Core/Ref.h b/Utilities/eigen3/Eigen/src/Core/Ref.h
index aba795bd..7a3becaf 100644
--- a/Utilities/eigen3/Eigen/src/Core/Ref.h
+++ b/Utilities/eigen3/Eigen/src/Core/Ref.h
@@ -94,24 +94,26 @@ struct traits<Ref<_PlainObjectType, _Options, _StrideType> >
typedef _PlainObjectType PlainObjectType;
typedef _StrideType StrideType;
enum {
- Options = _Options
+ Options = _Options,
+ Flags = traits<Map<_PlainObjectType, _Options, _StrideType> >::Flags | NestByRefBit
};
template<typename Derived> struct match {
enum {
HasDirectAccess = internal::has_direct_access<Derived>::ret,
- StorageOrderMatch = PlainObjectType::IsVectorAtCompileTime || ((PlainObjectType::Flags&RowMajorBit)==(Derived::Flags&RowMajorBit)),
+ StorageOrderMatch = PlainObjectType::IsVectorAtCompileTime || Derived::IsVectorAtCompileTime || ((PlainObjectType::Flags&RowMajorBit)==(Derived::Flags&RowMajorBit)),
InnerStrideMatch = int(StrideType::InnerStrideAtCompileTime)==int(Dynamic)
|| int(StrideType::InnerStrideAtCompileTime)==int(Derived::InnerStrideAtCompileTime)
|| (int(StrideType::InnerStrideAtCompileTime)==0 && int(Derived::InnerStrideAtCompileTime)==1),
OuterStrideMatch = Derived::IsVectorAtCompileTime
|| int(StrideType::OuterStrideAtCompileTime)==int(Dynamic) || int(StrideType::OuterStrideAtCompileTime)==int(Derived::OuterStrideAtCompileTime),
AlignmentMatch = (_Options!=Aligned) || ((PlainObjectType::Flags&AlignedBit)==0) || ((traits<Derived>::Flags&AlignedBit)==AlignedBit),
- MatchAtCompileTime = HasDirectAccess && StorageOrderMatch && InnerStrideMatch && OuterStrideMatch && AlignmentMatch
+ ScalarTypeMatch = internal::is_same<typename PlainObjectType::Scalar, typename Derived::Scalar>::value,
+ MatchAtCompileTime = HasDirectAccess && StorageOrderMatch && InnerStrideMatch && OuterStrideMatch && AlignmentMatch && ScalarTypeMatch
};
typedef typename internal::conditional<MatchAtCompileTime,internal::true_type,internal::false_type>::type type;
};
-
+
};
template<typename Derived>
@@ -171,8 +173,12 @@ protected:
}
else
::new (static_cast<Base*>(this)) Base(expr.data(), expr.rows(), expr.cols());
- ::new (&m_stride) StrideBase(StrideType::OuterStrideAtCompileTime==0?0:expr.outerStride(),
- StrideType::InnerStrideAtCompileTime==0?0:expr.innerStride());
+
+ if(Expression::IsVectorAtCompileTime && (!PlainObjectType::IsVectorAtCompileTime) && ((Expression::Flags&RowMajorBit)!=(PlainObjectType::Flags&RowMajorBit)))
+ ::new (&m_stride) StrideBase(expr.innerStride(), StrideType::InnerStrideAtCompileTime==0?0:1);
+ else
+ ::new (&m_stride) StrideBase(StrideType::OuterStrideAtCompileTime==0?0:expr.outerStride(),
+ StrideType::InnerStrideAtCompileTime==0?0:expr.innerStride());
}
StrideBase m_stride;
@@ -182,7 +188,11 @@ protected:
template<typename PlainObjectType, int Options, typename StrideType> class Ref
: public RefBase<Ref<PlainObjectType, Options, StrideType> >
{
+ private:
typedef internal::traits<Ref> Traits;
+ template<typename Derived>
+ inline Ref(const PlainObjectBase<Derived>& expr,
+ typename internal::enable_if<bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0);
public:
typedef RefBase<Ref> Base;
@@ -194,17 +204,20 @@ template<typename PlainObjectType, int Options, typename StrideType> class Ref
inline Ref(PlainObjectBase<Derived>& expr,
typename internal::enable_if<bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0)
{
- Base::construct(expr);
+ EIGEN_STATIC_ASSERT(static_cast<bool>(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);
+ Base::construct(expr.derived());
}
template<typename Derived>
inline Ref(const DenseBase<Derived>& expr,
- typename internal::enable_if<bool(internal::is_lvalue<Derived>::value&&bool(Traits::template match<Derived>::MatchAtCompileTime)),Derived>::type* = 0,
- int = Derived::ThisConstantIsPrivateInPlainObjectBase)
+ typename internal::enable_if<bool(Traits::template match<Derived>::MatchAtCompileTime),Derived>::type* = 0)
#else
template<typename Derived>
inline Ref(DenseBase<Derived>& expr)
#endif
{
+ EIGEN_STATIC_ASSERT(static_cast<bool>(internal::is_lvalue<Derived>::value), THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY);
+ EIGEN_STATIC_ASSERT(static_cast<bool>(Traits::template match<Derived>::MatchAtCompileTime), STORAGE_LAYOUT_DOES_NOT_MATCH);
+ enum { THIS_EXPRESSION_IS_NOT_A_LVALUE__IT_IS_READ_ONLY = Derived::ThisConstantIsPrivateInPlainObjectBase};
Base::construct(expr.const_cast_derived());
}
@@ -223,13 +236,23 @@ template<typename TPlainObjectType, int Options, typename StrideType> class Ref<
EIGEN_DENSE_PUBLIC_INTERFACE(Ref)
template<typename Derived>
- inline Ref(const DenseBase<Derived>& expr)
+ inline Ref(const DenseBase<Derived>& expr,
+ typename internal::enable_if<bool(Traits::template match<Derived>::ScalarTypeMatch),Derived>::type* = 0)
{
// std::cout << match_helper<Derived>::HasDirectAccess << "," << match_helper<Derived>::OuterStrideMatch << "," << match_helper<Derived>::InnerStrideMatch << "\n";
// std::cout << int(StrideType::OuterStrideAtCompileTime) << " - " << int(Derived::OuterStrideAtCompileTime) << "\n";
// std::cout << int(StrideType::InnerStrideAtCompileTime) << " - " << int(Derived::InnerStrideAtCompileTime) << "\n";
construct(expr.derived(), typename Traits::template match<Derived>::type());
}
+
+ inline Ref(const Ref& other) : Base(other) {
+ // copy constructor shall not copy the m_object, to avoid unnecessary malloc and copy
+ }
+
+ template<typename OtherRef>
+ inline Ref(const RefBase<OtherRef>& other) {
+ construct(other.derived(), typename Traits::template match<OtherRef>::type());
+ }
protected:
diff --git a/Utilities/eigen3/Eigen/src/Core/Replicate.h b/Utilities/eigen3/Eigen/src/Core/Replicate.h
index dde86a83..ac4537c1 100644
--- a/Utilities/eigen3/Eigen/src/Core/Replicate.h
+++ b/Utilities/eigen3/Eigen/src/Core/Replicate.h
@@ -135,7 +135,7 @@ template<typename MatrixType,int RowFactor,int ColFactor> class Replicate
*/
template<typename Derived>
template<int RowFactor, int ColFactor>
-inline const Replicate<Derived,RowFactor,ColFactor>
+const Replicate<Derived,RowFactor,ColFactor>
DenseBase<Derived>::replicate() const
{
return Replicate<Derived,RowFactor,ColFactor>(derived());
@@ -150,7 +150,7 @@ DenseBase<Derived>::replicate() const
* \sa VectorwiseOp::replicate(), DenseBase::replicate<int,int>(), class Replicate
*/
template<typename Derived>
-inline const Replicate<Derived,Dynamic,Dynamic>
+const typename DenseBase<Derived>::ReplicateReturnType
DenseBase<Derived>::replicate(Index rowFactor,Index colFactor) const
{
return Replicate<Derived,Dynamic,Dynamic>(derived(),rowFactor,colFactor);
diff --git a/Utilities/eigen3/Eigen/src/Core/ReturnByValue.h b/Utilities/eigen3/Eigen/src/Core/ReturnByValue.h
index d66c24ba..f635598d 100644
--- a/Utilities/eigen3/Eigen/src/Core/ReturnByValue.h
+++ b/Utilities/eigen3/Eigen/src/Core/ReturnByValue.h
@@ -72,6 +72,8 @@ template<typename Derived> class ReturnByValue
const Unusable& coeff(Index,Index) const { return *reinterpret_cast<const Unusable*>(this); }
Unusable& coeffRef(Index) { return *reinterpret_cast<Unusable*>(this); }
Unusable& coeffRef(Index,Index) { return *reinterpret_cast<Unusable*>(this); }
+ template<int LoadMode> Unusable& packet(Index) const;
+ template<int LoadMode> Unusable& packet(Index, Index) const;
#endif
};
@@ -83,6 +85,15 @@ Derived& DenseBase<Derived>::operator=(const ReturnByValue<OtherDerived>& other)
return derived();
}
+template<typename Derived>
+template<typename OtherDerived>
+Derived& DenseBase<Derived>::lazyAssign(const ReturnByValue<OtherDerived>& other)
+{
+ other.evalTo(derived());
+ return derived();
+}
+
+
} // end namespace Eigen
#endif // EIGEN_RETURNBYVALUE_H
diff --git a/Utilities/eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h b/Utilities/eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h
index 22f3047b..0956475a 100644
--- a/Utilities/eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h
+++ b/Utilities/eigen3/Eigen/src/Core/SelfCwiseBinaryOp.h
@@ -180,15 +180,9 @@ inline Derived& DenseBase<Derived>::operator*=(const Scalar& other)
template<typename Derived>
inline Derived& DenseBase<Derived>::operator/=(const Scalar& other)
{
- typedef typename internal::conditional<NumTraits<Scalar>::IsInteger,
- internal::scalar_quotient_op<Scalar>,
- internal::scalar_product_op<Scalar> >::type BinOp;
typedef typename Derived::PlainObject PlainObject;
- SelfCwiseBinaryOp<BinOp, Derived, typename PlainObject::ConstantReturnType> tmp(derived());
- Scalar actual_other;
- if(NumTraits<Scalar>::IsInteger) actual_other = other;
- else actual_other = Scalar(1)/other;
- tmp = PlainObject::Constant(rows(),cols(), actual_other);
+ SelfCwiseBinaryOp<internal::scalar_quotient_op<Scalar>, Derived, typename PlainObject::ConstantReturnType> tmp(derived());
+ tmp = PlainObject::Constant(rows(),cols(), other);
return derived();
}
diff --git a/Utilities/eigen3/Eigen/src/Core/StableNorm.h b/Utilities/eigen3/Eigen/src/Core/StableNorm.h
index c83e955e..389d9427 100644
--- a/Utilities/eigen3/Eigen/src/Core/StableNorm.h
+++ b/Utilities/eigen3/Eigen/src/Core/StableNorm.h
@@ -17,16 +17,29 @@ namespace internal {
template<typename ExpressionType, typename Scalar>
inline void stable_norm_kernel(const ExpressionType& bl, Scalar& ssq, Scalar& scale, Scalar& invScale)
{
- Scalar max = bl.cwiseAbs().maxCoeff();
- if (max>scale)
+ using std::max;
+ Scalar maxCoeff = bl.cwiseAbs().maxCoeff();
+
+ if (maxCoeff>scale)
{
- ssq = ssq * numext::abs2(scale/max);
- scale = max;
- invScale = Scalar(1)/scale;
+ ssq = ssq * numext::abs2(scale/maxCoeff);
+ Scalar tmp = Scalar(1)/maxCoeff;
+ if(tmp > NumTraits<Scalar>::highest())
+ {
+ invScale = NumTraits<Scalar>::highest();
+ scale = Scalar(1)/invScale;
+ }
+ else
+ {
+ scale = maxCoeff;
+ invScale = tmp;
+ }
}
- // TODO if the max is much much smaller than the current scale,
+
+ // TODO if the maxCoeff is much much smaller than the current scale,
// then we can neglect this sub vector
- ssq += (bl*invScale).squaredNorm();
+ if(scale>Scalar(0)) // if scale==0, then bl is 0
+ ssq += (bl*invScale).squaredNorm();
}
template<typename Derived>
diff --git a/Utilities/eigen3/Eigen/src/Core/Transpose.h b/Utilities/eigen3/Eigen/src/Core/Transpose.h
index f21b3aa6..22096ea2 100644
--- a/Utilities/eigen3/Eigen/src/Core/Transpose.h
+++ b/Utilities/eigen3/Eigen/src/Core/Transpose.h
@@ -284,7 +284,8 @@ struct inplace_transpose_selector<MatrixType,false> { // non square matrix
* Notice however that this method is only useful if you want to replace a matrix by its own transpose.
* If you just need the transpose of a matrix, use transpose().
*
- * \note if the matrix is not square, then \c *this must be a resizable matrix.
+ * \note if the matrix is not square, then \c *this must be a resizable matrix.
+ * This excludes (non-square) fixed-size matrices, block-expressions and maps.
*
* \sa transpose(), adjoint(), adjointInPlace() */
template<typename Derived>
@@ -315,6 +316,7 @@ inline void DenseBase<Derived>::transposeInPlace()
* If you just need the adjoint of a matrix, use adjoint().
*
* \note if the matrix is not square, then \c *this must be a resizable matrix.
+ * This excludes (non-square) fixed-size matrices, block-expressions and maps.
*
* \sa transpose(), adjoint(), transposeInPlace() */
template<typename Derived>
diff --git a/Utilities/eigen3/Eigen/src/Core/TriangularMatrix.h b/Utilities/eigen3/Eigen/src/Core/TriangularMatrix.h
index fba07365..4d65392c 100644
--- a/Utilities/eigen3/Eigen/src/Core/TriangularMatrix.h
+++ b/Utilities/eigen3/Eigen/src/Core/TriangularMatrix.h
@@ -278,21 +278,21 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView
/** Efficient triangular matrix times vector/matrix product */
template<typename OtherDerived>
- TriangularProduct<Mode,true,MatrixType,false,OtherDerived, OtherDerived::IsVectorAtCompileTime>
+ TriangularProduct<Mode, true, MatrixType, false, OtherDerived, OtherDerived::ColsAtCompileTime==1>
operator*(const MatrixBase<OtherDerived>& rhs) const
{
return TriangularProduct
- <Mode,true,MatrixType,false,OtherDerived,OtherDerived::IsVectorAtCompileTime>
+ <Mode, true, MatrixType, false, OtherDerived, OtherDerived::ColsAtCompileTime==1>
(m_matrix, rhs.derived());
}
/** Efficient vector/matrix times triangular matrix product */
template<typename OtherDerived> friend
- TriangularProduct<Mode,false,OtherDerived,OtherDerived::IsVectorAtCompileTime,MatrixType,false>
+ TriangularProduct<Mode, false, OtherDerived, OtherDerived::RowsAtCompileTime==1, MatrixType, false>
operator*(const MatrixBase<OtherDerived>& lhs, const TriangularView& rhs)
{
return TriangularProduct
- <Mode,false,OtherDerived,OtherDerived::IsVectorAtCompileTime,MatrixType,false>
+ <Mode, false, OtherDerived, OtherDerived::RowsAtCompileTime==1, MatrixType, false>
(lhs.derived(),rhs.m_matrix);
}
@@ -380,19 +380,19 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView
EIGEN_STRONG_INLINE TriangularView& operator=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
{
setZero();
- return assignProduct(other,1);
+ return assignProduct(other.derived(),1);
}
template<typename ProductDerived, typename Lhs, typename Rhs>
EIGEN_STRONG_INLINE TriangularView& operator+=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
{
- return assignProduct(other,1);
+ return assignProduct(other.derived(),1);
}
template<typename ProductDerived, typename Lhs, typename Rhs>
EIGEN_STRONG_INLINE TriangularView& operator-=(const ProductBase<ProductDerived, Lhs,Rhs>& other)
{
- return assignProduct(other,-1);
+ return assignProduct(other.derived(),-1);
}
@@ -400,25 +400,34 @@ template<typename _MatrixType, unsigned int _Mode> class TriangularView
EIGEN_STRONG_INLINE TriangularView& operator=(const ScaledProduct<ProductDerived>& other)
{
setZero();
- return assignProduct(other,other.alpha());
+ return assignProduct(other.derived(),other.alpha());
}
template<typename ProductDerived>
EIGEN_STRONG_INLINE TriangularView& operator+=(const ScaledProduct<ProductDerived>& other)
{
- return assignProduct(other,other.alpha());
+ return assignProduct(other.derived(),other.alpha());
}
template<typename ProductDerived>
EIGEN_STRONG_INLINE TriangularView& operator-=(const ScaledProduct<ProductDerived>& other)
{
- return assignProduct(other,-other.alpha());
+ return assignProduct(other.derived(),-other.alpha());
}
protected:
template<typename ProductDerived, typename Lhs, typename Rhs>
EIGEN_STRONG_INLINE TriangularView& assignProduct(const ProductBase<ProductDerived, Lhs,Rhs>& prod, const Scalar& alpha);
+
+ template<int Mode, bool LhsIsTriangular,
+ typename Lhs, bool LhsIsVector,
+ typename Rhs, bool RhsIsVector>
+ EIGEN_STRONG_INLINE TriangularView& assignProduct(const TriangularProduct<Mode, LhsIsTriangular, Lhs, LhsIsVector, Rhs, RhsIsVector>& prod, const Scalar& alpha)
+ {
+ lazyAssign(alpha*prod.eval());
+ return *this;
+ }
MatrixTypeNested m_matrix;
};
diff --git a/Utilities/eigen3/Eigen/src/Core/VectorwiseOp.h b/Utilities/eigen3/Eigen/src/Core/VectorwiseOp.h
index f447434a..d5ab0366 100644
--- a/Utilities/eigen3/Eigen/src/Core/VectorwiseOp.h
+++ b/Utilities/eigen3/Eigen/src/Core/VectorwiseOp.h
@@ -50,7 +50,7 @@ struct traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
MaxColsAtCompileTime = Direction==Horizontal ? 1 : MatrixType::MaxColsAtCompileTime,
Flags0 = (unsigned int)_MatrixTypeNested::Flags & HereditaryBits,
Flags = (Flags0 & ~RowMajorBit) | (RowsAtCompileTime == 1 ? RowMajorBit : 0),
- TraversalSize = Direction==Vertical ? RowsAtCompileTime : ColsAtCompileTime
+ TraversalSize = Direction==Vertical ? MatrixType::RowsAtCompileTime : MatrixType::ColsAtCompileTime
};
#if EIGEN_GNUC_AT_LEAST(3,4)
typedef typename MemberOp::template Cost<InputScalar,int(TraversalSize)> CostOpType;
@@ -58,7 +58,8 @@ struct traits<PartialReduxExpr<MatrixType, MemberOp, Direction> >
typedef typename MemberOp::template Cost<InputScalar,TraversalSize> CostOpType;
#endif
enum {
- CoeffReadCost = TraversalSize * traits<_MatrixTypeNested>::CoeffReadCost + int(CostOpType::value)
+ CoeffReadCost = TraversalSize==Dynamic ? Dynamic
+ : TraversalSize * traits<_MatrixTypeNested>::CoeffReadCost + int(CostOpType::value)
};
};
}
@@ -581,11 +582,6 @@ template<typename ExpressionType, int Direction> class VectorwiseOp
HNormalizedReturnType;
const HNormalizedReturnType hnormalized() const;
-
- // allow to extend VectorOp outside Eigen
- #ifdef EIGEN_VECTOROP_PLUGIN
- #include EIGEN_VECTOROP_PLUGIN
- #endif
protected:
ExpressionTypeNested m_matrix;
diff --git a/Utilities/eigen3/Eigen/src/Core/arch/NEON/Complex.h b/Utilities/eigen3/Eigen/src/Core/arch/NEON/Complex.h
index f183d31d..8d9255ee 100644
--- a/Utilities/eigen3/Eigen/src/Core/arch/NEON/Complex.h
+++ b/Utilities/eigen3/Eigen/src/Core/arch/NEON/Complex.h
@@ -110,7 +110,7 @@ template<> EIGEN_STRONG_INLINE Packet2cf ploaddup<Packet2cf>(const std::complex<
template<> EIGEN_STRONG_INLINE void pstore <std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_ALIGNED_STORE pstore((float*)to, from.v); }
template<> EIGEN_STRONG_INLINE void pstoreu<std::complex<float> >(std::complex<float> * to, const Packet2cf& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((float*)to, from.v); }
-template<> EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::complex<float> * addr) { __pld((float *)addr); }
+template<> EIGEN_STRONG_INLINE void prefetch<std::complex<float> >(const std::complex<float> * addr) { EIGEN_ARM_PREFETCH((float *)addr); }
template<> EIGEN_STRONG_INLINE std::complex<float> pfirst<Packet2cf>(const Packet2cf& a)
{
diff --git a/Utilities/eigen3/Eigen/src/Core/arch/NEON/PacketMath.h b/Utilities/eigen3/Eigen/src/Core/arch/NEON/PacketMath.h
index 163bac21..d49670e0 100644
--- a/Utilities/eigen3/Eigen/src/Core/arch/NEON/PacketMath.h
+++ b/Utilities/eigen3/Eigen/src/Core/arch/NEON/PacketMath.h
@@ -48,9 +48,18 @@ typedef uint32x4_t Packet4ui;
#define EIGEN_INIT_NEON_PACKET2(X, Y) {X, Y}
#define EIGEN_INIT_NEON_PACKET4(X, Y, Z, W) {X, Y, Z, W}
#endif
-
-#ifndef __pld
-#define __pld(x) asm volatile ( " pld [%[addr]]\n" :: [addr] "r" (x) : "cc" );
+
+// arm64 does have the pld instruction. If available, let's trust the __builtin_prefetch built-in function
+// which available on LLVM and GCC (at least)
+#if EIGEN_HAS_BUILTIN(__builtin_prefetch) || defined(__GNUC__)
+ #define EIGEN_ARM_PREFETCH(ADDR) __builtin_prefetch(ADDR);
+#elif defined __pld
+ #define EIGEN_ARM_PREFETCH(ADDR) __pld(ADDR)
+#elif !defined(__aarch64__)
+ #define EIGEN_ARM_PREFETCH(ADDR) __asm__ __volatile__ ( " pld [%[addr]]\n" :: [addr] "r" (ADDR) : "cc" );
+#else
+ // by default no explicit prefetching
+ #define EIGEN_ARM_PREFETCH(ADDR)
#endif
template<> struct packet_traits<float> : default_packet_traits
@@ -209,8 +218,8 @@ template<> EIGEN_STRONG_INLINE void pstore<int>(int* to, const Packet4i& f
template<> EIGEN_STRONG_INLINE void pstoreu<float>(float* to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_f32(to, from); }
template<> EIGEN_STRONG_INLINE void pstoreu<int>(int* to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE vst1q_s32(to, from); }
-template<> EIGEN_STRONG_INLINE void prefetch<float>(const float* addr) { __pld(addr); }
-template<> EIGEN_STRONG_INLINE void prefetch<int>(const int* addr) { __pld(addr); }
+template<> EIGEN_STRONG_INLINE void prefetch<float>(const float* addr) { EIGEN_ARM_PREFETCH(addr); }
+template<> EIGEN_STRONG_INLINE void prefetch<int>(const int* addr) { EIGEN_ARM_PREFETCH(addr); }
// FIXME only store the 2 first elements ?
template<> EIGEN_STRONG_INLINE float pfirst<Packet4f>(const Packet4f& a) { float EIGEN_ALIGN16 x[4]; vst1q_f32(x, a); return x[0]; }
@@ -375,6 +384,7 @@ template<> EIGEN_STRONG_INLINE int predux_max<Packet4i>(const Packet4i& a)
a_lo = vget_low_s32(a);
a_hi = vget_high_s32(a);
max = vpmax_s32(a_lo, a_hi);
+ max = vpmax_s32(max, max);
return vget_lane_s32(max, 0);
}
diff --git a/Utilities/eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h b/Utilities/eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h
index 3376a984..2b07168a 100644
--- a/Utilities/eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h
+++ b/Utilities/eigen3/Eigen/src/Core/arch/SSE/MathFunctions.h
@@ -52,7 +52,7 @@ Packet4f plog<Packet4f>(const Packet4f& _x)
Packet4i emm0;
- Packet4f invalid_mask = _mm_cmplt_ps(x, _mm_setzero_ps());
+ Packet4f invalid_mask = _mm_cmpnge_ps(x, _mm_setzero_ps()); // not greater equal is true if x is NaN
Packet4f iszero_mask = _mm_cmpeq_ps(x, _mm_setzero_ps());
x = pmax(x, p4f_min_norm_pos); /* cut off denormalized stuff */
@@ -126,7 +126,7 @@ Packet4f pexp<Packet4f>(const Packet4f& _x)
_EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p4, 1.6666665459E-1f);
_EIGEN_DECLARE_CONST_Packet4f(cephes_exp_p5, 5.0000001201E-1f);
- Packet4f tmp = _mm_setzero_ps(), fx;
+ Packet4f tmp, fx;
Packet4i emm0;
// clamp x
@@ -166,7 +166,7 @@ Packet4f pexp<Packet4f>(const Packet4f& _x)
emm0 = _mm_cvttps_epi32(fx);
emm0 = _mm_add_epi32(emm0, p4i_0x7f);
emm0 = _mm_slli_epi32(emm0, 23);
- return pmul(y, _mm_castsi128_ps(emm0));
+ return pmax(pmul(y, Packet4f(_mm_castsi128_ps(emm0))), _x);
}
template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED
Packet2d pexp<Packet2d>(const Packet2d& _x)
@@ -195,7 +195,7 @@ Packet2d pexp<Packet2d>(const Packet2d& _x)
_EIGEN_DECLARE_CONST_Packet2d(cephes_exp_C2, 1.42860682030941723212e-6);
static const __m128i p4i_1023_0 = _mm_setr_epi32(1023, 1023, 0, 0);
- Packet2d tmp = _mm_setzero_pd(), fx;
+ Packet2d tmp, fx;
Packet4i emm0;
// clamp x
@@ -239,7 +239,7 @@ Packet2d pexp<Packet2d>(const Packet2d& _x)
emm0 = _mm_add_epi32(emm0, p4i_1023_0);
emm0 = _mm_slli_epi32(emm0, 20);
emm0 = _mm_shuffle_epi32(emm0, _MM_SHUFFLE(1,2,0,3));
- return pmul(x, _mm_castsi128_pd(emm0));
+ return pmax(pmul(x, Packet2d(_mm_castsi128_pd(emm0))), _x);
}
/* evaluation of 4 sines at onces, using SSE2 intrinsics.
@@ -279,7 +279,7 @@ Packet4f psin<Packet4f>(const Packet4f& _x)
_EIGEN_DECLARE_CONST_Packet4f(coscof_p2, 4.166664568298827E-002f);
_EIGEN_DECLARE_CONST_Packet4f(cephes_FOPI, 1.27323954473516f); // 4 / M_PI
- Packet4f xmm1, xmm2 = _mm_setzero_ps(), xmm3, sign_bit, y;
+ Packet4f xmm1, xmm2, xmm3, sign_bit, y;
Packet4i emm0, emm2;
sign_bit = x;
@@ -378,7 +378,7 @@ Packet4f pcos<Packet4f>(const Packet4f& _x)
_EIGEN_DECLARE_CONST_Packet4f(coscof_p2, 4.166664568298827E-002f);
_EIGEN_DECLARE_CONST_Packet4f(cephes_FOPI, 1.27323954473516f); // 4 / M_PI
- Packet4f xmm1, xmm2 = _mm_setzero_ps(), xmm3, y;
+ Packet4f xmm1, xmm2, xmm3, y;
Packet4i emm0, emm2;
x = pabs(x);
@@ -442,8 +442,11 @@ Packet4f pcos<Packet4f>(const Packet4f& _x)
return _mm_xor_ps(y, sign_bit);
}
+#if EIGEN_FAST_MATH
+
// This is based on Quake3's fast inverse square root.
// For detail see here: http://www.beyond3d.com/content/articles/8/
+// It lacks 1 (or 2 bits in some rare cases) of precision, and does not handle negative, +inf, or denormalized numbers correctly.
template<> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS EIGEN_UNUSED
Packet4f psqrt<Packet4f>(const Packet4f& _x)
{
@@ -457,6 +460,14 @@ Packet4f psqrt<Packet4f>(const Packet4f& _x)
return pmul(_x,x);
}
+#else
+
+template<> EIGEN_STRONG_INLINE Packet4f psqrt<Packet4f>(const Packet4f& x) { return _mm_sqrt_ps(x); }
+
+#endif
+
+template<> EIGEN_STRONG_INLINE Packet2d psqrt<Packet2d>(const Packet2d& x) { return _mm_sqrt_pd(x); }
+
} // end namespace internal
} // end namespace Eigen
diff --git a/Utilities/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h b/Utilities/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h
index e256f4ba..fc8ae50f 100644
--- a/Utilities/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h
+++ b/Utilities/eigen3/Eigen/src/Core/arch/SSE/PacketMath.h
@@ -83,7 +83,8 @@ template<> struct packet_traits<double> : default_packet_traits
size=2,
HasDiv = 1,
- HasExp = 1
+ HasExp = 1,
+ HasSqrt = 1
};
};
template<> struct packet_traits<int> : default_packet_traits
@@ -507,8 +508,8 @@ template<> EIGEN_STRONG_INLINE int predux_min<Packet4i>(const Packet4i& a)
// for GCC (eg., it does not like using std::min after the pstore !!)
EIGEN_ALIGN16 int aux[4];
pstore(aux, a);
- register int aux0 = aux[0]<aux[1] ? aux[0] : aux[1];
- register int aux2 = aux[2]<aux[3] ? aux[2] : aux[3];
+ int aux0 = aux[0]<aux[1] ? aux[0] : aux[1];
+ int aux2 = aux[2]<aux[3] ? aux[2] : aux[3];
return aux0<aux2 ? aux0 : aux2;
}
@@ -528,8 +529,8 @@ template<> EIGEN_STRONG_INLINE int predux_max<Packet4i>(const Packet4i& a)
// for GCC (eg., it does not like using std::min after the pstore !!)
EIGEN_ALIGN16 int aux[4];
pstore(aux, a);
- register int aux0 = aux[0]>aux[1] ? aux[0] : aux[1];
- register int aux2 = aux[2]>aux[3] ? aux[2] : aux[3];
+ int aux0 = aux[0]>aux[1] ? aux[0] : aux[1];
+ int aux2 = aux[2]>aux[3] ? aux[2] : aux[3];
return aux0>aux2 ? aux0 : aux2;
}
diff --git a/Utilities/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h b/Utilities/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h
index c06a0df1..2a9d65b9 100644
--- a/Utilities/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h
+++ b/Utilities/eigen3/Eigen/src/Core/products/CoeffBasedProduct.h
@@ -90,6 +90,7 @@ struct traits<CoeffBasedProduct<LhsNested,RhsNested,NestingFlags> >
| (SameType && (CanVectorizeLhs || CanVectorizeRhs) ? PacketAccessBit : 0),
CoeffReadCost = InnerSize == Dynamic ? Dynamic
+ : InnerSize == 0 ? 0
: InnerSize * (NumTraits<Scalar>::MulCost + LhsCoeffReadCost + RhsCoeffReadCost)
+ (InnerSize - 1) * NumTraits<Scalar>::AddCost,
@@ -133,7 +134,7 @@ class CoeffBasedProduct
};
typedef internal::product_coeff_impl<CanVectorizeInner ? InnerVectorizedTraversal : DefaultTraversal,
- Unroll ? InnerSize-1 : Dynamic,
+ Unroll ? InnerSize : Dynamic,
_LhsNested, _RhsNested, Scalar> ScalarCoeffImpl;
typedef CoeffBasedProduct<LhsNested,RhsNested,NestByRefBit> LazyCoeffBasedProductType;
@@ -184,7 +185,7 @@ class CoeffBasedProduct
{
PacketScalar res;
internal::product_packet_impl<Flags&RowMajorBit ? RowMajor : ColMajor,
- Unroll ? InnerSize-1 : Dynamic,
+ Unroll ? InnerSize : Dynamic,
_LhsNested, _RhsNested, PacketScalar, LoadMode>
::run(row, col, m_lhs, m_rhs, res);
return res;
@@ -242,12 +243,12 @@ struct product_coeff_impl<DefaultTraversal, UnrollingIndex, Lhs, Rhs, RetScalar>
static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar &res)
{
product_coeff_impl<DefaultTraversal, UnrollingIndex-1, Lhs, Rhs, RetScalar>::run(row, col, lhs, rhs, res);
- res += lhs.coeff(row, UnrollingIndex) * rhs.coeff(UnrollingIndex, col);
+ res += lhs.coeff(row, UnrollingIndex-1) * rhs.coeff(UnrollingIndex-1, col);
}
};
template<typename Lhs, typename Rhs, typename RetScalar>
-struct product_coeff_impl<DefaultTraversal, 0, Lhs, Rhs, RetScalar>
+struct product_coeff_impl<DefaultTraversal, 1, Lhs, Rhs, RetScalar>
{
typedef typename Lhs::Index Index;
static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar &res)
@@ -256,16 +257,23 @@ struct product_coeff_impl<DefaultTraversal, 0, Lhs, Rhs, RetScalar>
}
};
+template<typename Lhs, typename Rhs, typename RetScalar>
+struct product_coeff_impl<DefaultTraversal, 0, Lhs, Rhs, RetScalar>
+{
+ typedef typename Lhs::Index Index;
+ static EIGEN_STRONG_INLINE void run(Index /*row*/, Index /*col*/, const Lhs& /*lhs*/, const Rhs& /*rhs*/, RetScalar &res)
+ {
+ res = RetScalar(0);
+ }
+};
+
template<typename Lhs, typename Rhs, typename RetScalar>
struct product_coeff_impl<DefaultTraversal, Dynamic, Lhs, Rhs, RetScalar>
{
typedef typename Lhs::Index Index;
static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar& res)
{
- eigen_assert(lhs.cols()>0 && "you are using a non initialized matrix");
- res = lhs.coeff(row, 0) * rhs.coeff(0, col);
- for(Index i = 1; i < lhs.cols(); ++i)
- res += lhs.coeff(row, i) * rhs.coeff(i, col);
+ res = (lhs.row(row).transpose().cwiseProduct( rhs.col(col) )).sum();
}
};
@@ -295,6 +303,16 @@ struct product_coeff_vectorized_unroller<0, Lhs, Rhs, Packet>
}
};
+template<typename Lhs, typename Rhs, typename RetScalar>
+struct product_coeff_impl<InnerVectorizedTraversal, 0, Lhs, Rhs, RetScalar>
+{
+ typedef typename Lhs::Index Index;
+ static EIGEN_STRONG_INLINE void run(Index /*row*/, Index /*col*/, const Lhs& /*lhs*/, const Rhs& /*rhs*/, RetScalar &res)
+ {
+ res = 0;
+ }
+};
+
template<int UnrollingIndex, typename Lhs, typename Rhs, typename RetScalar>
struct product_coeff_impl<InnerVectorizedTraversal, UnrollingIndex, Lhs, Rhs, RetScalar>
{
@@ -304,8 +322,7 @@ struct product_coeff_impl<InnerVectorizedTraversal, UnrollingIndex, Lhs, Rhs, Re
static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, RetScalar &res)
{
Packet pres;
- product_coeff_vectorized_unroller<UnrollingIndex+1-PacketSize, Lhs, Rhs, Packet>::run(row, col, lhs, rhs, pres);
- product_coeff_impl<DefaultTraversal,UnrollingIndex,Lhs,Rhs,RetScalar>::run(row, col, lhs, rhs, res);
+ product_coeff_vectorized_unroller<UnrollingIndex-PacketSize, Lhs, Rhs, Packet>::run(row, col, lhs, rhs, pres);
res = predux(pres);
}
};
@@ -373,7 +390,7 @@ struct product_packet_impl<RowMajor, UnrollingIndex, Lhs, Rhs, Packet, LoadMode>
static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res)
{
product_packet_impl<RowMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, res);
- res = pmadd(pset1<Packet>(lhs.coeff(row, UnrollingIndex)), rhs.template packet<LoadMode>(UnrollingIndex, col), res);
+ res = pmadd(pset1<Packet>(lhs.coeff(row, UnrollingIndex-1)), rhs.template packet<LoadMode>(UnrollingIndex-1, col), res);
}
};
@@ -384,12 +401,12 @@ struct product_packet_impl<ColMajor, UnrollingIndex, Lhs, Rhs, Packet, LoadMode>
static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res)
{
product_packet_impl<ColMajor, UnrollingIndex-1, Lhs, Rhs, Packet, LoadMode>::run(row, col, lhs, rhs, res);
- res = pmadd(lhs.template packet<LoadMode>(row, UnrollingIndex), pset1<Packet>(rhs.coeff(UnrollingIndex, col)), res);
+ res = pmadd(lhs.template packet<LoadMode>(row, UnrollingIndex-1), pset1<Packet>(rhs.coeff(UnrollingIndex-1, col)), res);
}
};
template<typename Lhs, typename Rhs, typename Packet, int LoadMode>
-struct product_packet_impl<RowMajor, 0, Lhs, Rhs, Packet, LoadMode>
+struct product_packet_impl<RowMajor, 1, Lhs, Rhs, Packet, LoadMode>
{
typedef typename Lhs::Index Index;
static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res)
@@ -399,7 +416,7 @@ struct product_packet_impl<RowMajor, 0, Lhs, Rhs, Packet, LoadMode>
};
template<typename Lhs, typename Rhs, typename Packet, int LoadMode>
-struct product_packet_impl<ColMajor, 0, Lhs, Rhs, Packet, LoadMode>
+struct product_packet_impl<ColMajor, 1, Lhs, Rhs, Packet, LoadMode>
{
typedef typename Lhs::Index Index;
static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet &res)
@@ -408,16 +425,35 @@ struct product_packet_impl<ColMajor, 0, Lhs, Rhs, Packet, LoadMode>
}
};
+template<typename Lhs, typename Rhs, typename Packet, int LoadMode>
+struct product_packet_impl<RowMajor, 0, Lhs, Rhs, Packet, LoadMode>
+{
+ typedef typename Lhs::Index Index;
+ static EIGEN_STRONG_INLINE void run(Index /*row*/, Index /*col*/, const Lhs& /*lhs*/, const Rhs& /*rhs*/, Packet &res)
+ {
+ res = pset1<Packet>(0);
+ }
+};
+
+template<typename Lhs, typename Rhs, typename Packet, int LoadMode>
+struct product_packet_impl<ColMajor, 0, Lhs, Rhs, Packet, LoadMode>
+{
+ typedef typename Lhs::Index Index;
+ static EIGEN_STRONG_INLINE void run(Index /*row*/, Index /*col*/, const Lhs& /*lhs*/, const Rhs& /*rhs*/, Packet &res)
+ {
+ res = pset1<Packet>(0);
+ }
+};
+
template<typename Lhs, typename Rhs, typename Packet, int LoadMode>
struct product_packet_impl<RowMajor, Dynamic, Lhs, Rhs, Packet, LoadMode>
{
typedef typename Lhs::Index Index;
static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet& res)
{
- eigen_assert(lhs.cols()>0 && "you are using a non initialized matrix");
- res = pmul(pset1<Packet>(lhs.coeff(row, 0)),rhs.template packet<LoadMode>(0, col));
- for(Index i = 1; i < lhs.cols(); ++i)
- res = pmadd(pset1<Packet>(lhs.coeff(row, i)), rhs.template packet<LoadMode>(i, col), res);
+ res = pset1<Packet>(0);
+ for(Index i = 0; i < lhs.cols(); ++i)
+ res = pmadd(pset1<Packet>(lhs.coeff(row, i)), rhs.template packet<LoadMode>(i, col), res);
}
};
@@ -427,10 +463,9 @@ struct product_packet_impl<ColMajor, Dynamic, Lhs, Rhs, Packet, LoadMode>
typedef typename Lhs::Index Index;
static EIGEN_STRONG_INLINE void run(Index row, Index col, const Lhs& lhs, const Rhs& rhs, Packet& res)
{
- eigen_assert(lhs.cols()>0 && "you are using a non initialized matrix");
- res = pmul(lhs.template packet<LoadMode>(row, 0), pset1<Packet>(rhs.coeff(0, col)));
- for(Index i = 1; i < lhs.cols(); ++i)
- res = pmadd(lhs.template packet<LoadMode>(row, i), pset1<Packet>(rhs.coeff(i, col)), res);
+ res = pset1<Packet>(0);
+ for(Index i = 0; i < lhs.cols(); ++i)
+ res = pmadd(lhs.template packet<LoadMode>(row, i), pset1<Packet>(rhs.coeff(i, col)), res);
}
};
diff --git a/Utilities/eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h b/Utilities/eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h
index 780fa74d..bcdca5b0 100644
--- a/Utilities/eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h
+++ b/Utilities/eigen3/Eigen/src/Core/products/GeneralBlockPanelKernel.h
@@ -1128,6 +1128,8 @@ EIGEN_DONT_INLINE void gemm_pack_lhs<Scalar, Index, Pack1, Pack2, StorageOrder,
enum { PacketSize = packet_traits<Scalar>::size };
EIGEN_ASM_COMMENT("EIGEN PRODUCT PACK LHS");
+ EIGEN_UNUSED_VARIABLE(stride)
+ EIGEN_UNUSED_VARIABLE(offset)
eigen_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride));
eigen_assert( (StorageOrder==RowMajor) || ((Pack1%PacketSize)==0 && Pack1<=4*PacketSize) );
conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj;
@@ -1215,6 +1217,8 @@ EIGEN_DONT_INLINE void gemm_pack_rhs<Scalar, Index, nr, ColMajor, Conjugate, Pan
::operator()(Scalar* blockB, const Scalar* rhs, Index rhsStride, Index depth, Index cols, Index stride, Index offset)
{
EIGEN_ASM_COMMENT("EIGEN PRODUCT PACK RHS COLMAJOR");
+ EIGEN_UNUSED_VARIABLE(stride)
+ EIGEN_UNUSED_VARIABLE(offset)
eigen_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride));
conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj;
Index packet_cols = (cols/nr) * nr;
@@ -1266,6 +1270,8 @@ EIGEN_DONT_INLINE void gemm_pack_rhs<Scalar, Index, nr, RowMajor, Conjugate, Pan
::operator()(Scalar* blockB, const Scalar* rhs, Index rhsStride, Index depth, Index cols, Index stride, Index offset)
{
EIGEN_ASM_COMMENT("EIGEN PRODUCT PACK RHS ROWMAJOR");
+ EIGEN_UNUSED_VARIABLE(stride)
+ EIGEN_UNUSED_VARIABLE(offset)
eigen_assert(((!PanelMode) && stride==0 && offset==0) || (PanelMode && stride>=depth && offset<=stride));
conj_if<NumTraits<Scalar>::IsComplex && Conjugate> cj;
Index packet_cols = (cols/nr) * nr;
diff --git a/Utilities/eigen3/Eigen/src/Core/products/GeneralMatrixVector.h b/Utilities/eigen3/Eigen/src/Core/products/GeneralMatrixVector.h
index c1cb7849..09387703 100644
--- a/Utilities/eigen3/Eigen/src/Core/products/GeneralMatrixVector.h
+++ b/Utilities/eigen3/Eigen/src/Core/products/GeneralMatrixVector.h
@@ -52,11 +52,7 @@ EIGEN_DONT_INLINE static void run(
Index rows, Index cols,
const LhsScalar* lhs, Index lhsStride,
const RhsScalar* rhs, Index rhsIncr,
- ResScalar* res, Index
- #ifdef EIGEN_INTERNAL_DEBUGGING
- resIncr
- #endif
- , RhsScalar alpha);
+ ResScalar* res, Index resIncr, RhsScalar alpha);
};
template<typename Index, typename LhsScalar, bool ConjugateLhs, typename RhsScalar, bool ConjugateRhs, int Version>
@@ -64,12 +60,9 @@ EIGEN_DONT_INLINE void general_matrix_vector_product<Index,LhsScalar,ColMajor,Co
Index rows, Index cols,
const LhsScalar* lhs, Index lhsStride,
const RhsScalar* rhs, Index rhsIncr,
- ResScalar* res, Index
- #ifdef EIGEN_INTERNAL_DEBUGGING
- resIncr
- #endif
- , RhsScalar alpha)
+ ResScalar* res, Index resIncr, RhsScalar alpha)
{
+ EIGEN_UNUSED_VARIABLE(resIncr)
eigen_internal_assert(resIncr==1);
#ifdef _EIGEN_ACCUMULATE_PACKETS
#error _EIGEN_ACCUMULATE_PACKETS has already been defined
@@ -265,7 +258,7 @@ EIGEN_DONT_INLINE void general_matrix_vector_product<Index,LhsScalar,ColMajor,Co
// process aligned result's coeffs
if ((size_t(lhs0+alignedStart)%sizeof(LhsPacket))==0)
for (Index i = alignedStart;i<alignedSize;i+=ResPacketSize)
- pstore(&res[i], pcj.pmadd(ploadu<LhsPacket>(&lhs0[i]), ptmp0, pload<ResPacket>(&res[i])));
+ pstore(&res[i], pcj.pmadd(pload<LhsPacket>(&lhs0[i]), ptmp0, pload<ResPacket>(&res[i])));
else
for (Index i = alignedStart;i<alignedSize;i+=ResPacketSize)
pstore(&res[i], pcj.pmadd(ploadu<LhsPacket>(&lhs0[i]), ptmp0, pload<ResPacket>(&res[i])));
diff --git a/Utilities/eigen3/Eigen/src/Core/products/Parallelizer.h b/Utilities/eigen3/Eigen/src/Core/products/Parallelizer.h
index 5c3e9b7a..6937ee33 100644
--- a/Utilities/eigen3/Eigen/src/Core/products/Parallelizer.h
+++ b/Utilities/eigen3/Eigen/src/Core/products/Parallelizer.h
@@ -125,19 +125,22 @@ void parallelize_gemm(const Functor& func, Index rows, Index cols, bool transpos
if(transpose)
std::swap(rows,cols);
- Index blockCols = (cols / threads) & ~Index(0x3);
- Index blockRows = (rows / threads) & ~Index(0x7);
-
GemmParallelInfo<Index>* info = new GemmParallelInfo<Index>[threads];
- #pragma omp parallel for schedule(static,1) num_threads(threads)
- for(Index i=0; i<threads; ++i)
+ #pragma omp parallel num_threads(threads)
{
+ Index i = omp_get_thread_num();
+ // Note that the actual number of threads might be lower than the number of request ones.
+ Index actual_threads = omp_get_num_threads();
+
+ Index blockCols = (cols / actual_threads) & ~Index(0x3);
+ Index blockRows = (rows / actual_threads) & ~Index(0x7);
+
Index r0 = i*blockRows;
- Index actualBlockRows = (i+1==threads) ? rows-r0 : blockRows;
+ Index actualBlockRows = (i+1==actual_threads) ? rows-r0 : blockRows;
Index c0 = i*blockCols;
- Index actualBlockCols = (i+1==threads) ? cols-c0 : blockCols;
+ Index actualBlockCols = (i+1==actual_threads) ? cols-c0 : blockCols;
info[i].rhs_start = c0;
info[i].rhs_length = actualBlockCols;
diff --git a/Utilities/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h b/Utilities/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h
index c40e80f5..f698f67f 100644
--- a/Utilities/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h
+++ b/Utilities/eigen3/Eigen/src/Core/products/SelfadjointMatrixVector.h
@@ -79,8 +79,8 @@ EIGEN_DONT_INLINE void selfadjoint_matrix_vector_product<Scalar,Index,StorageOrd
for (Index j=FirstTriangular ? bound : 0;
j<(FirstTriangular ? size : bound);j+=2)
{
- register const Scalar* EIGEN_RESTRICT A0 = lhs + j*lhsStride;
- register const Scalar* EIGEN_RESTRICT A1 = lhs + (j+1)*lhsStride;
+ const Scalar* EIGEN_RESTRICT A0 = lhs + j*lhsStride;
+ const Scalar* EIGEN_RESTRICT A1 = lhs + (j+1)*lhsStride;
Scalar t0 = cjAlpha * rhs[j];
Packet ptmp0 = pset1<Packet>(t0);
@@ -147,7 +147,7 @@ EIGEN_DONT_INLINE void selfadjoint_matrix_vector_product<Scalar,Index,StorageOrd
}
for (Index j=FirstTriangular ? 0 : bound;j<(FirstTriangular ? bound : size);j++)
{
- register const Scalar* EIGEN_RESTRICT A0 = lhs + j*lhsStride;
+ const Scalar* EIGEN_RESTRICT A0 = lhs + j*lhsStride;
Scalar t1 = cjAlpha * rhs[j];
Scalar t2(0);
diff --git a/Utilities/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h b/Utilities/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h
index ba41a1c9..4cc56a42 100644
--- a/Utilities/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h
+++ b/Utilities/eigen3/Eigen/src/Core/products/TriangularMatrixMatrix_MKL.h
@@ -109,7 +109,7 @@ struct product_triangular_matrix_matrix_trmm<EIGTYPE,Index,Mode,true, \
/* Non-square case - doesn't fit to MKL ?TRMM. Fall to default triangular product or call MKL ?GEMM*/ \
if (rows != depth) { \
\
- int nthr = mkl_domain_get_max_threads(MKL_BLAS); \
+ int nthr = mkl_domain_get_max_threads(EIGEN_MKL_DOMAIN_BLAS); \
\
if (((nthr==1) && (((std::max)(rows,depth)-diagSize)/(double)diagSize < 0.5))) { \
/* Most likely no benefit to call TRMM or GEMM from MKL*/ \
@@ -223,7 +223,7 @@ struct product_triangular_matrix_matrix_trmm<EIGTYPE,Index,Mode,false, \
/* Non-square case - doesn't fit to MKL ?TRMM. Fall to default triangular product or call MKL ?GEMM*/ \
if (cols != depth) { \
\
- int nthr = mkl_domain_get_max_threads(MKL_BLAS); \
+ int nthr = mkl_domain_get_max_threads(EIGEN_MKL_DOMAIN_BLAS); \
\
if ((nthr==1) && (((std::max)(cols,depth)-diagSize)/(double)diagSize < 0.5)) { \
/* Most likely no benefit to call TRMM or GEMM from MKL*/ \
diff --git a/Utilities/eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h b/Utilities/eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h
index f103eae7..04240ab5 100644
--- a/Utilities/eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h
+++ b/Utilities/eigen3/Eigen/src/Core/products/TriangularSolverMatrix.h
@@ -302,9 +302,12 @@ EIGEN_DONT_INLINE void triangular_solve_matrix<Scalar,Index,OnTheRight,Mode,Conj
for (Index i=0; i<actual_mc; ++i)
r[i] -= a[i] * b;
}
- Scalar b = (Mode & UnitDiag) ? Scalar(1) : Scalar(1)/conj(rhs(j,j));
- for (Index i=0; i<actual_mc; ++i)
- r[i] *= b;
+ if((Mode & UnitDiag)==0)
+ {
+ Scalar b = conj(rhs(j,j));
+ for (Index i=0; i<actual_mc; ++i)
+ r[i] /= b;
+ }
}
// pack the just computed part of lhs to A
diff --git a/Utilities/eigen3/Eigen/src/Core/util/Constants.h b/Utilities/eigen3/Eigen/src/Core/util/Constants.h
index 14b9624e..1e6277c4 100644
--- a/Utilities/eigen3/Eigen/src/Core/util/Constants.h
+++ b/Utilities/eigen3/Eigen/src/Core/util/Constants.h
@@ -433,6 +433,19 @@ struct MatrixXpr {};
/** The type used to identify an array expression */
struct ArrayXpr {};
+namespace internal {
+ /** \internal
+ * Constants for comparison functors
+ */
+ enum ComparisonName {
+ cmp_EQ = 0,
+ cmp_LT = 1,
+ cmp_LE = 2,
+ cmp_UNORD = 3,
+ cmp_NEQ = 4
+ };
+}
+
} // end namespace Eigen
#endif // EIGEN_CONSTANTS_H
diff --git a/Utilities/eigen3/Eigen/src/Core/util/ForwardDeclarations.h b/Utilities/eigen3/Eigen/src/Core/util/ForwardDeclarations.h
index d6a81458..f2777200 100644
--- a/Utilities/eigen3/Eigen/src/Core/util/ForwardDeclarations.h
+++ b/Utilities/eigen3/Eigen/src/Core/util/ForwardDeclarations.h
@@ -235,6 +235,9 @@ template<typename Scalar> class Rotation2D;
template<typename Scalar> class AngleAxis;
template<typename Scalar,int Dim> class Translation;
+// Sparse module:
+template<typename Derived> class SparseMatrixBase;
+
#ifdef EIGEN2_SUPPORT
template<typename Derived, int _Dim> class eigen2_RotationBase;
template<typename Lhs, typename Rhs> class eigen2_Cross;
diff --git a/Utilities/eigen3/Eigen/src/Core/util/MKL_support.h b/Utilities/eigen3/Eigen/src/Core/util/MKL_support.h
index 1e6e355d..1ef3b61d 100644
--- a/Utilities/eigen3/Eigen/src/Core/util/MKL_support.h
+++ b/Utilities/eigen3/Eigen/src/Core/util/MKL_support.h
@@ -54,11 +54,60 @@
#endif
#if defined EIGEN_USE_MKL
+# include <mkl.h>
+/*Check IMKL version for compatibility: < 10.3 is not usable with Eigen*/
+# ifndef INTEL_MKL_VERSION
+# undef EIGEN_USE_MKL /* INTEL_MKL_VERSION is not even defined on older versions */
+# elif INTEL_MKL_VERSION < 100305 /* the intel-mkl-103-release-notes say this was when the lapacke.h interface was added*/
+# undef EIGEN_USE_MKL
+# endif
+# ifndef EIGEN_USE_MKL
+ /*If the MKL version is too old, undef everything*/
+# undef EIGEN_USE_MKL_ALL
+# undef EIGEN_USE_BLAS
+# undef EIGEN_USE_LAPACKE
+# undef EIGEN_USE_MKL_VML
+# undef EIGEN_USE_LAPACKE_STRICT
+# undef EIGEN_USE_LAPACKE
+# endif
+#endif
-#include <mkl.h>
+#if defined EIGEN_USE_MKL
#include <mkl_lapacke.h>
#define EIGEN_MKL_VML_THRESHOLD 128
+/* MKL_DOMAIN_BLAS, etc are defined only in 10.3 update 7 */
+/* MKL_BLAS, etc are not defined in 11.2 */
+#ifdef MKL_DOMAIN_ALL
+#define EIGEN_MKL_DOMAIN_ALL MKL_DOMAIN_ALL
+#else
+#define EIGEN_MKL_DOMAIN_ALL MKL_ALL
+#endif
+
+#ifdef MKL_DOMAIN_BLAS
+#define EIGEN_MKL_DOMAIN_BLAS MKL_DOMAIN_BLAS
+#else
+#define EIGEN_MKL_DOMAIN_BLAS MKL_BLAS
+#endif
+
+#ifdef MKL_DOMAIN_FFT
+#define EIGEN_MKL_DOMAIN_FFT MKL_DOMAIN_FFT
+#else
+#define EIGEN_MKL_DOMAIN_FFT MKL_FFT
+#endif
+
+#ifdef MKL_DOMAIN_VML
+#define EIGEN_MKL_DOMAIN_VML MKL_DOMAIN_VML
+#else
+#define EIGEN_MKL_DOMAIN_VML MKL_VML
+#endif
+
+#ifdef MKL_DOMAIN_PARDISO
+#define EIGEN_MKL_DOMAIN_PARDISO MKL_DOMAIN_PARDISO
+#else
+#define EIGEN_MKL_DOMAIN_PARDISO MKL_PARDISO
+#endif
+
namespace Eigen {
typedef std::complex<double> dcomplex;
diff --git a/Utilities/eigen3/Eigen/src/Core/util/Macros.h b/Utilities/eigen3/Eigen/src/Core/util/Macros.h
index a50f1f8c..53fb5fae 100644
--- a/Utilities/eigen3/Eigen/src/Core/util/Macros.h
+++ b/Utilities/eigen3/Eigen/src/Core/util/Macros.h
@@ -13,7 +13,7 @@
#define EIGEN_WORLD_VERSION 3
#define EIGEN_MAJOR_VERSION 2
-#define EIGEN_MINOR_VERSION 0
+#define EIGEN_MINOR_VERSION 7
#define EIGEN_VERSION_AT_LEAST(x,y,z) (EIGEN_WORLD_VERSION>x || (EIGEN_WORLD_VERSION>=x && \
(EIGEN_MAJOR_VERSION>y || (EIGEN_MAJOR_VERSION>=y && \
@@ -96,6 +96,27 @@
#define EIGEN_DEFAULT_DENSE_INDEX_TYPE std::ptrdiff_t
#endif
+// A Clang feature extension to determine compiler features.
+// We use it to determine 'cxx_rvalue_references'
+#ifndef __has_feature
+# define __has_feature(x) 0
+#endif
+
+// Do we support r-value references?
+#if (__has_feature(cxx_rvalue_references) || \
+ defined(__GXX_EXPERIMENTAL_CXX0X__) || \
+ (defined(_MSC_VER) && _MSC_VER >= 1600))
+ #define EIGEN_HAVE_RVALUE_REFERENCES
+#endif
+
+
+// Cross compiler wrapper around LLVM's __has_builtin
+#ifdef __has_builtin
+# define EIGEN_HAS_BUILTIN(x) __has_builtin(x)
+#else
+# define EIGEN_HAS_BUILTIN(x) 0
+#endif
+
/** Allows to disable some optimizations which might affect the accuracy of the result.
* Such optimization are enabled by default, and set EIGEN_FAST_MATH to 0 to disable them.
* They currently include:
@@ -238,11 +259,16 @@
#endif
// Suppresses 'unused variable' warnings.
-#define EIGEN_UNUSED_VARIABLE(var) (void)var;
+namespace Eigen {
+ namespace internal {
+ template<typename T> void ignore_unused_variable(const T&) {}
+ }
+}
+#define EIGEN_UNUSED_VARIABLE(var) Eigen::internal::ignore_unused_variable(var);
#if !defined(EIGEN_ASM_COMMENT)
#if (defined __GNUC__) && ( defined(__i386__) || defined(__x86_64__) )
- #define EIGEN_ASM_COMMENT(X) asm("#" X)
+ #define EIGEN_ASM_COMMENT(X) __asm__("#" X)
#else
#define EIGEN_ASM_COMMENT(X)
#endif
@@ -266,6 +292,7 @@
#error Please tell me what is the equivalent of __attribute__((aligned(n))) for your compiler
#endif
+#define EIGEN_ALIGN8 EIGEN_ALIGN_TO_BOUNDARY(8)
#define EIGEN_ALIGN16 EIGEN_ALIGN_TO_BOUNDARY(16)
#if EIGEN_ALIGN_STATICALLY
@@ -284,7 +311,8 @@
#endif
#ifndef EIGEN_STACK_ALLOCATION_LIMIT
-#define EIGEN_STACK_ALLOCATION_LIMIT 20000
+// 131072 == 128 KB
+#define EIGEN_STACK_ALLOCATION_LIMIT 131072
#endif
#ifndef EIGEN_DEFAULT_IO_FORMAT
@@ -300,7 +328,7 @@
// just an empty macro !
#define EIGEN_EMPTY
-#if defined(_MSC_VER) && (!defined(__INTEL_COMPILER))
+#if defined(_MSC_VER) && (_MSC_VER < 1900) && (!defined(__INTEL_COMPILER))
#define EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived) \
using Base::operator =;
#elif defined(__clang__) // workaround clang bug (see http://forum.kde.org/viewtopic.php?f=74&t=102653)
@@ -319,8 +347,11 @@
}
#endif
-#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) \
- EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
+/** \internal
+ * \brief Macro to manually inherit assignment operators.
+ * This is necessary, because the implicitly defined assignment operator gets deleted when a custom operator= is defined.
+ */
+#define EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Derived) EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Derived)
/**
* Just a side note. Commenting within defines works only by documenting
@@ -392,6 +423,8 @@
#define EIGEN_SIZE_MAX(a,b) (((int)a == Dynamic || (int)b == Dynamic) ? Dynamic \
: ((int)a >= (int)b) ? (int)a : (int)b)
+#define EIGEN_ADD_COST(a,b) int(a)==Dynamic || int(b)==Dynamic ? Dynamic : int(a)+int(b)
+
#define EIGEN_LOGICAL_XOR(a,b) (((a) || (b)) && !((a) && (b)))
#define EIGEN_IMPLIES(a,b) (!(a) || (b))
diff --git a/Utilities/eigen3/Eigen/src/Core/util/Memory.h b/Utilities/eigen3/Eigen/src/Core/util/Memory.h
index 451535a0..b9af5cf8 100644
--- a/Utilities/eigen3/Eigen/src/Core/util/Memory.h
+++ b/Utilities/eigen3/Eigen/src/Core/util/Memory.h
@@ -63,7 +63,7 @@
// Currently, let's include it only on unix systems:
#if defined(__unix__) || defined(__unix)
#include <unistd.h>
- #if ((defined __QNXNTO__) || (defined _GNU_SOURCE) || ((defined _XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600))) && (defined _POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO > 0)
+ #if ((defined __QNXNTO__) || (defined _GNU_SOURCE) || (defined __PGI) || ((defined _XOPEN_SOURCE) && (_XOPEN_SOURCE >= 600))) && (defined _POSIX_ADVISORY_INFO) && (_POSIX_ADVISORY_INFO > 0)
#define EIGEN_HAS_POSIX_MEMALIGN 1
#endif
#endif
@@ -272,12 +272,12 @@ inline void* aligned_realloc(void *ptr, size_t new_size, size_t old_size)
// The defined(_mm_free) is just here to verify that this MSVC version
// implements _mm_malloc/_mm_free based on the corresponding _aligned_
// functions. This may not always be the case and we just try to be safe.
- #if defined(_MSC_VER) && defined(_mm_free)
+ #if defined(_MSC_VER) && (!defined(_WIN32_WCE)) && defined(_mm_free)
result = _aligned_realloc(ptr,new_size,16);
#else
result = generic_aligned_realloc(ptr,new_size,old_size);
#endif
-#elif defined(_MSC_VER)
+#elif defined(_MSC_VER) && (!defined(_WIN32_WCE))
result = _aligned_realloc(ptr,new_size,16);
#else
result = handmade_aligned_realloc(ptr,new_size,old_size);
@@ -417,6 +417,8 @@ template<typename T, bool Align> inline T* conditional_aligned_realloc_new(T* pt
template<typename T, bool Align> inline T* conditional_aligned_new_auto(size_t size)
{
+ if(size==0)
+ return 0; // short-cut. Also fixes Bug 884
check_size_for_overflow<T>(size);
T *result = reinterpret_cast<T*>(conditional_aligned_malloc<Align>(sizeof(T)*size));
if(NumTraits<T>::RequireInitialization)
@@ -464,9 +466,8 @@ template<typename T, bool Align> inline void conditional_aligned_delete_auto(T *
template<typename Scalar, typename Index>
static inline Index first_aligned(const Scalar* array, Index size)
{
- enum { PacketSize = packet_traits<Scalar>::size,
- PacketAlignedMask = PacketSize-1
- };
+ static const Index PacketSize = packet_traits<Scalar>::size;
+ static const Index PacketAlignedMask = PacketSize-1;
if(PacketSize==1)
{
@@ -522,7 +523,7 @@ template<typename T> struct smart_copy_helper<T,false> {
// you can overwrite Eigen's default behavior regarding alloca by defining EIGEN_ALLOCA
// to the appropriate stack allocation function
#ifndef EIGEN_ALLOCA
- #if (defined __linux__)
+ #if (defined __linux__) || (defined __APPLE__) || (defined alloca)
#define EIGEN_ALLOCA alloca
#elif defined(_MSC_VER)
#define EIGEN_ALLOCA _alloca
@@ -578,7 +579,7 @@ template<typename T> class aligned_stack_memory_handler
*/
#ifdef EIGEN_ALLOCA
- #ifdef __arm__
+ #if defined(__arm__) || defined(_WIN32)
#define EIGEN_ALIGNED_ALLOCA(SIZE) reinterpret_cast<void*>((reinterpret_cast<size_t>(EIGEN_ALLOCA(SIZE+16)) & ~(size_t(15))) + 16)
#else
#define EIGEN_ALIGNED_ALLOCA EIGEN_ALLOCA
@@ -612,7 +613,6 @@ template<typename T> class aligned_stack_memory_handler
void* operator new(size_t size, const std::nothrow_t&) throw() { \
try { return Eigen::internal::conditional_aligned_malloc<NeedsToAlign>(size); } \
catch (...) { return 0; } \
- return 0; \
}
#else
#define EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
@@ -634,7 +634,9 @@ template<typename T> class aligned_stack_memory_handler
/* memory allocated we can safely let the default implementation handle */ \
/* this particular case. */ \
static void *operator new(size_t size, void *ptr) { return ::operator new(size,ptr); } \
+ static void *operator new[](size_t size, void* ptr) { return ::operator new[](size,ptr); } \
void operator delete(void * memory, void *ptr) throw() { return ::operator delete(memory,ptr); } \
+ void operator delete[](void * memory, void *ptr) throw() { return ::operator delete[](memory,ptr); } \
/* nothrow-new (returns zero instead of std::bad_alloc) */ \
EIGEN_MAKE_ALIGNED_OPERATOR_NEW_NOTHROW(NeedsToAlign) \
void operator delete(void *ptr, const std::nothrow_t&) throw() { \
@@ -729,15 +731,6 @@ public:
::new( p ) T( value );
}
- // Support for c++11
-#if (__cplusplus >= 201103L)
- template<typename... Args>
- void construct(pointer p, Args&&... args)
- {
- ::new(p) T(std::forward<Args>(args)...);
- }
-#endif
-
void destroy( pointer p )
{
p->~T();
@@ -784,9 +777,9 @@ namespace internal {
#ifdef EIGEN_CPUID
-inline bool cpuid_is_vendor(int abcd[4], const char* vendor)
+inline bool cpuid_is_vendor(int abcd[4], const int vendor[3])
{
- return abcd[1]==(reinterpret_cast<const int*>(vendor))[0] && abcd[3]==(reinterpret_cast<const int*>(vendor))[1] && abcd[2]==(reinterpret_cast<const int*>(vendor))[2];
+ return abcd[1]==vendor[0] && abcd[3]==vendor[1] && abcd[2]==vendor[2];
}
inline void queryCacheSizes_intel_direct(int& l1, int& l2, int& l3)
@@ -928,13 +921,16 @@ inline void queryCacheSizes(int& l1, int& l2, int& l3)
{
#ifdef EIGEN_CPUID
int abcd[4];
+ const int GenuineIntel[] = {0x756e6547, 0x49656e69, 0x6c65746e};
+ const int AuthenticAMD[] = {0x68747541, 0x69746e65, 0x444d4163};
+ const int AMDisbetter_[] = {0x69444d41, 0x74656273, 0x21726574}; // "AMDisbetter!"
// identify the CPU vendor
EIGEN_CPUID(abcd,0x0,0);
int max_std_funcs = abcd[1];
- if(cpuid_is_vendor(abcd,"GenuineIntel"))
+ if(cpuid_is_vendor(abcd,GenuineIntel))
queryCacheSizes_intel(l1,l2,l3,max_std_funcs);
- else if(cpuid_is_vendor(abcd,"AuthenticAMD") || cpuid_is_vendor(abcd,"AMDisbetter!"))
+ else if(cpuid_is_vendor(abcd,AuthenticAMD) || cpuid_is_vendor(abcd,AMDisbetter_))
queryCacheSizes_amd(l1,l2,l3);
else
// by default let's use Intel's API
diff --git a/Utilities/eigen3/Eigen/src/Core/util/StaticAssert.h b/Utilities/eigen3/Eigen/src/Core/util/StaticAssert.h
index 8872c5b6..bac5d9fe 100644
--- a/Utilities/eigen3/Eigen/src/Core/util/StaticAssert.h
+++ b/Utilities/eigen3/Eigen/src/Core/util/StaticAssert.h
@@ -90,7 +90,9 @@
YOU_PASSED_A_COLUMN_VECTOR_BUT_A_ROW_VECTOR_WAS_EXPECTED,
THE_INDEX_TYPE_MUST_BE_A_SIGNED_TYPE,
THE_STORAGE_ORDER_OF_BOTH_SIDES_MUST_MATCH,
- OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG
+ OBJECT_ALLOCATED_ON_STACK_IS_TOO_BIG,
+ IMPLICIT_CONVERSION_TO_SCALAR_IS_FOR_INNER_PRODUCT_ONLY,
+ STORAGE_LAYOUT_DOES_NOT_MATCH
};
};
diff --git a/Utilities/eigen3/Eigen/src/Core/util/XprHelper.h b/Utilities/eigen3/Eigen/src/Core/util/XprHelper.h
index 3c477305..d05f8e5f 100644
--- a/Utilities/eigen3/Eigen/src/Core/util/XprHelper.h
+++ b/Utilities/eigen3/Eigen/src/Core/util/XprHelper.h
@@ -341,7 +341,7 @@ template<typename T, int n=1, typename PlainObject = typename eval<T>::type> str
};
template<typename T>
-T* const_cast_ptr(const T* ptr)
+inline T* const_cast_ptr(const T* ptr)
{
return const_cast<T*>(ptr);
}
@@ -366,17 +366,17 @@ struct dense_xpr_base<Derived, ArrayXpr>
/** \internal Helper base class to add a scalar multiple operator
* overloads for complex types */
-template<typename Derived,typename Scalar,typename OtherScalar,
+template<typename Derived, typename Scalar, typename OtherScalar, typename BaseType,
bool EnableIt = !is_same<Scalar,OtherScalar>::value >
-struct special_scalar_op_base : public DenseCoeffsBase<Derived>
+struct special_scalar_op_base : public BaseType
{
// dummy operator* so that the
// "using special_scalar_op_base::operator*" compiles
void operator*() const;
};
-template<typename Derived,typename Scalar,typename OtherScalar>
-struct special_scalar_op_base<Derived,Scalar,OtherScalar,true> : public DenseCoeffsBase<Derived>
+template<typename Derived,typename Scalar,typename OtherScalar, typename BaseType>
+struct special_scalar_op_base<Derived,Scalar,OtherScalar,BaseType,true> : public BaseType
{
const CwiseUnaryOp<scalar_multiple2_op<Scalar,OtherScalar>, Derived>
operator*(const OtherScalar& scalar) const
diff --git a/Utilities/eigen3/Eigen/src/Eigen2Support/LeastSquares.h b/Utilities/eigen3/Eigen/src/Eigen2Support/LeastSquares.h
index 0e6fdb48..7992d494 100644
--- a/Utilities/eigen3/Eigen/src/Eigen2Support/LeastSquares.h
+++ b/Utilities/eigen3/Eigen/src/Eigen2Support/LeastSquares.h
@@ -147,7 +147,6 @@ void fitHyperplane(int numPoints,
// compute the covariance matrix
CovMatrixType covMat = CovMatrixType::Zero(size, size);
- VectorType remean = VectorType::Zero(size);
for(int i = 0; i < numPoints; ++i)
{
VectorType diff = (*(points[i]) - mean).conjugate();
diff --git a/Utilities/eigen3/Eigen/src/Eigen2Support/SVD.h b/Utilities/eigen3/Eigen/src/Eigen2Support/SVD.h
index 077d26d5..3d03d228 100644
--- a/Utilities/eigen3/Eigen/src/Eigen2Support/SVD.h
+++ b/Utilities/eigen3/Eigen/src/Eigen2Support/SVD.h
@@ -512,8 +512,7 @@ template<typename MatrixType>
template<typename OtherDerived, typename ResultType>
bool SVD<MatrixType>::solve(const MatrixBase<OtherDerived> &b, ResultType* result) const
{
- const int rows = m_matU.rows();
- ei_assert(b.rows() == rows);
+ ei_assert(b.rows() == m_matU.rows());
Scalar maxVal = m_sigma.cwise().abs().maxCoeff();
for (int j=0; j<b.cols(); ++j)
diff --git a/Utilities/eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h b/Utilities/eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h
index af434bc9..417c7294 100644
--- a/Utilities/eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h
+++ b/Utilities/eigen3/Eigen/src/Eigenvalues/ComplexEigenSolver.h
@@ -234,6 +234,12 @@ template<typename _MatrixType> class ComplexEigenSolver
}
protected:
+
+ static void check_template_parameters()
+ {
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
+ }
+
EigenvectorType m_eivec;
EigenvalueType m_eivalues;
ComplexSchur<MatrixType> m_schur;
@@ -251,6 +257,8 @@ template<typename MatrixType>
ComplexEigenSolver<MatrixType>&
ComplexEigenSolver<MatrixType>::compute(const MatrixType& matrix, bool computeEigenvectors)
{
+ check_template_parameters();
+
// this code is inspired from Jampack
eigen_assert(matrix.cols() == matrix.rows());
diff --git a/Utilities/eigen3/Eigen/src/Eigenvalues/EigenSolver.h b/Utilities/eigen3/Eigen/src/Eigenvalues/EigenSolver.h
index 6e715068..20c59a7a 100644
--- a/Utilities/eigen3/Eigen/src/Eigenvalues/EigenSolver.h
+++ b/Utilities/eigen3/Eigen/src/Eigenvalues/EigenSolver.h
@@ -298,6 +298,13 @@ template<typename _MatrixType> class EigenSolver
void doComputeEigenvectors();
protected:
+
+ static void check_template_parameters()
+ {
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
+ EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::IsComplex, NUMERIC_TYPE_MUST_BE_REAL);
+ }
+
MatrixType m_eivec;
EigenvalueType m_eivalues;
bool m_isInitialized;
@@ -364,6 +371,8 @@ template<typename MatrixType>
EigenSolver<MatrixType>&
EigenSolver<MatrixType>::compute(const MatrixType& matrix, bool computeEigenvectors)
{
+ check_template_parameters();
+
using std::sqrt;
using std::abs;
eigen_assert(matrix.cols() == matrix.rows());
diff --git a/Utilities/eigen3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h b/Utilities/eigen3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h
index dc240e13..956e80d9 100644
--- a/Utilities/eigen3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h
+++ b/Utilities/eigen3/Eigen/src/Eigenvalues/GeneralizedEigenSolver.h
@@ -263,6 +263,13 @@ template<typename _MatrixType> class GeneralizedEigenSolver
}
protected:
+
+ static void check_template_parameters()
+ {
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
+ EIGEN_STATIC_ASSERT(!NumTraits<Scalar>::IsComplex, NUMERIC_TYPE_MUST_BE_REAL);
+ }
+
MatrixType m_eivec;
ComplexVectorType m_alphas;
VectorType m_betas;
@@ -290,6 +297,8 @@ template<typename MatrixType>
GeneralizedEigenSolver<MatrixType>&
GeneralizedEigenSolver<MatrixType>::compute(const MatrixType& A, const MatrixType& B, bool computeEigenvectors)
{
+ check_template_parameters();
+
using std::sqrt;
using std::abs;
eigen_assert(A.cols() == A.rows() && B.cols() == A.rows() && B.cols() == B.rows());
diff --git a/Utilities/eigen3/Eigen/src/Eigenvalues/RealQZ.h b/Utilities/eigen3/Eigen/src/Eigenvalues/RealQZ.h
index 5706eeeb..aa3833eb 100644
--- a/Utilities/eigen3/Eigen/src/Eigenvalues/RealQZ.h
+++ b/Utilities/eigen3/Eigen/src/Eigenvalues/RealQZ.h
@@ -240,10 +240,10 @@ namespace Eigen {
m_S.coeffRef(i,j) = Scalar(0.0);
m_S.rightCols(dim-j-1).applyOnTheLeft(i-1,i,G.adjoint());
m_T.rightCols(dim-i+1).applyOnTheLeft(i-1,i,G.adjoint());
+ // update Q
+ if (m_computeQZ)
+ m_Q.applyOnTheRight(i-1,i,G);
}
- // update Q
- if (m_computeQZ)
- m_Q.applyOnTheRight(i-1,i,G);
// kill T(i,i-1)
if(m_T.coeff(i,i-1)!=Scalar(0))
{
@@ -251,10 +251,10 @@ namespace Eigen {
m_T.coeffRef(i,i-1) = Scalar(0.0);
m_S.applyOnTheRight(i,i-1,G);
m_T.topRows(i).applyOnTheRight(i,i-1,G);
+ // update Z
+ if (m_computeQZ)
+ m_Z.applyOnTheLeft(i,i-1,G.adjoint());
}
- // update Z
- if (m_computeQZ)
- m_Z.applyOnTheLeft(i,i-1,G.adjoint());
}
}
}
@@ -313,7 +313,7 @@ namespace Eigen {
using std::abs;
using std::sqrt;
const Index dim=m_S.cols();
- if (abs(m_S.coeff(i+1,i)==Scalar(0)))
+ if (abs(m_S.coeff(i+1,i))==Scalar(0))
return;
Index z = findSmallDiagEntry(i,i+1);
if (z==i-1)
diff --git a/Utilities/eigen3/Eigen/src/Eigenvalues/RealSchur.h b/Utilities/eigen3/Eigen/src/Eigenvalues/RealSchur.h
index 64d13634..16d38753 100644
--- a/Utilities/eigen3/Eigen/src/Eigenvalues/RealSchur.h
+++ b/Utilities/eigen3/Eigen/src/Eigenvalues/RealSchur.h
@@ -234,7 +234,7 @@ template<typename _MatrixType> class RealSchur
typedef Matrix<Scalar,3,1> Vector3s;
Scalar computeNormOfT();
- Index findSmallSubdiagEntry(Index iu, const Scalar& norm);
+ Index findSmallSubdiagEntry(Index iu);
void splitOffTwoRows(Index iu, bool computeU, const Scalar& exshift);
void computeShift(Index iu, Index iter, Scalar& exshift, Vector3s& shiftInfo);
void initFrancisQRStep(Index il, Index iu, const Vector3s& shiftInfo, Index& im, Vector3s& firstHouseholderVector);
@@ -286,7 +286,7 @@ RealSchur<MatrixType>& RealSchur<MatrixType>::computeFromHessenberg(const HessMa
{
while (iu >= 0)
{
- Index il = findSmallSubdiagEntry(iu, norm);
+ Index il = findSmallSubdiagEntry(iu);
// Check for convergence
if (il == iu) // One root found
@@ -343,16 +343,14 @@ inline typename MatrixType::Scalar RealSchur<MatrixType>::computeNormOfT()
/** \internal Look for single small sub-diagonal element and returns its index */
template<typename MatrixType>
-inline typename MatrixType::Index RealSchur<MatrixType>::findSmallSubdiagEntry(Index iu, const Scalar& norm)
+inline typename MatrixType::Index RealSchur<MatrixType>::findSmallSubdiagEntry(Index iu)
{
using std::abs;
Index res = iu;
while (res > 0)
{
Scalar s = abs(m_matT.coeff(res-1,res-1)) + abs(m_matT.coeff(res,res));
- if (s == 0.0)
- s = norm;
- if (abs(m_matT.coeff(res,res-1)) < NumTraits<Scalar>::epsilon() * s)
+ if (abs(m_matT.coeff(res,res-1)) <= NumTraits<Scalar>::epsilon() * s)
break;
res--;
}
@@ -457,9 +455,7 @@ inline void RealSchur<MatrixType>::initFrancisQRStep(Index il, Index iu, const V
const Scalar lhs = m_matT.coeff(im,im-1) * (abs(v.coeff(1)) + abs(v.coeff(2)));
const Scalar rhs = v.coeff(0) * (abs(m_matT.coeff(im-1,im-1)) + abs(Tmm) + abs(m_matT.coeff(im+1,im+1)));
if (abs(lhs) < NumTraits<Scalar>::epsilon() * rhs)
- {
break;
- }
}
}
diff --git a/Utilities/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h b/Utilities/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h
index 3993046a..1131c8af 100644
--- a/Utilities/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h
+++ b/Utilities/eigen3/Eigen/src/Eigenvalues/SelfAdjointEigenSolver.h
@@ -80,6 +80,8 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
/** \brief Scalar type for matrices of type \p _MatrixType. */
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Index Index;
+
+ typedef Matrix<Scalar,Size,Size,ColMajor,MaxColsAtCompileTime,MaxColsAtCompileTime> EigenvectorsType;
/** \brief Real scalar type for \p _MatrixType.
*
@@ -225,7 +227,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
*
* \sa eigenvalues()
*/
- const MatrixType& eigenvectors() const
+ const EigenvectorsType& eigenvectors() const
{
eigen_assert(m_isInitialized && "SelfAdjointEigenSolver is not initialized.");
eigen_assert(m_eigenvectorsOk && "The eigenvectors have not been computed together with the eigenvalues.");
@@ -351,7 +353,12 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
#endif // EIGEN2_SUPPORT
protected:
- MatrixType m_eivec;
+ static void check_template_parameters()
+ {
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
+ }
+
+ EigenvectorsType m_eivec;
RealVectorType m_eivalues;
typename TridiagonalizationType::SubDiagonalType m_subdiag;
ComputationInfo m_info;
@@ -376,7 +383,7 @@ template<typename _MatrixType> class SelfAdjointEigenSolver
* "implicit symmetric QR step with Wilkinson shift"
*/
namespace internal {
-template<int StorageOrder,typename RealScalar, typename Scalar, typename Index>
+template<typename RealScalar, typename Scalar, typename Index>
static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index start, Index end, Scalar* matrixQ, Index n);
}
@@ -384,6 +391,8 @@ template<typename MatrixType>
SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
::compute(const MatrixType& matrix, int options)
{
+ check_template_parameters();
+
using std::abs;
eigen_assert(matrix.cols() == matrix.rows());
eigen_assert((options&~(EigVecMask|GenEigMask))==0
@@ -406,7 +415,7 @@ SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
// declare some aliases
RealVectorType& diag = m_eivalues;
- MatrixType& mat = m_eivec;
+ EigenvectorsType& mat = m_eivec;
// map the matrix coefficients to [-1:1] to avoid over- and underflow.
mat = matrix.template triangularView<Lower>();
@@ -442,7 +451,7 @@ SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
while (start>0 && m_subdiag[start-1]!=0)
start--;
- internal::tridiagonal_qr_step<MatrixType::Flags&RowMajorBit ? RowMajor : ColMajor>(diag.data(), m_subdiag.data(), start, end, computeEigenvectors ? m_eivec.data() : (Scalar*)0, n);
+ internal::tridiagonal_qr_step(diag.data(), m_subdiag.data(), start, end, computeEigenvectors ? m_eivec.data() : (Scalar*)0, n);
}
if (iter <= m_maxIterations * n)
@@ -490,7 +499,13 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3
typedef typename SolverType::MatrixType MatrixType;
typedef typename SolverType::RealVectorType VectorType;
typedef typename SolverType::Scalar Scalar;
+ typedef typename MatrixType::Index Index;
+ typedef typename SolverType::EigenvectorsType EigenvectorsType;
+ /** \internal
+ * Computes the roots of the characteristic polynomial of \a m.
+ * For numerical stability m.trace() should be near zero and to avoid over- or underflow m should be normalized.
+ */
static inline void computeRoots(const MatrixType& m, VectorType& roots)
{
using std::sqrt;
@@ -510,148 +525,123 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,3
// Construct the parameters used in classifying the roots of the equation
// and in solving the equation for the roots in closed form.
Scalar c2_over_3 = c2*s_inv3;
- Scalar a_over_3 = (c1 - c2*c2_over_3)*s_inv3;
- if (a_over_3 > Scalar(0))
+ Scalar a_over_3 = (c2*c2_over_3 - c1)*s_inv3;
+ if(a_over_3<Scalar(0))
a_over_3 = Scalar(0);
Scalar half_b = Scalar(0.5)*(c0 + c2_over_3*(Scalar(2)*c2_over_3*c2_over_3 - c1));
- Scalar q = half_b*half_b + a_over_3*a_over_3*a_over_3;
- if (q > Scalar(0))
+ Scalar q = a_over_3*a_over_3*a_over_3 - half_b*half_b;
+ if(q<Scalar(0))
q = Scalar(0);
// Compute the eigenvalues by solving for the roots of the polynomial.
- Scalar rho = sqrt(-a_over_3);
- Scalar theta = atan2(sqrt(-q),half_b)*s_inv3;
+ Scalar rho = sqrt(a_over_3);
+ Scalar theta = atan2(sqrt(q),half_b)*s_inv3; // since sqrt(q) > 0, atan2 is in [0, pi] and theta is in [0, pi/3]
Scalar cos_theta = cos(theta);
Scalar sin_theta = sin(theta);
- roots(0) = c2_over_3 + Scalar(2)*rho*cos_theta;
- roots(1) = c2_over_3 - rho*(cos_theta + s_sqrt3*sin_theta);
- roots(2) = c2_over_3 - rho*(cos_theta - s_sqrt3*sin_theta);
-
- // Sort in increasing order.
- if (roots(0) >= roots(1))
- std::swap(roots(0),roots(1));
- if (roots(1) >= roots(2))
- {
- std::swap(roots(1),roots(2));
- if (roots(0) >= roots(1))
- std::swap(roots(0),roots(1));
- }
+ // roots are already sorted, since cos is monotonically decreasing on [0, pi]
+ roots(0) = c2_over_3 - rho*(cos_theta + s_sqrt3*sin_theta); // == 2*rho*cos(theta+2pi/3)
+ roots(1) = c2_over_3 - rho*(cos_theta - s_sqrt3*sin_theta); // == 2*rho*cos(theta+ pi/3)
+ roots(2) = c2_over_3 + Scalar(2)*rho*cos_theta;
}
-
+
+ static inline bool extract_kernel(MatrixType& mat, Ref<VectorType> res, Ref<VectorType> representative)
+ {
+ using std::abs;
+ Index i0;
+ // Find non-zero column i0 (by construction, there must exist a non zero coefficient on the diagonal):
+ mat.diagonal().cwiseAbs().maxCoeff(&i0);
+ // mat.col(i0) is a good candidate for an orthogonal vector to the current eigenvector,
+ // so let's save it:
+ representative = mat.col(i0);
+ Scalar n0, n1;
+ VectorType c0, c1;
+ n0 = (c0 = representative.cross(mat.col((i0+1)%3))).squaredNorm();
+ n1 = (c1 = representative.cross(mat.col((i0+2)%3))).squaredNorm();
+ if(n0>n1) res = c0/std::sqrt(n0);
+ else res = c1/std::sqrt(n1);
+
+ return true;
+ }
+
static inline void run(SolverType& solver, const MatrixType& mat, int options)
{
- using std::sqrt;
eigen_assert(mat.cols() == 3 && mat.cols() == mat.rows());
eigen_assert((options&~(EigVecMask|GenEigMask))==0
&& (options&EigVecMask)!=EigVecMask
&& "invalid option parameter");
bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors;
- MatrixType& eivecs = solver.m_eivec;
+ EigenvectorsType& eivecs = solver.m_eivec;
VectorType& eivals = solver.m_eivalues;
- // map the matrix coefficients to [-1:1] to avoid over- and underflow.
- Scalar scale = mat.cwiseAbs().maxCoeff();
- MatrixType scaledMat = mat / scale;
+ // Shift the matrix to the mean eigenvalue and map the matrix coefficients to [-1:1] to avoid over- and underflow.
+ Scalar shift = mat.trace() / Scalar(3);
+ // TODO Avoid this copy. Currently it is necessary to suppress bogus values when determining maxCoeff and for computing the eigenvectors later
+ MatrixType scaledMat = mat.template selfadjointView<Lower>();
+ scaledMat.diagonal().array() -= shift;
+ Scalar scale = scaledMat.cwiseAbs().maxCoeff();
+ if(scale > 0) scaledMat /= scale; // TODO for scale==0 we could save the remaining operations
// compute the eigenvalues
computeRoots(scaledMat,eivals);
- // compute the eigen vectors
+ // compute the eigenvectors
if(computeEigenvectors)
{
- Scalar safeNorm2 = Eigen::NumTraits<Scalar>::epsilon();
- safeNorm2 *= safeNorm2;
if((eivals(2)-eivals(0))<=Eigen::NumTraits<Scalar>::epsilon())
{
+ // All three eigenvalues are numerically the same
eivecs.setIdentity();
}
else
{
- scaledMat = scaledMat.template selfadjointView<Lower>();
MatrixType tmp;
tmp = scaledMat;
+ // Compute the eigenvector of the most distinct eigenvalue
Scalar d0 = eivals(2) - eivals(1);
Scalar d1 = eivals(1) - eivals(0);
- int k = d0 > d1 ? 2 : 0;
- d0 = d0 > d1 ? d1 : d0;
-
- tmp.diagonal().array () -= eivals(k);
- VectorType cross;
- Scalar n;
- n = (cross = tmp.row(0).cross(tmp.row(1))).squaredNorm();
-
- if(n>safeNorm2)
- eivecs.col(k) = cross / sqrt(n);
- else
+ Index k(0), l(2);
+ if(d0 > d1)
{
- n = (cross = tmp.row(0).cross(tmp.row(2))).squaredNorm();
-
- if(n>safeNorm2)
- eivecs.col(k) = cross / sqrt(n);
- else
- {
- n = (cross = tmp.row(1).cross(tmp.row(2))).squaredNorm();
-
- if(n>safeNorm2)
- eivecs.col(k) = cross / sqrt(n);
- else
- {
- // the input matrix and/or the eigenvaues probably contains some inf/NaN,
- // => exit
- // scale back to the original size.
- eivals *= scale;
-
- solver.m_info = NumericalIssue;
- solver.m_isInitialized = true;
- solver.m_eigenvectorsOk = computeEigenvectors;
- return;
- }
- }
+ std::swap(k,l);
+ d0 = d1;
}
- tmp = scaledMat;
- tmp.diagonal().array() -= eivals(1);
+ // Compute the eigenvector of index k
+ {
+ tmp.diagonal().array () -= eivals(k);
+ // By construction, 'tmp' is of rank 2, and its kernel corresponds to the respective eigenvector.
+ extract_kernel(tmp, eivecs.col(k), eivecs.col(l));
+ }
- if(d0<=Eigen::NumTraits<Scalar>::epsilon())
- eivecs.col(1) = eivecs.col(k).unitOrthogonal();
+ // Compute eigenvector of index l
+ if(d0<=2*Eigen::NumTraits<Scalar>::epsilon()*d1)
+ {
+ // If d0 is too small, then the two other eigenvalues are numerically the same,
+ // and thus we only have to ortho-normalize the near orthogonal vector we saved above.
+ eivecs.col(l) -= eivecs.col(k).dot(eivecs.col(l))*eivecs.col(l);
+ eivecs.col(l).normalize();
+ }
else
{
- n = (cross = eivecs.col(k).cross(tmp.row(0).normalized())).squaredNorm();
- if(n>safeNorm2)
- eivecs.col(1) = cross / sqrt(n);
- else
- {
- n = (cross = eivecs.col(k).cross(tmp.row(1))).squaredNorm();
- if(n>safeNorm2)
- eivecs.col(1) = cross / sqrt(n);
- else
- {
- n = (cross = eivecs.col(k).cross(tmp.row(2))).squaredNorm();
- if(n>safeNorm2)
- eivecs.col(1) = cross / sqrt(n);
- else
- {
- // we should never reach this point,
- // if so the last two eigenvalues are likely to ve very closed to each other
- eivecs.col(1) = eivecs.col(k).unitOrthogonal();
- }
- }
- }
-
- // make sure that eivecs[1] is orthogonal to eivecs[2]
- Scalar d = eivecs.col(1).dot(eivecs.col(k));
- eivecs.col(1) = (eivecs.col(1) - d * eivecs.col(k)).normalized();
+ tmp = scaledMat;
+ tmp.diagonal().array () -= eivals(l);
+
+ VectorType dummy;
+ extract_kernel(tmp, eivecs.col(l), dummy);
}
- eivecs.col(k==2 ? 0 : 2) = eivecs.col(k).cross(eivecs.col(1)).normalized();
+ // Compute last eigenvector from the other two
+ eivecs.col(1) = eivecs.col(2).cross(eivecs.col(0)).normalized();
}
}
+
// Rescale back to the original size.
eivals *= scale;
+ eivals.array() += shift;
solver.m_info = Success;
solver.m_isInitialized = true;
@@ -665,11 +655,12 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,2
typedef typename SolverType::MatrixType MatrixType;
typedef typename SolverType::RealVectorType VectorType;
typedef typename SolverType::Scalar Scalar;
+ typedef typename SolverType::EigenvectorsType EigenvectorsType;
static inline void computeRoots(const MatrixType& m, VectorType& roots)
{
using std::sqrt;
- const Scalar t0 = Scalar(0.5) * sqrt( numext::abs2(m(0,0)-m(1,1)) + Scalar(4)*m(1,0)*m(1,0));
+ const Scalar t0 = Scalar(0.5) * sqrt( numext::abs2(m(0,0)-m(1,1)) + Scalar(4)*numext::abs2(m(1,0)));
const Scalar t1 = Scalar(0.5) * (m(0,0) + m(1,1));
roots(0) = t1 - t0;
roots(1) = t1 + t0;
@@ -678,13 +669,15 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,2
static inline void run(SolverType& solver, const MatrixType& mat, int options)
{
using std::sqrt;
+ using std::abs;
+
eigen_assert(mat.cols() == 2 && mat.cols() == mat.rows());
eigen_assert((options&~(EigVecMask|GenEigMask))==0
&& (options&EigVecMask)!=EigVecMask
&& "invalid option parameter");
bool computeEigenvectors = (options&ComputeEigenvectors)==ComputeEigenvectors;
- MatrixType& eivecs = solver.m_eivec;
+ EigenvectorsType& eivecs = solver.m_eivec;
VectorType& eivals = solver.m_eivalues;
// map the matrix coefficients to [-1:1] to avoid over- and underflow.
@@ -698,22 +691,29 @@ template<typename SolverType> struct direct_selfadjoint_eigenvalues<SolverType,2
// compute the eigen vectors
if(computeEigenvectors)
{
- scaledMat.diagonal().array () -= eivals(1);
- Scalar a2 = numext::abs2(scaledMat(0,0));
- Scalar c2 = numext::abs2(scaledMat(1,1));
- Scalar b2 = numext::abs2(scaledMat(1,0));
- if(a2>c2)
+ if((eivals(1)-eivals(0))<=abs(eivals(1))*Eigen::NumTraits<Scalar>::epsilon())
{
- eivecs.col(1) << -scaledMat(1,0), scaledMat(0,0);
- eivecs.col(1) /= sqrt(a2+b2);
+ eivecs.setIdentity();
}
else
{
- eivecs.col(1) << -scaledMat(1,1), scaledMat(1,0);
- eivecs.col(1) /= sqrt(c2+b2);
- }
+ scaledMat.diagonal().array () -= eivals(1);
+ Scalar a2 = numext::abs2(scaledMat(0,0));
+ Scalar c2 = numext::abs2(scaledMat(1,1));
+ Scalar b2 = numext::abs2(scaledMat(1,0));
+ if(a2>c2)
+ {
+ eivecs.col(1) << -scaledMat(1,0), scaledMat(0,0);
+ eivecs.col(1) /= sqrt(a2+b2);
+ }
+ else
+ {
+ eivecs.col(1) << -scaledMat(1,1), scaledMat(1,0);
+ eivecs.col(1) /= sqrt(c2+b2);
+ }
- eivecs.col(0) << eivecs.col(1).unitOrthogonal();
+ eivecs.col(0) << eivecs.col(1).unitOrthogonal();
+ }
}
// Rescale back to the original size.
@@ -736,7 +736,7 @@ SelfAdjointEigenSolver<MatrixType>& SelfAdjointEigenSolver<MatrixType>
}
namespace internal {
-template<int StorageOrder,typename RealScalar, typename Scalar, typename Index>
+template<typename RealScalar, typename Scalar, typename Index>
static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index start, Index end, Scalar* matrixQ, Index n)
{
using std::abs;
@@ -788,8 +788,7 @@ static void tridiagonal_qr_step(RealScalar* diag, RealScalar* subdiag, Index sta
// apply the givens rotation to the unit matrix Q = Q * G
if (matrixQ)
{
- // FIXME if StorageOrder == RowMajor this operation is not very efficient
- Map<Matrix<Scalar,Dynamic,Dynamic,StorageOrder> > q(matrixQ,n,n);
+ Map<Matrix<Scalar,Dynamic,Dynamic,ColMajor> > q(matrixQ,n,n);
q.applyOnTheRight(k,k+1,rot);
}
}
diff --git a/Utilities/eigen3/Eigen/src/Geometry/AlignedBox.h b/Utilities/eigen3/Eigen/src/Geometry/AlignedBox.h
index 8e186d57..7e1cd9eb 100644
--- a/Utilities/eigen3/Eigen/src/Geometry/AlignedBox.h
+++ b/Utilities/eigen3/Eigen/src/Geometry/AlignedBox.h
@@ -19,10 +19,12 @@ namespace Eigen {
*
* \brief An axis aligned box
*
- * \param _Scalar the type of the scalar coefficients
- * \param _AmbientDim the dimension of the ambient space, can be a compile time value or Dynamic.
+ * \tparam _Scalar the type of the scalar coefficients
+ * \tparam _AmbientDim the dimension of the ambient space, can be a compile time value or Dynamic.
*
* This class represents an axis aligned box as a pair of the minimal and maximal corners.
+ * \warning The result of most methods is undefined when applied to an empty box. You can check for empty boxes using isEmpty().
+ * \sa alignedboxtypedefs
*/
template <typename _Scalar, int _AmbientDim>
class AlignedBox
@@ -40,18 +42,21 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
/** Define constants to name the corners of a 1D, 2D or 3D axis aligned bounding box */
enum CornerType
{
- /** 1D names */
+ /** 1D names @{ */
Min=0, Max=1,
+ /** @} */
- /** Added names for 2D */
+ /** Identifier for 2D corner @{ */
BottomLeft=0, BottomRight=1,
TopLeft=2, TopRight=3,
+ /** @} */
- /** Added names for 3D */
+ /** Identifier for 3D corner @{ */
BottomLeftFloor=0, BottomRightFloor=1,
TopLeftFloor=2, TopRightFloor=3,
BottomLeftCeil=4, BottomRightCeil=5,
TopLeftCeil=6, TopRightCeil=7
+ /** @} */
};
@@ -63,34 +68,33 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
inline explicit AlignedBox(Index _dim) : m_min(_dim), m_max(_dim)
{ setEmpty(); }
- /** Constructs a box with extremities \a _min and \a _max. */
+ /** Constructs a box with extremities \a _min and \a _max.
+ * \warning If either component of \a _min is larger than the same component of \a _max, the constructed box is empty. */
template<typename OtherVectorType1, typename OtherVectorType2>
inline AlignedBox(const OtherVectorType1& _min, const OtherVectorType2& _max) : m_min(_min), m_max(_max) {}
/** Constructs a box containing a single point \a p. */
template<typename Derived>
- inline explicit AlignedBox(const MatrixBase<Derived>& a_p)
- {
- typename internal::nested<Derived,2>::type p(a_p.derived());
- m_min = p;
- m_max = p;
- }
+ inline explicit AlignedBox(const MatrixBase<Derived>& p) : m_min(p), m_max(m_min)
+ { }
~AlignedBox() {}
/** \returns the dimension in which the box holds */
inline Index dim() const { return AmbientDimAtCompileTime==Dynamic ? m_min.size() : Index(AmbientDimAtCompileTime); }
- /** \deprecated use isEmpty */
+ /** \deprecated use isEmpty() */
inline bool isNull() const { return isEmpty(); }
- /** \deprecated use setEmpty */
+ /** \deprecated use setEmpty() */
inline void setNull() { setEmpty(); }
- /** \returns true if the box is empty. */
+ /** \returns true if the box is empty.
+ * \sa setEmpty */
inline bool isEmpty() const { return (m_min.array() > m_max.array()).any(); }
- /** Makes \c *this an empty box. */
+ /** Makes \c *this an empty box.
+ * \sa isEmpty */
inline void setEmpty()
{
m_min.setConstant( ScalarTraits::highest() );
@@ -159,7 +163,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
* a uniform distribution */
inline VectorType sample() const
{
- VectorType r;
+ VectorType r(dim());
for(Index d=0; d<dim(); ++d)
{
if(!ScalarTraits::IsInteger)
@@ -175,27 +179,34 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
/** \returns true if the point \a p is inside the box \c *this. */
template<typename Derived>
- inline bool contains(const MatrixBase<Derived>& a_p) const
+ inline bool contains(const MatrixBase<Derived>& p) const
{
- typename internal::nested<Derived,2>::type p(a_p.derived());
- return (m_min.array()<=p.array()).all() && (p.array()<=m_max.array()).all();
+ typename internal::nested<Derived,2>::type p_n(p.derived());
+ return (m_min.array()<=p_n.array()).all() && (p_n.array()<=m_max.array()).all();
}
/** \returns true if the box \a b is entirely inside the box \c *this. */
inline bool contains(const AlignedBox& b) const
{ return (m_min.array()<=(b.min)().array()).all() && ((b.max)().array()<=m_max.array()).all(); }
- /** Extends \c *this such that it contains the point \a p and returns a reference to \c *this. */
+ /** \returns true if the box \a b is intersecting the box \c *this.
+ * \sa intersection, clamp */
+ inline bool intersects(const AlignedBox& b) const
+ { return (m_min.array()<=(b.max)().array()).all() && ((b.min)().array()<=m_max.array()).all(); }
+
+ /** Extends \c *this such that it contains the point \a p and returns a reference to \c *this.
+ * \sa extend(const AlignedBox&) */
template<typename Derived>
- inline AlignedBox& extend(const MatrixBase<Derived>& a_p)
+ inline AlignedBox& extend(const MatrixBase<Derived>& p)
{
- typename internal::nested<Derived,2>::type p(a_p.derived());
- m_min = m_min.cwiseMin(p);
- m_max = m_max.cwiseMax(p);
+ typename internal::nested<Derived,2>::type p_n(p.derived());
+ m_min = m_min.cwiseMin(p_n);
+ m_max = m_max.cwiseMax(p_n);
return *this;
}
- /** Extends \c *this such that it contains the box \a b and returns a reference to \c *this. */
+ /** Extends \c *this such that it contains the box \a b and returns a reference to \c *this.
+ * \sa merged, extend(const MatrixBase&) */
inline AlignedBox& extend(const AlignedBox& b)
{
m_min = m_min.cwiseMin(b.m_min);
@@ -203,7 +214,9 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
return *this;
}
- /** Clamps \c *this by the box \a b and returns a reference to \c *this. */
+ /** Clamps \c *this by the box \a b and returns a reference to \c *this.
+ * \note If the boxes don't intersect, the resulting box is empty.
+ * \sa intersection(), intersects() */
inline AlignedBox& clamp(const AlignedBox& b)
{
m_min = m_min.cwiseMax(b.m_min);
@@ -211,11 +224,15 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
return *this;
}
- /** Returns an AlignedBox that is the intersection of \a b and \c *this */
+ /** Returns an AlignedBox that is the intersection of \a b and \c *this
+ * \note If the boxes don't intersect, the resulting box is empty.
+ * \sa intersects(), clamp, contains() */
inline AlignedBox intersection(const AlignedBox& b) const
{return AlignedBox(m_min.cwiseMax(b.m_min), m_max.cwiseMin(b.m_max)); }
- /** Returns an AlignedBox that is the union of \a b and \c *this */
+ /** Returns an AlignedBox that is the union of \a b and \c *this.
+ * \note Merging with an empty box may result in a box bigger than \c *this.
+ * \sa extend(const AlignedBox&) */
inline AlignedBox merged(const AlignedBox& b) const
{ return AlignedBox(m_min.cwiseMin(b.m_min), m_max.cwiseMax(b.m_max)); }
@@ -231,20 +248,20 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
/** \returns the squared distance between the point \a p and the box \c *this,
* and zero if \a p is inside the box.
- * \sa exteriorDistance()
+ * \sa exteriorDistance(const MatrixBase&), squaredExteriorDistance(const AlignedBox&)
*/
template<typename Derived>
- inline Scalar squaredExteriorDistance(const MatrixBase<Derived>& a_p) const;
+ inline Scalar squaredExteriorDistance(const MatrixBase<Derived>& p) const;
/** \returns the squared distance between the boxes \a b and \c *this,
* and zero if the boxes intersect.
- * \sa exteriorDistance()
+ * \sa exteriorDistance(const AlignedBox&), squaredExteriorDistance(const MatrixBase&)
*/
inline Scalar squaredExteriorDistance(const AlignedBox& b) const;
/** \returns the distance between the point \a p and the box \c *this,
* and zero if \a p is inside the box.
- * \sa squaredExteriorDistance()
+ * \sa squaredExteriorDistance(const MatrixBase&), exteriorDistance(const AlignedBox&)
*/
template<typename Derived>
inline NonInteger exteriorDistance(const MatrixBase<Derived>& p) const
@@ -252,7 +269,7 @@ EIGEN_MAKE_ALIGNED_OPERATOR_NEW_IF_VECTORIZABLE_FIXED_SIZE(_Scalar,_AmbientDim)
/** \returns the distance between the boxes \a b and \c *this,
* and zero if the boxes intersect.
- * \sa squaredExteriorDistance()
+ * \sa squaredExteriorDistance(const AlignedBox&), exteriorDistance(const MatrixBase&)
*/
inline NonInteger exteriorDistance(const AlignedBox& b) const
{ using std::sqrt; return sqrt(NonInteger(squaredExteriorDistance(b))); }
diff --git a/Utilities/eigen3/Eigen/src/Geometry/AngleAxis.h b/Utilities/eigen3/Eigen/src/Geometry/AngleAxis.h
index 553d38c7..bbf6a7ed 100644
--- a/Utilities/eigen3/Eigen/src/Geometry/AngleAxis.h
+++ b/Utilities/eigen3/Eigen/src/Geometry/AngleAxis.h
@@ -131,7 +131,7 @@ public:
m_angle = Scalar(other.angle());
}
- static inline const AngleAxis Identity() { return AngleAxis(0, Vector3::UnitX()); }
+ static inline const AngleAxis Identity() { return AngleAxis(Scalar(0), Vector3::UnitX()); }
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
* determined by \a prec.
@@ -165,8 +165,8 @@ AngleAxis<Scalar>& AngleAxis<Scalar>::operator=(const QuaternionBase<QuatDerived
Scalar n2 = q.vec().squaredNorm();
if (n2 < NumTraits<Scalar>::dummy_precision()*NumTraits<Scalar>::dummy_precision())
{
- m_angle = 0;
- m_axis << 1, 0, 0;
+ m_angle = Scalar(0);
+ m_axis << Scalar(1), Scalar(0), Scalar(0);
}
else
{
diff --git a/Utilities/eigen3/Eigen/src/Geometry/EulerAngles.h b/Utilities/eigen3/Eigen/src/Geometry/EulerAngles.h
index 97984d59..82802fb4 100644
--- a/Utilities/eigen3/Eigen/src/Geometry/EulerAngles.h
+++ b/Utilities/eigen3/Eigen/src/Geometry/EulerAngles.h
@@ -28,7 +28,7 @@ namespace Eigen {
* * AngleAxisf(ea[2], Vector3f::UnitZ()); \endcode
* This corresponds to the right-multiply conventions (with right hand side frames).
*
- * The returned angles are in the ranges [0:pi]x[0:pi]x[-pi:pi].
+ * The returned angles are in the ranges [0:pi]x[-pi:pi]x[-pi:pi].
*
* \sa class AngleAxis
*/
diff --git a/Utilities/eigen3/Eigen/src/Geometry/Homogeneous.h b/Utilities/eigen3/Eigen/src/Geometry/Homogeneous.h
index 00e71d19..372e422b 100644
--- a/Utilities/eigen3/Eigen/src/Geometry/Homogeneous.h
+++ b/Utilities/eigen3/Eigen/src/Geometry/Homogeneous.h
@@ -79,7 +79,7 @@ template<typename MatrixType,int _Direction> class Homogeneous
{
if( (int(Direction)==Vertical && row==m_matrix.rows())
|| (int(Direction)==Horizontal && col==m_matrix.cols()))
- return 1;
+ return Scalar(1);
return m_matrix.coeff(row, col);
}
diff --git a/Utilities/eigen3/Eigen/src/Geometry/Hyperplane.h b/Utilities/eigen3/Eigen/src/Geometry/Hyperplane.h
index aeff43fe..00b7c430 100644
--- a/Utilities/eigen3/Eigen/src/Geometry/Hyperplane.h
+++ b/Utilities/eigen3/Eigen/src/Geometry/Hyperplane.h
@@ -100,7 +100,17 @@ public:
{
EIGEN_STATIC_ASSERT_VECTOR_SPECIFIC_SIZE(VectorType, 3)
Hyperplane result(p0.size());
- result.normal() = (p2 - p0).cross(p1 - p0).normalized();
+ VectorType v0(p2 - p0), v1(p1 - p0);
+ result.normal() = v0.cross(v1);
+ RealScalar norm = result.normal().norm();
+ if(norm <= v0.norm() * v1.norm() * NumTraits<RealScalar>::epsilon())
+ {
+ Matrix<Scalar,2,3> m; m << v0.transpose(), v1.transpose();
+ JacobiSVD<Matrix<Scalar,2,3> > svd(m, ComputeFullV);
+ result.normal() = svd.matrixV().col(2);
+ }
+ else
+ result.normal() /= norm;
result.offset() = -p0.dot(result.normal());
return result;
}
diff --git a/Utilities/eigen3/Eigen/src/Geometry/Quaternion.h b/Utilities/eigen3/Eigen/src/Geometry/Quaternion.h
index e135f2b6..25ed17bb 100644
--- a/Utilities/eigen3/Eigen/src/Geometry/Quaternion.h
+++ b/Utilities/eigen3/Eigen/src/Geometry/Quaternion.h
@@ -102,11 +102,11 @@ public:
/** \returns a quaternion representing an identity rotation
* \sa MatrixBase::Identity()
*/
- static inline Quaternion<Scalar> Identity() { return Quaternion<Scalar>(1, 0, 0, 0); }
+ static inline Quaternion<Scalar> Identity() { return Quaternion<Scalar>(Scalar(1), Scalar(0), Scalar(0), Scalar(0)); }
/** \sa QuaternionBase::Identity(), MatrixBase::setIdentity()
*/
- inline QuaternionBase& setIdentity() { coeffs() << 0, 0, 0, 1; return *this; }
+ inline QuaternionBase& setIdentity() { coeffs() << Scalar(0), Scalar(0), Scalar(0), Scalar(1); return *this; }
/** \returns the squared norm of the quaternion's coefficients
* \sa QuaternionBase::norm(), MatrixBase::squaredNorm()
@@ -150,10 +150,6 @@ public:
/** \returns the conjugated quaternion */
Quaternion<Scalar> conjugate() const;
- /** \returns an interpolation for a constant motion between \a other and \c *this
- * \a t in [0;1]
- * see http://en.wikipedia.org/wiki/Slerp
- */
template<class OtherDerived> Quaternion<Scalar> slerp(const Scalar& t, const QuaternionBase<OtherDerived>& other) const;
/** \returns \c true if \c *this is approximately equal to \a other, within the precision
@@ -165,7 +161,7 @@ public:
{ return coeffs().isApprox(other.coeffs(), prec); }
/** return the result vector of \a v through the rotation*/
- EIGEN_STRONG_INLINE Vector3 _transformVector(Vector3 v) const;
+ EIGEN_STRONG_INLINE Vector3 _transformVector(const Vector3& v) const;
/** \returns \c *this with scalar type casted to \a NewScalarType
*
@@ -194,11 +190,11 @@ public:
* \brief The quaternion class used to represent 3D orientations and rotations
*
* \tparam _Scalar the scalar type, i.e., the type of the coefficients
- * \tparam _Options controls the memory alignement of the coeffecients. Can be \# AutoAlign or \# DontAlign. Default is AutoAlign.
+ * \tparam _Options controls the memory alignment of the coefficients. Can be \# AutoAlign or \# DontAlign. Default is AutoAlign.
*
* This class represents a quaternion \f$ w+xi+yj+zk \f$ that is a convenient representation of
* orientations and rotations of objects in three dimensions. Compared to other representations
- * like Euler angles or 3x3 matrices, quatertions offer the following advantages:
+ * like Euler angles or 3x3 matrices, quaternions offer the following advantages:
* \li \b compact storage (4 scalars)
* \li \b efficient to compose (28 flops),
* \li \b stable spherical interpolation
@@ -207,6 +203,8 @@ public:
* \li \c Quaternionf for \c float
* \li \c Quaterniond for \c double
*
+ * \warning Operations interpreting the quaternion as rotation have undefined behavior if the quaternion is not normalized.
+ *
* \sa class AngleAxis, class Transform
*/
@@ -233,7 +231,7 @@ class Quaternion : public QuaternionBase<Quaternion<_Scalar,_Options> >
public:
typedef _Scalar Scalar;
- EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Quaternion)
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Quaternion)
using Base::operator*=;
typedef typename internal::traits<Quaternion>::Coefficients Coefficients;
@@ -343,12 +341,12 @@ class Map<const Quaternion<_Scalar>, _Options >
public:
typedef _Scalar Scalar;
typedef typename internal::traits<Map>::Coefficients Coefficients;
- EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Map)
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
using Base::operator*=;
/** Constructs a Mapped Quaternion object from the pointer \a coeffs
*
- * The pointer \a coeffs must reference the four coeffecients of Quaternion in the following order:
+ * The pointer \a coeffs must reference the four coefficients of Quaternion in the following order:
* \code *coeffs == {x, y, z, w} \endcode
*
* If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */
@@ -380,12 +378,12 @@ class Map<Quaternion<_Scalar>, _Options >
public:
typedef _Scalar Scalar;
typedef typename internal::traits<Map>::Coefficients Coefficients;
- EIGEN_INHERIT_ASSIGNMENT_EQUAL_OPERATOR(Map)
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(Map)
using Base::operator*=;
/** Constructs a Mapped Quaternion object from the pointer \a coeffs
*
- * The pointer \a coeffs must reference the four coeffecients of Quaternion in the following order:
+ * The pointer \a coeffs must reference the four coefficients of Quaternion in the following order:
* \code *coeffs == {x, y, z, w} \endcode
*
* If the template parameter _Options is set to #Aligned, then the pointer coeffs must be aligned. */
@@ -399,16 +397,16 @@ class Map<Quaternion<_Scalar>, _Options >
};
/** \ingroup Geometry_Module
- * Map an unaligned array of single precision scalar as a quaternion */
+ * Map an unaligned array of single precision scalars as a quaternion */
typedef Map<Quaternion<float>, 0> QuaternionMapf;
/** \ingroup Geometry_Module
- * Map an unaligned array of double precision scalar as a quaternion */
+ * Map an unaligned array of double precision scalars as a quaternion */
typedef Map<Quaternion<double>, 0> QuaternionMapd;
/** \ingroup Geometry_Module
- * Map a 16-bits aligned array of double precision scalars as a quaternion */
+ * Map a 16-byte aligned array of single precision scalars as a quaternion */
typedef Map<Quaternion<float>, Aligned> QuaternionMapAlignedf;
/** \ingroup Geometry_Module
- * Map a 16-bits aligned array of double precision scalars as a quaternion */
+ * Map a 16-byte aligned array of double precision scalars as a quaternion */
typedef Map<Quaternion<double>, Aligned> QuaternionMapAlignedd;
/***************************************************************************
@@ -463,12 +461,12 @@ EIGEN_STRONG_INLINE Derived& QuaternionBase<Derived>::operator*= (const Quaterni
*/
template <class Derived>
EIGEN_STRONG_INLINE typename QuaternionBase<Derived>::Vector3
-QuaternionBase<Derived>::_transformVector(Vector3 v) const
+QuaternionBase<Derived>::_transformVector(const Vector3& v) const
{
// Note that this algorithm comes from the optimization by hand
// of the conversion to a Matrix followed by a Matrix/Vector product.
// It appears to be much faster than the common algorithm found
- // in the litterature (30 versus 39 flops). It also requires two
+ // in the literature (30 versus 39 flops). It also requires two
// Vector3 as temporaries.
Vector3 uv = this->vec().cross(v);
uv += uv;
@@ -579,7 +577,7 @@ inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Deri
Scalar c = v1.dot(v0);
// if dot == -1, vectors are nearly opposites
- // => accuraletly compute the rotation axis by computing the
+ // => accurately compute the rotation axis by computing the
// intersection of the two planes. This is done by solving:
// x^T v0 = 0
// x^T v1 = 0
@@ -588,7 +586,7 @@ inline Derived& QuaternionBase<Derived>::setFromTwoVectors(const MatrixBase<Deri
// which yields a singular value problem
if (c < Scalar(-1)+NumTraits<Scalar>::dummy_precision())
{
- c = max<Scalar>(c,-1);
+ c = (max)(c,Scalar(-1));
Matrix<Scalar,2,3> m; m << v0.transpose(), v1.transpose();
JacobiSVD<Matrix<Scalar,2,3> > svd(m, ComputeFullV);
Vector3 axis = svd.matrixV().col(2);
@@ -639,7 +637,7 @@ inline Quaternion<typename internal::traits<Derived>::Scalar> QuaternionBase<Der
{
// FIXME should this function be called multiplicativeInverse and conjugate() be called inverse() or opposite() ??
Scalar n2 = this->squaredNorm();
- if (n2 > 0)
+ if (n2 > Scalar(0))
return Quaternion<Scalar>(conjugate().coeffs() / n2);
else
{
@@ -669,16 +667,19 @@ template <class OtherDerived>
inline typename internal::traits<Derived>::Scalar
QuaternionBase<Derived>::angularDistance(const QuaternionBase<OtherDerived>& other) const
{
- using std::acos;
+ using std::atan2;
using std::abs;
- double d = abs(this->dot(other));
- if (d>=1.0)
- return Scalar(0);
- return static_cast<Scalar>(2 * acos(d));
+ Quaternion<Scalar> d = (*this) * other.conjugate();
+ return Scalar(2) * atan2( d.vec().norm(), abs(d.w()) );
}
+
+
/** \returns the spherical linear interpolation between the two quaternions
- * \c *this and \a other at the parameter \a t
+ * \c *this and \a other at the parameter \a t in [0;1].
+ *
+ * This represents an interpolation for a constant motion between \c *this and \a other,
+ * see also http://en.wikipedia.org/wiki/Slerp.
*/
template <class Derived>
template <class OtherDerived>
@@ -709,7 +710,7 @@ QuaternionBase<Derived>::slerp(const Scalar& t, const QuaternionBase<OtherDerive
scale0 = sin( ( Scalar(1) - t ) * theta) / sinTheta;
scale1 = sin( ( t * theta) ) / sinTheta;
}
- if(d<0) scale1 = -scale1;
+ if(d<Scalar(0)) scale1 = -scale1;
return Quaternion<Scalar>(scale0 * coeffs() + scale1 * other.coeffs());
}
diff --git a/Utilities/eigen3/Eigen/src/Geometry/Rotation2D.h b/Utilities/eigen3/Eigen/src/Geometry/Rotation2D.h
index 1cac343a..a2d59fce 100644
--- a/Utilities/eigen3/Eigen/src/Geometry/Rotation2D.h
+++ b/Utilities/eigen3/Eigen/src/Geometry/Rotation2D.h
@@ -60,6 +60,9 @@ public:
/** Construct a 2D counter clock wise rotation from the angle \a a in radian. */
inline Rotation2D(const Scalar& a) : m_angle(a) {}
+
+ /** Default constructor wihtout initialization. The represented rotation is undefined. */
+ Rotation2D() {}
/** \returns the rotation angle */
inline Scalar angle() const { return m_angle; }
@@ -81,10 +84,10 @@ public:
/** Applies the rotation to a 2D vector */
Vector2 operator* (const Vector2& vec) const
{ return toRotationMatrix() * vec; }
-
+
template<typename Derived>
Rotation2D& fromRotationMatrix(const MatrixBase<Derived>& m);
- Matrix2 toRotationMatrix(void) const;
+ Matrix2 toRotationMatrix() const;
/** \returns the spherical interpolation between \c *this and \a other using
* parameter \a t. It is in fact equivalent to a linear interpolation.
diff --git a/Utilities/eigen3/Eigen/src/Geometry/Transform.h b/Utilities/eigen3/Eigen/src/Geometry/Transform.h
index 887e718d..e786e535 100644
--- a/Utilities/eigen3/Eigen/src/Geometry/Transform.h
+++ b/Utilities/eigen3/Eigen/src/Geometry/Transform.h
@@ -62,6 +62,8 @@ struct transform_construct_from_matrix;
template<typename TransformType> struct transform_take_affine_part;
+template<int Mode> struct transform_make_affine;
+
} // end namespace internal
/** \geometry_module \ingroup Geometry_Module
@@ -194,9 +196,9 @@ public:
/** type of the matrix used to represent the linear part of the transformation */
typedef Matrix<Scalar,Dim,Dim,Options> LinearMatrixType;
/** type of read/write reference to the linear part of the transformation */
- typedef Block<MatrixType,Dim,Dim,int(Mode)==(AffineCompact)> LinearPart;
+ typedef Block<MatrixType,Dim,Dim,int(Mode)==(AffineCompact) && (Options&RowMajor)==0> LinearPart;
/** type of read reference to the linear part of the transformation */
- typedef const Block<ConstMatrixType,Dim,Dim,int(Mode)==(AffineCompact)> ConstLinearPart;
+ typedef const Block<ConstMatrixType,Dim,Dim,int(Mode)==(AffineCompact) && (Options&RowMajor)==0> ConstLinearPart;
/** type of read/write reference to the affine part of the transformation */
typedef typename internal::conditional<int(Mode)==int(AffineCompact),
MatrixType&,
@@ -230,8 +232,7 @@ public:
inline Transform()
{
check_template_params();
- if (int(Mode)==Affine)
- makeAffine();
+ internal::transform_make_affine<(int(Mode)==Affine) ? Affine : AffineCompact>::run(m_matrix);
}
inline Transform(const Transform& other)
@@ -530,9 +531,9 @@ public:
inline Transform& operator=(const UniformScaling<Scalar>& t);
inline Transform& operator*=(const UniformScaling<Scalar>& s) { return scale(s.factor()); }
- inline Transform<Scalar,Dim,(int(Mode)==int(Isometry)?Affine:Isometry)> operator*(const UniformScaling<Scalar>& s) const
+ inline Transform<Scalar,Dim,(int(Mode)==int(Isometry)?int(Affine):int(Mode))> operator*(const UniformScaling<Scalar>& s) const
{
- Transform<Scalar,Dim,(int(Mode)==int(Isometry)?Affine:Isometry),Options> res = *this;
+ Transform<Scalar,Dim,(int(Mode)==int(Isometry)?int(Affine):int(Mode)),Options> res = *this;
res.scale(s.factor());
return res;
}
@@ -591,11 +592,7 @@ public:
*/
void makeAffine()
{
- if(int(Mode)!=int(AffineCompact))
- {
- matrix().template block<1,Dim>(Dim,0).setZero();
- matrix().coeffRef(Dim,Dim) = Scalar(1);
- }
+ internal::transform_make_affine<int(Mode)>::run(m_matrix);
}
/** \internal
@@ -1079,6 +1076,24 @@ Transform<Scalar,Dim,Mode,Options>::fromPositionOrientationScale(const MatrixBas
namespace internal {
+template<int Mode>
+struct transform_make_affine
+{
+ template<typename MatrixType>
+ static void run(MatrixType &mat)
+ {
+ static const int Dim = MatrixType::ColsAtCompileTime-1;
+ mat.template block<1,Dim>(Dim,0).setZero();
+ mat.coeffRef(Dim,Dim) = typename MatrixType::Scalar(1);
+ }
+};
+
+template<>
+struct transform_make_affine<AffineCompact>
+{
+ template<typename MatrixType> static void run(MatrixType &) { }
+};
+
// selector needed to avoid taking the inverse of a 3x4 matrix
template<typename TransformType, int Mode=TransformType::Mode>
struct projective_transform_inverse
diff --git a/Utilities/eigen3/Eigen/src/Geometry/Umeyama.h b/Utilities/eigen3/Eigen/src/Geometry/Umeyama.h
index 345b47e0..5e20662f 100644
--- a/Utilities/eigen3/Eigen/src/Geometry/Umeyama.h
+++ b/Utilities/eigen3/Eigen/src/Geometry/Umeyama.h
@@ -113,7 +113,7 @@ umeyama(const MatrixBase<Derived>& src, const MatrixBase<OtherDerived>& dst, boo
const Index n = src.cols(); // number of measurements
// required for demeaning ...
- const RealScalar one_over_n = 1 / static_cast<RealScalar>(n);
+ const RealScalar one_over_n = RealScalar(1) / static_cast<RealScalar>(n);
// computation of mean
const VectorType src_mean = src.rowwise().sum() * one_over_n;
@@ -136,16 +136,16 @@ umeyama(const MatrixBase<Derived>& src, const MatrixBase<OtherDerived>& dst, boo
// Eq. (39)
VectorType S = VectorType::Ones(m);
- if (sigma.determinant()<0) S(m-1) = -1;
+ if (sigma.determinant()<Scalar(0)) S(m-1) = Scalar(-1);
// Eq. (40) and (43)
const VectorType& d = svd.singularValues();
Index rank = 0; for (Index i=0; i<m; ++i) if (!internal::isMuchSmallerThan(d.coeff(i),d.coeff(0))) ++rank;
if (rank == m-1) {
- if ( svd.matrixU().determinant() * svd.matrixV().determinant() > 0 ) {
+ if ( svd.matrixU().determinant() * svd.matrixV().determinant() > Scalar(0) ) {
Rt.block(0,0,m,m).noalias() = svd.matrixU()*svd.matrixV().transpose();
} else {
- const Scalar s = S(m-1); S(m-1) = -1;
+ const Scalar s = S(m-1); S(m-1) = Scalar(-1);
Rt.block(0,0,m,m).noalias() = svd.matrixU() * S.asDiagonal() * svd.matrixV().transpose();
S(m-1) = s;
}
@@ -156,7 +156,7 @@ umeyama(const MatrixBase<Derived>& src, const MatrixBase<OtherDerived>& dst, boo
if (with_scaling)
{
// Eq. (42)
- const Scalar c = 1/src_var * svd.singularValues().dot(S);
+ const Scalar c = Scalar(1)/src_var * svd.singularValues().dot(S);
// Eq. (41)
Rt.col(m).head(m) = dst_mean;
diff --git a/Utilities/eigen3/Eigen/src/Householder/BlockHouseholder.h b/Utilities/eigen3/Eigen/src/Householder/BlockHouseholder.h
index 1991c652..60dbea5f 100644
--- a/Utilities/eigen3/Eigen/src/Householder/BlockHouseholder.h
+++ b/Utilities/eigen3/Eigen/src/Householder/BlockHouseholder.h
@@ -48,7 +48,7 @@ void apply_block_householder_on_the_left(MatrixType& mat, const VectorsType& vec
typedef typename MatrixType::Index Index;
enum { TFactorSize = MatrixType::ColsAtCompileTime };
Index nbVecs = vectors.cols();
- Matrix<typename MatrixType::Scalar, TFactorSize, TFactorSize> T(nbVecs,nbVecs);
+ Matrix<typename MatrixType::Scalar, TFactorSize, TFactorSize, ColMajor> T(nbVecs,nbVecs);
make_block_householder_triangular_factor(T, vectors, hCoeffs);
const TriangularView<const VectorsType, UnitLower>& V(vectors);
diff --git a/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h b/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h
index 73ca9bfd..1f3c060d 100644
--- a/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h
+++ b/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/BasicPreconditioners.h
@@ -65,10 +65,10 @@ class DiagonalPreconditioner
{
typename MatType::InnerIterator it(mat,j);
while(it && it.index()!=j) ++it;
- if(it && it.index()==j)
+ if(it && it.index()==j && it.value()!=Scalar(0))
m_invdiag(j) = Scalar(1)/it.value();
else
- m_invdiag(j) = 0;
+ m_invdiag(j) = Scalar(1);
}
m_isInitialized = true;
return *this;
diff --git a/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h b/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
index 6fc6ab85..55122190 100644
--- a/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
+++ b/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/BiCGSTAB.h
@@ -39,7 +39,6 @@ bool bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x,
int maxIters = iters;
int n = mat.cols();
- x = precond.solve(x);
VectorType r = rhs - mat * x;
VectorType r0 = r;
@@ -61,6 +60,7 @@ bool bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x,
VectorType s(n), t(n);
RealScalar tol2 = tol*tol;
+ RealScalar eps2 = NumTraits<Scalar>::epsilon()*NumTraits<Scalar>::epsilon();
int i = 0;
int restarts = 0;
@@ -69,7 +69,7 @@ bool bicgstab(const MatrixType& mat, const Rhs& rhs, Dest& x,
Scalar rho_old = rho;
rho = r0.dot(r);
- if (internal::isMuchSmallerThan(rho,r0_sqnorm))
+ if (abs(rho) < eps2*r0_sqnorm)
{
// The new residual vector became too orthogonal to the arbitrarily choosen direction r0
// Let's restart with a new r0:
@@ -142,7 +142,7 @@ struct traits<BiCGSTAB<_MatrixType,_Preconditioner> >
* SparseMatrix<double> A(n,n);
* // fill A and b
* BiCGSTAB<SparseMatrix<double> > solver;
- * solver(A);
+ * solver.compute(A);
* x = solver.solve(b);
* std::cout << "#iterations: " << solver.iterations() << std::endl;
* std::cout << "estimated error: " << solver.error() << std::endl;
@@ -151,20 +151,7 @@ struct traits<BiCGSTAB<_MatrixType,_Preconditioner> >
* \endcode
*
* By default the iterations start with x=0 as an initial guess of the solution.
- * One can control the start using the solveWithGuess() method. Here is a step by
- * step execution example starting with a random guess and printing the evolution
- * of the estimated error:
- * * \code
- * x = VectorXd::Random(n);
- * solver.setMaxIterations(1);
- * int i = 0;
- * do {
- * x = solver.solveWithGuess(b,x);
- * std::cout << i << " : " << solver.error() << std::endl;
- * ++i;
- * } while (solver.info()!=Success && i<100);
- * \endcode
- * Note that such a step by step excution is slightly slower.
+ * One can control the start using the solveWithGuess() method.
*
* \sa class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner
*/
@@ -199,7 +186,8 @@ public:
* this class becomes invalid. Call compute() to update it with the new
* matrix A, or modify a copy of A.
*/
- BiCGSTAB(const MatrixType& A) : Base(A) {}
+ template<typename MatrixDerived>
+ explicit BiCGSTAB(const EigenBase<MatrixDerived>& A) : Base(A.derived()) {}
~BiCGSTAB() {}
diff --git a/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h b/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h
index a74a8155..1a7e569c 100644
--- a/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h
+++ b/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/ConjugateGradient.h
@@ -112,9 +112,9 @@ struct traits<ConjugateGradient<_MatrixType,_UpLo,_Preconditioner> >
* This class allows to solve for A.x = b sparse linear problems using a conjugate gradient algorithm.
* The sparse matrix A must be selfadjoint. The vectors x and b can be either dense or sparse.
*
- * \tparam _MatrixType the type of the sparse matrix A, can be a dense or a sparse matrix.
- * \tparam _UpLo the triangular part that will be used for the computations. It can be Lower
- * or Upper. Default is Lower.
+ * \tparam _MatrixType the type of the matrix A, can be a dense or a sparse matrix.
+ * \tparam _UpLo the triangular part that will be used for the computations. It can be Lower,
+ * Upper, or Lower|Upper in which the full matrix entries will be considered. Default is Lower.
* \tparam _Preconditioner the type of the preconditioner. Default is DiagonalPreconditioner
*
* The maximal number of iterations and tolerance value can be controlled via the setMaxIterations()
@@ -137,20 +137,7 @@ struct traits<ConjugateGradient<_MatrixType,_UpLo,_Preconditioner> >
* \endcode
*
* By default the iterations start with x=0 as an initial guess of the solution.
- * One can control the start using the solveWithGuess() method. Here is a step by
- * step execution example starting with a random guess and printing the evolution
- * of the estimated error:
- * * \code
- * x = VectorXd::Random(n);
- * cg.setMaxIterations(1);
- * int i = 0;
- * do {
- * x = cg.solveWithGuess(b,x);
- * std::cout << i << " : " << cg.error() << std::endl;
- * ++i;
- * } while (cg.info()!=Success && i<100);
- * \endcode
- * Note that such a step by step excution is slightly slower.
+ * One can control the start using the solveWithGuess() method.
*
* \sa class SimplicialCholesky, DiagonalPreconditioner, IdentityPreconditioner
*/
@@ -189,7 +176,8 @@ public:
* this class becomes invalid. Call compute() to update it with the new
* matrix A, or modify a copy of A.
*/
- ConjugateGradient(const MatrixType& A) : Base(A) {}
+ template<typename MatrixDerived>
+ explicit ConjugateGradient(const EigenBase<MatrixDerived>& A) : Base(A.derived()) {}
~ConjugateGradient() {}
@@ -213,6 +201,10 @@ public:
template<typename Rhs,typename Dest>
void _solveWithGuess(const Rhs& b, Dest& x) const
{
+ typedef typename internal::conditional<UpLo==(Lower|Upper),
+ const MatrixType&,
+ SparseSelfAdjointView<const MatrixType, UpLo>
+ >::type MatrixWrapperType;
m_iterations = Base::maxIterations();
m_error = Base::m_tolerance;
@@ -222,8 +214,7 @@ public:
m_error = Base::m_tolerance;
typename Dest::ColXpr xj(x,j);
- internal::conjugate_gradient(mp_matrix->template selfadjointView<UpLo>(), b.col(j), xj,
- Base::m_preconditioner, m_iterations, m_error);
+ internal::conjugate_gradient(MatrixWrapperType(*mp_matrix), b.col(j), xj, Base::m_preconditioner, m_iterations, m_error);
}
m_isInitialized = true;
@@ -234,7 +225,7 @@ public:
template<typename Rhs,typename Dest>
void _solve(const Rhs& b, Dest& x) const
{
- x.setOnes();
+ x.setZero();
_solveWithGuess(b,x);
}
diff --git a/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h b/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h
index b55afc13..d3f37fea 100644
--- a/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h
+++ b/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/IncompleteLUT.h
@@ -150,7 +150,6 @@ class IncompleteLUT : internal::noncopyable
{
analyzePattern(amat);
factorize(amat);
- m_isInitialized = m_factorizationIsOk;
return *this;
}
@@ -160,7 +159,7 @@ class IncompleteLUT : internal::noncopyable
template<typename Rhs, typename Dest>
void _solve(const Rhs& b, Dest& x) const
{
- x = m_Pinv * b;
+ x = m_Pinv * b;
x = m_lu.template triangularView<UnitLower>().solve(x);
x = m_lu.template triangularView<Upper>().solve(x);
x = m_P * x;
@@ -223,18 +222,29 @@ template<typename _MatrixType>
void IncompleteLUT<Scalar>::analyzePattern(const _MatrixType& amat)
{
// Compute the Fill-reducing permutation
+ // Since ILUT does not perform any numerical pivoting,
+ // it is highly preferable to keep the diagonal through symmetric permutations.
+#ifndef EIGEN_MPL2_ONLY
+ // To this end, let's symmetrize the pattern and perform AMD on it.
SparseMatrix<Scalar,ColMajor, Index> mat1 = amat;
SparseMatrix<Scalar,ColMajor, Index> mat2 = amat.transpose();
- // Symmetrize the pattern
// FIXME for a matrix with nearly symmetric pattern, mat2+mat1 is the appropriate choice.
// on the other hand for a really non-symmetric pattern, mat2*mat1 should be prefered...
SparseMatrix<Scalar,ColMajor, Index> AtA = mat2 + mat1;
- AtA.prune(keep_diag());
- internal::minimum_degree_ordering<Scalar, Index>(AtA, m_P); // Then compute the AMD ordering...
-
- m_Pinv = m_P.inverse(); // ... and the inverse permutation
+ AMDOrdering<Index> ordering;
+ ordering(AtA,m_P);
+ m_Pinv = m_P.inverse(); // cache the inverse permutation
+#else
+ // If AMD is not available, (MPL2-only), then let's use the slower COLAMD routine.
+ SparseMatrix<Scalar,ColMajor, Index> mat1 = amat;
+ COLAMDOrdering<Index> ordering;
+ ordering(mat1,m_Pinv);
+ m_P = m_Pinv.inverse();
+#endif
m_analysisIsOk = true;
+ m_factorizationIsOk = false;
+ m_isInitialized = false;
}
template <typename Scalar>
@@ -442,6 +452,7 @@ void IncompleteLUT<Scalar>::factorize(const _MatrixType& amat)
m_lu.makeCompressed();
m_factorizationIsOk = true;
+ m_isInitialized = m_factorizationIsOk;
m_info = Success;
}
diff --git a/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h b/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h
index 2036922d..501ef2f8 100644
--- a/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h
+++ b/Utilities/eigen3/Eigen/src/IterativeLinearSolvers/IterativeSolverBase.h
@@ -49,10 +49,11 @@ public:
* this class becomes invalid. Call compute() to update it with the new
* matrix A, or modify a copy of A.
*/
- IterativeSolverBase(const MatrixType& A)
+ template<typename InputDerived>
+ IterativeSolverBase(const EigenBase<InputDerived>& A)
{
init();
- compute(A);
+ compute(A.derived());
}
~IterativeSolverBase() {}
@@ -62,9 +63,11 @@ public:
* Currently, this function mostly call analyzePattern on the preconditioner. In the future
* we might, for instance, implement column reodering for faster matrix vector products.
*/
- Derived& analyzePattern(const MatrixType& A)
+ template<typename InputDerived>
+ Derived& analyzePattern(const EigenBase<InputDerived>& A)
{
- m_preconditioner.analyzePattern(A);
+ grabInput(A.derived());
+ m_preconditioner.analyzePattern(*mp_matrix);
m_isInitialized = true;
m_analysisIsOk = true;
m_info = Success;
@@ -80,11 +83,12 @@ public:
* this class becomes invalid. Call compute() to update it with the new
* matrix A, or modify a copy of A.
*/
- Derived& factorize(const MatrixType& A)
+ template<typename InputDerived>
+ Derived& factorize(const EigenBase<InputDerived>& A)
{
+ grabInput(A.derived());
eigen_assert(m_analysisIsOk && "You must first call analyzePattern()");
- mp_matrix = &A;
- m_preconditioner.factorize(A);
+ m_preconditioner.factorize(*mp_matrix);
m_factorizationIsOk = true;
m_info = Success;
return derived();
@@ -100,10 +104,11 @@ public:
* this class becomes invalid. Call compute() to update it with the new
* matrix A, or modify a copy of A.
*/
- Derived& compute(const MatrixType& A)
+ template<typename InputDerived>
+ Derived& compute(const EigenBase<InputDerived>& A)
{
- mp_matrix = &A;
- m_preconditioner.compute(A);
+ grabInput(A.derived());
+ m_preconditioner.compute(*mp_matrix);
m_isInitialized = true;
m_analysisIsOk = true;
m_factorizationIsOk = true;
@@ -212,6 +217,28 @@ public:
}
protected:
+
+ template<typename InputDerived>
+ void grabInput(const EigenBase<InputDerived>& A)
+ {
+ // we const cast to prevent the creation of a MatrixType temporary by the compiler.
+ grabInput_impl(A.const_cast_derived());
+ }
+
+ template<typename InputDerived>
+ void grabInput_impl(const EigenBase<InputDerived>& A)
+ {
+ m_copyMatrix = A;
+ mp_matrix = &m_copyMatrix;
+ }
+
+ void grabInput_impl(MatrixType& A)
+ {
+ if(MatrixType::RowsAtCompileTime==Dynamic && MatrixType::ColsAtCompileTime==Dynamic)
+ m_copyMatrix.resize(0,0);
+ mp_matrix = &A;
+ }
+
void init()
{
m_isInitialized = false;
@@ -220,6 +247,7 @@ protected:
m_maxIterations = -1;
m_tolerance = NumTraits<Scalar>::epsilon();
}
+ MatrixType m_copyMatrix;
const MatrixType* mp_matrix;
Preconditioner m_preconditioner;
diff --git a/Utilities/eigen3/Eigen/src/LU/FullPivLU.h b/Utilities/eigen3/Eigen/src/LU/FullPivLU.h
index dfe25f42..26bc7144 100644
--- a/Utilities/eigen3/Eigen/src/LU/FullPivLU.h
+++ b/Utilities/eigen3/Eigen/src/LU/FullPivLU.h
@@ -20,10 +20,11 @@ namespace Eigen {
*
* \param MatrixType the type of the matrix of which we are computing the LU decomposition
*
- * This class represents a LU decomposition of any matrix, with complete pivoting: the matrix A
- * is decomposed as A = PLUQ where L is unit-lower-triangular, U is upper-triangular, and P and Q
- * are permutation matrices. This is a rank-revealing LU decomposition. The eigenvalues (diagonal
- * coefficients) of U are sorted in such a way that any zeros are at the end.
+ * This class represents a LU decomposition of any matrix, with complete pivoting: the matrix A is
+ * decomposed as \f$ A = P^{-1} L U Q^{-1} \f$ where L is unit-lower-triangular, U is
+ * upper-triangular, and P and Q are permutation matrices. This is a rank-revealing LU
+ * decomposition. The eigenvalues (diagonal coefficients) of U are sorted in such a way that any
+ * zeros are at the end.
*
* This decomposition provides the generic approach to solving systems of linear equations, computing
* the rank, invertibility, inverse, kernel, and determinant.
@@ -373,6 +374,12 @@ template<typename _MatrixType> class FullPivLU
inline Index cols() const { return m_lu.cols(); }
protected:
+
+ static void check_template_parameters()
+ {
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
+ }
+
MatrixType m_lu;
PermutationPType m_p;
PermutationQType m_q;
@@ -417,6 +424,8 @@ FullPivLU<MatrixType>::FullPivLU(const MatrixType& matrix)
template<typename MatrixType>
FullPivLU<MatrixType>& FullPivLU<MatrixType>::compute(const MatrixType& matrix)
{
+ check_template_parameters();
+
// the permutations are stored as int indices, so just to be sure:
eigen_assert(matrix.rows()<=NumTraits<int>::highest() && matrix.cols()<=NumTraits<int>::highest());
@@ -511,8 +520,8 @@ typename internal::traits<MatrixType>::Scalar FullPivLU<MatrixType>::determinant
}
/** \returns the matrix represented by the decomposition,
- * i.e., it returns the product: P^{-1} L U Q^{-1}.
- * This function is provided for debug purpose. */
+ * i.e., it returns the product: \f$ P^{-1} L U Q^{-1} \f$.
+ * This function is provided for debug purposes. */
template<typename MatrixType>
MatrixType FullPivLU<MatrixType>::reconstructedMatrix() const
{
diff --git a/Utilities/eigen3/Eigen/src/LU/PartialPivLU.h b/Utilities/eigen3/Eigen/src/LU/PartialPivLU.h
index 740ee694..7d1db948 100644
--- a/Utilities/eigen3/Eigen/src/LU/PartialPivLU.h
+++ b/Utilities/eigen3/Eigen/src/LU/PartialPivLU.h
@@ -171,6 +171,12 @@ template<typename _MatrixType> class PartialPivLU
inline Index cols() const { return m_lu.cols(); }
protected:
+
+ static void check_template_parameters()
+ {
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
+ }
+
MatrixType m_lu;
PermutationType m_p;
TranspositionType m_rowsTranspositions;
@@ -386,6 +392,8 @@ void partial_lu_inplace(MatrixType& lu, TranspositionType& row_transpositions, t
template<typename MatrixType>
PartialPivLU<MatrixType>& PartialPivLU<MatrixType>::compute(const MatrixType& matrix)
{
+ check_template_parameters();
+
// the row permutation is stored as int indices, so just to be sure:
eigen_assert(matrix.rows()<NumTraits<int>::highest());
diff --git a/Utilities/eigen3/Eigen/src/OrderingMethods/Amd.h b/Utilities/eigen3/Eigen/src/OrderingMethods/Amd.h
index 41b4fd7e..70550b8a 100644
--- a/Utilities/eigen3/Eigen/src/OrderingMethods/Amd.h
+++ b/Utilities/eigen3/Eigen/src/OrderingMethods/Amd.h
@@ -137,22 +137,27 @@ void minimum_degree_ordering(SparseMatrix<Scalar,ColMajor,Index>& C, Permutation
degree[i] = len[i]; // degree of node i
}
mark = internal::cs_wclear<Index>(0, 0, w, n); /* clear w */
- elen[n] = -2; /* n is a dead element */
- Cp[n] = -1; /* n is a root of assembly tree */
- w[n] = 0; /* n is a dead element */
/* --- Initialize degree lists ------------------------------------------ */
for(i = 0; i < n; i++)
{
+ bool has_diag = false;
+ for(p = Cp[i]; p<Cp[i+1]; ++p)
+ if(Ci[p]==i)
+ {
+ has_diag = true;
+ break;
+ }
+
d = degree[i];
- if(d == 0) /* node i is empty */
+ if(d == 1 && has_diag) /* node i is empty */
{
elen[i] = -2; /* element i is dead */
nel++;
Cp[i] = -1; /* i is a root of assembly tree */
w[i] = 0;
}
- else if(d > dense) /* node i is dense */
+ else if(d > dense || !has_diag) /* node i is dense or has no structural diagonal element */
{
nv[i] = 0; /* absorb i into element n */
elen[i] = -1; /* node i is dead */
@@ -168,6 +173,10 @@ void minimum_degree_ordering(SparseMatrix<Scalar,ColMajor,Index>& C, Permutation
}
}
+ elen[n] = -2; /* n is a dead element */
+ Cp[n] = -1; /* n is a root of assembly tree */
+ w[n] = 0; /* n is a dead element */
+
while (nel < n) /* while (selecting pivots) do */
{
/* --- Select node of minimum approximate degree -------------------- */
diff --git a/Utilities/eigen3/Eigen/src/OrderingMethods/Ordering.h b/Utilities/eigen3/Eigen/src/OrderingMethods/Ordering.h
index b4da6531..f3c31f9c 100644
--- a/Utilities/eigen3/Eigen/src/OrderingMethods/Ordering.h
+++ b/Utilities/eigen3/Eigen/src/OrderingMethods/Ordering.h
@@ -109,7 +109,7 @@ class NaturalOrdering
* \class COLAMDOrdering
*
* Functor computing the \em column \em approximate \em minimum \em degree ordering
- * The matrix should be in column-major format
+ * The matrix should be in column-major and \b compressed format (see SparseMatrix::makeCompressed()).
*/
template<typename Index>
class COLAMDOrdering
@@ -118,10 +118,14 @@ class COLAMDOrdering
typedef PermutationMatrix<Dynamic, Dynamic, Index> PermutationType;
typedef Matrix<Index, Dynamic, 1> IndexVector;
- /** Compute the permutation vector form a sparse matrix */
+ /** Compute the permutation vector \a perm form the sparse matrix \a mat
+ * \warning The input sparse matrix \a mat must be in compressed mode (see SparseMatrix::makeCompressed()).
+ */
template <typename MatrixType>
void operator() (const MatrixType& mat, PermutationType& perm)
{
+ eigen_assert(mat.isCompressed() && "COLAMDOrdering requires a sparse matrix in compressed mode. Call .makeCompressed() before passing it to COLAMDOrdering");
+
Index m = mat.rows();
Index n = mat.cols();
Index nnz = mat.nonZeros();
@@ -132,12 +136,12 @@ class COLAMDOrdering
Index stats [COLAMD_STATS];
internal::colamd_set_defaults(knobs);
- Index info;
IndexVector p(n+1), A(Alen);
for(Index i=0; i <= n; i++) p(i) = mat.outerIndexPtr()[i];
for(Index i=0; i < nnz; i++) A(i) = mat.innerIndexPtr()[i];
// Call Colamd routine to compute the ordering
- info = internal::colamd(m, n, Alen, A.data(), p.data(), knobs, stats);
+ Index info = internal::colamd(m, n, Alen, A.data(), p.data(), knobs, stats);
+ EIGEN_UNUSED_VARIABLE(info);
eigen_assert( info && "COLAMD failed " );
perm.resize(n);
diff --git a/Utilities/eigen3/Eigen/src/PardisoSupport/PardisoSupport.h b/Utilities/eigen3/Eigen/src/PardisoSupport/PardisoSupport.h
index 1c48f0df..18cd7d88 100644
--- a/Utilities/eigen3/Eigen/src/PardisoSupport/PardisoSupport.h
+++ b/Utilities/eigen3/Eigen/src/PardisoSupport/PardisoSupport.h
@@ -219,7 +219,7 @@ class PardisoImpl
void pardisoInit(int type)
{
m_type = type;
- bool symmetric = abs(m_type) < 10;
+ bool symmetric = std::abs(m_type) < 10;
m_iparm[0] = 1; // No solver default
m_iparm[1] = 3; // use Metis for the ordering
m_iparm[2] = 1; // Numbers of processors, value of OMP_NUM_THREADS
diff --git a/Utilities/eigen3/Eigen/src/QR/ColPivHouseholderQR.h b/Utilities/eigen3/Eigen/src/QR/ColPivHouseholderQR.h
index 8b01f817..567eab7c 100644
--- a/Utilities/eigen3/Eigen/src/QR/ColPivHouseholderQR.h
+++ b/Utilities/eigen3/Eigen/src/QR/ColPivHouseholderQR.h
@@ -76,7 +76,8 @@ template<typename _MatrixType> class ColPivHouseholderQR
m_colsTranspositions(),
m_temp(),
m_colSqNorms(),
- m_isInitialized(false) {}
+ m_isInitialized(false),
+ m_usePrescribedThreshold(false) {}
/** \brief Default Constructor with memory preallocation
*
@@ -349,7 +350,7 @@ template<typename _MatrixType> class ColPivHouseholderQR
return m_usePrescribedThreshold ? m_prescribedThreshold
// this formula comes from experimenting (see "LU precision tuning" thread on the list)
// and turns out to be identical to Higham's formula used already in LDLt.
- : NumTraits<Scalar>::epsilon() * m_qr.diagonalSize();
+ : NumTraits<Scalar>::epsilon() * RealScalar(m_qr.diagonalSize());
}
/** \returns the number of nonzero pivots in the QR decomposition.
@@ -383,6 +384,12 @@ template<typename _MatrixType> class ColPivHouseholderQR
}
protected:
+
+ static void check_template_parameters()
+ {
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
+ }
+
MatrixType m_qr;
HCoeffsType m_hCoeffs;
PermutationType m_colsPermutation;
@@ -421,6 +428,8 @@ typename MatrixType::RealScalar ColPivHouseholderQR<MatrixType>::logAbsDetermina
template<typename MatrixType>
ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const MatrixType& matrix)
{
+ check_template_parameters();
+
using std::abs;
Index rows = matrix.rows();
Index cols = matrix.cols();
@@ -462,20 +471,10 @@ ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const
// we store that back into our table: it can't hurt to correct our table.
m_colSqNorms.coeffRef(biggest_col_index) = biggest_col_sq_norm;
- // if the current biggest column is smaller than epsilon times the initial biggest column,
- // terminate to avoid generating nan/inf values.
- // Note that here, if we test instead for "biggest == 0", we get a failure every 1000 (or so)
- // repetitions of the unit test, with the result of solve() filled with large values of the order
- // of 1/(size*epsilon).
- if(biggest_col_sq_norm < threshold_helper * RealScalar(rows-k))
- {
+ // Track the number of meaningful pivots but do not stop the decomposition to make
+ // sure that the initial matrix is properly reproduced. See bug 941.
+ if(m_nonzero_pivots==size && biggest_col_sq_norm < threshold_helper * RealScalar(rows-k))
m_nonzero_pivots = k;
- m_hCoeffs.tail(size-k).setZero();
- m_qr.bottomRightCorner(rows-k,cols-k)
- .template triangularView<StrictlyLower>()
- .setZero();
- break;
- }
// apply the transposition to the columns
m_colsTranspositions.coeffRef(k) = biggest_col_index;
@@ -504,7 +503,7 @@ ColPivHouseholderQR<MatrixType>& ColPivHouseholderQR<MatrixType>::compute(const
}
m_colsPermutation.setIdentity(PermIndexType(cols));
- for(PermIndexType k = 0; k < m_nonzero_pivots; ++k)
+ for(PermIndexType k = 0; k < size/*m_nonzero_pivots*/; ++k)
m_colsPermutation.applyTranspositionOnTheRight(k, PermIndexType(m_colsTranspositions.coeff(k)));
m_det_pq = (number_of_transpositions%2) ? -1 : 1;
@@ -554,13 +553,15 @@ struct solve_retval<ColPivHouseholderQR<_MatrixType>, Rhs>
} // end namespace internal
-/** \returns the matrix Q as a sequence of householder transformations */
+/** \returns the matrix Q as a sequence of householder transformations.
+ * You can extract the meaningful part only by using:
+ * \code qr.householderQ().setLength(qr.nonzeroPivots()) \endcode*/
template<typename MatrixType>
typename ColPivHouseholderQR<MatrixType>::HouseholderSequenceType ColPivHouseholderQR<MatrixType>
::householderQ() const
{
eigen_assert(m_isInitialized && "ColPivHouseholderQR is not initialized.");
- return HouseholderSequenceType(m_qr, m_hCoeffs.conjugate()).setLength(m_nonzero_pivots);
+ return HouseholderSequenceType(m_qr, m_hCoeffs.conjugate());
}
/** \return the column-pivoting Householder QR decomposition of \c *this.
diff --git a/Utilities/eigen3/Eigen/src/QR/FullPivHouseholderQR.h b/Utilities/eigen3/Eigen/src/QR/FullPivHouseholderQR.h
index 0dd5ad34..0b39966e 100644
--- a/Utilities/eigen3/Eigen/src/QR/FullPivHouseholderQR.h
+++ b/Utilities/eigen3/Eigen/src/QR/FullPivHouseholderQR.h
@@ -63,9 +63,10 @@ template<typename _MatrixType> class FullPivHouseholderQR
typedef typename MatrixType::Index Index;
typedef internal::FullPivHouseholderQRMatrixQReturnType<MatrixType> MatrixQReturnType;
typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType;
- typedef Matrix<Index, 1, ColsAtCompileTime, RowMajor, 1, MaxColsAtCompileTime> IntRowVectorType;
+ typedef Matrix<Index, 1,
+ EIGEN_SIZE_MIN_PREFER_DYNAMIC(ColsAtCompileTime,RowsAtCompileTime), RowMajor, 1,
+ EIGEN_SIZE_MIN_PREFER_FIXED(MaxColsAtCompileTime,MaxRowsAtCompileTime)> IntDiagSizeVectorType;
typedef PermutationMatrix<ColsAtCompileTime, MaxColsAtCompileTime> PermutationType;
- typedef typename internal::plain_col_type<MatrixType, Index>::type IntColVectorType;
typedef typename internal::plain_row_type<MatrixType>::type RowVectorType;
typedef typename internal::plain_col_type<MatrixType>::type ColVectorType;
@@ -93,10 +94,10 @@ template<typename _MatrixType> class FullPivHouseholderQR
FullPivHouseholderQR(Index rows, Index cols)
: m_qr(rows, cols),
m_hCoeffs((std::min)(rows,cols)),
- m_rows_transpositions(rows),
- m_cols_transpositions(cols),
+ m_rows_transpositions((std::min)(rows,cols)),
+ m_cols_transpositions((std::min)(rows,cols)),
m_cols_permutation(cols),
- m_temp((std::min)(rows,cols)),
+ m_temp(cols),
m_isInitialized(false),
m_usePrescribedThreshold(false) {}
@@ -115,10 +116,10 @@ template<typename _MatrixType> class FullPivHouseholderQR
FullPivHouseholderQR(const MatrixType& matrix)
: m_qr(matrix.rows(), matrix.cols()),
m_hCoeffs((std::min)(matrix.rows(), matrix.cols())),
- m_rows_transpositions(matrix.rows()),
- m_cols_transpositions(matrix.cols()),
+ m_rows_transpositions((std::min)(matrix.rows(), matrix.cols())),
+ m_cols_transpositions((std::min)(matrix.rows(), matrix.cols())),
m_cols_permutation(matrix.cols()),
- m_temp((std::min)(matrix.rows(), matrix.cols())),
+ m_temp(matrix.cols()),
m_isInitialized(false),
m_usePrescribedThreshold(false)
{
@@ -126,11 +127,12 @@ template<typename _MatrixType> class FullPivHouseholderQR
}
/** This method finds a solution x to the equation Ax=b, where A is the matrix of which
- * *this is the QR decomposition, if any exists.
+ * \c *this is the QR decomposition.
*
* \param b the right-hand-side of the equation to solve.
*
- * \returns a solution.
+ * \returns the exact or least-square solution if the rank is greater or equal to the number of columns of A,
+ * and an arbitrary solution otherwise.
*
* \note The case where b is a matrix is not yet implemented. Also, this
* code is space inefficient.
@@ -172,7 +174,7 @@ template<typename _MatrixType> class FullPivHouseholderQR
}
/** \returns a const reference to the vector of indices representing the rows transpositions */
- const IntColVectorType& rowsTranspositions() const
+ const IntDiagSizeVectorType& rowsTranspositions() const
{
eigen_assert(m_isInitialized && "FullPivHouseholderQR is not initialized.");
return m_rows_transpositions;
@@ -344,7 +346,7 @@ template<typename _MatrixType> class FullPivHouseholderQR
return m_usePrescribedThreshold ? m_prescribedThreshold
// this formula comes from experimenting (see "LU precision tuning" thread on the list)
// and turns out to be identical to Higham's formula used already in LDLt.
- : NumTraits<Scalar>::epsilon() * m_qr.diagonalSize();
+ : NumTraits<Scalar>::epsilon() * RealScalar(m_qr.diagonalSize());
}
/** \returns the number of nonzero pivots in the QR decomposition.
@@ -366,10 +368,16 @@ template<typename _MatrixType> class FullPivHouseholderQR
RealScalar maxPivot() const { return m_maxpivot; }
protected:
+
+ static void check_template_parameters()
+ {
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
+ }
+
MatrixType m_qr;
HCoeffsType m_hCoeffs;
- IntColVectorType m_rows_transpositions;
- IntRowVectorType m_cols_transpositions;
+ IntDiagSizeVectorType m_rows_transpositions;
+ IntDiagSizeVectorType m_cols_transpositions;
PermutationType m_cols_permutation;
RowVectorType m_temp;
bool m_isInitialized, m_usePrescribedThreshold;
@@ -405,6 +413,8 @@ typename MatrixType::RealScalar FullPivHouseholderQR<MatrixType>::logAbsDetermin
template<typename MatrixType>
FullPivHouseholderQR<MatrixType>& FullPivHouseholderQR<MatrixType>::compute(const MatrixType& matrix)
{
+ check_template_parameters();
+
using std::abs;
Index rows = matrix.rows();
Index cols = matrix.cols();
@@ -415,10 +425,10 @@ FullPivHouseholderQR<MatrixType>& FullPivHouseholderQR<MatrixType>::compute(cons
m_temp.resize(cols);
- m_precision = NumTraits<Scalar>::epsilon() * size;
+ m_precision = NumTraits<Scalar>::epsilon() * RealScalar(size);
- m_rows_transpositions.resize(matrix.rows());
- m_cols_transpositions.resize(matrix.cols());
+ m_rows_transpositions.resize(size);
+ m_cols_transpositions.resize(size);
Index number_of_transpositions = 0;
RealScalar biggest(0);
@@ -516,17 +526,6 @@ struct solve_retval<FullPivHouseholderQR<_MatrixType>, Rhs>
dec().hCoeffs().coeff(k), &temp.coeffRef(0));
}
- if(!dec().isSurjective())
- {
- // is c is in the image of R ?
- RealScalar biggest_in_upper_part_of_c = c.topRows( dec().rank() ).cwiseAbs().maxCoeff();
- RealScalar biggest_in_lower_part_of_c = c.bottomRows(rows-dec().rank()).cwiseAbs().maxCoeff();
- // FIXME brain dead
- const RealScalar m_precision = NumTraits<Scalar>::epsilon() * (std::min)(rows,cols);
- // this internal:: prefix is needed by at least gcc 3.4 and ICC
- if(!internal::isMuchSmallerThan(biggest_in_lower_part_of_c, biggest_in_upper_part_of_c, m_precision))
- return;
- }
dec().matrixQR()
.topLeftCorner(dec().rank(), dec().rank())
.template triangularView<Upper>()
@@ -548,14 +547,14 @@ template<typename MatrixType> struct FullPivHouseholderQRMatrixQReturnType
{
public:
typedef typename MatrixType::Index Index;
- typedef typename internal::plain_col_type<MatrixType, Index>::type IntColVectorType;
+ typedef typename FullPivHouseholderQR<MatrixType>::IntDiagSizeVectorType IntDiagSizeVectorType;
typedef typename internal::plain_diag_type<MatrixType>::type HCoeffsType;
typedef Matrix<typename MatrixType::Scalar, 1, MatrixType::RowsAtCompileTime, RowMajor, 1,
MatrixType::MaxRowsAtCompileTime> WorkVectorType;
FullPivHouseholderQRMatrixQReturnType(const MatrixType& qr,
const HCoeffsType& hCoeffs,
- const IntColVectorType& rowsTranspositions)
+ const IntDiagSizeVectorType& rowsTranspositions)
: m_qr(qr),
m_hCoeffs(hCoeffs),
m_rowsTranspositions(rowsTranspositions)
@@ -595,7 +594,7 @@ public:
protected:
typename MatrixType::Nested m_qr;
typename HCoeffsType::Nested m_hCoeffs;
- typename IntColVectorType::Nested m_rowsTranspositions;
+ typename IntDiagSizeVectorType::Nested m_rowsTranspositions;
};
} // end namespace internal
diff --git a/Utilities/eigen3/Eigen/src/QR/HouseholderQR.h b/Utilities/eigen3/Eigen/src/QR/HouseholderQR.h
index abc61bcb..343a6649 100644
--- a/Utilities/eigen3/Eigen/src/QR/HouseholderQR.h
+++ b/Utilities/eigen3/Eigen/src/QR/HouseholderQR.h
@@ -189,6 +189,12 @@ template<typename _MatrixType> class HouseholderQR
const HCoeffsType& hCoeffs() const { return m_hCoeffs; }
protected:
+
+ static void check_template_parameters()
+ {
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
+ }
+
MatrixType m_qr;
HCoeffsType m_hCoeffs;
RowVectorType m_temp;
@@ -251,56 +257,62 @@ void householder_qr_inplace_unblocked(MatrixQR& mat, HCoeffs& hCoeffs, typename
}
/** \internal */
-template<typename MatrixQR, typename HCoeffs>
-void householder_qr_inplace_blocked(MatrixQR& mat, HCoeffs& hCoeffs,
- typename MatrixQR::Index maxBlockSize=32,
- typename MatrixQR::Scalar* tempData = 0)
+template<typename MatrixQR, typename HCoeffs,
+ typename MatrixQRScalar = typename MatrixQR::Scalar,
+ bool InnerStrideIsOne = (MatrixQR::InnerStrideAtCompileTime == 1 && HCoeffs::InnerStrideAtCompileTime == 1)>
+struct householder_qr_inplace_blocked
{
- typedef typename MatrixQR::Index Index;
- typedef typename MatrixQR::Scalar Scalar;
- typedef Block<MatrixQR,Dynamic,Dynamic> BlockType;
-
- Index rows = mat.rows();
- Index cols = mat.cols();
- Index size = (std::min)(rows, cols);
-
- typedef Matrix<Scalar,Dynamic,1,ColMajor,MatrixQR::MaxColsAtCompileTime,1> TempType;
- TempType tempVector;
- if(tempData==0)
+ // This is specialized for MKL-supported Scalar types in HouseholderQR_MKL.h
+ static void run(MatrixQR& mat, HCoeffs& hCoeffs,
+ typename MatrixQR::Index maxBlockSize=32,
+ typename MatrixQR::Scalar* tempData = 0)
{
- tempVector.resize(cols);
- tempData = tempVector.data();
- }
-
- Index blockSize = (std::min)(maxBlockSize,size);
+ typedef typename MatrixQR::Index Index;
+ typedef typename MatrixQR::Scalar Scalar;
+ typedef Block<MatrixQR,Dynamic,Dynamic> BlockType;
- Index k = 0;
- for (k = 0; k < size; k += blockSize)
- {
- Index bs = (std::min)(size-k,blockSize); // actual size of the block
- Index tcols = cols - k - bs; // trailing columns
- Index brows = rows-k; // rows of the block
+ Index rows = mat.rows();
+ Index cols = mat.cols();
+ Index size = (std::min)(rows, cols);
- // partition the matrix:
- // A00 | A01 | A02
- // mat = A10 | A11 | A12
- // A20 | A21 | A22
- // and performs the qr dec of [A11^T A12^T]^T
- // and update [A21^T A22^T]^T using level 3 operations.
- // Finally, the algorithm continue on A22
-
- BlockType A11_21 = mat.block(k,k,brows,bs);
- Block<HCoeffs,Dynamic,1> hCoeffsSegment = hCoeffs.segment(k,bs);
+ typedef Matrix<Scalar,Dynamic,1,ColMajor,MatrixQR::MaxColsAtCompileTime,1> TempType;
+ TempType tempVector;
+ if(tempData==0)
+ {
+ tempVector.resize(cols);
+ tempData = tempVector.data();
+ }
- householder_qr_inplace_unblocked(A11_21, hCoeffsSegment, tempData);
+ Index blockSize = (std::min)(maxBlockSize,size);
- if(tcols)
+ Index k = 0;
+ for (k = 0; k < size; k += blockSize)
{
- BlockType A21_22 = mat.block(k,k+bs,brows,tcols);
- apply_block_householder_on_the_left(A21_22,A11_21,hCoeffsSegment.adjoint());
+ Index bs = (std::min)(size-k,blockSize); // actual size of the block
+ Index tcols = cols - k - bs; // trailing columns
+ Index brows = rows-k; // rows of the block
+
+ // partition the matrix:
+ // A00 | A01 | A02
+ // mat = A10 | A11 | A12
+ // A20 | A21 | A22
+ // and performs the qr dec of [A11^T A12^T]^T
+ // and update [A21^T A22^T]^T using level 3 operations.
+ // Finally, the algorithm continue on A22
+
+ BlockType A11_21 = mat.block(k,k,brows,bs);
+ Block<HCoeffs,Dynamic,1> hCoeffsSegment = hCoeffs.segment(k,bs);
+
+ householder_qr_inplace_unblocked(A11_21, hCoeffsSegment, tempData);
+
+ if(tcols)
+ {
+ BlockType A21_22 = mat.block(k,k+bs,brows,tcols);
+ apply_block_householder_on_the_left(A21_22,A11_21,hCoeffsSegment.adjoint());
+ }
}
}
-}
+};
template<typename _MatrixType, typename Rhs>
struct solve_retval<HouseholderQR<_MatrixType>, Rhs>
@@ -343,6 +355,8 @@ struct solve_retval<HouseholderQR<_MatrixType>, Rhs>
template<typename MatrixType>
HouseholderQR<MatrixType>& HouseholderQR<MatrixType>::compute(const MatrixType& matrix)
{
+ check_template_parameters();
+
Index rows = matrix.rows();
Index cols = matrix.cols();
Index size = (std::min)(rows,cols);
@@ -352,7 +366,7 @@ HouseholderQR<MatrixType>& HouseholderQR<MatrixType>::compute(const MatrixType&
m_temp.resize(cols);
- internal::householder_qr_inplace_blocked(m_qr, m_hCoeffs, 48, m_temp.data());
+ internal::householder_qr_inplace_blocked<MatrixType, HCoeffsType>::run(m_qr, m_hCoeffs, 48, m_temp.data());
m_isInitialized = true;
return *this;
diff --git a/Utilities/eigen3/Eigen/src/QR/HouseholderQR_MKL.h b/Utilities/eigen3/Eigen/src/QR/HouseholderQR_MKL.h
index 5313de60..b80f1b48 100644
--- a/Utilities/eigen3/Eigen/src/QR/HouseholderQR_MKL.h
+++ b/Utilities/eigen3/Eigen/src/QR/HouseholderQR_MKL.h
@@ -34,28 +34,30 @@
#ifndef EIGEN_QR_MKL_H
#define EIGEN_QR_MKL_H
-#include "Eigen/src/Core/util/MKL_support.h"
+#include "../Core/util/MKL_support.h"
namespace Eigen {
-namespace internal {
+ namespace internal {
-/** \internal Specialization for the data types supported by MKL */
+ /** \internal Specialization for the data types supported by MKL */
#define EIGEN_MKL_QR_NOPIV(EIGTYPE, MKLTYPE, MKLPREFIX) \
template<typename MatrixQR, typename HCoeffs> \
-void householder_qr_inplace_blocked(MatrixQR& mat, HCoeffs& hCoeffs, \
- typename MatrixQR::Index maxBlockSize=32, \
- EIGTYPE* tempData = 0) \
+struct householder_qr_inplace_blocked<MatrixQR, HCoeffs, EIGTYPE, true> \
{ \
- lapack_int m = mat.rows(); \
- lapack_int n = mat.cols(); \
- lapack_int lda = mat.outerStride(); \
- lapack_int matrix_order = (MatrixQR::IsRowMajor) ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \
- LAPACKE_##MKLPREFIX##geqrf( matrix_order, m, n, (MKLTYPE*)mat.data(), lda, (MKLTYPE*)hCoeffs.data()); \
- hCoeffs.adjointInPlace(); \
-\
-}
+ static void run(MatrixQR& mat, HCoeffs& hCoeffs, \
+ typename MatrixQR::Index = 32, \
+ typename MatrixQR::Scalar* = 0) \
+ { \
+ lapack_int m = (lapack_int) mat.rows(); \
+ lapack_int n = (lapack_int) mat.cols(); \
+ lapack_int lda = (lapack_int) mat.outerStride(); \
+ lapack_int matrix_order = (MatrixQR::IsRowMajor) ? LAPACK_ROW_MAJOR : LAPACK_COL_MAJOR; \
+ LAPACKE_##MKLPREFIX##geqrf( matrix_order, m, n, (MKLTYPE*)mat.data(), lda, (MKLTYPE*)hCoeffs.data()); \
+ hCoeffs.adjointInPlace(); \
+ } \
+};
EIGEN_MKL_QR_NOPIV(double, double, d)
EIGEN_MKL_QR_NOPIV(float, float, s)
diff --git a/Utilities/eigen3/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h b/Utilities/eigen3/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h
index aa41f434..36138101 100644
--- a/Utilities/eigen3/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h
+++ b/Utilities/eigen3/Eigen/src/SPQRSupport/SuiteSparseQRSupport.h
@@ -47,7 +47,7 @@ namespace Eigen {
* You can then apply it to a vector.
*
* R is the sparse triangular factor. Use matrixQR() to get it as SparseMatrix.
- * NOTE : The Index type of R is always UF_long. You can get it with SPQR::Index
+ * NOTE : The Index type of R is always SuiteSparse_long. You can get it with SPQR::Index
*
* \tparam _MatrixType The type of the sparse matrix A, must be a column-major SparseMatrix<>
* NOTE
@@ -59,22 +59,18 @@ class SPQR
public:
typedef typename _MatrixType::Scalar Scalar;
typedef typename _MatrixType::RealScalar RealScalar;
- typedef UF_long Index ;
+ typedef SuiteSparse_long Index ;
typedef SparseMatrix<Scalar, ColMajor, Index> MatrixType;
typedef PermutationMatrix<Dynamic, Dynamic> PermutationType;
public:
SPQR()
- : m_ordering(SPQR_ORDERING_DEFAULT),
- m_allow_tol(SPQR_DEFAULT_TOL),
- m_tolerance (NumTraits<Scalar>::epsilon())
+ : m_isInitialized(false), m_ordering(SPQR_ORDERING_DEFAULT), m_allow_tol(SPQR_DEFAULT_TOL), m_tolerance (NumTraits<Scalar>::epsilon()), m_useDefaultThreshold(true)
{
cholmod_l_start(&m_cc);
}
- SPQR(const _MatrixType& matrix)
- : m_ordering(SPQR_ORDERING_DEFAULT),
- m_allow_tol(SPQR_DEFAULT_TOL),
- m_tolerance (NumTraits<Scalar>::epsilon())
+ SPQR(const _MatrixType& matrix)
+ : m_isInitialized(false), m_ordering(SPQR_ORDERING_DEFAULT), m_allow_tol(SPQR_DEFAULT_TOL), m_tolerance (NumTraits<Scalar>::epsilon()), m_useDefaultThreshold(true)
{
cholmod_l_start(&m_cc);
compute(matrix);
@@ -82,21 +78,43 @@ class SPQR
~SPQR()
{
- // Calls SuiteSparseQR_free()
+ SPQR_free();
+ cholmod_l_finish(&m_cc);
+ }
+ void SPQR_free()
+ {
cholmod_l_free_sparse(&m_H, &m_cc);
cholmod_l_free_sparse(&m_cR, &m_cc);
cholmod_l_free_dense(&m_HTau, &m_cc);
std::free(m_E);
std::free(m_HPinv);
- cholmod_l_finish(&m_cc);
}
+
void compute(const _MatrixType& matrix)
{
+ if(m_isInitialized) SPQR_free();
+
MatrixType mat(matrix);
+
+ /* Compute the default threshold as in MatLab, see:
+ * Tim Davis, "Algorithm 915, SuiteSparseQR: Multifrontal Multithreaded Rank-Revealing
+ * Sparse QR Factorization, ACM Trans. on Math. Soft. 38(1), 2011, Page 8:3
+ */
+ RealScalar pivotThreshold = m_tolerance;
+ if(m_useDefaultThreshold)
+ {
+ using std::max;
+ RealScalar max2Norm = 0.0;
+ for (int j = 0; j < mat.cols(); j++) max2Norm = (max)(max2Norm, mat.col(j).norm());
+ if(max2Norm==RealScalar(0))
+ max2Norm = RealScalar(1);
+ pivotThreshold = 20 * (mat.rows() + mat.cols()) * max2Norm * NumTraits<RealScalar>::epsilon();
+ }
+
cholmod_sparse A;
A = viewAsCholmod(mat);
Index col = matrix.cols();
- m_rank = SuiteSparseQR<Scalar>(m_ordering, m_tolerance, col, &A,
+ m_rank = SuiteSparseQR<Scalar>(m_ordering, pivotThreshold, col, &A,
&m_cR, &m_E, &m_H, &m_HPinv, &m_HTau, &m_cc);
if (!m_cR)
@@ -112,7 +130,7 @@ class SPQR
/**
* Get the number of rows of the input matrix and the Q matrix
*/
- inline Index rows() const {return m_H->nrow; }
+ inline Index rows() const {return m_cR->nrow; }
/**
* Get the number of columns of the input matrix.
@@ -137,16 +155,25 @@ class SPQR
{
eigen_assert(m_isInitialized && " The QR factorization should be computed first, call compute()");
eigen_assert(b.cols()==1 && "This method is for vectors only");
-
+
//Compute Q^T * b
- Dest y;
+ typename Dest::PlainObject y, y2;
y = matrixQ().transpose() * b;
- // Solves with the triangular matrix R
+
+ // Solves with the triangular matrix R
Index rk = this->rank();
- y.topRows(rk) = this->matrixR().topLeftCorner(rk, rk).template triangularView<Upper>().solve(y.topRows(rk));
- y.bottomRows(cols()-rk).setZero();
+ y2 = y;
+ y.resize((std::max)(cols(),Index(y.rows())),y.cols());
+ y.topRows(rk) = this->matrixR().topLeftCorner(rk, rk).template triangularView<Upper>().solve(y2.topRows(rk));
+
// Apply the column permutation
- dest.topRows(cols()) = colsPermutation() * y.topRows(cols());
+ // colsPermutation() performs a copy of the permutation,
+ // so let's apply it manually:
+ for(Index i = 0; i < rk; ++i) dest.row(m_E[i]) = y.row(i);
+ for(Index i = rk; i < cols(); ++i) dest.row(m_E[i]).setZero();
+
+// y.bottomRows(y.rows()-rk).setZero();
+// dest = colsPermutation() * y.topRows(cols());
m_info = Success;
}
@@ -189,7 +216,11 @@ class SPQR
/// Set the fill-reducing ordering method to be used
void setSPQROrdering(int ord) { m_ordering = ord;}
/// Set the tolerance tol to treat columns with 2-norm < =tol as zero
- void setPivotThreshold(const RealScalar& tol) { m_tolerance = tol; }
+ void setPivotThreshold(const RealScalar& tol)
+ {
+ m_useDefaultThreshold = false;
+ m_tolerance = tol;
+ }
/** \returns a pointer to the SPQR workspace */
cholmod_common *cholmodCommon() const { return &m_cc; }
@@ -222,6 +253,7 @@ class SPQR
mutable cholmod_dense *m_HTau; // The Householder coefficients
mutable Index m_rank; // The rank of the matrix
mutable cholmod_common m_cc; // Workspace and parameters
+ bool m_useDefaultThreshold; // Use default threshold
template<typename ,typename > friend struct SPQR_QProduct;
};
diff --git a/Utilities/eigen3/Eigen/src/SVD/JacobiSVD.h b/Utilities/eigen3/Eigen/src/SVD/JacobiSVD.h
index 4786768f..1b297741 100644
--- a/Utilities/eigen3/Eigen/src/SVD/JacobiSVD.h
+++ b/Utilities/eigen3/Eigen/src/SVD/JacobiSVD.h
@@ -375,14 +375,19 @@ struct svd_precondition_2x2_block_to_be_real<MatrixType, QRPreconditioner, true>
Scalar z;
JacobiRotation<Scalar> rot;
RealScalar n = sqrt(numext::abs2(work_matrix.coeff(p,p)) + numext::abs2(work_matrix.coeff(q,p)));
+
if(n==0)
{
z = abs(work_matrix.coeff(p,q)) / work_matrix.coeff(p,q);
work_matrix.row(p) *= z;
if(svd.computeU()) svd.m_matrixU.col(p) *= conj(z);
- z = abs(work_matrix.coeff(q,q)) / work_matrix.coeff(q,q);
- work_matrix.row(q) *= z;
- if(svd.computeU()) svd.m_matrixU.col(q) *= conj(z);
+ if(work_matrix.coeff(q,q)!=Scalar(0))
+ {
+ z = abs(work_matrix.coeff(q,q)) / work_matrix.coeff(q,q);
+ work_matrix.row(q) *= z;
+ if(svd.computeU()) svd.m_matrixU.col(q) *= conj(z);
+ }
+ // otherwise the second row is already zero, so we have nothing to do.
}
else
{
@@ -412,6 +417,7 @@ void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q,
JacobiRotation<RealScalar> *j_right)
{
using std::sqrt;
+ using std::abs;
Matrix<RealScalar,2,2> m;
m << numext::real(matrix.coeff(p,p)), numext::real(matrix.coeff(p,q)),
numext::real(matrix.coeff(q,p)), numext::real(matrix.coeff(q,q));
@@ -425,9 +431,11 @@ void real_2x2_jacobi_svd(const MatrixType& matrix, Index p, Index q,
}
else
{
- RealScalar u = d / t;
- rot1.c() = RealScalar(1) / sqrt(RealScalar(1) + numext::abs2(u));
- rot1.s() = rot1.c() * u;
+ RealScalar t2d2 = numext::hypot(t,d);
+ rot1.c() = abs(t)/t2d2;
+ rot1.s() = d/t2d2;
+ if(t<RealScalar(0))
+ rot1.s() = -rot1.s();
}
m.applyOnTheLeft(0,1,rot1);
j_right->makeJacobi(m,0,1);
@@ -528,8 +536,9 @@ template<typename _MatrixType, int QRPreconditioner> class JacobiSVD
JacobiSVD()
: m_isInitialized(false),
m_isAllocated(false),
+ m_usePrescribedThreshold(false),
m_computationOptions(0),
- m_rows(-1), m_cols(-1)
+ m_rows(-1), m_cols(-1), m_diagSize(0)
{}
@@ -542,6 +551,7 @@ template<typename _MatrixType, int QRPreconditioner> class JacobiSVD
JacobiSVD(Index rows, Index cols, unsigned int computationOptions = 0)
: m_isInitialized(false),
m_isAllocated(false),
+ m_usePrescribedThreshold(false),
m_computationOptions(0),
m_rows(-1), m_cols(-1)
{
@@ -561,6 +571,7 @@ template<typename _MatrixType, int QRPreconditioner> class JacobiSVD
JacobiSVD(const MatrixType& matrix, unsigned int computationOptions = 0)
: m_isInitialized(false),
m_isAllocated(false),
+ m_usePrescribedThreshold(false),
m_computationOptions(0),
m_rows(-1), m_cols(-1)
{
@@ -662,23 +673,92 @@ template<typename _MatrixType, int QRPreconditioner> class JacobiSVD
eigen_assert(m_isInitialized && "JacobiSVD is not initialized.");
return m_nonzeroSingularValues;
}
+
+ /** \returns the rank of the matrix of which \c *this is the SVD.
+ *
+ * \note This method has to determine which singular values should be considered nonzero.
+ * For that, it uses the threshold value that you can control by calling
+ * setThreshold(const RealScalar&).
+ */
+ inline Index rank() const
+ {
+ using std::abs;
+ eigen_assert(m_isInitialized && "JacobiSVD is not initialized.");
+ if(m_singularValues.size()==0) return 0;
+ RealScalar premultiplied_threshold = m_singularValues.coeff(0) * threshold();
+ Index i = m_nonzeroSingularValues-1;
+ while(i>=0 && m_singularValues.coeff(i) < premultiplied_threshold) --i;
+ return i+1;
+ }
+
+ /** Allows to prescribe a threshold to be used by certain methods, such as rank() and solve(),
+ * which need to determine when singular values are to be considered nonzero.
+ * This is not used for the SVD decomposition itself.
+ *
+ * When it needs to get the threshold value, Eigen calls threshold().
+ * The default is \c NumTraits<Scalar>::epsilon()
+ *
+ * \param threshold The new value to use as the threshold.
+ *
+ * A singular value will be considered nonzero if its value is strictly greater than
+ * \f$ \vert singular value \vert \leqslant threshold \times \vert max singular value \vert \f$.
+ *
+ * If you want to come back to the default behavior, call setThreshold(Default_t)
+ */
+ JacobiSVD& setThreshold(const RealScalar& threshold)
+ {
+ m_usePrescribedThreshold = true;
+ m_prescribedThreshold = threshold;
+ return *this;
+ }
+
+ /** Allows to come back to the default behavior, letting Eigen use its default formula for
+ * determining the threshold.
+ *
+ * You should pass the special object Eigen::Default as parameter here.
+ * \code svd.setThreshold(Eigen::Default); \endcode
+ *
+ * See the documentation of setThreshold(const RealScalar&).
+ */
+ JacobiSVD& setThreshold(Default_t)
+ {
+ m_usePrescribedThreshold = false;
+ return *this;
+ }
+
+ /** Returns the threshold that will be used by certain methods such as rank().
+ *
+ * See the documentation of setThreshold(const RealScalar&).
+ */
+ RealScalar threshold() const
+ {
+ eigen_assert(m_isInitialized || m_usePrescribedThreshold);
+ return m_usePrescribedThreshold ? m_prescribedThreshold
+ : (std::max<Index>)(1,m_diagSize)*NumTraits<Scalar>::epsilon();
+ }
inline Index rows() const { return m_rows; }
inline Index cols() const { return m_cols; }
private:
void allocate(Index rows, Index cols, unsigned int computationOptions);
+
+ static void check_template_parameters()
+ {
+ EIGEN_STATIC_ASSERT_NON_INTEGER(Scalar);
+ }
protected:
MatrixUType m_matrixU;
MatrixVType m_matrixV;
SingularValuesType m_singularValues;
WorkMatrixType m_workMatrix;
- bool m_isInitialized, m_isAllocated;
+ bool m_isInitialized, m_isAllocated, m_usePrescribedThreshold;
bool m_computeFullU, m_computeThinU;
bool m_computeFullV, m_computeThinV;
unsigned int m_computationOptions;
Index m_nonzeroSingularValues, m_rows, m_cols, m_diagSize;
+ RealScalar m_prescribedThreshold;
template<typename __MatrixType, int _QRPreconditioner, bool _IsComplex>
friend struct internal::svd_precondition_2x2_block_to_be_real;
@@ -687,6 +767,7 @@ template<typename _MatrixType, int QRPreconditioner> class JacobiSVD
internal::qr_preconditioner_impl<MatrixType, QRPreconditioner, internal::PreconditionIfMoreColsThanRows> m_qr_precond_morecols;
internal::qr_preconditioner_impl<MatrixType, QRPreconditioner, internal::PreconditionIfMoreRowsThanCols> m_qr_precond_morerows;
+ MatrixType m_scaledMatrix;
};
template<typename MatrixType, int QRPreconditioner>
@@ -733,14 +814,17 @@ void JacobiSVD<MatrixType, QRPreconditioner>::allocate(Index rows, Index cols, u
: 0);
m_workMatrix.resize(m_diagSize, m_diagSize);
- if(m_cols>m_rows) m_qr_precond_morecols.allocate(*this);
- if(m_rows>m_cols) m_qr_precond_morerows.allocate(*this);
+ if(m_cols>m_rows) m_qr_precond_morecols.allocate(*this);
+ if(m_rows>m_cols) m_qr_precond_morerows.allocate(*this);
+ if(m_cols!=m_cols) m_scaledMatrix.resize(rows,cols);
}
template<typename MatrixType, int QRPreconditioner>
JacobiSVD<MatrixType, QRPreconditioner>&
JacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsigned int computationOptions)
{
+ check_template_parameters();
+
using std::abs;
allocate(matrix.rows(), matrix.cols(), computationOptions);
@@ -751,11 +835,21 @@ JacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsig
// limit for very small denormal numbers to be considered zero in order to avoid infinite loops (see bug 286)
const RealScalar considerAsZero = RealScalar(2) * std::numeric_limits<RealScalar>::denorm_min();
+ // Scaling factor to reduce over/under-flows
+ RealScalar scale = matrix.cwiseAbs().maxCoeff();
+ if(scale==RealScalar(0)) scale = RealScalar(1);
+
/*** step 1. The R-SVD step: we use a QR decomposition to reduce to the case of a square matrix */
- if(!m_qr_precond_morecols.run(*this, matrix) && !m_qr_precond_morerows.run(*this, matrix))
+ if(m_rows!=m_cols)
{
- m_workMatrix = matrix.block(0,0,m_diagSize,m_diagSize);
+ m_scaledMatrix = matrix / scale;
+ m_qr_precond_morecols.run(*this, m_scaledMatrix);
+ m_qr_precond_morerows.run(*this, m_scaledMatrix);
+ }
+ else
+ {
+ m_workMatrix = matrix.block(0,0,m_diagSize,m_diagSize) / scale;
if(m_computeFullU) m_matrixU.setIdentity(m_rows,m_rows);
if(m_computeThinU) m_matrixU.setIdentity(m_rows,m_diagSize);
if(m_computeFullV) m_matrixV.setIdentity(m_cols,m_cols);
@@ -781,7 +875,8 @@ JacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsig
using std::max;
RealScalar threshold = (max)(considerAsZero, precision * (max)(abs(m_workMatrix.coeff(p,p)),
abs(m_workMatrix.coeff(q,q))));
- if((max)(abs(m_workMatrix.coeff(p,q)),abs(m_workMatrix.coeff(q,p))) > threshold)
+ // We compare both values to threshold instead of calling max to be robust to NaN (See bug 791)
+ if(abs(m_workMatrix.coeff(p,q))>threshold || abs(m_workMatrix.coeff(q,p)) > threshold)
{
finished = false;
@@ -830,6 +925,8 @@ JacobiSVD<MatrixType, QRPreconditioner>::compute(const MatrixType& matrix, unsig
if(computeV()) m_matrixV.col(pos).swap(m_matrixV.col(i));
}
}
+
+ m_singularValues *= scale;
m_isInitialized = true;
return *this;
@@ -851,11 +948,11 @@ struct solve_retval<JacobiSVD<_MatrixType, QRPreconditioner>, Rhs>
// So A^{-1} = V S^{-1} U^*
Matrix<Scalar, Dynamic, Rhs::ColsAtCompileTime, 0, _MatrixType::MaxRowsAtCompileTime, Rhs::MaxColsAtCompileTime> tmp;
- Index nonzeroSingVals = dec().nonzeroSingularValues();
+ Index rank = dec().rank();
- tmp.noalias() = dec().matrixU().leftCols(nonzeroSingVals).adjoint() * rhs();
- tmp = dec().singularValues().head(nonzeroSingVals).asDiagonal().inverse() * tmp;
- dst = dec().matrixV().leftCols(nonzeroSingVals) * tmp;
+ tmp.noalias() = dec().matrixU().leftCols(rank).adjoint() * rhs();
+ tmp = dec().singularValues().head(rank).asDiagonal().inverse() * tmp;
+ dst = dec().matrixV().leftCols(rank) * tmp;
}
};
} // end namespace internal
diff --git a/Utilities/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky.h b/Utilities/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky.h
index f41d7e01..e1f96ba5 100644
--- a/Utilities/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky.h
+++ b/Utilities/eigen3/Eigen/src/SparseCholesky/SimplicialCholesky.h
@@ -37,6 +37,7 @@ class SimplicialCholeskyBase : internal::noncopyable
{
public:
typedef typename internal::traits<Derived>::MatrixType MatrixType;
+ typedef typename internal::traits<Derived>::OrderingType OrderingType;
enum { UpLo = internal::traits<Derived>::UpLo };
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::RealScalar RealScalar;
@@ -240,15 +241,16 @@ class SimplicialCholeskyBase : internal::noncopyable
RealScalar m_shiftScale;
};
-template<typename _MatrixType, int _UpLo = Lower> class SimplicialLLT;
-template<typename _MatrixType, int _UpLo = Lower> class SimplicialLDLT;
-template<typename _MatrixType, int _UpLo = Lower> class SimplicialCholesky;
+template<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::Index> > class SimplicialLLT;
+template<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::Index> > class SimplicialLDLT;
+template<typename _MatrixType, int _UpLo = Lower, typename _Ordering = AMDOrdering<typename _MatrixType::Index> > class SimplicialCholesky;
namespace internal {
-template<typename _MatrixType, int _UpLo> struct traits<SimplicialLLT<_MatrixType,_UpLo> >
+template<typename _MatrixType, int _UpLo, typename _Ordering> struct traits<SimplicialLLT<_MatrixType,_UpLo,_Ordering> >
{
typedef _MatrixType MatrixType;
+ typedef _Ordering OrderingType;
enum { UpLo = _UpLo };
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Index Index;
@@ -259,9 +261,10 @@ template<typename _MatrixType, int _UpLo> struct traits<SimplicialLLT<_MatrixTyp
static inline MatrixU getU(const MatrixType& m) { return m.adjoint(); }
};
-template<typename _MatrixType,int _UpLo> struct traits<SimplicialLDLT<_MatrixType,_UpLo> >
+template<typename _MatrixType,int _UpLo, typename _Ordering> struct traits<SimplicialLDLT<_MatrixType,_UpLo,_Ordering> >
{
typedef _MatrixType MatrixType;
+ typedef _Ordering OrderingType;
enum { UpLo = _UpLo };
typedef typename MatrixType::Scalar Scalar;
typedef typename MatrixType::Index Index;
@@ -272,9 +275,10 @@ template<typename _MatrixType,int _UpLo> struct traits<SimplicialLDLT<_MatrixTyp
static inline MatrixU getU(const MatrixType& m) { return m.adjoint(); }
};
-template<typename _MatrixType, int _UpLo> struct traits<SimplicialCholesky<_MatrixType,_UpLo> >
+template<typename _MatrixType, int _UpLo, typename _Ordering> struct traits<SimplicialCholesky<_MatrixType,_UpLo,_Ordering> >
{
typedef _MatrixType MatrixType;
+ typedef _Ordering OrderingType;
enum { UpLo = _UpLo };
};
@@ -294,11 +298,12 @@ template<typename _MatrixType, int _UpLo> struct traits<SimplicialCholesky<_Matr
* \tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>
* \tparam _UpLo the triangular part that will be used for the computations. It can be Lower
* or Upper. Default is Lower.
+ * \tparam _Ordering The ordering method to use, either AMDOrdering<> or NaturalOrdering<>. Default is AMDOrdering<>
*
- * \sa class SimplicialLDLT
+ * \sa class SimplicialLDLT, class AMDOrdering, class NaturalOrdering
*/
-template<typename _MatrixType, int _UpLo>
- class SimplicialLLT : public SimplicialCholeskyBase<SimplicialLLT<_MatrixType,_UpLo> >
+template<typename _MatrixType, int _UpLo, typename _Ordering>
+ class SimplicialLLT : public SimplicialCholeskyBase<SimplicialLLT<_MatrixType,_UpLo,_Ordering> >
{
public:
typedef _MatrixType MatrixType;
@@ -382,11 +387,12 @@ public:
* \tparam _MatrixType the type of the sparse matrix A, it must be a SparseMatrix<>
* \tparam _UpLo the triangular part that will be used for the computations. It can be Lower
* or Upper. Default is Lower.
+ * \tparam _Ordering The ordering method to use, either AMDOrdering<> or NaturalOrdering<>. Default is AMDOrdering<>
*
- * \sa class SimplicialLLT
+ * \sa class SimplicialLLT, class AMDOrdering, class NaturalOrdering
*/
-template<typename _MatrixType, int _UpLo>
- class SimplicialLDLT : public SimplicialCholeskyBase<SimplicialLDLT<_MatrixType,_UpLo> >
+template<typename _MatrixType, int _UpLo, typename _Ordering>
+ class SimplicialLDLT : public SimplicialCholeskyBase<SimplicialLDLT<_MatrixType,_UpLo,_Ordering> >
{
public:
typedef _MatrixType MatrixType;
@@ -467,8 +473,8 @@ public:
*
* \sa class SimplicialLDLT, class SimplicialLLT
*/
-template<typename _MatrixType, int _UpLo>
- class SimplicialCholesky : public SimplicialCholeskyBase<SimplicialCholesky<_MatrixType,_UpLo> >
+template<typename _MatrixType, int _UpLo, typename _Ordering>
+ class SimplicialCholesky : public SimplicialCholeskyBase<SimplicialCholesky<_MatrixType,_UpLo,_Ordering> >
{
public:
typedef _MatrixType MatrixType;
@@ -612,15 +618,13 @@ void SimplicialCholeskyBase<Derived>::ordering(const MatrixType& a, CholMatrixTy
{
eigen_assert(a.rows()==a.cols());
const Index size = a.rows();
- // TODO allows to configure the permutation
// Note that amd compute the inverse permutation
{
CholMatrixType C;
C = a.template selfadjointView<UpLo>();
- // remove diagonal entries:
- // seems not to be needed
- // C.prune(keep_diag());
- internal::minimum_degree_ordering(C, m_Pinv);
+
+ OrderingType ordering;
+ ordering(C,m_Pinv);
}
if(m_Pinv.size()>0)
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/AmbiVector.h b/Utilities/eigen3/Eigen/src/SparseCore/AmbiVector.h
index 17fff96a..220c6451 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/AmbiVector.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/AmbiVector.h
@@ -69,7 +69,7 @@ class AmbiVector
delete[] m_buffer;
if (size<1000)
{
- Index allocSize = (size * sizeof(ListEl))/sizeof(Scalar);
+ Index allocSize = (size * sizeof(ListEl) + sizeof(Scalar) - 1)/sizeof(Scalar);
m_allocatedElements = (allocSize*sizeof(Scalar))/sizeof(ListEl);
m_buffer = new Scalar[allocSize];
}
@@ -88,7 +88,7 @@ class AmbiVector
Index copyElements = m_allocatedElements;
m_allocatedElements = (std::min)(Index(m_allocatedElements*1.5),m_size);
Index allocSize = m_allocatedElements * sizeof(ListEl);
- allocSize = allocSize/sizeof(Scalar) + (allocSize%sizeof(Scalar)>0?1:0);
+ allocSize = (allocSize + sizeof(Scalar) - 1)/sizeof(Scalar);
Scalar* newBuffer = new Scalar[allocSize];
memcpy(newBuffer, m_buffer, copyElements * sizeof(ListEl));
delete[] m_buffer;
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/CompressedStorage.h b/Utilities/eigen3/Eigen/src/SparseCore/CompressedStorage.h
index 3321fab4..a667cb56 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/CompressedStorage.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/CompressedStorage.h
@@ -51,8 +51,8 @@ class CompressedStorage
CompressedStorage& operator=(const CompressedStorage& other)
{
resize(other.size());
- memcpy(m_values, other.m_values, m_size * sizeof(Scalar));
- memcpy(m_indices, other.m_indices, m_size * sizeof(Index));
+ internal::smart_copy(other.m_values, other.m_values + m_size, m_values);
+ internal::smart_copy(other.m_indices, other.m_indices + m_size, m_indices);
return *this;
}
@@ -83,10 +83,10 @@ class CompressedStorage
reallocate(m_size);
}
- void resize(size_t size, float reserveSizeFactor = 0)
+ void resize(size_t size, double reserveSizeFactor = 0)
{
if (m_allocatedSize<size)
- reallocate(size + size_t(reserveSizeFactor*size));
+ reallocate(size + size_t(reserveSizeFactor*double(size)));
m_size = size;
}
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h b/Utilities/eigen3/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h
index 4b13f08d..5c320e2d 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/ConservativeSparseSparseProduct.h
@@ -66,9 +66,9 @@ static void conservative_sparse_sparse_product_impl(const Lhs& lhs, const Rhs& r
}
// unordered insertion
- for(int k=0; k<nnz; ++k)
+ for(Index k=0; k<nnz; ++k)
{
- int i = indices[k];
+ Index i = indices[k];
res.insertBackByOuterInnerUnordered(j,i) = values[i];
mask[i] = false;
}
@@ -76,8 +76,8 @@ static void conservative_sparse_sparse_product_impl(const Lhs& lhs, const Rhs& r
#if 0
// alternative ordered insertion code:
- int t200 = rows/(log2(200)*1.39);
- int t = (rows*100)/139;
+ Index t200 = rows/(log2(200)*1.39);
+ Index t = (rows*100)/139;
// FIXME reserve nnz non zeros
// FIXME implement fast sort algorithms for very small nnz
@@ -90,9 +90,9 @@ static void conservative_sparse_sparse_product_impl(const Lhs& lhs, const Rhs& r
if(true)
{
if(nnz>1) std::sort(indices.data(),indices.data()+nnz);
- for(int k=0; k<nnz; ++k)
+ for(Index k=0; k<nnz; ++k)
{
- int i = indices[k];
+ Index i = indices[k];
res.insertBackByOuterInner(j,i) = values[i];
mask[i] = false;
}
@@ -100,7 +100,7 @@ static void conservative_sparse_sparse_product_impl(const Lhs& lhs, const Rhs& r
else
{
// dense path
- for(int i=0; i<rows; ++i)
+ for(Index i=0; i<rows; ++i)
{
if(mask[i])
{
@@ -134,8 +134,8 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,C
static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)
{
- typedef SparseMatrix<typename ResultType::Scalar,RowMajor> RowMajorMatrix;
- typedef SparseMatrix<typename ResultType::Scalar,ColMajor> ColMajorMatrix;
+ typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::Index> RowMajorMatrix;
+ typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::Index> ColMajorMatrix;
ColMajorMatrix resCol(lhs.rows(),rhs.cols());
internal::conservative_sparse_sparse_product_impl<Lhs,Rhs,ColMajorMatrix>(lhs, rhs, resCol);
// sort the non zeros:
@@ -149,7 +149,7 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,RowMajor,C
{
static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)
{
- typedef SparseMatrix<typename ResultType::Scalar,RowMajor> RowMajorMatrix;
+ typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::Index> RowMajorMatrix;
RowMajorMatrix rhsRow = rhs;
RowMajorMatrix resRow(lhs.rows(), rhs.cols());
internal::conservative_sparse_sparse_product_impl<RowMajorMatrix,Lhs,RowMajorMatrix>(rhsRow, lhs, resRow);
@@ -162,7 +162,7 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,R
{
static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)
{
- typedef SparseMatrix<typename ResultType::Scalar,RowMajor> RowMajorMatrix;
+ typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::Index> RowMajorMatrix;
RowMajorMatrix lhsRow = lhs;
RowMajorMatrix resRow(lhs.rows(), rhs.cols());
internal::conservative_sparse_sparse_product_impl<Rhs,RowMajorMatrix,RowMajorMatrix>(rhs, lhsRow, resRow);
@@ -175,7 +175,7 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,RowMajor,R
{
static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)
{
- typedef SparseMatrix<typename ResultType::Scalar,RowMajor> RowMajorMatrix;
+ typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::Index> RowMajorMatrix;
RowMajorMatrix resRow(lhs.rows(), rhs.cols());
internal::conservative_sparse_sparse_product_impl<Rhs,Lhs,RowMajorMatrix>(rhs, lhs, resRow);
res = resRow;
@@ -190,7 +190,7 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,C
static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)
{
- typedef SparseMatrix<typename ResultType::Scalar,ColMajor> ColMajorMatrix;
+ typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::Index> ColMajorMatrix;
ColMajorMatrix resCol(lhs.rows(), rhs.cols());
internal::conservative_sparse_sparse_product_impl<Lhs,Rhs,ColMajorMatrix>(lhs, rhs, resCol);
res = resCol;
@@ -202,7 +202,7 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,RowMajor,C
{
static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)
{
- typedef SparseMatrix<typename ResultType::Scalar,ColMajor> ColMajorMatrix;
+ typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::Index> ColMajorMatrix;
ColMajorMatrix lhsCol = lhs;
ColMajorMatrix resCol(lhs.rows(), rhs.cols());
internal::conservative_sparse_sparse_product_impl<ColMajorMatrix,Rhs,ColMajorMatrix>(lhsCol, rhs, resCol);
@@ -215,7 +215,7 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,ColMajor,R
{
static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)
{
- typedef SparseMatrix<typename ResultType::Scalar,ColMajor> ColMajorMatrix;
+ typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::Index> ColMajorMatrix;
ColMajorMatrix rhsCol = rhs;
ColMajorMatrix resCol(lhs.rows(), rhs.cols());
internal::conservative_sparse_sparse_product_impl<Lhs,ColMajorMatrix,ColMajorMatrix>(lhs, rhsCol, resCol);
@@ -228,8 +228,8 @@ struct conservative_sparse_sparse_product_selector<Lhs,Rhs,ResultType,RowMajor,R
{
static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res)
{
- typedef SparseMatrix<typename ResultType::Scalar,RowMajor> RowMajorMatrix;
- typedef SparseMatrix<typename ResultType::Scalar,ColMajor> ColMajorMatrix;
+ typedef SparseMatrix<typename ResultType::Scalar,RowMajor,typename ResultType::Index> RowMajorMatrix;
+ typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::Index> ColMajorMatrix;
RowMajorMatrix resRow(lhs.rows(),rhs.cols());
internal::conservative_sparse_sparse_product_impl<Rhs,Lhs,RowMajorMatrix>(rhs, lhs, resRow);
// sort the non zeros:
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/MappedSparseMatrix.h b/Utilities/eigen3/Eigen/src/SparseCore/MappedSparseMatrix.h
index 93cd4832..ab1a266a 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/MappedSparseMatrix.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/MappedSparseMatrix.h
@@ -50,6 +50,8 @@ class MappedSparseMatrix
inline Index cols() const { return IsRowMajor ? m_innerSize : m_outerSize; }
inline Index innerSize() const { return m_innerSize; }
inline Index outerSize() const { return m_outerSize; }
+
+ bool isCompressed() const { return true; }
//----------------------------------------
// direct access interface
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/SparseBlock.h b/Utilities/eigen3/Eigen/src/SparseCore/SparseBlock.h
index 0b3e193d..0c90bafb 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/SparseBlock.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/SparseBlock.h
@@ -57,6 +57,16 @@ public:
inline BlockImpl(const XprType& xpr, int startRow, int startCol, int blockRows, int blockCols)
: m_matrix(xpr), m_outerStart(IsRowMajor ? startRow : startCol), m_outerSize(IsRowMajor ? blockRows : blockCols)
{}
+
+ inline const Scalar coeff(int row, int col) const
+ {
+ return m_matrix.coeff(row + IsRowMajor ? m_outerStart : 0, col +IsRowMajor ? 0 : m_outerStart);
+ }
+
+ inline const Scalar coeff(int index) const
+ {
+ return m_matrix.coeff(IsRowMajor ? m_outerStart : index, IsRowMajor ? index : m_outerStart);
+ }
EIGEN_STRONG_INLINE Index rows() const { return IsRowMajor ? m_outerSize.value() : m_matrix.rows(); }
EIGEN_STRONG_INLINE Index cols() const { return IsRowMajor ? m_matrix.cols() : m_outerSize.value(); }
@@ -66,6 +76,10 @@ public:
typename XprType::Nested m_matrix;
Index m_outerStart;
const internal::variable_if_dynamic<Index, OuterSize> m_outerSize;
+
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl)
+ private:
+ Index nonZeros() const;
};
@@ -80,6 +94,7 @@ class BlockImpl<SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true
typedef SparseMatrix<_Scalar, _Options, _Index> SparseMatrixType;
typedef typename internal::remove_all<typename SparseMatrixType::Nested>::type _MatrixTypeNested;
typedef Block<SparseMatrixType, BlockRows, BlockCols, true> BlockType;
+ typedef Block<const SparseMatrixType, BlockRows, BlockCols, true> ConstBlockType;
public:
enum { IsRowMajor = internal::traits<BlockType>::IsRowMajor };
EIGEN_SPARSE_PUBLIC_INTERFACE(BlockType)
@@ -221,6 +236,118 @@ public:
else
return Map<const Matrix<Index,OuterSize,1> >(m_matrix.innerNonZeroPtr()+m_outerStart, m_outerSize.value()).sum();
}
+
+ inline Scalar& coeffRef(int row, int col)
+ {
+ return m_matrix.const_cast_derived().coeffRef(row + (IsRowMajor ? m_outerStart : 0), col + (IsRowMajor ? 0 : m_outerStart));
+ }
+
+ inline const Scalar coeff(int row, int col) const
+ {
+ return m_matrix.coeff(row + (IsRowMajor ? m_outerStart : 0), col + (IsRowMajor ? 0 : m_outerStart));
+ }
+
+ inline const Scalar coeff(int index) const
+ {
+ return m_matrix.coeff(IsRowMajor ? m_outerStart : index, IsRowMajor ? index : m_outerStart);
+ }
+
+ const Scalar& lastCoeff() const
+ {
+ EIGEN_STATIC_ASSERT_VECTOR_ONLY(BlockImpl);
+ eigen_assert(nonZeros()>0);
+ if(m_matrix.isCompressed())
+ return m_matrix.valuePtr()[m_matrix.outerIndexPtr()[m_outerStart+1]-1];
+ else
+ return m_matrix.valuePtr()[m_matrix.outerIndexPtr()[m_outerStart]+m_matrix.innerNonZeroPtr()[m_outerStart]-1];
+ }
+
+ EIGEN_STRONG_INLINE Index rows() const { return IsRowMajor ? m_outerSize.value() : m_matrix.rows(); }
+ EIGEN_STRONG_INLINE Index cols() const { return IsRowMajor ? m_matrix.cols() : m_outerSize.value(); }
+
+ protected:
+
+ typename SparseMatrixType::Nested m_matrix;
+ Index m_outerStart;
+ const internal::variable_if_dynamic<Index, OuterSize> m_outerSize;
+
+};
+
+
+template<typename _Scalar, int _Options, typename _Index, int BlockRows, int BlockCols>
+class BlockImpl<const SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true,Sparse>
+ : public SparseMatrixBase<Block<const SparseMatrix<_Scalar, _Options, _Index>,BlockRows,BlockCols,true> >
+{
+ typedef SparseMatrix<_Scalar, _Options, _Index> SparseMatrixType;
+ typedef typename internal::remove_all<typename SparseMatrixType::Nested>::type _MatrixTypeNested;
+ typedef Block<const SparseMatrixType, BlockRows, BlockCols, true> BlockType;
+public:
+ enum { IsRowMajor = internal::traits<BlockType>::IsRowMajor };
+ EIGEN_SPARSE_PUBLIC_INTERFACE(BlockType)
+protected:
+ enum { OuterSize = IsRowMajor ? BlockRows : BlockCols };
+public:
+
+ class InnerIterator: public SparseMatrixType::InnerIterator
+ {
+ public:
+ inline InnerIterator(const BlockType& xpr, Index outer)
+ : SparseMatrixType::InnerIterator(xpr.m_matrix, xpr.m_outerStart + outer), m_outer(outer)
+ {}
+ inline Index row() const { return IsRowMajor ? m_outer : this->index(); }
+ inline Index col() const { return IsRowMajor ? this->index() : m_outer; }
+ protected:
+ Index m_outer;
+ };
+ class ReverseInnerIterator: public SparseMatrixType::ReverseInnerIterator
+ {
+ public:
+ inline ReverseInnerIterator(const BlockType& xpr, Index outer)
+ : SparseMatrixType::ReverseInnerIterator(xpr.m_matrix, xpr.m_outerStart + outer), m_outer(outer)
+ {}
+ inline Index row() const { return IsRowMajor ? m_outer : this->index(); }
+ inline Index col() const { return IsRowMajor ? this->index() : m_outer; }
+ protected:
+ Index m_outer;
+ };
+
+ inline BlockImpl(const SparseMatrixType& xpr, int i)
+ : m_matrix(xpr), m_outerStart(i), m_outerSize(OuterSize)
+ {}
+
+ inline BlockImpl(const SparseMatrixType& xpr, int startRow, int startCol, int blockRows, int blockCols)
+ : m_matrix(xpr), m_outerStart(IsRowMajor ? startRow : startCol), m_outerSize(IsRowMajor ? blockRows : blockCols)
+ {}
+
+ inline const Scalar* valuePtr() const
+ { return m_matrix.valuePtr() + m_matrix.outerIndexPtr()[m_outerStart]; }
+
+ inline const Index* innerIndexPtr() const
+ { return m_matrix.innerIndexPtr() + m_matrix.outerIndexPtr()[m_outerStart]; }
+
+ inline const Index* outerIndexPtr() const
+ { return m_matrix.outerIndexPtr() + m_outerStart; }
+
+ Index nonZeros() const
+ {
+ if(m_matrix.isCompressed())
+ return std::size_t(m_matrix.outerIndexPtr()[m_outerStart+m_outerSize.value()])
+ - std::size_t(m_matrix.outerIndexPtr()[m_outerStart]);
+ else if(m_outerSize.value()==0)
+ return 0;
+ else
+ return Map<const Matrix<Index,OuterSize,1> >(m_matrix.innerNonZeroPtr()+m_outerStart, m_outerSize.value()).sum();
+ }
+
+ inline const Scalar coeff(int row, int col) const
+ {
+ return m_matrix.coeff(row + (IsRowMajor ? m_outerStart : 0), col + (IsRowMajor ? 0 : m_outerStart));
+ }
+
+ inline const Scalar coeff(int index) const
+ {
+ return m_matrix.coeff(IsRowMajor ? m_outerStart : index, IsRowMajor ? index : m_outerStart);
+ }
const Scalar& lastCoeff() const
{
@@ -263,7 +390,8 @@ const typename SparseMatrixBase<Derived>::ConstInnerVectorReturnType SparseMatri
* is col-major (resp. row-major).
*/
template<typename Derived>
-Block<Derived,Dynamic,Dynamic,true> SparseMatrixBase<Derived>::innerVectors(Index outerStart, Index outerSize)
+typename SparseMatrixBase<Derived>::InnerVectorsReturnType
+SparseMatrixBase<Derived>::innerVectors(Index outerStart, Index outerSize)
{
return Block<Derived,Dynamic,Dynamic,true>(derived(),
IsRowMajor ? outerStart : 0, IsRowMajor ? 0 : outerStart,
@@ -275,7 +403,8 @@ Block<Derived,Dynamic,Dynamic,true> SparseMatrixBase<Derived>::innerVectors(Inde
* is col-major (resp. row-major). Read-only.
*/
template<typename Derived>
-const Block<const Derived,Dynamic,Dynamic,true> SparseMatrixBase<Derived>::innerVectors(Index outerStart, Index outerSize) const
+const typename SparseMatrixBase<Derived>::ConstInnerVectorsReturnType
+SparseMatrixBase<Derived>::innerVectors(Index outerStart, Index outerSize) const
{
return Block<const Derived,Dynamic,Dynamic,true>(derived(),
IsRowMajor ? outerStart : 0, IsRowMajor ? 0 : outerStart,
@@ -302,8 +431,8 @@ public:
: m_matrix(xpr),
m_startRow( (BlockRows==1) && (BlockCols==XprType::ColsAtCompileTime) ? i : 0),
m_startCol( (BlockRows==XprType::RowsAtCompileTime) && (BlockCols==1) ? i : 0),
- m_blockRows(xpr.rows()),
- m_blockCols(xpr.cols())
+ m_blockRows(BlockRows==1 ? 1 : xpr.rows()),
+ m_blockCols(BlockCols==1 ? 1 : xpr.cols())
{}
/** Dynamic-size constructor
@@ -391,6 +520,8 @@ public:
protected:
friend class InnerIterator;
friend class ReverseInnerIterator;
+
+ EIGEN_INHERIT_ASSIGNMENT_OPERATORS(BlockImpl)
typename XprType::Nested m_matrix;
const internal::variable_if_dynamic<Index, XprType::RowsAtCompileTime == 1 ? 0 : Dynamic> m_startRow;
@@ -403,3 +534,4 @@ public:
} // end namespace Eigen
#endif // EIGEN_SPARSE_BLOCK_H
+
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/SparseColEtree.h b/Utilities/eigen3/Eigen/src/SparseCore/SparseColEtree.h
index f89ca381..f8745f46 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/SparseColEtree.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/SparseColEtree.h
@@ -63,6 +63,7 @@ int coletree(const MatrixType& mat, IndexVector& parent, IndexVector& firstRowEl
typedef typename MatrixType::Index Index;
Index nc = mat.cols(); // Number of columns
Index m = mat.rows();
+ Index diagSize = (std::min)(nc,m);
IndexVector root(nc); // root of subtree of etree
root.setZero();
IndexVector pp(nc); // disjoint sets
@@ -72,7 +73,7 @@ int coletree(const MatrixType& mat, IndexVector& parent, IndexVector& firstRowEl
Index row,col;
firstRowElt.resize(m);
firstRowElt.setConstant(nc);
- firstRowElt.segment(0, nc).setLinSpaced(nc, 0, nc-1);
+ firstRowElt.segment(0, diagSize).setLinSpaced(diagSize, 0, diagSize-1);
bool found_diag;
for (col = 0; col < nc; col++)
{
@@ -91,7 +92,7 @@ int coletree(const MatrixType& mat, IndexVector& parent, IndexVector& firstRowEl
Index rset, cset, rroot;
for (col = 0; col < nc; col++)
{
- found_diag = false;
+ found_diag = col>=m;
pp(col) = col;
cset = col;
root(cset) = col;
@@ -105,6 +106,7 @@ int coletree(const MatrixType& mat, IndexVector& parent, IndexVector& firstRowEl
Index i = col;
if(it) i = it.index();
if (i == col) found_diag = true;
+
row = firstRowElt(i);
if (row >= col) continue;
rset = internal::etree_find(row, pp); // Find the name of the set containing row
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h b/Utilities/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h
index ec86ca93..4ca91283 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/SparseCwiseBinaryOp.h
@@ -73,7 +73,8 @@ class CwiseBinaryOpImpl<BinaryOp,Lhs,Rhs,Sparse>::InnerIterator
typedef internal::sparse_cwise_binary_op_inner_iterator_selector<
BinaryOp,Lhs,Rhs, InnerIterator> Base;
- EIGEN_STRONG_INLINE InnerIterator(const CwiseBinaryOpImpl& binOp, Index outer)
+ // NOTE: we have to prefix Index by "typename Lhs::" to avoid an ICE with VC11
+ EIGEN_STRONG_INLINE InnerIterator(const CwiseBinaryOpImpl& binOp, typename Lhs::Index outer)
: Base(binOp.derived(),outer)
{}
};
@@ -313,10 +314,10 @@ SparseMatrixBase<Derived>::operator+=(const SparseMatrixBase<OtherDerived>& othe
template<typename Derived>
template<typename OtherDerived>
-EIGEN_STRONG_INLINE const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE
+EIGEN_STRONG_INLINE const typename SparseMatrixBase<Derived>::template CwiseProductDenseReturnType<OtherDerived>::Type
SparseMatrixBase<Derived>::cwiseProduct(const MatrixBase<OtherDerived> &other) const
{
- return EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE(derived(), other.derived());
+ return typename CwiseProductDenseReturnType<OtherDerived>::Type(derived(), other.derived());
}
} // end namespace Eigen
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/SparseDenseProduct.h b/Utilities/eigen3/Eigen/src/SparseCore/SparseDenseProduct.h
index 30975c29..ccb6ae7b 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/SparseDenseProduct.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/SparseDenseProduct.h
@@ -19,7 +19,10 @@ template<typename Lhs, typename Rhs, int InnerSize> struct SparseDenseProductRet
template<typename Lhs, typename Rhs> struct SparseDenseProductReturnType<Lhs,Rhs,1>
{
- typedef SparseDenseOuterProduct<Lhs,Rhs,false> Type;
+ typedef typename internal::conditional<
+ Lhs::IsRowMajor,
+ SparseDenseOuterProduct<Rhs,Lhs,true>,
+ SparseDenseOuterProduct<Lhs,Rhs,false> >::type Type;
};
template<typename Lhs, typename Rhs, int InnerSize> struct DenseSparseProductReturnType
@@ -29,7 +32,10 @@ template<typename Lhs, typename Rhs, int InnerSize> struct DenseSparseProductRet
template<typename Lhs, typename Rhs> struct DenseSparseProductReturnType<Lhs,Rhs,1>
{
- typedef SparseDenseOuterProduct<Rhs,Lhs,true> Type;
+ typedef typename internal::conditional<
+ Rhs::IsRowMajor,
+ SparseDenseOuterProduct<Rhs,Lhs,true>,
+ SparseDenseOuterProduct<Lhs,Rhs,false> >::type Type;
};
namespace internal {
@@ -114,18 +120,31 @@ class SparseDenseOuterProduct<Lhs,Rhs,Transpose>::InnerIterator : public _LhsNes
typedef typename SparseDenseOuterProduct::Index Index;
public:
EIGEN_STRONG_INLINE InnerIterator(const SparseDenseOuterProduct& prod, Index outer)
- : Base(prod.lhs(), 0), m_outer(outer), m_factor(prod.rhs().coeff(outer))
- {
- }
+ : Base(prod.lhs(), 0), m_outer(outer), m_factor(get(prod.rhs(), outer, typename internal::traits<Rhs>::StorageKind() ))
+ { }
inline Index outer() const { return m_outer; }
- inline Index row() const { return Transpose ? Base::row() : m_outer; }
- inline Index col() const { return Transpose ? m_outer : Base::row(); }
+ inline Index row() const { return Transpose ? m_outer : Base::index(); }
+ inline Index col() const { return Transpose ? Base::index() : m_outer; }
inline Scalar value() const { return Base::value() * m_factor; }
protected:
- int m_outer;
+ static Scalar get(const _RhsNested &rhs, Index outer, Dense = Dense())
+ {
+ return rhs.coeff(outer);
+ }
+
+ static Scalar get(const _RhsNested &rhs, Index outer, Sparse = Sparse())
+ {
+ typename Traits::_RhsNested::InnerIterator it(rhs, outer);
+ if (it && it.index()==0)
+ return it.value();
+
+ return Scalar(0);
+ }
+
+ Index m_outer;
Scalar m_factor;
};
@@ -155,13 +174,13 @@ struct sparse_time_dense_product_impl<SparseLhsType,DenseRhsType,DenseResType, R
{
for(Index c=0; c<rhs.cols(); ++c)
{
- int n = lhs.outerSize();
+ Index n = lhs.outerSize();
for(Index j=0; j<n; ++j)
{
typename Res::Scalar tmp(0);
for(LhsInnerIterator it(lhs,j); it ;++it)
tmp += it.value() * rhs.coeff(it.index(),c);
- res.coeffRef(j,c) = alpha * tmp;
+ res.coeffRef(j,c) += alpha * tmp;
}
}
}
@@ -287,15 +306,6 @@ class DenseTimeSparseProduct
DenseTimeSparseProduct& operator=(const DenseTimeSparseProduct&);
};
-// sparse * dense
-template<typename Derived>
-template<typename OtherDerived>
-inline const typename SparseDenseProductReturnType<Derived,OtherDerived>::Type
-SparseMatrixBase<Derived>::operator*(const MatrixBase<OtherDerived> &other) const
-{
- return typename SparseDenseProductReturnType<Derived,OtherDerived>::Type(derived(), other.derived());
-}
-
} // end namespace Eigen
#endif // EIGEN_SPARSEDENSEPRODUCT_H
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/SparseMatrix.h b/Utilities/eigen3/Eigen/src/SparseCore/SparseMatrix.h
index adceafe1..2ff20155 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/SparseMatrix.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/SparseMatrix.h
@@ -223,7 +223,7 @@ class SparseMatrix
if(isCompressed())
{
- reserve(VectorXi::Constant(outerSize(), 2));
+ reserve(Matrix<Index,Dynamic,1>::Constant(outerSize(), 2));
}
return insertUncompressed(row,col);
}
@@ -402,7 +402,7 @@ class SparseMatrix
* \sa insertBack, insertBackByOuterInner */
inline void startVec(Index outer)
{
- eigen_assert(m_outerIndex[outer]==int(m_data.size()) && "You must call startVec for each inner vector sequentially");
+ eigen_assert(m_outerIndex[outer]==Index(m_data.size()) && "You must call startVec for each inner vector sequentially");
eigen_assert(m_outerIndex[outer+1]==0 && "You must call startVec for each inner vector sequentially");
m_outerIndex[outer+1] = m_outerIndex[outer];
}
@@ -480,7 +480,7 @@ class SparseMatrix
if(m_innerNonZeros != 0)
return;
m_innerNonZeros = static_cast<Index*>(std::malloc(m_outerSize * sizeof(Index)));
- for (int i = 0; i < m_outerSize; i++)
+ for (Index i = 0; i < m_outerSize; i++)
{
m_innerNonZeros[i] = m_outerIndex[i+1] - m_outerIndex[i];
}
@@ -691,7 +691,8 @@ class SparseMatrix
m_data.swap(other.m_data);
}
- /** Sets *this to the identity matrix */
+ /** Sets *this to the identity matrix.
+ * This function also turns the matrix into compressed mode, and drop any reserved memory. */
inline void setIdentity()
{
eigen_assert(rows() == cols() && "ONLY FOR SQUARED MATRICES");
@@ -699,6 +700,8 @@ class SparseMatrix
Eigen::Map<Matrix<Index, Dynamic, 1> >(&this->m_data.index(0), rows()).setLinSpaced(0, rows()-1);
Eigen::Map<Matrix<Scalar, Dynamic, 1> >(&this->m_data.value(0), rows()).setOnes();
Eigen::Map<Matrix<Index, Dynamic, 1> >(this->m_outerIndex, rows()+1).setLinSpaced(0, rows());
+ std::free(m_innerNonZeros);
+ m_innerNonZeros = 0;
}
inline SparseMatrix& operator=(const SparseMatrix& other)
{
@@ -752,8 +755,8 @@ class SparseMatrix
else
for (Index i=0; i<m.outerSize(); ++i)
{
- int p = m.m_outerIndex[i];
- int pe = m.m_outerIndex[i]+m.m_innerNonZeros[i];
+ Index p = m.m_outerIndex[i];
+ Index pe = m.m_outerIndex[i]+m.m_innerNonZeros[i];
Index k=p;
for (; k<pe; ++k)
s << "(" << m.m_data.value(k) << "," << m.m_data.index(k) << ") ";
@@ -939,12 +942,13 @@ void set_from_triplets(const InputIterator& begin, const InputIterator& end, Spa
EIGEN_UNUSED_VARIABLE(Options);
enum { IsRowMajor = SparseMatrixType::IsRowMajor };
typedef typename SparseMatrixType::Scalar Scalar;
- SparseMatrix<Scalar,IsRowMajor?ColMajor:RowMajor> trMat(mat.rows(),mat.cols());
+ typedef typename SparseMatrixType::Index Index;
+ SparseMatrix<Scalar,IsRowMajor?ColMajor:RowMajor,Index> trMat(mat.rows(),mat.cols());
- if(begin<end)
+ if(begin!=end)
{
// pass 1: count the nnz per inner-vector
- VectorXi wi(trMat.outerSize());
+ Matrix<Index,Dynamic,1> wi(trMat.outerSize());
wi.setZero();
for(InputIterator it(begin); it!=end; ++it)
{
@@ -1018,11 +1022,11 @@ void SparseMatrix<Scalar,_Options,_Index>::sumupDuplicates()
{
eigen_assert(!isCompressed());
// TODO, in practice we should be able to use m_innerNonZeros for that task
- VectorXi wi(innerSize());
+ Matrix<Index,Dynamic,1> wi(innerSize());
wi.fill(-1);
Index count = 0;
// for each inner-vector, wi[inner_index] will hold the position of first element into the index/value buffers
- for(int j=0; j<outerSize(); ++j)
+ for(Index j=0; j<outerSize(); ++j)
{
Index start = count;
Index oldEnd = m_outerIndex[j]+m_innerNonZeros[j];
@@ -1081,7 +1085,7 @@ EIGEN_DONT_INLINE SparseMatrix<Scalar,_Options,_Index>& SparseMatrix<Scalar,_Opt
// prefix sum
Index count = 0;
- VectorXi positions(dest.outerSize());
+ Matrix<Index,Dynamic,1> positions(dest.outerSize());
for (Index j=0; j<dest.outerSize(); ++j)
{
Index tmp = dest.m_outerIndex[j];
@@ -1177,7 +1181,7 @@ EIGEN_DONT_INLINE typename SparseMatrix<_Scalar,_Options,_Index>::Scalar& Sparse
size_t p = m_outerIndex[outer+1];
++m_outerIndex[outer+1];
- float reallocRatio = 1;
+ double reallocRatio = 1;
if (m_data.allocatedSize()<=m_data.size())
{
// if there is no preallocated memory, let's reserve a minimum of 32 elements
@@ -1189,13 +1193,13 @@ EIGEN_DONT_INLINE typename SparseMatrix<_Scalar,_Options,_Index>::Scalar& Sparse
{
// we need to reallocate the data, to reduce multiple reallocations
// we use a smart resize algorithm based on the current filling ratio
- // in addition, we use float to avoid integers overflows
- float nnzEstimate = float(m_outerIndex[outer])*float(m_outerSize)/float(outer+1);
- reallocRatio = (nnzEstimate-float(m_data.size()))/float(m_data.size());
+ // in addition, we use double to avoid integers overflows
+ double nnzEstimate = double(m_outerIndex[outer])*double(m_outerSize)/double(outer+1);
+ reallocRatio = (nnzEstimate-double(m_data.size()))/double(m_data.size());
// furthermore we bound the realloc ratio to:
// 1) reduce multiple minor realloc when the matrix is almost filled
// 2) avoid to allocate too much memory when the matrix is almost empty
- reallocRatio = (std::min)((std::max)(reallocRatio,1.5f),8.f);
+ reallocRatio = (std::min)((std::max)(reallocRatio,1.5),8.);
}
}
m_data.resize(m_data.size()+1,reallocRatio);
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h b/Utilities/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h
index 706f699b..9341d9ad 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/SparseMatrixBase.h
@@ -23,7 +23,14 @@ namespace Eigen {
* This class can be extended with the help of the plugin mechanism described on the page
* \ref TopicCustomizingEigen by defining the preprocessor symbol \c EIGEN_SPARSEMATRIXBASE_PLUGIN.
*/
-template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
+template<typename Derived> class SparseMatrixBase
+#ifndef EIGEN_PARSED_BY_DOXYGEN
+ : public internal::special_scalar_op_base<Derived,typename internal::traits<Derived>::Scalar,
+ typename NumTraits<typename internal::traits<Derived>::Scalar>::Real,
+ EigenBase<Derived> >
+#else
+ : public EigenBase<Derived>
+#endif // not EIGEN_PARSED_BY_DOXYGEN
{
public:
@@ -36,7 +43,6 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
>::type PacketReturnType;
typedef SparseMatrixBase StorageBaseType;
- typedef EigenBase<Derived> Base;
template<typename OtherDerived>
Derived& operator=(const EigenBase<OtherDerived> &other)
@@ -132,6 +138,9 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
inline Derived& derived() { return *static_cast<Derived*>(this); }
inline Derived& const_cast_derived() const
{ return *static_cast<Derived*>(const_cast<SparseMatrixBase*>(this)); }
+
+ typedef internal::special_scalar_op_base<Derived, Scalar, RealScalar, EigenBase<Derived> > Base;
+ using Base::operator*;
#endif // not EIGEN_PARSED_BY_DOXYGEN
#define EIGEN_CURRENT_STORAGE_BASE_CLASS Eigen::SparseMatrixBase
@@ -302,8 +311,8 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
}
else
{
- SparseMatrix<Scalar, RowMajorBit> trans = m;
- s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit> >&>(trans);
+ SparseMatrix<Scalar, RowMajorBit, Index> trans = m;
+ s << static_cast<const SparseMatrixBase<SparseMatrix<Scalar, RowMajorBit, Index> >&>(trans);
}
}
return s;
@@ -317,20 +326,18 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
Derived& operator*=(const Scalar& other);
Derived& operator/=(const Scalar& other);
- #define EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE \
- CwiseBinaryOp< \
- internal::scalar_product_op< \
- typename internal::scalar_product_traits< \
- typename internal::traits<Derived>::Scalar, \
- typename internal::traits<OtherDerived>::Scalar \
- >::ReturnType \
- >, \
- const Derived, \
- const OtherDerived \
- >
+ template<typename OtherDerived> struct CwiseProductDenseReturnType {
+ typedef CwiseBinaryOp<internal::scalar_product_op<typename internal::scalar_product_traits<
+ typename internal::traits<Derived>::Scalar,
+ typename internal::traits<OtherDerived>::Scalar
+ >::ReturnType>,
+ const Derived,
+ const OtherDerived
+ > Type;
+ };
template<typename OtherDerived>
- EIGEN_STRONG_INLINE const EIGEN_SPARSE_CWISE_PRODUCT_RETURN_TYPE
+ EIGEN_STRONG_INLINE const typename CwiseProductDenseReturnType<OtherDerived>::Type
cwiseProduct(const MatrixBase<OtherDerived> &other) const;
// sparse * sparse
@@ -358,7 +365,8 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
/** sparse * dense (returns a dense object unless it is an outer product) */
template<typename OtherDerived>
const typename SparseDenseProductReturnType<Derived,OtherDerived>::Type
- operator*(const MatrixBase<OtherDerived> &other) const;
+ operator*(const MatrixBase<OtherDerived> &other) const
+ { return typename SparseDenseProductReturnType<Derived,OtherDerived>::Type(derived(), other.derived()); }
/** \returns an expression of P H P^-1 where H is the matrix represented by \c *this */
SparseSymmetricPermutationProduct<Derived,Upper|Lower> twistedBy(const PermutationMatrix<Dynamic,Dynamic,Index>& perm) const
@@ -403,8 +411,10 @@ template<typename Derived> class SparseMatrixBase : public EigenBase<Derived>
const ConstInnerVectorReturnType innerVector(Index outer) const;
// set of inner-vectors
- Block<Derived,Dynamic,Dynamic,true> innerVectors(Index outerStart, Index outerSize);
- const Block<const Derived,Dynamic,Dynamic,true> innerVectors(Index outerStart, Index outerSize) const;
+ typedef Block<Derived,Dynamic,Dynamic,true> InnerVectorsReturnType;
+ typedef Block<const Derived,Dynamic,Dynamic,true> ConstInnerVectorsReturnType;
+ InnerVectorsReturnType innerVectors(Index outerStart, Index outerSize);
+ const ConstInnerVectorsReturnType innerVectors(Index outerStart, Index outerSize) const;
/** \internal use operator= */
template<typename DenseDerived>
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/SparsePermutation.h b/Utilities/eigen3/Eigen/src/SparseCore/SparsePermutation.h
index b897b759..75e21000 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/SparsePermutation.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/SparsePermutation.h
@@ -57,11 +57,11 @@ struct permut_sparsematrix_product_retval
if(MoveOuter)
{
SparseMatrix<Scalar,SrcStorageOrder,Index> tmp(m_matrix.rows(), m_matrix.cols());
- VectorXi sizes(m_matrix.outerSize());
+ Matrix<Index,Dynamic,1> sizes(m_matrix.outerSize());
for(Index j=0; j<m_matrix.outerSize(); ++j)
{
Index jp = m_permutation.indices().coeff(j);
- sizes[((Side==OnTheLeft) ^ Transposed) ? jp : j] = m_matrix.innerVector(((Side==OnTheRight) ^ Transposed) ? jp : j).size();
+ sizes[((Side==OnTheLeft) ^ Transposed) ? jp : j] = m_matrix.innerVector(((Side==OnTheRight) ^ Transposed) ? jp : j).nonZeros();
}
tmp.reserve(sizes);
for(Index j=0; j<m_matrix.outerSize(); ++j)
@@ -77,7 +77,7 @@ struct permut_sparsematrix_product_retval
else
{
SparseMatrix<Scalar,int(SrcStorageOrder)==RowMajor?ColMajor:RowMajor,Index> tmp(m_matrix.rows(), m_matrix.cols());
- VectorXi sizes(tmp.outerSize());
+ Matrix<Index,Dynamic,1> sizes(tmp.outerSize());
sizes.setZero();
PermutationMatrix<Dynamic,Dynamic,Index> perm;
if((Side==OnTheLeft) ^ Transposed)
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/SparseProduct.h b/Utilities/eigen3/Eigen/src/SparseCore/SparseProduct.h
index 70b6480e..cf766307 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/SparseProduct.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/SparseProduct.h
@@ -16,6 +16,7 @@ template<typename Lhs, typename Rhs>
struct SparseSparseProductReturnType
{
typedef typename internal::traits<Lhs>::Scalar Scalar;
+ typedef typename internal::traits<Lhs>::Index Index;
enum {
LhsRowMajor = internal::traits<Lhs>::Flags & RowMajorBit,
RhsRowMajor = internal::traits<Rhs>::Flags & RowMajorBit,
@@ -24,11 +25,11 @@ struct SparseSparseProductReturnType
};
typedef typename internal::conditional<TransposeLhs,
- SparseMatrix<Scalar,0>,
+ SparseMatrix<Scalar,0,Index>,
typename internal::nested<Lhs,Rhs::RowsAtCompileTime>::type>::type LhsNested;
typedef typename internal::conditional<TransposeRhs,
- SparseMatrix<Scalar,0>,
+ SparseMatrix<Scalar,0,Index>,
typename internal::nested<Rhs,Lhs::RowsAtCompileTime>::type>::type RhsNested;
typedef SparseSparseProduct<LhsNested, RhsNested> Type;
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/SparseSparseProductWithPruning.h b/Utilities/eigen3/Eigen/src/SparseCore/SparseSparseProductWithPruning.h
index 70857c7b..fcc18f5c 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/SparseSparseProductWithPruning.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/SparseSparseProductWithPruning.h
@@ -27,7 +27,7 @@ static void sparse_sparse_product_with_pruning_impl(const Lhs& lhs, const Rhs& r
// make sure to call innerSize/outerSize since we fake the storage order.
Index rows = lhs.innerSize();
Index cols = rhs.outerSize();
- //int size = lhs.outerSize();
+ //Index size = lhs.outerSize();
eigen_assert(lhs.outerSize() == rhs.innerSize());
// allocate a temporary buffer
@@ -100,7 +100,7 @@ struct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,ColMajor,C
static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance)
{
// we need a col-major matrix to hold the result
- typedef SparseMatrix<typename ResultType::Scalar> SparseTemporaryType;
+ typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename ResultType::Index> SparseTemporaryType;
SparseTemporaryType _res(res.rows(), res.cols());
internal::sparse_sparse_product_with_pruning_impl<Lhs,Rhs,SparseTemporaryType>(lhs, rhs, _res, tolerance);
res = _res;
@@ -126,10 +126,11 @@ struct sparse_sparse_product_with_pruning_selector<Lhs,Rhs,ResultType,RowMajor,R
typedef typename ResultType::RealScalar RealScalar;
static void run(const Lhs& lhs, const Rhs& rhs, ResultType& res, const RealScalar& tolerance)
{
- typedef SparseMatrix<typename ResultType::Scalar,ColMajor> ColMajorMatrix;
- ColMajorMatrix colLhs(lhs);
- ColMajorMatrix colRhs(rhs);
- internal::sparse_sparse_product_with_pruning_impl<ColMajorMatrix,ColMajorMatrix,ResultType>(colLhs, colRhs, res, tolerance);
+ typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::Index> ColMajorMatrixLhs;
+ typedef SparseMatrix<typename ResultType::Scalar,ColMajor,typename Lhs::Index> ColMajorMatrixRhs;
+ ColMajorMatrixLhs colLhs(lhs);
+ ColMajorMatrixRhs colRhs(rhs);
+ internal::sparse_sparse_product_with_pruning_impl<ColMajorMatrixLhs,ColMajorMatrixRhs,ResultType>(colLhs, colRhs, res, tolerance);
// let's transpose the product to get a column x column product
// typedef SparseMatrix<typename ResultType::Scalar> SparseTemporaryType;
diff --git a/Utilities/eigen3/Eigen/src/SparseCore/SparseTranspose.h b/Utilities/eigen3/Eigen/src/SparseCore/SparseTranspose.h
index 7c300ee8..76d031d5 100644
--- a/Utilities/eigen3/Eigen/src/SparseCore/SparseTranspose.h
+++ b/Utilities/eigen3/Eigen/src/SparseCore/SparseTranspose.h
@@ -26,7 +26,7 @@ template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>
inline Index nonZeros() const { return derived().nestedExpression().nonZeros(); }
};
-// NOTE: VC10 trigger an ICE if don't put typename TransposeImpl<MatrixType,Sparse>:: in front of Index,
+// NOTE: VC10 and VC11 trigger an ICE if don't put typename TransposeImpl<MatrixType,Sparse>:: in front of Index,
// a typedef typename TransposeImpl<MatrixType,Sparse>::Index Index;
// does not fix the issue.
// An alternative is to define the nested class in the parent class itself.
@@ -40,8 +40,8 @@ template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::InnerItera
EIGEN_STRONG_INLINE InnerIterator(const TransposeImpl& trans, typename TransposeImpl<MatrixType,Sparse>::Index outer)
: Base(trans.derived().nestedExpression(), outer)
{}
- Index row() const { return Base::col(); }
- Index col() const { return Base::row(); }
+ typename TransposeImpl<MatrixType,Sparse>::Index row() const { return Base::col(); }
+ typename TransposeImpl<MatrixType,Sparse>::Index col() const { return Base::row(); }
};
template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::ReverseInnerIterator
@@ -54,8 +54,8 @@ template<typename MatrixType> class TransposeImpl<MatrixType,Sparse>::ReverseInn
EIGEN_STRONG_INLINE ReverseInnerIterator(const TransposeImpl& xpr, typename TransposeImpl<MatrixType,Sparse>::Index outer)
: Base(xpr.derived().nestedExpression(), outer)
{}
- Index row() const { return Base::col(); }
- Index col() const { return Base::row(); }
+ typename TransposeImpl<MatrixType,Sparse>::Index row() con
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment