diff --git a/.github/workflows/windows-msvc.yaml b/.github/workflows/windows-msvc.yaml index f10c61ed..4a25497b 100644 --- a/.github/workflows/windows-msvc.yaml +++ b/.github/workflows/windows-msvc.yaml @@ -35,19 +35,20 @@ jobs: - name: Clone visp shell: bash run: | - git clone --depth 1 https://github.com/lagadic/visp ${HOME}/visp + git clone --depth 1 https://github.com/lagadic/visp /d/a/visp + echo "VISP_SRC_DIR=D:\a\visp" >> $GITHUB_ENV - name: Clone visp-images shell: bash run: | - git clone --depth 1 https://github.com/lagadic/visp-images ${HOME}/visp-images - echo "VISP_INPUT_IMAGE_PATH=$HOME/visp-images" >> $GITHUB_ENV + git clone --depth 1 https://github.com/lagadic/visp-images /d/a/visp-images + echo "VISP_INPUT_IMAGE_PATH=D:\a\visp-images" >> $GITHUB_ENV - name: Clone ustk-dataset shell: bash run: | - git clone --depth 1 https://github.com/lagadic/ustk-dataset ${HOME}/ustk-dataset - echo "USTK_DATASET_PATH=$HOME/ustk-dataset" >> $GITHUB_ENV + git clone --depth 1 https://github.com/lagadic/ustk-dataset /d/a/ustk-dataset + echo "USTK_DATASET_PATH=D:\a\ustk-dataset" >> $GITHUB_ENV echo ${USTK_DATASET_PATH} - name: Configure ViSP @@ -61,7 +62,7 @@ jobs: echo %USTK_DATASET_PATH% mkdir build cd build - cmake ${HOME}/visp -G "Visual Studio 17 2022" -A "x64" -DVISP_CONTRIB_MODULES_PATH=.. -DBUILD_MODULE_visp_ar=OFF -DBUILD_MODULE_visp_blob=OFF -DBUILD_MODULE_visp_detection=OFF -DBUILD_MODULE_visp_klt=OFF -DBUILD_MODULE_visp_mbt=OFF -DBUILD_MODULE_visp_me=OFF -DBUILD_MODULE_visp_tt=OFF -DBUILD_MODULE_visp_tt_mi=OFF -DBUILD_MODULE_visp_vision=OFF -DBUILD_MODULE_visp_visual_features=OFF -DBUILD_MODULE_visp_vs=OFF + cmake %VISP_SRC_DIR% -G "Visual Studio 17 2022" -A "x64" -DVISP_CONTRIB_MODULES_PATH=.. -DBUILD_MODULE_visp_ar=OFF -DBUILD_MODULE_visp_blob=OFF -DBUILD_MODULE_visp_detection=OFF -DBUILD_MODULE_visp_klt=OFF -DBUILD_MODULE_visp_mbt=OFF -DBUILD_MODULE_visp_me=OFF -DBUILD_MODULE_visp_tt=OFF -DBUILD_MODULE_visp_tt_mi=OFF -DBUILD_MODULE_visp_vision=OFF -DBUILD_MODULE_visp_visual_features=OFF -DBUILD_MODULE_visp_vs=OFF type ViSP-third-party.txt - name: Build UsTK diff --git a/modules/ustk_core/include/visp3/ustk_core/usBSpline3D.h b/modules/ustk_core/include/visp3/ustk_core/usBSpline3D.h index 85cdd892..825feba4 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usBSpline3D.h +++ b/modules/ustk_core/include/visp3/ustk_core/usBSpline3D.h @@ -35,6 +35,7 @@ #include +#include #include #include @@ -73,7 +74,7 @@ class VISP_EXPORT usBSpline3D void removeSegments(int i, int j); void clear(); - void defineFromPoints(const std::vector &points, const std::vector &lengths, int order = 3); + void defineFromPoints(const std::vector &points, const std::vector &lengths, int order = 3); const usPolynomialCurve3D &accessSegment(int i) const; const usPolynomialCurve3D &accessLastSegment() const; @@ -83,22 +84,22 @@ class VISP_EXPORT usBSpline3D //! Move - bool move(const vpHomogeneousMatrix &H); + bool move(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &H); bool move(double x, double y, double z, double tx, double ty, double tz); //! Measure curve information //! Position - vpColVector getPoint(double param) const; - vpColVector getTangent(double param) const; - double getDistanceFromPoint(const vpColVector &point, double start = 0, double stop = -1, + VISP_NAMESPACE_ADDRESSING vpColVector getPoint(double param) const; + VISP_NAMESPACE_ADDRESSING vpColVector getTangent(double param) const; + double getDistanceFromPoint(const VISP_NAMESPACE_ADDRESSING vpColVector &point, double start = 0, double stop = -1, double threshold = 1e-5) const; bool getParametersFromLength(double l, int &index, double ¶m) const; //! Curvature - double getCurvatureFromShape(double start, double end, vpColVector ¢er3D, vpColVector &direction3D) const; + double getCurvatureFromShape(double start, double end, VISP_NAMESPACE_ADDRESSING vpColVector ¢er3D, VISP_NAMESPACE_ADDRESSING vpColVector &direction3D) const; //! Data saving diff --git a/modules/ustk_core/include/visp3/ustk_core/usGeometryDisplayTools.h b/modules/ustk_core/include/visp3/ustk_core/usGeometryDisplayTools.h index 02cc9be7..cd3e8774 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usGeometryDisplayTools.h +++ b/modules/ustk_core/include/visp3/ustk_core/usGeometryDisplayTools.h @@ -35,6 +35,7 @@ #include +#include #include #include #include @@ -48,55 +49,55 @@ namespace usGeometryDisplayTools { template -VISP_EXPORT void displayFrame(const vpImage &I, const vpHomogeneousMatrix &imageMFrame, +VISP_EXPORT void displayFrame(const VISP_NAMESPACE_ADDRESSING vpImage &I, const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMFrame, double Xscale = 3000, double Yscale = 3000); //! Display usOrientedPlane3D template -VISP_EXPORT void display(const usOrientedPlane3D &plane, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, - const vpColor &color = vpColor::green); +VISP_EXPORT void display(const usOrientedPlane3D &plane, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, + const VISP_NAMESPACE_ADDRESSING vpColor &color = VISP_NAMESPACE_ADDRESSING vpColor::green); //! Display usPolynomialCurve2D template -VISP_EXPORT void display(const usPolynomialCurve2D &curve, const vpImage &I, double Xscale = 3000, - double Yscale = 3000, const vpColor &color = vpColor::red, int nbRenderingLines = 10); +VISP_EXPORT void display(const usPolynomialCurve2D &curve, const VISP_NAMESPACE_ADDRESSING vpImage &I, double Xscale = 3000, + double Yscale = 3000, const VISP_NAMESPACE_ADDRESSING vpColor &color = VISP_NAMESPACE_ADDRESSING vpColor::red, int nbRenderingLines = 10); //! Display usPolynomialCurve3D template -VISP_EXPORT void display(const usPolynomialCurve3D &curve, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, - const vpColor &color = vpColor::red, int nbRenderingLines = 10, +VISP_EXPORT void display(const usPolynomialCurve3D &curve, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, + const VISP_NAMESPACE_ADDRESSING vpColor &color = VISP_NAMESPACE_ADDRESSING vpColor::red, int nbRenderingLines = 10, double visibilityDistance = std::numeric_limits::infinity()); template -VISP_EXPORT void displayCurvatureFromShape(const usPolynomialCurve3D &spline, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, - double Yscale = 3000, const vpColor &color = vpColor::black); +VISP_EXPORT void displayCurvatureFromShape(const usPolynomialCurve3D &spline, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, + double Yscale = 3000, const VISP_NAMESPACE_ADDRESSING vpColor &color = VISP_NAMESPACE_ADDRESSING vpColor::black); //! Display usBSpline3D template -VISP_EXPORT void displayLine(const usBSpline3D &spline, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, - const vpColor &color = vpColor::red, int nbRenderingLinesPerSegment = 10, +VISP_EXPORT void displayLine(const usBSpline3D &spline, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, + const VISP_NAMESPACE_ADDRESSING vpColor &color = VISP_NAMESPACE_ADDRESSING vpColor::red, int nbRenderingLinesPerSegment = 10, double visibilityDistance = std::numeric_limits::infinity()); template -VISP_EXPORT void displayExtremities(const usBSpline3D &spline, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, - const vpColor &color = vpColor::red, +VISP_EXPORT void displayExtremities(const usBSpline3D &spline, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, + const VISP_NAMESPACE_ADDRESSING vpColor &color = VISP_NAMESPACE_ADDRESSING vpColor::red, double visibilityDistance = std::numeric_limits::infinity()); template -VISP_EXPORT void display(const usBSpline3D &spline, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, - const vpColor &color = vpColor::red, int nbRenderingLines = 10, +VISP_EXPORT void display(const usBSpline3D &spline, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, + const VISP_NAMESPACE_ADDRESSING vpColor &color = VISP_NAMESPACE_ADDRESSING vpColor::red, int nbRenderingLines = 10, double visibilityDistance = std::numeric_limits::infinity()); template -VISP_EXPORT void displayCurvatureFromShape(const usBSpline3D &spline, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, - double Yscale = 3000, const vpColor &color = vpColor::black); +VISP_EXPORT void displayCurvatureFromShape(const usBSpline3D &spline, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, + double Yscale = 3000, const VISP_NAMESPACE_ADDRESSING vpColor &color = VISP_NAMESPACE_ADDRESSING vpColor::black); } // namespace usGeometryDisplayTools diff --git a/modules/ustk_core/include/visp3/ustk_core/usGeometryTools.h b/modules/ustk_core/include/visp3/ustk_core/usGeometryTools.h index 680b918c..aeef37b1 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usGeometryTools.h +++ b/modules/ustk_core/include/visp3/ustk_core/usGeometryTools.h @@ -35,6 +35,7 @@ #include +#include #include #include @@ -44,60 +45,60 @@ namespace usGeometryTools { -VISP_EXPORT double getPointPlaneDistance(const vpColVector &point, const usOrientedPlane3D &plane); -VISP_EXPORT bool IsPointInFrontOfPlane(const vpColVector &point, const usOrientedPlane3D &plane); +VISP_EXPORT double getPointPlaneDistance(const VISP_NAMESPACE_ADDRESSING vpColVector &point, const usOrientedPlane3D &plane); +VISP_EXPORT bool IsPointInFrontOfPlane(const VISP_NAMESPACE_ADDRESSING vpColVector &point, const usOrientedPlane3D &plane); VISP_EXPORT bool DoesSegmentCrossPlane(const usPolynomialCurve3D &poly, const usOrientedPlane3D &plane); VISP_EXPORT bool DoesSegmentCrossPlane(const usBSpline3D &spline, const usOrientedPlane3D &plane); VISP_EXPORT bool DoesSegmentCrossPlaneDirect(const usPolynomialCurve3D &poly, const usOrientedPlane3D &plane); VISP_EXPORT bool DoesSegmentCrossPlaneDirect(const usBSpline3D &spline, const usOrientedPlane3D &plane); -VISP_EXPORT vpColVector getPlaneCurveCrossingPoint(const usPolynomialCurve3D &poly, const usOrientedPlane3D &plane, +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpColVector getPlaneCurveCrossingPoint(const usPolynomialCurve3D &poly, const usOrientedPlane3D &plane, double threshold, double *t = nullptr); -VISP_EXPORT vpColVector getPlaneCurveCrossingPoint(const usBSpline3D &spline, const usOrientedPlane3D &plane, +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpColVector getPlaneCurveCrossingPoint(const usBSpline3D &spline, const usOrientedPlane3D &plane, double threshold, double *t = nullptr); -VISP_EXPORT vpColVector projectPointOnPlane(const vpColVector &point, const usOrientedPlane3D &plane, - const vpColVector &direction = vpColVector()); -VISP_EXPORT vpColVector projectPointOnCurve(const vpColVector &point, const usPolynomialCurve3D &poly, +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpColVector projectPointOnPlane(const VISP_NAMESPACE_ADDRESSING vpColVector &point, const usOrientedPlane3D &plane, + const VISP_NAMESPACE_ADDRESSING vpColVector &direction = VISP_NAMESPACE_ADDRESSING vpColVector()); +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpColVector projectPointOnCurve(const VISP_NAMESPACE_ADDRESSING vpColVector &point, const usPolynomialCurve3D &poly, double threshold = -1, double *t = nullptr); -VISP_EXPORT vpColVector projectPointOnCurve(const vpColVector &point, const usBSpline3D &spline, double threshold = -1, +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpColVector projectPointOnCurve(const VISP_NAMESPACE_ADDRESSING vpColVector &point, const usBSpline3D &spline, double threshold = -1, int *index = nullptr, double *t = nullptr); VISP_EXPORT usOrientedPlane3D getNormalPlane(const usPolynomialCurve3D &p, double l); VISP_EXPORT usPolynomialCurve3D convertBSplineToPolynomial(const usBSpline3D &spline, int order); VISP_EXPORT usBSpline3D convertPolynomialToBSpline(const usPolynomialCurve3D &poly, int nbSegments, int order); -VISP_EXPORT vpPoseVector findPointCloudRelativePose(std::vector &P1, std::vector &P2, +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpPoseVector findPointCloudRelativePose(std::vector &P1, std::vector &P2, double *res = nullptr); // return transform from P1 to P2 (P2 = H * // P1) (here P1 and P2 have the same size // and are already matched one by one) -VISP_EXPORT vpTranslationVector findPointCloudRelativePosition(std::vector &P1, - std::vector &P2, - const vpRotationMatrix &worldRprobe, +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpTranslationVector findPointCloudRelativePosition(std::vector &P1, + std::vector &P2, + const VISP_NAMESPACE_ADDRESSING vpRotationMatrix &worldRprobe, double *res = nullptr); // return translation from P1 to // P2 (P2 = P1 + T) (here P1 and // P2 have the same size and are // already matched one by one) -VISP_EXPORT vpRotationMatrix findPointCloudRelativeRotation(std::vector &P1, std::vector &P2, +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpRotationMatrix findPointCloudRelativeRotation(std::vector &P1, std::vector &P2, double *res = nullptr); // return rotation from P1 to P2 (P2 // = R * P1) (here P1 and P2 have // the same size and are already // matched one by one) -VISP_EXPORT vpPoseVector ICPPointCloudRelativePose( - std::vector &P1, std::vector &P2, double *res = nullptr, - vpPoseVector *initialGuess = +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpPoseVector ICPPointCloudRelativePose( + std::vector &P1, std::vector &P2, double *res = nullptr, + VISP_NAMESPACE_ADDRESSING vpPoseVector *initialGuess = nullptr); // return transform from P1 to P2 (P2 = H * P1) (P1 and P2 can have different sizes) -VISP_EXPORT vpTranslationVector ICPPointCloudRelativePosition( - std::vector &P1, std::vector &P2, const vpRotationMatrix &worldRprobe, +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpTranslationVector ICPPointCloudRelativePosition( + std::vector &P1, std::vector &P2, const VISP_NAMESPACE_ADDRESSING vpRotationMatrix &worldRprobe, double *res = nullptr, - vpTranslationVector *initialGuess = + VISP_NAMESPACE_ADDRESSING vpTranslationVector *initialGuess = nullptr); // return translation from P1 to P2 (P2 = P1 + T) (P1 and P2 can have different sizes) -VISP_EXPORT vpRotationMatrix ICPPointCloudRelativeRotation( - std::vector &P1, std::vector &P2, double *res = nullptr, - vpRotationMatrix *initialGuess = +VISP_EXPORT VISP_NAMESPACE_ADDRESSING vpRotationMatrix ICPPointCloudRelativeRotation( + std::vector &P1, std::vector &P2, double *res = nullptr, + VISP_NAMESPACE_ADDRESSING vpRotationMatrix *initialGuess = nullptr); // return rotation from P1 to P2 (P2 = R * P1) (P1 and P2 can have different sizes) -VISP_EXPORT bool fitCircleTo2DPointCloud(const std::vector &points, vpColVector ¢er, double &r); -VISP_EXPORT bool fitSphereTo3DPointCloud(const std::vector &points, vpColVector ¢er, double &r); +VISP_EXPORT bool fitCircleTo2DPointCloud(const std::vector &points, VISP_NAMESPACE_ADDRESSING vpColVector ¢er, double &r); +VISP_EXPORT bool fitSphereTo3DPointCloud(const std::vector &points, VISP_NAMESPACE_ADDRESSING vpColVector ¢er, double &r); } // namespace usGeometryTools diff --git a/modules/ustk_core/include/visp3/ustk_core/usImage3D.h b/modules/ustk_core/include/visp3/ustk_core/usImage3D.h index c4c1d28b..62b91329 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usImage3D.h +++ b/modules/ustk_core/include/visp3/ustk_core/usImage3D.h @@ -46,6 +46,7 @@ #include #include +#include #include #include #include @@ -242,6 +243,10 @@ template class usImage3D template inline void usImage3D::init(unsigned int height, unsigned int width, unsigned int numberOfFrames) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if ((width != this->m_width) || (height != this->m_height) || (numberOfFrames != this->m_numberOfFrames)) { if (bitmap != NULL) { vpDEBUG_TRACE(10, "Destruction bitmap[]"); @@ -279,8 +284,7 @@ inline void usImage3D::init(unsigned int height, unsigned int width, unsig template usImage3D::usImage3D() : m_width(0), m_height(0), m_numberOfFrames(0), m_size(0), bitmap(NULL), framPointer(NULL) -{ -} +{ } template usImage3D::usImage3D(unsigned int height, unsigned int width, unsigned int frameNumber) @@ -332,14 +336,15 @@ template usImage3D &usImage3D::operator=(const usImage3 template bool usImage3D::operator==(const usImage3D &other) { bool settingsOk = this->getWidth() == other.getWidth() && this->getHeight() == other.getHeight() && - this->getNumberOfFrames() == other.getNumberOfFrames(); + this->getNumberOfFrames() == other.getNumberOfFrames(); if (settingsOk) { for (unsigned int i = 0; i < m_size; i++) { if (bitmap[i] != other.getConstData()[i]) return false; } - } else + } + else return false; return true; } @@ -347,18 +352,23 @@ template bool usImage3D::operator==(const usImage3D &ot template std::ostream &operator<<(std::ostream &out, const usImage3D &image) { return out << "width : " << image.getWidth() << std::endl - << "height : " << image.getHeight() << std::endl - << "frames in volume : " << image.getNumberOfFrames() << std::endl; + << "height : " << image.getHeight() << std::endl + << "frames in volume : " << image.getNumberOfFrames() << std::endl; } template void usImage3D::setData(Type *data, int numberOfVoxels) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + try { if (m_size != numberOfVoxels) { throw(vpException(vpException::fatalError, "usImage3D::setData() error, bitmap dimensions mismatch.")); } memcpy(bitmap, data, m_size * sizeof(Type)); - } catch (std::exception e) { + } + catch (std::exception e) { std::cout << "usImage3D::setData(), error when trying to copy the data :" << std::endl; std::cout << e.what() << std::endl; } @@ -368,7 +378,8 @@ template void usImage3D::initData(Type value) { try { std::fill_n(bitmap, m_size, value); - } catch (const std::exception &e) { + } + catch (const std::exception &e) { std::cout << e.what() << std::endl; } } diff --git a/modules/ustk_core/include/visp3/ustk_core/usImageHeaderXmlParser.h b/modules/ustk_core/include/visp3/ustk_core/usImageHeaderXmlParser.h index 382c0c09..02f9cc99 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usImageHeaderXmlParser.h +++ b/modules/ustk_core/include/visp3/ustk_core/usImageHeaderXmlParser.h @@ -55,7 +55,7 @@ * @brief Input/output operations between ultrasound image header and the associated xml files. Used for virtual server. * @ingroup module_ustk_grabber */ -class VISP_EXPORT usImageHeaderXmlParser : public vpXmlParser +class VISP_EXPORT usImageHeaderXmlParser : public VISP_NAMESPACE_ADDRESSING vpXmlParser { public: usImageHeaderXmlParser(); diff --git a/modules/ustk_core/include/visp3/ustk_core/usImagePostScan2D.h b/modules/ustk_core/include/visp3/ustk_core/usImagePostScan2D.h index 7b7cf8d7..0177b3ad 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usImagePostScan2D.h +++ b/modules/ustk_core/include/visp3/ustk_core/usImagePostScan2D.h @@ -105,11 +105,11 @@ int main() } \endcode */ -template class usImagePostScan2D : public vpImage, public usTransducerSettings +template class usImagePostScan2D : public VISP_NAMESPACE_ADDRESSING vpImage, public usTransducerSettings { public: usImagePostScan2D(); - usImagePostScan2D(const vpImage &image, const usTransducerSettings &transducerSettings, + usImagePostScan2D(const VISP_NAMESPACE_ADDRESSING vpImage &image, const usTransducerSettings &transducerSettings, double widthResolution = 0.0, double heightResolution = 0.0); usImagePostScan2D(const usImagePostScan2D &other); virtual ~usImagePostScan2D(); @@ -120,7 +120,7 @@ template class usImagePostScan2D : public vpImage, public usT usImagePostScan2D &operator=(const usImagePostScan2D &other); bool operator==(const usImagePostScan2D &other); - void setData(const vpImage &image); + void setData(const VISP_NAMESPACE_ADDRESSING vpImage &image); void setHeightResolution(double heightResolution); void setWidthResolution(double widthResolution); @@ -134,7 +134,7 @@ template class usImagePostScan2D : public vpImage, public usT */ template usImagePostScan2D::usImagePostScan2D() - : vpImage(), usTransducerSettings(), m_widthResolution(0.0), m_heightResolution(0.0) + : VISP_NAMESPACE_ADDRESSING vpImage(), usTransducerSettings(), m_widthResolution(0.0), m_heightResolution(0.0) { } /** @@ -143,7 +143,7 @@ usImagePostScan2D::usImagePostScan2D() */ template usImagePostScan2D::usImagePostScan2D(const usImagePostScan2D &other) - : vpImage(other), usTransducerSettings(other), m_widthResolution(other.getWidthResolution()), + : VISP_NAMESPACE_ADDRESSING vpImage(other), usTransducerSettings(other), m_widthResolution(other.getWidthResolution()), m_heightResolution(other.getHeightResolution()) { } @@ -155,9 +155,9 @@ usImagePostScan2D::usImagePostScan2D(const usImagePostScan2D &other) * @param widthResolution Width (in meters) of a pixel. */ template -usImagePostScan2D::usImagePostScan2D(const vpImage &image, const usTransducerSettings &transducerSettings, +usImagePostScan2D::usImagePostScan2D(const VISP_NAMESPACE_ADDRESSING vpImage &image, const usTransducerSettings &transducerSettings, double widthResolution, double heightResolution) - : vpImage(image), usTransducerSettings(transducerSettings), m_widthResolution(widthResolution), + : VISP_NAMESPACE_ADDRESSING vpImage(image), usTransducerSettings(transducerSettings), m_widthResolution(widthResolution), m_heightResolution(heightResolution) { } @@ -171,6 +171,10 @@ template usImagePostScan2D::~usImagePostScan2D() { } */ template usImagePostScan2D &usImagePostScan2D::operator=(const usImagePostScan2D &other) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + // from vpImage vpImage::operator=(other); @@ -189,6 +193,9 @@ template usImagePostScan2D &usImagePostScan2D::operator */ template bool usImagePostScan2D::operator==(const usImagePostScan2D &other) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif return (vpImage::operator==(other) && usTransducerSettings::operator==(other) && m_heightResolution == other.getHeightResolution() && m_widthResolution == other.getWidthResolution()); } @@ -208,8 +215,11 @@ template std::ostream &operator<<(std::ostream &out, const usImageP * Setter that updates 2D post-scan image data. * @param image Data to set. */ -template void usImagePostScan2D::setData(const vpImage &image) +template void usImagePostScan2D::setData(const VISP_NAMESPACE_ADDRESSING vpImage &image) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif vpImage::operator=(image); } diff --git a/modules/ustk_core/include/visp3/ustk_core/usImagePreScan2D.h b/modules/ustk_core/include/visp3/ustk_core/usImagePreScan2D.h index 5d2acc03..6d352ba0 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usImagePreScan2D.h +++ b/modules/ustk_core/include/visp3/ustk_core/usImagePreScan2D.h @@ -38,6 +38,7 @@ #ifndef __usImagePreScan2D_h_ #define __usImagePreScan2D_h_ +#include #include #include @@ -102,7 +103,7 @@ int main() \endcode */ -template class usImagePreScan2D : public vpImage, public usImagePreScanSettings +template class usImagePreScan2D : public VISP_NAMESPACE_ADDRESSING vpImage, public usImagePreScanSettings { public: // default constructors @@ -110,7 +111,7 @@ template class usImagePreScan2D : public vpImage, public usIm // sized constructor usImagePreScan2D(unsigned int height, unsigned int width); // All parameters initialisation constructors - usImagePreScan2D(const vpImage &image, const usImagePreScanSettings &preScanSettings); + usImagePreScan2D(const VISP_NAMESPACE_ADDRESSING vpImage &image, const usImagePreScanSettings &preScanSettings); // usImagePreScan2D copy constructor usImagePreScan2D(const usImagePreScan2D &other); @@ -127,7 +128,7 @@ template class usImagePreScan2D : public vpImage, public usIm bool operator==(const usImagePreScan2D &other); bool operator!=(const usImagePreScan2D &other); - void setData(const vpImage image); + void setData(const VISP_NAMESPACE_ADDRESSING vpImage image); void setScanLineNumber(unsigned int scanLineNumber); // Filtering before calling vpImage::resize() to update scanLineNumber @@ -138,7 +139,7 @@ template class usImagePreScan2D : public vpImage, public usIm /** * Basic constructor, all settings set to default values. */ -template usImagePreScan2D::usImagePreScan2D() : vpImage(), usImagePreScanSettings() {} +template usImagePreScan2D::usImagePreScan2D() : VISP_NAMESPACE_ADDRESSING vpImage(), usImagePreScanSettings() { } /** * Copy constructor. @@ -146,9 +147,8 @@ template usImagePreScan2D::usImagePreScan2D() : vpImage */ template usImagePreScan2D::usImagePreScan2D(const usImagePreScan2D &other) - : vpImage(other), usImagePreScanSettings(other) -{ -} + : VISP_NAMESPACE_ADDRESSING vpImage(other), usImagePreScanSettings(other) +{ } /** * Constructor from image size. @@ -157,7 +157,7 @@ usImagePreScan2D::usImagePreScan2D(const usImagePreScan2D &other) */ template usImagePreScan2D::usImagePreScan2D(unsigned int height, unsigned int width) - : vpImage(height, width), usImagePreScanSettings() + : VISP_NAMESPACE_ADDRESSING vpImage(height, width), usImagePreScanSettings() { usTransducerSettings::setScanLineNumber(width); } @@ -168,9 +168,13 @@ usImagePreScan2D::usImagePreScan2D(unsigned int height, unsigned int width * @param preScanSettings Pre-scan settings you want to set. */ template -usImagePreScan2D::usImagePreScan2D(const vpImage &image, const usImagePreScanSettings &preScanSettings) - : vpImage(image), usImagePreScanSettings(preScanSettings) +usImagePreScan2D::usImagePreScan2D(const VISP_NAMESPACE_ADDRESSING vpImage &image, const usImagePreScanSettings &preScanSettings) + : VISP_NAMESPACE_ADDRESSING vpImage(image), usImagePreScanSettings(preScanSettings) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (image.getWidth() != preScanSettings.getScanLineNumber()) throw(vpException(vpException::badValue, "Pre-scan image width differ from transducer scanline number")); } @@ -178,13 +182,16 @@ usImagePreScan2D::usImagePreScan2D(const vpImage &image, const usIma /** * Destructor. */ -template usImagePreScan2D::~usImagePreScan2D() {} +template usImagePreScan2D::~usImagePreScan2D() { } /** * Copy operator. */ template usImagePreScan2D &usImagePreScan2D::operator=(const usImagePreScan2D &other) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif // from vpImage vpImage::operator=(other); @@ -199,6 +206,9 @@ template usImagePreScan2D &usImagePreScan2D::operator=( */ template bool usImagePreScan2D::operator==(const usImagePreScan2D &other) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif return (vpImage::operator==(other) && usImagePreScanSettings::operator==(other)); } @@ -216,8 +226,8 @@ template bool usImagePreScan2D::operator!=(const usImagePreSc template std::ostream &operator<<(std::ostream &out, const usImagePreScan2D &other) { return out << static_cast(other) - << "number of B-mode samples in a scan line : " << other.getBModeSampleNumber() << std::endl - << "number of scan lines : " << other.getScanLineNumber() << std::endl; + << "number of B-mode samples in a scan line : " << other.getBModeSampleNumber() << std::endl + << "number of scan lines : " << other.getScanLineNumber() << std::endl; } /** @@ -226,6 +236,10 @@ template std::ostream &operator<<(std::ostream &out, const usImageP */ template unsigned int usImagePreScan2D::getBModeSampleNumber() const { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + return vpImage::getHeight(); } @@ -233,8 +247,12 @@ template unsigned int usImagePreScan2D::getBModeSampleNumber( * Setter for the image data. * @param image The image to set. */ -template void usImagePreScan2D::setData(const vpImage image) +template void usImagePreScan2D::setData(const VISP_NAMESPACE_ADDRESSING vpImage image) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpImage::operator=(image); setScanLineNumber(image.getWidth()); } @@ -247,6 +265,10 @@ template void usImagePreScan2D::setData(const vpImage i */ template void usImagePreScan2D::setScanLineNumber(unsigned int scanLineNumber) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpImage::resize(vpImage::getHeight(), scanLineNumber); usTransducerSettings::setScanLineNumber(scanLineNumber); } @@ -260,6 +282,10 @@ template void usImagePreScan2D::setScanLineNumber(unsigned in */ template void usImagePreScan2D::resize(const unsigned int h, const unsigned int w) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + usTransducerSettings::setScanLineNumber(w); vpImage::resize(h, w); } @@ -274,6 +300,10 @@ template void usImagePreScan2D::resize(const unsigned int h, */ template void usImagePreScan2D::resize(const unsigned int h, const unsigned int w, const Type val) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + usTransducerSettings::setScanLineNumber(w); vpImage::resize(h, w, val); } diff --git a/modules/ustk_core/include/visp3/ustk_core/usImagePreScan3D.h b/modules/ustk_core/include/visp3/ustk_core/usImagePreScan3D.h index 0981ee8c..703cb7ea 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usImagePreScan3D.h +++ b/modules/ustk_core/include/visp3/ustk_core/usImagePreScan3D.h @@ -39,6 +39,7 @@ #ifndef __usImagePreScan3D_h_ #define __usImagePreScan3D_h_ +#include #include #include @@ -174,8 +175,7 @@ class usImagePreScan3D : public usImage3D, public usImagePreScanSettings, */ template usImagePreScan3D::usImagePreScan3D() : usImage3D(), usImagePreScanSettings(), usMotorSettings() -{ -} +{ } /** * Copy constructor. @@ -188,6 +188,10 @@ usImagePreScan3D::usImagePreScan3D(const usImage3D &image, const usI const usMotorSettings &motorSettings) : usImage3D(image), usImagePreScanSettings(preScanSettings), usMotorSettings(motorSettings) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (image.getWidth() != preScanSettings.getScanLineNumber()) throw(vpException(vpException::badValue, "3D pre-scan image X-size differ from transducer scan line number")); if (image.getNumberOfFrames() != motorSettings.getFrameNumber()) @@ -201,13 +205,12 @@ usImagePreScan3D::usImagePreScan3D(const usImage3D &image, const usI template usImagePreScan3D::usImagePreScan3D(const usImagePreScan3D &other) : usImage3D(other), usImagePreScanSettings(other), usMotorSettings(other) -{ -} +{ } /** * Destructor. */ -template usImagePreScan3D::~usImagePreScan3D() {} +template usImagePreScan3D::~usImagePreScan3D() { } /** * Copy operator. @@ -241,7 +244,7 @@ template bool usImagePreScan3D::operator==(const usImagePreSc template std::ostream &operator<<(std::ostream &out, const usImagePreScan3D &other) { return out << static_cast &>(other) << static_cast(other) - << static_cast(other); + << static_cast(other); } /** @@ -311,6 +314,10 @@ void usImagePreScan3D::resize(unsigned int height, unsigned int width, uns */ template void usImagePreScan3D::insertFrame(const usImagePreScan2D &frame, unsigned int index) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + // Dimentions checks if (index > this->getNumberOfFrames()) throw(vpException(vpException::badValue, "usImage3D::insertFrame : frame index out of volume")); @@ -337,8 +344,11 @@ template void usImagePreScan3D::insertFrame(const usImagePreS */ template void usImagePreScan3D::getFrame(usImagePreScan2D &image, unsigned int index) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif - // Dimentions checks + // Dimensions checks if (index > this->getNumberOfFrames() - 1) throw(vpException(vpException::badValue, "usImage3D::getFrame : frame index out of volume")); diff --git a/modules/ustk_core/include/visp3/ustk_core/usImageRF2D.h b/modules/ustk_core/include/visp3/ustk_core/usImageRF2D.h index 889cb783..e20c134f 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usImageRF2D.h +++ b/modules/ustk_core/include/visp3/ustk_core/usImageRF2D.h @@ -40,6 +40,7 @@ #include +#include #include /*! @@ -162,8 +163,7 @@ template class usImageRF2D : public usImagePreScanSettings */ template usImageRF2D::usImageRF2D() : usImagePreScanSettings(), bitmap(NULL), npixels(0), width(0), height(0), col(NULL) -{ -} +{ } /** * Initializing constructor. @@ -187,6 +187,10 @@ template usImageRF2D::usImageRF2D(unsigned int height, unsigned int width, const usImagePreScanSettings &preScanSettings) : usImagePreScanSettings(preScanSettings), bitmap(NULL), npixels(0), width(0), height(0), col(NULL) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (width != preScanSettings.getScanLineNumber()) throw(vpException(vpException::badValue, "RF image width differ from transducer scan line number")); @@ -266,6 +270,10 @@ template bool usImageRF2D::operator==(const usImageRF2D */ template Type usImageRF2D::operator()(unsigned int i, unsigned int j) const { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (i >= height || j >= width) throw vpException(vpException::dimensionError, "usImageRF2D, try to acess index out of image bounds"); @@ -280,6 +288,10 @@ template Type usImageRF2D::operator()(unsigned int i, unsigne */ template void usImageRF2D::operator()(unsigned int i, unsigned int j, const Type &value) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (i >= height || j >= width) throw vpException(vpException::dimensionError, "usImageRF2D, try to write at index out of image bounds"); @@ -292,10 +304,10 @@ template void usImageRF2D::operator()(unsigned int i, unsigne template std::ostream &operator<<(std::ostream &out, const usImageRF2D &other) { return out << static_cast(other) << "image height : " << other.getHeight() - << std::endl - << "image width : " << other.getWidth() << std::endl - << "number of A-samples in a scan line : " << other.getRFSampleNumber() << std::endl - << "number of scan lines : " << other.getScanLineNumber() << std::endl; + << std::endl + << "image width : " << other.getWidth() << std::endl + << "number of A-samples in a scan line : " << other.getRFSampleNumber() << std::endl + << "number of scan lines : " << other.getScanLineNumber() << std::endl; } /** @@ -370,6 +382,10 @@ void usImageRF2D::resize(const unsigned int height, const unsigned int wid */ template void usImageRF2D::init(unsigned int height, unsigned int width) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (width != this->width) { if (col != NULL) { delete[] col; diff --git a/modules/ustk_core/include/visp3/ustk_core/usImageRF3D.h b/modules/ustk_core/include/visp3/ustk_core/usImageRF3D.h index 12cc30cd..4cdafab2 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usImageRF3D.h +++ b/modules/ustk_core/include/visp3/ustk_core/usImageRF3D.h @@ -40,6 +40,7 @@ #include +#include #include #include @@ -187,9 +188,8 @@ template class usImageRF3D : public usImagePreScanSettings, public template usImageRF3D::usImageRF3D() : usImagePreScanSettings(), usMotorSettings(), m_width(0), m_height(0), m_numberOfFrames(0), m_size(0), bitmap(NULL), - framPointer(NULL) -{ -} + framPointer(NULL) +{ } /** * Basic constructor. @@ -197,7 +197,7 @@ usImageRF3D::usImageRF3D() template usImageRF3D::usImageRF3D(unsigned int height, unsigned int width, unsigned int numberOfFrames) : usImagePreScanSettings(), usMotorSettings(), m_width(0), m_height(0), m_numberOfFrames(0), m_size(0), bitmap(NULL), - framPointer(NULL) + framPointer(NULL) { resize(height, width, numberOfFrames); } @@ -214,8 +214,12 @@ template usImageRF3D::usImageRF3D(unsigned int height, unsigned int width, unsigned int numberOfFrames, const usImagePreScanSettings &preScanSettings, const usMotorSettings &motorSettings) : usImagePreScanSettings(preScanSettings), usMotorSettings(motorSettings), m_width(0), m_height(0), - m_numberOfFrames(0), m_size(0), bitmap(NULL), framPointer(NULL) + m_numberOfFrames(0), m_size(0), bitmap(NULL), framPointer(NULL) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (width != preScanSettings.getScanLineNumber()) throw(vpException(vpException::badValue, "3D RF image U-size differ from transducer scanline number")); if (numberOfFrames != motorSettings.getFrameNumber()) @@ -231,7 +235,7 @@ usImageRF3D::usImageRF3D(unsigned int height, unsigned int width, unsigned template usImageRF3D::usImageRF3D(const usImageRF3D &other) : usImagePreScanSettings(other), usMotorSettings(other), m_width(0), m_height(0), m_numberOfFrames(0), m_size(0), - bitmap(NULL) + bitmap(NULL) { init(other.getHeight(), other.getWidth(), other.getNumberOfFrames()); memcpy(bitmap, other.getConstData(), (size_t)(m_width * m_height * m_numberOfFrames * sizeof(Type))); @@ -309,8 +313,8 @@ template bool usImageRF3D::operator==(const usImageRF3D template std::ostream &operator<<(std::ostream &out, const usImageRF3D &image) { return out << "width : " << image.getWidth() << "\nheight : " << image.getHeight() - << "\nnumberOfFrames : " << image.getNumberOfFrames() << std::endl - << static_cast(image) << static_cast(image); + << "\nnumberOfFrames : " << image.getNumberOfFrames() << std::endl + << static_cast(image) << static_cast(image); } /** @@ -368,6 +372,10 @@ void usImageRF3D::resize(unsigned int height, unsigned int width, unsigned */ template void usImageRF3D::insertFrame(const usImageRF2D &frame, unsigned int index) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + // Dimentions checks if (index > this->getNumberOfFrames()) throw(vpException(vpException::badValue, "usImageRF3D::insertFrame : frame index out of volume")); @@ -394,6 +402,10 @@ template void usImageRF3D::insertFrame(const usImageRF2D void usImageRF3D::getFrame(usImageRF2D &image, unsigned int index) const { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + // Dimentions checks if (index > this->getNumberOfFrames()) throw(vpException(vpException::badValue, "usImageRF3D::getFrame : frame index out of volume")); @@ -433,6 +445,10 @@ template void usImageRF3D::getFrame(usImageRF2D &image, */ template void usImageRF3D::init(unsigned int height, unsigned int width, unsigned int numberOfFrames) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if ((width != this->m_width) || (height != this->m_height) || (numberOfFrames != this->m_numberOfFrames)) { if (bitmap != NULL) { delete[] bitmap; @@ -502,6 +518,10 @@ template const Type *usImageRF3D::getConstData() const { retu */ template Type usImageRF3D::operator()(unsigned int i, unsigned int j, unsigned int k) const { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + bool indexOK = j < m_width && i < m_height && k < m_numberOfFrames; if (!indexOK) throw(vpException(vpException::dimensionError, "usImageRF3D : accessing a voxel out of range !")); @@ -519,6 +539,10 @@ template Type usImageRF3D::operator()(unsigned int i, unsigne template void usImageRF3D::operator()(unsigned int i, unsigned int j, unsigned int k, const Type &value) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + bool indexOK = j < m_width && i < m_height && k < m_numberOfFrames; if (!indexOK) throw(vpException(vpException::dimensionError, "usImageRF3D : trying to write in a voxel out of range !")); diff --git a/modules/ustk_core/include/visp3/ustk_core/usImageSettingsXmlParser.h b/modules/ustk_core/include/visp3/ustk_core/usImageSettingsXmlParser.h index d3446945..74a4e49c 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usImageSettingsXmlParser.h +++ b/modules/ustk_core/include/visp3/ustk_core/usImageSettingsXmlParser.h @@ -59,7 +59,7 @@ * @brief Input/output operations between ultrasound image settings and the associated xml files. * @ingroup module_ustk_core */ -class VISP_EXPORT usImageSettingsXmlParser : public vpXmlParser +class VISP_EXPORT usImageSettingsXmlParser : public VISP_NAMESPACE_ADDRESSING vpXmlParser { public: usImageSettingsXmlParser(); diff --git a/modules/ustk_core/include/visp3/ustk_core/usMeterPixelConversion.h b/modules/ustk_core/include/visp3/ustk_core/usMeterPixelConversion.h index 64498069..eb5eebba 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usMeterPixelConversion.h +++ b/modules/ustk_core/include/visp3/ustk_core/usMeterPixelConversion.h @@ -40,6 +40,7 @@ #include +#include #include #include diff --git a/modules/ustk_core/include/visp3/ustk_core/usOrientedPlane3D.h b/modules/ustk_core/include/visp3/ustk_core/usOrientedPlane3D.h index f5d0ed35..e9703042 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usOrientedPlane3D.h +++ b/modules/ustk_core/include/visp3/ustk_core/usOrientedPlane3D.h @@ -35,6 +35,7 @@ #include +#include #include #include #include @@ -42,33 +43,33 @@ class VISP_EXPORT usOrientedPlane3D { protected: - vpColVector m_direction; - vpPoseVector m_pose; + VISP_NAMESPACE_ADDRESSING vpColVector m_direction; + VISP_NAMESPACE_ADDRESSING vpPoseVector m_pose; public: //! Constructors, destructor usOrientedPlane3D(); usOrientedPlane3D(const usOrientedPlane3D &plane); - usOrientedPlane3D(const vpPoseVector &pose); - usOrientedPlane3D(const vpColVector &p, const vpColVector &d); + usOrientedPlane3D(const VISP_NAMESPACE_ADDRESSING vpPoseVector &pose); + usOrientedPlane3D(const VISP_NAMESPACE_ADDRESSING vpColVector &p, const VISP_NAMESPACE_ADDRESSING vpColVector &d); virtual ~usOrientedPlane3D(); const usOrientedPlane3D &operator=(const usOrientedPlane3D &plane); //! Parameters setters and getters - void setPose(const vpPoseVector &pose); - vpPoseVector getPose() const; + void setPose(const VISP_NAMESPACE_ADDRESSING vpPoseVector &pose); + VISP_NAMESPACE_ADDRESSING vpPoseVector getPose() const; - void setPosition(const vpColVector &P); - vpColVector getPosition() const; + void setPosition(const VISP_NAMESPACE_ADDRESSING vpColVector &P); + VISP_NAMESPACE_ADDRESSING vpColVector getPosition() const; - void setDirection(const vpColVector &D); - vpColVector getDirection() const; + void setDirection(const VISP_NAMESPACE_ADDRESSING vpColVector &D); + VISP_NAMESPACE_ADDRESSING vpColVector getDirection() const; - void moveInLocalFrame(const vpHomogeneousMatrix &H); + void moveInLocalFrame(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &H); void moveInLocalFrame(double x, double y, double z, double tx, double ty, double tz); - void moveInWorldFrame(const vpHomogeneousMatrix &H); + void moveInWorldFrame(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &H); void moveInWorldFrame(double x, double y, double z, double tx, double ty, double tz); //! Data saving diff --git a/modules/ustk_core/include/visp3/ustk_core/usPixelMeterConversion.h b/modules/ustk_core/include/visp3/ustk_core/usPixelMeterConversion.h index 31c1398d..9714d000 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usPixelMeterConversion.h +++ b/modules/ustk_core/include/visp3/ustk_core/usPixelMeterConversion.h @@ -38,6 +38,7 @@ #ifndef __usPixelMeterConversion_h_ #define __usPixelMeterConversion_h_ +#include #include #include diff --git a/modules/ustk_core/include/visp3/ustk_core/usPolynomialCurve2D.h b/modules/ustk_core/include/visp3/ustk_core/usPolynomialCurve2D.h index 1f5de38b..0bd166ee 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usPolynomialCurve2D.h +++ b/modules/ustk_core/include/visp3/ustk_core/usPolynomialCurve2D.h @@ -37,6 +37,7 @@ #include +#include #include #include @@ -138,52 +139,52 @@ class VISP_EXPORT usPolynomialCurve2D /** * Set the curve polynomial coefficients. */ - void setPolynomialCoefficients(const vpMatrix &polynomialCoefficients); + void setPolynomialCoefficients(const VISP_NAMESPACE_ADDRESSING vpMatrix &polynomialCoefficients); /** * Get the polynomial coefficients. */ - vpMatrix getPolynomialCoefficients() const; + VISP_NAMESPACE_ADDRESSING vpMatrix getPolynomialCoefficients() const; /** * Get the polynomial curve point at a given parametric value. */ - vpColVector getPoint(double parameter) const; + VISP_NAMESPACE_ADDRESSING vpColVector getPoint(double parameter) const; /** * Get the polynomial curve points at given parametric values. */ - vpMatrix getPoints(vpColVector parameters) const; + VISP_NAMESPACE_ADDRESSING vpMatrix getPoints(VISP_NAMESPACE_ADDRESSING vpColVector parameters) const; /** * Get the starting extremity of the polynomial curve. */ - vpColVector getStartPoint() const; + VISP_NAMESPACE_ADDRESSING vpColVector getStartPoint() const; /** * Get the ending extremity of the polynomial curve. */ - vpColVector getEndPoint() const; + VISP_NAMESPACE_ADDRESSING vpColVector getEndPoint() const; /** * Get the tangent vector at a given parametric value. */ - vpColVector getTangent(double parameter) const; + VISP_NAMESPACE_ADDRESSING vpColVector getTangent(double parameter) const; /** * Get the tangent vector at the starting extremity of the polynomial curve. */ - vpColVector getStartTangent() const; + VISP_NAMESPACE_ADDRESSING vpColVector getStartTangent() const; /** * Get the tangent vector at the starting extremity of the polynomial curve. */ - vpColVector getEndTangent() const; + VISP_NAMESPACE_ADDRESSING vpColVector getEndTangent() const; /** * Get the derivative of the polynmial curve at a given parametric value. */ - vpColVector getDerivative(double parameter, unsigned int order) const; + VISP_NAMESPACE_ADDRESSING vpColVector getDerivative(double parameter, unsigned int order) const; /** * Define the polynomial curve to fit as best as possible a set of control points at given parametric values. @@ -193,7 +194,7 @@ class VISP_EXPORT usPolynomialCurve2D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromPoints(const std::vector &points, const std::vector ¶m, + void defineFromPoints(const std::vector &points, const std::vector ¶m, unsigned int order = 0); /** @@ -204,7 +205,7 @@ class VISP_EXPORT usPolynomialCurve2D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromPoints(const vpMatrix points, const vpColVector ¶m, unsigned int order = 0); + void defineFromPoints(const VISP_NAMESPACE_ADDRESSING vpMatrix points, const VISP_NAMESPACE_ADDRESSING vpColVector ¶m, unsigned int order = 0); /** * Define the polynomial curve to fit as best as possible a set of control points. @@ -214,7 +215,7 @@ class VISP_EXPORT usPolynomialCurve2D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromPointsAuto(const std::vector &points, unsigned int order = 0); + void defineFromPointsAuto(const std::vector &points, unsigned int order = 0); /** * Define the polynomial curve to fit as best as possible a set of control points. @@ -224,7 +225,7 @@ class VISP_EXPORT usPolynomialCurve2D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromPointsAuto(const vpMatrix &points, unsigned int order = 0); + void defineFromPointsAuto(const VISP_NAMESPACE_ADDRESSING vpMatrix &points, unsigned int order = 0); /** * Define the polynomial curve to fit as best as possible a set of weighted control points at given parametric values. @@ -236,7 +237,7 @@ class VISP_EXPORT usPolynomialCurve2D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromPointsAuto(const std::vector &points, const vpColVector &direction, + void defineFromPointsAuto(const std::vector &points, const VISP_NAMESPACE_ADDRESSING vpColVector &direction, unsigned int order = 0); /** @@ -249,7 +250,7 @@ class VISP_EXPORT usPolynomialCurve2D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromPointsAuto(const vpMatrix &points, const vpColVector &direction, unsigned int order = 0); + void defineFromPointsAuto(const VISP_NAMESPACE_ADDRESSING vpMatrix &points, const VISP_NAMESPACE_ADDRESSING vpColVector &direction, unsigned int order = 0); /** * Define the polynomial curve to fit as best as possible a set of weighted control points at given parametric values. @@ -260,7 +261,7 @@ class VISP_EXPORT usPolynomialCurve2D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromWeightedPoints(const std::vector &points, const std::vector ¶m, + void defineFromWeightedPoints(const std::vector &points, const std::vector ¶m, const std::vector &weights, unsigned int order = 0); /** @@ -272,7 +273,7 @@ class VISP_EXPORT usPolynomialCurve2D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromWeightedPoints(const vpMatrix &points, const vpColVector ¶m, const vpColVector &weights, + void defineFromWeightedPoints(const VISP_NAMESPACE_ADDRESSING vpMatrix &points, const VISP_NAMESPACE_ADDRESSING vpColVector ¶m, const VISP_NAMESPACE_ADDRESSING vpColVector &weights, unsigned int order = 0); /** @@ -284,7 +285,7 @@ class VISP_EXPORT usPolynomialCurve2D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromWeightedPointsAuto(const std::vector &points, const std::vector &weights, + void defineFromWeightedPointsAuto(const std::vector &points, const std::vector &weights, unsigned int order = 0); /** @@ -296,7 +297,7 @@ class VISP_EXPORT usPolynomialCurve2D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromWeightedPointsAuto(const vpMatrix &points, const vpColVector &weights, unsigned int order = 0); + void defineFromWeightedPointsAuto(const VISP_NAMESPACE_ADDRESSING vpMatrix &points, const VISP_NAMESPACE_ADDRESSING vpColVector &weights, unsigned int order = 0); /** * Define the polynomial curve to fit as best as possible a set of control points at given parametric values. @@ -309,8 +310,8 @@ class VISP_EXPORT usPolynomialCurve2D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromWeightedPointsAuto(const std::vector &points, const std::vector &weights, - const vpColVector &direction, unsigned int order = 0); + void defineFromWeightedPointsAuto(const std::vector &points, const std::vector &weights, + const VISP_NAMESPACE_ADDRESSING vpColVector &direction, unsigned int order = 0); /** * Define the polynomial curve to fit as best as possible a set of control points at given parametric values. @@ -323,7 +324,7 @@ class VISP_EXPORT usPolynomialCurve2D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromWeightedPointsAuto(const vpMatrix &points, const vpColVector &weights, const vpColVector &direction, + void defineFromWeightedPointsAuto(const VISP_NAMESPACE_ADDRESSING vpMatrix &points, const VISP_NAMESPACE_ADDRESSING vpColVector &weights, const VISP_NAMESPACE_ADDRESSING vpColVector &direction, unsigned int order = 0); /** @@ -346,7 +347,7 @@ class VISP_EXPORT usPolynomialCurve2D * * @param controlPoints Reference to the desired control points. */ - void setControlPoints(const vpMatrix &controlPoints); + void setControlPoints(const VISP_NAMESPACE_ADDRESSING vpMatrix &controlPoints); /** * Set the control points. @@ -356,12 +357,12 @@ class VISP_EXPORT usPolynomialCurve2D /** * Get the control points. (to remove) */ - vpMatrix getControlPoints() const; + VISP_NAMESPACE_ADDRESSING vpMatrix getControlPoints() const; /** * Get the rendering points. (to remove) */ - vpMatrix getRenderingPoints() const; + VISP_NAMESPACE_ADDRESSING vpMatrix getRenderingPoints() const; /** * Compute the distance between two curves. (to remove) @@ -417,7 +418,7 @@ class VISP_EXPORT usPolynomialCurve2D unsigned int m_order; // Order of the polynomial curve double m_startParameter; // starting value of the parametric variable double m_endParameter; // ending value of the parametric variable - vpMatrix m_polynomialCoefficients; // coefficients of the polynomial curve + VISP_NAMESPACE_ADDRESSING vpMatrix m_polynomialCoefficients; // coefficients of the polynomial curve }; VISP_EXPORT std::ostream &operator<<(std::ostream &s, const usPolynomialCurve2D &seg); diff --git a/modules/ustk_core/include/visp3/ustk_core/usPolynomialCurve3D.h b/modules/ustk_core/include/visp3/ustk_core/usPolynomialCurve3D.h index 3665ceed..83e3f7c3 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usPolynomialCurve3D.h +++ b/modules/ustk_core/include/visp3/ustk_core/usPolynomialCurve3D.h @@ -35,6 +35,7 @@ #include +#include #include #include #include @@ -137,52 +138,52 @@ class VISP_EXPORT usPolynomialCurve3D /** * Set the curve polynomial coefficients. */ - void setPolynomialCoefficients(const vpMatrix &polynomialCoefficients); + void setPolynomialCoefficients(const VISP_NAMESPACE_ADDRESSING vpMatrix &polynomialCoefficients); /** * Get the polynomial coefficients. */ - vpMatrix getPolynomialCoefficients() const; + VISP_NAMESPACE_ADDRESSING vpMatrix getPolynomialCoefficients() const; /** * Get the polynomial curve point at a given parametric value. */ - vpColVector getPoint(double parameter) const; + VISP_NAMESPACE_ADDRESSING vpColVector getPoint(double parameter) const; /** * Get the polynomial curve points at given parametric values. */ - vpMatrix getPoints(const vpColVector ¶meters) const; + VISP_NAMESPACE_ADDRESSING vpMatrix getPoints(const VISP_NAMESPACE_ADDRESSING vpColVector ¶meters) const; /** * Get the starting extremity of the polynomial curve. */ - vpColVector getStartPoint() const; + VISP_NAMESPACE_ADDRESSING vpColVector getStartPoint() const; /** * Get the ending extremity of the polynomial curve. */ - vpColVector getEndPoint() const; + VISP_NAMESPACE_ADDRESSING vpColVector getEndPoint() const; /** * Get the tangent vector at a given parametric value. */ - vpColVector getTangent(double parameter) const; + VISP_NAMESPACE_ADDRESSING vpColVector getTangent(double parameter) const; /** * Get the tangent vector at the starting extremity of the polynomial curve. */ - vpColVector getStartTangent() const; + VISP_NAMESPACE_ADDRESSING vpColVector getStartTangent() const; /** * Get the tangent vector at the starting extremity of the polynomial curve. */ - vpColVector getEndTangent() const; + VISP_NAMESPACE_ADDRESSING vpColVector getEndTangent() const; /** * Get the derivative of the polynmial curve at a given parametric value. */ - vpColVector getDerivative(double parameter, unsigned int order) const; + VISP_NAMESPACE_ADDRESSING vpColVector getDerivative(double parameter, unsigned int order) const; /** * Define the polynomial curve to fit as best as possible a set of control points at given parametric values. @@ -192,7 +193,7 @@ class VISP_EXPORT usPolynomialCurve3D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromPoints(const std::vector &points, const std::vector ¶m, + void defineFromPoints(const std::vector &points, const std::vector ¶m, unsigned int order = 0); /** @@ -203,7 +204,7 @@ class VISP_EXPORT usPolynomialCurve3D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromPoints(const vpMatrix points, const vpColVector ¶m, unsigned int order = 0); + void defineFromPoints(const VISP_NAMESPACE_ADDRESSING vpMatrix points, const VISP_NAMESPACE_ADDRESSING vpColVector ¶m, unsigned int order = 0); /** * Define the polynomial curve to fit as best as possible a set of control points. @@ -213,7 +214,7 @@ class VISP_EXPORT usPolynomialCurve3D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromPointsAuto(const std::vector &points, unsigned int order = 0); + void defineFromPointsAuto(const std::vector &points, unsigned int order = 0); /** * Define the polynomial curve to fit as best as possible a set of control points. @@ -223,7 +224,7 @@ class VISP_EXPORT usPolynomialCurve3D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromPointsAuto(const vpMatrix &points, unsigned int order = 0); + void defineFromPointsAuto(const VISP_NAMESPACE_ADDRESSING vpMatrix &points, unsigned int order = 0); /** * Define the polynomial curve to fit as best as possible a set of weighted control points at given parametric values. @@ -235,7 +236,7 @@ class VISP_EXPORT usPolynomialCurve3D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromPointsAuto(const std::vector &points, const vpColVector &direction, + void defineFromPointsAuto(const std::vector &points, const VISP_NAMESPACE_ADDRESSING vpColVector &direction, unsigned int order = 0); /** @@ -248,7 +249,7 @@ class VISP_EXPORT usPolynomialCurve3D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromPointsAuto(const vpMatrix &points, const vpColVector &direction, unsigned int order = 0); + void defineFromPointsAuto(const VISP_NAMESPACE_ADDRESSING vpMatrix &points, const VISP_NAMESPACE_ADDRESSING vpColVector &direction, unsigned int order = 0); /** * Define the polynomial curve to fit as best as possible a set of weighted control points at given parametric values. @@ -259,7 +260,7 @@ class VISP_EXPORT usPolynomialCurve3D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromWeightedPoints(const std::vector &points, const std::vector ¶m, + void defineFromWeightedPoints(const std::vector &points, const std::vector ¶m, const std::vector &weights, unsigned int order = 0); /** @@ -271,7 +272,7 @@ class VISP_EXPORT usPolynomialCurve3D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromWeightedPoints(const vpMatrix &points, const vpColVector ¶m, const vpColVector &weights, + void defineFromWeightedPoints(const VISP_NAMESPACE_ADDRESSING vpMatrix &points, const VISP_NAMESPACE_ADDRESSING vpColVector ¶m, const VISP_NAMESPACE_ADDRESSING vpColVector &weights, unsigned int order = 0); /** @@ -283,7 +284,7 @@ class VISP_EXPORT usPolynomialCurve3D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromWeightedPointsAuto(const std::vector &points, const std::vector &weights, + void defineFromWeightedPointsAuto(const std::vector &points, const std::vector &weights, unsigned int order = 0); /** @@ -295,7 +296,7 @@ class VISP_EXPORT usPolynomialCurve3D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromWeightedPointsAuto(const vpMatrix &points, const vpColVector &weights, unsigned int order = 0); + void defineFromWeightedPointsAuto(const VISP_NAMESPACE_ADDRESSING vpMatrix &points, const VISP_NAMESPACE_ADDRESSING vpColVector &weights, unsigned int order = 0); /** * Define the polynomial curve to fit as best as possible a set of control points at given parametric values. @@ -308,8 +309,8 @@ class VISP_EXPORT usPolynomialCurve3D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromWeightedPointsAuto(const std::vector &points, const std::vector &weights, - const vpColVector &direction, unsigned int order = 0); + void defineFromWeightedPointsAuto(const std::vector &points, const std::vector &weights, + const VISP_NAMESPACE_ADDRESSING vpColVector &direction, unsigned int order = 0); /** * Define the polynomial curve to fit as best as possible a set of control points at given parametric values. @@ -322,7 +323,7 @@ class VISP_EXPORT usPolynomialCurve3D * @param order The order of the resulting polynomial curve (keep the current order of the curve if given value is <1 * (default)) */ - void defineFromWeightedPointsAuto(const vpMatrix &points, const vpColVector &weights, const vpColVector &direction, + void defineFromWeightedPointsAuto(const VISP_NAMESPACE_ADDRESSING vpMatrix &points, const VISP_NAMESPACE_ADDRESSING vpColVector &weights, const VISP_NAMESPACE_ADDRESSING vpColVector &direction, unsigned int order = 0); /** @@ -340,7 +341,7 @@ class VISP_EXPORT usPolynomialCurve3D * @param center3D Center of the circle fitting the portion of the curve. * @param direction3D Normal of the circle fitting the portion of the curve. */ - double getCurvatureFromShape(double start, double end, vpColVector ¢er3D, vpColVector &direction3D) const; + double getCurvatureFromShape(double start, double end, VISP_NAMESPACE_ADDRESSING vpColVector ¢er3D, VISP_NAMESPACE_ADDRESSING vpColVector &direction3D) const; /** * Get the mean deviation of the polynomial with respect to the straight axis between the two extremities. @@ -355,7 +356,7 @@ class VISP_EXPORT usPolynomialCurve3D * * @param controlPoints Reference to the desired control points. */ - void setControlPoints(const vpMatrix &controlPoints); + void setControlPoints(const VISP_NAMESPACE_ADDRESSING vpMatrix &controlPoints); /** * Set the control points. @@ -365,12 +366,12 @@ class VISP_EXPORT usPolynomialCurve3D /** * Get the control points. (to remove) */ - vpMatrix getControlPoints() const; + VISP_NAMESPACE_ADDRESSING vpMatrix getControlPoints() const; /** * Get the rendering points. (to remove) */ - vpMatrix getRenderingPoints() const; + VISP_NAMESPACE_ADDRESSING vpMatrix getRenderingPoints() const; /** * Compute the distance between two curves. (to remove) @@ -406,7 +407,7 @@ class VISP_EXPORT usPolynomialCurve3D /** * Apply an homogeneous transformation to the polynomial curve. */ - void move(const vpHomogeneousMatrix &H); + void move(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &H); /** * Apply an homogeneous transformation to the polynomial curve. @@ -431,7 +432,7 @@ class VISP_EXPORT usPolynomialCurve3D unsigned int m_order; // Order of the polynomial curve double m_startParameter; // starting value of the parametric variable double m_endParameter; // ending value of the parametric variable - vpMatrix m_polynomialCoefficients; // coefficients of the polynomial curve + VISP_NAMESPACE_ADDRESSING vpMatrix m_polynomialCoefficients; // coefficients of the polynomial curve }; VISP_EXPORT std::ostream &operator<<(std::ostream &s, const usPolynomialCurve3D &seg); diff --git a/modules/ustk_core/include/visp3/ustk_core/usPostScanToPreScan2DConverter.h b/modules/ustk_core/include/visp3/ustk_core/usPostScanToPreScan2DConverter.h index 8f98f2f4..b12c531c 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usPostScanToPreScan2DConverter.h +++ b/modules/ustk_core/include/visp3/ustk_core/usPostScanToPreScan2DConverter.h @@ -38,6 +38,7 @@ #ifndef __usPostScanToPreScan2DConverter_h_ #define __usPostScanToPreScan2DConverter_h_ +#include #include #include @@ -110,8 +111,8 @@ class VISP_EXPORT usPostScanToPreScan2DConverter const double xResolution, const double yResolution); private: - vpMatrix m_iMap; - vpMatrix m_jMap; + VISP_NAMESPACE_ADDRESSING vpMatrix m_iMap; + VISP_NAMESPACE_ADDRESSING vpMatrix m_jMap; double m_xResolution; double m_yResolution; int m_scanLineNumber; @@ -120,7 +121,7 @@ class VISP_EXPORT usPostScanToPreScan2DConverter bool m_isInit; - double interpolateLinear(const vpImage &I, double x, double y); + double interpolateLinear(const VISP_NAMESPACE_ADDRESSING vpImage &I, double x, double y); }; #endif // __usPostScanToPreScan2DConverter_h_ diff --git a/modules/ustk_core/include/visp3/ustk_core/usPreScanToPostScan2DConverter.h b/modules/ustk_core/include/visp3/ustk_core/usPreScanToPostScan2DConverter.h index 92e0bf87..c8e4558a 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usPreScanToPostScan2DConverter.h +++ b/modules/ustk_core/include/visp3/ustk_core/usPreScanToPostScan2DConverter.h @@ -38,6 +38,7 @@ #ifndef __usPreScanToPostScan2DConverter_h_ #define __usPreScanToPostScan2DConverter_h_ +#include #include #include #include @@ -109,10 +110,10 @@ class VISP_EXPORT usPreScanToPostScan2DConverter const double xResolution, const double yResolution); private: - double interpolateLinear(const vpImage &I, double x, double y); + double interpolateLinear(const VISP_NAMESPACE_ADDRESSING vpImage &I, double x, double y); - vpMatrix m_rMap; - vpMatrix m_tMap; + VISP_NAMESPACE_ADDRESSING vpMatrix m_rMap; + VISP_NAMESPACE_ADDRESSING vpMatrix m_tMap; double m_xResolution; double m_yResolution; diff --git a/modules/ustk_core/include/visp3/ustk_core/usRawFileParser.h b/modules/ustk_core/include/visp3/ustk_core/usRawFileParser.h index 0e888a2a..daaa9311 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usRawFileParser.h +++ b/modules/ustk_core/include/visp3/ustk_core/usRawFileParser.h @@ -63,8 +63,8 @@ class VISP_EXPORT usRawFileParser public: /** @name 2D io */ //@{ - void read(vpImage &image2D, const std::string &mhdFileName); - void write(const vpImage &image2D, const std::string &rawFileName); + void read(VISP_NAMESPACE_ADDRESSING vpImage &image2D, const std::string &mhdFileName); + void write(const VISP_NAMESPACE_ADDRESSING vpImage &image2D, const std::string &rawFileName); void read(usImageRF2D &image2D, const std::string &mhdFileName); void write(const usImageRF2D &image2D, const std::string &rawFileName); //@} diff --git a/modules/ustk_core/include/visp3/ustk_core/usRfReader.h b/modules/ustk_core/include/visp3/ustk_core/usRfReader.h index 38c87ae4..ac46a1aa 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usRfReader.h +++ b/modules/ustk_core/include/visp3/ustk_core/usRfReader.h @@ -46,6 +46,7 @@ #include #include +#include #include #include diff --git a/modules/ustk_core/include/visp3/ustk_core/usSequenceReader.h b/modules/ustk_core/include/visp3/ustk_core/usSequenceReader.h index 314789d7..26a83658 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usSequenceReader.h +++ b/modules/ustk_core/include/visp3/ustk_core/usSequenceReader.h @@ -227,6 +227,10 @@ template void usSequenceReader::setLastFrameIndex(l */ template void usSequenceReader::open(ImageType &image) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + (void)image; throw(vpException(vpException::notImplementedError)); } @@ -238,6 +242,10 @@ template void usSequenceReader::open(ImageType &ima */ template void usSequenceReader::open(ImageType &image, uint64_t ×tamp) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + (void)image; (void)timestamp; throw(vpException(vpException::notImplementedError)); @@ -245,6 +253,10 @@ template void usSequenceReader::open(ImageType &ima template <> inline void usSequenceReader >::open(usImagePreScan2D &image) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!m_fileNameIsSet) { throw(vpException(vpException::badValue, "Sequence settings file name not set")); } @@ -338,6 +350,10 @@ template <> inline void usSequenceReader >::open(usImagePreScan2D &image, uint64_t ×tamp) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!m_fileNameIsSet) { throw(vpException(vpException::badValue, "Sequence settings file name not set")); } @@ -435,6 +451,10 @@ inline void usSequenceReader >::open(usImagePreS template <> inline void usSequenceReader >::open(usImagePostScan2D &image) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!m_fileNameIsSet) { throw(vpException(vpException::badValue, "Sequence settings file name not set")); } @@ -534,6 +554,10 @@ template <> inline void usSequenceReader >::open(usImagePostScan2D &image, uint64_t ×tamp) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!m_fileNameIsSet) { throw(vpException(vpException::badValue, "Sequence settings file name not set")); } @@ -638,6 +662,10 @@ inline void usSequenceReader >::open(usImagePos */ template void usSequenceReader::acquire(ImageType &image) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!is_open) { this->open(image); return; @@ -703,6 +731,10 @@ template void usSequenceReader::acquire(ImageType & */ template void usSequenceReader::acquire(ImageType &image, uint64_t ×tamp) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!is_open) { this->open(image, timestamp); return; @@ -772,6 +804,10 @@ template void usSequenceReader::acquire(ImageType & template <> inline void usSequenceReader >::acquire(usImagePreScan2D &image) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!is_open) { this->open(image); return; @@ -842,6 +878,10 @@ template <> inline void usSequenceReader >::acquire(usImagePreScan2D &image, uint64_t ×tamp) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!is_open) { this->open(image, timestamp); return; @@ -913,6 +953,10 @@ inline void usSequenceReader >::acquire(usImageP */ template void usSequenceReader::getFrame(ImageType &image, int index) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!is_open) { open(image); return; @@ -957,6 +1001,10 @@ template void usSequenceReader::setLoopCycling(bool */ template long usSequenceReader::getFrameCount() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (is_open) return m_lastFrame - m_firstFrame + 1; throw(vpException(vpException::fatalError, "Cannot compute the frame number of the sequence before opening it !")); @@ -968,6 +1016,9 @@ template long usSequenceReader::getFrameCount() */ template usImageSettingsXmlParser usSequenceReader::getXmlParser() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif if (is_open) return m_xmlParser; throw(vpException(vpException::fatalError, "Sequence not opened, xml parser is empty !")); diff --git a/modules/ustk_core/include/visp3/ustk_core/usSequenceReader3D.h b/modules/ustk_core/include/visp3/ustk_core/usSequenceReader3D.h index e0225289..2ea9be56 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usSequenceReader3D.h +++ b/modules/ustk_core/include/visp3/ustk_core/usSequenceReader3D.h @@ -45,6 +45,7 @@ #include #include +#include #include #include @@ -124,13 +125,12 @@ template class usSequenceReader3D template usSequenceReader3D::usSequenceReader3D() : m_frameCount(0), m_fileName(""), m_fileNameIsSet(false), is_open(false), m_volHeader() -{ -} +{ } /** * Destructor. */ -template usSequenceReader3D::~usSequenceReader3D() {} +template usSequenceReader3D::~usSequenceReader3D() { } /** * FileName setter. @@ -148,6 +148,10 @@ template void usSequenceReader3D::setSequenceFileNa */ template void usSequenceReader3D::open(ImageType &image) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + (void)image; throw(vpException(vpException::notImplementedError)); } @@ -189,6 +193,10 @@ void usSequenceReader3D >::open(usImageRF2D &image) template <> void usSequenceReader3D >::open(usImagePreScan3D &image) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!m_fileNameIsSet) { throw(vpException(vpException::badValue, "Sequence file name not set")); } @@ -241,6 +249,10 @@ template <> void usSequenceReader3D >::open(usIm template <> void usSequenceReader3D >::open(usImagePostScan3D &image) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!m_fileNameIsSet) { throw(vpException(vpException::badValue, "Sequence file name not set")); } @@ -354,6 +366,10 @@ template <> void usSequenceReader3D >::getVolume(usImagePreScan3D &preScanImage, int volumeNumberInSequence) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!is_open) { this->open(preScanImage); return; diff --git a/modules/ustk_core/include/visp3/ustk_core/usSequenceWriter.h b/modules/ustk_core/include/visp3/ustk_core/usSequenceWriter.h index 706cf544..521683d0 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usSequenceWriter.h +++ b/modules/ustk_core/include/visp3/ustk_core/usSequenceWriter.h @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -151,6 +152,10 @@ template void usSequenceWriter::setSequenceFileName */ template void usSequenceWriter::setImageFileName(const std::string &imageFileName) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + // create subdirectory if there is one if (m_headerFileNameIsSet) { std::string relativePathToHeader = vpIoTools::getParent(imageFileName); @@ -179,6 +184,10 @@ template void usSequenceWriter::setFirstFrameIndex( */ template void usSequenceWriter::open(const ImageType &image, uint64_t timestamp) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!m_headerFileNameIsSet || !m_imageFileNameIsSet) throw(vpException(vpException::badValue, "file names not set")); @@ -223,11 +232,18 @@ template void usSequenceWriter::open(const ImageTyp */ template void usSequenceWriter::close() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif throw(vpException(vpException::notImplementedError)); } template <> inline void usSequenceWriter >::close() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!is_open) return; @@ -246,6 +262,10 @@ template <> inline void usSequenceWriter >::close() template <> inline void usSequenceWriter >::close() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!is_open) return; @@ -265,6 +285,10 @@ template <> inline void usSequenceWriter >::clos template <> inline void usSequenceWriter >::close() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!is_open) return; @@ -290,6 +314,10 @@ template <> inline void usSequenceWriter >::clo */ template void usSequenceWriter::saveImage(const ImageType &image, uint64_t timestamp) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + if (!is_open) { open(image, timestamp); return; // first image has been written by open(); diff --git a/modules/ustk_core/include/visp3/ustk_core/usTransducerSettings.h b/modules/ustk_core/include/visp3/ustk_core/usTransducerSettings.h index 7b348678..72e88cd7 100644 --- a/modules/ustk_core/include/visp3/ustk_core/usTransducerSettings.h +++ b/modules/ustk_core/include/visp3/ustk_core/usTransducerSettings.h @@ -45,6 +45,7 @@ // visp includes #include +#include #include // ustk includes diff --git a/modules/ustk_core/src/RFConversion/usLogCompressor.cpp b/modules/ustk_core/src/RFConversion/usLogCompressor.cpp index 856d47fd..25c00d9f 100644 --- a/modules/ustk_core/src/RFConversion/usLogCompressor.cpp +++ b/modules/ustk_core/src/RFConversion/usLogCompressor.cpp @@ -36,6 +36,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. */ diff --git a/modules/ustk_core/src/RFConversion/usRFToPostScan2DConverter.cpp b/modules/ustk_core/src/RFConversion/usRFToPostScan2DConverter.cpp index f1cd2bdb..47349355 100644 --- a/modules/ustk_core/src/RFConversion/usRFToPostScan2DConverter.cpp +++ b/modules/ustk_core/src/RFConversion/usRFToPostScan2DConverter.cpp @@ -40,19 +40,22 @@ #if defined(USTK_HAVE_FFTW) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. * @param decimationFactor Decimation factor : keep only 1 pre-scan sample every N sample (N = decimationFactor) */ usRFToPostScan2DConverter::usRFToPostScan2DConverter(int decimationFactor) : m_RFConverter(decimationFactor), m_scanConverter() -{ -} +{ } /** * Destructor. */ -usRFToPostScan2DConverter::~usRFToPostScan2DConverter() {} +usRFToPostScan2DConverter::~usRFToPostScan2DConverter() { } /** * Convert method : performs the conversion from RF frame to a post-scan frame using the following processes : diff --git a/modules/ustk_core/src/RFConversion/usRFToPostScan3DConverter.cpp b/modules/ustk_core/src/RFConversion/usRFToPostScan3DConverter.cpp index 04b68110..169036ac 100644 --- a/modules/ustk_core/src/RFConversion/usRFToPostScan3DConverter.cpp +++ b/modules/ustk_core/src/RFConversion/usRFToPostScan3DConverter.cpp @@ -39,6 +39,10 @@ #if defined(USTK_HAVE_FFTW) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. * @param decimationFactor Decimation factor for RF conversion (keeping 1 RF sample every decimationFactor samples) @@ -52,7 +56,7 @@ usRFToPostScan3DConverter::usRFToPostScan3DConverter(int decimationFactor) /** * Destructor. */ -usRFToPostScan3DConverter::~usRFToPostScan3DConverter() {} +usRFToPostScan3DConverter::~usRFToPostScan3DConverter() { } /** * Convert method : performs the conversion from RF frame to a post-scan volume. diff --git a/modules/ustk_core/src/RFConversion/usRFToPreScan2DConverter.cpp b/modules/ustk_core/src/RFConversion/usRFToPreScan2DConverter.cpp index 3f4d5864..6b11f509 100644 --- a/modules/ustk_core/src/RFConversion/usRFToPreScan2DConverter.cpp +++ b/modules/ustk_core/src/RFConversion/usRFToPreScan2DConverter.cpp @@ -40,14 +40,17 @@ #if defined(USTK_HAVE_FFTW) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. * @param decimationFactor Decimation factor : keep only 1 pre-scan sample every N sample (N = decimationFactor) */ usRFToPreScan2DConverter::usRFToPreScan2DConverter(int decimationFactor) : m_logCompressor(), m_decimationFactor(decimationFactor), m_isInit(false) -{ -} +{ } /** * Destructor. @@ -82,7 +85,8 @@ void usRFToPreScan2DConverter::init(int widthRF, int heigthRF) fftw_destroy_plan(m_pinv); delete m_env; delete m_comp; - } else if (m_signalSize == heigthRF && m_scanLineNumber == heigthRF) + } + else if (m_signalSize == heigthRF && m_scanLineNumber == heigthRF) return; // for FFT @@ -132,7 +136,8 @@ void usRFToPreScan2DConverter::enveloppeDetection(const short int *s, double *ou else if (i == N / 2) { m_fft_out[i][0] = 0; m_fft_out[i][1] = 0; - } else if (i > N / 2) + } + else if (i > N / 2) m_fft_out[i][0] = -m_fft_out[i][0]; if (i == 0) { m_fft_out[i][0] = 0; diff --git a/modules/ustk_core/src/RFConversion/usRFToPreScan3DConverter.cpp b/modules/ustk_core/src/RFConversion/usRFToPreScan3DConverter.cpp index bdda4ce8..34df3f54 100644 --- a/modules/ustk_core/src/RFConversion/usRFToPreScan3DConverter.cpp +++ b/modules/ustk_core/src/RFConversion/usRFToPreScan3DConverter.cpp @@ -44,15 +44,19 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. */ -usRFToPreScan3DConverter::usRFToPreScan3DConverter() : m_frameNumber(), m_isInit(false), m_decimationFactor(10) {} +usRFToPreScan3DConverter::usRFToPreScan3DConverter() : m_frameNumber(), m_isInit(false), m_decimationFactor(10) { } /** * Destructor. */ -usRFToPreScan3DConverter::~usRFToPreScan3DConverter() {} +usRFToPreScan3DConverter::~usRFToPreScan3DConverter() { } /** * Convert method : performs the conversion from RF frame to a pre-scan frame using the following processes : diff --git a/modules/ustk_core/src/geometry/usBSpline3D.cpp b/modules/ustk_core/src/geometry/usBSpline3D.cpp index aae45264..c5d65027 100644 --- a/modules/ustk_core/src/geometry/usBSpline3D.cpp +++ b/modules/ustk_core/src/geometry/usBSpline3D.cpp @@ -42,11 +42,15 @@ #include -usBSpline3D::usBSpline3D() {} +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + +usBSpline3D::usBSpline3D() { } -usBSpline3D::usBSpline3D(const usBSpline3D &spline) : m_spline(spline.m_spline) {} +usBSpline3D::usBSpline3D(const usBSpline3D &spline) : m_spline(spline.m_spline) { } -usBSpline3D::~usBSpline3D() {} +usBSpline3D::~usBSpline3D() { } const usBSpline3D &usBSpline3D::operator=(const usBSpline3D &spline) { @@ -235,7 +239,8 @@ void usBSpline3D::defineFromPoints(const std::vector &points, const solver.compute(M); A = solver.solve(B); - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::fatalError, "usBSpline3D::defineFromPoints: %s\n", e.what()); } @@ -254,7 +259,7 @@ void usBSpline3D::defineFromPoints(const std::vector &points, const // seg.setMaxCurvilinearCoordinate(seg.getLength()); m_spline.push_back(seg); startIndex += nbSegCoef; - } +} #else @@ -370,7 +375,8 @@ void usBSpline3D::defineFromPoints(const std::vector &points, const try { A = M.inverseByLU() * B; - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::fatalError, "usBSpline3D::defineFromPoints: %s\n", e.what()); } @@ -425,7 +431,8 @@ usBSpline3D usBSpline3D::getSubSpline(double a, double b) const tb = ta + b - t; p = m_spline.at(i).getSubPolynomialCurve(ta, tb); ta = tb; - } else { + } + else { tb = m_spline.at(i).getParametricLength(); p = m_spline.at(i).getSubPolynomialCurve(ta, tb); ta = 0; @@ -437,7 +444,8 @@ usBSpline3D usBSpline3D::getSubSpline(double a, double b) const t += p.getParametricLength(); } - } else + } + else s = *this; return s; @@ -658,7 +666,8 @@ double usBSpline3D::getCurvatureFromShape(double start, double end, vpColVector if (direction3D.size() == 3) { direction3D = V.getCol(2); - } else if (direction3D.size() == 4) { + } + else if (direction3D.size() == 4) { direction3D.insert(0, V.getCol(2)); direction3D[3] = 0; } @@ -666,7 +675,8 @@ double usBSpline3D::getCurvatureFromShape(double start, double end, vpColVector if (center3D.size() == 3) { V.resize(3, 2, false); center3D = V * center; - } else if (center3D.size() == 4) { + } + else if (center3D.size() == 4) { V.resize(3, 2, false); center3D.insert(0, V * center + mean.t()); center3D[3] = 1; diff --git a/modules/ustk_core/src/geometry/usGeometryDisplayTools.cpp b/modules/ustk_core/src/geometry/usGeometryDisplayTools.cpp index 8472f9db..f4a7a1a2 100644 --- a/modules/ustk_core/src/geometry/usGeometryDisplayTools.cpp +++ b/modules/ustk_core/src/geometry/usGeometryDisplayTools.cpp @@ -37,6 +37,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace usGeometryDisplayTools { diff --git a/modules/ustk_core/src/geometry/usGeometryTools.cpp b/modules/ustk_core/src/geometry/usGeometryTools.cpp index 8108d478..bd0885d6 100644 --- a/modules/ustk_core/src/geometry/usGeometryTools.cpp +++ b/modules/ustk_core/src/geometry/usGeometryTools.cpp @@ -39,6 +39,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + namespace usGeometryTools { @@ -110,7 +114,8 @@ vpColVector getPlaneCurveCrossingPoint(const usPolynomialCurve3D &poly, const us if (sideMid == sideStart) { start = mid; Pstart = Pmid; - } else if (sideMid == sideEnd) { + } + else if (sideMid == sideEnd) { end = mid; Pend = Pmid; } @@ -161,7 +166,8 @@ vpColVector getPlaneCurveCrossingPoint(const usBSpline3D &spline, const usOrient if (sideMid == sideStart) { start = mid; Pstart = Pmid; - } else if (sideMid == sideEnd) { + } + else if (sideMid == sideEnd) { end = mid; Pend = Pmid; } @@ -179,7 +185,8 @@ vpColVector getPlaneCurveCrossingPoint(const usBSpline3D &spline, const usOrient if (seg >= N) { throw vpException(vpException::badValue, "usGeometryTools::getPlaneCurveCrossingPoint(usBSpline3D): spline and plane do not cross"); - } else { + } + else { double t1 = -1; vpColVector P = getPlaneCurveCrossingPoint(spline.accessSegment(seg), plane, threshold, &t1); if (t) @@ -194,13 +201,15 @@ vpColVector projectPointOnPlane(const vpColVector &point, const usOrientedPlane3 vpColVector d(plane.getDirection()); if (direction.getCols() != 3) { return (point - vpColVector::dotProd(point - p, d) * d); - } else { + } + else { vpColVector dp = direction; dp.normalize(); double cos_theta = vpColVector::dotProd(dp, d); if (fabs(cos_theta) < std::numeric_limits::epsilon()) { return (point - vpColVector::dotProd(point - p, d) * d); - } else { + } + else { return (point - vpColVector::dotProd(point - p, d) / cos_theta * dp); } } @@ -270,7 +279,8 @@ vpColVector projectPointOnCurve(const vpColVector &point, const usBSpline3D &spl if (index) *index = seg; return projectPointOnCurve(point, spline.accessSegment(seg), threshold, t); - } else { + } + else { double t1; double t2; vpColVector P1 = projectPointOnCurve(point, spline.accessSegment(seg - 1), threshold, &t1); @@ -280,7 +290,8 @@ vpColVector projectPointOnCurve(const vpColVector &point, const usBSpline3D &spl if (t) *t = t1; return P1; - } else { + } + else { if (t) *t = t2; return P2; @@ -470,7 +481,8 @@ vpPoseVector ICPPointCloudRelativePose(std::vector &P1, std::vector if (initialGuess) { T = initialGuess->getTranslationVector(); R = initialGuess->getRotationMatrix(); - } else { + } + else { vpColVector meanP1(3, 0); for (unsigned int i = 0; i < P1.size(); i++) meanP1 += P1[i]; diff --git a/modules/ustk_core/src/geometry/usOrientedPlane3D.cpp b/modules/ustk_core/src/geometry/usOrientedPlane3D.cpp index f925b973..a65a301b 100644 --- a/modules/ustk_core/src/geometry/usOrientedPlane3D.cpp +++ b/modules/ustk_core/src/geometry/usOrientedPlane3D.cpp @@ -36,12 +36,15 @@ #include #include -usOrientedPlane3D::usOrientedPlane3D() : m_direction(3, 0), m_pose(0, 0, 0, 0, 0, 0) {} +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + +usOrientedPlane3D::usOrientedPlane3D() : m_direction(3, 0), m_pose(0, 0, 0, 0, 0, 0) { } usOrientedPlane3D::usOrientedPlane3D(const usOrientedPlane3D &plane) : m_direction(plane.m_direction), m_pose(plane.m_pose) -{ -} +{ } usOrientedPlane3D::usOrientedPlane3D(const vpPoseVector &pose) : m_direction(3, 0), m_pose(pose) { } @@ -51,7 +54,7 @@ usOrientedPlane3D::usOrientedPlane3D(const vpColVector &p, const vpColVector &d) this->setDirection(d); } -usOrientedPlane3D::~usOrientedPlane3D() {} +usOrientedPlane3D::~usOrientedPlane3D() { } const usOrientedPlane3D &usOrientedPlane3D::operator=(const usOrientedPlane3D &plane) { @@ -106,7 +109,8 @@ void usOrientedPlane3D::setDirection(const vpColVector &D) m_pose[3 + i] = tu[i]; m_direction = D; m_direction.normalize(); - } else { + } + else { m_direction = 0; for (int i = 3; i < 6; i++) m_pose[i] = 0; diff --git a/modules/ustk_core/src/geometry/usPolynomialCurve2D.cpp b/modules/ustk_core/src/geometry/usPolynomialCurve2D.cpp index 621217f9..d193dfeb 100644 --- a/modules/ustk_core/src/geometry/usPolynomialCurve2D.cpp +++ b/modules/ustk_core/src/geometry/usPolynomialCurve2D.cpp @@ -37,16 +37,18 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + usPolynomialCurve2D::usPolynomialCurve2D() : m_order(0), m_startParameter(0), m_endParameter(1), m_polynomialCoefficients(2, 1, 0) -{ -} +{ } usPolynomialCurve2D::usPolynomialCurve2D(const usPolynomialCurve2D &curve) : m_order(curve.m_order), m_startParameter(curve.m_startParameter), m_endParameter(curve.m_endParameter), - m_polynomialCoefficients(curve.m_polynomialCoefficients) -{ -} + m_polynomialCoefficients(curve.m_polynomialCoefficients) +{ } const usPolynomialCurve2D &usPolynomialCurve2D::operator=(const usPolynomialCurve2D &curve) { @@ -58,12 +60,11 @@ const usPolynomialCurve2D &usPolynomialCurve2D::operator=(const usPolynomialCurv return *this; } -usPolynomialCurve2D::~usPolynomialCurve2D() {} +usPolynomialCurve2D::~usPolynomialCurve2D() { } usPolynomialCurve2D::usPolynomialCurve2D(unsigned int order) : m_order(order), m_startParameter(0), m_endParameter(1), m_polynomialCoefficients(2, m_order + 1, 0) -{ -} +{ } void usPolynomialCurve2D::setOrder(unsigned int order) { @@ -73,8 +74,9 @@ void usPolynomialCurve2D::setOrder(unsigned int order) // Keep same polynomial m_order = order; m_polynomialCoefficients.resize(2, order + 1, false); - } else { - // Find polynomial to have the same properties at the extremities (position, direction, curvature, ...) + } + else { + // Find polynomial to have the same properties at the extremities (position, direction, curvature, ...) int nb_coef = order + 1; int nb_constraints_begin = nb_coef / 2 + nb_coef % 2; int nb_constraints_end = nb_coef / 2; @@ -149,7 +151,8 @@ void usPolynomialCurve2D::setBoundaries(double startParameter, double endParamet if (startParameter <= endParameter) { m_startParameter = startParameter; m_endParameter = endParameter; - } else { + } + else { m_startParameter = endParameter; m_endParameter = startParameter; this->reverse(); @@ -325,7 +328,8 @@ void usPolynomialCurve2D::defineFromPoints(const std::vector &point A = M.pseudoInverse(std::numeric_limits::epsilon()) * B; else A = M.inverseByCholeskyLapack() * B; - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::fatalError, "usPolynomialCurve2D::defineFromPoints(const std::vector " "&points, const std::vector ¶m, unsigned int order): %s", e.what()); @@ -383,7 +387,8 @@ void usPolynomialCurve2D::defineFromPoints(const vpMatrix points, const vpColVec A = M.pseudoInverse(std::numeric_limits::epsilon()) * B; else A = M.inverseByCholeskyLapack() * B; - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::fatalError, "usPolynomialCurve2D::defineFromPoints(const std::vector " "&points, const std::vector ¶m, unsigned int order): %s", e.what()); @@ -537,7 +542,7 @@ void usPolynomialCurve2D::defineFromPointsAuto(const vpMatrix &points, const vpC for (unsigned int j = 0; j < 2; j++) newPoints[j][i] = points[j][index[i]]; interLength[i - 1] = - sqrt(vpMath::sqr(newPoints[0][i] - newPoints[0][i - 1]) + vpMath::sqr(newPoints[1][i] - newPoints[1][i - 1])); + sqrt(vpMath::sqr(newPoints[0][i] - newPoints[0][i - 1]) + vpMath::sqr(newPoints[1][i] - newPoints[1][i - 1])); newLength += interLength[i - 1]; } double scaling = oldLength / newLength; @@ -602,7 +607,8 @@ void usPolynomialCurve2D::defineFromWeightedPoints(const std::vector::epsilon()) * B; - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::fatalError, "usPolynomialCurve2D::defineFromWeightedPoints(const vpMatrix &points, " "const vpColVector ¶m, const vpColVector &weights, unsigned int " "order): %s", @@ -663,7 +669,8 @@ void usPolynomialCurve2D::defineFromWeightedPoints(const vpMatrix &points, const vpMatrix A; try { A = M.pseudoInverse(std::numeric_limits::epsilon()) * B; - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::fatalError, "usPolynomialCurve2D::defineFromWeightedPoints(const vpMatrix &points, " "const vpColVector ¶m, const vpColVector &weights, unsigned int " "order): %s", @@ -808,7 +815,7 @@ void usPolynomialCurve2D::defineFromWeightedPointsAuto(const vpMatrix &points, c newPoints[j][i] = points[j][index[i]]; newWeights[i] = weights[index[i]]; interLength[i - 1] = - sqrt(vpMath::sqr(newPoints[0][i] - newPoints[0][i - 1]) + vpMath::sqr(newPoints[1][i] - newPoints[1][i - 1])); + sqrt(vpMath::sqr(newPoints[0][i] - newPoints[0][i - 1]) + vpMath::sqr(newPoints[1][i] - newPoints[1][i - 1])); newLength += interLength[i - 1]; } double scaling = oldLength / newLength; @@ -925,7 +932,7 @@ void usPolynomialCurve2D::defineFromWeightedPointsAuto(const vpMatrix &points, c newPoints[j][i] = points[j][index[i]]; newWeights[i] = weights[index[i]]; interLength[i - 1] = - sqrt(vpMath::sqr(newPoints[0][i] - newPoints[0][i - 1]) + vpMath::sqr(newPoints[1][i] - newPoints[1][i - 1])); + sqrt(vpMath::sqr(newPoints[0][i] - newPoints[0][i - 1]) + vpMath::sqr(newPoints[1][i] - newPoints[1][i - 1])); newLength += interLength[i - 1]; } double scaling = oldLength / newLength; diff --git a/modules/ustk_core/src/geometry/usPolynomialCurve3D.cpp b/modules/ustk_core/src/geometry/usPolynomialCurve3D.cpp index 1b69d2e4..88f86cca 100644 --- a/modules/ustk_core/src/geometry/usPolynomialCurve3D.cpp +++ b/modules/ustk_core/src/geometry/usPolynomialCurve3D.cpp @@ -36,16 +36,18 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + usPolynomialCurve3D::usPolynomialCurve3D() : m_order(0), m_startParameter(0), m_endParameter(1), m_polynomialCoefficients(3, 1, 0) -{ -} +{ } usPolynomialCurve3D::usPolynomialCurve3D(const usPolynomialCurve3D &curve) : m_order(curve.m_order), m_startParameter(curve.m_startParameter), m_endParameter(curve.m_endParameter), - m_polynomialCoefficients(curve.m_polynomialCoefficients) -{ -} + m_polynomialCoefficients(curve.m_polynomialCoefficients) +{ } const usPolynomialCurve3D &usPolynomialCurve3D::operator=(const usPolynomialCurve3D &curve) { @@ -57,12 +59,11 @@ const usPolynomialCurve3D &usPolynomialCurve3D::operator=(const usPolynomialCurv return *this; } -usPolynomialCurve3D::~usPolynomialCurve3D() {} +usPolynomialCurve3D::~usPolynomialCurve3D() { } usPolynomialCurve3D::usPolynomialCurve3D(unsigned int order) : m_order(order), m_startParameter(0), m_endParameter(1), m_polynomialCoefficients(3, m_order + 1, 0) -{ -} +{ } void usPolynomialCurve3D::setOrder(unsigned int order) { @@ -72,8 +73,9 @@ void usPolynomialCurve3D::setOrder(unsigned int order) // Keep same polynomial m_order = order; m_polynomialCoefficients.resize(3, order + 1, false); - } else { - // Find polynomial to have the same properties at the extremities (position, direction, curvature, ...) + } + else { + // Find polynomial to have the same properties at the extremities (position, direction, curvature, ...) int nb_coef = order + 1; int nb_constraints_begin = nb_coef / 2 + nb_coef % 2; int nb_constraints_end = nb_coef / 2; @@ -148,7 +150,8 @@ void usPolynomialCurve3D::setBoundaries(double startParameter, double endParamet if (startParameter <= endParameter) { m_startParameter = startParameter; m_endParameter = endParameter; - } else { + } + else { m_startParameter = endParameter; m_endParameter = startParameter; this->reverse(); @@ -324,7 +327,8 @@ void usPolynomialCurve3D::defineFromPoints(const std::vector &point A = M.pseudoInverse(std::numeric_limits::epsilon()) * B; else A = M.inverseByCholeskyLapack() * B; - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::fatalError, "usPolynomialCurve3D::defineFromPoints(const std::vector " "&points, const std::vector ¶m, unsigned int order): %s", e.what()); @@ -382,7 +386,8 @@ void usPolynomialCurve3D::defineFromPoints(const vpMatrix points, const vpColVec A = M.pseudoInverse(std::numeric_limits::epsilon()) * B; else A = M.inverseByCholeskyLapack() * B; - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::fatalError, "usPolynomialCurve3D::defineFromPoints(const std::vector " "&points, const std::vector ¶m, unsigned int order): %s", e.what()); @@ -537,8 +542,8 @@ void usPolynomialCurve3D::defineFromPointsAuto(const vpMatrix &points, const vpC for (unsigned int j = 0; j < 3; j++) newPoints[j][i] = points[j][index[i]]; interLength[i - 1] = - sqrt(vpMath::sqr(newPoints[0][i] - newPoints[0][i - 1]) + vpMath::sqr(newPoints[1][i] - newPoints[1][i - 1]) + - vpMath::sqr(newPoints[2][i] - newPoints[2][i - 1])); + sqrt(vpMath::sqr(newPoints[0][i] - newPoints[0][i - 1]) + vpMath::sqr(newPoints[1][i] - newPoints[1][i - 1]) + + vpMath::sqr(newPoints[2][i] - newPoints[2][i - 1])); newLength += interLength[i - 1]; } double scaling = oldLength / newLength; @@ -603,7 +608,8 @@ void usPolynomialCurve3D::defineFromWeightedPoints(const std::vector::epsilon()) * B; - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::fatalError, "usPolynomialCurve3D::defineFromWeightedPoints(const vpMatrix &points, " "const vpColVector ¶m, const vpColVector &weights, unsigned int " "order): %s", @@ -664,7 +670,8 @@ void usPolynomialCurve3D::defineFromWeightedPoints(const vpMatrix &points, const vpMatrix A; try { A = M.pseudoInverse(std::numeric_limits::epsilon()) * B; - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::fatalError, "usPolynomialCurve3D::defineFromWeightedPoints(const vpMatrix &points, " "const vpColVector ¶m, const vpColVector &weights, unsigned int " "order): %s", @@ -810,8 +817,8 @@ void usPolynomialCurve3D::defineFromWeightedPointsAuto(const vpMatrix &points, c newPoints[j][i] = points[j][index[i]]; newWeights[i] = weights[index[i]]; interLength[i - 1] = - sqrt(vpMath::sqr(newPoints[0][i] - newPoints[0][i - 1]) + vpMath::sqr(newPoints[1][i] - newPoints[1][i - 1]) + - vpMath::sqr(newPoints[2][i] - newPoints[2][i - 1])); + sqrt(vpMath::sqr(newPoints[0][i] - newPoints[0][i - 1]) + vpMath::sqr(newPoints[1][i] - newPoints[1][i - 1]) + + vpMath::sqr(newPoints[2][i] - newPoints[2][i - 1])); newLength += interLength[i - 1]; } double scaling = oldLength / newLength; @@ -929,8 +936,8 @@ void usPolynomialCurve3D::defineFromWeightedPointsAuto(const vpMatrix &points, c newPoints[j][i] = points[j][index[i]]; newWeights[i] = weights[index[i]]; interLength[i - 1] = - sqrt(vpMath::sqr(newPoints[0][i] - newPoints[0][i - 1]) + vpMath::sqr(newPoints[1][i] - newPoints[1][i - 1]) + - vpMath::sqr(newPoints[2][i] - newPoints[2][i - 1])); + sqrt(vpMath::sqr(newPoints[0][i] - newPoints[0][i - 1]) + vpMath::sqr(newPoints[1][i] - newPoints[1][i - 1]) + + vpMath::sqr(newPoints[2][i] - newPoints[2][i - 1])); newLength += interLength[i - 1]; } double scaling = oldLength / newLength; @@ -1038,7 +1045,8 @@ double usPolynomialCurve3D::getCurvatureFromShape(double start, double end, vpCo if (direction3D.size() == 3) { direction3D = V.getCol(2); - } else if (direction3D.size() == 4) { + } + else if (direction3D.size() == 4) { direction3D.insert(0, V.getCol(2)); direction3D[3] = 0; } @@ -1046,7 +1054,8 @@ double usPolynomialCurve3D::getCurvatureFromShape(double start, double end, vpCo if (center3D.size() == 3) { V.resize(3, 2, false); center3D = V * center; - } else if (center3D.size() == 4) { + } + else if (center3D.size() == 4) { V.resize(3, 2, false); center3D.insert(0, V * center + mean.t()); center3D[3] = 1; diff --git a/modules/ustk_core/src/io/usImageHeaderXmlParser.cpp b/modules/ustk_core/src/io/usImageHeaderXmlParser.cpp index 27a79a43..dd5c304d 100644 --- a/modules/ustk_core/src/io/usImageHeaderXmlParser.cpp +++ b/modules/ustk_core/src/io/usImageHeaderXmlParser.cpp @@ -41,6 +41,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Default constructor. */ diff --git a/modules/ustk_core/src/io/usImageIo.cpp b/modules/ustk_core/src/io/usImageIo.cpp index 1b93544d..6fe618e0 100644 --- a/modules/ustk_core/src/io/usImageIo.cpp +++ b/modules/ustk_core/src/io/usImageIo.cpp @@ -47,6 +47,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + usImageIo::usHeaderFormatType usImageIo::getHeaderFormat(const std::string &headerFileName) { std::string ext = usImageIo::getExtension(headerFileName); @@ -90,7 +94,8 @@ void usImageIo::write(const usImageRF2D &imageRf2D, const std::string &he usImageIo::usHeaderFormatType headerFormat = getHeaderFormat(headerFileName); if (headerFormat == FORMAT_XML) { write(imageRf2D, headerFileName, std::string(".png")); - } else if (headerFormat == FORMAT_MHD) { + } + else if (headerFormat == FORMAT_MHD) { write(imageRf2D, headerFileName, std::string(".raw")); } } @@ -139,7 +144,8 @@ void usImageIo::write(const usImageRF2D &imageRf2D, const std::string &he // filling raw usRawFileParser rawParser; rawParser.write(imageRf2D, imageFileName); - } else { + } + else { throw(vpException(vpException::fatalError, "Only mdh/raw files types are allowed to write 3D RF images.")); } } @@ -157,8 +163,9 @@ void usImageIo::read(usImageRF2D &imageRf2D, const std::string &heade usRfReader reader; reader.setFileName(headerFileName); reader.open(imageRf2D); - } else if (headerFormat == FORMAT_MHD) { - // header parsing + } + else if (headerFormat == FORMAT_MHD) { + // header parsing usMetaHeaderParser mhdParser; mhdParser.read(headerFileName); if (mhdParser.getImageType() != us::RF_2D && mhdParser.getImageType() != us::NOT_SET) { @@ -186,9 +193,10 @@ void usImageIo::read(usImageRF2D &imageRf2D, const std::string &heade // data parsing usRawFileParser rawParser; std::string fullImageFileName = - vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + mhdParser.getRawFileName(); + vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + mhdParser.getRawFileName(); rawParser.read(imageRf2D, fullImageFileName); - } else + } + else throw(vpException(vpException::fatalError, "Unknown header format.")); } @@ -203,7 +211,8 @@ void usImageIo::write(const usImageRF3D &imageRf3D, const std::string &he usImageIo::usHeaderFormatType headerFormat = getHeaderFormat(headerFileName); if (headerFormat == FORMAT_XML) { write(imageRf3D, headerFileName, std::string(".png")); - } else if (headerFormat == FORMAT_MHD) { + } + else if (headerFormat == FORMAT_MHD) { write(imageRf3D, headerFileName, std::string(".raw")); } } @@ -256,7 +265,8 @@ void usImageIo::write(const usImageRF3D &imageRf3D, const std::string &he // filling raw usRawFileParser rawParser; rawParser.write(imageRf3D, imageFileName); - } else { + } + else { throw(vpException(vpException::fatalError, "Unknown extension, only mdh allowed for 3D RF images.")); } } @@ -306,9 +316,10 @@ void usImageIo::read(usImageRF3D &imageRf3, const std::string &headerFile // data parsing usRawFileParser rawParser; std::string fullImageFileName = - vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + mhdParser.getRawFileName(); + vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + mhdParser.getRawFileName(); rawParser.read(imageRf3, fullImageFileName); - } else + } + else throw(vpException(vpException::fatalError, "Only mdh type is allowed for RF 3D.")); } @@ -323,9 +334,11 @@ void usImageIo::write(const usImagePreScan2D &preScanImage, const usImageIo::usHeaderFormatType headerFormat = getHeaderFormat(headerFileName); if (headerFormat == FORMAT_XML) { write(preScanImage, headerFileName, std::string(".png")); - } else if (headerFormat == FORMAT_MHD) { + } + else if (headerFormat == FORMAT_MHD) { write(preScanImage, headerFileName, std::string(".raw")); - } else { + } + else { throw(vpException(vpException::fatalError, "Unknown extension.")); } } @@ -358,14 +371,16 @@ void usImageIo::write(const usImagePreScan2D &preScanImage, const xmlSettings.setImageFileName(imageFileName); // write xml xmlSettings.save(headerFileName); - } catch (std::exception &e) { +} + catch (std::exception &e) { std::cout << "Error writing postScan image : " << std::endl; std::cout << e.what() << std::endl; } #else throw(vpException(vpException::fatalError, "Requires xml2")); #endif - } else if (headerFormat == FORMAT_MHD) { + } + else if (headerFormat == FORMAT_MHD) { if (imageExtension2D != ".raw") { throw(vpException(vpException::fatalError, "mhd files goes with .raw image extension")); } @@ -397,7 +412,8 @@ void usImageIo::write(const usImagePreScan2D &preScanImage, const // filling raw usRawFileParser rawParser; rawParser.write(preScanImage, imageFileName); - } else { + } + else { throw(vpException(vpException::fatalError, "Unknown extension.")); } } @@ -417,7 +433,7 @@ void usImageIo::read(usImagePreScan2D &preScanImage, const std::s xmlSettings.parse(headerFileName); std::string fullImageFileName = - vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + xmlSettings.getImageFileName(); + vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + xmlSettings.getImageFileName(); vpImageIo::read(preScanImage, fullImageFileName); preScanImage.setTransducerRadius(xmlSettings.getTransducerSettings().getTransducerRadius()); @@ -431,8 +447,9 @@ void usImageIo::read(usImagePreScan2D &preScanImage, const std::s #else throw(vpException(vpException::fatalError, "Requires xml2 library")); #endif // VISP_HAVE_XML2 - } else if (headerFormat == FORMAT_MHD) { - // header parsing + } + else if (headerFormat == FORMAT_MHD) { + // header parsing usMetaHeaderParser mhdParser; mhdParser.read(headerFileName); if (mhdParser.getImageType() != us::PRESCAN_2D && mhdParser.getImageType() != us::NOT_SET) { @@ -461,9 +478,10 @@ void usImageIo::read(usImagePreScan2D &preScanImage, const std::s // data parsing usRawFileParser rawParser; std::string fullImageFileName = - vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + mhdParser.getRawFileName(); + vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + mhdParser.getRawFileName(); rawParser.read(preScanImage, fullImageFileName); - } else + } + else throw(vpException(vpException::fatalError, "Unknown header format.")); } @@ -478,7 +496,8 @@ void usImageIo::write(const usImagePreScan3D &preScanImage, const usImageIo::usHeaderFormatType headerFormat = getHeaderFormat(headerFileName); if (headerFormat == FORMAT_XML) { write(preScanImage, headerFileName, std::string(".png")); - } else if (headerFormat == FORMAT_MHD) { + } + else if (headerFormat == FORMAT_MHD) { write(preScanImage, headerFileName, std::string(".raw")); } } @@ -502,7 +521,8 @@ void usImageIo::write(const usImagePreScan3D &preScanImage, const #else throw(vpException(vpException::fatalError, "Requires xml2")); #endif - } else if (headerFormat == FORMAT_MHD) { +} + else if (headerFormat == FORMAT_MHD) { if (imageExtension2D != ".raw") { throw(vpException(vpException::fatalError, "mhd files goes with .raw image extension")); } @@ -539,7 +559,8 @@ void usImageIo::write(const usImagePreScan3D &preScanImage, const // filling raw usRawFileParser rawParser; rawParser.write(preScanImage, imageFileName); - } else { + } + else { throw(vpException(vpException::fatalError, "Unknown extension.")); } } @@ -586,8 +607,9 @@ void usImageIo::read(usImagePreScan3D &preScanImage, const std::s #else throw(vpException(vpException::fatalError, "Requires xml2 library")); #endif // VISP_HAVE_XML2 - } else if (headerFormat == FORMAT_MHD) { - // header parsing +} + else if (headerFormat == FORMAT_MHD) { + // header parsing usMetaHeaderParser mhdParser; mhdParser.read(headerFileName); if (mhdParser.getImageType() != us::PRESCAN_3D && mhdParser.getImageType() != us::NOT_SET) { @@ -623,10 +645,11 @@ void usImageIo::read(usImagePreScan3D &preScanImage, const std::s // data parsing usRawFileParser rawParser; std::string fullImageFileName = - vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + mhdParser.getRawFileName(); + vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + mhdParser.getRawFileName(); rawParser.read(preScanImage, fullImageFileName); - } else if (headerFormat == FORMAT_VOL) { - // INIT + } + else if (headerFormat == FORMAT_VOL) { + // INIT int szHeader = sizeof(VolHeader); int n = 0; char byte; @@ -651,15 +674,15 @@ void usImageIo::read(usImagePreScan3D &preScanImage, const std::s } // Print header info std::cout << std::endl - << "Data header information: " << std::endl - << " type = " << header.type << std::endl - << " volumes = " << header.volumes << std::endl - << " fpv = " << header.fpv << std::endl - << " w = " << header.w << std::endl - << " h = " << header.h << std::endl - << " ss = " << header.ss << std::endl; - - // CHECK IMAGE TYPE + << "Data header information: " << std::endl + << " type = " << header.type << std::endl + << " volumes = " << header.volumes << std::endl + << " fpv = " << header.fpv << std::endl + << " w = " << header.w << std::endl + << " h = " << header.h << std::endl + << " ss = " << header.ss << std::endl; + +// CHECK IMAGE TYPE if (header.type != 0) throw(vpException(vpException::badValue, "trying to read non-prescan in .vol file")); @@ -683,7 +706,8 @@ void usImageIo::read(usImagePreScan3D &preScanImage, const std::s } } - } else + } + else throw(vpException(vpException::fatalError, "Unknown header format.")); } @@ -752,7 +776,8 @@ void usImageIo::write(const usImagePostScan2D &postScanImage, con usImageIo::usHeaderFormatType headerFormat = getHeaderFormat(headerFileName); if (headerFormat == FORMAT_XML) { write(postScanImage, headerFileName, std::string(".png")); - } else if (headerFormat == FORMAT_MHD) { + } + else if (headerFormat == FORMAT_MHD) { write(postScanImage, headerFileName, std::string(".raw")); } } @@ -785,14 +810,16 @@ void usImageIo::write(const usImagePostScan2D &postScanImage, con imageFileName = vpIoTools::getName(imageFileName); xmlSettings.setImageFileName(imageFileName); xmlSettings.save(headerFileName); - } catch (std::exception &e) { + } + catch (std::exception &e) { std::cout << "Error writing postScan image : " << std::endl; std::cout << e.what() << std::endl; } #else throw(vpException(vpException::fatalError, "Requires xml2 library")); #endif - } else if (headerFormat == FORMAT_MHD) { + } + else if (headerFormat == FORMAT_MHD) { if (imageExtension2D != ".raw" && imageExtension2D != ".RAW") { throw(vpException(vpException::fatalError, "mhd files goes with .raw image extension")); } @@ -827,7 +854,8 @@ void usImageIo::write(const usImagePostScan2D &postScanImage, con // filling raw usRawFileParser rawParser; rawParser.write(postScanImage, imageFileName); - } else + } + else throw(vpException(vpException::fatalError, "Unknown header format.")); } @@ -845,7 +873,7 @@ void usImageIo::read(usImagePostScan2D &postScanImage, const std: xmlSettings.parse(headerFileName); std::string fullImageFileName = - vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + xmlSettings.getImageFileName(); + vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + xmlSettings.getImageFileName(); vpImageIo::read(postScanImage, fullImageFileName); postScanImage.setTransducerRadius(xmlSettings.getTransducerSettings().getTransducerRadius()); @@ -859,9 +887,10 @@ void usImageIo::read(usImagePostScan2D &postScanImage, const std: #else throw(vpException(vpException::fatalError, "Requires xml2 library")); #endif - } else if (headerFormat == FORMAT_MHD) { - // mhd reading - // header parsing + } + else if (headerFormat == FORMAT_MHD) { + // mhd reading + // header parsing usMetaHeaderParser mhdParser; mhdParser.read(headerFileName); if (mhdParser.getImageType() != us::POSTSCAN_2D && mhdParser.getImageType() != us::NOT_SET) { @@ -888,9 +917,10 @@ void usImageIo::read(usImagePostScan2D &postScanImage, const std: // data parsing usRawFileParser rawParser; std::string fullImageFileName = - vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + mhdParser.getRawFileName(); + vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + mhdParser.getRawFileName(); rawParser.read(postScanImage, fullImageFileName); - } else + } + else throw(vpException(vpException::fatalError, "Unknown header format.")); } @@ -905,7 +935,8 @@ void usImageIo::write(const usImagePostScan3D &postScanImage, con usImageIo::usHeaderFormatType headerFormat = getHeaderFormat(headerFileName); if (headerFormat == FORMAT_XML) { write(postScanImage, headerFileName, std::string(".png")); - } else if (headerFormat == FORMAT_MHD) { + } + else if (headerFormat == FORMAT_MHD) { write(postScanImage, headerFileName, std::string(".raw")); } } @@ -926,7 +957,8 @@ void usImageIo::write(const usImagePostScan3D &postScanImage, con #else throw(vpException(vpException::fatalError, "Requires xml2 library")); #endif - } else if (headerFormat == FORMAT_MHD) { + } + else if (headerFormat == FORMAT_MHD) { if (imageExtension2D != ".raw") { throw(vpException(vpException::fatalError, "mhd files goes with .raw image extension")); } @@ -966,7 +998,8 @@ void usImageIo::write(const usImagePostScan3D &postScanImage, con // filling raw usRawFileParser rawParser; rawParser.write(postScanImage, imageFileName); - } else + } + else throw(vpException(vpException::fatalError, "Unknown header format.")); } @@ -984,8 +1017,9 @@ void usImageIo::read(usImagePostScan3D &postScanImage, const std: #else throw(vpException(vpException::fatalError, "Requires xml2 library")); #endif - } else if (headerFormat == FORMAT_MHD) { - // header parsing + } + else if (headerFormat == FORMAT_MHD) { + // header parsing usMetaHeaderParser mhdParser; mhdParser.read(headerFileName); if (mhdParser.getImageType() != us::POSTSCAN_3D && mhdParser.getImageType() != us::NOT_SET) { @@ -1017,8 +1051,9 @@ void usImageIo::read(usImagePostScan3D &postScanImage, const std: // data parsing usRawFileParser rawParser; std::string fullImageFileName = - vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + mhdParser.getRawFileName(); + vpIoTools::getParent(headerFileName) + vpIoTools::path("/") + mhdParser.getRawFileName(); rawParser.read(postScanImage, fullImageFileName); - } else + } + else throw(vpException(vpException::fatalError, "Unknown header format.")); } diff --git a/modules/ustk_core/src/io/usImageSettingsXmlParser.cpp b/modules/ustk_core/src/io/usImageSettingsXmlParser.cpp index da2d97fd..925bb48c 100644 --- a/modules/ustk_core/src/io/usImageSettingsXmlParser.cpp +++ b/modules/ustk_core/src/io/usImageSettingsXmlParser.cpp @@ -41,6 +41,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Default constructor. */ diff --git a/modules/ustk_core/src/io/usMHDSequenceReader.cpp b/modules/ustk_core/src/io/usMHDSequenceReader.cpp index 7da5ab31..12fa3718 100644 --- a/modules/ustk_core/src/io/usMHDSequenceReader.cpp +++ b/modules/ustk_core/src/io/usMHDSequenceReader.cpp @@ -1,17 +1,20 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor, initializes the member attribues. */ usMHDSequenceReader::usMHDSequenceReader() : m_sequenceDirectory(), m_sequenceImageType(us::NOT_SET), m_sequenceFiles(), m_totalImageNumber(0), m_imageCounter(0) -{ -} +{ } /** * Destructor. */ -usMHDSequenceReader::~usMHDSequenceReader() {} +usMHDSequenceReader::~usMHDSequenceReader() { } /** * Setter for the directory containing the mhd sequence to read. To call before calling acquire ! @@ -159,10 +162,11 @@ void usMHDSequenceReader::acquire(usImagePostScan2D &image, uint6 if (mhdHeader.isTransducerConvex) { // distance double deltaDepthPostScan2D = - mhdHeader.transducerRadius * - (1 - std::cos((double)((mhdHeader.scanLineNumber - 1) * mhdHeader.scanLinePitch / 2.0))); + mhdHeader.transducerRadius * + (1 - std::cos((double)((mhdHeader.scanLineNumber - 1) * mhdHeader.scanLinePitch / 2.0))); image.setDepth(mhdHeader.elementSpacing[1] * mhdHeader.dim[1] - deltaDepthPostScan2D); - } else // linear transducer + } + else // linear transducer image.setDepth(mhdHeader.elementSpacing[1] * mhdHeader.dim[1]); image.setWidthResolution(mhdHeader.dim[0]); @@ -544,10 +548,11 @@ void usMHDSequenceReader::getImage(unsigned int imageNumber, usImagePostScan2D +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor, initializes the member attribues. */ diff --git a/modules/ustk_core/src/io/usMetaHeaderParser.cpp b/modules/ustk_core/src/io/usMetaHeaderParser.cpp index 7c07b986..d5846355 100644 --- a/modules/ustk_core/src/io/usMetaHeaderParser.cpp +++ b/modules/ustk_core/src/io/usMetaHeaderParser.cpp @@ -40,6 +40,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Default constructor. */ diff --git a/modules/ustk_core/src/io/usRawFileParser.cpp b/modules/ustk_core/src/io/usRawFileParser.cpp index 0ee2c911..62b9ffee 100644 --- a/modules/ustk_core/src/io/usRawFileParser.cpp +++ b/modules/ustk_core/src/io/usRawFileParser.cpp @@ -41,6 +41,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Reading method for unisgned char 3D images. * @param[out] image3D 3D-image to fill. @@ -61,7 +65,7 @@ void usRawFileParser::read(usImage3D &image3D, const std::string void usRawFileParser::write(const usImage3D &image3D, const std::string &rawFilename) { std::fstream fileStream(rawFilename.c_str(), std::ios::out | std::ios::binary); - fileStream.write((const char*)image3D.getConstData(), image3D.getSize()*sizeof(unsigned char)); + fileStream.write((const char *)image3D.getConstData(), image3D.getSize()*sizeof(unsigned char)); fileStream.close(); } @@ -73,7 +77,7 @@ void usRawFileParser::write(const usImage3D &image3D, const std:: void usRawFileParser::read(usImageRF3D &image3D, const std::string &rawFilename) { std::ifstream fileStream(rawFilename.c_str(), std::ios::in | std::ios::binary); - fileStream.read((char*)image3D.bitmap, image3D.getSize()*sizeof(short)); + fileStream.read((char *)image3D.bitmap, image3D.getSize()*sizeof(short)); fileStream.close(); } @@ -85,7 +89,7 @@ void usRawFileParser::read(usImageRF3D &image3D, const std::string &rawFi void usRawFileParser::write(const usImageRF3D &image3D, const std::string &rawFilename) { std::fstream fileStream(rawFilename.c_str(), std::ios::out | std::ios::binary); - fileStream.write((const char*)image3D.getConstData(), image3D.getSize()*sizeof(short)); + fileStream.write((const char *)image3D.getConstData(), image3D.getSize()*sizeof(short)); fileStream.close(); } diff --git a/modules/ustk_core/src/io/usRfReader.cpp b/modules/ustk_core/src/io/usRfReader.cpp index 83af7a7e..5cf8b550 100644 --- a/modules/ustk_core/src/io/usRfReader.cpp +++ b/modules/ustk_core/src/io/usRfReader.cpp @@ -38,15 +38,19 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Default constructor. */ -usRfReader::usRfReader() : m_fileName(""), m_fileNameIsSet(false), m_header() {} +usRfReader::usRfReader() : m_fileName(""), m_fileNameIsSet(false), m_header() { } /** * Destructor. */ -usRfReader::~usRfReader() {} +usRfReader::~usRfReader() { } /** * FileName setter. diff --git a/modules/ustk_core/src/meterConversion/usMeterPixelConversion.cpp b/modules/ustk_core/src/meterConversion/usMeterPixelConversion.cpp index 13e92eb7..968f0044 100644 --- a/modules/ustk_core/src/meterConversion/usMeterPixelConversion.cpp +++ b/modules/ustk_core/src/meterConversion/usMeterPixelConversion.cpp @@ -37,6 +37,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Conversion method for 2D ultrasound images. * @@ -54,7 +58,7 @@ void usMeterPixelConversion::convert(const usImagePostScan2D &ima if (image.isTransducerConvex()) { u = (x + ((image.getWidth() * image.getWidthResolution()) / 2)) / image.getWidthResolution(); v = (y - image.getTransducerRadius() * std::cos((image.getScanLineNumber() - 1) * image.getScanLinePitch() / 2)) / - image.getHeightResolution(); + image.getHeightResolution(); } // Then linear probe type else { @@ -83,13 +87,15 @@ void usMeterPixelConversion::convert(const usImagePostScan3D &ima u = (x + ((image.getWidth() * image.getElementSpacingX()) / 2)) / image.getElementSpacingX(); v = y / image.getElementSpacingY(); w = (z + image.getNumberOfFrames() * image.getElementSpacingZ() / 2) / image.getElementSpacingZ(); - } else if (image.getMotorType() == usMotorSettings::TiltingMotor) { // tilting motor + } + else if (image.getMotorType() == usMotorSettings::TiltingMotor) { // tilting motor u = (x + ((image.getWidth() * image.getElementSpacingX()) / 2)) / image.getElementSpacingX(); v = (y - image.getMotorRadius() * std::cos((image.getFrameNumber() - 1) * image.getFramePitch() / 2) + image.getMotorRadius()) / - image.getElementSpacingY(); + image.getElementSpacingY(); w = (z + image.getNumberOfFrames() * image.getElementSpacingZ() / 2) / image.getElementSpacingZ(); - } else + } + else throw(vpException(vpException::notImplementedError, "Rotationnal Motor is not available yet.")); } // Then convex transducer @@ -97,21 +103,23 @@ void usMeterPixelConversion::convert(const usImagePostScan3D &ima if (image.getMotorType() == usMotorSettings::LinearMotor) { // linear motor u = (x + ((image.getWidth() * image.getElementSpacingX()) / 2)) / image.getElementSpacingX(); v = (y - image.getTransducerRadius() * std::cos((image.getScanLineNumber() - 1) * image.getScanLinePitch() / 2)) / - image.getElementSpacingY(); + image.getElementSpacingY(); w = (z + image.getNumberOfFrames() * image.getElementSpacingZ() / 2) / image.getElementSpacingZ(); - } else if (image.getMotorType() == usMotorSettings::TiltingMotor) { // tilting motor + } + else if (image.getMotorType() == usMotorSettings::TiltingMotor) { // tilting motor u = (x + ((image.getWidth() * image.getElementSpacingX()) / 2)) / image.getElementSpacingX(); v = (y - (image.getTransducerRadius() * // Rmin - std::cos((image.getScanLineNumber() - 1) * image.getScanLinePitch() / 2) // cos (FOV/2) + std::cos((image.getScanLineNumber() - 1) * image.getScanLinePitch() / 2) // cos (FOV/2) - (image.getTransducerRadius() - image.getMotorRadius())) // Delta R * std::cos((image.getFrameNumber() - 1) * image.getFramePitch() / 2) // cos(Phi/2) - (image.getTransducerRadius() - image.getMotorRadius())) // Delta R - / image.getElementSpacingY(); + / image.getElementSpacingY(); w = (z + image.getNumberOfFrames() * image.getElementSpacingZ() / 2) / image.getElementSpacingZ(); - } else + } + else throw(vpException(vpException::notImplementedError, "Rotationnal Motor is not available yet.")); } } diff --git a/modules/ustk_core/src/meterConversion/usPixelMeterConversion.cpp b/modules/ustk_core/src/meterConversion/usPixelMeterConversion.cpp index b0014666..9ef50788 100644 --- a/modules/ustk_core/src/meterConversion/usPixelMeterConversion.cpp +++ b/modules/ustk_core/src/meterConversion/usPixelMeterConversion.cpp @@ -38,6 +38,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * @brief Conversion for 2D post-scan images. * @param [in] image 2D Post-scan image with settings well filled. @@ -66,8 +70,8 @@ void usPixelMeterConversion::convert(const usImagePostScan2D &ima if (image.isTransducerConvex()) { x = image.getWidthResolution() * u - (((double)image.getWidth() * image.getWidthResolution()) / 2.0); y = image.getHeightResolution() * v + - image.getTransducerRadius() * - std::cos(((double)image.getScanLineNumber() - 1) * image.getScanLinePitch() / 2.0); + image.getTransducerRadius() * + std::cos(((double)image.getScanLineNumber() - 1) * image.getScanLinePitch() / 2.0); } // Then linear probe type else { @@ -117,13 +121,15 @@ void usPixelMeterConversion::convert(const usImagePostScan3D &ima x = image.getElementSpacingX() * u - ((image.getWidth() * image.getElementSpacingX()) / 2.0); y = image.getElementSpacingY() * v; z = image.getElementSpacingZ() * w - (image.getNumberOfFrames() * image.getElementSpacingZ() / 2.0); - } else if (image.getMotorType() == usMotorSettings::TiltingMotor) { // tilting motor + } + else if (image.getMotorType() == usMotorSettings::TiltingMotor) { // tilting motor x = image.getElementSpacingX() * u - ((image.getWidth() * image.getElementSpacingX()) / 2.0); y = image.getElementSpacingY() * v + - image.getMotorRadius() * std::cos((image.getFrameNumber() - 1) * image.getFramePitch() / 2.0) - - image.getMotorRadius(); + image.getMotorRadius() * std::cos((image.getFrameNumber() - 1) * image.getFramePitch() / 2.0) - + image.getMotorRadius(); z = image.getElementSpacingZ() * w - (image.getNumberOfFrames() * image.getElementSpacingZ() / 2.0); - } else + } + else throw(vpException(vpException::notImplementedError, "Rotationnal Motor is not available yet.")); } // Then convex transducer @@ -131,20 +137,22 @@ void usPixelMeterConversion::convert(const usImagePostScan3D &ima if (image.getMotorType() == usMotorSettings::LinearMotor) { // linear motor x = image.getElementSpacingX() * u - (image.getWidth() * image.getElementSpacingX() / 2.0); y = image.getElementSpacingY() * v + - image.getTransducerRadius() * std::cos((image.getScanLineNumber() - 1) * image.getScanLinePitch() / 2.0); + image.getTransducerRadius() * std::cos((image.getScanLineNumber() - 1) * image.getScanLinePitch() / 2.0); z = image.getElementSpacingZ() * w - (image.getNumberOfFrames() * image.getElementSpacingZ() / 2.0); - } else if (image.getMotorType() == usMotorSettings::TiltingMotor) { // tilting motor + } + else if (image.getMotorType() == usMotorSettings::TiltingMotor) { // tilting motor x = image.getElementSpacingX() * u - (image.getWidth() * image.getElementSpacingX() / 2.0); y = image.getElementSpacingY() * v + - (image.getTransducerRadius() * // Rmin - std::cos((image.getScanLineNumber() - 1) * image.getScanLinePitch() / 2) // cos (FOV/2) - - (image.getTransducerRadius() - image.getMotorRadius())) // Delta R - * std::cos((image.getFrameNumber() - 1) * image.getFramePitch() / 2) // cos(Phi/2) - + (image.getTransducerRadius() - image.getMotorRadius()); // Delta R + (image.getTransducerRadius() * // Rmin + std::cos((image.getScanLineNumber() - 1) * image.getScanLinePitch() / 2) // cos (FOV/2) + - (image.getTransducerRadius() - image.getMotorRadius())) // Delta R + * std::cos((image.getFrameNumber() - 1) * image.getFramePitch() / 2) // cos(Phi/2) + + (image.getTransducerRadius() - image.getMotorRadius()); // Delta R z = image.getElementSpacingZ() * w - (image.getNumberOfFrames() * image.getElementSpacingZ() / 2.0); - } else + } + else throw(vpException(vpException::notImplementedError, "Rotationnal Motor is not available yet.")); } } diff --git a/modules/ustk_core/src/scanConversion/usPostScanToPreScan2DConverter.cpp b/modules/ustk_core/src/scanConversion/usPostScanToPreScan2DConverter.cpp index fc92c23f..216b26a9 100644 --- a/modules/ustk_core/src/scanConversion/usPostScanToPreScan2DConverter.cpp +++ b/modules/ustk_core/src/scanConversion/usPostScanToPreScan2DConverter.cpp @@ -33,10 +33,14 @@ #include //#include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Default constructor. */ -usPostScanToPreScan2DConverter::usPostScanToPreScan2DConverter() : m_isInit(false) {} +usPostScanToPreScan2DConverter::usPostScanToPreScan2DConverter() : m_isInit(false) { } /** * Initialisation constructor. @@ -63,7 +67,7 @@ usPostScanToPreScan2DConverter::usPostScanToPreScan2DConverter(const usTransduce /** * Destructor. */ -usPostScanToPreScan2DConverter::~usPostScanToPreScan2DConverter() {} +usPostScanToPreScan2DConverter::~usPostScanToPreScan2DConverter() { } /** * Initialize the back-scan converter. @@ -147,7 +151,7 @@ void usPostScanToPreScan2DConverter::init(const usTransducerSettings &transducer if (transducerSettings.isTransducerConvex()) { double APitch = transducerSettings.getDepth() / BModeSampleNumber; double LPitch = - transducerSettings.getFieldOfView() * transducerSettings.getTransducerRadius() / (scanLineNumber - 1); + transducerSettings.getFieldOfView() * transducerSettings.getTransducerRadius() / (scanLineNumber - 1); double r_min = transducerSettings.getTransducerRadius(); double r_max = (transducerSettings.getTransducerRadius() + APitch * BModeSampleNumber); @@ -237,7 +241,8 @@ double usPostScanToPreScan2DConverter::interpolateLinear(const vpImage #include -usPreScanToPostScan2DConverter::usPreScanToPostScan2DConverter() : m_initDone(false) {} +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif -usPreScanToPostScan2DConverter::~usPreScanToPostScan2DConverter() {} +usPreScanToPostScan2DConverter::usPreScanToPostScan2DConverter() : m_initDone(false) { } + +usPreScanToPostScan2DConverter::~usPreScanToPostScan2DConverter() { } /** * Initialize the scan-converter. @@ -85,7 +89,8 @@ void usPreScanToPostScan2DConverter::init(const usImagePostScan2D m_tMap[i][j] = atan2(y, x) * inputSettings.getTransducerRadius() / LPitch + (scanLineNumber - 1) / 2.0; } } - } else { + } + else { m_scanLineNumber = scanLineNumber; m_BModeSampleNumber = BModeSampleNumber; m_xResolution = inputSettings.getWidthResolution(); @@ -156,7 +161,8 @@ void usPreScanToPostScan2DConverter::init(const usTransducerSettings &inputSetti m_tMap[i][j] = atan2(y, x) * inputSettings.getTransducerRadius() / LPitch + (scanLineNumber - 1) / 2.0; } } - } else { + } + else { m_scanLineNumber = scanLineNumber; m_BModeSampleNumber = BModeSampleNumber; m_xResolution = xResolution; @@ -205,7 +211,8 @@ void usPreScanToPostScan2DConverter::convert(const usImagePreScan2D #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + #ifdef USTK_HAVE_CUDA extern void GPUDirectConversionWrapper(unsigned char *dataPost, const unsigned char *dataPre, unsigned int m_nbX, unsigned int m_nbY, unsigned int m_nbZ, int X, int Y, int Z, double m_resolution, double xmax, double ymin, double zmax, unsigned int frameNumber, unsigned int scanLineNumber, double transducerRadius, double motorRadius, double scanLinePitch, double axialResolution, double framePitch, bool sweepInZdirection); #endif @@ -46,10 +50,9 @@ extern void GPUDirectConversionWrapper(unsigned char *dataPost, const unsigned c */ usPreScanToPostScan3DConverter::usPreScanToPostScan3DConverter() : m_converterOptimizationMethod(SINGLE_THREAD_REDUCED_LOOKUP_TABLE), - m_conversionOptimizationMethodUsedAtInit(SINGLE_THREAD_DIRECT_CONVERSION), m_GPULookupTables{NULL, NULL}, m_GPULookupTablesSize{0,0}, m_VpreScan(), m_downSamplingFactor(1), - m_resolution(), m_SweepInZdirection(true), m_initDone(false) -{ -} + m_conversionOptimizationMethodUsedAtInit(SINGLE_THREAD_DIRECT_CONVERSION), m_GPULookupTables { NULL, NULL }, m_GPULookupTablesSize { 0,0 }, m_VpreScan(), m_downSamplingFactor(1), + m_resolution(), m_SweepInZdirection(true), m_initDone(false) +{ } /** * Initialisation constructor. @@ -125,7 +128,7 @@ void usPreScanToPostScan3DConverter::init(const usImagePreScan3D #ifdef USTK_HAVE_CUDA this->GPUFreeLookupTables(); #endif - + switch (m_converterOptimizationMethod) { case SINGLE_THREAD_DIRECT_CONVERSION: { break; @@ -142,7 +145,8 @@ void usPreScanToPostScan3DConverter::init(const usImagePreScan3D // reserve to avoid reallocation during the LUT filling m_lookupTables[0].reserve(LUTmaxSize); m_lookupTables[1].reserve(LUTmaxSize); - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::ioError, "usPreScanToPostScan3DConverter::init: using method " "SINGLE_THREAD_FULL_LOOKUP_TABLE leads to %s \n Use another optimization " "method or downsample the volume", @@ -219,14 +223,15 @@ void usPreScanToPostScan3DConverter::init(const usImagePreScan3D // reserve to avoid reallocation during the LUT filling m_lookupTables[0].reserve(LUTmaxSize); m_lookupTables[1].reserve(LUTmaxSize); - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::ioError, "usPreScanToPostScan3DConverter::init: using method " "MULTI_THREAD_FULL_LOOKUP_TABLE leads to %s \n Use another optimization " "method or downsample the volume", e.what()); } - for (unsigned int sweepingDirection = 0 ; sweepingDirection < 2 ; sweepingDirection++) { + for (unsigned int sweepingDirection = 0; sweepingDirection < 2; sweepingDirection++) { #ifdef VISP_HAVE_OPENMP #pragma omp parallel for #endif @@ -300,7 +305,7 @@ void usPreScanToPostScan3DConverter::init(const usImagePreScan3D #ifdef USTK_HAVE_CUDA this->GPUAllocateFullLookupTables(); this->GPUFillFullLookupTables(); -std::cout << "LUT 1 size (bytes) : " << sizeof(usVoxelWeightAndIndex) * m_GPULookupTablesSize[0] << std::endl; + std::cout << "LUT 1 size (bytes) : " << sizeof(usVoxelWeightAndIndex) * m_GPULookupTablesSize[0] << std::endl; std::cout << "LUT 2 size (bytes) : " << sizeof(usVoxelWeightAndIndex) * m_GPULookupTablesSize[1] << std::endl; #else throw vpException( @@ -308,14 +313,15 @@ std::cout << "LUT 1 size (bytes) : " << sizeof(usVoxelWeightAndIndex) * m_GPULoo "usPreScanToPostScan3DConverter::init: using method GPU_FULL_LOOKUP_TABLE is not implemented yet"); #endif break; - } + } case SINGLE_THREAD_REDUCED_LOOKUP_TABLE: { try { long int LUTmaxSize = (long int)m_nbX * (long int)m_nbY * (long int)m_nbZ; // reserve to avoid reallocation during the LUT filling m_reducedLookupTables[0].reserve(LUTmaxSize); m_reducedLookupTables[1].reserve(LUTmaxSize); - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::ioError, "usPreScanToPostScan3DConverter::init: using method " "SINGLE_THREAD_REDUCED_LOOKUP_TABLE leads to %s \n Use another " "optimization method or downsample the volume", @@ -354,9 +360,9 @@ std::cout << "LUT 1 size (bytes) : " << sizeof(usVoxelWeightAndIndex) * m_GPULoo } } std::cout << "LUT 1 size (bytes) : " << sizeof(usVoxelWeightAndIndexReducedMemory) * m_reducedLookupTables[0].size() - << std::endl; + << std::endl; std::cout << "LUT 2 size (bytes) : " << sizeof(usVoxelWeightAndIndexReducedMemory) * m_reducedLookupTables[1].size() - << std::endl; + << std::endl; break; } case MULTI_THREAD_REDUCED_LOOKUP_TABLE: { @@ -365,7 +371,8 @@ std::cout << "LUT 1 size (bytes) : " << sizeof(usVoxelWeightAndIndex) * m_GPULoo // reserve to avoid reallocation during the LUT filling m_reducedLookupTables[0].reserve(LUTmaxSize); m_reducedLookupTables[1].reserve(LUTmaxSize); - } catch (std::exception &e) { + } + catch (std::exception &e) { throw vpException(vpException::ioError, "usPreScanToPostScan3DConverter::init: using method " "MULTI_THREAD_REDUCED_LOOKUP_TABLE leads to %s \n Use another " "optimization method or downsample the volume", @@ -409,9 +416,9 @@ std::cout << "LUT 1 size (bytes) : " << sizeof(usVoxelWeightAndIndex) * m_GPULoo } } std::cout << "LUT 1 size (bytes) : " << sizeof(usVoxelWeightAndIndexReducedMemory) * m_reducedLookupTables[0].size() - << std::endl; + << std::endl; std::cout << "LUT 2 size (bytes) : " << sizeof(usVoxelWeightAndIndexReducedMemory) * m_reducedLookupTables[1].size() - << std::endl; + << std::endl; break; } case GPU_REDUCED_LOOKUP_TABLE: { @@ -431,12 +438,12 @@ std::cout << "LUT 1 size (bytes) : " << sizeof(usVoxelWeightAndIndex) * m_GPULoo m_conversionOptimizationMethodUsedAtInit = m_converterOptimizationMethod; m_initDone = true; -} + } -/** - * Destructor. - */ -usPreScanToPostScan3DConverter::~usPreScanToPostScan3DConverter() {} + /** + * Destructor. + */ +usPreScanToPostScan3DConverter::~usPreScanToPostScan3DConverter() { } /** * Conversion method : compute the scan-conversion 3D and write the post-scan image settings. @@ -450,9 +457,9 @@ void usPreScanToPostScan3DConverter::convert(usImagePostScan3D &p postScanImage.resize(m_nbY, m_nbX, m_nbZ); postScanImage.initData(0); - (usTransducerSettings&)postScanImage = (const usTransducerSettings&)preScanImage; - (usMotorSettings&)postScanImage = (const usMotorSettings&)preScanImage; - + (usTransducerSettings &)postScanImage = (const usTransducerSettings &)preScanImage; + (usMotorSettings &)postScanImage = (const usMotorSettings &)preScanImage; + unsigned char *dataPost = postScanImage.getData(); const unsigned char *dataPre = preScanImage.getConstData(); @@ -504,22 +511,22 @@ void usPreScanToPostScan3DConverter::convert(usImagePostScan3D &p double v1w = v1 * w; double vw = v * w; - double W[8] = {u1 * v1w1, u * v1w1, u1 * vw1, u * vw1, u1 * v1w, u * v1w, u1 * vw, u * vw}; + double W[8] = { u1 * v1w1, u * v1w1, u1 * vw1, u * vw1, u1 * v1w, u * v1w, u1 * vw, u * vw }; double Xjj = X * jj; double Xjj1 = X * (jj + 1); double XYKK = XY * kk; double XYKK1 = XY * (kk + 1); - unsigned int index[8] = {(unsigned int)(ii + Xjj + XYKK), (unsigned int)(ii + 1 + Xjj + XYKK), + unsigned int index[8] = { (unsigned int)(ii + Xjj + XYKK), (unsigned int)(ii + 1 + Xjj + XYKK), (unsigned int)(ii + Xjj1 + XYKK), (unsigned int)(ii + 1 + Xjj1 + XYKK), (unsigned int)(ii + Xjj + XYKK1), (unsigned int)(ii + 1 + Xjj + XYKK1), - (unsigned int)(ii + Xjj1 + XYKK1), (unsigned int)(ii + 1 + Xjj1 + XYKK1)}; + (unsigned int)(ii + Xjj1 + XYKK1), (unsigned int)(ii + 1 + Xjj1 + XYKK1) }; double val = 0; - for (int n = 0; n < 8; n++) + for (int n = 0; n < 8; n++) val += W[n] * dataPre[index[n]]; - + dataPost[x + m_nbX * y + nbXY * z] = (unsigned char)val; } } @@ -577,20 +584,20 @@ void usPreScanToPostScan3DConverter::convert(usImagePostScan3D &p double v1w = v1 * w; double vw = v * w; - double W[8] = {u1 * v1w1, u * v1w1, u1 * vw1, u * vw1, u1 * v1w, u * v1w, u1 * vw, u * vw}; + double W[8] = { u1 * v1w1, u * v1w1, u1 * vw1, u * vw1, u1 * v1w, u * v1w, u1 * vw, u * vw }; double Xjj = X * jj; double Xjj1 = X * (jj + 1); double XYKK = XY * kk; double XYKK1 = XY * (kk + 1); - unsigned int index[8] = {(unsigned int)(ii + Xjj + XYKK), (unsigned int)(ii + 1 + Xjj + XYKK), + unsigned int index[8] = { (unsigned int)(ii + Xjj + XYKK), (unsigned int)(ii + 1 + Xjj + XYKK), (unsigned int)(ii + Xjj1 + XYKK), (unsigned int)(ii + 1 + Xjj1 + XYKK), (unsigned int)(ii + Xjj + XYKK1), (unsigned int)(ii + 1 + Xjj + XYKK1), - (unsigned int)(ii + Xjj1 + XYKK1), (unsigned int)(ii + 1 + Xjj1 + XYKK1)}; + (unsigned int)(ii + Xjj1 + XYKK1), (unsigned int)(ii + 1 + Xjj1 + XYKK1) }; double val = 0; - for (int n = 0; n < 8; n++) + for (int n = 0; n < 8; n++) val += W[n] * dataPre[index[n]]; #ifdef VISP_HAVE_OPENMP #pragma omp critical @@ -664,11 +671,11 @@ void usPreScanToPostScan3DConverter::convert(usImagePostScan3D &p double v1w = v1 * w; double vw = v * w; - double W[8] = {u1 * v1w1, u * v1w1, u1 * vw1, u * vw1, u1 * v1w, u * v1w, u1 * vw, u * vw}; + double W[8] = { u1 * v1w1, u * v1w1, u1 * vw1, u * vw1, u1 * v1w, u * v1w, u1 * vw, u * vw }; - unsigned int index[8] = {m.m_inputIndex, m.m_inputIndex + 1, m.m_inputIndex + X, + unsigned int index[8] = { m.m_inputIndex, m.m_inputIndex + 1, m.m_inputIndex + X, m.m_inputIndex + 1 + X, m.m_inputIndex + XY, m.m_inputIndex + 1 + XY, - m.m_inputIndex + X + XY, m.m_inputIndex + 1 + X + XY}; + m.m_inputIndex + X + XY, m.m_inputIndex + 1 + X + XY }; double val = 0; for (int j = 0; j < 8; j++) @@ -699,11 +706,11 @@ void usPreScanToPostScan3DConverter::convert(usImagePostScan3D &p double v1w = v1 * w; double vw = v * w; - double W[8] = {u1 * v1w1, u * v1w1, u1 * vw1, u * vw1, u1 * v1w, u * v1w, u1 * vw, u * vw}; + double W[8] = { u1 * v1w1, u * v1w1, u1 * vw1, u * vw1, u1 * v1w, u * v1w, u1 * vw, u * vw }; - unsigned int index[8] = {m.m_inputIndex, m.m_inputIndex + 1, m.m_inputIndex + X, + unsigned int index[8] = { m.m_inputIndex, m.m_inputIndex + 1, m.m_inputIndex + X, m.m_inputIndex + 1 + X, m.m_inputIndex + XY, m.m_inputIndex + 1 + XY, - m.m_inputIndex + X + XY, m.m_inputIndex + 1 + X + XY}; + m.m_inputIndex + X + XY, m.m_inputIndex + 1 + X + XY }; double val = 0; for (int j = 0; j < 8; j++) @@ -731,12 +738,12 @@ void usPreScanToPostScan3DConverter::convert(usImagePostScan3D &p postScanImage.setElementSpacingY(m_resolution); postScanImage.setElementSpacingZ(m_resolution); postScanImage.setScanLineDepth(m_resolution * m_VpreScan.getBModeSampleNumber()); -} + } -/** - * Choose the method used for the optimization of the conversion. - * @param method optimization method. - */ + /** + * Choose the method used for the optimization of the conversion. + * @param method optimization method. + */ void usPreScanToPostScan3DConverter::setConverterOptimizationMethod(usConverterOptimizationMethod method) { m_converterOptimizationMethod = method; @@ -752,8 +759,8 @@ void usPreScanToPostScan3DConverter::setConverterOptimizationMethod(usConverterO case MULTI_THREAD_REDUCED_LOOKUP_TABLE: { #ifndef VISP_HAVE_OPENMP std::cout << "Warning in usPreScanToPostScan3DConverter::setConverterOptimizationMethod: OpenMP is not available " - "to use multi-thread optimization, will use single thread implementation instead." - << std::endl; + "to use multi-thread optimization, will use single thread implementation instead." + << std::endl; #endif break; } @@ -797,9 +804,9 @@ void usPreScanToPostScan3DConverter::convertPreScanCoordToPostScanCoord(double i // const double theta = (sweepInZdirection ? 1 : -1) * (m_VpreScan.getFramePitch() * Nframe * (j_preScan + Nline * // k_preScan) / (Nframe * Nline - 1) - offsetTheta); const double theta = - (m_VpreScan.getFramePitch() * Nframe * - ((sweepInZdirection ? j_preScan : Nline - 1 - j_preScan) + Nline * k_preScan) / (Nframe * Nline - 1) - - offsetTheta); + (m_VpreScan.getFramePitch() * Nframe * + ((sweepInZdirection ? j_preScan : Nline - 1 - j_preScan) + Nline * k_preScan) / (Nframe * Nline - 1) - + offsetTheta); const double cPhi = cos(phi); @@ -849,6 +856,6 @@ void usPreScanToPostScan3DConverter::convertPostScanCoordToPreScanCoord(double i //} if (k_preScan) { *k_preScan = (Nframe * Nline - 1) * (0.5 / Nline + theta / (m_VpreScan.getFramePitch() * Nframe * Nline)) - - (sweepInZdirection ? jtmp : Nline - 1 - jtmp) / Nline; + (sweepInZdirection ? jtmp : Nline - 1 - jtmp) / Nline; } } diff --git a/modules/ustk_core/src/scanConversion/usPreScanToPostScan3DConverter.cu b/modules/ustk_core/src/scanConversion/usPreScanToPostScan3DConverter.cu index dcfcd08f..24e2d969 100644 --- a/modules/ustk_core/src/scanConversion/usPreScanToPostScan3DConverter.cu +++ b/modules/ustk_core/src/scanConversion/usPreScanToPostScan3DConverter.cu @@ -39,6 +39,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + struct cudaVoxelWeightAndIndex { unsigned int m_outputIndex; diff --git a/modules/ustk_core/src/settings/usImagePreScanSettings.cpp b/modules/ustk_core/src/settings/usImagePreScanSettings.cpp index 0cf9339f..718fabf4 100644 --- a/modules/ustk_core/src/settings/usImagePreScanSettings.cpp +++ b/modules/ustk_core/src/settings/usImagePreScanSettings.cpp @@ -39,6 +39,10 @@ // ustk includes #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Default constructor, all parameters set with default values. */ diff --git a/modules/ustk_core/src/settings/usMotorSettings.cpp b/modules/ustk_core/src/settings/usMotorSettings.cpp index 68e82ffb..ab839a2b 100644 --- a/modules/ustk_core/src/settings/usMotorSettings.cpp +++ b/modules/ustk_core/src/settings/usMotorSettings.cpp @@ -44,13 +44,16 @@ // ustk includes +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Basic Constructor, all settings set to default. */ usMotorSettings::usMotorSettings() : m_motorRadius(0.0), m_framePitch(0.0), m_frameNumberIsSet(false), m_motorType(LinearMotor) -{ -} +{ } /** * Full Constructor, all settings availables @@ -63,9 +66,8 @@ usMotorSettings::usMotorSettings() usMotorSettings::usMotorSettings(double motorRadius, double framePitch, unsigned int frameNumber, const usMotorType &motorType) : m_motorRadius(motorRadius), m_framePitch(framePitch), m_frameNumber(frameNumber), m_frameNumberIsSet(true), - m_motorType(motorType) -{ -} + m_motorType(motorType) +{ } /** * Copy Constructor, all settings availables @@ -73,14 +75,13 @@ usMotorSettings::usMotorSettings(double motorRadius, double framePitch, unsigned */ usMotorSettings::usMotorSettings(const usMotorSettings &other) : m_motorRadius(other.getMotorRadius()), m_framePitch(other.getFramePitch()), m_frameNumber(other.getFrameNumber()), - m_frameNumberIsSet(other.frameNumberIsSet()), m_motorType(other.getMotorType()) -{ -} + m_frameNumberIsSet(other.frameNumberIsSet()), m_motorType(other.getMotorType()) +{ } /** * Destructor. */ -usMotorSettings::~usMotorSettings() {} +usMotorSettings::~usMotorSettings() { } /** * Assignment operator. @@ -121,9 +122,9 @@ bool usMotorSettings::operator!=(const usMotorSettings &other) { return !operato VISP_EXPORT std::ostream &operator<<(std::ostream &out, const usMotorSettings &other) { return out << "motor radius : " << other.getMotorRadius() << std::endl - << "frame angle : " << other.getFramePitch() << std::endl - << "frame number : " << other.getFrameNumber() << std::endl - << "motor type : " << other.getMotorType() << std::endl; + << "frame angle : " << other.getFramePitch() << std::endl + << "frame number : " << other.getFrameNumber() << std::endl + << "motor type : " << other.getMotorType() << std::endl; } // probe settings getters/setters diff --git a/modules/ustk_core/src/settings/usTransducerSettings.cpp b/modules/ustk_core/src/settings/usTransducerSettings.cpp index 7909e5b0..ae87d25c 100644 --- a/modules/ustk_core/src/settings/usTransducerSettings.cpp +++ b/modules/ustk_core/src/settings/usTransducerSettings.cpp @@ -44,14 +44,17 @@ // ustk includes +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Basic constructor, all settings set to default. */ usTransducerSettings::usTransducerSettings() : m_transducerRadius(0.0f), m_scanLinePitch(0.0f), m_scanLineNumber(0), m_isTransducerConvex(true), - m_scanLineNumberIsSet(false), m_transmitFrequency(0), m_samplingFrequency(0) -{ -} + m_scanLineNumberIsSet(false), m_transmitFrequency(0), m_samplingFrequency(0) +{ } /** * Full constructor with all the settings availables: @@ -70,10 +73,9 @@ usTransducerSettings::usTransducerSettings(double transducerRadius, double scanL bool transducerConvex, double depth, int transmitFrequency, int samplingFrequency) : m_transducerRadius(transducerRadius), m_scanLinePitch(scanLinePitch), m_scanLineNumber(scanLineNumber), - m_isTransducerConvex(transducerConvex), m_depth(depth), m_scanLineNumberIsSet(true), - m_transmitFrequency(transmitFrequency), m_samplingFrequency(samplingFrequency) -{ -} + m_isTransducerConvex(transducerConvex), m_depth(depth), m_scanLineNumberIsSet(true), + m_transmitFrequency(transmitFrequency), m_samplingFrequency(samplingFrequency) +{ } /** * Copy constructor. @@ -84,7 +86,7 @@ usTransducerSettings::usTransducerSettings(const usTransducerSettings &other) { /** * Destructor. */ -usTransducerSettings::~usTransducerSettings() {} +usTransducerSettings::~usTransducerSettings() { } /** * Assignment operator. @@ -140,10 +142,10 @@ VISP_EXPORT std::ostream &operator<<(std::ostream &out, const usTransducerSettin else out << "scan line pitch distance: " << other.getScanLinePitch() << std::endl; out << "scan line number : " << other.getScanLineNumber() << std::endl - << "convex probe used: " << other.isTransducerConvex() << std::endl - << "depth : " << other.getDepth() << std::endl - << "sampling frequency " << other.getSamplingFrequency() << std::endl - << "transmit frequency " << other.getTransmitFrequency() << std::endl; + << "convex probe used: " << other.isTransducerConvex() << std::endl + << "depth : " << other.getDepth() << std::endl + << "sampling frequency " << other.getSamplingFrequency() << std::endl + << "transmit frequency " << other.getTransmitFrequency() << std::endl; return out; } diff --git a/modules/ustk_core/src/us.cpp b/modules/ustk_core/src/us.cpp index 9345350a..076433e5 100644 --- a/modules/ustk_core/src/us.cpp +++ b/modules/ustk_core/src/us.cpp @@ -53,6 +53,9 @@ namespace us */ std::string getDataSetPath() { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif std::string data_path; std::string file_to_test("post-scan/3D_mhd/volume.mhd"); std::string filename; @@ -69,7 +72,8 @@ std::string getDataSetPath() filename = data_path + "/" + file_to_test; if (vpIoTools::checkFilename(filename)) return data_path; - } catch (...) { + } + catch (...) { } data_path = ""; return data_path; diff --git a/modules/ustk_core/test/geometry/testUsBSpline3D.cpp b/modules/ustk_core/test/geometry/testUsBSpline3D.cpp index e93276d7..f0b55e93 100644 --- a/modules/ustk_core/test/geometry/testUsBSpline3D.cpp +++ b/modules/ustk_core/test/geometry/testUsBSpline3D.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main() { std::cout << "Start testUsBSpline3D" << std::endl; diff --git a/modules/ustk_core/test/geometry/testUsGeometryDisplayTools.cpp b/modules/ustk_core/test/geometry/testUsGeometryDisplayTools.cpp index 7ddddca4..11a537fe 100644 --- a/modules/ustk_core/test/geometry/testUsGeometryDisplayTools.cpp +++ b/modules/ustk_core/test/geometry/testUsGeometryDisplayTools.cpp @@ -62,6 +62,10 @@ // List of allowed command line options #define GETOPTARGS "hlt:cd" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType; void usage(const char *name, const char *badparam, vpDisplayType &dtype); @@ -148,252 +152,246 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, vpDisplayType &dtype, bool &list, bool &display) { - const char *optarg_; - int c; - std::string sDisplayType; - while((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) - { - - switch (c) - { - case 'l': - list = true; - break; - case 't': - sDisplayType = optarg_; - // Parse the display type option - if(sDisplayType.compare("X11") == 0) dtype = vpX11; - else if (sDisplayType.compare("GTK") == 0) dtype = vpGTK; - else if (sDisplayType.compare("GDI") == 0) dtype = vpGDI; - else if (sDisplayType.compare("D3D") == 0) dtype = vpD3D; - else if (sDisplayType.compare("CV") == 0) dtype = vpCV; - - break; - case 'h': - usage(argv[0], NULL, dtype); - return false; - break; - - case 'c': - break; - - case 'd': - display = false; - break; - - default: - usage(argv[0], optarg_, dtype); - return false; - break; - } + const char *optarg_; + int c; + std::string sDisplayType; + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { + + switch (c) { + case 'l': + list = true; + break; + case 't': + sDisplayType = optarg_; + // Parse the display type option + if (sDisplayType.compare("X11") == 0) dtype = vpX11; + else if (sDisplayType.compare("GTK") == 0) dtype = vpGTK; + else if (sDisplayType.compare("GDI") == 0) dtype = vpGDI; + else if (sDisplayType.compare("D3D") == 0) dtype = vpD3D; + else if (sDisplayType.compare("CV") == 0) dtype = vpCV; + + break; + case 'h': + usage(argv[0], NULL, dtype); + return false; + break; + + case 'c': + break; + + case 'd': + display = false; + break; + + default: + usage(argv[0], optarg_, dtype); + return false; + break; } + } - if((c == 1) || (c == -1)) - { - // standalone param or error - usage(argv[0], NULL, dtype); - std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; - return false; - } + if ((c == 1) || (c == -1)) { + // standalone param or error + usage(argv[0], NULL, dtype); + std::cerr << "ERROR: " << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; + return false; + } - return true; + return true; } int main(int argc, const char **argv) { - bool opt_list = false; // To print the list of video devices - vpDisplayType opt_dtype; // Type of display to use - bool opt_display = true; + bool opt_list = false; // To print the list of video devices + vpDisplayType opt_dtype; // Type of display to use + bool opt_display = true; // Default display is one available #if defined VISP_HAVE_GTK - opt_dtype = vpGTK; + opt_dtype = vpGTK; #elif defined VISP_HAVE_X11 - opt_dtype = vpX11; + opt_dtype = vpX11; #elif defined VISP_HAVE_GDI - opt_dtype = vpGDI; + opt_dtype = vpGDI; #elif defined VISP_HAVE_D3D9 - opt_dtype = vpD3D; + opt_dtype = vpD3D; #elif defined VISP_HAVE_OPENCV - opt_dtype = vpCV; + opt_dtype = vpCV; #endif // Read the command line options - if(!getOptions(argc, argv, opt_dtype, opt_list, opt_display)) exit(-1); + if (!getOptions(argc, argv, opt_dtype, opt_list, opt_display)) exit(-1); - // Print the list of video-devices available - if (opt_list) { - unsigned nbDevices = 0; - std::cout << "List of video-devices available: \n"; + // Print the list of video-devices available + if (opt_list) { + unsigned nbDevices = 0; + std::cout << "List of video-devices available: \n"; #if defined VISP_HAVE_GTK - std::cout << " GTK (use \"-t GTK\" option to use it)\n"; - nbDevices++; + std::cout << " GTK (use \"-t GTK\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_X11 - std::cout << " X11 (use \"-t X11\" option to use it)\n"; - nbDevices++; + std::cout << " X11 (use \"-t X11\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_GDI - std::cout << " GDI (use \"-t GDI\" option to use it)\n"; - nbDevices++; + std::cout << " GDI (use \"-t GDI\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_D3D9 - std::cout << " D3D (use \"-t D3D\" option to use it)\n"; - nbDevices++; + std::cout << " D3D (use \"-t D3D\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_OPENCV - std::cout << " CV (use \"-t CV\" option to use it)\n"; - nbDevices++; + std::cout << " CV (use \"-t CV\" option to use it)\n"; + nbDevices++; #endif - if (!nbDevices) { - std::cout << " No display is available\n"; - } - return (0); + if (!nbDevices) { + std::cout << " No display is available\n"; } + return (0); +} + + vpImage I1(700, 500, 255); + vpImage I2(700, 500, vpRGBa(255, 255, 255, 255)); - vpImage I1(700, 500, 255); - vpImage I2(700, 500, vpRGBa(255,255,255,255)); - - vpDisplay *display1 = nullptr; - vpDisplay *display2 = nullptr; - - if(opt_display) - { - switch (opt_dtype) - { - case vpX11: - std::cout << "Requested X11 display functionnalities..." << std::endl; + vpDisplay *display1 = nullptr; + vpDisplay *display2 = nullptr; + + if (opt_display) { + switch (opt_dtype) { + case vpX11: + std::cout << "Requested X11 display functionnalities..." << std::endl; #if defined VISP_HAVE_X11 - display1 = new vpDisplayX; - display2 = new vpDisplayX; + display1 = new vpDisplayX; + display2 = new vpDisplayX; #else - std::cout << " Sorry, X11 video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, X11 video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpGTK: - std::cout << "Requested GTK display functionnalities..." << std::endl; + break; + case vpGTK: + std::cout << "Requested GTK display functionnalities..." << std::endl; #if defined VISP_HAVE_GTK - display1 = new vpDisplayGTK; - display2 = new vpDisplayGTK; + display1 = new vpDisplayGTK; + display2 = new vpDisplayGTK; #else - std::cout << " Sorry, GTK video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, GTK video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpGDI: - std::cout << "Requested GDI display functionnalities..." << std::endl; + break; + case vpGDI: + std::cout << "Requested GDI display functionnalities..." << std::endl; #if defined VISP_HAVE_GDI - display1 = new vpDisplayGDI; - display2 = new vpDisplayGDI; + display1 = new vpDisplayGDI; + display2 = new vpDisplayGDI; #else - std::cout << " Sorry, GDI video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, GDI video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpD3D: - std::cout << "Requested D3D display functionnalities..." << std::endl; + break; + case vpD3D: + std::cout << "Requested D3D display functionnalities..." << std::endl; #if defined VISP_HAVE_D3D9 - display1 = new vpDisplayD3D; - display2 = new vpDisplayD3D; + display1 = new vpDisplayD3D; + display2 = new vpDisplayD3D; #else - std::cout << " Sorry, D3D video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, D3D video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpCV: - std::cout << "Requested OpenCV display functionnalities..." << std::endl; + break; + case vpCV: + std::cout << "Requested OpenCV display functionnalities..." << std::endl; #if defined(VISP_HAVE_OPENCV) - display1 = new vpDisplayOpenCV; - display2 = new vpDisplayOpenCV; + display1 = new vpDisplayOpenCV; + display2 = new vpDisplayOpenCV; #else - std::cout << " Sorry, OpenCV video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, OpenCV video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - } + break; } + } - if(opt_display) - { - display1->init(I1, 0,0, "Display unsigned char"); - display2->init(I2, display1->getWindowXPosition()+display1->getWidth(), display1->getWindowYPosition(), "Display vpRGBa"); - - std::cout << "Start test testUsGeometryDisplayTools" << std::endl; - - usOrientedPlane3D plane(vpPoseVector(0,0,0.05, 0,M_PI/4,0)); - - std::vector points2D(4, vpColVector(2,0)); - points2D.at(0)[0] = 0.02;points2D.at(0)[1] = 0.02; - points2D.at(1)[0] = 0.02;points2D.at(1)[1] = 0.03; - points2D.at(2)[0] = 0.03;points2D.at(2)[1] = 0.03; - points2D.at(3)[0] = 0.02;points2D.at(3)[1] = 0.05; - usPolynomialCurve2D curve2D; - curve2D.defineFromPointsAuto(points2D, points2D.back()-points2D.front(),3); - - std::vector points3D(4, vpColVector(3,0)); - points3D.at(1)[0] = 0.02; - points3D.at(2)[1] = 0.02;points3D.at(2)[2] = 0.03; - points3D.at(3)[2] = 0.05; - usPolynomialCurve3D curve3D; - curve3D.defineFromPointsAuto(points3D, points3D.back()-points3D.front(),3); - - usBSpline3D spline; - std::vector lengths(3); - lengths.at(0) = 0.02;lengths.at(1) = 0.04;lengths.at(2) = 0.04; - spline.defineFromPoints(points3D, lengths, 3); - - vpHomogeneousMatrix imageMworld(0.1, 0.1, 0.1, M_PI/2, 0, 0); - - vpDisplay::display(I1); - vpDisplay::display(I2); - - usGeometryDisplayTools::display(plane, I1, imageMworld, 3000, 3000, vpColor::green); - std::cout << "done: usGeometryDisplayTools::display(const usOrientedPlane3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&);" << std::endl; - usGeometryDisplayTools::display(plane, I2, imageMworld, 3000, 3000, vpColor::green); - std::cout << "done: usGeometryDisplayTools::display(const usOrientedPlane3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&);" << std::endl; - - usGeometryDisplayTools::display(curve2D, I1, 3000, 3000, vpColor::red, 10); - std::cout << "done: usGeometryDisplayTools::display(const usPolynomialCurve2D&, vpImage&, double, double, const vpColor&);" << std::endl; - usGeometryDisplayTools::display(curve2D, I2, 3000, 3000, vpColor::red, 10); - std::cout << "done: usGeometryDisplayTools::display(const usPolynomialCurve2D&, vpImage&, double, double, const vpColor&);" << std::endl; - - usGeometryDisplayTools::display(curve3D, I1, imageMworld, 3000, 3000, vpColor::blue, 10, std::numeric_limits::infinity()); - std::cout << "done: usGeometryDisplayTools::display(const usPolynomialCurve3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&, int, double);" << std::endl; - usGeometryDisplayTools::display(curve3D, I2, imageMworld, 3000, 3000, vpColor::blue, 10, std::numeric_limits::infinity()); - std::cout << "done: usGeometryDisplayTools::display(const usPolynomialCurve3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&, int, double);" << std::endl; - - usGeometryDisplayTools::displayLine(spline, I1, imageMworld, 3000, 3000, vpColor::orange, 10, std::numeric_limits::infinity()); - std::cout << "done: usGeometryDisplayTools::displayLine(const usBSpline3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&, int, double);" << std::endl; - usGeometryDisplayTools::displayLine(spline, I2, imageMworld, 3000, 3000, vpColor::orange, 10, std::numeric_limits::infinity()); - std::cout << "done: usGeometryDisplayTools::displayLine(const usBSpline3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&, int, double);" << std::endl; - - usGeometryDisplayTools::displayExtremities(spline, I1, imageMworld, 3000, 3000, vpColor::orange, std::numeric_limits::infinity()); - std::cout << "done: usGeometryDisplayTools::displayExtremities(const usBSpline3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&, double);" << std::endl; - usGeometryDisplayTools::displayExtremities(spline, I2, imageMworld, 3000, 3000, vpColor::orange, std::numeric_limits::infinity()); - std::cout << "done: usGeometryDisplayTools::displayExtremities(const usBSpline3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&, double);" << std::endl; - - usGeometryDisplayTools::displayCurvatureFromShape(spline, I1, imageMworld, 3000, 3000, vpColor::orange); - std::cout << "done: usGeometryDisplayTools::displayCurvatureFromShape(const usBSpline3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&);" << std::endl; - usGeometryDisplayTools::displayCurvatureFromShape(spline, I2, imageMworld, 3000, 3000, vpColor::orange); - std::cout << "done: usGeometryDisplayTools::displayCurvatureFromShape(const usBSpline3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&);" << std::endl; - - vpDisplay::flush(I1); - vpDisplay::flush(I2); - - vpTime::wait(2000); - - if(display1) delete display1; - if(display2) delete display2; - } - - return 0; + if (opt_display) { + display1->init(I1, 0, 0, "Display unsigned char"); + display2->init(I2, display1->getWindowXPosition()+display1->getWidth(), display1->getWindowYPosition(), "Display vpRGBa"); + + std::cout << "Start test testUsGeometryDisplayTools" << std::endl; + + usOrientedPlane3D plane(vpPoseVector(0, 0, 0.05, 0, M_PI/4, 0)); + + std::vector points2D(4, vpColVector(2, 0)); + points2D.at(0)[0] = 0.02;points2D.at(0)[1] = 0.02; + points2D.at(1)[0] = 0.02;points2D.at(1)[1] = 0.03; + points2D.at(2)[0] = 0.03;points2D.at(2)[1] = 0.03; + points2D.at(3)[0] = 0.02;points2D.at(3)[1] = 0.05; + usPolynomialCurve2D curve2D; + curve2D.defineFromPointsAuto(points2D, points2D.back()-points2D.front(), 3); + + std::vector points3D(4, vpColVector(3, 0)); + points3D.at(1)[0] = 0.02; + points3D.at(2)[1] = 0.02;points3D.at(2)[2] = 0.03; + points3D.at(3)[2] = 0.05; + usPolynomialCurve3D curve3D; + curve3D.defineFromPointsAuto(points3D, points3D.back()-points3D.front(), 3); + + usBSpline3D spline; + std::vector lengths(3); + lengths.at(0) = 0.02;lengths.at(1) = 0.04;lengths.at(2) = 0.04; + spline.defineFromPoints(points3D, lengths, 3); + + vpHomogeneousMatrix imageMworld(0.1, 0.1, 0.1, M_PI/2, 0, 0); + + vpDisplay::display(I1); + vpDisplay::display(I2); + + usGeometryDisplayTools::display(plane, I1, imageMworld, 3000, 3000, vpColor::green); + std::cout << "done: usGeometryDisplayTools::display(const usOrientedPlane3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&);" << std::endl; + usGeometryDisplayTools::display(plane, I2, imageMworld, 3000, 3000, vpColor::green); + std::cout << "done: usGeometryDisplayTools::display(const usOrientedPlane3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&);" << std::endl; + + usGeometryDisplayTools::display(curve2D, I1, 3000, 3000, vpColor::red, 10); + std::cout << "done: usGeometryDisplayTools::display(const usPolynomialCurve2D&, vpImage&, double, double, const vpColor&);" << std::endl; + usGeometryDisplayTools::display(curve2D, I2, 3000, 3000, vpColor::red, 10); + std::cout << "done: usGeometryDisplayTools::display(const usPolynomialCurve2D&, vpImage&, double, double, const vpColor&);" << std::endl; + + usGeometryDisplayTools::display(curve3D, I1, imageMworld, 3000, 3000, vpColor::blue, 10, std::numeric_limits::infinity()); + std::cout << "done: usGeometryDisplayTools::display(const usPolynomialCurve3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&, int, double);" << std::endl; + usGeometryDisplayTools::display(curve3D, I2, imageMworld, 3000, 3000, vpColor::blue, 10, std::numeric_limits::infinity()); + std::cout << "done: usGeometryDisplayTools::display(const usPolynomialCurve3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&, int, double);" << std::endl; + + usGeometryDisplayTools::displayLine(spline, I1, imageMworld, 3000, 3000, vpColor::orange, 10, std::numeric_limits::infinity()); + std::cout << "done: usGeometryDisplayTools::displayLine(const usBSpline3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&, int, double);" << std::endl; + usGeometryDisplayTools::displayLine(spline, I2, imageMworld, 3000, 3000, vpColor::orange, 10, std::numeric_limits::infinity()); + std::cout << "done: usGeometryDisplayTools::displayLine(const usBSpline3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&, int, double);" << std::endl; + + usGeometryDisplayTools::displayExtremities(spline, I1, imageMworld, 3000, 3000, vpColor::orange, std::numeric_limits::infinity()); + std::cout << "done: usGeometryDisplayTools::displayExtremities(const usBSpline3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&, double);" << std::endl; + usGeometryDisplayTools::displayExtremities(spline, I2, imageMworld, 3000, 3000, vpColor::orange, std::numeric_limits::infinity()); + std::cout << "done: usGeometryDisplayTools::displayExtremities(const usBSpline3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&, double);" << std::endl; + + usGeometryDisplayTools::displayCurvatureFromShape(spline, I1, imageMworld, 3000, 3000, vpColor::orange); + std::cout << "done: usGeometryDisplayTools::displayCurvatureFromShape(const usBSpline3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&);" << std::endl; + usGeometryDisplayTools::displayCurvatureFromShape(spline, I2, imageMworld, 3000, 3000, vpColor::orange); + std::cout << "done: usGeometryDisplayTools::displayCurvatureFromShape(const usBSpline3D&, vpImage&, const vpHomogeneousMatrix&, double, double, const vpColor&);" << std::endl; + + vpDisplay::flush(I1); + vpDisplay::flush(I2); + + vpTime::wait(2000); + + if (display1) delete display1; + if (display2) delete display2; + } + + return 0; } diff --git a/modules/ustk_core/test/geometry/testUsOrientedPlane3D.cpp b/modules/ustk_core/test/geometry/testUsOrientedPlane3D.cpp index feb7b5b7..dce67edc 100644 --- a/modules/ustk_core/test/geometry/testUsOrientedPlane3D.cpp +++ b/modules/ustk_core/test/geometry/testUsOrientedPlane3D.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main() { std::cout << "Start testUsOrientedPlane3D" << std::endl; diff --git a/modules/ustk_core/test/geometry/testUsPolynomialCurve2D.cpp b/modules/ustk_core/test/geometry/testUsPolynomialCurve2D.cpp index 3a637049..1ac29d73 100644 --- a/modules/ustk_core/test/geometry/testUsPolynomialCurve2D.cpp +++ b/modules/ustk_core/test/geometry/testUsPolynomialCurve2D.cpp @@ -43,6 +43,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main() { std::cout << "Start testUsPolynomialCurve2D" << std::endl; @@ -154,64 +158,64 @@ int main() curve.defineFromPoints(points1, params1, 4); std::cout << "done: case 1 usPolynomialCurve2D::defineFromPoints(const std::vector &points, const " - "std::vector ¶m, unsigned int order)" - << std::endl; + "std::vector ¶m, unsigned int order)" + << std::endl; curve.defineFromPoints(points2, params2, 4); std::cout << "done: case 2 usPolynomialCurve2D::defineFromPoints(const std::vector &points, const " - "std::vector ¶m, unsigned int order)" - << std::endl; + "std::vector ¶m, unsigned int order)" + << std::endl; curve.defineFromPoints(point3M, params3V, 3); std::cout << "done: case 3 usPolynomialCurve2D::defineFromPoints(const std::vector &points, const " - "std::vector ¶m, unsigned int order)" - << std::endl; + "std::vector ¶m, unsigned int order)" + << std::endl; curve.defineFromPoints(points3, params3, 3); std::cout << "done: usPolynomialCurve2D::defineFromPoints(const vpMatrix points, const vpColVector ¶m, unsigned " - "int order)" - << std::endl; + "int order)" + << std::endl; curve.defineFromPointsAuto(points3, 3); std::cout - << "done: usPolynomialCurve2D::defineFromPointsAuto(const std::vector &points, unsigned int order)" - << std::endl; + << "done: usPolynomialCurve2D::defineFromPointsAuto(const std::vector &points, unsigned int order)" + << std::endl; curve.defineFromPointsAuto(point3M, 3); std::cout << "done: usPolynomialCurve2D::defineFromPointsAuto(const vpMatrix &points, unsigned int order)" - << std::endl; + << std::endl; vpColVector direction(2, 0); direction[0] = 1; curve.defineFromPointsAuto(points3, direction, 3); std::cout << "done: usPolynomialCurve2D::defineFromPointsAuto(const std::vector &points, const " - "vpColVector &direction, unsigned int order)" - << std::endl; + "vpColVector &direction, unsigned int order)" + << std::endl; curve.defineFromPointsAuto(point3M, direction, 3); std::cout << "done: usPolynomialCurve2D::defineFromPointsAuto(const vpMatrix &points, const vpColVector &direction, " - "unsigned int order)" - << std::endl; + "unsigned int order)" + << std::endl; curve.defineFromWeightedPoints(points3, params3, weights3, 3); std::cout << "done: usPolynomialCurve2D::defineFromWeightedPoints(const std::vector &points, const " - "std::vector ¶m, const std::vector &weights, unsigned int order)" - << std::endl; + "std::vector ¶m, const std::vector &weights, unsigned int order)" + << std::endl; curve.defineFromWeightedPoints(point3M, params3V, weights3V, 3); std::cout << "done: usPolynomialCurve2D::defineFromWeightedPoints(const vpMatrix &points, const vpColVector ¶m, " - "const vpColVector &weights, unsigned int order)" - << std::endl; + "const vpColVector &weights, unsigned int order)" + << std::endl; curve.defineFromWeightedPointsAuto(points3, weights3, 3); std::cout << "done: usPolynomialCurve2D::defineFromWeightedPointsAuto(const std::vector &points, const " - "std::vector &weights, unsigned int order)" - << std::endl; + "std::vector &weights, unsigned int order)" + << std::endl; curve.defineFromWeightedPointsAuto(point3M, weights3V, 3); std::cout << "done: usPolynomialCurve2D::defineFromWeightedPointsAuto(const vpMatrix &points, const vpColVector " - "&weights, unsigned int order)" - << std::endl; + "&weights, unsigned int order)" + << std::endl; curve.defineFromWeightedPointsAuto(points3, weights3, direction, 3); std::cout << "done: usPolynomialCurve2D::defineFromWeightedPointsAuto(const std::vector &points, const " - "std::vector &weights, const vpColVector &direction, unsigned int order)" - << std::endl; + "std::vector &weights, const vpColVector &direction, unsigned int order)" + << std::endl; curve.defineFromWeightedPointsAuto(point3M, weights3V, direction, 3); std::cout << "done: usPolynomialCurve2D::defineFromWeightedPointsAuto(const vpMatrix &points, const vpColVector " - "&weights, const vpColVector &direction, unsigned int order)" - << std::endl; + "&weights, const vpColVector &direction, unsigned int order)" + << std::endl; curve.getCurvature(0.25); std::cout << "done: usPolynomialCurve2D::getCurvature" << std::endl; diff --git a/modules/ustk_core/test/geometry/testUsPolynomialCurve3D.cpp b/modules/ustk_core/test/geometry/testUsPolynomialCurve3D.cpp index b4e02598..33bd2261 100644 --- a/modules/ustk_core/test/geometry/testUsPolynomialCurve3D.cpp +++ b/modules/ustk_core/test/geometry/testUsPolynomialCurve3D.cpp @@ -44,6 +44,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main() { std::cout << "Start testUsPolynomialCurve3D" << std::endl; @@ -155,64 +159,64 @@ int main() curve.defineFromPoints(points1, params1, 4); std::cout << "done: case 1 usPolynomialCurve3D::defineFromPoints(const std::vector &points, const " - "std::vector ¶m, unsigned int order)" - << std::endl; + "std::vector ¶m, unsigned int order)" + << std::endl; curve.defineFromPoints(points2, params2, 4); std::cout << "done: case 2 usPolynomialCurve3D::defineFromPoints(const std::vector &points, const " - "std::vector ¶m, unsigned int order)" - << std::endl; + "std::vector ¶m, unsigned int order)" + << std::endl; curve.defineFromPoints(point3M, params3V, 3); std::cout << "done: case 3 usPolynomialCurve3D::defineFromPoints(const std::vector &points, const " - "std::vector ¶m, unsigned int order)" - << std::endl; + "std::vector ¶m, unsigned int order)" + << std::endl; curve.defineFromPoints(points3, params3, 3); std::cout << "done: usPolynomialCurve3D::defineFromPoints(const vpMatrix points, const vpColVector ¶m, unsigned " - "int order)" - << std::endl; + "int order)" + << std::endl; curve.defineFromPointsAuto(points3, 3); std::cout - << "done: usPolynomialCurve3D::defineFromPointsAuto(const std::vector &points, unsigned int order)" - << std::endl; + << "done: usPolynomialCurve3D::defineFromPointsAuto(const std::vector &points, unsigned int order)" + << std::endl; curve.defineFromPointsAuto(point3M, 3); std::cout << "done: usPolynomialCurve3D::defineFromPointsAuto(const vpMatrix &points, unsigned int order)" - << std::endl; + << std::endl; vpColVector direction(3, 0); direction[0] = 1; curve.defineFromPointsAuto(points3, direction, 3); std::cout << "done: usPolynomialCurve3D::defineFromPointsAuto(const std::vector &points, const " - "vpColVector &direction, unsigned int order)" - << std::endl; + "vpColVector &direction, unsigned int order)" + << std::endl; curve.defineFromPointsAuto(point3M, direction, 3); std::cout << "done: usPolynomialCurve3D::defineFromPointsAuto(const vpMatrix &points, const vpColVector &direction, " - "unsigned int order)" - << std::endl; + "unsigned int order)" + << std::endl; curve.defineFromWeightedPoints(points3, params3, weights3, 3); std::cout << "done: usPolynomialCurve3D::defineFromWeightedPoints(const std::vector &points, const " - "std::vector ¶m, const std::vector &weights, unsigned int order)" - << std::endl; + "std::vector ¶m, const std::vector &weights, unsigned int order)" + << std::endl; curve.defineFromWeightedPoints(point3M, params3V, weights3V, 3); std::cout << "done: usPolynomialCurve3D::defineFromWeightedPoints(const vpMatrix &points, const vpColVector ¶m, " - "const vpColVector &weights, unsigned int order)" - << std::endl; + "const vpColVector &weights, unsigned int order)" + << std::endl; curve.defineFromWeightedPointsAuto(points3, weights3, 3); std::cout << "done: usPolynomialCurve3D::defineFromWeightedPointsAuto(const std::vector &points, const " - "std::vector &weights, unsigned int order)" - << std::endl; + "std::vector &weights, unsigned int order)" + << std::endl; curve.defineFromWeightedPointsAuto(point3M, weights3V, 3); std::cout << "done: usPolynomialCurve3D::defineFromWeightedPointsAuto(const vpMatrix &points, const vpColVector " - "&weights, unsigned int order)" - << std::endl; + "&weights, unsigned int order)" + << std::endl; curve.defineFromWeightedPointsAuto(points3, weights3, direction, 3); std::cout << "done: usPolynomialCurve3D::defineFromWeightedPointsAuto(const std::vector &points, const " - "std::vector &weights, const vpColVector &direction, unsigned int order)" - << std::endl; + "std::vector &weights, const vpColVector &direction, unsigned int order)" + << std::endl; curve.defineFromWeightedPointsAuto(point3M, weights3V, direction, 3); std::cout << "done: usPolynomialCurve3D::defineFromWeightedPointsAuto(const vpMatrix &points, const vpColVector " - "&weights, const vpColVector &direction, unsigned int order)" - << std::endl; + "&weights, const vpColVector &direction, unsigned int order)" + << std::endl; curve.getCurvature(0.25); std::cout << "done: usPolynomialCurve3D::getCurvature" << std::endl; diff --git a/modules/ustk_core/test/meterConversion/testUsMeterConversion.cpp b/modules/ustk_core/test/meterConversion/testUsMeterConversion.cpp index c1faa6d6..f46b758e 100644 --- a/modules/ustk_core/test/meterConversion/testUsMeterConversion.cpp +++ b/modules/ustk_core/test/meterConversion/testUsMeterConversion.cpp @@ -46,6 +46,10 @@ /* MAIN FUNCTION */ /* -------------------------------------------------------------------------- */ +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, const char **argv) { bool testFailed = false; @@ -60,8 +64,8 @@ int main(int argc, const char **argv) std::cout << "-------------------------------------------------------" << std::endl; std::cout << " testUsMeterConversion.cpp" << std::endl << std::endl; std::cout << " The test converts a pixel position to a meter position, and converts it back to pixel conversion." - " Then it checks if it is the same position." - << std::endl; + " Then it checks if it is the same position." + << std::endl; std::cout << "-------------------------------------------------------" << std::endl; std::cout << std::endl; @@ -93,7 +97,7 @@ int main(int argc, const char **argv) usImagePostScan2DReference.setHeightResolution(0.0018); std::cout << "before conversion, u = " << std::scientific << UBase << ", and v = " << std::scientific << VBase - << std::endl; + << std::endl; usPixelMeterConversion::convert(usImagePostScan2DReference, UBase, VBase, X, Y); @@ -102,7 +106,7 @@ int main(int argc, const char **argv) usMeterPixelConversion::convert(usImagePostScan2DReference, X, Y, U, V); std::cout << "after back conversion, u = " << std::scientific << U << ", and v = " << std::scientific << V - << std::endl; + << std::endl; std::cout << "|U - UBase| = " << std::abs(U - UBase) << std::endl; std::cout << "|UBase * epsilon| = " << std::abs(std::numeric_limits::epsilon() * UBase) << std::endl; @@ -121,7 +125,7 @@ int main(int argc, const char **argv) usImagePostScan2DReference.setTransducerConvexity(false); std::cout << "before conversion, u = " << std::scientific << UBase << ", and v = " << std::scientific << VBase - << std::endl; + << std::endl; usPixelMeterConversion::convert(usImagePostScan2DReference, UBase, VBase, X, Y); @@ -130,7 +134,7 @@ int main(int argc, const char **argv) usMeterPixelConversion::convert(usImagePostScan2DReference, X, Y, U, V); std::cout << "after back conversion, u = " << std::scientific << U << ", and v = " << std::scientific << V - << std::endl; + << std::endl; std::cout << "|U - UBase| = " << std::abs(U - UBase) << std::endl; std::cout << "|UBase * epsilon| = " << std::abs(std::numeric_limits::epsilon() * UBase) << std::endl; diff --git a/modules/ustk_core/test/mhd/testUsImagePostScan2DMhdParser.cpp b/modules/ustk_core/test/mhd/testUsImagePostScan2DMhdParser.cpp index 6483d921..8887864e 100644 --- a/modules/ustk_core/test/mhd/testUsImagePostScan2DMhdParser.cpp +++ b/modules/ustk_core/test/mhd/testUsImagePostScan2DMhdParser.cpp @@ -71,6 +71,10 @@ UltrasoundImageType = POSTSCAN_2D // List of allowed command line options #define GETOPTARGS "cdo:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, const std::string &opath, const std::string &user); bool getOptions(int argc, const char **argv, std::string &opath, const std::string &user); @@ -204,7 +208,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(dirname); - } catch (...) { + } + catch (...) { usage(argv[0], NULL, opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << dirname << std::endl; @@ -248,7 +253,8 @@ int main(int argc, const char **argv) std::cout << "Test failed !" << std::endl; return 1; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; return 1; } diff --git a/modules/ustk_core/test/mhd/testUsImagePostScan3DMhdParser.cpp b/modules/ustk_core/test/mhd/testUsImagePostScan3DMhdParser.cpp index 4a296d70..1145935c 100644 --- a/modules/ustk_core/test/mhd/testUsImagePostScan3DMhdParser.cpp +++ b/modules/ustk_core/test/mhd/testUsImagePostScan3DMhdParser.cpp @@ -71,6 +71,10 @@ UltrasoundImageType = POSTSCAN_3D // List of allowed command line options #define GETOPTARGS "cdo:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, const std::string &opath, const std::string &user); bool getOptions(int argc, const char **argv, std::string &opath, const std::string &user); @@ -204,7 +208,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(dirname); - } catch (...) { + } + catch (...) { usage(argv[0], NULL, opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << dirname << std::endl; @@ -258,7 +263,8 @@ int main(int argc, const char **argv) std::cout << "Test failed !" << std::endl; return 1; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; return 1; } diff --git a/modules/ustk_core/test/mhd/testUsImagePreScan2DMhdParser.cpp b/modules/ustk_core/test/mhd/testUsImagePreScan2DMhdParser.cpp index 421f91ba..da6d3908 100644 --- a/modules/ustk_core/test/mhd/testUsImagePreScan2DMhdParser.cpp +++ b/modules/ustk_core/test/mhd/testUsImagePreScan2DMhdParser.cpp @@ -73,6 +73,10 @@ UltrasoundImageType = PRESCAN_2D // List of allowed command line options #define GETOPTARGS "cdo:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, const std::string &opath, const std::string &user); bool getOptions(int argc, const char **argv, std::string &opath, const std::string &user); @@ -204,7 +208,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(dirname); - } catch (...) { + } + catch (...) { usage(argv[0], NULL, opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << dirname << std::endl; @@ -246,7 +251,8 @@ int main(int argc, const char **argv) std::cout << "Test failed !" << std::endl; return 1; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; return 1; } diff --git a/modules/ustk_core/test/mhd/testUsImagePreScan3DMhdParser.cpp b/modules/ustk_core/test/mhd/testUsImagePreScan3DMhdParser.cpp index 57d3641f..4e81a4ce 100644 --- a/modules/ustk_core/test/mhd/testUsImagePreScan3DMhdParser.cpp +++ b/modules/ustk_core/test/mhd/testUsImagePreScan3DMhdParser.cpp @@ -71,6 +71,10 @@ UltrasoundImageType = PRESCAN_3D // List of allowed command line options #define GETOPTARGS "cdo:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, const std::string &opath, const std::string &user); bool getOptions(int argc, const char **argv, std::string &opath, const std::string &user); @@ -204,7 +208,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(dirname); - } catch (...) { + } + catch (...) { usage(argv[0], NULL, opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << dirname << std::endl; @@ -251,7 +256,8 @@ int main(int argc, const char **argv) std::cout << "Test failed !" << std::endl; return 1; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; return 1; } diff --git a/modules/ustk_core/test/mhd/testUsImageRf2DMhdParser.cpp b/modules/ustk_core/test/mhd/testUsImageRf2DMhdParser.cpp index d3dfcd31..69222757 100644 --- a/modules/ustk_core/test/mhd/testUsImageRf2DMhdParser.cpp +++ b/modules/ustk_core/test/mhd/testUsImageRf2DMhdParser.cpp @@ -69,6 +69,10 @@ UltrasoundImageType = RF_2D // List of allowed command line options #define GETOPTARGS "cdo:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, const std::string &opath, const std::string &user); bool getOptions(int argc, const char **argv, std::string &opath, const std::string &user); @@ -202,7 +206,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(dirname); - } catch (...) { + } + catch (...) { usage(argv[0], NULL, opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << dirname << std::endl; @@ -244,7 +249,8 @@ int main(int argc, const char **argv) std::cout << "Test failed !" << std::endl; return 1; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; return 1; } diff --git a/modules/ustk_core/test/mhd/testUsImageRf3DMhdParser.cpp b/modules/ustk_core/test/mhd/testUsImageRf3DMhdParser.cpp index 996da966..dcfde559 100644 --- a/modules/ustk_core/test/mhd/testUsImageRf3DMhdParser.cpp +++ b/modules/ustk_core/test/mhd/testUsImageRf3DMhdParser.cpp @@ -70,6 +70,10 @@ UltrasoundImageType = RF_3D // List of allowed command line options #define GETOPTARGS "cdo:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, const std::string &opath, const std::string &user); bool getOptions(int argc, const char **argv, std::string &opath, const std::string &user); @@ -203,7 +207,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(dirname); - } catch (...) { + } + catch (...) { usage(argv[0], NULL, opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << dirname << std::endl; @@ -248,7 +253,8 @@ int main(int argc, const char **argv) std::cout << "Test failed !" << std::endl; return 1; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; return 1; } diff --git a/modules/ustk_core/test/scanConversion/testUsScanConversion.cpp b/modules/ustk_core/test/scanConversion/testUsScanConversion.cpp index 50d5ee0e..77a754e9 100644 --- a/modules/ustk_core/test/scanConversion/testUsScanConversion.cpp +++ b/modules/ustk_core/test/scanConversion/testUsScanConversion.cpp @@ -50,6 +50,10 @@ /* MAIN FUNCTION */ /* -------------------------------------------------------------------------- */ #if defined(VISP_HAVE_XML2) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, const char **argv) { (void)argc; @@ -63,8 +67,8 @@ int main(int argc, const char **argv) std::cout << "-------------------------------------------------------" << std::endl; std::cout << " testUsScanConversion2D.cpp" << std::endl << std::endl; std::cout << " The test converts a pre-scan image to post-scan, and converts it back to pre-scan." - " Then it checks if the difference between the 2 images, using sum of square differences." - << std::endl; + " Then it checks if the difference between the 2 images, using sum of square differences." + << std::endl; std::cout << "-------------------------------------------------------" << std::endl; std::cout << std::endl; @@ -90,7 +94,8 @@ int main(int argc, const char **argv) for (unsigned int j = 0; j < prescanBack.getWidth(); j++) { if (i > 3 && j > 3) { // we skip top & left borders, they have huge differencies compared to the rest of the image inc += (prescanBack[i][j] - prescanReference[i][j]) * (prescanBack[i][j] - prescanReference[i][j]); - } else { + } + else { pxSkipped++; } } diff --git a/modules/ustk_core/test/scanConversion/testUsScanConversion3D.cpp b/modules/ustk_core/test/scanConversion/testUsScanConversion3D.cpp index 91d110ef..a0a5e59c 100644 --- a/modules/ustk_core/test/scanConversion/testUsScanConversion3D.cpp +++ b/modules/ustk_core/test/scanConversion/testUsScanConversion3D.cpp @@ -33,6 +33,9 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif int main(int argc, const char **argv) { @@ -56,15 +59,15 @@ int main(int argc, const char **argv) // Fill pre-scan volume with some data usImage3D I(sampleNumber, scanLineNumber, frameNumber); - for(unsigned int k=0 ; k postscan[18]; - - usPreScanToPostScan3DConverter::usConverterOptimizationMethod optMethod[9] = - {usPreScanToPostScan3DConverter::SINGLE_THREAD_DIRECT_CONVERSION, - usPreScanToPostScan3DConverter::MULTI_THREAD_DIRECT_CONVERSION, - usPreScanToPostScan3DConverter::GPU_DIRECT_CONVERSION, - usPreScanToPostScan3DConverter::SINGLE_THREAD_REDUCED_LOOKUP_TABLE, - usPreScanToPostScan3DConverter::MULTI_THREAD_REDUCED_LOOKUP_TABLE, - usPreScanToPostScan3DConverter::GPU_REDUCED_LOOKUP_TABLE, - usPreScanToPostScan3DConverter::SINGLE_THREAD_FULL_LOOKUP_TABLE, - usPreScanToPostScan3DConverter::MULTI_THREAD_FULL_LOOKUP_TABLE, - usPreScanToPostScan3DConverter::GPU_FULL_LOOKUP_TABLE}; - - char method[9][35] = - {"SINGLE_THREAD_DIRECT_CONVERSION", - "MULTI_THREAD_DIRECT_CONVERSION", - "GPU_DIRECT_CONVERSION", - "SINGLE_THREAD_REDUCED_LOOKUP_TABLE", - "MULTI_THREAD_REDUCED_LOOKUP_TABLE", - "GPU_REDUCED_LOOKUP_TABLE", - "SINGLE_THREAD_FULL_LOOKUP_TABLE", - "MULTI_THREAD_FULL_LOOKUP_TABLE", - "GPU_FULL_LOOKUP_TABLE"}; - - for(int i=0 ; i<9 ; i++) - { + + usPreScanToPostScan3DConverter::usConverterOptimizationMethod optMethod[9] = + { usPreScanToPostScan3DConverter::SINGLE_THREAD_DIRECT_CONVERSION, + usPreScanToPostScan3DConverter::MULTI_THREAD_DIRECT_CONVERSION, + usPreScanToPostScan3DConverter::GPU_DIRECT_CONVERSION, + usPreScanToPostScan3DConverter::SINGLE_THREAD_REDUCED_LOOKUP_TABLE, + usPreScanToPostScan3DConverter::MULTI_THREAD_REDUCED_LOOKUP_TABLE, + usPreScanToPostScan3DConverter::GPU_REDUCED_LOOKUP_TABLE, + usPreScanToPostScan3DConverter::SINGLE_THREAD_FULL_LOOKUP_TABLE, + usPreScanToPostScan3DConverter::MULTI_THREAD_FULL_LOOKUP_TABLE, + usPreScanToPostScan3DConverter::GPU_FULL_LOOKUP_TABLE }; + + char method[9][35] = + { "SINGLE_THREAD_DIRECT_CONVERSION", + "MULTI_THREAD_DIRECT_CONVERSION", + "GPU_DIRECT_CONVERSION", + "SINGLE_THREAD_REDUCED_LOOKUP_TABLE", + "MULTI_THREAD_REDUCED_LOOKUP_TABLE", + "GPU_REDUCED_LOOKUP_TABLE", + "SINGLE_THREAD_FULL_LOOKUP_TABLE", + "MULTI_THREAD_FULL_LOOKUP_TABLE", + "GPU_FULL_LOOKUP_TABLE" }; + + for (int i = 0; i<9; i++) { std::cout << "---------- Optimization method: " << method[i] << std::endl; usPreScanToPostScan3DConverter converter; - try - { + try { converter.setConverterOptimizationMethod(optMethod[i]); std::cout << "---- Converter initialization:" << std::endl; double t = vpTime::measureTimeMs(); @@ -126,11 +127,10 @@ int main(int argc, const char **argv) std::cout << "Timing: " << vpTime::measureTimeMs()-t << std::endl; std::cout << "---- End of conversion" << std::endl; } - catch(std::exception &e) - { + catch (std::exception &e) { std::cout << e.what() << std::endl; } - } - + } + return 0; } diff --git a/modules/ustk_core/test/sequence/testUsSequenceIOXml.cpp b/modules/ustk_core/test/sequence/testUsSequenceIOXml.cpp index 25355ba8..d81dd8d2 100644 --- a/modules/ustk_core/test/sequence/testUsSequenceIOXml.cpp +++ b/modules/ustk_core/test/sequence/testUsSequenceIOXml.cpp @@ -54,6 +54,10 @@ // List of allowed command line options #define GETOPTARGS "cdo:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, const std::string &opath, const std::string &user); bool getOptions(int argc, const char **argv, std::string &opath, const std::string &user); @@ -185,7 +189,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(dirname); - } catch (...) { + } + catch (...) { usage(argv[0], NULL, opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << dirname << std::endl; @@ -296,7 +301,8 @@ int main(int argc, const char **argv) vpXmlParser::cleanup(); std::cout << "Test exit code : " << (int)!testPassed << std::endl; return !testPassed; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; return 1; } diff --git a/modules/ustk_core/test/xml/testUsImagePostScan2DXmlParser.cpp b/modules/ustk_core/test/xml/testUsImagePostScan2DXmlParser.cpp index e9ad5e2f..6a8e8201 100644 --- a/modules/ustk_core/test/xml/testUsImagePostScan2DXmlParser.cpp +++ b/modules/ustk_core/test/xml/testUsImagePostScan2DXmlParser.cpp @@ -72,6 +72,10 @@ // List of allowed command line options #define GETOPTARGS "cdo:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, const std::string &opath, const std::string &user); bool getOptions(int argc, const char **argv, std::string &opath, const std::string &user); @@ -203,7 +207,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(dirname); - } catch (...) { + } + catch (...) { usage(argv[0], NULL, opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << dirname << std::endl; @@ -246,7 +251,8 @@ int main(int argc, const char **argv) vpXmlParser::cleanup(); std::cout << "Test failed !" << std::endl; return 1; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; return 1; } diff --git a/modules/ustk_core/test/xml/testUsImagePreScan2DXmlParser.cpp b/modules/ustk_core/test/xml/testUsImagePreScan2DXmlParser.cpp index c014bd5c..7a2e12a4 100644 --- a/modules/ustk_core/test/xml/testUsImagePreScan2DXmlParser.cpp +++ b/modules/ustk_core/test/xml/testUsImagePreScan2DXmlParser.cpp @@ -72,6 +72,10 @@ // List of allowed command line options #define GETOPTARGS "cdo:h" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usage(const char *name, const char *badparam, const std::string &opath, const std::string &user); bool getOptions(int argc, const char **argv, std::string &opath, const std::string &user); @@ -203,7 +207,8 @@ int main(int argc, const char **argv) try { // Create the dirname vpIoTools::makeDirectory(dirname); - } catch (...) { + } + catch (...) { usage(argv[0], NULL, opath, username); std::cerr << std::endl << "ERROR:" << std::endl; std::cerr << " Cannot create " << dirname << std::endl; @@ -247,7 +252,8 @@ int main(int argc, const char **argv) vpXmlParser::cleanup(); std::cout << "Test failed !" << std::endl; return 1; - } catch (const vpException &e) { + } + catch (const vpException &e) { std::cout << "Catch an exception: " << e.getMessage() << std::endl; return 1; } diff --git a/modules/ustk_elastography/include/visp3/ustk_elastography/usConvolution2d.h b/modules/ustk_elastography/include/visp3/ustk_elastography/usConvolution2d.h index 5ce9624a..793d003f 100644 --- a/modules/ustk_elastography/include/visp3/ustk_elastography/usConvolution2d.h +++ b/modules/ustk_elastography/include/visp3/ustk_elastography/usConvolution2d.h @@ -59,8 +59,8 @@ class VISP_EXPORT usConvolution2d public: usConvolution2d(); virtual ~usConvolution2d(); - void init(const vpMatrix &matrix1, const vpMatrix &matrix2); - vpMatrix run(const vpMatrix &matrix1, const vpMatrix &matrix2); + void init(const VISP_NAMESPACE_ADDRESSING vpMatrix &matrix1, const VISP_NAMESPACE_ADDRESSING vpMatrix &matrix2); + VISP_NAMESPACE_ADDRESSING vpMatrix run(const VISP_NAMESPACE_ADDRESSING vpMatrix &matrix1, const VISP_NAMESPACE_ADDRESSING vpMatrix &matrix2); private: fftw_complex *outa; @@ -75,9 +75,9 @@ class VISP_EXPORT usConvolution2d bool m_init; - vpMatrix m_M1; - vpMatrix m_M2; - vpMatrix m_R; + VISP_NAMESPACE_ADDRESSING vpMatrix m_M1; + VISP_NAMESPACE_ADDRESSING vpMatrix m_M2; + VISP_NAMESPACE_ADDRESSING vpMatrix m_R; unsigned int h_dst; unsigned int w_dst; unsigned int hf; diff --git a/modules/ustk_elastography/include/visp3/ustk_elastography/usElastography.h b/modules/ustk_elastography/include/visp3/ustk_elastography/usElastography.h index c254d3ab..f03d1290 100644 --- a/modules/ustk_elastography/include/visp3/ustk_elastography/usElastography.h +++ b/modules/ustk_elastography/include/visp3/ustk_elastography/usElastography.h @@ -72,7 +72,7 @@ class VISP_EXPORT usElastography double getFPS(void) { return m_FPS; } double getSamplingFrequency(void) { return m_samplingFrequency; } - vpImage run(); + VISP_NAMESPACE_ADDRESSING vpImage run(); void setDecimationFactor(unsigned int decimationFactor) { m_decimationFactor = decimationFactor; } void setFPS(double fps); @@ -89,7 +89,7 @@ class VISP_EXPORT usElastography private: usImageRF2D usImageRF_ROI(const usImageRF2D &M, uint r, uint c, uint nrows, uint ncols); - vpImage m_StrainMap; + VISP_NAMESPACE_ADDRESSING vpImage m_StrainMap; usImageRF2D m_Precomp; usImageRF2D m_Postcomp; @@ -122,8 +122,8 @@ class VISP_EXPORT usElastography usMotionEstimation m_ME; #endif - vpMatrix U; - vpMatrix V; + VISP_NAMESPACE_ADDRESSING vpMatrix U; + VISP_NAMESPACE_ADDRESSING vpMatrix V; unsigned int m_decimationFactor; }; diff --git a/modules/ustk_elastography/include/visp3/ustk_elastography/usImageElastography.h b/modules/ustk_elastography/include/visp3/ustk_elastography/usImageElastography.h index 9737cc8e..502b31ec 100644 --- a/modules/ustk_elastography/include/visp3/ustk_elastography/usImageElastography.h +++ b/modules/ustk_elastography/include/visp3/ustk_elastography/usImageElastography.h @@ -39,6 +39,8 @@ #ifndef __usImageElastography_h_ #define __usImageElastography_h_ +#include +#include #include #include #include @@ -69,21 +71,21 @@ class VISP_EXPORT usImageElastography public: usImageElastography(); - usImageElastography(const vpImage &ultrasoundImage, const vpImage &strainMap, + usImageElastography(const VISP_NAMESPACE_ADDRESSING vpImage &ultrasoundImage, const VISP_NAMESPACE_ADDRESSING vpImage &strainMap, unsigned int heightPosition, unsigned int widthPosition); virtual ~usImageElastography(); - vpImage getElastoImage(); + VISP_NAMESPACE_ADDRESSING vpImage getElastoImage(); - void setStrainMap(const vpImage &strainMap, unsigned int heightPosition, unsigned int widthPosition); - void setUltrasoundImage(const vpImage &ultrasoundImage); + void setStrainMap(const VISP_NAMESPACE_ADDRESSING vpImage &strainMap, unsigned int heightPosition, unsigned int widthPosition); + void setUltrasoundImage(const VISP_NAMESPACE_ADDRESSING vpImage &ultrasoundImage); private: void computeElastographyImage(); - vpImage m_ultrasoundImage; - vpImage m_strainMap; - vpImage m_elastoImage; + VISP_NAMESPACE_ADDRESSING vpImage m_ultrasoundImage; + VISP_NAMESPACE_ADDRESSING vpImage m_strainMap; + VISP_NAMESPACE_ADDRESSING vpImage m_elastoImage; unsigned int m_heigthPosition; unsigned int m_widthPosition; diff --git a/modules/ustk_elastography/include/visp3/ustk_elastography/usMotionEstimation.h b/modules/ustk_elastography/include/visp3/ustk_elastography/usMotionEstimation.h index c3b8104f..957fad38 100644 --- a/modules/ustk_elastography/include/visp3/ustk_elastography/usMotionEstimation.h +++ b/modules/ustk_elastography/include/visp3/ustk_elastography/usMotionEstimation.h @@ -87,12 +87,12 @@ class VISP_EXPORT usMotionEstimation mat MedianFilt2D(mat M, int kw, int kh); mat getU(void) { return m_U; } mat getV(void) { return m_V; } - vpMatrix getU_vp(void) { return convert_mat2vpMatrix(m_U); } - vpMatrix getV_vp(void) { return convert_mat2vpMatrix(m_V); } + VISP_NAMESPACE_ADDRESSING vpMatrix getU_vp(void) { return convert_mat2vpMatrix(m_U); } + VISP_NAMESPACE_ADDRESSING vpMatrix getV_vp(void) { return convert_mat2vpMatrix(m_V); } void saveU(const char *t_s); void saveV(const char *t_s); mat convert_usImageRF2mat(const usImageRF2D &vI); - vpMatrix convert_mat2vpMatrix(mat vI); + VISP_NAMESPACE_ADDRESSING vpMatrix convert_mat2vpMatrix(mat vI); private: mat m_M1; diff --git a/modules/ustk_elastography/include/visp3/ustk_elastography/usSignalProcessing.h b/modules/ustk_elastography/include/visp3/ustk_elastography/usSignalProcessing.h index 05d0894d..988f4afb 100644 --- a/modules/ustk_elastography/include/visp3/ustk_elastography/usSignalProcessing.h +++ b/modules/ustk_elastography/include/visp3/ustk_elastography/usSignalProcessing.h @@ -40,6 +40,7 @@ * interpolation). */ +#include #include #include @@ -74,16 +75,16 @@ class VISP_EXPORT usSignalProcessing /// Virtual destructor virtual ~usSignalProcessing(); /// Gaussian Kernel generator - static vpMatrix GaussianFilter(int height, int width, double sigma); + static VISP_NAMESPACE_ADDRESSING vpMatrix GaussianFilter(int height, int width, double sigma); /// Computation of gradients - static vpMatrix getXGradient(const usImageRF2D &image); - static vpMatrix getYGradient(const usImageRF2D &image); + static VISP_NAMESPACE_ADDRESSING vpMatrix getXGradient(const usImageRF2D &image); + static VISP_NAMESPACE_ADDRESSING vpMatrix getYGradient(const usImageRF2D &image); // Diference between usImageRF2D - static vpMatrix Difference(const usImageRF2D &A, const usImageRF2D &B); + static VISP_NAMESPACE_ADDRESSING vpMatrix Difference(const usImageRF2D &A, const usImageRF2D &B); /// Bilinear Interpolation - static vpMatrix BilinearInterpolation(vpMatrix In, uint newW, uint newH); + static VISP_NAMESPACE_ADDRESSING vpMatrix BilinearInterpolation(VISP_NAMESPACE_ADDRESSING vpMatrix In, uint newW, uint newH); /// Element-wise product - static vpMatrix HadamardProd(vpMatrix matrix1, vpMatrix matrix2); + static VISP_NAMESPACE_ADDRESSING vpMatrix HadamardProd(VISP_NAMESPACE_ADDRESSING vpMatrix matrix1, VISP_NAMESPACE_ADDRESSING vpMatrix matrix2); }; #endif // __usSignalProcessing_h_ diff --git a/modules/ustk_elastography/src/usConvolution2d.cpp b/modules/ustk_elastography/src/usConvolution2d.cpp index c4f60629..58f1aac2 100644 --- a/modules/ustk_elastography/src/usConvolution2d.cpp +++ b/modules/ustk_elastography/src/usConvolution2d.cpp @@ -35,14 +35,17 @@ #if defined(USTK_HAVE_FFTW) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Default constructor. * It only initializes the pointers class members to NULL. */ usConvolution2d::usConvolution2d() : outa(NULL), outb(NULL), outc(NULL), out(NULL), ad(NULL), bd(NULL), p1(), p2(), p3(), m_init(false) -{ -} +{ } /** * Destructor. @@ -112,7 +115,8 @@ void usConvolution2d::init(const vpMatrix &matrix1, const vpMatrix &matrix2) p1 = fftw_plan_dft_2d(wf, hf, ad, outa, FFTW_FORWARD, FFTW_ESTIMATE); p2 = fftw_plan_dft_2d(wf, hf, bd, outb, FFTW_FORWARD, FFTW_ESTIMATE); p3 = fftw_plan_dft_2d(wf, hf, outc, out, FFTW_BACKWARD, FFTW_ESTIMATE); - } else { // init already done with correct matrix dimentions + } + else { // init already done with correct matrix dimentions m_M1 = matrix1; m_M2 = matrix2; } diff --git a/modules/ustk_elastography/src/usElastography.cpp b/modules/ustk_elastography/src/usElastography.cpp index 8293d9ce..6a750e93 100644 --- a/modules/ustk_elastography/src/usElastography.cpp +++ b/modules/ustk_elastography/src/usElastography.cpp @@ -35,6 +35,10 @@ #if defined(USTK_HAVE_FFTW) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Default constructor. */ @@ -144,7 +148,8 @@ void usElastography::updateRF(const usImageRF2D &image) { if (!m_isloadPre) { setPreCompression(image); - } else { + } + else { if (m_isloadPost) setPreCompression(m_Postcomp); setPostCompression(image); @@ -218,8 +223,9 @@ vpImage usElastography::run() throw vpException(vpException::fatalError, "usElastography : cannot use block-matching algorithm, armadillo is missing."); #endif - } else { - // Step 1: Numerical gradients + } + else { + // Step 1: Numerical gradients vpMatrix Fx = usSignalProcessing::getXGradient(m_PreROI); vpMatrix Fy = usSignalProcessing::getYGradient(m_PreROI); // Difference @@ -320,9 +326,9 @@ vpImage usElastography::run() for (unsigned int xIndex = 0; xIndex < m_StrainMap.getCols(); ++xIndex) { for (unsigned int yIndex = 0; yIndex < m_StrainMap.getRows(); ++yIndex) { m_StrainMap[yIndex][xIndex] = - std::isnan(strainMatrix[yIndex * m_decimationFactor][xIndex]) - ? 0.0 - : 254 * (fabs(strainMatrix[yIndex * m_decimationFactor][xIndex]) / (m_max_abs)); + std::isnan(strainMatrix[yIndex * m_decimationFactor][xIndex]) + ? 0.0 + : 254 * (fabs(strainMatrix[yIndex * m_decimationFactor][xIndex]) / (m_max_abs)); } } } diff --git a/modules/ustk_elastography/src/usElastography3D.cpp b/modules/ustk_elastography/src/usElastography3D.cpp index 3f90c84e..2b279291 100644 --- a/modules/ustk_elastography/src/usElastography3D.cpp +++ b/modules/ustk_elastography/src/usElastography3D.cpp @@ -34,6 +34,10 @@ #if defined(USTK_HAVE_FFTW) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Default constructor. */ @@ -62,7 +66,7 @@ usElastography3D::usElastography3D(usImageRF3D &Pre, usImageRF3D &volume) { if (!m_isloadPre) { setPreCompression(volume); - } else { + } + else { if (m_isloadPost) setPreCompression(m_Postcomp); setPostCompression(volume); diff --git a/modules/ustk_elastography/src/usImageElastography.cpp b/modules/ustk_elastography/src/usImageElastography.cpp index 78d3eabb..ee927106 100644 --- a/modules/ustk_elastography/src/usImageElastography.cpp +++ b/modules/ustk_elastography/src/usImageElastography.cpp @@ -32,13 +32,16 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! \brief Constructor. */ usImageElastography::usImageElastography() : m_ultrasoundImage(), m_strainMap(), m_elastoImage(), m_heigthPosition(0), m_widthPosition(0) -{ -} +{ } /** * Initializing constructor. @@ -53,7 +56,7 @@ usImageElastography::usImageElastography(const vpImage &ultrasoun const vpImage &strainMap, unsigned int heightPosition, unsigned int widthPosition) : m_ultrasoundImage(ultrasoundImage), m_strainMap(strainMap), m_elastoImage(), m_heigthPosition(heightPosition), - m_widthPosition(widthPosition) + m_widthPosition(widthPosition) { computeElastographyImage(); } @@ -61,7 +64,7 @@ usImageElastography::usImageElastography(const vpImage &ultrasoun /** * Destructor. */ -usImageElastography::~usImageElastography() {} +usImageElastography::~usImageElastography() { } /** * Get the resulting image, combinig ultrasound and elastography. @@ -115,7 +118,8 @@ void usImageElastography::computeElastographyImage() if (i >= (int)m_heigthPosition && i < (int)(m_heigthPosition + m_strainMap.getHeight()) && j >= m_widthPosition && j < m_widthPosition + m_strainMap.getWidth()) { newColor.R = m_strainMap[i - m_heigthPosition][j - m_widthPosition]; - } else { // oustide + } + else { // oustide newColor.R = m_ultrasoundImage[i][j]; newColor.G = m_ultrasoundImage[i][j]; newColor.B = m_ultrasoundImage[i][j]; diff --git a/modules/ustk_elastography/src/usMotionEstimation.cpp b/modules/ustk_elastography/src/usMotionEstimation.cpp index 759c9a95..f51b8722 100644 --- a/modules/ustk_elastography/src/usMotionEstimation.cpp +++ b/modules/ustk_elastography/src/usMotionEstimation.cpp @@ -34,9 +34,13 @@ #include #if defined(USTK_HAVE_ARMADILLO) && (ARMA_VERSION_MAJOR > 6) && (ARMA_VERSION_MAJOR > 700) -usMotionEstimation::usMotionEstimation() {} +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif -usMotionEstimation::~usMotionEstimation() {} +usMotionEstimation::usMotionEstimation() { } + +usMotionEstimation::~usMotionEstimation() { } /*! * \brief init @@ -291,5 +295,5 @@ vpMatrix usMotionEstimation::convert_mat2vpMatrix(mat vI) #elif !defined(VISP_BUILD_SHARED_LIBS) // Work arround to avoid warning: libvisp_ustk_elastograpy.a(usMotionEstimation.cpp.o) has no symbols -void dummy_vpusMotionEstimation(){}; +void dummy_vpusMotionEstimation() { }; #endif // ARMADILLO diff --git a/modules/ustk_elastography/src/usSignalProcessing.cpp b/modules/ustk_elastography/src/usSignalProcessing.cpp index 3b2ccf64..7999dee5 100644 --- a/modules/ustk_elastography/src/usSignalProcessing.cpp +++ b/modules/ustk_elastography/src/usSignalProcessing.cpp @@ -33,16 +33,20 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /*! * \brief usSignalProcessing::usSignalProcessing * Constructor */ -usSignalProcessing::usSignalProcessing() {} +usSignalProcessing::usSignalProcessing() { } /*! * \brief usSignalProcessing::~usSignalProcessing * Destructor - void */ -usSignalProcessing::~usSignalProcessing() {} +usSignalProcessing::~usSignalProcessing() { } /** * Gaussian filter kernel generator. diff --git a/modules/ustk_elastography/test/testUsElastography.cpp b/modules/ustk_elastography/test/testUsElastography.cpp index f8e3c289..c9b3abd4 100644 --- a/modules/ustk_elastography/test/testUsElastography.cpp +++ b/modules/ustk_elastography/test/testUsElastography.cpp @@ -38,6 +38,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main() { @@ -62,7 +66,7 @@ int main() // read groud truth image vpImage groundTruthStrainImage; std::string groundTruthFileName = - us::getDataSetPath() + std::string("/ustk-tests-groudTruth/testElasto_imgRFElasto12&15_ROI-40-2500-50-500.png"); + us::getDataSetPath() + std::string("/ustk-tests-groudTruth/testElasto_imgRFElasto12&15_ROI-40-2500-50-500.png"); vpImageIo::read(groundTruthStrainImage, groundTruthFileName.c_str()); // compare diff --git a/modules/ustk_grabber/include/visp3/ustk_grabber/usNetworkGrabberPostScan2D.h b/modules/ustk_grabber/include/visp3/ustk_grabber/usNetworkGrabberPostScan2D.h index 22a967ba..6281c4f5 100644 --- a/modules/ustk_grabber/include/visp3/ustk_grabber/usNetworkGrabberPostScan2D.h +++ b/modules/ustk_grabber/include/visp3/ustk_grabber/usNetworkGrabberPostScan2D.h @@ -81,7 +81,7 @@ class VISP_EXPORT usNetworkGrabberPostScan2D : public usNetworkGrabber void stopRecording(); - void useVpDisplay(vpDisplay *display); + void useVpDisplay(VISP_NAMESPACE_ADDRESSING vpDisplay *display); signals: void newFrameAvailable(); diff --git a/modules/ustk_grabber/include/visp3/ustk_grabber/usNetworkGrabberPreScan2D.h b/modules/ustk_grabber/include/visp3/ustk_grabber/usNetworkGrabberPreScan2D.h index 36ecd8ee..acbcfea6 100644 --- a/modules/ustk_grabber/include/visp3/ustk_grabber/usNetworkGrabberPreScan2D.h +++ b/modules/ustk_grabber/include/visp3/ustk_grabber/usNetworkGrabberPreScan2D.h @@ -81,7 +81,7 @@ class VISP_EXPORT usNetworkGrabberPreScan2D : public usNetworkGrabber void stopRecording(); - void useVpDisplay(vpDisplay *display); + void useVpDisplay(VISP_NAMESPACE_ADDRESSING vpDisplay *display); signals: void newFrameAvailable(); diff --git a/modules/ustk_grabber/src/usNetworkGrabber.cpp b/modules/ustk_grabber/src/usNetworkGrabber.cpp index 610b34b5..8a128975 100644 --- a/modules/ustk_grabber/src/usNetworkGrabber.cpp +++ b/modules/ustk_grabber/src/usNetworkGrabber.cpp @@ -44,6 +44,10 @@ using namespace std; +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. * @param parent Parent QObject. diff --git a/modules/ustk_grabber/src/usNetworkGrabberPostScan2D.cpp b/modules/ustk_grabber/src/usNetworkGrabberPostScan2D.cpp index 6ab38c76..ebbf8e61 100644 --- a/modules/ustk_grabber/src/usNetworkGrabberPostScan2D.cpp +++ b/modules/ustk_grabber/src/usNetworkGrabberPostScan2D.cpp @@ -38,6 +38,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. Inititializes the image, and manages Qt signal. */ diff --git a/modules/ustk_grabber/src/usNetworkGrabberPostScanBiPlan.cpp b/modules/ustk_grabber/src/usNetworkGrabberPostScanBiPlan.cpp index f5a8b399..6e3cb181 100644 --- a/modules/ustk_grabber/src/usNetworkGrabberPostScanBiPlan.cpp +++ b/modules/ustk_grabber/src/usNetworkGrabberPostScanBiPlan.cpp @@ -38,6 +38,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. Inititializes the image, and manages Qt signal. */ diff --git a/modules/ustk_grabber/src/usNetworkGrabberPreScan2D.cpp b/modules/ustk_grabber/src/usNetworkGrabberPreScan2D.cpp index 92252751..a1afbad6 100644 --- a/modules/ustk_grabber/src/usNetworkGrabberPreScan2D.cpp +++ b/modules/ustk_grabber/src/usNetworkGrabberPreScan2D.cpp @@ -39,6 +39,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. Inititializes the image, and manages Qt signal. */ diff --git a/modules/ustk_grabber/src/usNetworkGrabberPreScan3D.cpp b/modules/ustk_grabber/src/usNetworkGrabberPreScan3D.cpp index 1117d91f..90f85dbe 100644 --- a/modules/ustk_grabber/src/usNetworkGrabberPreScan3D.cpp +++ b/modules/ustk_grabber/src/usNetworkGrabberPreScan3D.cpp @@ -37,6 +37,11 @@ #include #include + +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. Inititializes the image, and manages Qt signal. */ diff --git a/modules/ustk_grabber/src/usNetworkGrabberRF2D.cpp b/modules/ustk_grabber/src/usNetworkGrabberRF2D.cpp index 9b9575c7..269fc97d 100644 --- a/modules/ustk_grabber/src/usNetworkGrabberRF2D.cpp +++ b/modules/ustk_grabber/src/usNetworkGrabberRF2D.cpp @@ -37,6 +37,11 @@ #include #include + +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. Inititializes the image, and manages Qt signal. */ diff --git a/modules/ustk_grabber/src/usNetworkGrabberRF3D.cpp b/modules/ustk_grabber/src/usNetworkGrabberRF3D.cpp index 3a276e5e..69535421 100644 --- a/modules/ustk_grabber/src/usNetworkGrabberRF3D.cpp +++ b/modules/ustk_grabber/src/usNetworkGrabberRF3D.cpp @@ -37,6 +37,11 @@ #include #include + +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. Inititializes the image, and manages Qt signal. */ diff --git a/modules/ustk_gui/include/visp3/ustk_gui/us2DSceneWidget.h b/modules/ustk_gui/include/visp3/ustk_gui/us2DSceneWidget.h index c789423b..283a8037 100644 --- a/modules/ustk_gui/include/visp3/ustk_gui/us2DSceneWidget.h +++ b/modules/ustk_gui/include/visp3/ustk_gui/us2DSceneWidget.h @@ -132,11 +132,11 @@ class VISP_EXPORT us2DSceneWidget : public usViewerWidget public: // Constructor/Destructor us2DSceneWidget(QWidget *parent = NULL, Qt::WindowFlags f = Qt::WindowFlags()); - ~us2DSceneWidget() {} + ~us2DSceneWidget() { } void drawLine(double u1, double v1, double w1, double u2, double v2, double w2); - void getClick(vpColVector &vec); + void getClick(VISP_NAMESPACE_ADDRESSING vpColVector &vec); void getCurrentSlice(usImagePostScan2D &image2D); @@ -176,14 +176,14 @@ class VISP_EXPORT us2DSceneWidget : public usViewerWidget public slots: void updateImageData(vtkImageData *imageData); - void changeMatrix(vpHomogeneousMatrix matrix); + void changeMatrix(VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix matrix); void saveViewSlot(); void updateView(); signals: void matrixChanged(vtkMatrix4x4 *matrix); - void voxelPicked(vpColVector vector); + void voxelPicked(VISP_NAMESPACE_ADDRESSING vpColVector vector); private: // image @@ -234,7 +234,7 @@ public slots: // for getClick blocking bool m_pickingState; - vpColVector m_pickedVoxel; + VISP_NAMESPACE_ADDRESSING vpColVector m_pickedVoxel; }; #endif #endif // __us2DSceneWidget_h_ diff --git a/modules/ustk_gui/include/visp3/ustk_gui/usElastographyDisplayWidget.h b/modules/ustk_gui/include/visp3/ustk_gui/usElastographyDisplayWidget.h index f48fa674..b24087a4 100644 --- a/modules/ustk_gui/include/visp3/ustk_gui/usElastographyDisplayWidget.h +++ b/modules/ustk_gui/include/visp3/ustk_gui/usElastographyDisplayWidget.h @@ -67,7 +67,7 @@ class VISP_EXPORT usElastographyDisplayWidget : public QWidget void resizeEvent(QResizeEvent *event); public slots: - void updateFrame(const vpImage elastographyImage); + void updateFrame(const VISP_NAMESPACE_ADDRESSING vpImage elastographyImage); private: QLabel *m_label; diff --git a/modules/ustk_gui/include/visp3/ustk_gui/usElastographyQtWrapper.h b/modules/ustk_gui/include/visp3/ustk_gui/usElastographyQtWrapper.h index b890348e..eb77296b 100644 --- a/modules/ustk_gui/include/visp3/ustk_gui/usElastographyQtWrapper.h +++ b/modules/ustk_gui/include/visp3/ustk_gui/usElastographyQtWrapper.h @@ -65,7 +65,7 @@ public slots: void updateFrame(const usImageRF2D &img); signals: - void elastoReady(vpImage); + void elastoReady(VISP_NAMESPACE_ADDRESSING vpImage); private: usElastography m_elastography; diff --git a/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidget.h b/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidget.h index 881cdb80..cf465dd3 100644 --- a/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidget.h +++ b/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidget.h @@ -69,7 +69,7 @@ class VISP_EXPORT usImageDisplayWidget : public QWidget void resizeEvent(QResizeEvent *event); public slots: - void updateFrame(const vpImage img); + void updateFrame(const VISP_NAMESPACE_ADDRESSING vpImage img); void updateFrame(const usImagePreScan2D img); void updateFrame(const usImagePostScan2D img); @@ -84,7 +84,7 @@ public slots: bool m_useScanConversion; usPreScanToPostScan2DConverter m_scanConverter; usImagePostScan2D m_postScan; - vpImage m_image; + VISP_NAMESPACE_ADDRESSING vpImage m_image; }; #endif // QT #endif // __usImageDisplayWidget_h_ diff --git a/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidgetQmlOverlay.h b/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidgetQmlOverlay.h index ea630f7b..4824dee8 100644 --- a/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidgetQmlOverlay.h +++ b/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidgetQmlOverlay.h @@ -65,19 +65,19 @@ class VISP_EXPORT usImageDisplayWidgetQmlOverlay : public usImageDisplayWidget void resizeEvent(QResizeEvent *event); public slots: - void updateRectPosition(vpRectOriented newRectangle); + void updateRectPosition(VISP_NAMESPACE_ADDRESSING vpRectOriented newRectangle); void startTrackingSlot(); signals: - void startTracking(vpRectOriented); + void startTracking(VISP_NAMESPACE_ADDRESSING vpRectOriented); void stopTracking(); private: - vpImagePoint displayImageToRealImageDimentions(const vpImagePoint displayPoint); - vpImagePoint realImageToDisplayImageDimentions(const vpImagePoint realImagePoint); + VISP_NAMESPACE_ADDRESSING vpImagePoint displayImageToRealImageDimentions(const VISP_NAMESPACE_ADDRESSING vpImagePoint displayPoint); + VISP_NAMESPACE_ADDRESSING vpImagePoint realImageToDisplayImageDimentions(const VISP_NAMESPACE_ADDRESSING vpImagePoint realImagePoint); - vpRectOriented displayImageToRealImageDimentions(const vpRectOriented displayRectangle); - vpRectOriented realImageToDisplayImageDimentions(const vpRectOriented realRectangle); + VISP_NAMESPACE_ADDRESSING vpRectOriented displayImageToRealImageDimentions(const VISP_NAMESPACE_ADDRESSING vpRectOriented displayRectangle); + VISP_NAMESPACE_ADDRESSING vpRectOriented realImageToDisplayImageDimentions(const VISP_NAMESPACE_ADDRESSING vpRectOriented realRectangle); QQuickWidget *m_qQuickOverlay; }; diff --git a/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidgetQmlOverlayServoing.h b/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidgetQmlOverlayServoing.h index a20ebe5c..80598645 100644 --- a/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidgetQmlOverlayServoing.h +++ b/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidgetQmlOverlayServoing.h @@ -74,7 +74,7 @@ class VISP_EXPORT usImageDisplayWidgetQmlOverlayServoing : public usImageDisplay public slots: void enableFeaturesDisplay(); void disableFeaturesDisplay(); - void updateRectPosition(vpRectOriented newRectangle); + void updateRectPosition(VISP_NAMESPACE_ADDRESSING vpRectOriented newRectangle); void updateConfidenceAngle(double scanline); void updateConfidenceMap(usImagePreScan2D confidence); void updateFrame(const usImagePreScan2D img); @@ -82,17 +82,17 @@ public slots: void startTrackingSlot(); signals: - void startTrackingRect(vpRectOriented); + void startTrackingRect(VISP_NAMESPACE_ADDRESSING vpRectOriented); void stopTrackingRect(); void startServoingRect(); void stopServoingRect(); private: - vpImagePoint displayImageToRealImageDimentions(const vpImagePoint displayPoint); - vpImagePoint realImageToDisplayImageDimentions(const vpImagePoint realImagePoint); + VISP_NAMESPACE_ADDRESSING vpImagePoint displayImageToRealImageDimentions(const VISP_NAMESPACE_ADDRESSING vpImagePoint displayPoint); + VISP_NAMESPACE_ADDRESSING vpImagePoint realImageToDisplayImageDimentions(const VISP_NAMESPACE_ADDRESSING vpImagePoint realImagePoint); - vpRectOriented displayImageToRealImageDimentions(const vpRectOriented displayRectangle); - vpRectOriented realImageToDisplayImageDimentions(const vpRectOriented realRectangle); + VISP_NAMESPACE_ADDRESSING vpRectOriented displayImageToRealImageDimentions(const VISP_NAMESPACE_ADDRESSING vpRectOriented displayRectangle); + VISP_NAMESPACE_ADDRESSING vpRectOriented realImageToDisplayImageDimentions(const VISP_NAMESPACE_ADDRESSING vpRectOriented realRectangle); QQuickWidget *m_qQuickOverlay; bool m_isTrackingRect; @@ -102,12 +102,12 @@ public slots: // optionnal features displays bool m_useFeatureDisplay; usImagePreScan2D m_confidence; - vpPlot m_plot; + VISP_NAMESPACE_ADDRESSING vpPlot m_plot; double m_startTime; #if defined(VISP_HAVE_GDI) - vpDisplayGDI *m_display; + VISP_NAMESPACE_ADDRESSING vpDisplayGDI *m_display; #elif defined(VISP_HAVE_OPENCV) - vpDisplayOpenCV *m_display; + VISP_NAMESPACE_ADDRESSING vpDisplayOpenCV *m_display; #endif }; #endif // QT && ELASTOGRAPHY diff --git a/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidgetRobotControl.h b/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidgetRobotControl.h index 20727d55..d61ba80a 100644 --- a/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidgetRobotControl.h +++ b/modules/ustk_gui/include/visp3/ustk_gui/usImageDisplayWidgetRobotControl.h @@ -72,7 +72,7 @@ class VISP_EXPORT usImageDisplayWidgetRobotControl : public usImageDisplayWidget void resizeEvent(QResizeEvent *event); public slots: - void updateFrame(const vpImage img); + void updateFrame(const VISP_NAMESPACE_ADDRESSING vpImage img); void updateFrame(const usImagePreScan2D img); void updateConfidenceServoingStatus(bool); void updateConfidenceAngle(double sanline); @@ -94,12 +94,12 @@ public slots: // optionnal features displays bool m_useFeatureDisplay; usImagePreScan2D m_confidence; - vpPlot m_plot; + VISP_NAMESPACE_ADDRESSING vpPlot m_plot; double m_startTime; #if defined(VISP_HAVE_GDI) - vpDisplayGDI *m_display; + VISP_NAMESPACE_ADDRESSING vpDisplayGDI *m_display; #elif defined(VISP_HAVE_OPENCV) - vpDisplayOpenCV *m_display; + VISP_NAMESPACE_ADDRESSING vpDisplayOpenCV *m_display; #endif }; #endif // QT && ELASTOGRAPHY diff --git a/modules/ustk_gui/include/visp3/ustk_gui/usImageElastographyCreationWrapper.h b/modules/ustk_gui/include/visp3/ustk_gui/usImageElastographyCreationWrapper.h index e9475131..d1e260e1 100644 --- a/modules/ustk_gui/include/visp3/ustk_gui/usImageElastographyCreationWrapper.h +++ b/modules/ustk_gui/include/visp3/ustk_gui/usImageElastographyCreationWrapper.h @@ -68,10 +68,10 @@ public slots: void setROI(unsigned int i, unsigned int j, unsigned int height, unsigned int width); private slots: - void strainMapReadySlot(vpImage); + void strainMapReadySlot(VISP_NAMESPACE_ADDRESSING vpImage); signals: - void elastographyImageReady(vpImage); + void elastographyImageReady(VISP_NAMESPACE_ADDRESSING vpImage); private: // processing objects diff --git a/modules/ustk_gui/include/visp3/ustk_gui/usRectangleVisualServoingController.h b/modules/ustk_gui/include/visp3/ustk_gui/usRectangleVisualServoingController.h index a60b670d..ee9335bd 100644 --- a/modules/ustk_gui/include/visp3/ustk_gui/usRectangleVisualServoingController.h +++ b/modules/ustk_gui/include/visp3/ustk_gui/usRectangleVisualServoingController.h @@ -68,13 +68,13 @@ class VISP_EXPORT usRectangleVisualServoingController : public QObject void confidenceMap(usImagePreScan2D); void updatePobeXVelocity(int linearVelocity); void updateProbeZOrientation(int angularVelocity); - void newRectTracked(vpRectOriented rect); + void newRectTracked(VISP_NAMESPACE_ADDRESSING vpRectOriented rect); void newPostScanFrame(usImagePostScan2D image); void trackerXError(double error); public slots: void updateImage(usImagePreScan2D image); - void initTracker(vpRectOriented rect); + void initTracker(VISP_NAMESPACE_ADDRESSING vpRectOriented rect); void stopTracking(); void activateController(bool activate); void activateController(); diff --git a/modules/ustk_gui/include/visp3/ustk_gui/usTracker2DQtWrapper.h b/modules/ustk_gui/include/visp3/ustk_gui/usTracker2DQtWrapper.h index 037e4b47..1a29bff6 100644 --- a/modules/ustk_gui/include/visp3/ustk_gui/usTracker2DQtWrapper.h +++ b/modules/ustk_gui/include/visp3/ustk_gui/usTracker2DQtWrapper.h @@ -62,18 +62,18 @@ class VISP_EXPORT usTracker2DQtWrapper : public QObject ~usTracker2DQtWrapper(); public slots: - void initTracker(vpRectOriented rect); - void updateImage(vpImage image); + void initTracker(VISP_NAMESPACE_ADDRESSING vpRectOriented rect); + void updateImage(VISP_NAMESPACE_ADDRESSING vpImage image); void updateImage(usImagePreScan2D image); void updateImage(usImagePostScan2D image); void stopTracking(); signals: - void newTrackedRectangle(vpRectOriented); + void newTrackedRectangle(VISP_NAMESPACE_ADDRESSING vpRectOriented); private: usDenseTracker2D m_tracker; - vpImage m_firstImage; + VISP_NAMESPACE_ADDRESSING vpImage m_firstImage; bool m_firstFrameArrived; bool m_isInitialized; }; diff --git a/modules/ustk_gui/include/visp3/ustk_gui/usVTKConverter.h b/modules/ustk_gui/include/visp3/ustk_gui/usVTKConverter.h index 1c50665e..c5c1a3a8 100644 --- a/modules/ustk_gui/include/visp3/ustk_gui/usVTKConverter.h +++ b/modules/ustk_gui/include/visp3/ustk_gui/usVTKConverter.h @@ -74,8 +74,8 @@ class VISP_EXPORT usVTKConverter static void convert(vtkSmartPointer &vtkPostScanImage, usImagePostScan2D &postScanImage); // matrix types - static void convert(const vpHomogeneousMatrix &, vtkMatrix4x4 *); - static void convert(vtkMatrix4x4 *, vpHomogeneousMatrix &); + static void convert(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &, vtkMatrix4x4 *); + static void convert(vtkMatrix4x4 *, VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &); }; #endif #endif // __usMedicalImageViewer_h_ diff --git a/modules/ustk_gui/include/visp3/ustk_gui/usViper850WrapperVelocityControl.h b/modules/ustk_gui/include/visp3/ustk_gui/usViper850WrapperVelocityControl.h index 640f89e6..2d2058cd 100644 --- a/modules/ustk_gui/include/visp3/ustk_gui/usViper850WrapperVelocityControl.h +++ b/modules/ustk_gui/include/visp3/ustk_gui/usViper850WrapperVelocityControl.h @@ -96,16 +96,16 @@ private slots: private: bool m_initialized; bool m_run; - vpRobotViper850 *viper; + VISP_NAMESPACE_ADDRESSING vpRobotViper850 *viper; void startRobot(void); - vpMatrix eJe; // robot jacobian + VISP_NAMESPACE_ADDRESSING vpMatrix eJe; // robot jacobian - vpVelocityTwistMatrix eVp; // change velocity from ultrasound probe contact force to end-effector frame + VISP_NAMESPACE_ADDRESSING vpVelocityTwistMatrix eVp; // change velocity from ultrasound probe contact force to end-effector frame - vpColVector velocityProbeContact; // velocity in ultrasound probe contact point - vpColVector q_dot; - vpColVector ve; // velocity of end-effector + VISP_NAMESPACE_ADDRESSING vpColVector velocityProbeContact; // velocity in ultrasound probe contact point + VISP_NAMESPACE_ADDRESSING vpColVector q_dot; + VISP_NAMESPACE_ADDRESSING vpColVector ve; // velocity of end-effector }; #endif // USTK_HAVE_VTK_QT && VISP_HAVE_VIPER850 #endif // __usViper850WrapperVelocityControl_h_ diff --git a/modules/ustk_gui/src/us2DSceneWidget.cpp b/modules/ustk_gui/src/us2DSceneWidget.cpp index 3b0f913c..63c6a1fc 100644 --- a/modules/ustk_gui/src/us2DSceneWidget.cpp +++ b/modules/ustk_gui/src/us2DSceneWidget.cpp @@ -46,6 +46,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. * @param parent The QWidget parent. diff --git a/modules/ustk_gui/src/us3DSceneWidget.cpp b/modules/ustk_gui/src/us3DSceneWidget.cpp index 6dae3bf3..24cdb27a 100644 --- a/modules/ustk_gui/src/us3DSceneWidget.cpp +++ b/modules/ustk_gui/src/us3DSceneWidget.cpp @@ -65,6 +65,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. */ diff --git a/modules/ustk_gui/src/usConfidenceMapController.cpp b/modules/ustk_gui/src/usConfidenceMapController.cpp index 4d00ee82..a8318e58 100644 --- a/modules/ustk_gui/src/usConfidenceMapController.cpp +++ b/modules/ustk_gui/src/usConfidenceMapController.cpp @@ -44,13 +44,16 @@ */ usConfidenceMapController::usConfidenceMapController(QObject *parent) : QObject(parent), m_confidenceProcessor(), m_confidenceMap(), m_gain(5), m_activated(false) -{ -} +{ } -usConfidenceMapController::~usConfidenceMapController() {} +usConfidenceMapController::~usConfidenceMapController() { } void usConfidenceMapController::updateImage(usImagePreScan2D image) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + m_confidenceProcessor.run(m_confidenceMap, image); // robot orientation control law diff --git a/modules/ustk_gui/src/usElastographyDisplayWidget.cpp b/modules/ustk_gui/src/usElastographyDisplayWidget.cpp index 433890aa..a03ae708 100644 --- a/modules/ustk_gui/src/usElastographyDisplayWidget.cpp +++ b/modules/ustk_gui/src/usElastographyDisplayWidget.cpp @@ -42,6 +42,10 @@ #if (defined(USTK_HAVE_VTK_QT) || defined(USTK_HAVE_QT5)) && defined(VISP_HAVE_MODULE_USTK_ELASTOGRAPHY) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. */ diff --git a/modules/ustk_gui/src/usElastographyQtWrapper.cpp b/modules/ustk_gui/src/usElastographyQtWrapper.cpp index 39aa47db..f0a35294 100644 --- a/modules/ustk_gui/src/usElastographyQtWrapper.cpp +++ b/modules/ustk_gui/src/usElastographyQtWrapper.cpp @@ -42,12 +42,12 @@ /** * Constructor. */ -usElastographyQtWrapper::usElastographyQtWrapper() : QObject(), m_elastography() {} +usElastographyQtWrapper::usElastographyQtWrapper() : QObject(), m_elastography() { } /** * Destructor. */ -usElastographyQtWrapper::~usElastographyQtWrapper() {} +usElastographyQtWrapper::~usElastographyQtWrapper() { } /** * ROI setter, coordinates are set in RF image pixel coordinates. @@ -65,6 +65,10 @@ void usElastographyQtWrapper::setROI(int tx, int ty, int tw, int th) { m_elastog */ void usElastographyQtWrapper::updateFrame(const usImageRF2D &img) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + m_elastography.updateRF(img); vpImage elasto = m_elastography.run(); if (elasto.getHeight() != 0 && elasto.getWidth() != 0) diff --git a/modules/ustk_gui/src/usImageDisplayWidget.cpp b/modules/ustk_gui/src/usImageDisplayWidget.cpp index d82446d1..aef3cf44 100644 --- a/modules/ustk_gui/src/usImageDisplayWidget.cpp +++ b/modules/ustk_gui/src/usImageDisplayWidget.cpp @@ -39,6 +39,10 @@ #if (defined(USTK_HAVE_VTK_QT) || defined(USTK_HAVE_QT5)) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. */ @@ -102,7 +106,8 @@ void usImageDisplayWidget::updateFrame(const usImagePreScan2D img m_scanConverter.convert(img, m_postScan); m_QImage = QImage(m_postScan.bitmap, m_postScan.getWidth(), m_postScan.getHeight(), m_postScan.getWidth(), QImage::Format_Indexed8); - } else { + } + else { m_image = img; m_QImage = QImage(img.bitmap, img.getWidth(), img.getHeight(), img.getWidth(), QImage::Format_Indexed8); } diff --git a/modules/ustk_gui/src/usImageDisplayWidgetQmlOverlay.cpp b/modules/ustk_gui/src/usImageDisplayWidgetQmlOverlay.cpp index 6753ebb5..b1cdc1b6 100644 --- a/modules/ustk_gui/src/usImageDisplayWidgetQmlOverlay.cpp +++ b/modules/ustk_gui/src/usImageDisplayWidgetQmlOverlay.cpp @@ -42,6 +42,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. */ diff --git a/modules/ustk_gui/src/usImageDisplayWidgetQmlOverlayServoing.cpp b/modules/ustk_gui/src/usImageDisplayWidgetQmlOverlayServoing.cpp index ec458334..1064b8de 100644 --- a/modules/ustk_gui/src/usImageDisplayWidgetQmlOverlayServoing.cpp +++ b/modules/ustk_gui/src/usImageDisplayWidgetQmlOverlayServoing.cpp @@ -42,6 +42,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. */ diff --git a/modules/ustk_gui/src/usImageDisplayWidgetRobotControl.cpp b/modules/ustk_gui/src/usImageDisplayWidgetRobotControl.cpp index 2e45744d..e76095c2 100644 --- a/modules/ustk_gui/src/usImageDisplayWidgetRobotControl.cpp +++ b/modules/ustk_gui/src/usImageDisplayWidgetRobotControl.cpp @@ -39,12 +39,16 @@ #if (defined(USTK_HAVE_VTK_QT) || defined(USTK_HAVE_QT5)) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. */ usImageDisplayWidgetRobotControl::usImageDisplayWidgetRobotControl() : usImageDisplayWidget(), m_controlArrowsActivated(false), m_leftArrow(), m_rightArrow(), - m_confidenceServoingButton(), m_useFeatureDisplay(false), m_confidence(), m_plot(), m_startTime() + m_confidenceServoingButton(), m_useFeatureDisplay(false), m_confidence(), m_plot(), m_startTime() { this->setMinimumSize(200, 200); @@ -85,7 +89,7 @@ usImageDisplayWidgetRobotControl::usImageDisplayWidgetRobotControl() /** * Destructor. */ -usImageDisplayWidgetRobotControl::~usImageDisplayWidgetRobotControl() {} +usImageDisplayWidgetRobotControl::~usImageDisplayWidgetRobotControl() { } /** * Slot called to update the ultrasound image to display. @@ -114,7 +118,8 @@ void usImageDisplayWidgetRobotControl::updateFrame(const usImagePreScan2D)), this, SLOT(strainMapReadySlot(vpImage))); @@ -54,7 +58,7 @@ usImageElastographyCreationWrapper::usImageElastographyCreationWrapper() /** * Destructor. */ -usImageElastographyCreationWrapper::~usImageElastographyCreationWrapper() {} +usImageElastographyCreationWrapper::~usImageElastographyCreationWrapper() { } /** * ROI setter, coordinates are set in RF image pixel coordinates. diff --git a/modules/ustk_gui/src/usRectangleVisualServoingController.cpp b/modules/ustk_gui/src/usRectangleVisualServoingController.cpp index ea6ec60a..1af812b1 100644 --- a/modules/ustk_gui/src/usRectangleVisualServoingController.cpp +++ b/modules/ustk_gui/src/usRectangleVisualServoingController.cpp @@ -39,16 +39,19 @@ #if (defined(USTK_HAVE_VTK_QT) || defined(USTK_HAVE_QT5)) && defined(VISP_HAVE_MODULE_USTK_TEMPLATE_TRACKING) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. */ usRectangleVisualServoingController::usRectangleVisualServoingController(QObject *parent) : QObject(parent), m_tracker(), m_confidenceProcess(), m_converter(), m_imagePreScan(), m_confidencePreScan(), - m_imagePostScan(), m_trackerActivated(false), m_controllerActivated(false) -{ -} + m_imagePostScan(), m_trackerActivated(false), m_controllerActivated(false) +{ } -usRectangleVisualServoingController::~usRectangleVisualServoingController() {} +usRectangleVisualServoingController::~usRectangleVisualServoingController() { } void usRectangleVisualServoingController::updateImage(usImagePreScan2D image) { diff --git a/modules/ustk_gui/src/usResliceMatrixViewer.cpp b/modules/ustk_gui/src/usResliceMatrixViewer.cpp index 19e90595..6e36d882 100644 --- a/modules/ustk_gui/src/usResliceMatrixViewer.cpp +++ b/modules/ustk_gui/src/usResliceMatrixViewer.cpp @@ -81,6 +81,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. * @param imageFileName the mhd file to read. diff --git a/modules/ustk_gui/src/usTracker2DQtWrapper.cpp b/modules/ustk_gui/src/usTracker2DQtWrapper.cpp index 60c19363..527b3061 100644 --- a/modules/ustk_gui/src/usTracker2DQtWrapper.cpp +++ b/modules/ustk_gui/src/usTracker2DQtWrapper.cpp @@ -39,18 +39,21 @@ #if (defined(USTK_HAVE_VTK_QT) || defined(USTK_HAVE_QT5)) && defined(VISP_HAVE_MODULE_USTK_TEMPLATE_TRACKING) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. */ usTracker2DQtWrapper::usTracker2DQtWrapper() : QObject(), m_tracker(), m_firstImage(), m_firstFrameArrived(false), m_isInitialized(false) -{ -} +{ } /** * Destructor. */ -usTracker2DQtWrapper::~usTracker2DQtWrapper() {} +usTracker2DQtWrapper::~usTracker2DQtWrapper() { } /** * Slot to init the tracker. @@ -61,7 +64,8 @@ void usTracker2DQtWrapper::initTracker(vpRectOriented rect) if (m_firstFrameArrived) { m_tracker.init(m_firstImage, rect); m_isInitialized = true; - } else { + } + else { throw(vpException(vpException::fatalError, "Cannot init tracker: no frames sent to usTracker2DQtWrapper.")); } } @@ -75,7 +79,8 @@ void usTracker2DQtWrapper::updateImage(vpImage image) if (m_isInitialized) { m_tracker.update(image); emit(newTrackedRectangle(m_tracker.getTarget())); - } else { + } + else { m_firstImage = image; m_firstFrameArrived = true; } @@ -90,7 +95,8 @@ void usTracker2DQtWrapper::updateImage(usImagePreScan2D image) if (m_isInitialized) { m_tracker.update(image); emit(newTrackedRectangle(m_tracker.getTarget())); - } else { + } + else { m_firstImage = image; m_firstFrameArrived = true; } @@ -105,7 +111,8 @@ void usTracker2DQtWrapper::updateImage(usImagePostScan2D image) if (m_isInitialized) { m_tracker.update(image); emit(newTrackedRectangle(m_tracker.getTarget())); - } else { + } + else { m_firstImage = image; m_firstFrameArrived = true; } diff --git a/modules/ustk_gui/src/usVTKConverter.cpp b/modules/ustk_gui/src/usVTKConverter.cpp index a0d77573..9c62b97a 100644 --- a/modules/ustk_gui/src/usVTKConverter.cpp +++ b/modules/ustk_gui/src/usVTKConverter.cpp @@ -43,6 +43,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Converts a usImagePostScan3D to a vtkImageData. */ @@ -57,7 +61,8 @@ void usVTKConverter::convert(const usImagePostScan3D &postScanIma importer->SetDataExtentToWholeExtent(); importer->SetNumberOfScalarComponents(1); importer->SetImportVoidPointer((void *)postScanImage.getConstData(), 1); - } else + } + else importer->SetImportVoidPointer((void *)postScanImage.getConstData()); importer->Update(); @@ -81,7 +86,8 @@ void usVTKConverter::convert(const usImagePreScan3D &preScanImage preScanImage.getNumberOfFrames() - 1); importer->SetDataExtentToWholeExtent(); importer->SetNumberOfScalarComponents(1); - } else + } + else importer->SetImportVoidPointer((void *)preScanImage.getConstData()); importer->Update(); @@ -106,7 +112,7 @@ void usVTKConverter::convert(vtkSmartPointer &vtkPostScanImage, for (int i = 0; i < imageDims[0]; i++) { for (int j = 0; j < imageDims[1]; j++) { postScanImage[j][i] = - (unsigned char)(vtkPostScanImage->GetScalarComponentAsDouble(i, imageDims[1] - j - 1, 0, 0)); + (unsigned char)(vtkPostScanImage->GetScalarComponentAsDouble(i, imageDims[1] - j - 1, 0, 0)); } } diff --git a/modules/ustk_gui/src/usViper850WrapperVelocityControl.cpp b/modules/ustk_gui/src/usViper850WrapperVelocityControl.cpp index 6d373c0b..fd83f9f9 100644 --- a/modules/ustk_gui/src/usViper850WrapperVelocityControl.cpp +++ b/modules/ustk_gui/src/usViper850WrapperVelocityControl.cpp @@ -2,6 +2,10 @@ #if defined(USTK_HAVE_VTK_QT) && defined(VISP_HAVE_VIPER850) && defined(VISP_HAVE_MODULE_ROBOT) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + usViper850WrapperVelocityControl::usViper850WrapperVelocityControl() { m_initialized = false; @@ -25,7 +29,8 @@ void usViper850WrapperVelocityControl::init() try { // create viper object viper = new vpRobotViper850(); - } catch (...) { + } + catch (...) { std::cout << "Viper robot could not be initialized" << std::endl; emit(robotError()); } @@ -55,12 +60,14 @@ void usViper850WrapperVelocityControl::startRobot(void) try { viper->powerOn(); viper->setRobotState(vpRobot::STATE_VELOCITY_CONTROL); - } catch (...) { + } + catch (...) { viper->setRobotState(vpRobot::STATE_STOP); std::cout << "Viper robot could not be initialized" << std::endl; emit(robotError()); } - } else + } + else std::cout << "For security reason, the Viper robot has to be used with the dead man switch)" << std::endl; } @@ -95,7 +102,8 @@ void usViper850WrapperVelocityControl::controlLoop() // Send the joint velocities to the robot viper->setVelocity(vpRobot::ARTICULAR_FRAME, q_dot); - } catch (...) { + } + catch (...) { viper->setRobotState(vpRobot::STATE_STOP); std::cout << "Viper robot could not be initialized" << std::endl; emit(robotError()); @@ -322,7 +330,8 @@ void usViper850WrapperVelocityControl::controlLoopAutomatic() viper->setVelocity(vpRobot::ARTICULAR_FRAME, q_dot); iter++; - } catch (...) { + } + catch (...) { viper->setRobotState(vpRobot::STATE_STOP); std::cout << "Viper robot could not be initialized" << std::endl; emit(robotError()); diff --git a/modules/ustk_image_processing/ustk_confidence_map/src/usScanlineConfidence2D.cpp b/modules/ustk_image_processing/ustk_confidence_map/src/usScanlineConfidence2D.cpp index 02eac096..7346e3aa 100644 --- a/modules/ustk_image_processing/ustk_confidence_map/src/usScanlineConfidence2D.cpp +++ b/modules/ustk_image_processing/ustk_confidence_map/src/usScanlineConfidence2D.cpp @@ -33,15 +33,19 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Default constructor. */ -usScanlineConfidence2D::usScanlineConfidence2D() {} +usScanlineConfidence2D::usScanlineConfidence2D() { } /** * Default destructor. */ -usScanlineConfidence2D::~usScanlineConfidence2D() {} +usScanlineConfidence2D::~usScanlineConfidence2D() { } /** * Run the confidence map processor on pre-scan image. diff --git a/modules/ustk_image_processing/ustk_needle_detection/include/visp3/ustk_needle_detection/usNeedleDetectionTools.h b/modules/ustk_image_processing/ustk_needle_detection/include/visp3/ustk_needle_detection/usNeedleDetectionTools.h index aa900a81..80a7430b 100644 --- a/modules/ustk_image_processing/ustk_needle_detection/include/visp3/ustk_needle_detection/usNeedleDetectionTools.h +++ b/modules/ustk_image_processing/ustk_needle_detection/include/visp3/ustk_needle_detection/usNeedleDetectionTools.h @@ -92,7 +92,7 @@ double angle(double *p1, double *p2, double *q1, double *q2); * \right] * \f] */ -vpMatrix approximateCoordinates(vpMatrix X, vpMatrix MSS, unsigned int s); +VISP_NAMESPACE_ADDRESSING vpMatrix approximateCoordinates(VISP_NAMESPACE_ADDRESSING vpMatrix X, VISP_NAMESPACE_ADDRESSING vpMatrix MSS, unsigned int s); /** * Compute the mean (center of mass) of a set of d-dimensional points. @@ -101,7 +101,7 @@ vpMatrix approximateCoordinates(vpMatrix X, vpMatrix MSS, unsigned int s); * @param npts Number of points. * @param d Dimension. */ -void arithmeticMean(const vpMatrix points, double *mean, unsigned int npts, unsigned int d); +void arithmeticMean(const VISP_NAMESPACE_ADDRESSING vpMatrix points, double *mean, unsigned int npts, unsigned int d); void computeQuantile(unsigned char *data, unsigned int dataSize, unsigned int nDesired, unsigned int &q, unsigned int &nThresholded); @@ -110,15 +110,15 @@ void computeQuantile(short *data, unsigned int dataSize, unsigned int nDesired, void computeQuantile(const unsigned int *data, unsigned int dataSize, unsigned int nDesired, unsigned int &q, unsigned int &nThresholded); -void computeControlPoints(const vpMatrix &model, vpMatrix &mss, double **points, const unsigned int &nPoints); +void computeControlPoints(const VISP_NAMESPACE_ADDRESSING vpMatrix &model, VISP_NAMESPACE_ADDRESSING vpMatrix &mss, double **points, const unsigned int &nPoints); /** * Compute the euclidean distance between two 3D points. */ double dist3(double *x, double *y); -bool findEntry(const vpMatrix &model, double *entry, unsigned int nPoints, const vpColVector &origin, - const vpColVector &entryPlane, int VOI[6]); +bool findEntry(const VISP_NAMESPACE_ADDRESSING vpMatrix &model, double *entry, unsigned int nPoints, const VISP_NAMESPACE_ADDRESSING vpColVector &origin, + const VISP_NAMESPACE_ADDRESSING vpColVector &entryPlane, int VOI[6]); /** * Compute the geometric median of a set of d-dimensional points. @@ -126,27 +126,27 @@ bool findEntry(const vpMatrix &model, double *entry, unsigned int nPoints, const * @param npts Number of points. * @param d Dimension. */ -vpColVector geometricMedian(const vpMatrix points, unsigned int npts, unsigned int d); +VISP_NAMESPACE_ADDRESSING vpColVector geometricMedian(const VISP_NAMESPACE_ADDRESSING vpMatrix points, unsigned int npts, unsigned int d); -bool inside(const vpColVector point, int *VOI); +bool inside(const VISP_NAMESPACE_ADDRESSING vpColVector point, int *VOI); /** * Get the intersection between a plane and a straight line. */ -bool intersectionLinePlane(vpMatrix line, const vpColVector &plane, double offset, double &x, double &y, double &z); +bool intersectionLinePlane(VISP_NAMESPACE_ADDRESSING vpMatrix line, const VISP_NAMESPACE_ADDRESSING vpColVector &plane, double offset, double &x, double &y, double &z); /** * Performs linear regression on a set of 3D points. */ -void linearRegression(vpMatrix &points, double &x, double &y, double &z, double &u, double &v, double &w); -void linearRegression(vpMatrix &points, double &a, double &b, double &u, double &v, double &w); +void linearRegression(VISP_NAMESPACE_ADDRESSING vpMatrix &points, double &x, double &y, double &z, double &u, double &v, double &w); +void linearRegression(VISP_NAMESPACE_ADDRESSING vpMatrix &points, double &a, double &b, double &u, double &v, double &w); short quantile(short *data, unsigned int num, unsigned int n); /** * Compute the variance of a set of d-dimensional points. */ -double variance(vpMatrix points, unsigned int npts, unsigned int d); +double variance(VISP_NAMESPACE_ADDRESSING vpMatrix points, unsigned int npts, unsigned int d); } #endif // __usNeedleDetectionTools_h_ diff --git a/modules/ustk_image_processing/ustk_needle_detection/include/visp3/ustk_needle_detection/usNeedleTrackerSIR2D.h b/modules/ustk_image_processing/ustk_needle_detection/include/visp3/ustk_needle_detection/usNeedleTrackerSIR2D.h index 425353cb..dcf8ee92 100644 --- a/modules/ustk_image_processing/ustk_needle_detection/include/visp3/ustk_needle_detection/usNeedleTrackerSIR2D.h +++ b/modules/ustk_image_processing/ustk_needle_detection/include/visp3/ustk_needle_detection/usNeedleTrackerSIR2D.h @@ -69,7 +69,7 @@ class VISP_EXPORT usNeedleTrackerSIR2D * @param model The needle model. * @param I The input image. */ - double computeLikelihood(const usPolynomialCurve2D &model, const vpImage &I); + double computeLikelihood(const usPolynomialCurve2D &model, const VISP_NAMESPACE_ADDRESSING vpImage &I); /** * Returns the detected needle model. @@ -109,7 +109,7 @@ class VISP_EXPORT usNeedleTrackerSIR2D * @param nParticles The number of particles. * @param needle The initial needle model. */ - void init(const vpImage &I, unsigned int nPoints, unsigned int nParticles, + void init(const VISP_NAMESPACE_ADDRESSING vpImage &I, unsigned int nPoints, unsigned int nParticles, const usPolynomialCurve2D &needle); /** @@ -123,7 +123,7 @@ class VISP_EXPORT usNeedleTrackerSIR2D * @param I The input image. * @param v The insertion velocity. */ - void run(vpImage &I, double v); + void run(VISP_NAMESPACE_ADDRESSING vpImage &I, double v); /** * Set the standard deviation for the update noise. @@ -147,9 +147,9 @@ class VISP_EXPORT usNeedleTrackerSIR2D usPolynomialCurve2D *m_needleModel; usPolynomialCurve2D **m_particles; double *m_weights; - vpGaussRand m_noise; - vpUniRand m_sample; - vpMatrix m_sigma; + VISP_NAMESPACE_ADDRESSING vpGaussRand m_noise; + VISP_NAMESPACE_ADDRESSING vpUniRand m_sample; + VISP_NAMESPACE_ADDRESSING vpMatrix m_sigma; double m_lengthThreshold; // Image parameters diff --git a/modules/ustk_image_processing/ustk_needle_detection/src/usNeedleDetectionTools.cpp b/modules/ustk_image_processing/ustk_needle_detection/src/usNeedleDetectionTools.cpp index e805104d..8f7774ac 100644 --- a/modules/ustk_image_processing/ustk_needle_detection/src/usNeedleDetectionTools.cpp +++ b/modules/ustk_image_processing/ustk_needle_detection/src/usNeedleDetectionTools.cpp @@ -33,6 +33,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + void usNeedleDetectionTools::arithmeticMean(vpMatrix points, double *mean, unsigned int npts, unsigned int d) { for (unsigned int i = 0; i < d; i++) { @@ -49,7 +53,7 @@ vpColVector usNeedleDetectionTools::geometricMedian(vpMatrix points, unsigned in { if (npts == 0) { std::cerr << "Error: In usNeedleDetectionTools::geometricMedian(): " - << "argument 2 should be > 0." << std::endl; + << "argument 2 should be > 0." << std::endl; exit(EXIT_FAILURE); } if (npts == 1) { @@ -369,7 +373,7 @@ vpMatrix usNeedleDetectionTools::approximateCoordinates(vpMatrix X, vpMatrix MSS double ss = dirVec.sumSquare(); if (ss == 0.0) { std::cerr << "Error: in usNeedleDetectionTools::approximateCoordinates(): " - << "first and last points are equal." << std::endl; + << "first and last points are equal." << std::endl; exit(EXIT_FAILURE); } ndirVec = dirVec / ss; diff --git a/modules/ustk_image_processing/ustk_needle_detection/src/usNeedleTrackerSIR2D.cpp b/modules/ustk_image_processing/ustk_needle_detection/src/usNeedleTrackerSIR2D.cpp index 641688df..21483016 100644 --- a/modules/ustk_image_processing/ustk_needle_detection/src/usNeedleTrackerSIR2D.cpp +++ b/modules/ustk_image_processing/ustk_needle_detection/src/usNeedleTrackerSIR2D.cpp @@ -34,6 +34,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + usNeedleTrackerSIR2D::usNeedleTrackerSIR2D() { m_needleModel = NULL; @@ -117,7 +121,7 @@ usPolynomialCurve2D *usNeedleTrackerSIR2D::getParticle(unsigned int i) { if (i >= m_nParticles) { std::cerr << "Error: in usNeedleTrackerSIR2D::getParticle(): " - << "Particle index is out of range." << std::endl; + << "Particle index is out of range." << std::endl; exit(EXIT_FAILURE); } return m_particles[i]; @@ -127,7 +131,7 @@ double usNeedleTrackerSIR2D::getWeight(unsigned int i) { if (i >= m_nParticles) { std::cerr << "Error: in usNeedleTrackerSIR2D::getWeight(): " - << "Particle index is out of range." << std::endl; + << "Particle index is out of range." << std::endl; exit(EXIT_FAILURE); } return m_weights[i]; @@ -236,12 +240,12 @@ void usNeedleTrackerSIR2D::run(vpImage &I, double v) if ((m_needleModel->getLength()) > m_lengthThreshold && (m_nPoints != m_nPointsCurrent)) { std::cout << "Changing polynomial order from " << m_nPointsCurrent - 1 << " to " << m_nPointsCurrent << std::endl; usPolynomialCurve2D *newModel = - new usPolynomialCurve2D(m_needleModel->getNewOrderPolynomialCurve(m_nPointsCurrent)); + new usPolynomialCurve2D(m_needleModel->getNewOrderPolynomialCurve(m_nPointsCurrent)); delete m_needleModel; m_needleModel = newModel; for (unsigned int i = 0; i < m_nParticles; ++i) { usPolynomialCurve2D *newModel = - new usPolynomialCurve2D(m_particles[i]->getNewOrderPolynomialCurve(m_nPointsCurrent)); + new usPolynomialCurve2D(m_particles[i]->getNewOrderPolynomialCurve(m_nPointsCurrent)); delete m_particles[i]; m_particles[i] = newModel; } diff --git a/modules/ustk_image_processing/ustk_needle_detection/test/testUsNeedleTracking2D.cpp b/modules/ustk_image_processing/ustk_needle_detection/test/testUsNeedleTracking2D.cpp index 2430f79f..28017469 100644 --- a/modules/ustk_image_processing/ustk_needle_detection/test/testUsNeedleTracking2D.cpp +++ b/modules/ustk_image_processing/ustk_needle_detection/test/testUsNeedleTracking2D.cpp @@ -46,6 +46,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main() { std::string xml_filename; @@ -154,14 +158,14 @@ int main() double error = sqrt(vpMath::sqr(tipMean[0] - tipGroundTruth.at(i)[0]) + vpMath::sqr(tipMean[1] - tipGroundTruth.at(i)[1])); if (error > error_max) { std::cout << "Error " << error << " exeeds " << error_max << " with i error=" << std::abs(tipMean[0] - tipGroundTruth.at(i)[0]) - << ", j error= " << std::abs(tipMean[1] - tipGroundTruth.at(i)[1]) << std::endl; + << ", j error= " << std::abs(tipMean[1] - tipGroundTruth.at(i)[1]) << std::endl; return EXIT_FAILURE; } } tipGroundTruth.clear(); - std::cout << "Test succeed" << std::endl; + std::cout << "Test succeed" << std::endl; return EXIT_SUCCESS; } diff --git a/modules/ustk_image_processing/ustk_tracking/ustk_template_tracking/include/visp3/ustk_template_tracking/usDenseTracker2D.h b/modules/ustk_image_processing/ustk_tracking/ustk_template_tracking/include/visp3/ustk_template_tracking/usDenseTracker2D.h index 53832202..c6fd34c8 100644 --- a/modules/ustk_image_processing/ustk_tracking/ustk_template_tracking/include/visp3/ustk_template_tracking/usDenseTracker2D.h +++ b/modules/ustk_image_processing/ustk_tracking/ustk_template_tracking/include/visp3/ustk_template_tracking/usDenseTracker2D.h @@ -59,28 +59,28 @@ class VISP_EXPORT usDenseTracker2D usDenseTracker2D(); ~usDenseTracker2D(); - vpImage &getRegion(); + VISP_NAMESPACE_ADDRESSING vpImage &getRegion(); - vpRectOriented getTarget() const; + VISP_NAMESPACE_ADDRESSING vpRectOriented getTarget() const; - vpImage &getTemplate(); + VISP_NAMESPACE_ADDRESSING vpImage &getTemplate(); - void init(const vpImage &I, const vpRectOriented &R); + void init(const VISP_NAMESPACE_ADDRESSING vpImage &I, const VISP_NAMESPACE_ADDRESSING vpRectOriented &R); bool isInit(); - void update(const vpImage &I); + void update(const VISP_NAMESPACE_ADDRESSING vpImage &I); private: - vpColVector s_desired; - vpColVector s_current; - vpRectOriented m_target; - vpImage m_template; - vpImage m_region; - vpImage m_gradX; - vpImage m_gradY; - vpMatrix m_LI; - vpMatrix m_LI_inverse; + VISP_NAMESPACE_ADDRESSING vpColVector s_desired; + VISP_NAMESPACE_ADDRESSING vpColVector s_current; + VISP_NAMESPACE_ADDRESSING vpRectOriented m_target; + VISP_NAMESPACE_ADDRESSING vpImage m_template; + VISP_NAMESPACE_ADDRESSING vpImage m_region; + VISP_NAMESPACE_ADDRESSING vpImage m_gradX; + VISP_NAMESPACE_ADDRESSING vpImage m_gradY; + VISP_NAMESPACE_ADDRESSING vpMatrix m_LI; + VISP_NAMESPACE_ADDRESSING vpMatrix m_LI_inverse; unsigned int m_height; unsigned int m_width; unsigned int m_size; diff --git a/modules/ustk_image_processing/ustk_tracking/ustk_template_tracking/src/usDenseTracker2D.cpp b/modules/ustk_image_processing/ustk_tracking/ustk_template_tracking/src/usDenseTracker2D.cpp index 89af4ebb..f7b318de 100644 --- a/modules/ustk_image_processing/ustk_tracking/ustk_template_tracking/src/usDenseTracker2D.cpp +++ b/modules/ustk_image_processing/ustk_tracking/ustk_template_tracking/src/usDenseTracker2D.cpp @@ -37,6 +37,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. */ @@ -45,7 +49,7 @@ usDenseTracker2D::usDenseTracker2D() { m_isInit = false; } /** * Destructor. */ -usDenseTracker2D::~usDenseTracker2D() {} +usDenseTracker2D::~usDenseTracker2D() { } /** * @brief Initialisation of the tracker : to call to set the region to track (R) in the image (I) before starting the @@ -82,7 +86,7 @@ void usDenseTracker2D::init(const vpImage &I, const vpRectOriente m_LI[u * m_width + v][0] = m_gradX[u][v]; m_LI[u * m_width + v][1] = m_gradY[u][v]; m_LI[u * m_width + v][2] = - (static_cast(u) - u0) * m_gradY[u][v] - (static_cast(v) - v0) * m_gradX[u][v]; + (static_cast(u) - u0) * m_gradY[u][v] - (static_cast(v) - v0) * m_gradX[u][v]; } // pseudo inverse of interaction matrix m_LI_inverse = m_LI.pseudoInverse(); diff --git a/modules/ustk_image_processing/ustk_tracking/ustk_template_tracking/test/testUsTemplateTracking.cpp b/modules/ustk_image_processing/ustk_tracking/ustk_template_tracking/test/testUsTemplateTracking.cpp index 8a58ffb4..c026c7b0 100644 --- a/modules/ustk_image_processing/ustk_tracking/ustk_template_tracking/test/testUsTemplateTracking.cpp +++ b/modules/ustk_image_processing/ustk_tracking/ustk_template_tracking/test/testUsTemplateTracking.cpp @@ -38,6 +38,10 @@ #if defined(VISP_HAVE_XML2) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + bool compare(int number1, int number2) { return (number2 == number1); } int main() diff --git a/modules/ustk_image_processing/ustk_volume_processing/include/visp3/ustk_volume_processing/usVolumeProcessing.h b/modules/ustk_image_processing/ustk_volume_processing/include/visp3/ustk_volume_processing/usVolumeProcessing.h index 054098a7..80238e6a 100644 --- a/modules/ustk_image_processing/ustk_volume_processing/include/visp3/ustk_volume_processing/usVolumeProcessing.h +++ b/modules/ustk_image_processing/ustk_volume_processing/include/visp3/ustk_volume_processing/usVolumeProcessing.h @@ -136,15 +136,15 @@ class VISP_EXPORT usVolumeProcessing static usImage3D generateGaussianDerivativeFilterKK(double sigma, int size); - template static void gradient(const usImage3D &src, usImage3D &dst); + template static void gradient(const usImage3D &src, usImage3D &dst); - template static void hessian(const usImage3D &src, usImage3D &dst); + template static void hessian(const usImage3D &src, usImage3D &dst); template static Type max(const usImage3D &V); template static Type min(const usImage3D &V); - static void norm(const usImage3D &src, usImage3D &dst); + static void norm(const usImage3D &src, usImage3D &dst); }; /**************************************************************************** @@ -458,8 +458,12 @@ void usVolumeProcessing::derivativeK(const usImage3D &src, usImage3D void usVolumeProcessing::gradient(const usImage3D &src, usImage3D &dst) +template void usVolumeProcessing::gradient(const usImage3D &src, usImage3D &dst) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + unsigned int height = src.getHeight(); unsigned int width = src.getWidth(); unsigned int nbFrames = src.getNumberOfFrames(); @@ -482,8 +486,12 @@ template void usVolumeProcessing::gradient(const usImage3D &s * @param src The volume to filter. * @param dst The volume filtered. */ -template void usVolumeProcessing::hessian(const usImage3D &src, usImage3D &dst) +template void usVolumeProcessing::hessian(const usImage3D &src, usImage3D &dst) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + unsigned int height = src.getHeight(); unsigned int width = src.getWidth(); unsigned int nbFrames = src.getNumberOfFrames(); @@ -529,6 +537,10 @@ template void usVolumeProcessing::hessian(const usImage3D &sr template void usVolumeProcessing::frangi(const usImage3D &src, usImage3D &dst, double a, double b, double c) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + unsigned int height = src.getHeight(); unsigned int width = src.getWidth(); unsigned int nbFrames = src.getNumberOfFrames(); @@ -555,7 +567,7 @@ void usVolumeProcessing::frangi(const usImage3D &src, usImage3D &d double S = evalues.frobeniusNorm(); v = (1.0 - exp(-vpMath::sqr(Ra) / (2.0 * vpMath::sqr(a)))) * exp(-vpMath::sqr(Rb) / (2.0 * vpMath::sqr(b))) * - (1.0 - exp(-vpMath::sqr(S) / (2.0 * vpMath::sqr(c)))); + (1.0 - exp(-vpMath::sqr(S) / (2.0 * vpMath::sqr(c)))); } dst.getData()[i] = v; } @@ -570,6 +582,10 @@ void usVolumeProcessing::frangi(const usImage3D &src, usImage3D &d template void usVolumeProcessing::difference(const usImage3D &src1, const usImage3D &src2, usImage3D &dst) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + unsigned int height = src1.getHeight(); unsigned int width = src1.getWidth(); unsigned int nbFrames = src1.getNumberOfFrames(); @@ -591,6 +607,10 @@ template void usVolumeProcessing::absoluteDifference(const usImage3D &src1, const usImage3D &src2, usImage3D &dst) { +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + unsigned int height = src1.getHeight(); unsigned int width = src1.getWidth(); unsigned int nbFrames = src1.getNumberOfFrames(); diff --git a/modules/ustk_image_processing/ustk_volume_processing/src/usVolumeProcessing.cpp b/modules/ustk_image_processing/ustk_volume_processing/src/usVolumeProcessing.cpp index 82452293..92dc230e 100644 --- a/modules/ustk_image_processing/ustk_volume_processing/src/usVolumeProcessing.cpp +++ b/modules/ustk_image_processing/ustk_volume_processing/src/usVolumeProcessing.cpp @@ -34,6 +34,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Compute the norm of a vector image. * @param src Input volume. @@ -165,7 +169,7 @@ usImage3D usVolumeProcessing::generateGaussianDerivativeFilterII(double for (int i = 0; i < size; i++) { ddgi = (vpMath::sqr(i - m) / (4.0 * vpMath::sqr(sigma2) * sqrt(2.0 * M_PI)) - 1.0 / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI))) * - exp(-vpMath::sqr(i - m) / (2.0 * sigma2)); + exp(-vpMath::sqr(i - m) / (2.0 * sigma2)); filter(i, j, k, ddgi * gj * gk); } } @@ -196,7 +200,7 @@ usImage3D usVolumeProcessing::generateGaussianDerivativeFilterJJ(double for (int j = 0; j < size; j++) { ddgj = (vpMath::sqr(j - m) / (4.0 * vpMath::sqr(sigma2) * sqrt(2.0 * M_PI)) - 1.0 / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI))) * - exp(-vpMath::sqr(j - m) / (2.0 * sigma2)); + exp(-vpMath::sqr(j - m) / (2.0 * sigma2)); for (int i = 0; i < size; i++) { gi = exp(-vpMath::sqr(i - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI)); filter(i, j, k, gi * ddgj * gk); @@ -227,7 +231,7 @@ usImage3D usVolumeProcessing::generateGaussianDerivativeFilterKK(double for (int k = 0; k < size; k++) { ddgk = (vpMath::sqr(k - m) / (4.0 * vpMath::sqr(sigma2) * sqrt(2.0 * M_PI)) - 1.0 / (2.0 * sigma * sigma2 * sqrt(2.0 * M_PI))) * - exp(-vpMath::sqr(k - m) / (2.0 * sigma2)); + exp(-vpMath::sqr(k - m) / (2.0 * sigma2)); for (int j = 0; j < size; j++) { gj = exp(-vpMath::sqr(j - m) / (2.0 * sigma2)) / (sigma * sqrt(2.0 * M_PI)); for (int i = 0; i < size; i++) { diff --git a/modules/ustk_image_processing/ustk_volume_processing/test/testVolumeProcessing.cpp b/modules/ustk_image_processing/ustk_volume_processing/test/testVolumeProcessing.cpp index 91634db8..8b89435e 100644 --- a/modules/ustk_image_processing/ustk_volume_processing/test/testVolumeProcessing.cpp +++ b/modules/ustk_image_processing/ustk_volume_processing/test/testVolumeProcessing.cpp @@ -42,6 +42,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main() { std::cout << "Start testVolumeProcessing" << std::endl; @@ -151,7 +155,7 @@ int main() std::cout << "done: usVolumeProcessing::frangi" << std::endl; #else std::cout << "ViSP does not have GSL 3rd party to compute usVolumeProcessing::frangi, skipping frangi test." - << std::endl; + << std::endl; #endif usImage3D Vvect(size, size, size, vpColVector(3, 1)); diff --git a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelInterface.h b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelInterface.h index 9a39a15a..78f7099a 100644 --- a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelInterface.h +++ b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelInterface.h @@ -43,27 +43,27 @@ class VISP_EXPORT usNeedleInsertionModelInterface //! The following methods should be redefined in the derived classes virtual bool setBasePose( - const vpPoseVector &pose) = 0; // must set the base pose and automatically update the whole state of the model - virtual vpPoseVector getBasePose() const = 0; + const VISP_NAMESPACE_ADDRESSING vpPoseVector &pose) = 0; // must set the base pose and automatically update the whole state of the model + virtual VISP_NAMESPACE_ADDRESSING vpPoseVector getBasePose() const = 0; //! These function simply overload the previous ones bool setBasePose(double tx, double ty, double tz, double thetax, double thetay, double thetaz); - bool setBasePose(const vpHomogeneousMatrix &Hpose); + bool setBasePose(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &Hpose); - vpHomogeneousMatrix getWorldMbase() const; - vpColVector getBasePosition() const; + VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix getWorldMbase() const; + VISP_NAMESPACE_ADDRESSING vpColVector getBasePosition() const; - bool moveBase(const vpColVector &v, double time); + bool moveBase(const VISP_NAMESPACE_ADDRESSING vpColVector &v, double time); bool moveBase(double tx, double ty, double tz, double thetax, double thetay, double thetaz); - bool moveBase(const vpPoseVector &pose); - bool moveBase(const vpColVector &v); - bool moveBase(const vpHomogeneousMatrix &Hmotion); + bool moveBase(const VISP_NAMESPACE_ADDRESSING vpPoseVector &pose); + bool moveBase(const VISP_NAMESPACE_ADDRESSING vpColVector &v); + bool moveBase(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &Hmotion); - bool moveBaseWorldFrame(const vpColVector &command, double time); + bool moveBaseWorldFrame(const VISP_NAMESPACE_ADDRESSING vpColVector &command, double time); bool moveBaseWorldFrame(double tx, double ty, double tz, double thetax, double thetay, double thetaz); - bool moveBaseWorldFrame(const vpPoseVector &pose); - bool moveBaseWorldFrame(const vpColVector &v); - bool moveBaseWorldFrame(const vpHomogeneousMatrix &Hmotion); + bool moveBaseWorldFrame(const VISP_NAMESPACE_ADDRESSING vpPoseVector &pose); + bool moveBaseWorldFrame(const VISP_NAMESPACE_ADDRESSING vpColVector &v); + bool moveBaseWorldFrame(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &Hmotion); }; #endif // __usNeedleInsertionModelInterface_h diff --git a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelKinematic.h b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelKinematic.h index eebf0785..21d85d10 100644 --- a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelKinematic.h +++ b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelKinematic.h @@ -73,8 +73,8 @@ class VISP_EXPORT usNeedleInsertionModelKinematic : public usNeedleInsertionMode bool moveBase(double controlCurvature, double vz, double wz, double time); using usNeedleInsertionModelInterface::setBasePose; - bool setBasePose(const vpPoseVector &pose); - vpPoseVector getBasePose() const; + bool setBasePose(const VISP_NAMESPACE_ADDRESSING vpPoseVector &pose); + VISP_NAMESPACE_ADDRESSING vpPoseVector getBasePose() const; }; #endif // __usNeedleInsertionModelKinematic_h diff --git a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelRayleighRitzSpline.h b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelRayleighRitzSpline.h index 89b52221..c56fea45 100644 --- a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelRayleighRitzSpline.h +++ b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelRayleighRitzSpline.h @@ -53,7 +53,8 @@ class VISP_EXPORT usNeedleInsertionModelRayleighRitzSpline : public usNeedleInsertionModelInterface { public: - enum class ModelPreset : int { + enum class ModelPreset : int + { BiopsyNeedle, BiopsyCannula, Symmetric, @@ -158,8 +159,8 @@ class VISP_EXPORT usNeedleInsertionModelRayleighRitzSpline : public usNeedleInse bool IsNeedleInserted() const; double getNeedleFreeLength(int *seg = nullptr, double *param = nullptr) const; double getInsertionDepth() const; - vpColVector getNeedleInsertionPoint() const; - vpColVector getTissueInsertionPoint() const; + VISP_NAMESPACE_ADDRESSING vpColVector getNeedleInsertionPoint() const; + VISP_NAMESPACE_ADDRESSING vpColVector getTissueInsertionPoint() const; bool getCorrespondingPathPoint(double l, int &correspondingRestIndex, double &correspondingRestParam) const; @@ -179,13 +180,13 @@ class VISP_EXPORT usNeedleInsertionModelRayleighRitzSpline : public usNeedleInse //! Control of the needle using usNeedleInsertionModelInterface::setBasePose; - bool setBasePose(const vpPoseVector &p); - vpPoseVector getBasePose() const; + bool setBasePose(const VISP_NAMESPACE_ADDRESSING vpPoseVector &p); + VISP_NAMESPACE_ADDRESSING vpPoseVector getBasePose() const; //! Control of the tissue void setSurfaceAtTip(); - bool cutPathToPoint(const vpColVector &P); + bool cutPathToPoint(const VISP_NAMESPACE_ADDRESSING vpColVector &P); //! Internal model command diff --git a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelVirtualSprings.h b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelVirtualSprings.h index e5f62407..21bc2783 100644 --- a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelVirtualSprings.h +++ b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleInsertionModelVirtualSprings.h @@ -51,7 +51,8 @@ class VISP_EXPORT usNeedleInsertionModelVirtualSprings : public usNeedleInsertio { public: enum class InsertionType : int { ForceInsert, ForceRemove, NaturalBehavior }; - enum class ModelPreset : int { + enum class ModelPreset : int + { BiopsyNeedle, BiopsyCannula, AbayazidRRM13, @@ -155,8 +156,8 @@ class VISP_EXPORT usNeedleInsertionModelVirtualSprings : public usNeedleInsertio const usNeedleModelSpline &accessNeedle() const; usNeedleModelSpline &accessNeedle(); bool IsNeedleInserted() const; - vpColVector getNeedleInsertionPoint() const; - vpColVector getTissueInsertionPoint() const; + VISP_NAMESPACE_ADDRESSING vpColVector getNeedleInsertionPoint() const; + VISP_NAMESPACE_ADDRESSING vpColVector getTissueInsertionPoint() const; double getNeedleFreeLength() const; double getInsertionDepth() const; @@ -191,7 +192,7 @@ class VISP_EXPORT usNeedleInsertionModelVirtualSprings : public usNeedleInsertio //! Needle position - double getPathDistanceFromPoint(const vpColVector &P) const; + double getPathDistanceFromPoint(const VISP_NAMESPACE_ADDRESSING vpColVector &P) const; //! Tissue deformation energy @@ -205,20 +206,20 @@ class VISP_EXPORT usNeedleInsertionModelVirtualSprings : public usNeedleInsertio //! Control of the needle using usNeedleInsertionModelInterface::setBasePose; - bool setBasePose(const vpPoseVector &p); - vpPoseVector getBasePose() const; + bool setBasePose(const VISP_NAMESPACE_ADDRESSING vpPoseVector &p); + VISP_NAMESPACE_ADDRESSING vpPoseVector getBasePose() const; //! Control of the tissue void addMeasureSpring( - const vpColVector &p, - const vpColVector &d); // Add a spring in space and recompute stiffnesses in vicinity to keep the tissue property + const VISP_NAMESPACE_ADDRESSING vpColVector &p, + const VISP_NAMESPACE_ADDRESSING vpColVector &d); // Add a spring in space and recompute stiffnesses in vicinity to keep the tissue property - bool setSpringPosition(int index, const vpColVector &P, bool update = false); - bool setSpringDirection(int index, const vpColVector &D, bool update = false); + bool setSpringPosition(int index, const VISP_NAMESPACE_ADDRESSING vpColVector &P, bool update = false); + bool setSpringDirection(int index, const VISP_NAMESPACE_ADDRESSING vpColVector &D, bool update = false); void setSpringStiffness(int index, double K, bool update = false); - bool moveSpringPosition(int index, const vpColVector &dP, bool update = false); - bool moveSpringDirection(int index, const vpThetaUVector &thetaU, bool update = false); + bool moveSpringPosition(int index, const VISP_NAMESPACE_ADDRESSING vpColVector &dP, bool update = false); + bool moveSpringDirection(int index, const VISP_NAMESPACE_ADDRESSING vpThetaUVector &thetaU, bool update = false); void addSpringStiffness(int index, double dK, bool update = false); void setSurfaceAtTip(); @@ -227,8 +228,8 @@ class VISP_EXPORT usNeedleInsertionModelVirtualSprings : public usNeedleInsertio int addInsertionPoint(usVirtualSpring spg); int addInsertionPoint( - const vpColVector &p, - const vpColVector &d); // Add a spring in space and recompute stiffnesses in vicinity to keep the tissue property + const VISP_NAMESPACE_ADDRESSING vpColVector &p, + const VISP_NAMESPACE_ADDRESSING vpColVector &d); // Add a spring in space and recompute stiffnesses in vicinity to keep the tissue property void addInsertionPointOnSegmentHard(int segment, double s); // Add a spring on the needle with default spring stiffness diff --git a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleJacobians.h b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleJacobians.h index 865effff..097f0148 100644 --- a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleJacobians.h +++ b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleJacobians.h @@ -46,736 +46,817 @@ namespace usNeedleJacobians { //! Generic Jacobians - - template - bool getJacobian(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputVectorMethod, std::function DifferenceMethod, vpMatrix &J, const vpColVector &discretizationStep, bool centeredDifference=true); - - template - bool getJacobianScalarToScalar(NeedleInsertionModel model, std::function InputScalarMethod, std::function OutputScalarMethod, vpMatrix &J, double discretizationStep = 1e-5, bool centeredDifference=true); - - template - bool getJacobianScalarToVector(NeedleInsertionModel model, std::function InputScalarMethod, std::function OutputVectorMethod, vpMatrix &J, double discretizationStep = 1e-5, bool centeredDifference=true); - - template - bool getJacobianVectorToScalar(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputScalarMethod, vpMatrix &J, const vpColVector &discretizationStep, bool centeredDifference=true); - - template - bool getJacobianVectorToVector(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputVectorMethod, vpMatrix &J, const vpColVector &discretizationStep, bool centeredDifference=true); - - template - bool getJacobianVectorToPose(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputVectorMethod, vpMatrix &J, const vpColVector &discretizationStep, bool centeredDifference=true); - - //! Base to tip (manipulation Jacobian) (6x6) - - template - bool getJacobianWorldBaseVelocityToWorldTipVelocity(const NeedleInsertionModel &model, vpMatrix &J); - - template - bool getJacobianBaseVelocityToWorldTipVelocity(const NeedleInsertionModel &model, vpMatrix &J); - - template - bool getJacobianWorldBaseVelocityToTipVelocity(const NeedleInsertionModel &model, vpMatrix &J); - - template - bool getJacobianBaseVelocityToTipVelocity(const NeedleInsertionModel &model, vpMatrix &J); - - //! Base to bending energy (1x6) - - template - bool getJacobianBaseVelocityToBendingEnergy(const NeedleInsertionModel &model, vpMatrix &J); - - template - bool getJacobianWorldBaseVelocityToBendingEnergy(const NeedleInsertionModel &model, vpMatrix &J); - - //! Base to tissue deformation energy (1x6) - - template - bool getJacobianBaseVelocityToTissueEnergy(const NeedleInsertionModel &model, vpMatrix &J); - - template - bool getJacobianWorldBaseVelocityToTissueEnergy(const NeedleInsertionModel &model, vpMatrix &J); - - template - bool getJacobianBaseVelocityToNeedleInsertionPointVelocity(const NeedleInsertionModel &model, vpMatrix &J); - - template - bool getJacobianBaseVelocityToSurfaceTissueStretch(const NeedleInsertionModel &model, vpMatrix &J); - - template - bool getJacobianBaseVelocityToMaxTissueStretch(const NeedleInsertionModel &model, vpMatrix &J); - - template - bool getJacobianBaseVelocityToMeanTissueStretch(const NeedleInsertionModel &model, vpMatrix &J); - - //! Base to needle point (3x6) - - template - bool getJacobianBaseVelocityToPointVelocity(const NeedleInsertionModel &model, vpMatrix &J, double l); - - template - bool getJacobianWorldBaseVelocityToPointVelocity(const NeedleInsertionModel &model, vpMatrix &J, double l); - - //! Base to features (1x6) - - template - bool getJacobianBaseVelocityToTransversalTargetDistance(const NeedleInsertionModel &model, vpMatrix &J, const vpColVector &target); - - template - bool getJacobianBaseVelocityToTargetAngle(const NeedleInsertionModel &model, vpMatrix &J, const vpColVector &target); - - //! Springs to needle point (3x6) - - template - bool getJacobianSpringVelocityToPointVelocity(const NeedleInsertionModel &model, vpMatrix &J, int spring, double l); - - //! Springs to distance from points (nbPointsx6) - - template - bool getJacobianSpringVelocityToPointsDistance(const NeedleInsertionModel &model, vpMatrix &J, int spring, const std::vector &points); - - //! Rest path points to model point (3x3) - - template - bool getJacobianRestPathPointVelocityToPointsVelocity(const NeedleInsertionModel &model, vpMatrix &J, int restPoint, const std::vector &l); - - //! Rest path points distance from points (nbPointsx3) - - template - bool getJacobianRestPathPointVelocityToPointsDistance(const NeedleInsertionModel &model, vpMatrix &J, int restPoint, const std::vector &points); - - //! Stiffness per unit length to distance from points (nbPointsx1) - - template - bool getJacobianStiffnessPerUnitLengthToPointsDistance(const NeedleInsertionModel &model, vpMatrix &J, const std::vector &points); - - //! Stiffness per unit length to needle point ( (3*nbPoints)x1 matrix) - - template - bool getJacobianStiffnessPerUnitLengthToPointsVelocity(const NeedleInsertionModel &model, vpMatrix &J, const std::vector &l); - - /*! - * Implementation - !*/ - - //! Generic Jacobian computation - - template - bool getJacobian(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputVectorMethod, std::function DifferenceMethod, vpMatrix &J, const vpColVector &discretizationStep, bool centeredDifference) - { + +template +bool getJacobian(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputVectorMethod, std::function DifferenceMethod, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const VISP_NAMESPACE_ADDRESSING vpColVector &discretizationStep, bool centeredDifference = true); + +template +bool getJacobianScalarToScalar(NeedleInsertionModel model, std::function InputScalarMethod, std::function OutputScalarMethod, VISP_NAMESPACE_ADDRESSING vpMatrix &J, double discretizationStep = 1e-5, bool centeredDifference = true); + +template +bool getJacobianScalarToVector(NeedleInsertionModel model, std::function InputScalarMethod, std::function OutputVectorMethod, VISP_NAMESPACE_ADDRESSING vpMatrix &J, double discretizationStep = 1e-5, bool centeredDifference = true); + +template +bool getJacobianVectorToScalar(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputScalarMethod, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const VISP_NAMESPACE_ADDRESSING vpColVector &discretizationStep, bool centeredDifference = true); + +template +bool getJacobianVectorToVector(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputVectorMethod, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const VISP_NAMESPACE_ADDRESSING vpColVector &discretizationStep, bool centeredDifference = true); + +template +bool getJacobianVectorToPose(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputVectorMethod, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const VISP_NAMESPACE_ADDRESSING vpColVector &discretizationStep, bool centeredDifference = true); + +//! Base to tip (manipulation Jacobian) (6x6) + +template +bool getJacobianWorldBaseVelocityToWorldTipVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J); + +template +bool getJacobianBaseVelocityToWorldTipVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J); + +template +bool getJacobianWorldBaseVelocityToTipVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J); + +template +bool getJacobianBaseVelocityToTipVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J); + +//! Base to bending energy (1x6) + +template +bool getJacobianBaseVelocityToBendingEnergy(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J); + +template +bool getJacobianWorldBaseVelocityToBendingEnergy(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J); + +//! Base to tissue deformation energy (1x6) + +template +bool getJacobianBaseVelocityToTissueEnergy(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J); + +template +bool getJacobianWorldBaseVelocityToTissueEnergy(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J); + +template +bool getJacobianBaseVelocityToNeedleInsertionPointVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J); + +template +bool getJacobianBaseVelocityToSurfaceTissueStretch(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J); + +template +bool getJacobianBaseVelocityToMaxTissueStretch(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J); + +template +bool getJacobianBaseVelocityToMeanTissueStretch(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J); + +//! Base to needle point (3x6) + +template +bool getJacobianBaseVelocityToPointVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, double l); + +template +bool getJacobianWorldBaseVelocityToPointVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, double l); + +//! Base to features (1x6) + +template +bool getJacobianBaseVelocityToTransversalTargetDistance(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const VISP_NAMESPACE_ADDRESSING vpColVector &target); + +template +bool getJacobianBaseVelocityToTargetAngle(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const VISP_NAMESPACE_ADDRESSING vpColVector &target); + +//! Springs to needle point (3x6) + +template +bool getJacobianSpringVelocityToPointVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, int spring, double l); + +//! Springs to distance from points (nbPointsx6) + +template +bool getJacobianSpringVelocityToPointsDistance(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, int spring, const std::vector &points); + +//! Rest path points to model point (3x3) + +template +bool getJacobianRestPathPointVelocityToPointsVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, int restPoint, const std::vector &l); + +//! Rest path points distance from points (nbPointsx3) + +template +bool getJacobianRestPathPointVelocityToPointsDistance(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, int restPoint, const std::vector &points); + +//! Stiffness per unit length to distance from points (nbPointsx1) + +template +bool getJacobianStiffnessPerUnitLengthToPointsDistance(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const std::vector &points); + +//! Stiffness per unit length to needle point ( (3*nbPoints)x1 matrix) + +template +bool getJacobianStiffnessPerUnitLengthToPointsVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const std::vector &l); + +/*! + * Implementation +!*/ + +//! Generic Jacobian computation + +template +bool getJacobian(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputVectorMethod, std::function DifferenceMethod, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const VISP_NAMESPACE_ADDRESSING vpColVector &discretizationStep, bool centeredDifference) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif // dVectorOut = J * dVectorIn - - double stepFactor = (centeredDifference?2:1); - NeedleInsertionModel SimulationNeedle(model); - - int dim = discretizationStep.size(); - vpColVector test(OutputVectorMethod(SimulationNeedle)); - vpMatrix M(test.size(), dim); - - vpColVector v2; - if(!centeredDifference) v2 = OutputVectorMethod(model); - for(int i=0 ; i - bool getJacobianScalarToScalar(NeedleInsertionModel model, std::function InputScalarMethod, std::function OutputScalarMethod, vpMatrix &J, double discretizationStep, bool centeredDifference) - { + J = M; + + return true; +} + +template +bool getJacobianScalarToScalar(NeedleInsertionModel model, std::function InputScalarMethod, std::function OutputScalarMethod, VISP_NAMESPACE_ADDRESSING vpMatrix &J, double discretizationStep, bool centeredDifference) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif // dScalarOut = J * dScalarIn - std::function InputVectorMethod = [&InputScalarMethod](NeedleInsertionModel& m, const vpColVector& v) - { - return InputScalarMethod(m, v[0]); - }; - - std::function OutputVectorMethod = [&OutputScalarMethod](const NeedleInsertionModel& m) - { - return vpColVector(1,OutputScalarMethod(m)); - }; - - std::function DifferenceMethod = [](const vpColVector& v1, const vpColVector& v2, const double step) - { - return 1./step*(v1-v2); - }; - vpColVector vectorDiscretizationStep(1,discretizationStep); - - return getJacobian(model, InputVectorMethod, OutputVectorMethod, DifferenceMethod, J, vectorDiscretizationStep, centeredDifference); - } + std::function InputVectorMethod = [&InputScalarMethod](NeedleInsertionModel &m, const vpColVector &v) + { + return InputScalarMethod(m, v[0]); + }; - template - bool getJacobianScalarToVector(NeedleInsertionModel model, std::function InputScalarMethod, std::function OutputVectorMethod, vpMatrix &J, double discretizationStep, bool centeredDifference) - { - // dVectorOut = J * dScalarIn + std::function OutputVectorMethod = [&OutputScalarMethod](const NeedleInsertionModel &m) + { + return vpColVector(1, OutputScalarMethod(m)); + }; - std::function InputVectorMethod = [&InputScalarMethod](NeedleInsertionModel& m, const vpColVector& v) - { - return InputScalarMethod(m, v[0]); - }; - - std::function DifferenceMethod = [](const vpColVector& v1, const vpColVector& v2, const double step) - { - return 1./step*(v1-v2); - }; - vpColVector vectorDiscretizationStep(1,discretizationStep); - - return getJacobian(model, InputVectorMethod, OutputVectorMethod, DifferenceMethod, J, vectorDiscretizationStep, centeredDifference); - } + std::function DifferenceMethod = [](const vpColVector &v1, const vpColVector &v2, const double step) + { + return 1./step*(v1-v2); + }; + vpColVector vectorDiscretizationStep(1, discretizationStep); - template - bool getJacobianVectorToScalar(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputScalarMethod, vpMatrix &J, const vpColVector &discretizationStep, bool centeredDifference) - { - // dScalarOut = J * dVectorIn - - std::function OutputVectorMethod = [&OutputScalarMethod](const NeedleInsertionModel& m) - { - return vpColVector(1,OutputScalarMethod(m)); - }; - - std::function DifferenceMethod = [](const vpColVector& v1, const vpColVector& v2, const double step) - { - return 1./step*(v1-v2); - }; - - return getJacobian(model, InputVectorMethod, OutputVectorMethod, DifferenceMethod, J, discretizationStep, centeredDifference); - } + return getJacobian(model, InputVectorMethod, OutputVectorMethod, DifferenceMethod, J, vectorDiscretizationStep, centeredDifference); +} - template - bool getJacobianVectorToVector(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputVectorMethod, vpMatrix &J, const vpColVector &discretizationStep, bool centeredDifference) - { - // dVectorOut = J * dVectorIn +template +bool getJacobianScalarToVector(NeedleInsertionModel model, std::function InputScalarMethod, std::function OutputVectorMethod, VISP_NAMESPACE_ADDRESSING vpMatrix &J, double discretizationStep, bool centeredDifference) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + // dVectorOut = J * dScalarIn - std::function DifferenceMethod = [](const vpColVector& v1, const vpColVector& v2, const double step) - { - return 1./step*(v1-v2); - }; + std::function InputVectorMethod = [&InputScalarMethod](NeedleInsertionModel &m, const vpColVector &v) + { + return InputScalarMethod(m, v[0]); + }; - return getJacobian(model, InputVectorMethod, OutputVectorMethod, DifferenceMethod, J, discretizationStep, centeredDifference); - } + std::function DifferenceMethod = [](const vpColVector &v1, const vpColVector &v2, const double step) + { + return 1./step*(v1-v2); + }; + vpColVector vectorDiscretizationStep(1, discretizationStep); - template - bool getJacobianVectorToPose(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputVectorMethod, vpMatrix &J, const vpColVector &discretizationStep, bool centeredDifference) - { - // dPose/dt= J * dVectorIn/dt (use exponential map instead of difference) - - std::function trueOutputVectorMethod = [&OutputVectorMethod](const NeedleInsertionModel& m) - { - return vpColVector(vpPoseVector(OutputVectorMethod(m))); - }; - - std::function DifferenceMethod = [](const vpColVector& v1, const vpColVector& v2, const double step) - { - vpHomogeneousMatrix H1(v1[0], v1[1], v1[2], v1[3], v1[4], v1[5]); - vpHomogeneousMatrix H2(v2[0], v2[1], v2[2], v2[3], v2[4], v2[5]); - return vpExponentialMap::inverse(H2.inverse()*H1, step); - }; - - return getJacobian(model, InputVectorMethod, trueOutputVectorMethod, DifferenceMethod, J, discretizationStep, centeredDifference); - } + return getJacobian(model, InputVectorMethod, OutputVectorMethod, DifferenceMethod, J, vectorDiscretizationStep, centeredDifference); +} - //! Base to tip - - template - bool getJacobianWorldBaseVelocityToTipVelocity(const NeedleInsertionModel &model, vpMatrix &J) - { - vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBaseWorldFrame(v); - return n.updateState(); - }; - std::function OutputFunction = [](const NeedleInsertionModel& n) - { - return n.accessNeedle().getWorldMtip(); - }; - - bool success = getJacobianVectorToPose(model, InputFunction, OutputFunction, J, discretStep); - - return success; - } +template +bool getJacobianVectorToScalar(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputScalarMethod, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const VISP_NAMESPACE_ADDRESSING vpColVector &discretizationStep, bool centeredDifference) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + // dScalarOut = J * dVectorIn - template - bool getJacobianBaseVelocityToTipVelocity(const NeedleInsertionModel &model, vpMatrix &J) - { - vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBase(v); - return n.updateState(); - }; - std::function OutputFunction = [](const NeedleInsertionModel& n) - { - return n.accessNeedle().getWorldMtip(); - }; - - bool success = getJacobianVectorToPose(model, InputFunction, OutputFunction, J, discretStep); - - return success; - } + std::function OutputVectorMethod = [&OutputScalarMethod](const NeedleInsertionModel &m) + { + return vpColVector(1, OutputScalarMethod(m)); + }; - template - bool getJacobianWorldBaseVelocityToWorldTipVelocity(const NeedleInsertionModel &model, vpMatrix &J) - { - vpMatrix M; - bool success = getJacobianWorldBaseVelocityToTipVelocity(model,M); + std::function DifferenceMethod = [](const vpColVector &v1, const vpColVector &v2, const double step) + { + return 1./step*(v1-v2); + }; - if(success) - { - // Vtip_tip = J * Vbase_world - // (worldRtip 0 ) - // => Vtip_world = ( 0 worldRtip) * J * Vbase_world + return getJacobian(model, InputVectorMethod, OutputVectorMethod, DifferenceMethod, J, discretizationStep, centeredDifference); +} - vpRotationMatrix worldRtip(model.accessNeedle().getWorldMtip()); +template +bool getJacobianVectorToVector(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputVectorMethod, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const VISP_NAMESPACE_ADDRESSING vpColVector &discretizationStep, bool centeredDifference) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + // dVectorOut = J * dVectorIn - vpMatrix Jtranslation(M, 0,0, 3,6); - vpMatrix Jrotation(M, 3,0, 3,6); + std::function DifferenceMethod = [](const vpColVector &v1, const vpColVector &v2, const double step) + { + return 1./step*(v1-v2); + }; - Jtranslation = static_cast(worldRtip) * Jtranslation; - Jrotation = static_cast(worldRtip) * Jrotation; + return getJacobian(model, InputVectorMethod, OutputVectorMethod, DifferenceMethod, J, discretizationStep, centeredDifference); +} - J.resize(6,6); - J.insert(Jtranslation, 0,0); - J.insert(Jrotation, 3,0); - } +template +bool getJacobianVectorToPose(NeedleInsertionModel model, std::function InputVectorMethod, std::function OutputVectorMethod, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const VISP_NAMESPACE_ADDRESSING vpColVector &discretizationStep, bool centeredDifference) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + // dPose/dt= J * dVectorIn/dt (use exponential map instead of difference) - return success; - } + std::function trueOutputVectorMethod = [&OutputVectorMethod](const NeedleInsertionModel &m) + { + return vpColVector(vpPoseVector(OutputVectorMethod(m))); + }; - template - bool getJacobianBaseVelocityToWorldTipVelocity(const NeedleInsertionModel &model, vpMatrix &J) - { - vpMatrix M; - bool success = getJacobianBaseVelocityToTipVelocity(model,M); + std::function DifferenceMethod = [](const vpColVector &v1, const vpColVector &v2, const double step) + { + vpHomogeneousMatrix H1(v1[0], v1[1], v1[2], v1[3], v1[4], v1[5]); + vpHomogeneousMatrix H2(v2[0], v2[1], v2[2], v2[3], v2[4], v2[5]); + return vpExponentialMap::inverse(H2.inverse()*H1, step); + }; - if(success) - { - // Vtip_tip = J * Vbase_base - // (worldRtip 0 ) - // => Vtip_world = ( 0 worldRtip) * J * Vbase_base + return getJacobian(model, InputVectorMethod, trueOutputVectorMethod, DifferenceMethod, J, discretizationStep, centeredDifference); +} - vpRotationMatrix worldRtip(model.accessNeedle().getWorldMtip()); +//! Base to tip - vpMatrix Jtranslation(M, 0,0, 3,6); - vpMatrix Jrotation(M, 3,0, 3,6); +template +bool getJacobianWorldBaseVelocityToTipVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBaseWorldFrame(v); + return n.updateState(); + }; + std::function OutputFunction = [](const NeedleInsertionModel &n) + { + return n.accessNeedle().getWorldMtip(); + }; + + bool success = getJacobianVectorToPose(model, InputFunction, OutputFunction, J, discretStep); + + return success; +} + +template +bool getJacobianBaseVelocityToTipVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBase(v); + return n.updateState(); + }; + std::function OutputFunction = [](const NeedleInsertionModel &n) + { + return n.accessNeedle().getWorldMtip(); + }; + + bool success = getJacobianVectorToPose(model, InputFunction, OutputFunction, J, discretStep); + + return success; +} + +template +bool getJacobianWorldBaseVelocityToWorldTipVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpMatrix M; + bool success = getJacobianWorldBaseVelocityToTipVelocity(model, M); - Jtranslation = static_cast(worldRtip) * Jtranslation; - Jrotation = static_cast(worldRtip) * Jrotation; + if (success) { + // Vtip_tip = J * Vbase_world + // (worldRtip 0 ) + // => Vtip_world = ( 0 worldRtip) * J * Vbase_world - J.resize(6,6); - J.insert(Jtranslation, 0,0); - J.insert(Jrotation, 3,0); - } + vpRotationMatrix worldRtip(model.accessNeedle().getWorldMtip()); - return success; - } + vpMatrix Jtranslation(M, 0, 0, 3, 6); + vpMatrix Jrotation(M, 3, 0, 3, 6); - //! Base to bending energy (1x6) - - template - bool getJacobianBaseVelocityToBendingEnergy(const NeedleInsertionModel &model, vpMatrix &J) - { - vpColVector discretStep(6, 1e-5*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBase(v); - return n.updateState(); - }; - std::function OutputFunction = [](const NeedleInsertionModel& n){return n.accessNeedle().getBendingEnergy();}; - return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); - } + Jtranslation = static_cast(worldRtip) * Jtranslation; + Jrotation = static_cast(worldRtip) * Jrotation; - template - bool getJacobianWorldBaseVelocityToBendingEnergy(const NeedleInsertionModel &model, vpMatrix &J) - { - vpColVector discretStep(6, 1e-5*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBaseWorldFrame(v); - return n.updateState(); - }; - std::function OutputFunction = [](const NeedleInsertionModel& n){return n.accessNeedle().getBendingEnergy();}; - return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); + J.resize(6, 6); + J.insert(Jtranslation, 0, 0); + J.insert(Jrotation, 3, 0); } - //! Base to tissue deformation energy (1x6) - - template - bool getJacobianBaseVelocityToTissueEnergy(const NeedleInsertionModel &model, vpMatrix &J) - { - vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBase(v); - return n.updateState(); - }; - std::function OutputFunction = [](const NeedleInsertionModel& n){return n.getTissueDeformationEnergy();}; - return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); - } + return success; +} - template - bool getJacobianWorldBaseVelocityToTissueEnergy(const NeedleInsertionModel &model, vpMatrix &J) - { - vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBase(v); - return n.updateState(); - }; - std::function OutputFunction = [](const NeedleInsertionModel& n){return n.getTissueDeformationEnergy();}; - return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); - } +template +bool getJacobianBaseVelocityToWorldTipVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpMatrix M; + bool success = getJacobianBaseVelocityToTipVelocity(model, M); - template - bool getJacobianBaseVelocityToNeedleInsertionPointVelocity(const NeedleInsertionModel &model, vpMatrix &J) - { - vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBase(v); - return n.updateState(); - }; - std::function OutputFunction = [](const NeedleInsertionModel& n){return n.getNeedleInsertionPoint();}; - return getJacobianVectorToVector(model, InputFunction, OutputFunction, J, discretStep); - } + if (success) { + // Vtip_tip = J * Vbase_base + // (worldRtip 0 ) + // => Vtip_world = ( 0 worldRtip) * J * Vbase_base - template - bool getJacobianBaseVelocityToBaseForceTorque(const NeedleInsertionModel &model, vpMatrix &J) - { - vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBase(v); - return n.updateState(); - }; - std::function OutputFunction = [](const NeedleInsertionModel& n) - { - vpColVector baseForceTorque = n.accessNeedle().getBaseStaticTorsor(); - vpRotationMatrix bRw = n.accessNeedle().getWorldMbase().getRotationMatrix().inverse(); - baseForceTorque.insert(0, bRw * vpColVector(baseForceTorque, 0,3)); - baseForceTorque.insert(3, bRw * vpColVector(baseForceTorque, 3,3)); - return baseForceTorque; - }; - return getJacobianVectorToVector(model, InputFunction, OutputFunction, J, discretStep); - } + vpRotationMatrix worldRtip(model.accessNeedle().getWorldMtip()); - template - bool getJacobianBaseVelocityToInsertionLength(const NeedleInsertionModel &model, vpMatrix &J) - { - vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBase(v); - return n.updateState(); - }; - std::function OutputFunction = [](const NeedleInsertionModel& n){return n.getInsertionDepth();}; - return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); - } + vpMatrix Jtranslation(M, 0, 0, 3, 6); + vpMatrix Jrotation(M, 3, 0, 3, 6); - template - bool getJacobianBaseVelocityToSurfaceTissueStretch(const NeedleInsertionModel &model, vpMatrix &J) - { - vpColVector e = model.getNeedleInsertionPoint() - model.getTissueInsertionPoint(); - double norm = e.frobeniusNorm(); - if(norm <= std::numeric_limits::epsilon()) return false; - else e /= norm; - - vpMatrix M(6,3,0); - if(getJacobianBaseVelocityToNeedleInsertionPointVelocity(model,M)) - { - J = e.t() * M; - return true; - } - else return false; - } + Jtranslation = static_cast(worldRtip) * Jtranslation; + Jrotation = static_cast(worldRtip) * Jrotation; - template - bool getJacobianBaseVelocityToMaxTissueStretch(const NeedleInsertionModel &model, vpMatrix &J) - { - vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBase(v); - return n.updateState(); - }; - std::function OutputFunction = [](const NeedleInsertionModel& n){return n.getMaxTissueStretch();}; - return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); + J.resize(6, 6); + J.insert(Jtranslation, 0, 0); + J.insert(Jrotation, 3, 0); } - template - bool getJacobianBaseVelocityToMeanTissueStretch(const NeedleInsertionModel &model, vpMatrix &J) - { - vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBase(v); - return n.updateState(); - }; - std::function OutputFunction = [](const NeedleInsertionModel& n){return n.getMeanTissueStretch();}; - return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); - } + return success; +} - //! Base to model point (3x6) - - template - bool getJacobianBaseVelocityToPointVelocity(const NeedleInsertionModel &model, vpMatrix &J, double l) - { - vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBase(v); - return n.updateState(); - }; - std::function OutputFunction = [l](const NeedleInsertionModel& n){return n.accessNeedle().getPoint(l);}; - return getJacobianVectorToVector(model, InputFunction, OutputFunction, J, discretStep); - } +//! Base to bending energy (1x6) - template - bool getJacobianWorldBaseVelocityToPointVelocity(const NeedleInsertionModel &model, vpMatrix &J, double l) - { - vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBaseWorldFrame(v); - return n.updateState(); - }; - std::function OutputFunction = [l](const NeedleInsertionModel& n){return n.accessNeedle().getPoint(l);}; - return getJacobianVectorToVector(model, InputFunction, OutputFunction, J, discretStep); +template +bool getJacobianBaseVelocityToBendingEnergy(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 1e-5*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBase(v); + return n.updateState(); + }; + std::function OutputFunction = [](const NeedleInsertionModel &n) {return n.accessNeedle().getBendingEnergy();}; + return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); +} + +template +bool getJacobianWorldBaseVelocityToBendingEnergy(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 1e-5*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBaseWorldFrame(v); + return n.updateState(); + }; + std::function OutputFunction = [](const NeedleInsertionModel &n) {return n.accessNeedle().getBendingEnergy();}; + return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); +} + +//! Base to tissue deformation energy (1x6) + +template +bool getJacobianBaseVelocityToTissueEnergy(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBase(v); + return n.updateState(); + }; + std::function OutputFunction = [](const NeedleInsertionModel &n) {return n.getTissueDeformationEnergy();}; + return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); +} + +template +bool getJacobianWorldBaseVelocityToTissueEnergy(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBase(v); + return n.updateState(); + }; + std::function OutputFunction = [](const NeedleInsertionModel &n) {return n.getTissueDeformationEnergy();}; + return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); +} + +template +bool getJacobianBaseVelocityToNeedleInsertionPointVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBase(v); + return n.updateState(); + }; + std::function OutputFunction = [](const NeedleInsertionModel &n) {return n.getNeedleInsertionPoint();}; + return getJacobianVectorToVector(model, InputFunction, OutputFunction, J, discretStep); +} + +template +bool getJacobianBaseVelocityToBaseForceTorque(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBase(v); + return n.updateState(); + }; + std::function OutputFunction = [](const NeedleInsertionModel &n) + { + vpColVector baseForceTorque = n.accessNeedle().getBaseStaticTorsor(); + vpRotationMatrix bRw = n.accessNeedle().getWorldMbase().getRotationMatrix().inverse(); + baseForceTorque.insert(0, bRw * vpColVector(baseForceTorque, 0, 3)); + baseForceTorque.insert(3, bRw * vpColVector(baseForceTorque, 3, 3)); + return baseForceTorque; + }; + return getJacobianVectorToVector(model, InputFunction, OutputFunction, J, discretStep); +} + +template +bool getJacobianBaseVelocityToInsertionLength(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBase(v); + return n.updateState(); + }; + std::function OutputFunction = [](const NeedleInsertionModel &n) {return n.getInsertionDepth();}; + return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); +} + +template +bool getJacobianBaseVelocityToSurfaceTissueStretch(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector e = model.getNeedleInsertionPoint() - model.getTissueInsertionPoint(); + double norm = e.frobeniusNorm(); + if (norm <= std::numeric_limits::epsilon()) return false; + else e /= norm; + + vpMatrix M(6, 3, 0); + if (getJacobianBaseVelocityToNeedleInsertionPointVelocity(model, M)) { + J = e.t() * M; + return true; } + else return false; +} - //! Base to features (1x6) - - template - bool getJacobianBaseVelocityToTransversalTargetDistance(const NeedleInsertionModel &model, vpMatrix &J, const vpColVector &target) - { - vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBase(v); - return n.updateState(); - }; - std::function OutputFunction = [target](const NeedleInsertionModel& n) - { - vpColVector v(4,1); - v.insert(0,target); - v = n.accessNeedle().getWorldMtip().inverse()*v; - return sqrt(v[0]*v[0]+v[1]*v[1]); - }; - return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); - } +template +bool getJacobianBaseVelocityToMaxTissueStretch(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBase(v); + return n.updateState(); + }; + std::function OutputFunction = [](const NeedleInsertionModel &n) {return n.getMaxTissueStretch();}; + return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); +} + +template +bool getJacobianBaseVelocityToMeanTissueStretch(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBase(v); + return n.updateState(); + }; + std::function OutputFunction = [](const NeedleInsertionModel &n) {return n.getMeanTissueStretch();}; + return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); +} + +//! Base to model point (3x6) + +template +bool getJacobianBaseVelocityToPointVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, double l) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBase(v); + return n.updateState(); + }; + std::function OutputFunction = [l](const NeedleInsertionModel &n) {return n.accessNeedle().getPoint(l);}; + return getJacobianVectorToVector(model, InputFunction, OutputFunction, J, discretStep); +} + +template +bool getJacobianWorldBaseVelocityToPointVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, double l) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBaseWorldFrame(v); + return n.updateState(); + }; + std::function OutputFunction = [l](const NeedleInsertionModel &n) {return n.accessNeedle().getPoint(l);}; + return getJacobianVectorToVector(model, InputFunction, OutputFunction, J, discretStep); +} + +//! Base to features (1x6) + +template +bool getJacobianBaseVelocityToTransversalTargetDistance(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const VISP_NAMESPACE_ADDRESSING vpColVector &target) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBase(v); + return n.updateState(); + }; + std::function OutputFunction = [target](const NeedleInsertionModel &n) + { + vpColVector v(4, 1); + v.insert(0, target); + v = n.accessNeedle().getWorldMtip().inverse()*v; + return sqrt(v[0]*v[0]+v[1]*v[1]); + }; + return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); +} + +template +bool getJacobianBaseVelocityToTargetAngle(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const VISP_NAMESPACE_ADDRESSING vpColVector &target) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); + std::function InputFunction = [](NeedleInsertionModel &n, const vpColVector &v) + { + n.accessNeedle().moveBase(v); + return n.updateState(); + }; + std::function OutputFunction = [target](const NeedleInsertionModel &n) + { + vpColVector v(4, 1); + v.insert(0, target); + v = n.accessNeedle().getWorldMtip().inverse()*v; + return atan2(sqrt(v[0]*v[0]+v[1]*v[1]), v[2]); + }; + return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); +} + +//! Springs to model point (3x3) + +template +bool getJacobianSpringVelocityToPointVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, int spring, double l) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(3, 1e-6); + std::function InputFunction = [spring](NeedleInsertionModel &n, const vpColVector &v) {return n.moveSpringPosition(spring, v, true);}; + std::function OutputFunction = [l](const NeedleInsertionModel &n) {return n.accessNeedle().getPoint(l);}; + return getJacobianVectorToVector(model, InputFunction, OutputFunction, J, discretStep); +} + +//! Springs to distance from points (nbPointsx3) + +template +bool getJacobianSpringVelocityToPointsDistance(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, int spring, const std::vector &points) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(3, 1e-6); + std::function InputFunction = [spring](NeedleInsertionModel &n, const vpColVector &v) {return n.moveSpringPosition(spring, v, true);}; + std::function OutputFunction = [points](const NeedleInsertionModel &n) + { + int m = points.size(); + vpColVector P(m, 1); + for (int i = 0; i - bool getJacobianBaseVelocityToTargetAngle(const NeedleInsertionModel &model, vpMatrix &J, const vpColVector &target) - { - vpColVector discretStep(6, 0.01*model.accessNeedle().getParametricLength()); - std::function InputFunction = [](NeedleInsertionModel& n, const vpColVector& v) - { - n.accessNeedle().moveBase(v); - return n.updateState(); - }; - std::function OutputFunction = [target](const NeedleInsertionModel& n) - { - vpColVector v(4,1); - v.insert(0,target); - v = n.accessNeedle().getWorldMtip().inverse()*v; - return atan2(sqrt(v[0]*v[0]+v[1]*v[1]),v[2]); - }; - return getJacobianVectorToScalar(model, InputFunction, OutputFunction, J, discretStep); - } +//! Rest path points to model point (3x3) - //! Springs to model point (3x3) +template +bool getJacobianRestPathPointVelocityToPointsVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, int restPoint, const std::vector &l) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(3, 1e-6); + std::function InputFunction = [restPoint](NeedleInsertionModel &n, const vpColVector &v) + { + int m = n.accessTissue().accessPath().getNbSegments()+1; + if (restPoint<0 || restPoint>=m || v.size()!=3) return false; + std::vector P(m); + std::vector lengths(m-1); + for (int i = 0; i - bool getJacobianSpringVelocityToPointVelocity(const NeedleInsertionModel &model, vpMatrix &J, int spring, double l) - { - vpColVector discretStep(3, 1e-6); - std::function InputFunction = [spring](NeedleInsertionModel& n, const vpColVector& v){return n.moveSpringPosition(spring, v, true);}; - std::function OutputFunction = [l](const NeedleInsertionModel& n){return n.accessNeedle().getPoint(l);}; - return getJacobianVectorToVector(model, InputFunction, OutputFunction, J, discretStep); - } + P.at(restPoint) += v; + n.accessTissue().accessPath().defineFromPoints(P, lengths, 1); + n.updateState(); + return true; + }; + std::function OutputFunction = [l](const NeedleInsertionModel &n) + { + int m = l.size(); + vpColVector P(3*m, 1); + for (int i = 0; i - bool getJacobianSpringVelocityToPointsDistance(const NeedleInsertionModel &model, vpMatrix &J, int spring, const std::vector &points) - { - vpColVector discretStep(3, 1e-6); - std::function InputFunction = [spring](NeedleInsertionModel& n, const vpColVector& v){return n.moveSpringPosition(spring, v, true);}; - std::function OutputFunction = [points](const NeedleInsertionModel& n) - { - int m = points.size(); - vpColVector P(m,1); - for(int i=0 ; i - bool getJacobianRestPathPointVelocityToPointsVelocity(const NeedleInsertionModel &model, vpMatrix &J, int restPoint, const std::vector &l) - { - vpColVector discretStep(3, 1e-6); - std::function InputFunction = [restPoint](NeedleInsertionModel& n, const vpColVector& v) - { - int m = n.accessTissue().accessPath().getNbSegments()+1; - if(restPoint<0 || restPoint>=m || v.size()!=3) return false; - std::vector P(m); - std::vector lengths(m-1); - for(int i=0 ; i OutputFunction = [l](const NeedleInsertionModel& n) - { - int m = l.size(); - vpColVector P(3*m,1); - for(int i=0 ; i +bool getJacobianRestPathPointVelocityToPointsDistance(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, int restPoint, const std::vector &points) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + vpColVector discretStep(3, 1e-6); + std::function InputFunction = [restPoint](NeedleInsertionModel &n, const vpColVector &v) + { + int m = n.accessTissue().accessPath().getNbSegments()+1; + if (restPoint<0 || restPoint>=m || v.size()!=3) return false; + std::vector P(m); + std::vector lengths(m-1); + for (int i = 0; i - bool getJacobianRestPathPointVelocityToPointsDistance(const NeedleInsertionModel &model, vpMatrix &J, int restPoint, const std::vector &points) - { - vpColVector discretStep(3, 1e-6); - std::function InputFunction = [restPoint](NeedleInsertionModel& n, const vpColVector& v) - { - int m = n.accessTissue().accessPath().getNbSegments()+1; - if(restPoint<0 || restPoint>=m || v.size()!=3) return false; - std::vector P(m); - std::vector lengths(m-1); - for(int i=0 ; i OutputFunction = [points](const NeedleInsertionModel& n) - { - int m = points.size(); - vpColVector P(m,1); - for(int i=0 ; i OutputFunction = [points](const NeedleInsertionModel &n) + { + int m = points.size(); + vpColVector P(m, 1); + for (int i = 0; i - bool getJacobianStiffnessPerUnitLengthToPointsDistance(const NeedleInsertionModel &model, vpMatrix &J, const std::vector &points) - { - double discretStep = 0.01*model.getStiffnessPerUnitLength(); - std::function InputFunction = [](NeedleInsertionModel& n, double dK) - { - n.setStiffnessPerUnitLength(n.getStiffnessPerUnitLength()+dK); - return n.updateState(); - }; - std::function OutputFunction = [points](const NeedleInsertionModel& n) - { - vpColVector d(points.size()); - for(unsigned int i=0 ; i - bool getJacobianStiffnessPerUnitLengthToPointsVelocity(const NeedleInsertionModel &model, vpMatrix &J, const std::vector &l) - { - double discretStep = 0.01*model.getStiffnessPerUnitLength(); - std::function InputFunction = [](NeedleInsertionModel& n, double dK) - { - n.setStiffnessPerUnitLength(n.getStiffnessPerUnitLength()+dK); - return n.updateState(); - }; - std::function OutputFunction = [l](const NeedleInsertionModel& n) - { - int m = l.size(); - vpColVector P(3*m,1); - for(int i=0 ; i +bool getJacobianStiffnessPerUnitLengthToPointsDistance(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const std::vector &points) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + double discretStep = 0.01*model.getStiffnessPerUnitLength(); + std::function InputFunction = [](NeedleInsertionModel &n, double dK) + { + n.setStiffnessPerUnitLength(n.getStiffnessPerUnitLength()+dK); + return n.updateState(); + }; + std::function OutputFunction = [points](const NeedleInsertionModel &n) + { + vpColVector d(points.size()); + for (unsigned int i = 0; i +bool getJacobianStiffnessPerUnitLengthToPointsVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, const std::vector &l) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + double discretStep = 0.01*model.getStiffnessPerUnitLength(); + std::function InputFunction = [](NeedleInsertionModel &n, double dK) + { + n.setStiffnessPerUnitLength(n.getStiffnessPerUnitLength()+dK); + return n.updateState(); + }; + std::function OutputFunction = [l](const NeedleInsertionModel &n) + { + int m = l.size(); + vpColVector P(3*m, 1); + for (int i = 0; i - bool getJacobianStiffnessPerUnitLengthToPointsVelocity(const NeedleInsertionModel &model, vpMatrix &J, int i, const std::vector &l) - { - double discretStep = 0.01*model.getStiffnessPerUnitLength(i); - std::function InputFunction = [i](NeedleInsertionModel& n, double dK) - { - n.setStiffnessPerUnitLength(i, n.getStiffnessPerUnitLength(i)+dK); - return n.updateState(); - }; - std::function OutputFunction = [l](const NeedleInsertionModel& n) - { - int m = l.size(); - vpColVector P(3*m,1); - for(int i=0 ; i +bool getJacobianStiffnessPerUnitLengthToPointsVelocity(const NeedleInsertionModel &model, VISP_NAMESPACE_ADDRESSING vpMatrix &J, int i, const std::vector &l) +{ +#ifdef ENABLE_VISP_NAMESPACE + using namespace VISP_NAMESPACE_NAME; +#endif + double discretStep = 0.01*model.getStiffnessPerUnitLength(i); + std::function InputFunction = [i](NeedleInsertionModel &n, double dK) + { + n.setStiffnessPerUnitLength(i, n.getStiffnessPerUnitLength(i)+dK); + return n.updateState(); + }; + std::function OutputFunction = [l](const NeedleInsertionModel &n) + { + int m = l.size(); + vpColVector P(3*m, 1); + for (int i = 0; i -VISP_EXPORT void displayBase(const usNeedleModelBaseTip &needleModel, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); +VISP_EXPORT void displayBase(const usNeedleModelBaseTip &needleModel, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); template -VISP_EXPORT void displayTip(const usNeedleModelBaseTip &needleModel, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); +VISP_EXPORT void displayTip(const usNeedleModelBaseTip &needleModel, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); template -VISP_EXPORT void display(const usNeedleModelBaseTip &needleModel, vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); +VISP_EXPORT void display(const usNeedleModelBaseTip &needleModel, VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); //! Display usNeedleModelPolynomial template -VISP_EXPORT void displayNeedle(const usNeedleModelPolynomial &needleModel, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, +VISP_EXPORT void displayNeedle(const usNeedleModelPolynomial &needleModel, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, bool displayFullBody = false); template -VISP_EXPORT void displayBaseStaticTorsor(const usNeedleModelPolynomial &needleModel, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, +VISP_EXPORT void displayBaseStaticTorsor(const usNeedleModelPolynomial &needleModel, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); template -VISP_EXPORT void displayCurvatureFromShape(const usNeedleModelPolynomial &needleModel, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, +VISP_EXPORT void displayCurvatureFromShape(const usNeedleModelPolynomial &needleModel, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); template -VISP_EXPORT void display(const usNeedleModelPolynomial &needleModel, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, +VISP_EXPORT void display(const usNeedleModelPolynomial &needleModel, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, bool displayFullBody = false); //! Display usNeedleModelSpline template -VISP_EXPORT void displayNeedle(const usNeedleModelSpline &needleModel, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, +VISP_EXPORT void displayNeedle(const usNeedleModelSpline &needleModel, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, bool displayFullBody = false); template -VISP_EXPORT void displayBaseStaticTorsor(const usNeedleModelSpline &needleModel, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, +VISP_EXPORT void displayBaseStaticTorsor(const usNeedleModelSpline &needleModel, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); template -VISP_EXPORT void displayCurvatureFromShape(const usNeedleModelSpline &needleModel, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, +VISP_EXPORT void displayCurvatureFromShape(const usNeedleModelSpline &needleModel, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); template -VISP_EXPORT void display(const usNeedleModelSpline &needleModel, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, +VISP_EXPORT void display(const usNeedleModelSpline &needleModel, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, bool displayFullBody = false); //! Display usVirtualSpring template -VISP_EXPORT void display(const usVirtualSpring &spring, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); +VISP_EXPORT void display(const usVirtualSpring &spring, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); //! Display usTissueModelSpline template -VISP_EXPORT void display(const usTissueModelSpline &tissue, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); +VISP_EXPORT void display(const usTissueModelSpline &tissue, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); //! Display usNeedleTip template -VISP_EXPORT void display(const usNeedleTip &tip, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); +VISP_EXPORT void display(const usNeedleTip &tip, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); //! Display usNeedleTipActuated template -VISP_EXPORT void display(const usNeedleTipActuated &tip, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); +VISP_EXPORT void display(const usNeedleTipActuated &tip, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); //! Display usNeedleTipBeveled template -VISP_EXPORT void display(const usNeedleTipBeveled &tip, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); +VISP_EXPORT void display(const usNeedleTipBeveled &tip, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); //! Display usNeedleTipPrebent template -VISP_EXPORT void display(const usNeedleTipPrebent &tip, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); +VISP_EXPORT void display(const usNeedleTipPrebent &tip, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); //! Display usNeedleTipSymmetric template -VISP_EXPORT void display(const usNeedleTipSymmetric &tip, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); +VISP_EXPORT void display(const usNeedleTipSymmetric &tip, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); //! Display usNeedleInsertionModelKinematic template -VISP_EXPORT void display(const usNeedleInsertionModelKinematic &model, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); +VISP_EXPORT void display(const usNeedleInsertionModelKinematic &model, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); //! Display usNeedleInsertionModelRayleighRitzSpline template -VISP_EXPORT void displayLayers(const usNeedleInsertionModelRayleighRitzSpline &model, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); +VISP_EXPORT void displayLayers(const usNeedleInsertionModelRayleighRitzSpline &model, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); template VISP_EXPORT void displayInteraction(const usNeedleInsertionModelRayleighRitzSpline &model, - const vpImage &I, const vpHomogeneousMatrix &imageMworld, + const VISP_NAMESPACE_ADDRESSING vpImage &I, const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000); template -VISP_EXPORT void display(const usNeedleInsertionModelRayleighRitzSpline &model, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, +VISP_EXPORT void display(const usNeedleInsertionModelRayleighRitzSpline &model, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, bool displayFullBody = false); //! Display usNeedleInsertionModelVirtualSprings template -VISP_EXPORT void display(const usNeedleInsertionModelVirtualSprings &model, const vpImage &I, - const vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, +VISP_EXPORT void display(const usNeedleInsertionModelVirtualSprings &model, const VISP_NAMESPACE_ADDRESSING vpImage &I, + const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &imageMworld, double Xscale = 3000, double Yscale = 3000, bool displayFullBody = false); } // namespace usNeedleModelingDisplayTools diff --git a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleTip.h b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleTip.h index b392f708..adb84b8f 100644 --- a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleTip.h +++ b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usNeedleTip.h @@ -42,10 +42,10 @@ class VISP_EXPORT usNeedleTip { protected: - vpPoseVector m_basePose; - vpHomogeneousMatrix m_worldMbase; - vpPoseVector m_tipPose; - vpHomogeneousMatrix m_worldMtip; + VISP_NAMESPACE_ADDRESSING vpPoseVector m_basePose; + VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix m_worldMbase; + VISP_NAMESPACE_ADDRESSING vpPoseVector m_tipPose; + VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix m_worldMtip; public: //! Constructors, destructors @@ -58,21 +58,21 @@ class VISP_EXPORT usNeedleTip //! Parameters setters and getters - void setBasePose(const vpPoseVector &pose); - vpPoseVector getBasePose() const; - void setWorldMbase(const vpHomogeneousMatrix &worldMbase); - vpHomogeneousMatrix getWorldMbase() const; - void setBasePosition(const vpColVector &position); - vpColVector getBasePosition() const; - - vpPoseVector getTipPose() const; - vpHomogeneousMatrix getWorldMtip() const; - vpColVector getTipPosition() const; - vpColVector getTipDirection() const; - - vpColVector getBaseAxisX() const; - vpColVector getBaseAxisY() const; - vpColVector getBaseAxisZ() const; + void setBasePose(const VISP_NAMESPACE_ADDRESSING vpPoseVector &pose); + VISP_NAMESPACE_ADDRESSING vpPoseVector getBasePose() const; + void setWorldMbase(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &worldMbase); + VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix getWorldMbase() const; + void setBasePosition(const VISP_NAMESPACE_ADDRESSING vpColVector &position); + VISP_NAMESPACE_ADDRESSING vpColVector getBasePosition() const; + + VISP_NAMESPACE_ADDRESSING vpPoseVector getTipPose() const; + VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix getWorldMtip() const; + VISP_NAMESPACE_ADDRESSING vpColVector getTipPosition() const; + VISP_NAMESPACE_ADDRESSING vpColVector getTipDirection() const; + + VISP_NAMESPACE_ADDRESSING vpColVector getBaseAxisX() const; + VISP_NAMESPACE_ADDRESSING vpColVector getBaseAxisY() const; + VISP_NAMESPACE_ADDRESSING vpColVector getBaseAxisZ() const; //! Data saving diff --git a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usTissueModelPolynomial.h b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usTissueModelPolynomial.h index 24053677..4f9899cb 100644 --- a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usTissueModelPolynomial.h +++ b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usTissueModelPolynomial.h @@ -63,12 +63,12 @@ class VISP_EXPORT usTissueModelPolynomial const usPolynomialCurve3D &accessPath() const; usPolynomialCurve3D accessPath(); - bool moveInWorldFrame(const vpHomogeneousMatrix &H); + bool moveInWorldFrame(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &H); bool moveInWorldFrame(double x, double y, double z, double tx, double ty, double tz); - bool move(const vpHomogeneousMatrix &H); + bool move(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &H); bool move(double x, double y, double z, double tx, double ty, double tz); - bool setPose(const vpPoseVector &p); - vpPoseVector getPose() const; + bool setPose(const VISP_NAMESPACE_ADDRESSING vpPoseVector &p); + VISP_NAMESPACE_ADDRESSING vpPoseVector getPose() const; //! Data saving diff --git a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usTissueModelSpline.h b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usTissueModelSpline.h index 0f8fc4c8..fc8e3ffd 100644 --- a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usTissueModelSpline.h +++ b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usTissueModelSpline.h @@ -31,12 +31,12 @@ class VISP_EXPORT usTissueModelSpline const usBSpline3D &accessPath() const; usBSpline3D &accessPath(); - bool moveInWorldFrame(const vpHomogeneousMatrix &H); + bool moveInWorldFrame(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &H); bool moveInWorldFrame(double x, double y, double z, double tx, double ty, double tz); - bool move(const vpHomogeneousMatrix &H); + bool move(const VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix &H); bool move(double x, double y, double z, double tx, double ty, double tz); - bool setPose(const vpPoseVector &p); - vpPoseVector getPose() const; + bool setPose(const VISP_NAMESPACE_ADDRESSING vpPoseVector &p); + VISP_NAMESPACE_ADDRESSING vpPoseVector getPose() const; //! Data saving diff --git a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usTissueTranslationEstimatorUKF.h b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usTissueTranslationEstimatorUKF.h index 98cf696a..cacfa9d9 100644 --- a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usTissueTranslationEstimatorUKF.h +++ b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usTissueTranslationEstimatorUKF.h @@ -49,68 +49,68 @@ class VISP_EXPORT usTissueTranslationEstimatorUKF : public usUnscentedKalmanFilter { public: - - enum StateDynamicsType : int {CONSTANT_POSITION, CONSTANT_VELOCITY}; - enum TissueTranslationType : int {LATERAL_TRANSLATIONS_ONLY, FULL_TRANSLATIONS}; - enum MeasureType : int {NEEDLE_BODY_POINTS, TIP_POSITION_AND_DIRECTION, BASE_FORCE_TORQUE}; - - double m_var_measure_p; - double m_var_measure_d; - double m_var_measure_f; - double m_var_measure_t; - double m_var_process_p; - double m_var_process_v; - StateDynamicsType m_stateDynamicsType; - TissueTranslationType m_tissueTranslationType; - MeasureType m_measureType; - - double m_propagationTime; - - usNeedleInsertionModelRayleighRitzSpline m_needle; + + enum StateDynamicsType : int { CONSTANT_POSITION, CONSTANT_VELOCITY }; + enum TissueTranslationType : int { LATERAL_TRANSLATIONS_ONLY, FULL_TRANSLATIONS }; + enum MeasureType : int { NEEDLE_BODY_POINTS, TIP_POSITION_AND_DIRECTION, BASE_FORCE_TORQUE }; + + double m_var_measure_p; + double m_var_measure_d; + double m_var_measure_f; + double m_var_measure_t; + double m_var_process_p; + double m_var_process_v; + StateDynamicsType m_stateDynamicsType; + TissueTranslationType m_tissueTranslationType; + MeasureType m_measureType; + + double m_propagationTime; + + usNeedleInsertionModelRayleighRitzSpline m_needle; public: - usTissueTranslationEstimatorUKF(); - ~usTissueTranslationEstimatorUKF(); - - double getPositionMeasureNoiseVariance() const; - void setPositionMeasureNoiseVariance(double sigma); - - double getTipDirectionMeasureNoiseVariance() const; - void setTipDirectionMeasureNoiseVariance(double sigma); - - double getForceMeasureNoiseVariance() const; - void setForceMeasureNoiseVariance(double sigma); - - double getTorqueMeasureNoiseVariance() const; - void setTorqueMeasureNoiseVariance(double sigma); - - double getTissuePositionProcessNoiseVariance() const; - void setTissuePositionProcessNoiseVariance(double sigma); - - double getTissueVelocityProcessNoiseVariance() const; - void setTissueVelocityProcessNoiseVariance(double sigma); - - StateDynamicsType getStateDynamicsType() const; - void setStateDynamicsType(StateDynamicsType type); - - TissueTranslationType getTissueTranslationType() const; - void setTissueTranslationType(TissueTranslationType type); - - MeasureType getMeasureType() const; - void setMeasureType(MeasureType type); - - void setPropagationTime(double time); - - void setCurrentNeedle(const usNeedleInsertionModelRayleighRitzSpline& needle); - void applyStateToNeedle(usNeedleInsertionModelRayleighRitzSpline& needle) const; - - bool checkConsistency(const vpColVector &measure); - void computeProcessNoiseCovarianceMatrix(); - void computeMeasureNoiseCovarianceMatrix(); - vpColVector propagateSigmaPoint(const vpColVector &sigmaPoint); - vpColVector computeMeasureFromSigmaPoint(const vpColVector &sigmaPoint); - double stateNorm(const vpColVector& state) const; - vpColVector measureLog(const vpColVector& measure, const vpColVector &measureCenter) const; + usTissueTranslationEstimatorUKF(); + ~usTissueTranslationEstimatorUKF(); + + double getPositionMeasureNoiseVariance() const; + void setPositionMeasureNoiseVariance(double sigma); + + double getTipDirectionMeasureNoiseVariance() const; + void setTipDirectionMeasureNoiseVariance(double sigma); + + double getForceMeasureNoiseVariance() const; + void setForceMeasureNoiseVariance(double sigma); + + double getTorqueMeasureNoiseVariance() const; + void setTorqueMeasureNoiseVariance(double sigma); + + double getTissuePositionProcessNoiseVariance() const; + void setTissuePositionProcessNoiseVariance(double sigma); + + double getTissueVelocityProcessNoiseVariance() const; + void setTissueVelocityProcessNoiseVariance(double sigma); + + StateDynamicsType getStateDynamicsType() const; + void setStateDynamicsType(StateDynamicsType type); + + TissueTranslationType getTissueTranslationType() const; + void setTissueTranslationType(TissueTranslationType type); + + MeasureType getMeasureType() const; + void setMeasureType(MeasureType type); + + void setPropagationTime(double time); + + void setCurrentNeedle(const usNeedleInsertionModelRayleighRitzSpline &needle); + void applyStateToNeedle(usNeedleInsertionModelRayleighRitzSpline &needle) const; + + bool checkConsistency(const VISP_NAMESPACE_ADDRESSING vpColVector &measure); + void computeProcessNoiseCovarianceMatrix(); + void computeMeasureNoiseCovarianceMatrix(); + VISP_NAMESPACE_ADDRESSING vpColVector propagateSigmaPoint(const VISP_NAMESPACE_ADDRESSING vpColVector &sigmaPoint); + VISP_NAMESPACE_ADDRESSING vpColVector computeMeasureFromSigmaPoint(const VISP_NAMESPACE_ADDRESSING vpColVector &sigmaPoint); + double stateNorm(const VISP_NAMESPACE_ADDRESSING vpColVector &state) const; + VISP_NAMESPACE_ADDRESSING vpColVector measureLog(const VISP_NAMESPACE_ADDRESSING vpColVector &measure, const VISP_NAMESPACE_ADDRESSING vpColVector &measureCenter) const; }; #endif // __usTissueTranslationEstimatorUKF_h_ diff --git a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usUnscentedKalmanFilter.h b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usUnscentedKalmanFilter.h index 8d0d82d9..cd101e66 100644 --- a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usUnscentedKalmanFilter.h +++ b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usUnscentedKalmanFilter.h @@ -50,104 +50,104 @@ class VISP_EXPORT usUnscentedKalmanFilter { public: - enum NoiseType : int {ADDITIVE_NOISE, GENERIC_NOISE}; - enum SigmaPointGenerationType : int {STANDARD_COVARIANCE, FIXED_SCALING_FACTOR, LIMITED_SPREAD}; - + enum NoiseType : int { ADDITIVE_NOISE, GENERIC_NOISE }; + enum SigmaPointGenerationType : int { STANDARD_COVARIANCE, FIXED_SCALING_FACTOR, LIMITED_SPREAD }; + protected: - - unsigned int m_stateDimension; - unsigned int m_measureDimension; - unsigned int m_processNoiseDimension; - unsigned int m_measureNoiseDimension; - - vpColVector m_state; - vpMatrix m_stateCovarianceMatrix; - - NoiseType m_processNoiseType; - vpMatrix m_processNoiseCovarianceMatrix; - bool m_computeProcessNoiseCovarianceMatrixAutomatically; - - NoiseType m_measureNoiseType; - vpMatrix m_measureNoiseCovarianceMatrix; - bool m_computeMeasureNoiseCovarianceMatrixAutomatically; - - vpColVector m_measure; - - SigmaPointGenerationType m_sigmaPointsGenerationType; - vpMatrix m_sigmaPointsInit; - vpMatrix m_sigmaPointsPropagated; - vpMatrix m_sigmaPointsMeasure; - vpColVector m_sigmaPointsMeanWeights; - vpColVector m_sigmaPointsCovarianceWeights; - double m_sigmaPointsScalingFactor; - double m_sigmaPointsSpreadThreshold; - - vpColVector m_stateSigmaMean; - vpColVector m_measureSigmaMean; - vpMatrix m_stateSigmaCovarianceMatrix; - vpMatrix m_stateMeasureSigmaCovarianceMatrix; - vpMatrix m_measureSigmaCovarianceMatrix; + + unsigned int m_stateDimension; + unsigned int m_measureDimension; + unsigned int m_processNoiseDimension; + unsigned int m_measureNoiseDimension; + + VISP_NAMESPACE_ADDRESSING vpColVector m_state; + VISP_NAMESPACE_ADDRESSING vpMatrix m_stateCovarianceMatrix; + + NoiseType m_processNoiseType; + VISP_NAMESPACE_ADDRESSING vpMatrix m_processNoiseCovarianceMatrix; + bool m_computeProcessNoiseCovarianceMatrixAutomatically; + + NoiseType m_measureNoiseType; + VISP_NAMESPACE_ADDRESSING vpMatrix m_measureNoiseCovarianceMatrix; + bool m_computeMeasureNoiseCovarianceMatrixAutomatically; + + VISP_NAMESPACE_ADDRESSING vpColVector m_measure; + + SigmaPointGenerationType m_sigmaPointsGenerationType; + VISP_NAMESPACE_ADDRESSING vpMatrix m_sigmaPointsInit; + VISP_NAMESPACE_ADDRESSING vpMatrix m_sigmaPointsPropagated; + VISP_NAMESPACE_ADDRESSING vpMatrix m_sigmaPointsMeasure; + VISP_NAMESPACE_ADDRESSING vpColVector m_sigmaPointsMeanWeights; + VISP_NAMESPACE_ADDRESSING vpColVector m_sigmaPointsCovarianceWeights; + double m_sigmaPointsScalingFactor; + double m_sigmaPointsSpreadThreshold; + + VISP_NAMESPACE_ADDRESSING vpColVector m_stateSigmaMean; + VISP_NAMESPACE_ADDRESSING vpColVector m_measureSigmaMean; + VISP_NAMESPACE_ADDRESSING vpMatrix m_stateSigmaCovarianceMatrix; + VISP_NAMESPACE_ADDRESSING vpMatrix m_stateMeasureSigmaCovarianceMatrix; + VISP_NAMESPACE_ADDRESSING vpMatrix m_measureSigmaCovarianceMatrix; public: - usUnscentedKalmanFilter(); - virtual ~usUnscentedKalmanFilter(); - - int getStateDimension() const; - void setStateDimension(int dim); - - int getMeasureDimension() const; - void setMeasureDimension(int dim); - - NoiseType getProcessNoiseType() const; - void setProcessNoiseType(NoiseType type); - int getProcessNoiseDimension() const; - void setProcessNoiseDimension(int dim); - - NoiseType getMeasureNoiseType() const; - void setMeasureNoiseType(NoiseType type); - int getMeasureNoiseDimension() const; - void setMeasureNoiseDimension(int dim); - - SigmaPointGenerationType getSigmaPointGenerationType() const; - void setSigmaPointGenerationType(SigmaPointGenerationType type); - double getSigmaPointScalingFactor() const; - void setSigmaPointScalingFactor(double factor); - double getSigmaPointSpreadThreshold() const; - void setSigmaPointSpreadThreshold(double threshold); - - vpColVector getState() const; - void setState(const vpColVector &state); - - vpMatrix getStateCovarianceMatrix() const; - void setStateCovarianceMatrix(const vpMatrix &mat); - - vpMatrix getProcessNoiseCovarianceMatrix() const; - void setProcessNoiseCovarianceMatrix(const vpMatrix &cov); - bool computeProcessNoiseCovarianceMatrixAutomatically() const; - void computeProcessNoiseCovarianceMatrixAutomatically(bool flag); - - vpMatrix getMeasureNoiseCovarianceMatrix() const; - void setMeasureNoiseCovarianceMatrix(const vpMatrix &cov); - bool computeMeasureNoiseCovarianceMatrixAutomatically() const; - void computeMeasureNoiseCovarianceMatrixAutomatically(bool flag); - - virtual bool checkConsistency(const vpColVector &measure); - virtual void computeProcessNoiseCovarianceMatrix(); - virtual void computeMeasureNoiseCovarianceMatrix(); - bool generateSigmaPoints(); - bool computePropagatedSigmaPoints(); - bool computeSigmaMeasures(); - void computeMeansAndCovarianceMatricesFromSigmaPoints(); - bool updateState(); - - bool filter(const vpColVector &measure); - - virtual vpColVector propagateSigmaPoint(const vpColVector &sigmaPoint)=0; - virtual vpColVector computeMeasureFromSigmaPoint(const vpColVector &sigmaPoint)=0; - virtual double stateNorm(const vpColVector &state) const; - virtual vpColVector measureLog(const vpColVector &measure, const vpColVector &measureCenter) const; - virtual vpColVector stateLog(const vpColVector &state, const vpColVector &stateCenter) const; - virtual vpColVector stateExp(const vpColVector &state, const vpColVector &stateCenter) const; + usUnscentedKalmanFilter(); + virtual ~usUnscentedKalmanFilter(); + + int getStateDimension() const; + void setStateDimension(int dim); + + int getMeasureDimension() const; + void setMeasureDimension(int dim); + + NoiseType getProcessNoiseType() const; + void setProcessNoiseType(NoiseType type); + int getProcessNoiseDimension() const; + void setProcessNoiseDimension(int dim); + + NoiseType getMeasureNoiseType() const; + void setMeasureNoiseType(NoiseType type); + int getMeasureNoiseDimension() const; + void setMeasureNoiseDimension(int dim); + + SigmaPointGenerationType getSigmaPointGenerationType() const; + void setSigmaPointGenerationType(SigmaPointGenerationType type); + double getSigmaPointScalingFactor() const; + void setSigmaPointScalingFactor(double factor); + double getSigmaPointSpreadThreshold() const; + void setSigmaPointSpreadThreshold(double threshold); + + VISP_NAMESPACE_ADDRESSING vpColVector getState() const; + void setState(const VISP_NAMESPACE_ADDRESSING vpColVector &state); + + VISP_NAMESPACE_ADDRESSING vpMatrix getStateCovarianceMatrix() const; + void setStateCovarianceMatrix(const VISP_NAMESPACE_ADDRESSING vpMatrix &mat); + + VISP_NAMESPACE_ADDRESSING vpMatrix getProcessNoiseCovarianceMatrix() const; + void setProcessNoiseCovarianceMatrix(const VISP_NAMESPACE_ADDRESSING vpMatrix &cov); + bool computeProcessNoiseCovarianceMatrixAutomatically() const; + void computeProcessNoiseCovarianceMatrixAutomatically(bool flag); + + VISP_NAMESPACE_ADDRESSING vpMatrix getMeasureNoiseCovarianceMatrix() const; + void setMeasureNoiseCovarianceMatrix(const VISP_NAMESPACE_ADDRESSING vpMatrix &cov); + bool computeMeasureNoiseCovarianceMatrixAutomatically() const; + void computeMeasureNoiseCovarianceMatrixAutomatically(bool flag); + + virtual bool checkConsistency(const VISP_NAMESPACE_ADDRESSING vpColVector &measure); + virtual void computeProcessNoiseCovarianceMatrix(); + virtual void computeMeasureNoiseCovarianceMatrix(); + bool generateSigmaPoints(); + bool computePropagatedSigmaPoints(); + bool computeSigmaMeasures(); + void computeMeansAndCovarianceMatricesFromSigmaPoints(); + bool updateState(); + + bool filter(const VISP_NAMESPACE_ADDRESSING vpColVector &measure); + + virtual VISP_NAMESPACE_ADDRESSING vpColVector propagateSigmaPoint(const VISP_NAMESPACE_ADDRESSING vpColVector &sigmaPoint) = 0; + virtual VISP_NAMESPACE_ADDRESSING vpColVector computeMeasureFromSigmaPoint(const VISP_NAMESPACE_ADDRESSING vpColVector &sigmaPoint) = 0; + virtual double stateNorm(const VISP_NAMESPACE_ADDRESSING vpColVector &state) const; + virtual VISP_NAMESPACE_ADDRESSING vpColVector measureLog(const VISP_NAMESPACE_ADDRESSING vpColVector &measure, const VISP_NAMESPACE_ADDRESSING vpColVector &measureCenter) const; + virtual VISP_NAMESPACE_ADDRESSING vpColVector stateLog(const VISP_NAMESPACE_ADDRESSING vpColVector &state, const VISP_NAMESPACE_ADDRESSING vpColVector &stateCenter) const; + virtual VISP_NAMESPACE_ADDRESSING vpColVector stateExp(const VISP_NAMESPACE_ADDRESSING vpColVector &state, const VISP_NAMESPACE_ADDRESSING vpColVector &stateCenter) const; }; #endif // __usUnscentedKalmanFilter_h_ diff --git a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usVirtualSpring.h b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usVirtualSpring.h index bb10c51d..174eacde 100644 --- a/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usVirtualSpring.h +++ b/modules/ustk_needle_modeling/include/visp3/ustk_needle_modeling/usVirtualSpring.h @@ -55,7 +55,7 @@ class VISP_EXPORT usVirtualSpring : public usOrientedPlane3D usVirtualSpring(); usVirtualSpring(const usVirtualSpring &spring); - usVirtualSpring(const vpColVector &p, const vpColVector &d, double K); + usVirtualSpring(const VISP_NAMESPACE_ADDRESSING vpColVector &p, const VISP_NAMESPACE_ADDRESSING vpColVector &d, double K); virtual ~usVirtualSpring(); const usVirtualSpring &operator=(const usVirtualSpring &spring); diff --git a/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelInterface.cpp b/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelInterface.cpp index 54406425..70894481 100644 --- a/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelInterface.cpp +++ b/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelInterface.cpp @@ -37,6 +37,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + bool usNeedleInsertionModelInterface::setBasePose(double tx, double ty, double tz, double thetax, double thetay, double thetaz) { diff --git a/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelKinematic.cpp b/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelKinematic.cpp index 3a858452..af3bd622 100644 --- a/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelKinematic.cpp +++ b/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelKinematic.cpp @@ -36,14 +36,17 @@ #include #include -usNeedleInsertionModelKinematic::usNeedleInsertionModelKinematic() : m_needle(), m_naturalCurvature(0) {} +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + +usNeedleInsertionModelKinematic::usNeedleInsertionModelKinematic() : m_needle(), m_naturalCurvature(0) { } usNeedleInsertionModelKinematic::usNeedleInsertionModelKinematic(const usNeedleInsertionModelKinematic &needle) : m_needle(needle.m_needle), m_naturalCurvature(needle.m_naturalCurvature) -{ -} +{ } -usNeedleInsertionModelKinematic::~usNeedleInsertionModelKinematic() {} +usNeedleInsertionModelKinematic::~usNeedleInsertionModelKinematic() { } usNeedleInsertionModelKinematic &usNeedleInsertionModelKinematic:: operator=(const usNeedleInsertionModelKinematic &needle) diff --git a/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelRayleighRitzSpline.cpp b/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelRayleighRitzSpline.cpp index e904d6bd..c2880168 100644 --- a/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelRayleighRitzSpline.cpp +++ b/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelRayleighRitzSpline.cpp @@ -49,10 +49,14 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + usNeedleInsertionModelRayleighRitzSpline::usNeedleInsertionModelRayleighRitzSpline() : m_needle(), m_needleTip(new usNeedleTipBeveled()), m_needleTipType(NeedleTipType::BeveledTip), m_tissue(), - m_pathUpdateType(PathUpdateType::NoUpdate), m_pathUpdateLengthThreshold(0.001), m_pathUpdateMixCoefficient(0.5), - m_solvingMethod(SolvingMethod::FixedBeamLength) + m_pathUpdateType(PathUpdateType::NoUpdate), m_pathUpdateLengthThreshold(0.001), m_pathUpdateMixCoefficient(0.5), + m_solvingMethod(SolvingMethod::FixedBeamLength) { m_stiffnessPerUnitLength.resize(1, 10000); m_layerLength.resize(1, 1); @@ -62,15 +66,14 @@ usNeedleInsertionModelRayleighRitzSpline::usNeedleInsertionModelRayleighRitzSpli usNeedleInsertionModelRayleighRitzSpline::usNeedleInsertionModelRayleighRitzSpline( const usNeedleInsertionModelRayleighRitzSpline &model) : m_needle(model.m_needle), m_needleTip(model.m_needleTip->clone()), m_needleTipType(model.m_needleTipType), - m_tissue(model.m_tissue), m_stiffnessPerUnitLength(model.m_stiffnessPerUnitLength), - m_layerLength(model.m_layerLength), + m_tissue(model.m_tissue), m_stiffnessPerUnitLength(model.m_stiffnessPerUnitLength), + m_layerLength(model.m_layerLength), - m_pathUpdateType(model.m_pathUpdateType), m_pathUpdateLengthThreshold(model.m_pathUpdateLengthThreshold), - m_pathUpdateMixCoefficient(model.m_pathUpdateMixCoefficient), + m_pathUpdateType(model.m_pathUpdateType), m_pathUpdateLengthThreshold(model.m_pathUpdateLengthThreshold), + m_pathUpdateMixCoefficient(model.m_pathUpdateMixCoefficient), - m_solvingMethod(model.m_solvingMethod), m_restDilatationFactor(model.m_restDilatationFactor) -{ -} + m_solvingMethod(model.m_solvingMethod), m_restDilatationFactor(model.m_restDilatationFactor) +{ } usNeedleInsertionModelRayleighRitzSpline::~usNeedleInsertionModelRayleighRitzSpline() { @@ -379,7 +382,8 @@ double usNeedleInsertionModelRayleighRitzSpline::getNeedleFreeLength(int *seg, d if (!usGeometryTools::IsPointInFrontOfPlane(m_needle.accessSegment(i).getEndPoint(), m_tissue.accessSurface())) { ltot += m_needle.accessSegment(i).getParametricLength(); i++; - } else { + } + else { if (usGeometryTools::DoesSegmentCrossPlane(m_needle.accessSegment(i), m_tissue.accessSurface())) { usGeometryTools::getPlaneCurveCrossingPoint(m_needle.accessSegment(i), m_tissue.accessSurface(), -1, &l); ltot += l; @@ -393,14 +397,16 @@ double usNeedleInsertionModelRayleighRitzSpline::getNeedleFreeLength(int *seg, d *seg = i; if (param != nullptr) *param = l; - } else { + } + else { if (seg != nullptr) *seg = -1; if (param != nullptr) *param = -1; } return ltot; - } else { + } + else { if (seg != nullptr) *seg = -1; if (param != nullptr) @@ -463,7 +469,8 @@ bool usNeedleInsertionModelRayleighRitzSpline::getCorrespondingPathPoint(double insertionLength) { currentNeedleInsertedLength += m_needle.accessSegment(needleIndex).getParametricLength() - needleParam; needleParam = 0; - } else { + } + else { currentNeedleInsertedLength = insertionLength; } @@ -473,7 +480,7 @@ bool usNeedleInsertionModelRayleighRitzSpline::getCorrespondingPathPoint(double (m_tissue.accessPath().accessSegment(restIndex).getParametricLength() - currentRestParam) < currentNeedleInsertedLength) { currentRestLength += m_restDilatationFactor.at(needleIndex) * - (m_tissue.accessPath().accessSegment(restIndex).getParametricLength() - currentRestParam); + (m_tissue.accessPath().accessSegment(restIndex).getParametricLength() - currentRestParam); currentRestParam = 0; restIndex++; } @@ -716,13 +723,14 @@ bool usNeedleInsertionModelRayleighRitzSpline::cutPathToPoint(const vpColVector "usNeedleInsertionModelRayleighRitzSpline::cutPathToPoint: invalid vector dimension"); if (!usGeometryTools::IsPointInFrontOfPlane(P, m_tissue.accessSurface())) return false; - + vpColVector lastPoint(3); vpColVector lastDirection(3); if (m_tissue.accessPath().getNbSegments() > 0) { lastPoint = m_tissue.accessPath().accessLastSegment().getEndPoint(); lastDirection = m_needle.getTipDirection(); // m_tissue.accessPath().accessLastSegment().getEndTangent(); - } else { + } + else { lastDirection = m_needle.getTipDirection(); lastPoint = usGeometryTools::projectPointOnPlane(P, m_tissue.accessSurface(), lastDirection); } @@ -730,8 +738,8 @@ bool usNeedleInsertionModelRayleighRitzSpline::cutPathToPoint(const vpColVector if (vpColVector::dotProd(P - lastPoint, lastDirection) > m_pathUpdateLengthThreshold) { if ((P - m_needle.getBasePosition()).frobeniusNorm() > 1.1*m_needle.getFullLength()) { std::cout << "Warning usNeedleInsertionModelRayleighRitzSpline::cutPathToPoint: cut point is inconsistent with " - "current needle state" - << std::endl; + "current needle state" + << std::endl; return false; } @@ -743,7 +751,8 @@ bool usNeedleInsertionModelRayleighRitzSpline::cutPathToPoint(const vpColVector seg.setParametricLength((P - lastPoint).frobeniusNorm()); m_tissue.accessPath().addSegment(seg); return true; - } else + } + else return false; } @@ -764,7 +773,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersSparseEige trueFreeLength += m_needle.accessSegment(i).getLength(); } trueFreeLength += m_needle.accessSegment(seg).getSubPolynomialCurve(0, param).getLength(); - } else { + } + else { vpColVector p(3); for (int i = 0; i < 3; i++) p[i] = m_needle.getBasePose()[i]; @@ -968,9 +978,9 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersSparseEige double l = LsegMin; while (l < LsegMax) { usPolynomialCurve3D p(m_tissue.accessPath().accessSegment(restIndex).getSubPolynomialCurve( - currentRestParam, - ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + - m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); + currentRestParam, + ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + + m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); p.changeCoefficientsToFitBoundaries(l, l + m_restDilatationFactor.at(i - 1) * p.getParametricLength()); int nbRestSegCoef = p.getOrder() + 1; @@ -980,7 +990,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersSparseEige Lmax = LsegMax; currentRestParam += (LsegMax - l) / m_restDilatationFactor.at(i - 1); l = LsegMax; - } else { + } + else { Lmax = l + p.getParametricLength(); l = Lmax; currentRestParam = 0; @@ -1002,7 +1013,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersSparseEige layerIndex++; nextLayerDepth += m_layerLength.at(layerIndex); lseg += LsegMax - LsegMin; - } else + } + else lseg = segLength; currentDepth += LsegMax - LsegMin; @@ -1074,7 +1086,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse trueFreeLength += m_needle.accessSegment(i).getLength(); } trueFreeLength += m_needle.accessSegment(seg).getSubPolynomialCurve(0, param).getLength(); - } else { + } + else { vpColVector p(3); for (int i = 0; i < 3; i++) p[i] = m_needle.getBasePose()[i]; @@ -1296,9 +1309,9 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse double l = LsegMin; while (l < LsegMax) { usPolynomialCurve3D p(m_tissue.accessPath().accessSegment(restIndex).getSubPolynomialCurve( - currentRestParam, - ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + - m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); + currentRestParam, + ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + + m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); p.changeCoefficientsToFitBoundaries(l, l + m_restDilatationFactor.at(i) * p.getParametricLength()); int nbRestSegCoef = p.getOrder() + 1; @@ -1308,7 +1321,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse Lmax = LsegMax; currentRestParam += (LsegMax - l) / m_restDilatationFactor.at(i); l = LsegMax; - } else { + } + else { Lmax = l + p.getParametricLength(); l = Lmax; currentRestParam = 0; @@ -1330,7 +1344,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse layerIndex++; nextLayerDepth += m_layerLength.at(layerIndex); lseg += LsegMax - LsegMin; - } else + } + else lseg = segLength; currentDepth += LsegMax - LsegMin; @@ -1363,8 +1378,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse double cosTheta = vpColVector::dotProd(m_tissue.accessSurface().getDirection(), bevelSegment); if (cosTheta > std::numeric_limits::epsilon()) LbevMin = - fabs(usGeometryTools::getPointPlaneDistance(m_needleTip->getBasePosition(), m_tissue.accessSurface())) / - cosTheta; + fabs(usGeometryTools::getPointPlaneDistance(m_needleTip->getBasePosition(), m_tissue.accessSurface())) / + cosTheta; else LbevMin = bevLength; } @@ -1403,9 +1418,9 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse double l = LbevMin; while (l < LbevMax) { usPolynomialCurve3D p(m_tissue.accessPath().accessSegment(restIndex).getSubPolynomialCurve( - currentRestParam, - ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + - m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); + currentRestParam, + ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + + m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); p.changeCoefficientsToFitBoundaries(l, l + p.getParametricLength()); int nbRestSegCoef = p.getOrder() + 1; @@ -1415,7 +1430,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse Lmax = LbevMax; currentRestParam += LbevMax - l; l = LbevMax; - } else { + } + else { Lmax = l + p.getParametricLength(); l = Lmax; currentRestParam = 0; @@ -1444,7 +1460,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse layerIndex++; nextLayerDepth += m_layerLength.at(layerIndex); lbev += LbevMax - LbevMin; - } else + } + else lbev = bevLength; currentDepth += LbevMax - LbevMin; @@ -1514,7 +1531,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse trueFreeLength += m_needle.accessSegment(i).getLength(); } trueFreeLength += m_needle.accessSegment(seg).getSubPolynomialCurve(0, param).getLength(); - } else { + } + else { vpColVector p(3); for (int i = 0; i < 3; i++) p[i] = m_needle.getBasePose()[i]; @@ -1730,9 +1748,9 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse double factor = m_restDilatationFactor.at(i); while (l < LsegMax) { usPolynomialCurve3D p(m_tissue.accessPath().accessSegment(restIndex).getSubPolynomialCurve( - currentRestParam, - ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + - m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); + currentRestParam, + ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + + m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); p.changeCoefficientsToFitBoundaries(l, l + factor * p.getParametricLength()); int nbRestSegCoef = p.getOrder() + 1; @@ -1742,7 +1760,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse Lmax = LsegMax; currentRestParam += (LsegMax - l) / factor; l = LsegMax; - } else { + } + else { Lmax = l + p.getParametricLength(); l = Lmax; currentRestParam = 0; @@ -1765,7 +1784,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse layerIndex++; nextLayerDepth += m_layerLength.at(layerIndex); lseg += LsegMax - LsegMin; - } else + } + else lseg = segLength; currentDepth += LsegMax - LsegMin; @@ -1802,8 +1822,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse double cosTheta = vpColVector::dotProd(m_tissue.accessSurface().getDirection(), bevelSegment); if (cosTheta > std::numeric_limits::epsilon()) LbevMin = - fabs(usGeometryTools::getPointPlaneDistance(m_needleTip->getBasePosition(), m_tissue.accessSurface())) / - cosTheta; + fabs(usGeometryTools::getPointPlaneDistance(m_needleTip->getBasePosition(), m_tissue.accessSurface())) / + cosTheta; else LbevMin = bevLength; } @@ -1842,9 +1862,9 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse double l = LbevMin; while (l < LbevMax) { usPolynomialCurve3D p(m_tissue.accessPath().accessSegment(restIndex).getSubPolynomialCurve( - currentRestParam, - ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + - m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); + currentRestParam, + ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + + m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); p.changeCoefficientsToFitBoundaries(l, l + p.getParametricLength()); int nbRestSegCoef = p.getOrder() + 1; @@ -1854,7 +1874,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse Lmax = LbevMax; currentRestParam += LbevMax - l; l = LbevMax; - } else { + } + else { Lmax = l + p.getParametricLength(); l = Lmax; currentRestParam = 0; @@ -1883,7 +1904,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersFullSparse layerIndex++; nextLayerDepth += m_layerLength.at(layerIndex); lbev += LbevMax - LbevMin; - } else + } + else lbev = bevLength; currentDepth += LbevMax - LbevMin; @@ -1952,7 +1974,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersDense() trueFreeLength += m_needle.accessSegment(i).getLength(); } trueFreeLength += m_needle.accessSegment(seg).getSubPolynomialCurve(0, param).getLength(); - } else { + } + else { vpColVector p(3); for (int i = 0; i < 3; i++) p[i] = m_needle.getBasePose()[i]; @@ -2164,9 +2187,9 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersDense() double factor = m_restDilatationFactor.at(i); while (l < LsegMax) { usPolynomialCurve3D p(m_tissue.accessPath().accessSegment(restIndex).getSubPolynomialCurve( - currentRestParam, - ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + - m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); + currentRestParam, + ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + + m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); p.changeCoefficientsToFitBoundaries(l, l + factor * p.getParametricLength()); int nbRestSegCoef = p.getOrder() + 1; @@ -2176,7 +2199,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersDense() Lmax = LsegMax; currentRestParam += (LsegMax - l) / factor; l = LsegMax; - } else { + } + else { Lmax = l + p.getParametricLength(); l = Lmax; currentRestParam = 0; @@ -2199,7 +2223,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersDense() layerIndex++; nextLayerDepth += m_layerLength.at(layerIndex); lseg += LsegMax - LsegMin; - } else + } + else lseg = segLength; currentDepth += LsegMax - LsegMin; @@ -2236,8 +2261,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersDense() double cosTheta = vpColVector::dotProd(m_tissue.accessSurface().getDirection(), bevelSegment); if (cosTheta > std::numeric_limits::epsilon()) LbevMin = - fabs(usGeometryTools::getPointPlaneDistance(m_needleTip->getBasePosition(), m_tissue.accessSurface())) / - cosTheta; + fabs(usGeometryTools::getPointPlaneDistance(m_needleTip->getBasePosition(), m_tissue.accessSurface())) / + cosTheta; else LbevMin = bevLength; } @@ -2276,9 +2301,9 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersDense() double l = LbevMin; while (l < LbevMax) { usPolynomialCurve3D p(m_tissue.accessPath().accessSegment(restIndex).getSubPolynomialCurve( - currentRestParam, - ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + - m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); + currentRestParam, + ((restIndex == m_tissue.accessPath().getNbSegments() - 1) ? currentRestParam : 0) + + m_tissue.accessPath().accessSegment(restIndex).getParametricLength())); p.changeCoefficientsToFitBoundaries(l, l + p.getParametricLength()); int nbRestSegCoef = p.getOrder() + 1; @@ -2288,7 +2313,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersDense() Lmax = LbevMax; currentRestParam += LbevMax - l; l = LbevMax; - } else { + } + else { Lmax = l + p.getParametricLength(); l = Lmax; currentRestParam = 0; @@ -2317,7 +2343,8 @@ void usNeedleInsertionModelRayleighRitzSpline::solveSegmentsParametersDense() layerIndex++; nextLayerDepth += m_layerLength.at(layerIndex); lbev += LbevMax - LbevMin; - } else + } + else lbev = bevLength; currentDepth += LbevMax - LbevMin; @@ -2373,9 +2400,9 @@ void usNeedleInsertionModelRayleighRitzSpline::updateTipPose() vpTranslationVector t(pt[0], pt[1], pt[2]); vpColVector vect = - vpColVector::crossProd(m_needle.accessSegment(0).getStartTangent(), m_needle.accessLastSegment().getEndTangent()); + vpColVector::crossProd(m_needle.accessSegment(0).getStartTangent(), m_needle.accessLastSegment().getEndTangent()); double dot = - vpColVector::dotProd(m_needle.accessSegment(0).getStartTangent(), m_needle.accessLastSegment().getEndTangent()); + vpColVector::dotProd(m_needle.accessSegment(0).getStartTangent(), m_needle.accessLastSegment().getEndTangent()); double theta = atan2(vect.frobeniusNorm(), dot); vect.normalize(); vect = theta * vect; @@ -2428,7 +2455,8 @@ bool usNeedleInsertionModelRayleighRitzSpline::updateState() for (unsigned int i = 0; i < m_restDilatationFactor.size(); i++) m_restDilatationFactor.at(i) = l / restLength; - } else { + } + else { pl.setPosition(m_tissue.accessPath().accessLastSegment().getEndPoint()); if (usGeometryTools::DoesSegmentCrossPlaneDirect(m_needle, pl)) { double l = -1; @@ -2438,7 +2466,8 @@ bool usNeedleInsertionModelRayleighRitzSpline::updateState() for (unsigned int i = 0; i < m_restDilatationFactor.size(); i++) m_restDilatationFactor.at(i) = l / restLength; - } else + } + else for (unsigned int i = 0; i < m_restDilatationFactor.size(); i++) m_restDilatationFactor.at(i) = 1; } @@ -2475,20 +2504,24 @@ bool usNeedleInsertionModelRayleighRitzSpline::updatePath() restIndex, restParam); lastPoint = m_tissue.accessPath().accessLastSegment().getEndPoint(); lastDirection = m_tissue.accessPath().accessLastSegment().getEndTangent(); - } else if (usGeometryTools::IsPointInFrontOfPlane(m_needleTip->getTipPosition(), m_tissue.accessSurface())) { + } + else if (usGeometryTools::IsPointInFrontOfPlane(m_needleTip->getTipPosition(), m_tissue.accessSurface())) { lastDirection = m_needleTip->getTipDirection(); lastPoint = - usGeometryTools::projectPointOnPlane(m_needleTip->getTipPosition(), m_tissue.accessSurface(), lastDirection); - } else + usGeometryTools::projectPointOnPlane(m_needleTip->getTipPosition(), m_tissue.accessSurface(), lastDirection); + } + else return false; double insertionStep = 0; if (m_tissue.accessPath().getNbSegments() > 0 && restIndex == m_tissue.accessPath().getNbSegments() - 1) { insertionStep = restParam - m_tissue.accessPath().accessSegment(restIndex).getParametricLength(); - } else if (m_tissue.accessPath().getNbSegments() == 0) { + } + else if (m_tissue.accessPath().getNbSegments() == 0) { insertionStep = vpColVector::dotProd(m_needleTip->getTipPosition() - lastPoint, lastDirection); - } else + } + else return false; if (insertionStep > m_pathUpdateLengthThreshold) { @@ -2503,7 +2536,8 @@ bool usNeedleInsertionModelRayleighRitzSpline::updatePath() seg.setParametricLength(u.frobeniusNorm()); m_tissue.accessPath().addSegment(seg); return true; - } else + } + else return false; } case PathUpdateType::WithTipMix: { @@ -2517,20 +2551,24 @@ bool usNeedleInsertionModelRayleighRitzSpline::updatePath() restIndex, restParam); lastPoint = m_tissue.accessPath().accessLastSegment().getEndPoint(); lastDirection = m_tissue.accessPath().accessLastSegment().getEndTangent(); - } else if (usGeometryTools::IsPointInFrontOfPlane(m_needleTip->getTipPosition(), m_tissue.accessSurface())) { + } + else if (usGeometryTools::IsPointInFrontOfPlane(m_needleTip->getTipPosition(), m_tissue.accessSurface())) { lastDirection = m_needleTip->getTipDirection(); lastPoint = - usGeometryTools::projectPointOnPlane(m_needleTip->getTipPosition(), m_tissue.accessSurface(), lastDirection); - } else + usGeometryTools::projectPointOnPlane(m_needleTip->getTipPosition(), m_tissue.accessSurface(), lastDirection); + } + else return false; double insertionStep = 0; if (m_tissue.accessPath().getNbSegments() > 0 && restIndex == m_tissue.accessPath().getNbSegments() - 1) { insertionStep = restParam - m_tissue.accessPath().accessSegment(restIndex).getParametricLength(); - } else if (m_tissue.accessPath().getNbSegments() == 0) { + } + else if (m_tissue.accessPath().getNbSegments() == 0) { insertionStep = vpColVector::dotProd(m_needleTip->getTipPosition() - lastPoint, lastDirection); - } else + } + else return false; if (insertionStep > m_pathUpdateLengthThreshold) { @@ -2539,14 +2577,15 @@ bool usNeedleInsertionModelRayleighRitzSpline::updatePath() M.insert(lastPoint, 0, 0); vpColVector newPoint = m_pathUpdateMixCoefficient * (lastPoint + insertionStep * m_needleTip->getTipDirection()) + - (1 - m_pathUpdateMixCoefficient) * m_needleTip->getTipPosition(); + (1 - m_pathUpdateMixCoefficient) * m_needleTip->getTipPosition(); M.insert((newPoint - lastPoint).normalize(), 0, 1); seg.setPolynomialCoefficients(M); seg.setParametricLength((newPoint - lastPoint).frobeniusNorm()); m_tissue.accessPath().addSegment(seg); return true; - } else + } + else return false; } default: diff --git a/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelVirtualSprings.cpp b/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelVirtualSprings.cpp index 6620b625..72a1af40 100644 --- a/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelVirtualSprings.cpp +++ b/modules/ustk_needle_modeling/src/usInsertionModel/usNeedleInsertionModelVirtualSprings.cpp @@ -55,24 +55,28 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + usNeedleInsertionModelVirtualSprings::usNeedleInsertionModelVirtualSprings() : m_needle(), - m_tipForce(0), m_tipMoment(0), m_cutAngle(0), m_bevelLength(0.001), + m_tipForce(0), m_tipMoment(0), m_cutAngle(0), m_bevelLength(0.001), - m_defaultSpringStiffness(100), m_stiffnessPerUnitLength(25000), - m_tissueSurface(vpColVector(3, 0), vpColVector(3, 0)), + m_defaultSpringStiffness(100), m_stiffnessPerUnitLength(25000), + m_tissueSurface(vpColVector(3, 0), vpColVector(3, 0)), - m_interSpringDistance(0.005), m_interTipSpringDistance(0.0005), + m_interSpringDistance(0.005), m_interTipSpringDistance(0.0005), - m_IsStateConsistent(false), + m_IsStateConsistent(false), - m_LastSegmentLengthComputed(true), + m_LastSegmentLengthComputed(true), - m_insertionBehavior(InsertionType::NaturalBehavior), m_IsInserting(false), m_AllowSpringAddition(true), - m_AllowSpringRemoval(true), m_AutomaticSpringAddition(true), + m_insertionBehavior(InsertionType::NaturalBehavior), m_IsInserting(false), m_AllowSpringAddition(true), + m_AllowSpringRemoval(true), m_AutomaticSpringAddition(true), - m_tipSpringsIndex(0), m_nbMinTipSprings(1), m_nbMaxTipSprings(10) + m_tipSpringsIndex(0), m_nbMinTipSprings(1), m_nbMaxTipSprings(10) { // Computation of tip position @@ -83,31 +87,30 @@ usNeedleInsertionModelVirtualSprings::usNeedleInsertionModelVirtualSprings( const usNeedleInsertionModelVirtualSprings &needle) : m_needle(needle.m_needle), - m_tipForce(needle.m_tipForce), m_tipMoment(needle.m_tipMoment), m_cutAngle(needle.m_cutAngle), - m_bevelLength(needle.m_bevelLength), + m_tipForce(needle.m_tipForce), m_tipMoment(needle.m_tipMoment), m_cutAngle(needle.m_cutAngle), + m_bevelLength(needle.m_bevelLength), - m_defaultSpringStiffness(needle.m_defaultSpringStiffness), - m_stiffnessPerUnitLength(needle.m_stiffnessPerUnitLength), + m_defaultSpringStiffness(needle.m_defaultSpringStiffness), + m_stiffnessPerUnitLength(needle.m_stiffnessPerUnitLength), - m_springs(needle.m_springs), m_inactiveAutoAddedSprings(needle.m_inactiveAutoAddedSprings), - m_inactiveMeasureSprings(needle.m_inactiveMeasureSprings), m_tissueSurface(needle.m_tissueSurface), - m_interSpringDistance(needle.m_interSpringDistance), m_interTipSpringDistance(needle.m_interTipSpringDistance), + m_springs(needle.m_springs), m_inactiveAutoAddedSprings(needle.m_inactiveAutoAddedSprings), + m_inactiveMeasureSprings(needle.m_inactiveMeasureSprings), m_tissueSurface(needle.m_tissueSurface), + m_interSpringDistance(needle.m_interSpringDistance), m_interTipSpringDistance(needle.m_interTipSpringDistance), - m_IsStateConsistent(needle.m_IsStateConsistent), + m_IsStateConsistent(needle.m_IsStateConsistent), - m_LastSegmentLengthComputed(needle.m_LastSegmentLengthComputed), + m_LastSegmentLengthComputed(needle.m_LastSegmentLengthComputed), - m_insertionBehavior(needle.m_insertionBehavior), m_IsInserting(needle.m_IsInserting), - m_AllowSpringAddition(needle.m_AllowSpringAddition), m_AllowSpringRemoval(needle.m_AllowSpringRemoval), - m_AutomaticSpringAddition(needle.m_AutomaticSpringAddition), + m_insertionBehavior(needle.m_insertionBehavior), m_IsInserting(needle.m_IsInserting), + m_AllowSpringAddition(needle.m_AllowSpringAddition), m_AllowSpringRemoval(needle.m_AllowSpringRemoval), + m_AutomaticSpringAddition(needle.m_AutomaticSpringAddition), - m_tipSpringsIndex(needle.m_tipSpringsIndex), m_nbMinTipSprings(needle.m_nbMinTipSprings), - m_nbMaxTipSprings(needle.m_nbMaxTipSprings) + m_tipSpringsIndex(needle.m_tipSpringsIndex), m_nbMinTipSprings(needle.m_nbMinTipSprings), + m_nbMaxTipSprings(needle.m_nbMaxTipSprings) -{ -} +{ } -usNeedleInsertionModelVirtualSprings::~usNeedleInsertionModelVirtualSprings() {} +usNeedleInsertionModelVirtualSprings::~usNeedleInsertionModelVirtualSprings() { } usNeedleInsertionModelVirtualSprings *usNeedleInsertionModelVirtualSprings::clone() const { @@ -268,7 +271,8 @@ void usNeedleInsertionModelVirtualSprings::setStiffnessPerUnitLength(double K) if (K > 0) { m_stiffnessPerUnitLength = K; updateTipForce(); - } else + } + else m_stiffnessPerUnitLength = 0; } @@ -373,7 +377,8 @@ void usNeedleInsertionModelVirtualSprings::setNbMinTipSprings(int nb) m_nbMinTipSprings = nb; else m_nbMinTipSprings = m_nbMaxTipSprings; - } else + } + else m_nbMinTipSprings = 1; } @@ -389,7 +394,8 @@ void usNeedleInsertionModelVirtualSprings::setNbMaxTipSprings(int nb) m_nbMaxTipSprings = nb; else m_nbMaxTipSprings = m_nbMinTipSprings; - } else + } + else m_nbMaxTipSprings = 1; } @@ -536,7 +542,7 @@ vpPoseVector usNeedleInsertionModelVirtualSprings::getBasePose() const { return bool usNeedleInsertionModelVirtualSprings::setSpringPosition(int index, const vpColVector &P, bool update) { - if (index < 0 || index > (int)m_springs.size() - 1) + if (index < 0 || index >(int)m_springs.size() - 1) throw vpException(vpException::badValue, "usNeedleInsertionModelVirtualSprings::setSpringPosition: invlaid spring index"); @@ -553,7 +559,7 @@ bool usNeedleInsertionModelVirtualSprings::setSpringPosition(int index, const vp bool usNeedleInsertionModelVirtualSprings::setSpringDirection(int index, const vpColVector &D, bool update) { - if (index < 0 || index > (int)m_springs.size() - 1) + if (index < 0 || index >(int)m_springs.size() - 1) throw vpException(vpException::badValue, "usNeedleInsertionModelVirtualSprings::setSpringDirection: invalid spring index"); if (D.size() != 3) @@ -569,7 +575,7 @@ bool usNeedleInsertionModelVirtualSprings::setSpringDirection(int index, const v void usNeedleInsertionModelVirtualSprings::setSpringStiffness(int index, double K, bool update) { - if (index < 0 || index > (int)m_springs.size() - 1) + if (index < 0 || index >(int)m_springs.size() - 1) throw vpException(vpException::badValue, "usNeedleInsertionModelVirtualSprings::setSpringStiffness: bad spring index"); if (K <= 0) @@ -602,7 +608,7 @@ void usNeedleInsertionModelVirtualSprings::setSurfaceAtTip() vpColVector p = m_needle.accessLastSegment().getEndPoint(); vpColVector d = m_needle.accessLastSegment().getEndTangent(); p += m_bevelLength * d + - m_needle.getOuterDiameter() / 2 * vpColVector(vpHomogeneousMatrix(m_needle.getTipPose()).getCol(1), 0, 3); + m_needle.getOuterDiameter() / 2 * vpColVector(vpHomogeneousMatrix(m_needle.getTipPose()).getCol(1), 0, 3); m_tissueSurface.setPosition(p); m_tissueSurface.setDirection(d); } @@ -640,7 +646,8 @@ void usNeedleInsertionModelVirtualSprings::addInsertionPointOnSegmentHard(int se usVirtualSpring spg(m_needle.accessLastSegment().getStartPoint() + l * bevelDirection, m_needle.accessSegment(segment).getEndTangent(), m_defaultSpringStiffness); m_springs.insert(m_springs.begin() + segment, spg); - } else { + } + else { usVirtualSpring spg(m_needle.accessSegment(segment).getEndPoint(), m_needle.accessSegment(segment).getEndTangent(), m_defaultSpringStiffness); m_springs.insert(m_springs.begin() + segment, spg); @@ -672,11 +679,12 @@ void usNeedleInsertionModelVirtualSprings::addInsertionPointOnSegment(int segmen if (segment == 0) // if first spring added { K = m_stiffnessPerUnitLength * l2; - } else { + } + else { double L1 = - m_needle.accessSegment(segment - 1).getParametricLength(); // length of tissue before current last spring + m_needle.accessSegment(segment - 1).getParametricLength(); // length of tissue before current last spring double L = m_needle.accessLastSegment().getParametricLength() + - m_bevelLength; // length of tissue after current last spring + m_bevelLength; // length of tissue after current last spring if (segment == 1) L1 = 0; K = m_springs.at(segment - 1).getStiffness() * (L - s / 2) / (L1 / 2 + L); @@ -685,7 +693,8 @@ void usNeedleInsertionModelVirtualSprings::addInsertionPointOnSegment(int segmen this->addInsertionPointOnSegmentHard(segment, s); m_springs.back().setStiffness(K); - } else // spring added on intermediate segment => interpolation + } + else // spring added on intermediate segment => interpolation { double c = s / Lseg; vpColVector x0 = m_springs.at(segment - 1).getPosition(); @@ -734,7 +743,8 @@ int usNeedleInsertionModelVirtualSprings::addInsertionPoint(usVirtualSpring spg) double s = -1; if (usGeometryTools::DoesSegmentCrossPlane(m_needle.accessSegment(segment), spg)) { usGeometryTools::getPlaneCurveCrossingPoint(m_needle.accessSegment(segment), spg, -1, &s); - } else + } + else s = Lseg / 2; double l2 = Lseg - s; @@ -745,18 +755,20 @@ int usNeedleInsertionModelVirtualSprings::addInsertionPoint(usVirtualSpring spg) if (segment == 0) // if first spring added { K = 2 * m_stiffnessPerUnitLength * (l2 + m_bevelLength); - } else { + } + else { double L1 = - m_needle.accessSegment(segment - 1).getParametricLength(); // length of tissue before current last spring + m_needle.accessSegment(segment - 1).getParametricLength(); // length of tissue before current last spring double L = m_needle.accessLastSegment().getParametricLength() + - m_bevelLength; // length of tissue after current last spring + m_bevelLength; // length of tissue after current last spring if (segment == 1) L1 = 0; K = m_springs.at(segment - 1).getStiffness() * (L - s / 2) / (L1 / 2 + L); m_springs.at(segment - 1).addStiffness(-K); } spg.setStiffness(K); - } else // spring added on intermediate segment => interpolation + } + else // spring added on intermediate segment => interpolation { double L1 = m_needle.accessSegment(segment - 1).getParametricLength(); if (segment - 1 == 0) @@ -790,7 +802,7 @@ int usNeedleInsertionModelVirtualSprings::addInsertionPoint(const vpColVector &p if (index == 0 && m_springs.size() != 0) { std::cout << "Warning in usNeedleInsertionModelVirtualSprings::addInsertionPoint: add spring on first segment" - << std::endl; + << std::endl; } usVirtualSpring spg(p, d, 0); @@ -802,19 +814,22 @@ int usNeedleInsertionModelVirtualSprings::addInsertionPoint(const vpColVector &p !usGeometryTools::IsPointInFrontOfPlane(m_needle.accessSegment(index).getEndPoint(), spg)) { spg.setDirection(-spg.getDirection()); s = Lseg / 2; - } else if (usGeometryTools::IsPointInFrontOfPlane(m_needle.accessSegment(index).getStartPoint(), spg) && - usGeometryTools::IsPointInFrontOfPlane(m_needle.accessSegment(index).getEndPoint(), spg)) { + } + else if (usGeometryTools::IsPointInFrontOfPlane(m_needle.accessSegment(index).getStartPoint(), spg) && + usGeometryTools::IsPointInFrontOfPlane(m_needle.accessSegment(index).getEndPoint(), spg)) { s = m_interTipSpringDistance; vpColVector P = m_needle.accessSegment(index).getPoint(s); spg.setDirection(vpColVector::crossProd(P - p, vpColVector::crossProd(d, P - p)).normalize()); - } else if (!usGeometryTools::IsPointInFrontOfPlane(m_needle.accessSegment(index).getStartPoint(), spg) && - !usGeometryTools::IsPointInFrontOfPlane(m_needle.accessSegment(index).getEndPoint(), spg)) { + } + else if (!usGeometryTools::IsPointInFrontOfPlane(m_needle.accessSegment(index).getStartPoint(), spg) && + !usGeometryTools::IsPointInFrontOfPlane(m_needle.accessSegment(index).getEndPoint(), spg)) { s = Lseg - m_interTipSpringDistance; vpColVector P = m_needle.accessSegment(index).getPoint(s); spg.setDirection(vpColVector::crossProd(P - p, vpColVector::crossProd(d, P - p)).normalize()); - } else { + } + else { s = Lseg / 2; } @@ -828,18 +843,20 @@ int usNeedleInsertionModelVirtualSprings::addInsertionPoint(const vpColVector &p if (segment == 0) // if first spring added { K = 2 * m_stiffnessPerUnitLength * (l2 + m_bevelLength); - } else { + } + else { double L1 = - m_needle.accessSegment(segment - 1).getParametricLength(); // length of tissue before current last spring + m_needle.accessSegment(segment - 1).getParametricLength(); // length of tissue before current last spring double L = m_needle.accessLastSegment().getParametricLength() + - m_bevelLength; // length of tissue after current last spring + m_bevelLength; // length of tissue after current last spring if (segment == 1) L1 = 0; double K = m_springs.at(segment - 1).getStiffness() * (L - s / 2) / (L1 / 2 + L); m_springs.at(segment - 1).addStiffness(-K); } spg.setStiffness(K); - } else // spring added on intermediate segment => interpolation + } + else // spring added on intermediate segment => interpolation { double L1 = m_needle.accessSegment(segment - 1).getParametricLength(); if (segment - 1 == 0) @@ -928,16 +945,16 @@ void usNeedleInsertionModelVirtualSprings::removeInsertionPoints(int first, int this->fusionSprings(first - 1, last); double L1 = m_needle.accessSegment(m_needle.getNbSegments() - 3) - .getParametricLength(); // length of tissue before last spring that will remain + .getParametricLength(); // length of tissue before last spring that will remain double L = m_needle.accessSegment(m_needle.getNbSegments() - 2) - .getParametricLength(); // length of tissue before current last spring + .getParametricLength(); // length of tissue before current last spring double L2 = m_needle.accessLastSegment().getParametricLength() + - m_bevelLength; // length of tissue after current last spring + m_bevelLength; // length of tissue after current last spring if (m_springs.size() == 2) L1 = 0; m_springs.at(m_springs.size() - 2) - .setStiffness((m_springs.at(m_springs.size() - 2).getStiffness() + m_springs.back().getStiffness()) * - (L1 / 2 + L2) / (L1 / 2 + L + L2)); + .setStiffness((m_springs.at(m_springs.size() - 2).getStiffness() + m_springs.back().getStiffness()) * + (L1 / 2 + L2) / (L1 / 2 + L + L2)); if (!m_springs.back().IsPositionUpdateAllowed()) m_inactiveMeasureSprings.push_back(m_springs.back()); @@ -989,7 +1006,8 @@ void usNeedleInsertionModelVirtualSprings::fusionSprings(int firstSpring, int la if (!m_springs.at(firstSpring + 1).IsPositionUpdateAllowed()) m_inactiveMeasureSprings.push_back(m_springs.at(firstSpring + 1)); this->removeInsertionPointsHard(firstSpring + 1); - } else { + } + else { int middle = (firstSpring + lastSpring) / 2; this->fusionSprings(middle, lastSpring); this->fusionSprings(firstSpring, middle + 1); @@ -1028,7 +1046,8 @@ void usNeedleInsertionModelVirtualSprings::updateCutAngle() double vect = vpColVector::crossProd(z, ztip).frobeniusNorm(); double dot = vpColVector::dotProd(z, ztip); m_cutAngle = 180 / M_PI * atan2(vect, dot); - } else { + } + else { m_cutAngle = 0; } // m_cutAngle = 0; @@ -1043,12 +1062,12 @@ void usNeedleInsertionModelVirtualSprings::updateTipForce() double b = m_needle.getOuterDiameter() / sin(bevel_rad); m_tipForce = 0.5 * m_stiffnessPerUnitLength * - (a * a * tan(cut_rad) / 2 - b * b * cos(bevel_rad) * tan(bevel_rad - cut_rad) / 2); + (a * a * tan(cut_rad) / 2 - b * b * cos(bevel_rad) * tan(bevel_rad - cut_rad) / 2); m_tipMoment = 0.5 * m_stiffnessPerUnitLength * - (-a * a * a * tan(cut_rad) / 6 + - b * b * tan(bevel_rad - cut_rad) / 2 * - (a * cos(bevel_rad) / 3 - m_needle.getOuterDiameter() * sin(bevel_rad) / 6)); + (-a * a * a * tan(cut_rad) / 6 + + b * b * tan(bevel_rad - cut_rad) / 2 * + (a * cos(bevel_rad) / 3 - m_needle.getOuterDiameter() * sin(bevel_rad) / 6)); } void usNeedleInsertionModelVirtualSprings::updateInsertionDirections() @@ -1202,7 +1221,8 @@ void usNeedleInsertionModelVirtualSprings::solveSegmentsParametersSparseEigen() z[1] = 0; z[2] = 1; n1m_n = vpColVector::crossProd(m_springs.at(n).getDirection(), z); - } else { + } + else { vpColVector y(3); y[0] = 0; y[1] = 1; @@ -1291,9 +1311,9 @@ void usNeedleInsertionModelVirtualSprings::solveSegmentsParametersSparseEigen() for (int i = 0; i < m_needle.getNbSegments(); i++) { vpColVector vect = - vpColVector::crossProd(m_needle.accessSegment(i).getStartTangent(), m_needle.accessSegment(i).getEndTangent()); + vpColVector::crossProd(m_needle.accessSegment(i).getStartTangent(), m_needle.accessSegment(i).getEndTangent()); double dot = - vpColVector::dotProd(m_needle.accessSegment(i).getStartTangent(), m_needle.accessSegment(i).getEndTangent()); + vpColVector::dotProd(m_needle.accessSegment(i).getStartTangent(), m_needle.accessSegment(i).getEndTangent()); double theta = atan2(vect.frobeniusNorm(), dot); vect.normalize(); vect = theta * vect; @@ -1460,7 +1480,8 @@ void usNeedleInsertionModelVirtualSprings::solveSegmentsParametersOpenCV() z[1] = 0; z[2] = 1; n1m_n = vpColVector::crossProd(m_springs.at(n).getDirection(), z); - } else { + } + else { vpColVector y(3); y[0] = 0; y[1] = 1; @@ -1543,9 +1564,9 @@ void usNeedleInsertionModelVirtualSprings::solveSegmentsParametersOpenCV() for (int i = 0; i < m_needle.getNbSegments(); i++) { vpColVector vect = - vpColVector::crossProd(m_needle.accessSegment(i).getStartTangent(), m_needle.accessSegment(i).getEndTangent()); + vpColVector::crossProd(m_needle.accessSegment(i).getStartTangent(), m_needle.accessSegment(i).getEndTangent()); double dot = - vpColVector::dotProd(m_needle.accessSegment(i).getStartTangent(), m_needle.accessSegment(i).getEndTangent()); + vpColVector::dotProd(m_needle.accessSegment(i).getStartTangent(), m_needle.accessSegment(i).getEndTangent()); double theta = atan2(vect.frobeniusNorm(), dot); vect.normalize(); vect = theta * vect; @@ -1710,7 +1731,8 @@ void usNeedleInsertionModelVirtualSprings::solveSegmentsParametersViSP() z[1] = 0; z[2] = 1; n1m_n = vpColVector::crossProd(m_springs.at(n).getDirection(), z); - } else { + } + else { vpColVector y(3); y[0] = 0; y[1] = 1; @@ -1796,9 +1818,9 @@ void usNeedleInsertionModelVirtualSprings::solveSegmentsParametersViSP() for (int i = 0; i < m_needle.getNbSegments(); i++) { vpColVector vect = - vpColVector::crossProd(m_needle.accessSegment(i).getStartTangent(), m_needle.accessSegment(i).getEndTangent()); + vpColVector::crossProd(m_needle.accessSegment(i).getStartTangent(), m_needle.accessSegment(i).getEndTangent()); double dot = - vpColVector::dotProd(m_needle.accessSegment(i).getStartTangent(), m_needle.accessSegment(i).getEndTangent()); + vpColVector::dotProd(m_needle.accessSegment(i).getStartTangent(), m_needle.accessSegment(i).getEndTangent()); double theta = atan2(vect.frobeniusNorm(), dot); vect.normalize(); vect = theta * vect; @@ -1859,12 +1881,14 @@ bool usNeedleInsertionModelVirtualSprings::addRemoveSprings() this->addInsertionPointOnSegment(m_needle.getNbSegments() - 1, s); m_LastSegmentLengthComputed = true; return true; - } else { + } + else { m_needle.accessLastSegment().setParametricLength(m_needle.getFullLength()); m_LastSegmentLengthComputed = true; return false; } - } else { + } + else { m_needle.accessLastSegment().setParametricLength(m_needle.getFullLength()); m_LastSegmentLengthComputed = true; return false; @@ -1889,7 +1913,7 @@ bool usNeedleInsertionModelVirtualSprings::addRemoveSprings() // if the needle is still inserted if (segment - 1 > 0) { double lastSegmentLength = - m_needle.getFullLength() - (totalLength - m_needle.accessSegment(segment - 1).getParametricLength()); + m_needle.getFullLength() - (totalLength - m_needle.accessSegment(segment - 1).getParametricLength()); int lastValidSpringIndex = segment - 2; if (m_AutomaticSpringAddition) { @@ -1910,10 +1934,12 @@ bool usNeedleInsertionModelVirtualSprings::addRemoveSprings() if (l > 1.5 * m_interTipSpringDistance) { this->addInsertionPointOnSegment(m_tipSpringsIndex, l - m_interTipSpringDistance); lastValidSpringIndex++; - } else + } + else m_tipSpringsIndex--; } - } else + } + else m_tipSpringsIndex = lastValidSpringIndex; // Remove all springs where the needle is not anymore @@ -1935,7 +1961,7 @@ bool usNeedleInsertionModelVirtualSprings::addRemoveSprings() // Keep spring if it leads to a segment that is too long or if it is a measure spring and increase tip spring index // instead if ((m_tipSpringsIndex == 0) || (m_needle.accessSegment(m_tipSpringsIndex).getParametricLength() + - m_needle.accessSegment(m_tipSpringsIndex + 1).getParametricLength() >= + m_needle.accessSegment(m_tipSpringsIndex + 1).getParametricLength() >= m_interSpringDistance) || (!m_springs.at(m_tipSpringsIndex).IsPositionUpdateAllowed())) { // this->fusionSprings(m_tipSpringsIndex, m_tipSpringsIndex+2); @@ -2006,8 +2032,8 @@ void usNeedleInsertionModelVirtualSprings::addMeasureSpring(const vpColVector &p if (m_tissueSurface.getDirection().frobeniusNorm() != 0 && !usGeometryTools::IsPointInFrontOfPlane(p, m_tissueSurface)) { std::cerr - << "Warning in usNeedleInsertionModelVirtualSprings::addMeasureSpring: cannot add spring outside of tissue" - << std::endl; + << "Warning in usNeedleInsertionModelVirtualSprings::addMeasureSpring: cannot add spring outside of tissue" + << std::endl; return; } @@ -2051,7 +2077,8 @@ bool usNeedleInsertionModelVirtualSprings::updateState() // Removal else if (insertionStep < -1e-5 && m_IsInserting) m_IsInserting = false; - } else + } + else m_IsInserting = false; int i = 0; diff --git a/modules/ustk_needle_modeling/src/usNeedleInsertionModelUpdate/usTissueTranslationEstimatorUKF.cpp b/modules/ustk_needle_modeling/src/usNeedleInsertionModelUpdate/usTissueTranslationEstimatorUKF.cpp index 29386807..8db5ff16 100644 --- a/modules/ustk_needle_modeling/src/usNeedleInsertionModelUpdate/usTissueTranslationEstimatorUKF.cpp +++ b/modules/ustk_needle_modeling/src/usNeedleInsertionModelUpdate/usTissueTranslationEstimatorUKF.cpp @@ -34,6 +34,9 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif usTissueTranslationEstimatorUKF::usTissueTranslationEstimatorUKF() : usUnscentedKalmanFilter(), diff --git a/modules/ustk_needle_modeling/src/usNeedleInsertionModelUpdate/usUnscentedKalmanFilter.cpp b/modules/ustk_needle_modeling/src/usNeedleInsertionModelUpdate/usUnscentedKalmanFilter.cpp index 85cb2fde..3ca1ba43 100644 --- a/modules/ustk_needle_modeling/src/usNeedleInsertionModelUpdate/usUnscentedKalmanFilter.cpp +++ b/modules/ustk_needle_modeling/src/usNeedleInsertionModelUpdate/usUnscentedKalmanFilter.cpp @@ -38,577 +38,551 @@ #include #endif +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif vpMatrix root(const vpMatrix &M) { - if(M.getCols() != M.getRows()) throw vpException(vpException::dimensionError, "NeedleUpdate::root(const vpMatrix&): input matrix should be square"); + if (M.getCols() != M.getRows()) throw vpException(vpException::dimensionError, "NeedleUpdate::root(const vpMatrix&): input matrix should be square"); + + vpMatrix sqrtM(M.getRows(), M.getCols()); - vpMatrix sqrtM(M.getRows(), M.getCols()); - #if defined(VISP_HAVE_EIGEN3) - Eigen::MatrixXd Meigen(M.getRows(),M.getCols()); + Eigen::MatrixXd Meigen(M.getRows(), M.getCols()); - for(unsigned int i =0 ; i::epsilon() * I; - A.svd(w,V); - } - for(unsigned int i=0 ; i 1e-8 * w[0]) sqrtM.insert(sqrt(w[i])*A.getCol(i), 0,i); - } + vpMatrix A(M); + vpColVector w; + vpMatrix V; + try { + A.svd(w, V); + } + catch (std::exception &e) { + vpMatrix I; + I.eye(M.getCols()); + A = M + std::numeric_limits::epsilon() * I; + A.svd(w, V); + } + for (unsigned int i = 0; i 1e-8 * w[0]) sqrtM.insert(sqrt(w[i])*A.getCol(i), 0, i); + } #endif - return sqrtM; -} - -usUnscentedKalmanFilter::usUnscentedKalmanFilter(): - m_stateDimension(0), - m_measureDimension(0), - m_processNoiseDimension(0), - m_measureNoiseDimension(0), - - m_state(), - m_stateCovarianceMatrix(), - - m_processNoiseType(usUnscentedKalmanFilter::NoiseType::ADDITIVE_NOISE), - m_processNoiseCovarianceMatrix(), - m_computeProcessNoiseCovarianceMatrixAutomatically(false), - - m_measureNoiseType(usUnscentedKalmanFilter::NoiseType::ADDITIVE_NOISE), - m_measureNoiseCovarianceMatrix(), - m_computeMeasureNoiseCovarianceMatrixAutomatically(false), - - m_measure(), - - m_sigmaPointsGenerationType(usUnscentedKalmanFilter::STANDARD_COVARIANCE), - m_sigmaPointsInit(), - m_sigmaPointsPropagated(), - m_sigmaPointsMeasure(), - m_sigmaPointsMeanWeights(), - m_sigmaPointsCovarianceWeights(), - m_sigmaPointsScalingFactor(1), - m_sigmaPointsSpreadThreshold(std::numeric_limits::max()), - - m_stateSigmaMean(), - m_measureSigmaMean(), - m_stateSigmaCovarianceMatrix(), - m_stateMeasureSigmaCovarianceMatrix(), - m_measureSigmaCovarianceMatrix() -{ - + return sqrtM; +} + +usUnscentedKalmanFilter::usUnscentedKalmanFilter() : + m_stateDimension(0), + m_measureDimension(0), + m_processNoiseDimension(0), + m_measureNoiseDimension(0), + + m_state(), + m_stateCovarianceMatrix(), + + m_processNoiseType(usUnscentedKalmanFilter::NoiseType::ADDITIVE_NOISE), + m_processNoiseCovarianceMatrix(), + m_computeProcessNoiseCovarianceMatrixAutomatically(false), + + m_measureNoiseType(usUnscentedKalmanFilter::NoiseType::ADDITIVE_NOISE), + m_measureNoiseCovarianceMatrix(), + m_computeMeasureNoiseCovarianceMatrixAutomatically(false), + + m_measure(), + + m_sigmaPointsGenerationType(usUnscentedKalmanFilter::STANDARD_COVARIANCE), + m_sigmaPointsInit(), + m_sigmaPointsPropagated(), + m_sigmaPointsMeasure(), + m_sigmaPointsMeanWeights(), + m_sigmaPointsCovarianceWeights(), + m_sigmaPointsScalingFactor(1), + m_sigmaPointsSpreadThreshold(std::numeric_limits::max()), + + m_stateSigmaMean(), + m_measureSigmaMean(), + m_stateSigmaCovarianceMatrix(), + m_stateMeasureSigmaCovarianceMatrix(), + m_measureSigmaCovarianceMatrix() +{ + } usUnscentedKalmanFilter::~usUnscentedKalmanFilter() { - + } int usUnscentedKalmanFilter::getStateDimension() const { - return m_stateDimension; + return m_stateDimension; } void usUnscentedKalmanFilter::setStateDimension(int dim) { - if(dim <= 0) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setStateDimension: state dimension should be positive"); - - m_stateDimension = dim; - m_state.resize(dim); - m_stateCovarianceMatrix.resize(dim,dim); - m_stateSigmaMean.resize(dim); - m_stateSigmaCovarianceMatrix.resize(dim,dim); - m_stateMeasureSigmaCovarianceMatrix.resize(m_stateDimension, m_measureDimension); + if (dim <= 0) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setStateDimension: state dimension should be positive"); + + m_stateDimension = dim; + m_state.resize(dim); + m_stateCovarianceMatrix.resize(dim, dim); + m_stateSigmaMean.resize(dim); + m_stateSigmaCovarianceMatrix.resize(dim, dim); + m_stateMeasureSigmaCovarianceMatrix.resize(m_stateDimension, m_measureDimension); } int usUnscentedKalmanFilter::getMeasureDimension() const { - return m_measureDimension; + return m_measureDimension; } void usUnscentedKalmanFilter::setMeasureDimension(int dim) { - if(dim <= 0) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setMeasureDimension: measure dimension should be positive"); - - m_measureDimension = dim; - m_measureSigmaMean.resize(dim); - m_measureSigmaCovarianceMatrix.resize(dim,dim); - m_stateMeasureSigmaCovarianceMatrix.resize(m_stateDimension, m_measureDimension); + if (dim <= 0) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setMeasureDimension: measure dimension should be positive"); + + m_measureDimension = dim; + m_measureSigmaMean.resize(dim); + m_measureSigmaCovarianceMatrix.resize(dim, dim); + m_stateMeasureSigmaCovarianceMatrix.resize(m_stateDimension, m_measureDimension); } usUnscentedKalmanFilter::NoiseType usUnscentedKalmanFilter::getProcessNoiseType() const { - return m_processNoiseType; + return m_processNoiseType; } void usUnscentedKalmanFilter::setProcessNoiseType(NoiseType type) { - m_processNoiseType = type; + m_processNoiseType = type; } int usUnscentedKalmanFilter::getProcessNoiseDimension() const { - return m_processNoiseDimension; + return m_processNoiseDimension; } void usUnscentedKalmanFilter::setProcessNoiseDimension(int dim) { - if(dim <= 0) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setProcessNoiseDimension: noise dimension should be positive"); - - m_processNoiseDimension = dim; - m_processNoiseCovarianceMatrix.resize(dim,dim); + if (dim <= 0) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setProcessNoiseDimension: noise dimension should be positive"); + + m_processNoiseDimension = dim; + m_processNoiseCovarianceMatrix.resize(dim, dim); } usUnscentedKalmanFilter::NoiseType usUnscentedKalmanFilter::getMeasureNoiseType() const { - return m_measureNoiseType; + return m_measureNoiseType; } void usUnscentedKalmanFilter::setMeasureNoiseType(NoiseType type) { - m_measureNoiseType = type; + m_measureNoiseType = type; } int usUnscentedKalmanFilter::getMeasureNoiseDimension() const { - return m_measureNoiseDimension; + return m_measureNoiseDimension; } void usUnscentedKalmanFilter::setMeasureNoiseDimension(int dim) { - if(dim <= 0) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setMeasureNoiseDimension: noise dimension should be positive"); - - m_measureNoiseDimension = dim; - m_measureNoiseCovarianceMatrix.resize(dim,dim); + if (dim <= 0) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setMeasureNoiseDimension: noise dimension should be positive"); + + m_measureNoiseDimension = dim; + m_measureNoiseCovarianceMatrix.resize(dim, dim); } usUnscentedKalmanFilter::SigmaPointGenerationType usUnscentedKalmanFilter::getSigmaPointGenerationType() const { - return m_sigmaPointsGenerationType; + return m_sigmaPointsGenerationType; } void usUnscentedKalmanFilter::setSigmaPointGenerationType(usUnscentedKalmanFilter::SigmaPointGenerationType type) { - m_sigmaPointsGenerationType = type; + m_sigmaPointsGenerationType = type; } double usUnscentedKalmanFilter::getSigmaPointScalingFactor() const { - return m_sigmaPointsScalingFactor; + return m_sigmaPointsScalingFactor; } void usUnscentedKalmanFilter::setSigmaPointScalingFactor(double factor) { - m_sigmaPointsScalingFactor = factor; + m_sigmaPointsScalingFactor = factor; } double usUnscentedKalmanFilter::getSigmaPointSpreadThreshold() const { - return m_sigmaPointsSpreadThreshold; + return m_sigmaPointsSpreadThreshold; } void usUnscentedKalmanFilter::setSigmaPointSpreadThreshold(double threshold) { - m_sigmaPointsSpreadThreshold = threshold; + m_sigmaPointsSpreadThreshold = threshold; } vpColVector usUnscentedKalmanFilter::getState() const { - return m_state; + return m_state; } void usUnscentedKalmanFilter::setState(const vpColVector &state) { - if(state.getRows() != m_stateDimension) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setState: invalid state dimension"); - - m_state = state; + if (state.getRows() != m_stateDimension) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setState: invalid state dimension"); + + m_state = state; } vpMatrix usUnscentedKalmanFilter::getStateCovarianceMatrix() const { - return m_stateCovarianceMatrix; + return m_stateCovarianceMatrix; } void usUnscentedKalmanFilter::setStateCovarianceMatrix(const vpMatrix &mat) { - if(mat.getRows() != m_stateDimension || mat.getCols() != m_stateDimension) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setStateCovarianceMatrix: invalid matrix dimension"); - - m_stateCovarianceMatrix = mat; + if (mat.getRows() != m_stateDimension || mat.getCols() != m_stateDimension) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setStateCovarianceMatrix: invalid matrix dimension"); + + m_stateCovarianceMatrix = mat; } vpMatrix usUnscentedKalmanFilter::getProcessNoiseCovarianceMatrix() const { - return m_processNoiseCovarianceMatrix; + return m_processNoiseCovarianceMatrix; } void usUnscentedKalmanFilter::setProcessNoiseCovarianceMatrix(const vpMatrix &cov) { - if(cov.getCols() != m_processNoiseDimension || cov.getRows() != m_processNoiseDimension) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setProcessNoiseCovarianceMatrix: invalid matrix dimension"); - - m_processNoiseCovarianceMatrix = cov; + if (cov.getCols() != m_processNoiseDimension || cov.getRows() != m_processNoiseDimension) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setProcessNoiseCovarianceMatrix: invalid matrix dimension"); + + m_processNoiseCovarianceMatrix = cov; } bool usUnscentedKalmanFilter::computeProcessNoiseCovarianceMatrixAutomatically() const { - return m_computeProcessNoiseCovarianceMatrixAutomatically; + return m_computeProcessNoiseCovarianceMatrixAutomatically; } void usUnscentedKalmanFilter::computeProcessNoiseCovarianceMatrixAutomatically(bool flag) { - m_computeProcessNoiseCovarianceMatrixAutomatically = flag; + m_computeProcessNoiseCovarianceMatrixAutomatically = flag; } vpMatrix usUnscentedKalmanFilter::getMeasureNoiseCovarianceMatrix() const { - return m_measureNoiseCovarianceMatrix; + return m_measureNoiseCovarianceMatrix; } void usUnscentedKalmanFilter::setMeasureNoiseCovarianceMatrix(const vpMatrix &cov) { - if(cov.getCols() != m_measureNoiseDimension || cov.getRows() != m_measureNoiseDimension) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setMeasureNoiseCovarianceMatrix: invalid matrix dimension"); - - m_measureNoiseCovarianceMatrix = cov; + if (cov.getCols() != m_measureNoiseDimension || cov.getRows() != m_measureNoiseDimension) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::setMeasureNoiseCovarianceMatrix: invalid matrix dimension"); + + m_measureNoiseCovarianceMatrix = cov; } bool usUnscentedKalmanFilter::computeMeasureNoiseCovarianceMatrixAutomatically() const { - return m_computeMeasureNoiseCovarianceMatrixAutomatically; + return m_computeMeasureNoiseCovarianceMatrixAutomatically; } void usUnscentedKalmanFilter::computeMeasureNoiseCovarianceMatrixAutomatically(bool flag) { - m_computeMeasureNoiseCovarianceMatrixAutomatically = flag; + m_computeMeasureNoiseCovarianceMatrixAutomatically = flag; } bool usUnscentedKalmanFilter::checkConsistency(const vpColVector &measure) { - if(!m_computeProcessNoiseCovarianceMatrixAutomatically && (m_processNoiseType == usUnscentedKalmanFilter::ADDITIVE_NOISE) && (m_stateDimension != m_processNoiseDimension)) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::checkConsistency: additive process noise is set, but the noise dimension (%d) does not match the state dimension (%d)", m_processNoiseDimension, m_stateDimension); - if(!m_computeMeasureNoiseCovarianceMatrixAutomatically && (m_measureNoiseType == usUnscentedKalmanFilter::ADDITIVE_NOISE) && (m_measureDimension != m_measureNoiseDimension)) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::checkConsistency: additive measure noise is set, but the noise dimension (%d) does not match the measure dimension (%d)", m_measureNoiseDimension, m_measureDimension); - if(measure.size() != m_measureDimension) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::checkConsistency: invamid input measure dimension (%d), should be %d", measure.size(), m_measureDimension); - - return true; + if (!m_computeProcessNoiseCovarianceMatrixAutomatically && (m_processNoiseType == usUnscentedKalmanFilter::ADDITIVE_NOISE) && (m_stateDimension != m_processNoiseDimension)) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::checkConsistency: additive process noise is set, but the noise dimension (%d) does not match the state dimension (%d)", m_processNoiseDimension, m_stateDimension); + if (!m_computeMeasureNoiseCovarianceMatrixAutomatically && (m_measureNoiseType == usUnscentedKalmanFilter::ADDITIVE_NOISE) && (m_measureDimension != m_measureNoiseDimension)) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::checkConsistency: additive measure noise is set, but the noise dimension (%d) does not match the measure dimension (%d)", m_measureNoiseDimension, m_measureDimension); + if (measure.size() != m_measureDimension) throw vpException(vpException::dimensionError, "usUnscentedKalmanFilter::checkConsistency: invamid input measure dimension (%d), should be %d", measure.size(), m_measureDimension); + + return true; } void usUnscentedKalmanFilter::computeProcessNoiseCovarianceMatrix() { - + } void usUnscentedKalmanFilter::computeMeasureNoiseCovarianceMatrix() { - + } bool usUnscentedKalmanFilter::generateSigmaPoints() { - int augmentedStateDimension = 0; - vpMatrix augmentedStateCovarianceMatrix; - - switch(m_processNoiseType) + int augmentedStateDimension = 0; + vpMatrix augmentedStateCovarianceMatrix; + + switch (m_processNoiseType) { + case NoiseType::ADDITIVE_NOISE: + { + switch (m_measureNoiseType) { + case NoiseType::ADDITIVE_NOISE: { - case NoiseType::ADDITIVE_NOISE: - { - switch(m_measureNoiseType) - { - case NoiseType::ADDITIVE_NOISE: - { - augmentedStateDimension = m_stateDimension; - augmentedStateCovarianceMatrix = m_stateCovarianceMatrix; - break; - } - case NoiseType::GENERIC_NOISE: - { - augmentedStateDimension = m_stateDimension + m_measureNoiseDimension; - augmentedStateCovarianceMatrix.resize(augmentedStateDimension,augmentedStateDimension); - augmentedStateCovarianceMatrix.insert(m_stateCovarianceMatrix, 0,0); - augmentedStateCovarianceMatrix.insert(m_measureNoiseCovarianceMatrix, m_stateDimension,m_stateDimension); - break; - } - } - break; - } - case NoiseType::GENERIC_NOISE: - { - switch(m_measureNoiseType) - { - case NoiseType::ADDITIVE_NOISE: - { - augmentedStateDimension = m_stateDimension + m_processNoiseDimension; - augmentedStateCovarianceMatrix.resize(augmentedStateDimension,augmentedStateDimension); - augmentedStateCovarianceMatrix.insert(m_stateCovarianceMatrix, 0,0); - augmentedStateCovarianceMatrix.insert(m_processNoiseCovarianceMatrix, m_stateDimension,m_stateDimension); - break; - } - case NoiseType::GENERIC_NOISE: - { - augmentedStateDimension = m_stateDimension + m_processNoiseDimension + m_measureNoiseDimension; - augmentedStateCovarianceMatrix.resize(augmentedStateDimension,augmentedStateDimension); - augmentedStateCovarianceMatrix.insert(m_stateCovarianceMatrix, 0,0); - augmentedStateCovarianceMatrix.insert(m_processNoiseCovarianceMatrix, m_stateDimension,m_stateDimension); - augmentedStateCovarianceMatrix.insert(m_measureNoiseCovarianceMatrix, m_stateDimension + m_processNoiseDimension,m_stateDimension + m_processNoiseDimension); - break; - } - } - break; - } + augmentedStateDimension = m_stateDimension; + augmentedStateCovarianceMatrix = m_stateCovarianceMatrix; + break; } - - vpMatrix rootP; - - try + case NoiseType::GENERIC_NOISE: { - rootP = root(augmentedStateCovarianceMatrix); + augmentedStateDimension = m_stateDimension + m_measureNoiseDimension; + augmentedStateCovarianceMatrix.resize(augmentedStateDimension, augmentedStateDimension); + augmentedStateCovarianceMatrix.insert(m_stateCovarianceMatrix, 0, 0); + augmentedStateCovarianceMatrix.insert(m_measureNoiseCovarianceMatrix, m_stateDimension, m_stateDimension); + break; + } } - catch (std::exception &e) + break; + } + case NoiseType::GENERIC_NOISE: + { + switch (m_measureNoiseType) { + case NoiseType::ADDITIVE_NOISE: { - std::cout << "usUnscentedKalmanFilter::generateSigmaPoints failed: " << e.what() << std::endl; - return false; + augmentedStateDimension = m_stateDimension + m_processNoiseDimension; + augmentedStateCovarianceMatrix.resize(augmentedStateDimension, augmentedStateDimension); + augmentedStateCovarianceMatrix.insert(m_stateCovarianceMatrix, 0, 0); + augmentedStateCovarianceMatrix.insert(m_processNoiseCovarianceMatrix, m_stateDimension, m_stateDimension); + break; } - - double alpha = 0; - const double beta = 2; - const double k = 0; // 3 - augmentedStateDimension - switch(m_sigmaPointsGenerationType) + case NoiseType::GENERIC_NOISE: { - case SigmaPointGenerationType::STANDARD_COVARIANCE: - { - alpha = 1; - break; - } - case SigmaPointGenerationType::FIXED_SCALING_FACTOR: - { - alpha = m_sigmaPointsScalingFactor; - break; - } - case SigmaPointGenerationType::LIMITED_SPREAD: - { - double max = 0; - for(unsigned int i=0 ; i max) max = val; - } - double thresholdForMax = m_sigmaPointsSpreadThreshold/(m_sigmaPointsScalingFactor*sqrt(augmentedStateDimension+k)); - alpha = m_sigmaPointsScalingFactor * thresholdForMax / (max + thresholdForMax); - break; - } + augmentedStateDimension = m_stateDimension + m_processNoiseDimension + m_measureNoiseDimension; + augmentedStateCovarianceMatrix.resize(augmentedStateDimension, augmentedStateDimension); + augmentedStateCovarianceMatrix.insert(m_stateCovarianceMatrix, 0, 0); + augmentedStateCovarianceMatrix.insert(m_processNoiseCovarianceMatrix, m_stateDimension, m_stateDimension); + augmentedStateCovarianceMatrix.insert(m_measureNoiseCovarianceMatrix, m_stateDimension + m_processNoiseDimension, m_stateDimension + m_processNoiseDimension); + break; + } } + break; + } + } + + vpMatrix rootP; + + try { + rootP = root(augmentedStateCovarianceMatrix); + } + catch (std::exception &e) { + std::cout << "usUnscentedKalmanFilter::generateSigmaPoints failed: " << e.what() << std::endl; + return false; + } + + double alpha = 0; + const double beta = 2; + const double k = 0; // 3 - augmentedStateDimension + switch (m_sigmaPointsGenerationType) { + case SigmaPointGenerationType::STANDARD_COVARIANCE: + { + alpha = 1; + break; + } + case SigmaPointGenerationType::FIXED_SCALING_FACTOR: + { + alpha = m_sigmaPointsScalingFactor; + break; + } + case SigmaPointGenerationType::LIMITED_SPREAD: + { + double max = 0; + for (unsigned int i = 0; i max) max = val; + } + double thresholdForMax = m_sigmaPointsSpreadThreshold/(m_sigmaPointsScalingFactor*sqrt(augmentedStateDimension+k)); + alpha = m_sigmaPointsScalingFactor * thresholdForMax / (max + thresholdForMax); + break; + } + } - double lambda = alpha*alpha*(augmentedStateDimension+k)-augmentedStateDimension; + double lambda = alpha*alpha*(augmentedStateDimension+k)-augmentedStateDimension; - vpMatrix sqrtP = sqrt(fabs(augmentedStateDimension+lambda))*rootP; + vpMatrix sqrtP = sqrt(fabs(augmentedStateDimension+lambda))*rootP; - m_sigmaPointsInit.resize(augmentedStateDimension, 1+2*augmentedStateDimension); + m_sigmaPointsInit.resize(augmentedStateDimension, 1+2*augmentedStateDimension); - vpColVector sigmaCenter(augmentedStateDimension, 0); - sigmaCenter.insert(0, this->stateLog(m_state, m_state)); - - for(int i=0 ; istateLog(m_state, m_state)); - m_sigmaPointsMeanWeights.resize(1+2*augmentedStateDimension); - m_sigmaPointsCovarianceWeights.resize(1+2*augmentedStateDimension); + for (int i = 0; ipropagateSigmaPoint(m_sigmaPointsInit.getCol(i)); - } - catch(std::exception &e) - { - std::cout << "usUnscentedKalmanFilter::computePropagatedSigmaPoints failed: " << e.what() << std::endl; - return false; - } - m_sigmaPointsPropagated.insert(propagatedSigmaPoint, 0,i); + m_sigmaPointsPropagated.resize(m_sigmaPointsInit.getRows(), m_sigmaPointsInit.getCols()); + for (unsigned int i = 0; ipropagateSigmaPoint(m_sigmaPointsInit.getCol(i)); } - return true; + catch (std::exception &e) { + std::cout << "usUnscentedKalmanFilter::computePropagatedSigmaPoints failed: " << e.what() << std::endl; + return false; + } + m_sigmaPointsPropagated.insert(propagatedSigmaPoint, 0, i); + } + return true; } bool usUnscentedKalmanFilter::computeSigmaMeasures() { - m_sigmaPointsMeasure.resize(m_measureDimension, m_sigmaPointsPropagated.getCols()); - vpColVector measureCenter; - try - { - measureCenter = this->computeMeasureFromSigmaPoint(this->stateLog(m_state, m_state)); + m_sigmaPointsMeasure.resize(m_measureDimension, m_sigmaPointsPropagated.getCols()); + vpColVector measureCenter; + try { + measureCenter = this->computeMeasureFromSigmaPoint(this->stateLog(m_state, m_state)); + } + catch (std::exception &e) { + std::cout << "usUnscentedKalmanFilter::computeSigmaMeasures failed: " << e.what() << std::endl; + return false; + } + + for (unsigned int i = 0; icomputeMeasureFromSigmaPoint(m_sigmaPointsPropagated.getCol(i)); } - catch(std::exception &e) - { - std::cout << "usUnscentedKalmanFilter::computeSigmaMeasures failed: " << e.what() << std::endl; - return false; + catch (std::exception &e) { + std::cout << "usUnscentedKalmanFilter::computeSigmaMeasures failed: " << e.what() << std::endl; + return false; } - - for(unsigned int i=0 ; icomputeMeasureFromSigmaPoint(m_sigmaPointsPropagated.getCol(i)); - } - catch(std::exception &e) - { - std::cout << "usUnscentedKalmanFilter::computeSigmaMeasures failed: " << e.what() << std::endl; - return false; - } - m_sigmaPointsMeasure.insert(this->measureLog(sigmaMeasure, measureCenter), 0,i); - } - return true; + m_sigmaPointsMeasure.insert(this->measureLog(sigmaMeasure, measureCenter), 0, i); + } + return true; } void usUnscentedKalmanFilter::computeMeansAndCovarianceMatricesFromSigmaPoints() { - int nbSigmaPoints = m_sigmaPointsPropagated.getCols(); - - m_stateSigmaMean = 0; - for(int i=0 ; imeasureLog(m_measure, this->computeMeasureFromSigmaPoint(this->stateLog(m_state, m_state))) - m_measureSigmaMean; + vpColVector Innov = this->measureLog(m_measure, this->computeMeasureFromSigmaPoint(this->stateLog(m_state, m_state))) - m_measureSigmaMean; - m_state = this->stateExp(m_stateSigmaMean + kalmanGain * Innov, m_state); + m_state = this->stateExp(m_stateSigmaMean + kalmanGain * Innov, m_state); - m_stateCovarianceMatrix = m_stateSigmaCovarianceMatrix - kalmanGain * m_measureSigmaCovarianceMatrix * kalmanGain.t(); - } - catch (std::exception &e) - { - std::cout << "usUnscentedKalmanFilter::updateState failed: " << e.what() << std::endl; - return false; - } - return true; + m_stateCovarianceMatrix = m_stateSigmaCovarianceMatrix - kalmanGain * m_measureSigmaCovarianceMatrix * kalmanGain.t(); + } + catch (std::exception &e) { + std::cout << "usUnscentedKalmanFilter::updateState failed: " << e.what() << std::endl; + return false; + } + return true; } bool usUnscentedKalmanFilter::filter(const vpColVector &measure) { - if(!this->checkConsistency(measure)) return false; + if (!this->checkConsistency(measure)) return false; + + m_measure = measure; - m_measure = measure; - - if(m_computeProcessNoiseCovarianceMatrixAutomatically) this->computeProcessNoiseCovarianceMatrix(); - if(m_computeMeasureNoiseCovarianceMatrixAutomatically) this->computeMeasureNoiseCovarianceMatrix(); - if(!this->generateSigmaPoints()) return false; - if(!this->computePropagatedSigmaPoints()) return false; - if(!this->computeSigmaMeasures()) return false; - this->computeMeansAndCovarianceMatricesFromSigmaPoints(); - - if(!this->updateState()) return false; - - return true; + if (m_computeProcessNoiseCovarianceMatrixAutomatically) this->computeProcessNoiseCovarianceMatrix(); + if (m_computeMeasureNoiseCovarianceMatrixAutomatically) this->computeMeasureNoiseCovarianceMatrix(); + if (!this->generateSigmaPoints()) return false; + if (!this->computePropagatedSigmaPoints()) return false; + if (!this->computeSigmaMeasures()) return false; + this->computeMeansAndCovarianceMatricesFromSigmaPoints(); + + if (!this->updateState()) return false; + + return true; } double usUnscentedKalmanFilter::stateNorm(const vpColVector &state) const { - return state.frobeniusNorm(); + return state.frobeniusNorm(); } -vpColVector usUnscentedKalmanFilter::measureLog(const vpColVector& measure, const vpColVector &measureCenter) const +vpColVector usUnscentedKalmanFilter::measureLog(const vpColVector &measure, const vpColVector &measureCenter) const { - (void)measureCenter; // unused variable - return measure; + (void)measureCenter; // unused variable + return measure; } vpColVector usUnscentedKalmanFilter::stateLog(const vpColVector &state, const vpColVector &stateCenter) const { - (void)stateCenter; // unused variable - return state; + (void)stateCenter; // unused variable + return state; } vpColVector usUnscentedKalmanFilter::stateExp(const vpColVector &state, const vpColVector &stateCenter) const { - (void)stateCenter; // unused variable - return state; + (void)stateCenter; // unused variable + return state; } - diff --git a/modules/ustk_needle_modeling/src/usNeedleModel/usNeedleModelBaseTip.cpp b/modules/ustk_needle_modeling/src/usNeedleModel/usNeedleModelBaseTip.cpp index 78c917ae..cc46476a 100644 --- a/modules/ustk_needle_modeling/src/usNeedleModel/usNeedleModelBaseTip.cpp +++ b/modules/ustk_needle_modeling/src/usNeedleModel/usNeedleModelBaseTip.cpp @@ -35,6 +35,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + usNeedleModelBaseTip::usNeedleModelBaseTip() : m_basePose(), m_worldMbase(), m_tipPose(), m_worldMtip() { } usNeedleModelBaseTip::usNeedleModelBaseTip(const usNeedleModelBaseTip &needle) diff --git a/modules/ustk_needle_modeling/src/usNeedleModel/usNeedleModelPolynomial.cpp b/modules/ustk_needle_modeling/src/usNeedleModel/usNeedleModelPolynomial.cpp index 1e25c6e8..7ef37961 100644 --- a/modules/ustk_needle_modeling/src/usNeedleModel/usNeedleModelPolynomial.cpp +++ b/modules/ustk_needle_modeling/src/usNeedleModel/usNeedleModelPolynomial.cpp @@ -39,10 +39,14 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + usNeedleModelPolynomial::usNeedleModelPolynomial() : usNeedleModelBaseTip(), usPolynomialCurve3D(), - m_outerDiameter(0.001), m_insideDiameter(0), m_needleYoungModulus(200000000000) + m_outerDiameter(0.001), m_insideDiameter(0), m_needleYoungModulus(200000000000) { this->init(); } @@ -50,12 +54,11 @@ usNeedleModelPolynomial::usNeedleModelPolynomial() usNeedleModelPolynomial::usNeedleModelPolynomial(const usNeedleModelPolynomial &needle) : usNeedleModelBaseTip(needle), usPolynomialCurve3D(needle), - m_outerDiameter(needle.m_outerDiameter), m_insideDiameter(needle.m_insideDiameter), - m_needleYoungModulus(needle.m_needleYoungModulus) -{ -} + m_outerDiameter(needle.m_outerDiameter), m_insideDiameter(needle.m_insideDiameter), + m_needleYoungModulus(needle.m_needleYoungModulus) +{ } -usNeedleModelPolynomial::~usNeedleModelPolynomial() {} +usNeedleModelPolynomial::~usNeedleModelPolynomial() { } const usNeedleModelPolynomial &usNeedleModelPolynomial::operator=(const usNeedleModelPolynomial &needle) { @@ -345,7 +348,8 @@ double usNeedleModelPolynomial::getCurvatureFromNeedleShape(double start, double if (direction3D.size() == 3) { direction3D = V.getCol(2); - } else if (direction3D.size() == 4) { + } + else if (direction3D.size() == 4) { direction3D.insert(0, V.getCol(2)); direction3D[3] = 0; } @@ -353,7 +357,8 @@ double usNeedleModelPolynomial::getCurvatureFromNeedleShape(double start, double if (center3D.size() == 3) { V.resize(3, 2, false); center3D = V * center; - } else if (center3D.size() == 4) { + } + else if (center3D.size() == 4) { V.resize(3, 2, false); center3D.insert(0, V * center + mean.t()); center3D[3] = 1; diff --git a/modules/ustk_needle_modeling/src/usNeedleModel/usNeedleModelSpline.cpp b/modules/ustk_needle_modeling/src/usNeedleModel/usNeedleModelSpline.cpp index 35398289..ac8785f3 100644 --- a/modules/ustk_needle_modeling/src/usNeedleModel/usNeedleModelSpline.cpp +++ b/modules/ustk_needle_modeling/src/usNeedleModel/usNeedleModelSpline.cpp @@ -39,10 +39,14 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + usNeedleModelSpline::usNeedleModelSpline() : usNeedleModelBaseTip(), usBSpline3D(), - m_length(0.1), m_outerDiameter(0.001), m_insideDiameter(0), m_needleYoungModulus(200000000000) + m_length(0.1), m_outerDiameter(0.001), m_insideDiameter(0), m_needleYoungModulus(200000000000) { this->init(); } @@ -50,12 +54,11 @@ usNeedleModelSpline::usNeedleModelSpline() usNeedleModelSpline::usNeedleModelSpline(const usNeedleModelSpline &needle) : usNeedleModelBaseTip(needle), usBSpline3D(needle), - m_length(needle.m_length), m_outerDiameter(needle.m_outerDiameter), m_insideDiameter(needle.m_insideDiameter), - m_needleYoungModulus(needle.m_needleYoungModulus) -{ -} + m_length(needle.m_length), m_outerDiameter(needle.m_outerDiameter), m_insideDiameter(needle.m_insideDiameter), + m_needleYoungModulus(needle.m_needleYoungModulus) +{ } -usNeedleModelSpline::~usNeedleModelSpline() {} +usNeedleModelSpline::~usNeedleModelSpline() { } const usNeedleModelSpline &usNeedleModelSpline::operator=(const usNeedleModelSpline &needle) { @@ -273,7 +276,8 @@ double usNeedleModelSpline::getBendingEnergy() const E += pow(curvature, 2); } - } else { + } + else { for (unsigned int n = 0; n < m_spline.size(); n++) { const usPolynomialCurve3D &poly = m_spline.at(n); @@ -446,7 +450,8 @@ double usNeedleModelSpline::getCurvatureFromNeedleShape(double start, double end if (direction3D.size() == 3) { direction3D = V.getCol(2); - } else if (direction3D.size() == 4) { + } + else if (direction3D.size() == 4) { direction3D.insert(0, V.getCol(2)); direction3D[3] = 0; } @@ -454,7 +459,8 @@ double usNeedleModelSpline::getCurvatureFromNeedleShape(double start, double end if (center3D.size() == 3) { V.resize(3, 2, false); center3D = V * center; - } else if (center3D.size() == 4) { + } + else if (center3D.size() == 4) { V.resize(3, 2, false); center3D.insert(0, V * center + mean.t()); center3D[3] = 1; @@ -521,7 +527,7 @@ void usNeedleModelSpline::showNeedleSegmentCoef() const vpMatrix m = m_spline.at(i).getPolynomialCoefficients(); for (int j = 0; j < 3; j++) { std::cout << "\t\t " << std::setw(15) << m[j][0] << " " << std::setw(15) << m[j][1] << " " << std::setw(15) - << m[j][2] << " " << std::setw(15) << m[j][3] << "\n"; + << m[j][2] << " " << std::setw(15) << m[j][3] << "\n"; } } std::cout << std::endl; diff --git a/modules/ustk_needle_modeling/src/usNeedleModelingDisplayTools.cpp b/modules/ustk_needle_modeling/src/usNeedleModelingDisplayTools.cpp index c5bd7cd3..7893d261 100644 --- a/modules/ustk_needle_modeling/src/usNeedleModelingDisplayTools.cpp +++ b/modules/ustk_needle_modeling/src/usNeedleModelingDisplayTools.cpp @@ -40,7 +40,9 @@ namespace usNeedleModelingDisplayTools { - +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif //! Display usNeedleModelBaseTip template diff --git a/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTip.cpp b/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTip.cpp index 4626243c..8a55e260 100644 --- a/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTip.cpp +++ b/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTip.cpp @@ -34,14 +34,17 @@ #include -usNeedleTip::usNeedleTip() : m_basePose(), m_worldMbase(), m_tipPose(), m_worldMtip() {} +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + +usNeedleTip::usNeedleTip() : m_basePose(), m_worldMbase(), m_tipPose(), m_worldMtip() { } usNeedleTip::usNeedleTip(const usNeedleTip &tip) : m_basePose(tip.m_basePose), m_worldMbase(tip.m_worldMbase), m_tipPose(tip.m_tipPose), m_worldMtip(tip.m_worldMtip) -{ -} +{ } -usNeedleTip::~usNeedleTip() {} +usNeedleTip::~usNeedleTip() { } usNeedleTip &usNeedleTip::operator=(const usNeedleTip &tip) { diff --git a/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipActuated.cpp b/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipActuated.cpp index 837bc5eb..09266b43 100644 --- a/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipActuated.cpp +++ b/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipActuated.cpp @@ -35,15 +35,18 @@ #include #include -usNeedleTipActuated::usNeedleTipActuated() : usNeedleTip(), _diameter(0), _length(0), _angle(0), _steeringAngle(0) {} +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + +usNeedleTipActuated::usNeedleTipActuated() : usNeedleTip(), _diameter(0), _length(0), _angle(0), _steeringAngle(0) { } usNeedleTipActuated::usNeedleTipActuated(const usNeedleTipActuated &tip) : usNeedleTip(tip), _diameter(tip._diameter), _length(tip._length), _angle(tip._angle), - _steeringAngle(tip._steeringAngle) -{ -} + _steeringAngle(tip._steeringAngle) +{ } -usNeedleTipActuated::~usNeedleTipActuated() {} +usNeedleTipActuated::~usNeedleTipActuated() { } usNeedleTipActuated &usNeedleTipActuated::operator=(const usNeedleTipActuated &tip) { diff --git a/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipBeveled.cpp b/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipBeveled.cpp index 6e805d02..09c10da0 100644 --- a/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipBeveled.cpp +++ b/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipBeveled.cpp @@ -35,14 +35,17 @@ #include #include -usNeedleTipBeveled::usNeedleTipBeveled() : usNeedleTip(), _diameter(0.001), _length(0.001) {} +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + +usNeedleTipBeveled::usNeedleTipBeveled() : usNeedleTip(), _diameter(0.001), _length(0.001) { } usNeedleTipBeveled::usNeedleTipBeveled(const usNeedleTipBeveled &tip) : usNeedleTip(tip), _diameter(tip._diameter), _length(tip._length) -{ -} +{ } -usNeedleTipBeveled::~usNeedleTipBeveled() {} +usNeedleTipBeveled::~usNeedleTipBeveled() { } usNeedleTipBeveled &usNeedleTipBeveled::operator=(const usNeedleTipBeveled &tip) { diff --git a/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipPrebent.cpp b/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipPrebent.cpp index 514b9c28..530df516 100644 --- a/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipPrebent.cpp +++ b/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipPrebent.cpp @@ -36,14 +36,17 @@ #include #include -usNeedleTipPrebent::usNeedleTipPrebent() : usNeedleTip(), _diameter(0.001), _length(0.01), _angle(0) {} +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + +usNeedleTipPrebent::usNeedleTipPrebent() : usNeedleTip(), _diameter(0.001), _length(0.01), _angle(0) { } usNeedleTipPrebent::usNeedleTipPrebent(const usNeedleTipPrebent &tip) : usNeedleTip(tip), _diameter(tip._diameter), _length(tip._length), _angle(tip._angle) -{ -} +{ } -usNeedleTipPrebent::~usNeedleTipPrebent() {} +usNeedleTipPrebent::~usNeedleTipPrebent() { } usNeedleTipPrebent &usNeedleTipPrebent::operator=(const usNeedleTipPrebent &tip) { diff --git a/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipSymmetric.cpp b/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipSymmetric.cpp index 2d3cfe02..a3d8ddf2 100644 --- a/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipSymmetric.cpp +++ b/modules/ustk_needle_modeling/src/usNeedleTipModel/usNeedleTipSymmetric.cpp @@ -35,14 +35,17 @@ #include #include -usNeedleTipSymmetric::usNeedleTipSymmetric() : usNeedleTip(), _diameter(0.001), _length(0.001) {} +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + +usNeedleTipSymmetric::usNeedleTipSymmetric() : usNeedleTip(), _diameter(0.001), _length(0.001) { } usNeedleTipSymmetric::usNeedleTipSymmetric(const usNeedleTipSymmetric &tip) : usNeedleTip(tip), _diameter(tip._diameter), _length(tip._length) -{ -} +{ } -usNeedleTipSymmetric::~usNeedleTipSymmetric() {} +usNeedleTipSymmetric::~usNeedleTipSymmetric() { } usNeedleTipSymmetric &usNeedleTipSymmetric::operator=(const usNeedleTipSymmetric &tip) { diff --git a/modules/ustk_needle_modeling/src/usTissueModel/usTissueModelPolynomial.cpp b/modules/ustk_needle_modeling/src/usTissueModel/usTissueModelPolynomial.cpp index a8b654c2..8e3c2de2 100644 --- a/modules/ustk_needle_modeling/src/usTissueModel/usTissueModelPolynomial.cpp +++ b/modules/ustk_needle_modeling/src/usTissueModel/usTissueModelPolynomial.cpp @@ -32,14 +32,17 @@ #include -usTissueModelPolynomial::usTissueModelPolynomial() : m_surface(), m_path() {} +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + +usTissueModelPolynomial::usTissueModelPolynomial() : m_surface(), m_path() { } usTissueModelPolynomial::usTissueModelPolynomial(const usTissueModelPolynomial &tissue) : m_surface(tissue.m_surface), m_path(tissue.m_path) -{ -} +{ } -usTissueModelPolynomial::~usTissueModelPolynomial() {} +usTissueModelPolynomial::~usTissueModelPolynomial() { } const usTissueModelPolynomial &usTissueModelPolynomial::operator=(const usTissueModelPolynomial &tissue) { diff --git a/modules/ustk_needle_modeling/src/usTissueModel/usTissueModelSpline.cpp b/modules/ustk_needle_modeling/src/usTissueModel/usTissueModelSpline.cpp index 3649f894..54903ccb 100644 --- a/modules/ustk_needle_modeling/src/usTissueModel/usTissueModelSpline.cpp +++ b/modules/ustk_needle_modeling/src/usTissueModel/usTissueModelSpline.cpp @@ -32,14 +32,17 @@ #include -usTissueModelSpline::usTissueModelSpline() : m_surface(), m_path() {} +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + +usTissueModelSpline::usTissueModelSpline() : m_surface(), m_path() { } usTissueModelSpline::usTissueModelSpline(const usTissueModelSpline &tissue) : m_surface(tissue.m_surface), m_path(tissue.m_path) -{ -} +{ } -usTissueModelSpline::~usTissueModelSpline() {} +usTissueModelSpline::~usTissueModelSpline() { } const usTissueModelSpline &usTissueModelSpline::operator=(const usTissueModelSpline &tissue) { diff --git a/modules/ustk_needle_modeling/src/usTissueModel/usVirtualSpring.cpp b/modules/ustk_needle_modeling/src/usTissueModel/usVirtualSpring.cpp index 30309705..ab3afb80 100644 --- a/modules/ustk_needle_modeling/src/usTissueModel/usVirtualSpring.cpp +++ b/modules/ustk_needle_modeling/src/usTissueModel/usVirtualSpring.cpp @@ -32,35 +32,37 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + usVirtualSpring::usVirtualSpring() : usOrientedPlane3D(), m_stiffness(0), - m_IsActive(true), m_IsRemovable(true), m_AllowPositionUpdate(true), m_AllowDirectionUpdate(true), - m_AllowStiffnessUpdate(true) -{ -} + m_IsActive(true), m_IsRemovable(true), m_AllowPositionUpdate(true), m_AllowDirectionUpdate(true), + m_AllowStiffnessUpdate(true) +{ } usVirtualSpring::usVirtualSpring(const usVirtualSpring &spring) : usOrientedPlane3D(spring), - m_stiffness(spring.m_stiffness), + m_stiffness(spring.m_stiffness), - m_IsActive(spring.m_IsActive), m_IsRemovable(spring.m_IsRemovable), - m_AllowPositionUpdate(spring.m_AllowPositionUpdate), m_AllowDirectionUpdate(spring.m_AllowDirectionUpdate), - m_AllowStiffnessUpdate(spring.m_AllowStiffnessUpdate) -{ -} + m_IsActive(spring.m_IsActive), m_IsRemovable(spring.m_IsRemovable), + m_AllowPositionUpdate(spring.m_AllowPositionUpdate), m_AllowDirectionUpdate(spring.m_AllowDirectionUpdate), + m_AllowStiffnessUpdate(spring.m_AllowStiffnessUpdate) +{ } usVirtualSpring::usVirtualSpring(const vpColVector &p, const vpColVector &d, double K) : usOrientedPlane3D(p, d), m_stiffness(0), - m_IsActive(true), m_IsRemovable(true), m_AllowPositionUpdate(true), m_AllowDirectionUpdate(true), - m_AllowStiffnessUpdate(true) + m_IsActive(true), m_IsRemovable(true), m_AllowPositionUpdate(true), m_AllowDirectionUpdate(true), + m_AllowStiffnessUpdate(true) { this->setStiffness(K); } -usVirtualSpring::~usVirtualSpring() {} +usVirtualSpring::~usVirtualSpring() { } const usVirtualSpring &usVirtualSpring::operator=(const usVirtualSpring &spring) { diff --git a/modules/ustk_needle_modeling/test/testUsNeedleInsertionModelKinematic.cpp b/modules/ustk_needle_modeling/test/testUsNeedleInsertionModelKinematic.cpp index 92b24e61..5cab6443 100644 --- a/modules/ustk_needle_modeling/test/testUsNeedleInsertionModelKinematic.cpp +++ b/modules/ustk_needle_modeling/test/testUsNeedleInsertionModelKinematic.cpp @@ -62,6 +62,10 @@ // List of allowed command line options #define GETOPTARGS "hlt:cd" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType; void usage(const char *name, const char *badparam, vpDisplayType &dtype); @@ -148,207 +152,200 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, vpDisplayType &dtype, bool &list, bool &display) { - const char *optarg_; - int c; - std::string sDisplayType; - while((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) - { - - switch (c) - { - case 'l': - list = true; - break; - - case 't': - sDisplayType = optarg_; - // Parse the display type option - if(sDisplayType.compare("X11") == 0) dtype = vpX11; - else if (sDisplayType.compare("GTK") == 0) dtype = vpGTK; - else if (sDisplayType.compare("GDI") == 0) dtype = vpGDI; - else if (sDisplayType.compare("D3D") == 0) dtype = vpD3D; - else if (sDisplayType.compare("CV") == 0) dtype = vpCV; - break; - - case 'h': - usage(argv[0], NULL, dtype); - return false; - break; - - case 'c': - break; - - case 'd': - display = false; - break; - - default: - usage(argv[0], optarg_, dtype); - return false; - break; - } + const char *optarg_; + int c; + std::string sDisplayType; + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { + + switch (c) { + case 'l': + list = true; + break; + + case 't': + sDisplayType = optarg_; + // Parse the display type option + if (sDisplayType.compare("X11") == 0) dtype = vpX11; + else if (sDisplayType.compare("GTK") == 0) dtype = vpGTK; + else if (sDisplayType.compare("GDI") == 0) dtype = vpGDI; + else if (sDisplayType.compare("D3D") == 0) dtype = vpD3D; + else if (sDisplayType.compare("CV") == 0) dtype = vpCV; + break; + + case 'h': + usage(argv[0], NULL, dtype); + return false; + break; + + case 'c': + break; + + case 'd': + display = false; + break; + + default: + usage(argv[0], optarg_, dtype); + return false; + break; } + } - if((c == 1) || (c == -1)) - { - // standalone param or error - usage(argv[0], NULL, dtype); - std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; - return false; - } + if ((c == 1) || (c == -1)) { + // standalone param or error + usage(argv[0], NULL, dtype); + std::cerr << "ERROR: " << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; + return false; + } - return true; + return true; } int main(int argc, const char **argv) { - bool opt_list = false; // To print the list of video devices - vpDisplayType opt_dtype; // Type of display to use - bool opt_display = true; + bool opt_list = false; // To print the list of video devices + vpDisplayType opt_dtype; // Type of display to use + bool opt_display = true; // Default display is one available #if defined VISP_HAVE_GTK - opt_dtype = vpGTK; + opt_dtype = vpGTK; #elif defined VISP_HAVE_X11 - opt_dtype = vpX11; + opt_dtype = vpX11; #elif defined VISP_HAVE_GDI - opt_dtype = vpGDI; + opt_dtype = vpGDI; #elif defined VISP_HAVE_D3D9 - opt_dtype = vpD3D; + opt_dtype = vpD3D; #elif defined VISP_HAVE_OPENCV - opt_dtype = vpCV; + opt_dtype = vpCV; #endif // Read the command line options - if(!getOptions(argc, argv, opt_dtype, opt_list, opt_display)) exit(-1); + if (!getOptions(argc, argv, opt_dtype, opt_list, opt_display)) exit(-1); - // Print the list of video-devices available - if (opt_list) { - unsigned nbDevices = 0; - std::cout << "List of video-devices available: \n"; + // Print the list of video-devices available + if (opt_list) { + unsigned nbDevices = 0; + std::cout << "List of video-devices available: \n"; #if defined VISP_HAVE_GTK - std::cout << " GTK (use \"-t GTK\" option to use it)\n"; - nbDevices++; + std::cout << " GTK (use \"-t GTK\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_X11 - std::cout << " X11 (use \"-t X11\" option to use it)\n"; - nbDevices++; + std::cout << " X11 (use \"-t X11\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_GDI - std::cout << " GDI (use \"-t GDI\" option to use it)\n"; - nbDevices++; + std::cout << " GDI (use \"-t GDI\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_D3D9 - std::cout << " D3D (use \"-t D3D\" option to use it)\n"; - nbDevices++; + std::cout << " D3D (use \"-t D3D\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_OPENCV - std::cout << " CV (use \"-t CV\" option to use it)\n"; - nbDevices++; + std::cout << " CV (use \"-t CV\" option to use it)\n"; + nbDevices++; #endif - if (!nbDevices) { - std::cout << " No display is available\n"; - } - return (0); + if (!nbDevices) { + std::cout << " No display is available\n"; } - - vpImage I(700, 500, 255); - - vpDisplay *display = nullptr; - - if(opt_display) - { - switch (opt_dtype) - { - case vpX11: - std::cout << "Requested X11 display functionnalities..." << std::endl; + return (0); +} + + vpImage I(700, 500, 255); + + vpDisplay *display = nullptr; + + if (opt_display) { + switch (opt_dtype) { + case vpX11: + std::cout << "Requested X11 display functionnalities..." << std::endl; #if defined VISP_HAVE_X11 - display = new vpDisplayX; + display = new vpDisplayX; #else - std::cout << " Sorry, X11 video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, X11 video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpGTK: - std::cout << "Requested GTK display functionnalities..." << std::endl; + break; + case vpGTK: + std::cout << "Requested GTK display functionnalities..." << std::endl; #if defined VISP_HAVE_GTK - display = new vpDisplayGTK; + display = new vpDisplayGTK; #else - std::cout << " Sorry, GTK video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, GTK video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpGDI: - std::cout << "Requested GDI display functionnalities..." << std::endl; + break; + case vpGDI: + std::cout << "Requested GDI display functionnalities..." << std::endl; #if defined VISP_HAVE_GDI - display = new vpDisplayGDI; + display = new vpDisplayGDI; #else - std::cout << " Sorry, GDI video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, GDI video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpD3D: - std::cout << "Requested D3D display functionnalities..." << std::endl; + break; + case vpD3D: + std::cout << "Requested D3D display functionnalities..." << std::endl; #if defined VISP_HAVE_D3D9 - display = new vpDisplayD3D; + display = new vpDisplayD3D; #else - std::cout << " Sorry, D3D video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, D3D video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpCV: - std::cout << "Requested OpenCV display functionnalities..." << std::endl; + break; + case vpCV: + std::cout << "Requested OpenCV display functionnalities..." << std::endl; #if defined(VISP_HAVE_OPENCV) - display = new vpDisplayOpenCV; + display = new vpDisplayOpenCV; #else - std::cout << " Sorry, OpenCV video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, OpenCV video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - } + break; } + } - if(opt_display) display->init(I); - - usNeedleInsertionModelKinematic n; - n.accessNeedle().setBasePose(vpPoseVector(0,0,0.1, M_PI/sqrt(2),M_PI/sqrt(2),0)); - n.accessNeedle().setTipPose(vpPoseVector(0,0,0, M_PI/sqrt(2),M_PI/sqrt(2),0)); - n.setNaturalCurvature(1/0.05); - - usNeedleInsertionModelKinematic n1; - n1.accessNeedle().setBasePose(vpPoseVector(0.01,0,0.1, M_PI/sqrt(2),M_PI/sqrt(2),0)); - n1.accessNeedle().setTipPose(vpPoseVector(0.01,0,0, M_PI/sqrt(2),M_PI/sqrt(2),0)); - n1.setNaturalCurvature(1/0.2); - - usOrientedPlane3D surface(n.accessNeedle().getTipPose()); - - for(int i=0 ; i<100 ; i++) - { - n.moveBase(0,0,0.001,0,0,0.1); - n1.moveBase(0,0,0.001,0,0,0.1); - - if(opt_display) - { - vpDisplay::display(I); - - usNeedleModelingDisplayTools::display(n, I, vpHomogeneousMatrix(0.08 ,0.1, 0.2, M_PI/2,0,0), 3000,3000); - usNeedleModelingDisplayTools::display(n1, I, vpHomogeneousMatrix(0.08 ,0.1, 0.2, M_PI/2,0,0), 3000,3000); - usGeometryDisplayTools::display(surface, I, vpHomogeneousMatrix(0.08 ,0.1, 0.2, M_PI/2,0,0), 3000,3000); - - vpDisplay::flush(I); - vpTime::wait(50); - } + if (opt_display) display->init(I); + + usNeedleInsertionModelKinematic n; + n.accessNeedle().setBasePose(vpPoseVector(0, 0, 0.1, M_PI/sqrt(2), M_PI/sqrt(2), 0)); + n.accessNeedle().setTipPose(vpPoseVector(0, 0, 0, M_PI/sqrt(2), M_PI/sqrt(2), 0)); + n.setNaturalCurvature(1/0.05); + + usNeedleInsertionModelKinematic n1; + n1.accessNeedle().setBasePose(vpPoseVector(0.01, 0, 0.1, M_PI/sqrt(2), M_PI/sqrt(2), 0)); + n1.accessNeedle().setTipPose(vpPoseVector(0.01, 0, 0, M_PI/sqrt(2), M_PI/sqrt(2), 0)); + n1.setNaturalCurvature(1/0.2); + + usOrientedPlane3D surface(n.accessNeedle().getTipPose()); + + for (int i = 0; i<100; i++) { + n.moveBase(0, 0, 0.001, 0, 0, 0.1); + n1.moveBase(0, 0, 0.001, 0, 0, 0.1); + + if (opt_display) { + vpDisplay::display(I); + + usNeedleModelingDisplayTools::display(n, I, vpHomogeneousMatrix(0.08, 0.1, 0.2, M_PI/2, 0, 0), 3000, 3000); + usNeedleModelingDisplayTools::display(n1, I, vpHomogeneousMatrix(0.08, 0.1, 0.2, M_PI/2, 0, 0), 3000, 3000); + usGeometryDisplayTools::display(surface, I, vpHomogeneousMatrix(0.08, 0.1, 0.2, M_PI/2, 0, 0), 3000, 3000); + + vpDisplay::flush(I); + vpTime::wait(50); } - - if(display) delete display; + } + + if (display) delete display; - return 0; + return 0; } diff --git a/modules/ustk_needle_modeling/test/testUsNeedleInsertionModelRayleighRitzSpline.cpp b/modules/ustk_needle_modeling/test/testUsNeedleInsertionModelRayleighRitzSpline.cpp index aca54f43..64eb474e 100644 --- a/modules/ustk_needle_modeling/test/testUsNeedleInsertionModelRayleighRitzSpline.cpp +++ b/modules/ustk_needle_modeling/test/testUsNeedleInsertionModelRayleighRitzSpline.cpp @@ -62,6 +62,10 @@ // List of allowed command line options #define GETOPTARGS "hlt:cd" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType; void usage(const char *name, const char *badparam, vpDisplayType &dtype); @@ -148,238 +152,229 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, vpDisplayType &dtype, bool &list, bool &display) { - const char *optarg_; - int c; - std::string sDisplayType; - while((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) - { - - switch (c) - { - case 'l': - list = true; - break; - - case 't': - sDisplayType = optarg_; - // Parse the display type option - if(sDisplayType.compare("X11") == 0) dtype = vpX11; - else if (sDisplayType.compare("GTK") == 0) dtype = vpGTK; - else if (sDisplayType.compare("GDI") == 0) dtype = vpGDI; - else if (sDisplayType.compare("D3D") == 0) dtype = vpD3D; - else if (sDisplayType.compare("CV") == 0) dtype = vpCV; - break; - - case 'h': - usage(argv[0], NULL, dtype); - return false; - break; - - case 'c': - break; - - case 'd': - display = false; - break; - - default: - usage(argv[0], optarg_, dtype); - return false; - break; - } + const char *optarg_; + int c; + std::string sDisplayType; + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { + + switch (c) { + case 'l': + list = true; + break; + + case 't': + sDisplayType = optarg_; + // Parse the display type option + if (sDisplayType.compare("X11") == 0) dtype = vpX11; + else if (sDisplayType.compare("GTK") == 0) dtype = vpGTK; + else if (sDisplayType.compare("GDI") == 0) dtype = vpGDI; + else if (sDisplayType.compare("D3D") == 0) dtype = vpD3D; + else if (sDisplayType.compare("CV") == 0) dtype = vpCV; + break; + + case 'h': + usage(argv[0], NULL, dtype); + return false; + break; + + case 'c': + break; + + case 'd': + display = false; + break; + + default: + usage(argv[0], optarg_, dtype); + return false; + break; } + } - if((c == 1) || (c == -1)) - { - // standalone param or error - usage(argv[0], NULL, dtype); - std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; - return false; - } + if ((c == 1) || (c == -1)) { + // standalone param or error + usage(argv[0], NULL, dtype); + std::cerr << "ERROR: " << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; + return false; + } - return true; + return true; } int main(int argc, const char **argv) { - bool opt_list = false; // To print the list of video devices - vpDisplayType opt_dtype; // Type of display to use - bool opt_display = true; + bool opt_list = false; // To print the list of video devices + vpDisplayType opt_dtype; // Type of display to use + bool opt_display = true; // Default display is one available #if defined VISP_HAVE_GTK - opt_dtype = vpGTK; + opt_dtype = vpGTK; #elif defined VISP_HAVE_X11 - opt_dtype = vpX11; + opt_dtype = vpX11; #elif defined VISP_HAVE_GDI - opt_dtype = vpGDI; + opt_dtype = vpGDI; #elif defined VISP_HAVE_D3D9 - opt_dtype = vpD3D; + opt_dtype = vpD3D; #elif defined VISP_HAVE_OPENCV - opt_dtype = vpCV; + opt_dtype = vpCV; #endif // Read the command line options - if(!getOptions(argc, argv, opt_dtype, opt_list, opt_display)) exit(-1); + if (!getOptions(argc, argv, opt_dtype, opt_list, opt_display)) exit(-1); - // Print the list of video-devices available - if (opt_list) { - unsigned nbDevices = 0; - std::cout << "List of video-devices available: \n"; + // Print the list of video-devices available + if (opt_list) { + unsigned nbDevices = 0; + std::cout << "List of video-devices available: \n"; #if defined VISP_HAVE_GTK - std::cout << " GTK (use \"-t GTK\" option to use it)\n"; - nbDevices++; + std::cout << " GTK (use \"-t GTK\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_X11 - std::cout << " X11 (use \"-t X11\" option to use it)\n"; - nbDevices++; + std::cout << " X11 (use \"-t X11\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_GDI - std::cout << " GDI (use \"-t GDI\" option to use it)\n"; - nbDevices++; + std::cout << " GDI (use \"-t GDI\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_D3D9 - std::cout << " D3D (use \"-t D3D\" option to use it)\n"; - nbDevices++; + std::cout << " D3D (use \"-t D3D\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_OPENCV - std::cout << " CV (use \"-t CV\" option to use it)\n"; - nbDevices++; + std::cout << " CV (use \"-t CV\" option to use it)\n"; + nbDevices++; #endif - if (!nbDevices) { - std::cout << " No display is available\n"; - } - return (0); + if (!nbDevices) { + std::cout << " No display is available\n"; } - - vpImage I(700, 500, 255); - - vpDisplay *display = nullptr; - - if(opt_display) - { - switch (opt_dtype) - { - case vpX11: - std::cout << "Requested X11 display functionnalities..." << std::endl; + return (0); +} + + vpImage I(700, 500, 255); + + vpDisplay *display = nullptr; + + if (opt_display) { + switch (opt_dtype) { + case vpX11: + std::cout << "Requested X11 display functionnalities..." << std::endl; #if defined VISP_HAVE_X11 - display = new vpDisplayX; + display = new vpDisplayX; #else - std::cout << " Sorry, X11 video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, X11 video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpGTK: - std::cout << "Requested GTK display functionnalities..." << std::endl; + break; + case vpGTK: + std::cout << "Requested GTK display functionnalities..." << std::endl; #if defined VISP_HAVE_GTK - display = new vpDisplayGTK; + display = new vpDisplayGTK; #else - std::cout << " Sorry, GTK video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, GTK video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpGDI: - std::cout << "Requested GDI display functionnalities..." << std::endl; + break; + case vpGDI: + std::cout << "Requested GDI display functionnalities..." << std::endl; #if defined VISP_HAVE_GDI - display = new vpDisplayGDI; + display = new vpDisplayGDI; #else - std::cout << " Sorry, GDI video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, GDI video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpD3D: - std::cout << "Requested D3D display functionnalities..." << std::endl; + break; + case vpD3D: + std::cout << "Requested D3D display functionnalities..." << std::endl; #if defined VISP_HAVE_D3D9 - display = new vpDisplayD3D; + display = new vpDisplayD3D; #else - std::cout << " Sorry, D3D video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, D3D video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpCV: - std::cout << "Requested OpenCV display functionnalities..." << std::endl; + break; + case vpCV: + std::cout << "Requested OpenCV display functionnalities..." << std::endl; #if defined(VISP_HAVE_OPENCV) - display = new vpDisplayOpenCV; + display = new vpDisplayOpenCV; #else - std::cout << " Sorry, OpenCV video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, OpenCV video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - } + break; } + } + + if (opt_display) display->init(I); + + usNeedleInsertionModelRayleighRitzSpline n; + + n.loadPreset(usNeedleInsertionModelRayleighRitzSpline::ModelPreset::BiopsyNeedle); + n.accessNeedle().setOuterDiameter(0.001); + n.accessNeedle().setInsideDiameter(0.0007); + n.accessNeedle().setNeedleYoungModulus(75e9); + n.accessNeedle().setFullLength(0.1); + + n.accessNeedle().accessSegment(0).setOrder(3); + n.setStiffnessPerUnitLength(0, 10000); + + n.setPathUpdateType(usNeedleInsertionModelRayleighRitzSpline::PathUpdateType::WithTipPosition); + n.setPathUpdateLengthThreshold(0.001); - if(opt_display) display->init(I); - - usNeedleInsertionModelRayleighRitzSpline n; - - n.loadPreset(usNeedleInsertionModelRayleighRitzSpline::ModelPreset::BiopsyNeedle); - n.accessNeedle().setOuterDiameter(0.001); - n.accessNeedle().setInsideDiameter(0.0007); - n.accessNeedle().setNeedleYoungModulus(75e9); - n.accessNeedle().setFullLength(0.1); - - n.accessNeedle().accessSegment(0).setOrder(3); - n.setStiffnessPerUnitLength(0, 10000); - - n.setPathUpdateType(usNeedleInsertionModelRayleighRitzSpline::PathUpdateType::WithTipPosition); - n.setPathUpdateLengthThreshold(0.001); - - n.setBasePose(vpPoseVector(0,0,0.1, M_PI,0,0)); - - n.accessTissue().accessSurface().setPosition(n.accessNeedle().getTipPosition()+0.01*n.accessNeedle().getTipDirection()); - n.accessTissue().accessSurface().setDirection(n.accessNeedle().getTipDirection()); - - n.setNeedleTipType(usNeedleInsertionModelRayleighRitzSpline::NeedleTipType::ActuatedTip); - dynamic_cast(n.accessNeedleTip()).setDiameter(2*n.accessNeedle().getOuterDiameter()); - dynamic_cast(n.accessNeedleTip()).setLength(0.005); - dynamic_cast(n.accessNeedleTip()).setTipAngleDeg(5); - dynamic_cast(n.accessNeedleTip()).setSteeringAngleDeg(90); - - n.setSolvingMethod(usNeedleInsertionModelRayleighRitzSpline::SolvingMethod::FixedBeamLength); - - n.updateState(); - - usNeedleInsertionModelRayleighRitzSpline n1(n); - n1.moveBaseWorldFrame(0.01,0,0,0,0,0); - - for(int i=0 ; i<300 ; i++) - { - if(i > 50 && i < 100) - { - n1.accessNeedle().setFullLength(n1.accessNeedle().getFullLength()+0.0002); - n1.updateState(); - } - - if(i > 50) - { - dynamic_cast(n.accessNeedleTip()).setTipAngleDeg(0.1*(i%40)); - dynamic_cast(n.accessNeedleTip()).setSteeringAngleDeg(i%36); - n.updateState(); - } - - n.moveBase(0,0,0.001,0,0,0.1); - n1.moveBase(0,0,0.001,0,0,0.1); - - if(opt_display) - { - vpDisplay::display(I); - - usNeedleModelingDisplayTools::display(n, I, vpHomogeneousMatrix(0.08 ,0.1, 0.2, M_PI/2,0,0), 3000,3000); - usNeedleModelingDisplayTools::display(n1, I, vpHomogeneousMatrix(0.08 ,0.1, 0.2, M_PI/2,0,0), 3000,3000); - - vpDisplay::flush(I); - } + n.setBasePose(vpPoseVector(0, 0, 0.1, M_PI, 0, 0)); + + n.accessTissue().accessSurface().setPosition(n.accessNeedle().getTipPosition()+0.01*n.accessNeedle().getTipDirection()); + n.accessTissue().accessSurface().setDirection(n.accessNeedle().getTipDirection()); + + n.setNeedleTipType(usNeedleInsertionModelRayleighRitzSpline::NeedleTipType::ActuatedTip); + dynamic_cast(n.accessNeedleTip()).setDiameter(2*n.accessNeedle().getOuterDiameter()); + dynamic_cast(n.accessNeedleTip()).setLength(0.005); + dynamic_cast(n.accessNeedleTip()).setTipAngleDeg(5); + dynamic_cast(n.accessNeedleTip()).setSteeringAngleDeg(90); + + n.setSolvingMethod(usNeedleInsertionModelRayleighRitzSpline::SolvingMethod::FixedBeamLength); + + n.updateState(); + + usNeedleInsertionModelRayleighRitzSpline n1(n); + n1.moveBaseWorldFrame(0.01, 0, 0, 0, 0, 0); + + for (int i = 0; i<300; i++) { + if (i > 50 && i < 100) { + n1.accessNeedle().setFullLength(n1.accessNeedle().getFullLength()+0.0002); + n1.updateState(); + } + + if (i > 50) { + dynamic_cast(n.accessNeedleTip()).setTipAngleDeg(0.1*(i%40)); + dynamic_cast(n.accessNeedleTip()).setSteeringAngleDeg(i%36); + n.updateState(); } - if(display) delete display; + n.moveBase(0, 0, 0.001, 0, 0, 0.1); + n1.moveBase(0, 0, 0.001, 0, 0, 0.1); + + if (opt_display) { + vpDisplay::display(I); + + usNeedleModelingDisplayTools::display(n, I, vpHomogeneousMatrix(0.08, 0.1, 0.2, M_PI/2, 0, 0), 3000, 3000); + usNeedleModelingDisplayTools::display(n1, I, vpHomogeneousMatrix(0.08, 0.1, 0.2, M_PI/2, 0, 0), 3000, 3000); + + vpDisplay::flush(I); + } + } + + if (display) delete display; - return 0; + return 0; } diff --git a/modules/ustk_needle_modeling/test/testUsNeedleInsertionModelVirtualSprings.cpp b/modules/ustk_needle_modeling/test/testUsNeedleInsertionModelVirtualSprings.cpp index 19ca434d..e010875e 100644 --- a/modules/ustk_needle_modeling/test/testUsNeedleInsertionModelVirtualSprings.cpp +++ b/modules/ustk_needle_modeling/test/testUsNeedleInsertionModelVirtualSprings.cpp @@ -62,6 +62,10 @@ // List of allowed command line options #define GETOPTARGS "hlt:cd" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType; void usage(const char *name, const char *badparam, vpDisplayType &dtype); @@ -148,237 +152,227 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, vpDisplayType &dtype, bool &list, bool &display) { - const char *optarg_; - int c; - std::string sDisplayType; - while((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) - { - - switch (c) - { - case 'l': - list = true; - break; - - case 't': - sDisplayType = optarg_; - // Parse the display type option - if(sDisplayType.compare("X11") == 0) dtype = vpX11; - else if (sDisplayType.compare("GTK") == 0) dtype = vpGTK; - else if (sDisplayType.compare("GDI") == 0) dtype = vpGDI; - else if (sDisplayType.compare("D3D") == 0) dtype = vpD3D; - else if (sDisplayType.compare("CV") == 0) dtype = vpCV; - break; - - case 'h': - usage(argv[0], NULL, dtype); - return false; - break; - - case 'c': - break; - - case 'd': - display = false; - break; - - default: - usage(argv[0], optarg_, dtype); - return false; - break; - } + const char *optarg_; + int c; + std::string sDisplayType; + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { + + switch (c) { + case 'l': + list = true; + break; + + case 't': + sDisplayType = optarg_; + // Parse the display type option + if (sDisplayType.compare("X11") == 0) dtype = vpX11; + else if (sDisplayType.compare("GTK") == 0) dtype = vpGTK; + else if (sDisplayType.compare("GDI") == 0) dtype = vpGDI; + else if (sDisplayType.compare("D3D") == 0) dtype = vpD3D; + else if (sDisplayType.compare("CV") == 0) dtype = vpCV; + break; + + case 'h': + usage(argv[0], NULL, dtype); + return false; + break; + + case 'c': + break; + + case 'd': + display = false; + break; + + default: + usage(argv[0], optarg_, dtype); + return false; + break; } + } - if((c == 1) || (c == -1)) - { - // standalone param or error - usage(argv[0], NULL, dtype); - std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; - return false; - } + if ((c == 1) || (c == -1)) { + // standalone param or error + usage(argv[0], NULL, dtype); + std::cerr << "ERROR: " << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; + return false; + } - return true; + return true; } int main(int argc, const char **argv) { - bool opt_list = false; // To print the list of video devices - vpDisplayType opt_dtype; // Type of display to use - bool opt_display = true; + bool opt_list = false; // To print the list of video devices + vpDisplayType opt_dtype; // Type of display to use + bool opt_display = true; // Default display is one available #if defined VISP_HAVE_GTK - opt_dtype = vpGTK; + opt_dtype = vpGTK; #elif defined VISP_HAVE_X11 - opt_dtype = vpX11; + opt_dtype = vpX11; #elif defined VISP_HAVE_GDI - opt_dtype = vpGDI; + opt_dtype = vpGDI; #elif defined VISP_HAVE_D3D9 - opt_dtype = vpD3D; + opt_dtype = vpD3D; #elif defined VISP_HAVE_OPENCV - opt_dtype = vpCV; + opt_dtype = vpCV; #endif // Read the command line options - if(!getOptions(argc, argv, opt_dtype, opt_list, opt_display)) exit(-1); + if (!getOptions(argc, argv, opt_dtype, opt_list, opt_display)) exit(-1); - // Print the list of video-devices available - if (opt_list) { - unsigned nbDevices = 0; - std::cout << "List of video-devices available: \n"; + // Print the list of video-devices available + if (opt_list) { + unsigned nbDevices = 0; + std::cout << "List of video-devices available: \n"; #if defined VISP_HAVE_GTK - std::cout << " GTK (use \"-t GTK\" option to use it)\n"; - nbDevices++; + std::cout << " GTK (use \"-t GTK\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_X11 - std::cout << " X11 (use \"-t X11\" option to use it)\n"; - nbDevices++; + std::cout << " X11 (use \"-t X11\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_GDI - std::cout << " GDI (use \"-t GDI\" option to use it)\n"; - nbDevices++; + std::cout << " GDI (use \"-t GDI\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_D3D9 - std::cout << " D3D (use \"-t D3D\" option to use it)\n"; - nbDevices++; + std::cout << " D3D (use \"-t D3D\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_OPENCV - std::cout << " CV (use \"-t CV\" option to use it)\n"; - nbDevices++; + std::cout << " CV (use \"-t CV\" option to use it)\n"; + nbDevices++; #endif - if (!nbDevices) { - std::cout << " No display is available\n"; - } - return (0); + if (!nbDevices) { + std::cout << " No display is available\n"; } - - vpImage I(700, 500, 255); - - vpDisplay *display = nullptr; - - if(opt_display) - { - switch (opt_dtype) - { - case vpX11: - std::cout << "Requested X11 display functionnalities..." << std::endl; + return (0); + } + + vpImage I(700, 500, 255); + + vpDisplay *display = nullptr; + + if (opt_display) { + switch (opt_dtype) { + case vpX11: + std::cout << "Requested X11 display functionnalities..." << std::endl; #if defined VISP_HAVE_X11 - display = new vpDisplayX; + display = new vpDisplayX; #else - std::cout << " Sorry, X11 video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, X11 video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpGTK: - std::cout << "Requested GTK display functionnalities..." << std::endl; + break; + case vpGTK: + std::cout << "Requested GTK display functionnalities..." << std::endl; #if defined VISP_HAVE_GTK - display = new vpDisplayGTK; + display = new vpDisplayGTK; #else - std::cout << " Sorry, GTK video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, GTK video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpGDI: - std::cout << "Requested GDI display functionnalities..." << std::endl; + break; + case vpGDI: + std::cout << "Requested GDI display functionnalities..." << std::endl; #if defined VISP_HAVE_GDI - display = new vpDisplayGDI; + display = new vpDisplayGDI; #else - std::cout << " Sorry, GDI video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, GDI video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpD3D: - std::cout << "Requested D3D display functionnalities..." << std::endl; + break; + case vpD3D: + std::cout << "Requested D3D display functionnalities..." << std::endl; #if defined VISP_HAVE_D3D9 - display = new vpDisplayD3D; + display = new vpDisplayD3D; #else - std::cout << " Sorry, D3D video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, D3D video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpCV: - std::cout << "Requested OpenCV display functionnalities..." << std::endl; + break; + case vpCV: + std::cout << "Requested OpenCV display functionnalities..." << std::endl; #if defined(VISP_HAVE_OPENCV) - display = new vpDisplayOpenCV; + display = new vpDisplayOpenCV; #else - std::cout << " Sorry, OpenCV video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, OpenCV video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - } + break; } + } + + if (opt_display) display->init(I); + + usNeedleInsertionModelVirtualSprings n; + + n.loadPreset(usNeedleInsertionModelVirtualSprings::ModelPreset::BiopsyNeedle); + n.accessNeedle().setOuterDiameter(0.001); + n.accessNeedle().setInsideDiameter(0.0007); + n.accessNeedle().setNeedleYoungModulus(75e9); + n.accessNeedle().setFullLength(0.1); + + n.accessNeedle().accessSegment(0).setOrder(3); + n.setStiffnessPerUnitLength(10000); - if(opt_display) display->init(I); - - usNeedleInsertionModelVirtualSprings n; - - n.loadPreset(usNeedleInsertionModelVirtualSprings::ModelPreset::BiopsyNeedle); - n.accessNeedle().setOuterDiameter(0.001); - n.accessNeedle().setInsideDiameter(0.0007); - n.accessNeedle().setNeedleYoungModulus(75e9); - n.accessNeedle().setFullLength(0.1); - - n.accessNeedle().accessSegment(0).setOrder(3); - n.setStiffnessPerUnitLength(10000); - - n.setInterSpringDistance(0.005); - n.setInterTipSpringDistance(0.001); - n.setNbMinTipSprings(5); - n.setNbMaxTipSprings(10); - n.setAutomaticSpringAddition(true); - - n.setBasePose(vpPoseVector(0,0,0.1, M_PI/sqrt(2),M_PI/sqrt(2),0)); - - usNeedleInsertionModelVirtualSprings n1(n); - n1.moveBaseWorldFrame(0.01,0,0,0,0,0); - - n1.setInterSpringDistance(0.01); - n1.setInterTipSpringDistance(0.002); - n1.setNbMinTipSprings(4); - n1.setNbMaxTipSprings(5); - - n.setSurfaceAtTip(); - n1.setSurfaceAtTip(); - - for(int i=0 ; i<300 ; i++) - { - if(i < 100) - { - n.moveBase(0,0,0.001,0,0,0); - n1.moveBase(0,0,0.001,0,0,0); - } - else if(i < 200) - { - n.moveBase(0,0,-0.001,0,0,0); - n1.moveBase(0,0,-0.001,0,0,0); - } - else - { - n.moveBase(0,0,0.001,0,0,0.05); - n1.moveBase(0,0,0.001,0,0,0.05); - } - - if(opt_display) - { - vpDisplay::display(I); - - usNeedleModelingDisplayTools::display(n, I, vpHomogeneousMatrix(0.08 ,0.1, 0.2, M_PI/2,0,0), 3000,3000); - usNeedleModelingDisplayTools::display(n1, I, vpHomogeneousMatrix(0.08 ,0.1, 0.2, M_PI/2,0,0), 3000,3000); - - vpDisplay::flush(I); - } + n.setInterSpringDistance(0.005); + n.setInterTipSpringDistance(0.001); + n.setNbMinTipSprings(5); + n.setNbMaxTipSprings(10); + n.setAutomaticSpringAddition(true); + + n.setBasePose(vpPoseVector(0, 0, 0.1, M_PI/sqrt(2), M_PI/sqrt(2), 0)); + + usNeedleInsertionModelVirtualSprings n1(n); + n1.moveBaseWorldFrame(0.01, 0, 0, 0, 0, 0); + + n1.setInterSpringDistance(0.01); + n1.setInterTipSpringDistance(0.002); + n1.setNbMinTipSprings(4); + n1.setNbMaxTipSprings(5); + + n.setSurfaceAtTip(); + n1.setSurfaceAtTip(); + + for (int i = 0; i<300; i++) { + if (i < 100) { + n.moveBase(0, 0, 0.001, 0, 0, 0); + n1.moveBase(0, 0, 0.001, 0, 0, 0); + } + else if (i < 200) { + n.moveBase(0, 0, -0.001, 0, 0, 0); + n1.moveBase(0, 0, -0.001, 0, 0, 0); + } + else { + n.moveBase(0, 0, 0.001, 0, 0, 0.05); + n1.moveBase(0, 0, 0.001, 0, 0, 0.05); } - - if(display) delete display; - return 0; + if (opt_display) { + vpDisplay::display(I); + + usNeedleModelingDisplayTools::display(n, I, vpHomogeneousMatrix(0.08, 0.1, 0.2, M_PI/2, 0, 0), 3000, 3000); + usNeedleModelingDisplayTools::display(n1, I, vpHomogeneousMatrix(0.08, 0.1, 0.2, M_PI/2, 0, 0), 3000, 3000); + + vpDisplay::flush(I); + } + } + + if (display) delete display; + + return 0; } diff --git a/modules/ustk_needle_modeling/test/testUsNeedleJacobians.cpp b/modules/ustk_needle_modeling/test/testUsNeedleJacobians.cpp index d62996fd..11ae6051 100644 --- a/modules/ustk_needle_modeling/test/testUsNeedleJacobians.cpp +++ b/modules/ustk_needle_modeling/test/testUsNeedleJacobians.cpp @@ -56,161 +56,163 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main() { - std::cout << "Start test testUsNeedleJacobians" << std::endl; - - //! Generate some inserted needle models - - usNeedleInsertionModelRayleighRitzSpline needleRR; - needleRR.loadPreset(usNeedleInsertionModelRayleighRitzSpline::ModelPreset::BiopsyNeedle); - needleRR.setPathUpdateType(usNeedleInsertionModelRayleighRitzSpline::PathUpdateType::WithTipPosition); - needleRR.setBasePose(vpPoseVector(0,0,0,0,0,0)); - needleRR.setSurfaceAtTip(); - usNeedleInsertionModelVirtualSprings needleVS; - needleVS.loadPreset(usNeedleInsertionModelVirtualSprings::ModelPreset::BiopsyNeedle); - needleVS.setBasePose(vpPoseVector(0,0,0,0,0,0)); - needleVS.setSurfaceAtTip(); - - for(int i=0 ; i<20 ; i++) - { - needleRR.moveBase(0.0005,0,0.001,0.0001,0,0); - needleVS.moveBase(0.0005,0,0.001,0.0001,0,0); - } - - vpMatrix JRR; - vpMatrix JVS; - - //! Base to tip (manipulation Jacobian) (6x6) - - if(!usNeedleJacobians::getJacobianWorldBaseVelocityToWorldTipVelocity(needleRR, JRR)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToWorldTipVelocity" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToWorldTipVelocity(needleRR, JRR)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToWorldTipVelocity" << std::endl; - if(!usNeedleJacobians::getJacobianWorldBaseVelocityToTipVelocity(needleRR, JRR)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToTipVelocity" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToTipVelocity(needleRR, JRR)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTipVelocity" << std::endl; - - if(!usNeedleJacobians::getJacobianWorldBaseVelocityToWorldTipVelocity(needleVS, JVS)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToWorldTipVelocity" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToWorldTipVelocity(needleVS, JVS)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToWorldTipVelocity" << std::endl; - if(!usNeedleJacobians::getJacobianWorldBaseVelocityToTipVelocity(needleVS, JVS)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToTipVelocity" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToTipVelocity(needleVS, JVS)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTipVelocity" << std::endl; - - //! Base to bending energy (1x6) - - if(!usNeedleJacobians::getJacobianBaseVelocityToBendingEnergy(needleRR, JRR)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToBendingEnergy" << std::endl; - if(!usNeedleJacobians::getJacobianWorldBaseVelocityToBendingEnergy(needleRR, JRR)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToBendingEnergy" << std::endl; - - if(!usNeedleJacobians::getJacobianBaseVelocityToBendingEnergy(needleVS, JVS)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToBendingEnergy" << std::endl; - if(!usNeedleJacobians::getJacobianWorldBaseVelocityToBendingEnergy(needleVS, JVS)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToBendingEnergy" << std::endl; - - //! Base to tissue deformation energy (1x6) - - if(!usNeedleJacobians::getJacobianBaseVelocityToTissueEnergy(needleRR, JRR)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTissueEnergy" << std::endl; - if(!usNeedleJacobians::getJacobianWorldBaseVelocityToTissueEnergy(needleRR, JRR)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToTissueEnergy" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToNeedleInsertionPointVelocity(needleRR, JRR)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToNeedleInsertionPointVelocity" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToSurfaceTissueStretch(needleRR, JRR)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToSurfaceTissueStretch" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToMaxTissueStretch(needleRR, JRR)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToMaxTissueStretch" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToMeanTissueStretch(needleRR, JRR)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToMeanTissueStretch" << std::endl; - - if(!usNeedleJacobians::getJacobianBaseVelocityToTissueEnergy(needleVS, JVS)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTissueEnergy" << std::endl; - if(!usNeedleJacobians::getJacobianWorldBaseVelocityToTissueEnergy(needleVS, JVS)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToTissueEnergy" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToNeedleInsertionPointVelocity(needleVS, JVS)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToNeedleInsertionPointVelocity" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToSurfaceTissueStretch(needleVS, JVS)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToSurfaceTissueStretch" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToMaxTissueStretch(needleVS, JVS)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToMaxTissueStretch" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToMeanTissueStretch(needleVS, JVS)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToMeanTissueStretch" << std::endl; - - //! Base to needle point (3x6) - - if(!usNeedleJacobians::getJacobianBaseVelocityToPointVelocity(needleRR, JRR, 0.5*needleRR.accessNeedle().getFullLength())) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToPointVelocity" << std::endl; - if(!usNeedleJacobians::getJacobianWorldBaseVelocityToPointVelocity(needleRR, JRR, 0.5*needleRR.accessNeedle().getFullLength())) return 1; - std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToPointVelocity" << std::endl; - - if(!usNeedleJacobians::getJacobianBaseVelocityToPointVelocity(needleVS, JVS, 0.5*needleRR.accessNeedle().getFullLength())) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToPointVelocity" << std::endl; - if(!usNeedleJacobians::getJacobianWorldBaseVelocityToPointVelocity(needleVS, JVS, 0.5*needleRR.accessNeedle().getFullLength())) return 1; - std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToPointVelocity" << std::endl; - - //! Base to features (1x6) - - vpColVector target(needleRR.accessNeedle().getTipPosition()); - target[0] += 0.01; - target[2] += 0.02; - if(!usNeedleJacobians::getJacobianBaseVelocityToTransversalTargetDistance(needleRR, JRR, target)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTransversalTargetDistance" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToTargetAngle(needleRR, JRR, target)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTargetAngle" << std::endl; - - if(!usNeedleJacobians::getJacobianBaseVelocityToTransversalTargetDistance(needleVS, JVS, target)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTransversalTargetDistance" << std::endl; - if(!usNeedleJacobians::getJacobianBaseVelocityToTargetAngle(needleVS, JVS, target)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTargetAngle" << std::endl; - - //! Springs to needle point (3x6) - - if(!usNeedleJacobians::getJacobianSpringVelocityToPointVelocity(needleVS, JVS, needleVS.getNbSprings()/2, 0.5 * needleVS.accessNeedle().getFullLength())) return 1; - std::cout << "done: usNeedleJacobians::getJacobianSpringVelocityToPointVelocity" << std::endl; - - //! Springs to distance from points (nbPointsx6) - - vpColVector point(needleVS.accessNeedle().getPoint(0.5*needleVS.accessNeedle().getFullLength())); - point[0] += 0.005; - std::vector points; - for(int i=0 ; i<10 ; i++) - { - point[2] += 0.002; - points.push_back(point); - } - if(!usNeedleJacobians::getJacobianSpringVelocityToPointsDistance(needleVS, JVS, needleVS.getNbSprings()/2, points)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianSpringVelocityToPointsDistance" << std::endl; - - //! Rest path points to model point (3*nbPointsx3) - - std::vector l; - for(int i=0 ; i<10 ; i++) l.push_back(i * needleRR.accessNeedle().getFullLength() / 10.); - if(!usNeedleJacobians::getJacobianRestPathPointVelocityToPointsVelocity(needleRR, JRR, needleRR.accessTissue().accessPath().getNbSegments() / 2, l)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianRestPathPointVelocityToPointsVelocity" << std::endl; - - //! Rest path points distance from points (nbPointsx3) - - if(!usNeedleJacobians::getJacobianRestPathPointVelocityToPointsDistance(needleRR, JRR, needleRR.accessTissue().accessPath().getNbSegments() / 2, points)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianRestPathPointVelocityToPointsDistance" << std::endl; - - //! Stiffness per unit length to distance from points (nbPointsx1) - - if(!usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsDistance(needleRR, JRR, points)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsDistance" << std::endl; - if(!usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsDistance(needleVS, JVS, points)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsDistance" << std::endl; - - //! Stiffness per unit length to needle point ( (3*nbPoints)x1 matrix) - - if(!usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsVelocity(needleRR, JRR, l)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsVelocity" << std::endl; - if(!usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsVelocity(needleVS, JVS, l)) return 1; - std::cout << "done: usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsVelocity" << std::endl; - - return 0; + std::cout << "Start test testUsNeedleJacobians" << std::endl; + + //! Generate some inserted needle models + + usNeedleInsertionModelRayleighRitzSpline needleRR; + needleRR.loadPreset(usNeedleInsertionModelRayleighRitzSpline::ModelPreset::BiopsyNeedle); + needleRR.setPathUpdateType(usNeedleInsertionModelRayleighRitzSpline::PathUpdateType::WithTipPosition); + needleRR.setBasePose(vpPoseVector(0, 0, 0, 0, 0, 0)); + needleRR.setSurfaceAtTip(); + usNeedleInsertionModelVirtualSprings needleVS; + needleVS.loadPreset(usNeedleInsertionModelVirtualSprings::ModelPreset::BiopsyNeedle); + needleVS.setBasePose(vpPoseVector(0, 0, 0, 0, 0, 0)); + needleVS.setSurfaceAtTip(); + + for (int i = 0; i<20; i++) { + needleRR.moveBase(0.0005, 0, 0.001, 0.0001, 0, 0); + needleVS.moveBase(0.0005, 0, 0.001, 0.0001, 0, 0); + } + + vpMatrix JRR; + vpMatrix JVS; + + //! Base to tip (manipulation Jacobian) (6x6) + + if (!usNeedleJacobians::getJacobianWorldBaseVelocityToWorldTipVelocity(needleRR, JRR)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToWorldTipVelocity" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToWorldTipVelocity(needleRR, JRR)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToWorldTipVelocity" << std::endl; + if (!usNeedleJacobians::getJacobianWorldBaseVelocityToTipVelocity(needleRR, JRR)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToTipVelocity" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToTipVelocity(needleRR, JRR)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTipVelocity" << std::endl; + + if (!usNeedleJacobians::getJacobianWorldBaseVelocityToWorldTipVelocity(needleVS, JVS)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToWorldTipVelocity" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToWorldTipVelocity(needleVS, JVS)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToWorldTipVelocity" << std::endl; + if (!usNeedleJacobians::getJacobianWorldBaseVelocityToTipVelocity(needleVS, JVS)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToTipVelocity" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToTipVelocity(needleVS, JVS)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTipVelocity" << std::endl; + + //! Base to bending energy (1x6) + + if (!usNeedleJacobians::getJacobianBaseVelocityToBendingEnergy(needleRR, JRR)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToBendingEnergy" << std::endl; + if (!usNeedleJacobians::getJacobianWorldBaseVelocityToBendingEnergy(needleRR, JRR)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToBendingEnergy" << std::endl; + + if (!usNeedleJacobians::getJacobianBaseVelocityToBendingEnergy(needleVS, JVS)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToBendingEnergy" << std::endl; + if (!usNeedleJacobians::getJacobianWorldBaseVelocityToBendingEnergy(needleVS, JVS)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToBendingEnergy" << std::endl; + + //! Base to tissue deformation energy (1x6) + + if (!usNeedleJacobians::getJacobianBaseVelocityToTissueEnergy(needleRR, JRR)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTissueEnergy" << std::endl; + if (!usNeedleJacobians::getJacobianWorldBaseVelocityToTissueEnergy(needleRR, JRR)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToTissueEnergy" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToNeedleInsertionPointVelocity(needleRR, JRR)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToNeedleInsertionPointVelocity" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToSurfaceTissueStretch(needleRR, JRR)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToSurfaceTissueStretch" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToMaxTissueStretch(needleRR, JRR)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToMaxTissueStretch" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToMeanTissueStretch(needleRR, JRR)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToMeanTissueStretch" << std::endl; + + if (!usNeedleJacobians::getJacobianBaseVelocityToTissueEnergy(needleVS, JVS)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTissueEnergy" << std::endl; + if (!usNeedleJacobians::getJacobianWorldBaseVelocityToTissueEnergy(needleVS, JVS)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToTissueEnergy" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToNeedleInsertionPointVelocity(needleVS, JVS)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToNeedleInsertionPointVelocity" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToSurfaceTissueStretch(needleVS, JVS)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToSurfaceTissueStretch" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToMaxTissueStretch(needleVS, JVS)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToMaxTissueStretch" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToMeanTissueStretch(needleVS, JVS)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToMeanTissueStretch" << std::endl; + + //! Base to needle point (3x6) + + if (!usNeedleJacobians::getJacobianBaseVelocityToPointVelocity(needleRR, JRR, 0.5*needleRR.accessNeedle().getFullLength())) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToPointVelocity" << std::endl; + if (!usNeedleJacobians::getJacobianWorldBaseVelocityToPointVelocity(needleRR, JRR, 0.5*needleRR.accessNeedle().getFullLength())) return 1; + std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToPointVelocity" << std::endl; + + if (!usNeedleJacobians::getJacobianBaseVelocityToPointVelocity(needleVS, JVS, 0.5*needleRR.accessNeedle().getFullLength())) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToPointVelocity" << std::endl; + if (!usNeedleJacobians::getJacobianWorldBaseVelocityToPointVelocity(needleVS, JVS, 0.5*needleRR.accessNeedle().getFullLength())) return 1; + std::cout << "done: usNeedleJacobians::getJacobianWorldBaseVelocityToPointVelocity" << std::endl; + + //! Base to features (1x6) + + vpColVector target(needleRR.accessNeedle().getTipPosition()); + target[0] += 0.01; + target[2] += 0.02; + if (!usNeedleJacobians::getJacobianBaseVelocityToTransversalTargetDistance(needleRR, JRR, target)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTransversalTargetDistance" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToTargetAngle(needleRR, JRR, target)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTargetAngle" << std::endl; + + if (!usNeedleJacobians::getJacobianBaseVelocityToTransversalTargetDistance(needleVS, JVS, target)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTransversalTargetDistance" << std::endl; + if (!usNeedleJacobians::getJacobianBaseVelocityToTargetAngle(needleVS, JVS, target)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianBaseVelocityToTargetAngle" << std::endl; + + //! Springs to needle point (3x6) + + if (!usNeedleJacobians::getJacobianSpringVelocityToPointVelocity(needleVS, JVS, needleVS.getNbSprings()/2, 0.5 * needleVS.accessNeedle().getFullLength())) return 1; + std::cout << "done: usNeedleJacobians::getJacobianSpringVelocityToPointVelocity" << std::endl; + + //! Springs to distance from points (nbPointsx6) + + vpColVector point(needleVS.accessNeedle().getPoint(0.5*needleVS.accessNeedle().getFullLength())); + point[0] += 0.005; + std::vector points; + for (int i = 0; i<10; i++) { + point[2] += 0.002; + points.push_back(point); + } + if (!usNeedleJacobians::getJacobianSpringVelocityToPointsDistance(needleVS, JVS, needleVS.getNbSprings()/2, points)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianSpringVelocityToPointsDistance" << std::endl; + + //! Rest path points to model point (3*nbPointsx3) + + std::vector l; + for (int i = 0; i<10; i++) l.push_back(i * needleRR.accessNeedle().getFullLength() / 10.); + if (!usNeedleJacobians::getJacobianRestPathPointVelocityToPointsVelocity(needleRR, JRR, needleRR.accessTissue().accessPath().getNbSegments() / 2, l)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianRestPathPointVelocityToPointsVelocity" << std::endl; + + //! Rest path points distance from points (nbPointsx3) + + if (!usNeedleJacobians::getJacobianRestPathPointVelocityToPointsDistance(needleRR, JRR, needleRR.accessTissue().accessPath().getNbSegments() / 2, points)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianRestPathPointVelocityToPointsDistance" << std::endl; + + //! Stiffness per unit length to distance from points (nbPointsx1) + + if (!usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsDistance(needleRR, JRR, points)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsDistance" << std::endl; + if (!usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsDistance(needleVS, JVS, points)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsDistance" << std::endl; + + //! Stiffness per unit length to needle point ( (3*nbPoints)x1 matrix) + + if (!usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsVelocity(needleRR, JRR, l)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsVelocity" << std::endl; + if (!usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsVelocity(needleVS, JVS, l)) return 1; + std::cout << "done: usNeedleJacobians::getJacobianStiffnessPerUnitLengthToPointsVelocity" << std::endl; + + return 0; } diff --git a/modules/ustk_needle_modeling/test/testUsTissueTranslationEstimatorUKF.cpp b/modules/ustk_needle_modeling/test/testUsTissueTranslationEstimatorUKF.cpp index 3634211e..0dba3074 100644 --- a/modules/ustk_needle_modeling/test/testUsTissueTranslationEstimatorUKF.cpp +++ b/modules/ustk_needle_modeling/test/testUsTissueTranslationEstimatorUKF.cpp @@ -69,6 +69,10 @@ // List of allowed command line options #define GETOPTARGS "hlt:cd" +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + typedef enum { vpX11, vpGTK, vpGDI, vpD3D, vpCV } vpDisplayType; void usage(const char *name, const char *badparam, vpDisplayType &dtype); @@ -155,423 +159,395 @@ OPTIONS: Default\n\ */ bool getOptions(int argc, const char **argv, vpDisplayType &dtype, bool &list, bool &display) { - const char *optarg_; - int c; - std::string sDisplayType; - while((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) - { - - switch (c) - { - case 'l': - list = true; - break; - case 't': - sDisplayType = optarg_; - // Parse the display type option - if(sDisplayType.compare("X11") == 0) dtype = vpX11; - else if (sDisplayType.compare("GTK") == 0) dtype = vpGTK; - else if (sDisplayType.compare("GDI") == 0) dtype = vpGDI; - else if (sDisplayType.compare("D3D") == 0) dtype = vpD3D; - else if (sDisplayType.compare("CV") == 0) dtype = vpCV; - - break; - case 'h': - usage(argv[0], NULL, dtype); - return false; - break; - case 'c': - break; - case 'd': - display = false; - break; - - - default: - usage(argv[0], optarg_, dtype); - return false; - break; - } + const char *optarg_; + int c; + std::string sDisplayType; + while ((c = vpParseArgv::parse(argc, argv, GETOPTARGS, &optarg_)) > 1) { + + switch (c) { + case 'l': + list = true; + break; + case 't': + sDisplayType = optarg_; + // Parse the display type option + if (sDisplayType.compare("X11") == 0) dtype = vpX11; + else if (sDisplayType.compare("GTK") == 0) dtype = vpGTK; + else if (sDisplayType.compare("GDI") == 0) dtype = vpGDI; + else if (sDisplayType.compare("D3D") == 0) dtype = vpD3D; + else if (sDisplayType.compare("CV") == 0) dtype = vpCV; + + break; + case 'h': + usage(argv[0], NULL, dtype); + return false; + break; + case 'c': + break; + case 'd': + display = false; + break; + + + default: + usage(argv[0], optarg_, dtype); + return false; + break; } + } - if((c == 1) || (c == -1)) - { - // standalone param or error - usage(argv[0], NULL, dtype); - std::cerr << "ERROR: " << std::endl; - std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; - return false; - } + if ((c == 1) || (c == -1)) { + // standalone param or error + usage(argv[0], NULL, dtype); + std::cerr << "ERROR: " << std::endl; + std::cerr << " Bad argument " << optarg_ << std::endl << std::endl; + return false; + } - return true; + return true; } int main(int argc, const char **argv) { - bool opt_list = false; // To print the list of video devices - vpDisplayType opt_dtype; // Type of display to use - bool opt_display = true; + bool opt_list = false; // To print the list of video devices + vpDisplayType opt_dtype; // Type of display to use + bool opt_display = true; // Default display is one available #if defined VISP_HAVE_GTK - opt_dtype = vpGTK; + opt_dtype = vpGTK; #elif defined VISP_HAVE_X11 - opt_dtype = vpX11; + opt_dtype = vpX11; #elif defined VISP_HAVE_GDI - opt_dtype = vpGDI; + opt_dtype = vpGDI; #elif defined VISP_HAVE_D3D9 - opt_dtype = vpD3D; + opt_dtype = vpD3D; #elif defined VISP_HAVE_OPENCV - opt_dtype = vpCV; + opt_dtype = vpCV; #endif // Read the command line options - if(!getOptions(argc, argv, opt_dtype, opt_list, opt_display)) exit(-1); + if (!getOptions(argc, argv, opt_dtype, opt_list, opt_display)) exit(-1); - // Print the list of video-devices available - if (opt_list) { - unsigned nbDevices = 0; - std::cout << "List of video-devices available: \n"; + // Print the list of video-devices available + if (opt_list) { + unsigned nbDevices = 0; + std::cout << "List of video-devices available: \n"; #if defined VISP_HAVE_GTK - std::cout << " GTK (use \"-t GTK\" option to use it)\n"; - nbDevices++; + std::cout << " GTK (use \"-t GTK\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_X11 - std::cout << " X11 (use \"-t X11\" option to use it)\n"; - nbDevices++; + std::cout << " X11 (use \"-t X11\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_GDI - std::cout << " GDI (use \"-t GDI\" option to use it)\n"; - nbDevices++; + std::cout << " GDI (use \"-t GDI\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_D3D9 - std::cout << " D3D (use \"-t D3D\" option to use it)\n"; - nbDevices++; + std::cout << " D3D (use \"-t D3D\" option to use it)\n"; + nbDevices++; #endif #if defined VISP_HAVE_OPENCV - std::cout << " CV (use \"-t CV\" option to use it)\n"; - nbDevices++; + std::cout << " CV (use \"-t CV\" option to use it)\n"; + nbDevices++; #endif - if (!nbDevices) { - std::cout << " No display is available\n"; - } - return (0); + if (!nbDevices) { + std::cout << " No display is available\n"; } + return (0); +} - vpImage I1(700, 500, 255); - vpImage I2(700, 500, vpRGBa(255,255,255,255)); - - vpDisplay *display1 = nullptr; - vpDisplay *display2 = nullptr; + vpImage I1(700, 500, 255); + vpImage I2(700, 500, vpRGBa(255, 255, 255, 255)); + + vpDisplay *display1 = nullptr; + vpDisplay *display2 = nullptr; #if defined(VISP_HAVE_DISPLAY) - vpPlot *statePlot = NULL; + vpPlot *statePlot = NULL; #endif - if(opt_display) - { - switch (opt_dtype) - { - case vpX11: - std::cout << "Requested X11 display functionnalities..." << std::endl; + if (opt_display) { + switch (opt_dtype) { + case vpX11: + std::cout << "Requested X11 display functionnalities..." << std::endl; #if defined VISP_HAVE_X11 - display1 = new vpDisplayX; - display2 = new vpDisplayX; + display1 = new vpDisplayX; + display2 = new vpDisplayX; #else - std::cout << " Sorry, X11 video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, X11 video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpGTK: - std::cout << "Requested GTK display functionnalities..." << std::endl; + break; + case vpGTK: + std::cout << "Requested GTK display functionnalities..." << std::endl; #if defined VISP_HAVE_GTK - display1 = new vpDisplayGTK; - display2 = new vpDisplayGTK; + display1 = new vpDisplayGTK; + display2 = new vpDisplayGTK; #else - std::cout << " Sorry, GTK video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, GTK video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpGDI: - std::cout << "Requested GDI display functionnalities..." << std::endl; + break; + case vpGDI: + std::cout << "Requested GDI display functionnalities..." << std::endl; #if defined VISP_HAVE_GDI - display1 = new vpDisplayGDI; - display2 = new vpDisplayGDI; + display1 = new vpDisplayGDI; + display2 = new vpDisplayGDI; #else - std::cout << " Sorry, GDI video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, GDI video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpD3D: - std::cout << "Requested D3D display functionnalities..." << std::endl; + break; + case vpD3D: + std::cout << "Requested D3D display functionnalities..." << std::endl; #if defined VISP_HAVE_D3D9 - display1 = new vpDisplayD3D; - display2 = new vpDisplayD3D; + display1 = new vpDisplayD3D; + display2 = new vpDisplayD3D; #else - std::cout << " Sorry, D3D video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, D3D video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - case vpCV: - std::cout << "Requested OpenCV display functionnalities..." << std::endl; + break; + case vpCV: + std::cout << "Requested OpenCV display functionnalities..." << std::endl; #if defined(VISP_HAVE_OPENCV) - display1 = new vpDisplayOpenCV; - display2 = new vpDisplayOpenCV; + display1 = new vpDisplayOpenCV; + display2 = new vpDisplayOpenCV; #else - std::cout << " Sorry, OpenCV video device is not available.\n"; - std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; - return 0; + std::cout << " Sorry, OpenCV video device is not available.\n"; + std::cout << "Use \"" << argv[0] << " -l\" to print the list of available devices.\n"; + return 0; #endif - break; - } + break; } + } + + std::cout << "Start test testUsTissueTranslationEstimatorUKF" << std::endl; - std::cout << "Start test testUsTissueTranslationEstimatorUKF" << std::endl; - - const int nbNeedles = 6; - - if(opt_display) - { - display1->init(I1, 0,0, "XZ"); - display2->init(I2, display1->getWindowXPosition()+display1->getWidth(), display1->getWindowYPosition(), "YZ"); + const int nbNeedles = 6; + + if (opt_display) { + display1->init(I1, 0, 0, "XZ"); + display2->init(I2, display1->getWindowXPosition()+display1->getWidth(), display1->getWindowYPosition(), "YZ"); #if defined(VISP_HAVE_DISPLAY) - statePlot = new vpPlot; - statePlot->init(4); - for(int i=0 ; i<4 ; i++) statePlot->initGraph(i,1+nbNeedles); - statePlot->setTitle(0, "Tissue position X"); - statePlot->setTitle(1, "Tissue position Y"); - statePlot->setTitle(2, "Tissue velocity X"); - statePlot->setTitle(3, "Tissue velocity Y"); - statePlot->setLegend(0,0, "Ref"); - for(int i=0 ; isetLegend(0,i+1,[i](){std::ostringstream t;t<init(4); + for (int i = 0; i<4; i++) statePlot->initGraph(i, 1+nbNeedles); + statePlot->setTitle(0, "Tissue position X"); + statePlot->setTitle(1, "Tissue position Y"); + statePlot->setTitle(2, "Tissue velocity X"); + statePlot->setTitle(3, "Tissue velocity Y"); + statePlot->setLegend(0, 0, "Ref"); + for (int i = 0; isetLegend(0, i+1, [i]() {std::ostringstream t;t<plot(2,0, time, 0.001); - statePlot->plot(3,0, time, 0); - } + if (opt_display) { + statePlot->plot(2, 0, time, 0.001); + statePlot->plot(3, 0, time, 0); + } #endif - } - else if(i<20) - { - needleRef.accessTissue().move(0,0.001,0,0,0,0); - needleRef.updateState(); + } + else if (i<20) { + needleRef.accessTissue().move(0, 0.001, 0, 0, 0, 0); + needleRef.updateState(); #if defined(VISP_HAVE_DISPLAY) - if(opt_display) - { - statePlot->plot(2,0, time, 0); - statePlot->plot(3,0, time, 0.001); - } + if (opt_display) { + statePlot->plot(2, 0, time, 0); + statePlot->plot(3, 0, time, 0.001); + } #endif } - else if(i<30) - { - needleRef.accessTissue().move(-0.002,0,0,0,0,0); - needleRef.updateState(); + else if (i<30) { + needleRef.accessTissue().move(-0.002, 0, 0, 0, 0, 0); + needleRef.updateState(); #if defined(VISP_HAVE_DISPLAY) - if(opt_display) - { - statePlot->plot(2,0, time, -0.002); - statePlot->plot(3,0, time, 0); - } + if (opt_display) { + statePlot->plot(2, 0, time, -0.002); + statePlot->plot(3, 0, time, 0); + } #endif } - else if(i<40) - { - needleRef.accessTissue().move(0,-0.002,0,0,0,0); - needleRef.updateState(); + else if (i<40) { + needleRef.accessTissue().move(0, -0.002, 0, 0, 0, 0); + needleRef.updateState(); #if defined(VISP_HAVE_DISPLAY) - if(opt_display) - { - statePlot->plot(2,0, time, 0); - statePlot->plot(3,0, time, -0.002); - } + if (opt_display) { + statePlot->plot(2, 0, time, 0); + statePlot->plot(3, 0, time, -0.002); + } #endif } - else - { - needleRef.accessTissue().move(0.001,0.001,0,0,0,0); - needleRef.updateState(); + else { + needleRef.accessTissue().move(0.001, 0.001, 0, 0, 0, 0); + needleRef.updateState(); #if defined(VISP_HAVE_DISPLAY) - if(opt_display) - { - statePlot->plot(2,0, time, 0.001); - statePlot->plot(3,0, time, 0.001); - } + if (opt_display) { + statePlot->plot(2, 0, time, 0.001); + statePlot->plot(3, 0, time, 0.001); + } #endif - } - + } + #if defined(VISP_HAVE_DISPLAY) - if(opt_display) - { - statePlot->plot(0,0, time, needleRef.accessTissue().getPose()[0]); - statePlot->plot(1,0, time, needleRef.accessTissue().getPose()[1]); + if (opt_display) { + statePlot->plot(0, 0, time, needleRef.accessTissue().getPose()[0]); + statePlot->plot(1, 0, time, needleRef.accessTissue().getPose()[1]); } #endif - int nbObs = floor(needleRef.getInsertionDepth()/0.005) + 2; - double step = needleRef.getInsertionDepth()/(nbObs-1); - vpColVector CP(3*nbObs); + int nbObs = floor(needleRef.getInsertionDepth()/0.005) + 2; + double step = needleRef.getInsertionDepth()/(nbObs-1); + vpColVector CP(3*nbObs); - for(int j=0 ; jplot(0,1+i, time, needle[i].accessTissue().getPose()[0]); - statePlot->plot(1,1+i, time, needle[i].accessTissue().getPose()[1]); + statePlot->plot(0, 1+i, time, needle[i].accessTissue().getPose()[0]); + statePlot->plot(1, 1+i, time, needle[i].accessTissue().getPose()[1]); #endif - } + } #if defined(VISP_HAVE_DISPLAY) - for(int i=0 ; iplot(2,1+i, time, Kalman[i].getState()[3]); - statePlot->plot(3,1+i, time, Kalman[i].getState()[4]); - } + for (int i = 0; iplot(2, 1+i, time, Kalman[i].getState()[3]); + statePlot->plot(3, 1+i, time, Kalman[i].getState()[4]); + } #endif - vpDisplay::flush(I1); - vpDisplay::flush(I2); - } - time += 1; + vpDisplay::flush(I1); + vpDisplay::flush(I2); + } + time += 1; } - - if (display1) delete display1; - if (display2) delete display2; + + if (display1) delete display1; + if (display2) delete display2; #if defined(VISP_HAVE_DISPLAY) - if (statePlot) delete statePlot; + if (statePlot) delete statePlot; #endif - return 0; + return 0; } diff --git a/tutorial/ustk/elastography/tutorial-elastography-2D-basic.cpp b/tutorial/ustk/elastography/tutorial-elastography-2D-basic.cpp index 6097be02..2eb448ed 100644 --- a/tutorial/ustk/elastography/tutorial-elastography-2D-basic.cpp +++ b/tutorial/ustk/elastography/tutorial-elastography-2D-basic.cpp @@ -10,6 +10,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main() { diff --git a/tutorial/ustk/elastography/tutorial-elastography-2D-separate-displays.cpp b/tutorial/ustk/elastography/tutorial-elastography-2D-separate-displays.cpp index e4cd3773..e9ce21b5 100644 --- a/tutorial/ustk/elastography/tutorial-elastography-2D-separate-displays.cpp +++ b/tutorial/ustk/elastography/tutorial-elastography-2D-separate-displays.cpp @@ -17,6 +17,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -112,8 +116,8 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), FFTW and a display graphic system (GDI or " - "X11) to run this tutorial" - << std::endl; + "X11) to run this tutorial" + << std::endl; return 0; } diff --git a/tutorial/ustk/elastography/tutorial-elastography-2D.cpp b/tutorial/ustk/elastography/tutorial-elastography-2D.cpp index 9e07ca6b..93da83e8 100644 --- a/tutorial/ustk/elastography/tutorial-elastography-2D.cpp +++ b/tutorial/ustk/elastography/tutorial-elastography-2D.cpp @@ -20,6 +20,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -127,8 +131,8 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), FFTW and a display graphic system (GDI or " - "X11) to run this tutorial" - << std::endl; + "X11) to run this tutorial" + << std::endl; return 0; } diff --git a/tutorial/ustk/elastography/tutorial-elastography-3D-acquisition.cpp b/tutorial/ustk/elastography/tutorial-elastography-3D-acquisition.cpp index f62dc646..033a2d0a 100644 --- a/tutorial/ustk/elastography/tutorial-elastography-3D-acquisition.cpp +++ b/tutorial/ustk/elastography/tutorial-elastography-3D-acquisition.cpp @@ -10,6 +10,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -23,17 +27,19 @@ int main(int argc, char **argv) // record directories if (qApp->arguments().contains(QString("--preCompressed"))) { preCompressedDirectory = - qApp->arguments().at(qApp->arguments().indexOf(QString("--preCompressed")) + 1).toStdString(); - } else { + qApp->arguments().at(qApp->arguments().indexOf(QString("--preCompressed")) + 1).toStdString(); + } + else { std::cout << "You need to specify the directory to record the pre-compressed volumes with --preCompressed option\n"; throw vpException(vpException::fatalError, "No output directory specified for pre-compressed volumes !"); } if (qApp->arguments().contains(QString("--postCompressed"))) { postCompressedDirectory = - qApp->arguments().at(qApp->arguments().indexOf(QString("--postCompressed")) + 1).toStdString(); - } else { + qApp->arguments().at(qApp->arguments().indexOf(QString("--postCompressed")) + 1).toStdString(); + } + else { std::cout - << "You need to specify the directory to record the post-compressed volumes with --postCompressed option\n"; + << "You need to specify the directory to record the post-compressed volumes with --postCompressed option\n"; throw vpException(vpException::fatalError, "No output directory specified for post-compressed volumes !"); } diff --git a/tutorial/ustk/elastography/tutorial-elastography-3D-basic.cpp b/tutorial/ustk/elastography/tutorial-elastography-3D-basic.cpp index 6ffbbe74..96265b9a 100644 --- a/tutorial/ustk/elastography/tutorial-elastography-3D-basic.cpp +++ b/tutorial/ustk/elastography/tutorial-elastography-3D-basic.cpp @@ -15,8 +15,8 @@ int main() if (us::getDataSetPath().empty()) { std::cout << "You should set USTK_DATASET_PATH environment var to access to ustk dataset containing RF volumes for " - "elastography" - << std::endl; + "elastography" + << std::endl; return 0; } diff --git a/tutorial/ustk/elastography/tutorial-elastography-BMA-2D.cpp b/tutorial/ustk/elastography/tutorial-elastography-BMA-2D.cpp index 01b599dd..b39db3fc 100644 --- a/tutorial/ustk/elastography/tutorial-elastography-BMA-2D.cpp +++ b/tutorial/ustk/elastography/tutorial-elastography-BMA-2D.cpp @@ -17,6 +17,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -113,8 +117,8 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), FFTW and a display graphic system (GDI or " - "X11) to run this tutorial" - << std::endl; + "X11) to run this tutorial" + << std::endl; return 0; } diff --git a/tutorial/ustk/gui/tutorial-image-display-qtquickoverlay.cpp b/tutorial/ustk/gui/tutorial-image-display-qtquickoverlay.cpp index 8c2870c9..c8618b6f 100644 --- a/tutorial/ustk/gui/tutorial-image-display-qtquickoverlay.cpp +++ b/tutorial/ustk/gui/tutorial-image-display-qtquickoverlay.cpp @@ -15,6 +15,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { QApplication app(argc, argv); diff --git a/tutorial/ustk/gui/tutorial-image-display-qtquickoverlayServoing.cpp b/tutorial/ustk/gui/tutorial-image-display-qtquickoverlayServoing.cpp index 668acdf8..b1f8dafc 100644 --- a/tutorial/ustk/gui/tutorial-image-display-qtquickoverlayServoing.cpp +++ b/tutorial/ustk/gui/tutorial-image-display-qtquickoverlayServoing.cpp @@ -17,6 +17,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { QApplication app(argc, argv); diff --git a/tutorial/ustk/gui/us2DViewer.cpp b/tutorial/ustk/gui/us2DViewer.cpp index 4e82b316..1869448e 100644 --- a/tutorial/ustk/gui/us2DViewer.cpp +++ b/tutorial/ustk/gui/us2DViewer.cpp @@ -9,6 +9,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { std::string mhd_filename; diff --git a/tutorial/ustk/gui/us2DViewerDrawing.cpp b/tutorial/ustk/gui/us2DViewerDrawing.cpp index e3c49c23..2fd4aed9 100644 --- a/tutorial/ustk/gui/us2DViewerDrawing.cpp +++ b/tutorial/ustk/gui/us2DViewerDrawing.cpp @@ -9,6 +9,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { std::string mhd_filename; diff --git a/tutorial/ustk/gui/us2DViewerPicker.cpp b/tutorial/ustk/gui/us2DViewerPicker.cpp index 923aa852..7ebcd933 100644 --- a/tutorial/ustk/gui/us2DViewerPicker.cpp +++ b/tutorial/ustk/gui/us2DViewerPicker.cpp @@ -9,6 +9,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { std::string mhd_filename; diff --git a/tutorial/ustk/gui/usFullConverter.cpp b/tutorial/ustk/gui/usFullConverter.cpp index bf104379..7e949c66 100644 --- a/tutorial/ustk/gui/usFullConverter.cpp +++ b/tutorial/ustk/gui/usFullConverter.cpp @@ -8,6 +8,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { std::string mhd_filename; diff --git a/tutorial/ustk/gui/usGrabber3DViewer.cpp b/tutorial/ustk/gui/usGrabber3DViewer.cpp index 40bb7700..9b1522b4 100644 --- a/tutorial/ustk/gui/usGrabber3DViewer.cpp +++ b/tutorial/ustk/gui/usGrabber3DViewer.cpp @@ -9,6 +9,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { std::string mhd_filename; diff --git a/tutorial/ustk/imageConversion/tutorial-RFConversion2D.cpp b/tutorial/ustk/imageConversion/tutorial-RFConversion2D.cpp index 85b3f4ed..b8c8a202 100644 --- a/tutorial/ustk/imageConversion/tutorial-RFConversion2D.cpp +++ b/tutorial/ustk/imageConversion/tutorial-RFConversion2D.cpp @@ -6,6 +6,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { std::string filename; diff --git a/tutorial/ustk/imageConversion/tutorial-RFConversion3D.cpp b/tutorial/ustk/imageConversion/tutorial-RFConversion3D.cpp index bd169c2f..b7288af7 100644 --- a/tutorial/ustk/imageConversion/tutorial-RFConversion3D.cpp +++ b/tutorial/ustk/imageConversion/tutorial-RFConversion3D.cpp @@ -6,6 +6,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { std::string filename; diff --git a/tutorial/ustk/imageConversion/tutorial-fullConversion2D.cpp b/tutorial/ustk/imageConversion/tutorial-fullConversion2D.cpp index 8303311f..9589b295 100644 --- a/tutorial/ustk/imageConversion/tutorial-fullConversion2D.cpp +++ b/tutorial/ustk/imageConversion/tutorial-fullConversion2D.cpp @@ -6,6 +6,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { std::string filename; diff --git a/tutorial/ustk/imageConversion/tutorial-fullConversion3D.cpp b/tutorial/ustk/imageConversion/tutorial-fullConversion3D.cpp index 9f13c57f..9dcd4f11 100644 --- a/tutorial/ustk/imageConversion/tutorial-fullConversion3D.cpp +++ b/tutorial/ustk/imageConversion/tutorial-fullConversion3D.cpp @@ -6,6 +6,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main() { std::string filename; diff --git a/tutorial/ustk/imageConversion/tutorial-rfFileToPreScanConversion.cpp b/tutorial/ustk/imageConversion/tutorial-rfFileToPreScanConversion.cpp index 95e3e0cd..ee10d9d1 100644 --- a/tutorial/ustk/imageConversion/tutorial-rfFileToPreScanConversion.cpp +++ b/tutorial/ustk/imageConversion/tutorial-rfFileToPreScanConversion.cpp @@ -9,6 +9,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main() { std::string filename; diff --git a/tutorial/ustk/imageConversion/tutorial-scanConversion2D.cpp b/tutorial/ustk/imageConversion/tutorial-scanConversion2D.cpp index b21910db..8cebf4ea 100644 --- a/tutorial/ustk/imageConversion/tutorial-scanConversion2D.cpp +++ b/tutorial/ustk/imageConversion/tutorial-scanConversion2D.cpp @@ -3,6 +3,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { std::string filename; diff --git a/tutorial/ustk/imageConversion/tutorial-scanConversion3D.cpp b/tutorial/ustk/imageConversion/tutorial-scanConversion3D.cpp index e08794a8..c270531e 100644 --- a/tutorial/ustk/imageConversion/tutorial-scanConversion3D.cpp +++ b/tutorial/ustk/imageConversion/tutorial-scanConversion3D.cpp @@ -3,6 +3,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { std::string mhd_filename; diff --git a/tutorial/ustk/meshDeformation/usMeshDeformation.cpp b/tutorial/ustk/meshDeformation/usMeshDeformation.cpp index be984319..b224850f 100644 --- a/tutorial/ustk/meshDeformation/usMeshDeformation.cpp +++ b/tutorial/ustk/meshDeformation/usMeshDeformation.cpp @@ -38,6 +38,10 @@ #ifdef USTK_HAVE_VTK_QT +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. */ @@ -60,7 +64,7 @@ usMeshDeformation::usMeshDeformation(QWidget *parent, Qt::WindowFlags f) : usVie renderWindow->AddRenderer(renderer); } -usMeshDeformation::~usMeshDeformation() {} +usMeshDeformation::~usMeshDeformation() { } /** * Qt paint event overload if needed to update Qt widget @@ -84,7 +88,8 @@ void usMeshDeformation::keyPressEvent(QKeyEvent *event) #else this->renderWindow()->Render(); #endif - } else if (event->key() == Qt::Key_Down) { // move first point of the mesh of along Y + } + else if (event->key() == Qt::Key_Down) { // move first point of the mesh of along Y double *point1 = m_meshPolyData->GetPoints()->GetPoint(0); point1[1] -= 1; m_meshPolyData->GetPoints()->SetPoint(0, point1); @@ -94,7 +99,8 @@ void usMeshDeformation::keyPressEvent(QKeyEvent *event) #else this->renderWindow()->Render(); #endif - } else { + } + else { usViewerWidget::keyPressEvent(event); } } @@ -127,8 +133,9 @@ void usMeshDeformation::updateMeshPosition(vpHomogeneousMatrix transform) vtkSmartPointer vtkMatrix = vtkSmartPointer::New(); usVTKConverter::convert(transform, vtkMatrix); m_meshActor->SetUserMatrix(vtkMatrix); - } else { - // get current matrix + } + else { + // get current matrix vpHomogeneousMatrix currentTransform; currentTransform.eye(); usVTKConverter::convert(m_meshActor->GetUserMatrix(), currentTransform); diff --git a/tutorial/ustk/meshDeformation/usMeshDeformation.h b/tutorial/ustk/meshDeformation/usMeshDeformation.h index dd8fb5c6..b9aba0bc 100644 --- a/tutorial/ustk/meshDeformation/usMeshDeformation.h +++ b/tutorial/ustk/meshDeformation/usMeshDeformation.h @@ -120,7 +120,7 @@ class usMeshDeformation : public usViewerWidget void render(); public slots: - void updateMeshPosition(vpHomogeneousMatrix transform); + void updateMeshPosition(VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix transform); private: // mesh polydata diff --git a/tutorial/ustk/needleDetection/tutorial-needleDetection2D.cpp b/tutorial/ustk/needleDetection/tutorial-needleDetection2D.cpp index fa4053a7..402fbdbd 100644 --- a/tutorial/ustk/needleDetection/tutorial-needleDetection2D.cpp +++ b/tutorial/ustk/needleDetection/tutorial-needleDetection2D.cpp @@ -55,6 +55,10 @@ using namespace std; +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /* -------------------------------------------------------------------------- */ /* COMMAND LINE OPTIONS */ /* -------------------------------------------------------------------------- */ diff --git a/tutorial/ustk/needleDetection/tutorial-volReading.cpp b/tutorial/ustk/needleDetection/tutorial-volReading.cpp index b1eaccb0..97370b3a 100644 --- a/tutorial/ustk/needleDetection/tutorial-volReading.cpp +++ b/tutorial/ustk/needleDetection/tutorial-volReading.cpp @@ -58,6 +58,10 @@ using namespace std; +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /* -------------------------------------------------------------------------- */ /* COMMAND LINE OPTIONS */ /* -------------------------------------------------------------------------- */ diff --git a/tutorial/ustk/realTimeDisplay/tutorial-local-grabbing-elastography-display.cpp b/tutorial/ustk/realTimeDisplay/tutorial-local-grabbing-elastography-display.cpp index 71d2b643..05a34b7d 100644 --- a/tutorial/ustk/realTimeDisplay/tutorial-local-grabbing-elastography-display.cpp +++ b/tutorial/ustk/realTimeDisplay/tutorial-local-grabbing-elastography-display.cpp @@ -12,6 +12,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { diff --git a/tutorial/ustk/realTimeDisplay/tutorial-ultrasonix-qt-grabbing-pre-scan3D-display.cpp b/tutorial/ustk/realTimeDisplay/tutorial-ultrasonix-qt-grabbing-pre-scan3D-display.cpp index c60eb951..f0db35f8 100644 --- a/tutorial/ustk/realTimeDisplay/tutorial-ultrasonix-qt-grabbing-pre-scan3D-display.cpp +++ b/tutorial/ustk/realTimeDisplay/tutorial-ultrasonix-qt-grabbing-pre-scan3D-display.cpp @@ -15,6 +15,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -93,13 +97,15 @@ int main(int argc, char **argv) scene.show(); init = true; - } else { + } + else { usVTKConverter::convert(*grabbedFrame, vtkImage); scene.setImageData(vtkImage); } - } else { + } + else { vpTime::wait(10); } } while (captureRunning); diff --git a/tutorial/ustk/sonosite/tutorial-servo-target-confidence.cpp b/tutorial/ustk/sonosite/tutorial-servo-target-confidence.cpp index 2bba5728..be767744 100644 --- a/tutorial/ustk/sonosite/tutorial-servo-target-confidence.cpp +++ b/tutorial/ustk/sonosite/tutorial-servo-target-confidence.cpp @@ -23,6 +23,10 @@ #if defined(VISP_HAVE_V4L2) && defined(VISP_HAVE_PTHREAD) && defined(VISP_HAVE_VIPER850) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // Shared vars typedef enum { capture_waiting, capture_started, capture_stopped } t_CaptureState; t_CaptureState s_capture_state = capture_waiting; @@ -264,7 +268,8 @@ vpThread::Return displayFunction(vpThread::Args args) // Update the display vpDisplay::flush(postScan_); vpDisplay::flush(confidencePostScan_); - } else { + } + else { vpTime::wait(2); // Sleep 2ms } } while (capture_state_ != capture_stopped); diff --git a/tutorial/ustk/sonosite/tutorial-servo-target.cpp b/tutorial/ustk/sonosite/tutorial-servo-target.cpp index beedb85d..60c4f066 100644 --- a/tutorial/ustk/sonosite/tutorial-servo-target.cpp +++ b/tutorial/ustk/sonosite/tutorial-servo-target.cpp @@ -18,6 +18,10 @@ #if defined(VISP_HAVE_V4L2) && defined(VISP_HAVE_PTHREAD) && defined(VISP_HAVE_VIPER850) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // Shared vars typedef enum { capture_waiting, capture_started, capture_stopped } t_CaptureState; t_CaptureState s_capture_state = capture_waiting; @@ -140,7 +144,7 @@ vpThread::Return displayFunction(vpThread::Args args) std::cout << "Height resolution : " << postScan_.getHeightResolution() << std::endl; std::cout << "Width resolution : " << postScan_.getWidthResolution() << std::endl; std::cout << "Center i = " << rectangle.getCenter().get_i() << ", j = " << rectangle.getCenter().get_j() - << std::endl; + << std::endl; std::cout << "xtarget = " << xtarget << ", ytarget = " << ytarget << std::endl; double time = (vpTime::measureTimeMs() - startTime) / 1000.0; @@ -192,7 +196,8 @@ vpThread::Return displayFunction(vpThread::Args args) // Update the display vpDisplay::flush(postScan_); firstLoopCycle = false; - } else { + } + else { vpTime::wait(2); // Sleep 2ms } } while (capture_state_ != capture_stopped); diff --git a/tutorial/ustk/sonosite/tutorial-sonosite-confidence-control.cpp b/tutorial/ustk/sonosite/tutorial-sonosite-confidence-control.cpp index e2235137..d9a055d4 100644 --- a/tutorial/ustk/sonosite/tutorial-sonosite-confidence-control.cpp +++ b/tutorial/ustk/sonosite/tutorial-sonosite-confidence-control.cpp @@ -19,6 +19,10 @@ #if defined(VISP_HAVE_V4L2) && defined(VISP_HAVE_PTHREAD) && defined(VISP_HAVE_VIPER850) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // Shared vars typedef enum { capture_waiting, capture_started, capture_stopped } t_CaptureState; t_CaptureState s_capture_state = capture_waiting; @@ -218,7 +222,8 @@ vpThread::Return displayFunction(vpThread::Args args) vpDisplay::flush(preScan_); vpDisplay::flush(confidencePostScan_); vpDisplay::flush(confidencePreScan_); - } else { + } + else { vpTime::wait(2); // Sleep 2ms } } while (capture_state_ != capture_stopped); diff --git a/tutorial/ustk/sonosite/tutorial-sonosite-confidence-map.cpp b/tutorial/ustk/sonosite/tutorial-sonosite-confidence-map.cpp index 5a8799ca..22d94ffa 100644 --- a/tutorial/ustk/sonosite/tutorial-sonosite-confidence-map.cpp +++ b/tutorial/ustk/sonosite/tutorial-sonosite-confidence-map.cpp @@ -17,6 +17,10 @@ #if defined(VISP_HAVE_V4L2) && defined(VISP_HAVE_PTHREAD) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // Shared vars typedef enum { capture_waiting, capture_started, capture_stopped } t_CaptureState; t_CaptureState s_capture_state = capture_waiting; @@ -174,7 +178,8 @@ vpThread::Return displayFunction(vpThread::Args args) vpDisplay::flush(preScan_); vpDisplay::flush(confidencePostScan_); vpDisplay::flush(confidencePreScan_); - } else { + } + else { vpTime::wait(2); // Sleep 2ms } } while (capture_state_ != capture_stopped); diff --git a/tutorial/ustk/sonosite/tutorial-sonosite-grabber.cpp b/tutorial/ustk/sonosite/tutorial-sonosite-grabber.cpp index b51d9f49..7c507d4e 100644 --- a/tutorial/ustk/sonosite/tutorial-sonosite-grabber.cpp +++ b/tutorial/ustk/sonosite/tutorial-sonosite-grabber.cpp @@ -13,6 +13,10 @@ #if defined(VISP_HAVE_V4L2) && defined(VISP_HAVE_PTHREAD) +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // Shared vars typedef enum { capture_waiting, capture_started, capture_stopped } t_CaptureState; t_CaptureState s_capture_state = capture_waiting; @@ -110,7 +114,8 @@ vpThread::Return displayFunction(vpThread::Args args) // Update the display vpDisplay::flush(postScan_); - } else { + } + else { vpTime::wait(2); // Sleep 2ms } } while (capture_state_ != capture_stopped); diff --git a/tutorial/ustk/tracking/tutorial-ultrasonix-servo-target-confidence.cpp b/tutorial/ustk/tracking/tutorial-ultrasonix-servo-target-confidence.cpp index 92521b2d..c8e41938 100644 --- a/tutorial/ustk/tracking/tutorial-ultrasonix-servo-target-confidence.cpp +++ b/tutorial/ustk/tracking/tutorial-ultrasonix-servo-target-confidence.cpp @@ -29,6 +29,11 @@ #include #include + +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // Shared vars typedef enum { capture_waiting, capture_started, capture_stopped } t_CaptureState; t_CaptureState s_capture_state = capture_waiting; @@ -223,7 +228,8 @@ vpThread::Return displayFunction(vpThread::Args args) // Update the display vpDisplay::flush(postScan_); vpDisplay::flush(confidencePostScan_); - } else { + } + else { vpTime::wait(2); // Sleep 2ms } } while (capture_state_ != capture_stopped); diff --git a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-RF-scan-conversion.cpp b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-RF-scan-conversion.cpp index bc71e655..9912c578 100644 --- a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-RF-scan-conversion.cpp +++ b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-RF-scan-conversion.cpp @@ -17,6 +17,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -29,17 +33,20 @@ int main(int argc, char **argv) usNetworkGrabber::usInitHeaderSent header; if (qApp->arguments().contains(QString("--probeID"))) { header.probeId = qApp->arguments().at(qApp->arguments().indexOf(QString("--probeID")) + 1).toInt(); - } else + } + else header.probeId = 15; // 4DC7 id = 15 by default if (qApp->arguments().contains(QString("--slotID"))) { header.slotId = qApp->arguments().at(qApp->arguments().indexOf(QString("--slotID")) + 1).toInt(); - } else + } + else header.slotId = 0; // top slot id = 0 by default if (qApp->arguments().contains(QString("--imagingMode"))) { header.imagingMode = qApp->arguments().at(qApp->arguments().indexOf(QString("--imagingMode")) + 1).toInt(); - } else + } + else header.imagingMode = 12; // RF = 12 // prepare image; diff --git a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-RF.cpp b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-RF.cpp index da29ddcb..4d90f6a4 100644 --- a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-RF.cpp +++ b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-RF.cpp @@ -16,6 +16,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -34,17 +38,20 @@ int main(int argc, char **argv) usNetworkGrabber::usInitHeaderSent header; if (qApp->arguments().contains(QString("--probeID"))) { header.probeId = qApp->arguments().at(qApp->arguments().indexOf(QString("--probeID")) + 1).toInt(); - } else + } + else header.probeId = 15; // 4DC7 id = 15 by default if (qApp->arguments().contains(QString("--slotID"))) { header.slotId = qApp->arguments().at(qApp->arguments().indexOf(QString("--slotID")) + 1).toInt(); - } else + } + else header.slotId = 0; // top slot id = 0 by default if (qApp->arguments().contains(QString("--imagingMode"))) { header.imagingMode = qApp->arguments().at(qApp->arguments().indexOf(QString("--imagingMode")) + 1).toInt(); - } else + } + else header.imagingMode = 12; // RF = 12 // prepare image; @@ -114,7 +121,7 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), FFTW and GDI or X11 to run this tutorial" - << std::endl; + << std::endl; return 0; } diff --git a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-RF3D.cpp b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-RF3D.cpp index 4c1e615a..7669138e 100644 --- a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-RF3D.cpp +++ b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-RF3D.cpp @@ -13,6 +13,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -50,17 +54,17 @@ int main(int argc, char **argv) // our local grabbing loop do { - grabbedVolume = qtGrabber->acquire(); + grabbedVolume = qtGrabber->acquire(); - std::cout << "MAIN THREAD received volume No : " << grabbedVolume->getVolumeCount() << std::endl; + std::cout << "MAIN THREAD received volume No : " << grabbedVolume->getVolumeCount() << std::endl; - // convert RF to pre-scan to save the image - converter.convert(*grabbedVolume, preScanImage); + // convert RF to pre-scan to save the image + converter.convert(*grabbedVolume, preScanImage); - QString filename = QString("volume") + QString::number(grabbedVolume->getVolumeCount()) + QString(".mhd"); - usImageIo::write(preScanImage, filename.toStdString()); + QString filename = QString("volume") + QString::number(grabbedVolume->getVolumeCount()) + QString(".mhd"); + usImageIo::write(preScanImage, filename.toStdString()); } while (captureRunning); - + qtGrabber->stopAcquisition(); return 0; @@ -70,7 +74,7 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), FFTW and GDI or X11 to run this tutorial" - << std::endl; + << std::endl; return 0; } diff --git a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-post-scan-bi-plan.cpp b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-post-scan-bi-plan.cpp index 1a8b11d2..d82c27e6 100644 --- a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-post-scan-bi-plan.cpp +++ b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-post-scan-bi-plan.cpp @@ -13,6 +13,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -60,9 +64,9 @@ int main(int argc, char **argv) grabbedFrame = qtGrabber->acquire(); std::cout << "MAIN THREAD received frame No : " << grabbedFrame[0]->getFrameCount() << " and " - << grabbedFrame[1]->getFrameCount() << std::endl; + << grabbedFrame[1]->getFrameCount() << std::endl; - // init display +// init display if (!displayInit && grabbedFrame[0]->getHeight() != 0 && grabbedFrame[0]->getWidth() != 0) { #if defined(VISP_HAVE_X11) display1 = new vpDisplayX(*(grabbedFrame[0])); @@ -102,7 +106,7 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), and display X to run this tutorial" - << std::endl; + << std::endl; return 0; } diff --git a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-post-scan.cpp b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-post-scan.cpp index 540950d4..5fe239e5 100644 --- a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-post-scan.cpp +++ b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-post-scan.cpp @@ -14,6 +14,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -32,17 +36,20 @@ int main(int argc, char **argv) usNetworkGrabber::usInitHeaderSent header; if (qApp->arguments().contains(QString("--probeID"))) { header.probeId = qApp->arguments().at(qApp->arguments().indexOf(QString("--probeID")) + 1).toInt(); - } else + } + else header.probeId = 15; // 4DC7 id = 15 by default if (qApp->arguments().contains(QString("--slotID"))) { header.slotId = qApp->arguments().at(qApp->arguments().indexOf(QString("--slotID")) + 1).toInt(); - } else + } + else header.slotId = 0; // top slot id = 0 by default if (qApp->arguments().contains(QString("--imagingMode"))) { header.imagingMode = qApp->arguments().at(qApp->arguments().indexOf(QString("--imagingMode")) + 1).toInt(); - } else + } + else header.imagingMode = 0; // B-mode = 0 by default usFrameGrabbedInfo > *grabbedFrame; @@ -120,7 +127,7 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), and display X to run this tutorial" - << std::endl; + << std::endl; return 0; } diff --git a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-post-scan3D.cpp b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-post-scan3D.cpp index 185cc21c..f39bf299 100644 --- a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-post-scan3D.cpp +++ b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-post-scan3D.cpp @@ -16,6 +16,10 @@ #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application diff --git a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan-confidence-control.cpp b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan-confidence-control.cpp index ff1ba305..38d1e120 100644 --- a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan-confidence-control.cpp +++ b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan-confidence-control.cpp @@ -17,6 +17,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + // Shared vars vpMutex s_mutex_control_velocity; @@ -242,7 +246,7 @@ vpThread::Return controlFunction(vpThread::Args args) // Compute the force/torque control law in the sensor frame (propotionnal + derivate controller) v_s = - lambdaProportionnal * sEs + lambdaDerivate * (sEs - sEs_last) / deltaTmilliseconds + lambdaIntegral * sEs_sum; + lambdaProportionnal * sEs + lambdaDerivate * (sEs - sEs_last) / deltaTmilliseconds + lambdaIntegral * sEs_sum; v_s[0] = 0.0; v_s[1] = 0.0; @@ -285,17 +289,20 @@ int main(int argc, char **argv) usNetworkGrabber::usInitHeaderSent header; if (qApp->arguments().contains(QString("--probeID"))) { header.probeId = qApp->arguments().at(qApp->arguments().indexOf(QString("--probeID")) + 1).toInt(); - } else + } + else header.probeId = 15; // 4DC7 id = 15 by default if (qApp->arguments().contains(QString("--slotID"))) { header.slotId = qApp->arguments().at(qApp->arguments().indexOf(QString("--slotID")) + 1).toInt(); - } else + } + else header.slotId = 0; // top slot id = 0 by default if (qApp->arguments().contains(QString("--imagingMode"))) { header.imagingMode = qApp->arguments().at(qApp->arguments().indexOf(QString("--imagingMode")) + 1).toInt(); - } else + } + else header.imagingMode = 0; // B-mode = 0 by default // prepare image; @@ -400,7 +407,7 @@ int main(int argc, char **argv) vpTime::wait(10); // wait to simulate a local process running on last frame frabbed } } while (captureRunning); - + qtGrabber->stopAcquisition(); std::cout << "stop capture" << std::endl; @@ -442,7 +449,7 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), and display X to run this tutorial" - << std::endl; + << std::endl; return 0; } diff --git a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan-confidence.cpp b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan-confidence.cpp index bfbfce49..081c08a3 100644 --- a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan-confidence.cpp +++ b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan-confidence.cpp @@ -16,6 +16,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -28,17 +32,20 @@ int main(int argc, char **argv) usNetworkGrabber::usInitHeaderSent header; if (qApp->arguments().contains(QString("--probeID"))) { header.probeId = qApp->arguments().at(qApp->arguments().indexOf(QString("--probeID")) + 1).toInt(); - } else + } + else header.probeId = 15; // 4DC7 id = 15 by default if (qApp->arguments().contains(QString("--slotID"))) { header.slotId = qApp->arguments().at(qApp->arguments().indexOf(QString("--slotID")) + 1).toInt(); - } else + } + else header.slotId = 0; // top slot id = 0 by default if (qApp->arguments().contains(QString("--imagingMode"))) { header.imagingMode = qApp->arguments().at(qApp->arguments().indexOf(QString("--imagingMode")) + 1).toInt(); - } else + } + else header.imagingMode = 0; // B-mode = 0 by default // prepare image; @@ -118,7 +125,7 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), and display X to run this tutorial" - << std::endl; + << std::endl; return 0; } diff --git a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan.cpp b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan.cpp index df1a18b8..41e7716c 100644 --- a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan.cpp +++ b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan.cpp @@ -14,6 +14,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -32,17 +36,20 @@ int main(int argc, char **argv) usNetworkGrabber::usInitHeaderSent header; if (qApp->arguments().contains(QString("--probeID"))) { header.probeId = qApp->arguments().at(qApp->arguments().indexOf(QString("--probeID")) + 1).toInt(); - } else + } + else header.probeId = 15; // 4DC7 id = 15 by default if (qApp->arguments().contains(QString("--slotID"))) { header.slotId = qApp->arguments().at(qApp->arguments().indexOf(QString("--slotID")) + 1).toInt(); - } else + } + else header.slotId = 0; // top slot id = 0 by default if (qApp->arguments().contains(QString("--imagingMode"))) { header.imagingMode = qApp->arguments().at(qApp->arguments().indexOf(QString("--imagingMode")) + 1).toInt(); - } else + } + else header.imagingMode = 0; // B-mode = 0 by default // prepare image; @@ -107,7 +114,7 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), and display X to run this tutorial" - << std::endl; + << std::endl; return 0; } diff --git a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan3D.cpp b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan3D.cpp index d65062e3..ef634451 100644 --- a/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan3D.cpp +++ b/tutorial/ustk/ultrasonix/tutorial-ultrasonix-qt-grabbing-pre-scan3D.cpp @@ -16,6 +16,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application diff --git a/tutorial/ustk/virtualNeedle/usVirtualNeedle.cpp b/tutorial/ustk/virtualNeedle/usVirtualNeedle.cpp index 18fd7e4a..9d0215f2 100644 --- a/tutorial/ustk/virtualNeedle/usVirtualNeedle.cpp +++ b/tutorial/ustk/virtualNeedle/usVirtualNeedle.cpp @@ -39,6 +39,10 @@ #ifdef USTK_HAVE_VTK_QT +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + /** * Constructor. */ @@ -110,32 +114,38 @@ void usVirtualNeedle::keyPressEvent(QKeyEvent *event) transform.eye(); transform[0][3] = 0.001; // add 1mm on X axis updateNeedlePosition(transform); - } else if (event->key() == Qt::Key_Right) { + } + else if (event->key() == Qt::Key_Right) { vpHomogeneousMatrix transform; transform.eye(); transform[0][3] = -0.001; // minus 1mm on X axis updateNeedlePosition(transform); - } else if (event->key() == Qt::Key_Up) { + } + else if (event->key() == Qt::Key_Up) { vpHomogeneousMatrix transform; transform.eye(); transform[1][3] = 0.001; // add 1mm on Y axis updateNeedlePosition(transform); - } else if (event->key() == Qt::Key_Down) { + } + else if (event->key() == Qt::Key_Down) { vpHomogeneousMatrix transform; transform.eye(); transform[1][3] = -0.001; // remove 1mm on Y axis updateNeedlePosition(transform); - } else if (event->key() == Qt::Key_PageUp) { + } + else if (event->key() == Qt::Key_PageUp) { vpHomogeneousMatrix transform; transform.eye(); transform[2][3] = 0.001; // remove 1mm on Z axis updateNeedlePosition(transform); - } else if (event->key() == Qt::Key_PageDown) { + } + else if (event->key() == Qt::Key_PageDown) { vpHomogeneousMatrix transform; transform.eye(); transform[2][3] = -0.001; // remove 1mm on Z axis updateNeedlePosition(transform); - } else if (event->key() == Qt::Key_Space) { // move first point of the mesh of 1mm along Z + } + else if (event->key() == Qt::Key_Space) { // move first point of the mesh of 1mm along Z double *point1 = m_meshPolyData->GetPoints()->GetPoint(0); point1[2] += 0.001; m_meshPolyData->GetPoints()->SetPoint(0, point1); @@ -145,7 +155,8 @@ void usVirtualNeedle::keyPressEvent(QKeyEvent *event) #else this->renderWindow()->Render(); #endif - } else if (event->key() == Qt::Key_0) { // move first point of the mesh of - 1mm along Z + } + else if (event->key() == Qt::Key_0) { // move first point of the mesh of - 1mm along Z double *point1 = m_meshPolyData->GetPoints()->GetPoint(0); point1[2] -= 0.001; m_meshPolyData->GetPoints()->SetPoint(0, point1); @@ -155,7 +166,8 @@ void usVirtualNeedle::keyPressEvent(QKeyEvent *event) #else this->renderWindow()->Render(); #endif - } else { + } + else { usViewerWidget::keyPressEvent(event); } } @@ -189,8 +201,9 @@ void usVirtualNeedle::updateNeedlePosition(vpHomogeneousMatrix transform) vtkSmartPointer vtkMatrix = vtkSmartPointer::New(); usVTKConverter::convert(transform, vtkMatrix); m_needleActor->SetUserMatrix(vtkMatrix); - } else { - // get current matrix + } + else { + // get current matrix vpHomogeneousMatrix currentTransform; currentTransform.eye(); usVTKConverter::convert(m_needleActor->GetUserMatrix(), currentTransform); diff --git a/tutorial/ustk/virtualNeedle/usVirtualNeedle.h b/tutorial/ustk/virtualNeedle/usVirtualNeedle.h index 60971fa4..88b5511b 100644 --- a/tutorial/ustk/virtualNeedle/usVirtualNeedle.h +++ b/tutorial/ustk/virtualNeedle/usVirtualNeedle.h @@ -119,7 +119,7 @@ class usVirtualNeedle : public usViewerWidget void render(); public slots: - void updateNeedlePosition(vpHomogeneousMatrix transform); + void updateNeedlePosition(VISP_NAMESPACE_ADDRESSING vpHomogeneousMatrix transform); private: // mesh polydata diff --git a/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-RF2D.cpp b/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-RF2D.cpp index 1249a7b7..21a2b3a3 100644 --- a/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-RF2D.cpp +++ b/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-RF2D.cpp @@ -18,6 +18,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -79,7 +83,8 @@ int main(int argc, char **argv) } vpDisplay::display(preScanImage); vpDisplay::flush(preScanImage); - } else { + } + else { vpTime::wait(10); } } while (captureRunning); @@ -93,7 +98,7 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), and display X to run this tutorial" - << std::endl; + << std::endl; return 0; } diff --git a/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-RF3D.cpp b/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-RF3D.cpp index efce60a1..bf4fbfb9 100644 --- a/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-RF3D.cpp +++ b/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-RF3D.cpp @@ -18,6 +18,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -71,7 +75,8 @@ int main(int argc, char **argv) if (!outputPath.isEmpty()) writer.write(preScanImage, grabbedVolume->getTimeStamps()); - } else { + } + else { vpTime::wait(10); } } while (captureRunning); @@ -83,7 +88,7 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), and display X to run this tutorial" - << std::endl; + << std::endl; return 0; } diff --git a/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-postScan2D.cpp b/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-postScan2D.cpp index 41ea9735..f5ed71d8 100644 --- a/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-postScan2D.cpp +++ b/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-postScan2D.cpp @@ -17,6 +17,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -77,7 +81,8 @@ int main(int argc, char **argv) } vpDisplay::display(*grabbedFrame); vpDisplay::flush(*grabbedFrame); - } else { + } + else { vpTime::wait(10); } } while (captureRunning); @@ -91,7 +96,7 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), and display X to run this tutorial" - << std::endl; + << std::endl; return 0; } diff --git a/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-preScan2D.cpp b/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-preScan2D.cpp index 532034d4..773f8272 100644 --- a/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-preScan2D.cpp +++ b/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-preScan2D.cpp @@ -17,6 +17,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -77,7 +81,8 @@ int main(int argc, char **argv) } vpDisplay::display(*grabbedFrame); vpDisplay::flush(*grabbedFrame); - } else { + } + else { vpTime::wait(10); } } while (captureRunning); @@ -91,7 +96,7 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), and display X to run this tutorial" - << std::endl; + << std::endl; return 0; } diff --git a/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-preScan3D.cpp b/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-preScan3D.cpp index 6b1f2568..59e2d497 100644 --- a/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-preScan3D.cpp +++ b/tutorial/ustk/virtualServerClients/tutorial-ustk-virtual-server-preScan3D.cpp @@ -17,6 +17,10 @@ #include #include +#ifdef ENABLE_VISP_NAMESPACE +using namespace VISP_NAMESPACE_NAME; +#endif + int main(int argc, char **argv) { // QT application @@ -56,7 +60,8 @@ int main(int argc, char **argv) std::cout << "MAIN THREAD received volume No : " << grabbedFrame->getVolumeCount() << std::endl; - } else { + } + else { vpTime::wait(10); } } while (captureRunning); @@ -68,7 +73,7 @@ int main(int argc, char **argv) int main() { std::cout << "You should intall Qt5 (with wigdets and network modules), and display X to run this tutorial" - << std::endl; + << std::endl; return 0; }