From dafa5cd1aa41409c1abe4e3f176fd6e9151c11d3 Mon Sep 17 00:00:00 2001 From: malaterre Date: Sun, 24 Jul 2005 00:24:46 +0000 Subject: [PATCH] COMP: OK pow and powf are just to much pain for a simple square. Rewrote the code. Also trying to rewrote some 1st year student code... --- src/gdcmFile.cxx | 25 +++++++++++++++++-------- src/gdcmFile.h | 10 +++++----- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/gdcmFile.cxx b/src/gdcmFile.cxx index 66d2ffd8..e2fbce1f 100644 --- a/src/gdcmFile.cxx +++ b/src/gdcmFile.cxx @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.cxx,v $ Language: C++ - Date: $Date: 2005/07/23 02:01:37 $ - Version: $Revision: 1.260 $ + Date: $Date: 2005/07/24 00:24:46 $ + Version: $Revision: 1.261 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -1878,6 +1878,8 @@ float File::TypeOrientation( ) } +// FIXME. Seriously who wrote that ! +// Haven't you ever heard of so called reference in c++ Res File::VerfCriterion(int typeCriterion, float criterionNew, Res res) { float criterion = res.second; @@ -1898,8 +1900,17 @@ Res File::VerfCriterion(int typeCriterion, float criterionNew, Res res) return res; } -float File::CalculLikelyhood2Vec(vector3D refA, vector3D refB, - vector3D ori1, vector3D ori2) +inline double square_dist(vector3D const &v1, vector3D const & v2) +{ + double res; + res = (v1.x - v2.x)*(v1.x - v2.x) + + (v1.y - v2.y)*(v1.y - v2.y) + + (v1.z - v2.z)*(v1.z - v2.z); + return res; +} + +float File::CalculLikelyhood2Vec(vector3D const & refA, vector3D const &refB, + vector3D const & ori1, vector3D const &ori2) { // # ------------------------- Purpose : ----------------------------------- // # - This function determines the orientation similarity of two planes. @@ -1920,9 +1931,7 @@ float File::CalculLikelyhood2Vec(vector3D refA, vector3D refB, vector3D ori3 = ProductVectorial(ori1,ori2); vector3D refC = ProductVectorial(refA,refB); - float res = pow(refC.x-ori3.x, 2.) + - pow(refC.y-ori3.y, 2.) + - pow(refC.z-ori3.z, 2.); + double res = square_dist(refC, ori3); /* // ori3=self.ProductVectorial(ori1,ori2) @@ -1933,7 +1942,7 @@ float File::CalculLikelyhood2Vec(vector3D refA, vector3D refB, return sqrt(res); } -vector3D File::ProductVectorial(vector3D vec1, vector3D vec2) +vector3D File::ProductVectorial(vector3D const & vec1, vector3D const & vec2) { // # ------------------------- Purpose : ----------------------------------- diff --git a/src/gdcmFile.h b/src/gdcmFile.h index 643e407e..9062a1c8 100644 --- a/src/gdcmFile.h +++ b/src/gdcmFile.h @@ -3,8 +3,8 @@ Program: gdcm Module: $RCSfile: gdcmFile.h,v $ Language: C++ - Date: $Date: 2005/07/21 14:01:50 $ - Version: $Revision: 1.112 $ + Date: $Date: 2005/07/24 00:24:46 $ + Version: $Revision: 1.113 $ Copyright (c) CREATIS (Centre de Recherche et d'Applications en Traitement de l'Image). All rights reserved. See Doc/License.txt or @@ -213,9 +213,9 @@ private: void ReadAndSkipEncapsulatedBasicOffsetTable(); Res VerfCriterion(int typeCriterion, float criterionNew, Res res); - float CalculLikelyhood2Vec(vector3D refA, vector3D refB, - vector3D ori1, vector3D ori2); - vector3D ProductVectorial(vector3D vec1, vector3D vec2); + float CalculLikelyhood2Vec(vector3D const & refA, vector3D const & refB, + vector3D const & ori1, vector3D const & ori2); + vector3D ProductVectorial(vector3D const & vec1, vector3D const & vec2); }; } // end namespace gdcm -- 2.45.1