From e02cb6172a8b80516ff9c04155333648f73d557f Mon Sep 17 00:00:00 2001 From: Pierre Alliez Date: Wed, 16 Jan 2008 16:41:58 +0000 Subject: [PATCH] PCA: simplified interface in 3D --- .../windows/3d/Mesh.sln | 30 +- .../windows/3d/Mesh.vcproj | 416 ++++++++++++------ .../windows/3d/MeshDoc.cpp | 24 +- .../windows/3d/TextualStatusBar.cpp | 25 -- .../include/CGAL/PCA_util.h | 30 +- .../CGAL/linear_least_squares_fitting_3.h | 110 ++--- .../linear_least_squares_fitting_points_3.h | 4 +- .../linear_least_squares_fitting_segments_3.h | 20 +- .../linear_least_squares_fitting_spheres_3.h | 12 +- ...inear_least_squares_fitting_tetrahedra_3.h | 30 +- ...linear_least_squares_fitting_triangles_3.h | 16 +- 11 files changed, 420 insertions(+), 297 deletions(-) diff --git a/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/Mesh.sln b/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/Mesh.sln index 832dede214c..62f1aafdecc 100644 --- a/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/Mesh.sln +++ b/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/Mesh.sln @@ -1,23 +1,21 @@ -Microsoft Visual Studio Solution File, Format Version 8.00 +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Mesh", "Mesh.vcproj", "{83571301-4A1D-4C64-B89E-656467112D87}" - ProjectSection(ProjectDependencies) = postProject - EndProjectSection +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{7A88F6B5-90BD-491B-869E-360370AD28EB}" EndProject Global - GlobalSection(SolutionConfiguration) = preSolution - Debug = Debug - Release = Release + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 EndGlobalSection - GlobalSection(ProjectConfiguration) = postSolution - {83571301-4A1D-4C64-B89E-656467112D87}.Debug.ActiveCfg = Debug|Win32 - {83571301-4A1D-4C64-B89E-656467112D87}.Debug.Build.0 = Debug|Win32 - {83571301-4A1D-4C64-B89E-656467112D87}.Release.ActiveCfg = Release|Win32 - {83571301-4A1D-4C64-B89E-656467112D87}.Release.Build.0 = Release|Win32 + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {83571301-4A1D-4C64-B89E-656467112D87}.Debug|Win32.ActiveCfg = Debug|Win32 + {83571301-4A1D-4C64-B89E-656467112D87}.Debug|Win32.Build.0 = Debug|Win32 + {83571301-4A1D-4C64-B89E-656467112D87}.Release|Win32.ActiveCfg = Release|Win32 + {83571301-4A1D-4C64-B89E-656467112D87}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection - GlobalSection(SolutionItems) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - EndGlobalSection - GlobalSection(ExtensibilityAddIns) = postSolution + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE EndGlobalSection EndGlobal diff --git a/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/Mesh.vcproj b/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/Mesh.vcproj index 9b0aa433b4e..6cc88607e19 100644 --- a/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/Mesh.vcproj +++ b/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/Mesh.vcproj @@ -1,137 +1,198 @@ + Keyword="MFCProj" + > + Name="Win32" + /> + + + CharacterSet="2" + > + + + + + + Detect64BitPortabilityProblems="false" + DebugInformationFormat="3" + /> - - - - - + Name="VCManagedResourceCompilerTool" + /> + AdditionalIncludeDirectories="$(IntDir)" + /> + Name="VCPreLinkEventTool" + /> + Name="VCLinkerTool" + AdditionalDependencies="opengl32.lib glu32.lib" + LinkIncremental="2" + AdditionalLibraryDirectories=""$(CGALROOT)\lib"" + GenerateDebugInformation="true" + SubSystem="2" + TargetMachine="1" + /> + Name="VCALinkTool" + /> + Name="VCManifestTool" + /> + Name="VCXDCMakeTool" + /> + + + + + + CharacterSet="2" + > + Name="VCPreBuildEventTool" + /> + Name="VCCustomBuildTool" + /> + Name="VCXMLDataGeneratorTool" + /> + + MkTypLibCompatible="false" + /> + Name="VCCLCompilerTool" + Optimization="3" + EnableIntrinsicFunctions="true" + FavorSizeOrSpeed="1" + AdditionalIncludeDirectories="..\..\..\..\include;"$(CGALROOT)\include\CGAL\config\msvc";"$(CGALROOT)\include";"$(BOOSTROOT)"" + PreprocessorDefinitions="WIN32;NDEBUG;_SCL_SECURE_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE" + MinimalRebuild="false" + BasicRuntimeChecks="0" + SmallerTypeCheck="false" + RuntimeLibrary="0" + TreatWChar_tAsBuiltInType="true" + RuntimeTypeInfo="true" + UsePrecompiledHeader="2" + WarningLevel="3" + Detect64BitPortabilityProblems="false" + DebugInformationFormat="0" + /> - + Name="VCManagedResourceCompilerTool" + /> + AdditionalIncludeDirectories="$(IntDir)" + /> + Name="VCPreLinkEventTool" + /> + Name="VCLinkerTool" + AdditionalDependencies="opengl32.lib glu32.lib" + LinkIncremental="1" + AdditionalLibraryDirectories=""$(CGALROOT)\lib"" + GenerateDebugInformation="false" + SubSystem="2" + OptimizeReferences="2" + EnableCOMDATFolding="2" + TargetMachine="1" + /> + Name="VCALinkTool" + /> + Name="VCManifestTool" + /> + Name="VCXDCMakeTool" + /> + + + + + @@ -140,197 +201,272 @@ + UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}" + > + RelativePath=".\ChildFrm.cpp" + > + RelativePath=".\DialogOptions.cpp" + > + RelativePath=".\MainFrm.cpp" + > + RelativePath=".\Mesh.cpp" + > + RelativePath=".\MeshDoc.cpp" + > + RelativePath=".\MeshView.cpp" + > + RelativePath=".\stdafx.cpp" + > + Name="Debug|Win32" + > + UsePrecompiledHeader="1" + /> + Name="Release|Win32" + > + UsePrecompiledHeader="1" + /> + RelativePath=".\TextualStatusBar.cpp" + > + UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}" + > + RelativePath=".\ChildFrm.h" + > + RelativePath=".\DialogOptions.h" + > + RelativePath=".\lib\dt3.h" + > + RelativePath="$(CGALROOT)\$(CGALROOT)\include\Cgal\eigen.h" + > + RelativePath=".\MainFrm.h" + > + RelativePath=".\Mesh.h" + > + RelativePath=".\MeshDoc.h" + > + RelativePath=".\MeshView.h" + > + RelativePath=".\Resource.h" + > + RelativePath=".\stdafx.h" + > + RelativePath=".\TextualStatusBar.h" + > + UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}" + > + RelativePath=".\res\idb0.bmp" + > + RelativePath=".\res\idb1.bmp" + > + RelativePath=".\res\idb2.bmp" + > + RelativePath=".\res\idb3.bmp" + > + RelativePath=".\res\idb4.bmp" + > + RelativePath=".\res\idb5.bmp" + > + RelativePath=".\res\idb6.bmp" + > + RelativePath=".\res\idb7.bmp" + > + RelativePath=".\res\idb8.bmp" + > + RelativePath=".\res\Mesh.ico" + > + RelativePath=".\Mesh.rc" + > + RelativePath=".\res\Mesh.rc2" + > + RelativePath=".\res\MeshDoc.ico" + > + RelativePath=".\res\Toolbar.bmp" + > + > + RelativePath=".\lib\enriched_polyhedron.h" + > + > + RelativePath=".\lib\arcball\Arcball.cpp" + > + RelativePath=".\lib\arcball\Arcball.h" + > + RelativePath=".\lib\arcball\Camera.cpp" + > + RelativePath=".\lib\arcball\Camera.h" + > + RelativePath=".\lib\arcball\Matrix44.cpp" + > + RelativePath=".\lib\arcball\Matrix44.h" + > + RelativePath=".\lib\arcball\Quaternion.cpp" + > + RelativePath=".\lib\arcball\Quaternion.h" + > + RelativePath=".\lib\arcball\Vector3d.cpp" + > + RelativePath=".\lib\arcball\Vector3d.h" + > + RelativePath=".\lib\arcball\Viewport.cpp" + > + RelativePath=".\lib\arcball\Viewport.h" + > + DeploymentContent="true" + > + DeploymentContent="true" + > + RelativePath=".\res\Mesh.manifest" + > + + + + + + + RelativePath=".\Mesh.reg" + > + RelativePath=".\ReadMe.txt" + > + Value="Mesh.rc" + /> diff --git a/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/MeshDoc.cpp b/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/MeshDoc.cpp index e2e9e111f7a..9d7769907d1 100644 --- a/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/MeshDoc.cpp +++ b/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/MeshDoc.cpp @@ -245,19 +245,23 @@ void CMeshDoc::OnFitFitpointset() { linear_least_squares_fitting_3(m_points.begin(), m_points.end(), - m_fitting_line); + m_fitting_line, + CGAL::PCA_dimension_0_tag()); linear_least_squares_fitting_3(m_points.begin(), m_points.end(), m_fitting_line, - m_centroid); + m_centroid, + CGAL::PCA_dimension_0_tag()); linear_least_squares_fitting_3(m_points.begin(), m_points.end(), - m_fitting_plane); + m_fitting_plane, + CGAL::PCA_dimension_0_tag()); linear_least_squares_fitting_3(m_points.begin(), m_points.end(), m_fitting_plane, - m_centroid); + m_centroid, + CGAL::PCA_dimension_0_tag()); UpdateAllViews(NULL); } @@ -265,18 +269,22 @@ void CMeshDoc::OnFitTriangleset32899() { linear_least_squares_fitting_3(m_triangles.begin(), m_triangles.end(), - m_fitting_line); + m_fitting_line, + CGAL::PCA_dimension_2_tag()); linear_least_squares_fitting_3(m_triangles.begin(), m_triangles.end(), m_fitting_line, - m_centroid); + m_centroid, + CGAL::PCA_dimension_2_tag()); linear_least_squares_fitting_3(m_triangles.begin(), m_triangles.end(), - m_fitting_plane); + m_fitting_plane, + CGAL::PCA_dimension_2_tag()); linear_least_squares_fitting_3(m_triangles.begin(), m_triangles.end(), m_fitting_plane, - m_centroid); + m_centroid, + CGAL::PCA_dimension_2_tag()); UpdateAllViews(NULL); } diff --git a/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/TextualStatusBar.cpp b/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/TextualStatusBar.cpp index a0b455b6589..27557178f54 100644 --- a/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/TextualStatusBar.cpp +++ b/Principal_component_analysis/demo/Principal_component_analysis/windows/3d/TextualStatusBar.cpp @@ -25,7 +25,6 @@ BEGIN_MESSAGE_MAP(CTextualStatusBar, CStatusBar) //{{AFX_MSG_MAP(CTextualStatusBar) ON_WM_CREATE() ON_WM_DESTROY() - ON_WM_NCHITTEST() //}}AFX_MSG_MAP END_MESSAGE_MAP() @@ -57,27 +56,3 @@ BOOL CTextualStatusBar::PreTranslateMessage(MSG* pMsg) return CStatusBar::PreTranslateMessage(pMsg); } -UINT CTextualStatusBar::OnNcHitTest(CPoint point) -{ - CStatusBarCtrl& statusBar = GetStatusBarCtrl(); - int i = -1; - CRect rectPane; - CPoint ptTmp(point); - ScreenToClient(&ptTmp); - int nCount = GetCount(); - - while (i++ < nCount) - { - statusBar.GetRect(i, rectPane); - if (rectPane.PtInRect(ptTmp) ) - { - CString strTip; - m_wndToolTip.GetText(strTip, this); - LPCTSTR lpPaneText = GetPaneText(i); - if (strTip != lpPaneText) - m_wndToolTip.UpdateTipText(lpPaneText, this); - break; - } - } - return CStatusBar::OnNcHitTest(point); -} diff --git a/Principal_component_analysis/include/CGAL/PCA_util.h b/Principal_component_analysis/include/CGAL/PCA_util.h index 037b78330b9..7141ac4aa59 100644 --- a/Principal_component_analysis/include/CGAL/PCA_util.h +++ b/Principal_component_analysis/include/CGAL/PCA_util.h @@ -91,7 +91,7 @@ assemble_covariance_matrix_3(InputIterator first, InputIterator beyond, typename K::FT covariance[6], // covariance matrix const typename K::Point_3& c, // centroid - const K& , // kernel + const K& k, // kernel const typename K::Triangle_3*,// used for indirection const CGAL::PCA_dimension_2_tag& tag) { @@ -114,7 +114,7 @@ assemble_covariance_matrix_3(InputIterator first, FT temp[9] = {1.0/12.0, 1.0/24.0, 1.0/24.0, 1.0/24.0, 1.0/12.0, 1.0/24.0, 1.0/24.0, 1.0/24.0, 1.0/12.0}; - Matrix moment = init_Matrix(3,temp); + Matrix moment = init_matrix(3,temp); for(InputIterator it = first; it != beyond; @@ -129,7 +129,7 @@ assemble_covariance_matrix_3(InputIterator first, FT delta[9] = {t[0].x(), t[1].x(), t[2].x(), t[0].y(), t[1].y(), t[2].y(), t[0].z(), t[1].z(), t[2].z()}; - Matrix transformation = init_Matrix(3,delta); + Matrix transformation = init_matrix(3,delta); FT area = std::sqrt(t.squared_area()); CGAL_assertion(area != 0.0); @@ -191,7 +191,7 @@ assemble_covariance_matrix_3(InputIterator first, FT temp[9] = {1.0/3.0, 1.0/4.0, 1.0/4.0, 1.0/4.0, 1.0/3.0, 1.0/4.0, 1.0/4.0, 1.0/4.0, 1.0/3.0}; - Matrix moment = init_Matrix(3,temp); + Matrix moment = init_matrix(3,temp); for(InputIterator it = first; it != beyond; @@ -209,7 +209,7 @@ assemble_covariance_matrix_3(InputIterator first, FT delta[9] = {t[1].x()-x0, t[3].x()-x0, t[5].x()-x0, t[1].y()-y0, t[3].y()-y0, t[5].y()-y0, t[1].z()-z0, t[3].z()-z0, t[5].z()-z0}; - Matrix transformation = init_Matrix(3,delta); + Matrix transformation = init_matrix(3,delta); FT volume = t.volume(); CGAL_assertion(volume != 0.0); @@ -276,7 +276,7 @@ assemble_covariance_matrix_3(InputIterator first, FT temp[9] = {7.0/3.0, 1.5, 1.5, 1.5, 7.0/3.0, 1.5, 1.5, 1.5, 7.0/3.0}; - Matrix moment = init_Matrix(3,temp); + Matrix moment = init_matrix(3,temp); for(InputIterator it = first; it != beyond; @@ -294,7 +294,7 @@ assemble_covariance_matrix_3(InputIterator first, FT delta[9] = {t[1].x()-x0, t[3].x()-x0, t[5].x()-x0, t[1].y()-y0, t[3].y()-y0, t[5].y()-y0, t[1].z()-z0, t[3].z()-z0, t[5].z()-z0}; - Matrix transformation = init_Matrix(3,delta); + Matrix transformation = init_matrix(3,delta); FT area = pow(delta[0]*delta[0] + delta[3]*delta[3] + delta[6]*delta[6],1/3.0)*pow(delta[1]*delta[1] + delta[4]*delta[4] + delta[7]*delta[7],1/3.0)*2 + @@ -369,7 +369,7 @@ assemble_covariance_matrix_3(InputIterator first, FT temp[9] = {4.0/15.0, 0.0, 0.0, 0.0, 4.0/15.0, 0.0, 0.0, 0.0, 4.0/15.0}; - Matrix moment = init_Matrix(3,temp); + Matrix moment = init_matrix(3,temp); for(InputIterator it = first; it != beyond; @@ -385,7 +385,7 @@ assemble_covariance_matrix_3(InputIterator first, FT delta[9] = {radius, 0.0, 0.0, 0.0, radius, 0.0, 0.0, 0.0, radius}; - Matrix transformation = init_Matrix(3,delta); + Matrix transformation = init_matrix(3,delta); FT volume = 4/3.0 * radius*t.squared_radius(); CGAL_assertion(volume != 0.0); @@ -451,7 +451,7 @@ assemble_covariance_matrix_3(InputIterator first, FT temp[9] = {4.0/3.0, 0.0, 0.0, 0.0, 4.0/3.0, 0.0, 0.0, 0.0, 4.0/3.0}; - Matrix moment = init_Matrix(3,temp); + Matrix moment = init_matrix(3,temp); for(InputIterator it = first; it != beyond; @@ -467,7 +467,7 @@ assemble_covariance_matrix_3(InputIterator first, FT delta[9] = {radius, 0.0, 0.0, 0.0, radius, 0.0, 0.0, 0.0, radius}; - Matrix transformation = init_Matrix(3,delta); + Matrix transformation = init_matrix(3,delta); FT area = 4 * t.squared_radius(); CGAL_assertion(area != 0.0); @@ -534,7 +534,7 @@ assemble_covariance_matrix_3(InputIterator first, FT temp[9] = {1.0/60.0, 1.0/120.0, 1.0/120.0, 1.0/120.0, 1.0/60.0, 1.0/120.0, 1.0/120.0, 1.0/120.0, 1.0/60.0}; - Matrix moment = init_Matrix(3,temp); + Matrix moment = init_matrix(3,temp); for(InputIterator it = first; it != beyond; @@ -553,7 +553,7 @@ assemble_covariance_matrix_3(InputIterator first, FT delta[9] = {t[1].x()-x0, t[2].x()-x0, t[3].x()-x0, t[1].y()-y0, t[2].y()-y0, t[3].y()-y0, t[1].z()-z0, t[2].z()-z0, t[3].z()-z0}; - Matrix transformation = init_Matrix(3,delta); + Matrix transformation = init_matrix(3,delta); FT volume = t.volume(); CGAL_assertion(volume != 0.0); @@ -620,7 +620,7 @@ assemble_covariance_matrix_3(InputIterator first, FT temp[9] = {1.0, 0.5, 0.0, 0.5, 1.0, 0.0, 0.0, 0.0, 0.0}; - Matrix moment = 1.0/3.0 * init_Matrix(3,temp); + Matrix moment = 1.0/3.0 * init_matrix(3,temp); for(InputIterator it = first; it != beyond; @@ -635,7 +635,7 @@ assemble_covariance_matrix_3(InputIterator first, FT delta[9] = {t[0].x(), t[1].x(), 0.0, t[0].y(), t[1].y(), 0.0, t[0].z(), t[1].z(), 1.0}; - Matrix transformation = init_Matrix(3,delta); + Matrix transformation = init_matrix(3,delta); FT length = std::sqrt(t.squared_length()); CGAL_assertion(length != 0.0); diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_3.h index 13c89002188..fc1b5db3b35 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_3.h @@ -40,77 +40,42 @@ CGAL_BEGIN_NAMESPACE // complete set of parameters template < typename InputIterator, typename Object, - typename K, + typename Kernel, typename Tag > inline -typename K::FT +typename Kernel::FT linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, - typename Object& object, // plane or line - typename K::Point_3& centroid, - const K& kernel, - const Tag& tag) + typename Object& object, // plane or line (result) + typename Kernel::Point_3& centroid, + const Tag& tag, + const Kernel& kernel) { typedef typename std::iterator_traits::value_type Value_type; return CGALi::linear_least_squares_fitting_3(first, beyond, object, centroid, (Value_type*) NULL, kernel, tag); } -// default tag (dimension of fitted objects, ie 1 for segments, 2 for triangles, 3 for tets, etc.) -template < typename InputIterator, - typename Object, - typename K > -inline -typename K::FT -linear_least_squares_fitting_3(InputIterator first, - InputIterator beyond, - typename Object& object, // plane or line - typename K::Point_3& centroid, - const K& kernel) -{ - typedef typename std::iterator_traits::value_type Value_type; - return CGALi::linear_least_squares_fitting_3(first, beyond, object, - centroid, (Value_type*) NULL, kernel); -} - - -// omits centroid -template < typename InputIterator, - typename Object, - typename K, - typename Tag > -inline -typename K::FT -linear_least_squares_fitting_3(InputIterator first, - InputIterator beyond, - Object& object, - const K& kernel, - const Tag& tag) -{ - typedef typename std::iterator_traits::value_type Value_type; - typename K::Point_3 centroid; // unused by caller - return CGALi::linear_least_squares_fitting_3(first, beyond, object, - centroid, (Value_type*) NULL, kernel, tag); -} // deduces kernel from value type of input iterator template < typename InputIterator, typename Object, + typename Point, typename Tag> inline typename Kernel_traits::Kernel::FT linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, Object& object, - typename Kernel_traits::Kernel::Point_3& centroid, + Point& centroid, const Tag& tag) { typedef typename std::iterator_traits::value_type Value_type; - typedef typename Kernel_traits::Kernel K; - return CGAL::linear_least_squares_fitting_3(first,beyond,object,centroid,(Value_type*) NULL,K(),tag); + typedef typename Kernel_traits::Kernel Kernel; + return CGAL::linear_least_squares_fitting_3(first,beyond,object,centroid,tag,Kernel()); } -// does not return the centroid and deduces kernel +// does not writes centroid and deduces kernel template < typename InputIterator, typename Object, typename Tag> @@ -122,9 +87,9 @@ linear_least_squares_fitting_3(InputIterator first, const Tag& tag) { typedef typename std::iterator_traits::value_type Value_type; - typedef typename Kernel_traits::Kernel K; - typename K::Point_3 centroid; // unused by caller - return CGAL::linear_least_squares_fitting_3(first,beyond,object,centroid,K(),tag); + typedef typename Kernel_traits::Kernel Kernel; + typename Kernel::Point_3 centroid; // unused by caller + return CGAL::linear_least_squares_fitting_3(first,beyond,object,centroid,tag); } // does not return the centroid, deduces kernel, and default tag @@ -139,8 +104,8 @@ linear_least_squares_fitting_3(InputIterator first, Object& object) { typedef typename std::iterator_traits::value_type Value_type; - typedef typename Kernel_traits::Kernel K; - typename K::Point_3 centroid; // unused by caller + typedef typename Kernel_traits::Kernel Kernel; + typename Kernel::Point_3 centroid; // unused by caller return CGAL::linear_least_squares_fitting_3(first,beyond,object,centroid,(Value_type *)NULL,K()); }*/ @@ -176,7 +141,48 @@ linear_least_squares_fitting_3(InputIterator first, } // BOOST_STATIC_ASSERT((boost::is_same::Algebraic_category,CGAL::Field_with_sqrt_tag>::value)); -*/ + + // default tag (dimension of fitted objects, ie 1 for segments, 2 for triangles, 3 for tets, etc.) +template < typename InputIterator, + typename Object, + typename Kernel > +inline +typename Kernel::FT +linear_least_squares_fitting_3(InputIterator first, + InputIterator beyond, + typename Object& object, // plane or line + typename Kernel::Point_3& centroid, + const Kernel& kernel) +{ + typedef typename std::iterator_traits::value_type Value_type; + return CGALi::linear_least_squares_fitting_3(first, beyond, object, + centroid, (Value_type*) NULL, kernel); +} + + + +// omits centroid +template < typename InputIterator, + typename Object, + typename Kernel, + typename Tag > +inline +typename Kernel::FT +linear_least_squares_fitting_3(InputIterator first, + InputIterator beyond, + Object& object, + const Kernel& kernel, + const Tag& tag) +{ + typedef typename std::iterator_traits::value_type Value_type; + typename Kernel::Point_3 centroid; // unused by caller + return CGALi::linear_least_squares_fitting_3(first, beyond, object, + centroid, (Value_type*) NULL, kernel, tag); +} + + + + */ CGAL_END_NAMESPACE diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_3.h index 5568c072179..cf8b8bd0c64 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_points_3.h @@ -41,8 +41,8 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Plane_3& plane, // best fit plane typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Point_3*, // used for indirection + const K& k, // kernel const CGAL::PCA_dimension_0_tag& tag = CGAL::PCA_dimension_0_tag()) { typedef typename K::FT FT; @@ -75,8 +75,8 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Line_3& line, // best fit line typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Point_3*, // used for indirection + const K& k, // kernel const CGAL::PCA_dimension_0_tag& tag = CGAL::PCA_dimension_0_tag) { typedef typename K::FT FT; diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_3.h index cace4d3d298..ec7e26f77ae 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_segments_3.h @@ -39,9 +39,9 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Plane_3& plane, // best fit plane typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Segment_3*, // used for indirection - const CGAL::PCA_dimension_1_tag& tag = CGAL::PCA_dimension_1_tag()) + const K& k, // kernel + const CGAL::PCA_dimension_1_tag& tag) { typedef typename K::FT FT; typedef typename K::Segment_3 Segment; @@ -69,8 +69,8 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Plane_3& plane, // best fit plane typename K::Point_3& c, // centroid + const typename K::Segment_3*, // used for indirection const K& k, // kernel - const typename K::Segment_3*, // used for indirection const CGAL::PCA_dimension_0_tag& tag) { typedef typename K::FT FT; @@ -101,11 +101,11 @@ template < typename InputIterator, typename K::FT linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, - typename K::Line_3& line, // best fit line - typename K::Point_3& c, // centroid - const K& k, // kernel + typename K::Line_3& line, // best fit line + typename K::Point_3& c, // centroid const typename K::Segment_3*, // used for indirection - const CGAL::PCA_dimension_1_tag& tag = CGAL::PCA_dimension_1_tag()) + const K& k, // kernel + const CGAL::PCA_dimension_1_tag& tag) { typedef typename K::FT FT; typedef typename K::Segment_3 Segment; @@ -131,10 +131,10 @@ template < typename InputIterator, typename K::FT linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, - typename K::Line_3& line, // best fit plane - typename K::Point_3& c, // centroid - const K& k, // kernel + typename K::Line_3& line, // best fit line + typename K::Point_3& c, // centroid const typename K::Segment_3*, // used for indirection + const K& k, // kernel const CGAL::PCA_dimension_0_tag& tag) { typedef typename K::FT FT; diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_spheres_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_spheres_3.h index d4529fa23f6..d728e762557 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_spheres_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_spheres_3.h @@ -39,9 +39,9 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Plane_3& plane, // best fit plane typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Sphere_3*, // used for indirection - const CGAL::PCA_dimension_3_tag& tag = CGAL::PCA_dimension_3_tag()) + const K& k, // kernel + const CGAL::PCA_dimension_3_tag& tag) { typedef typename K::FT FT; typedef typename K::Sphere_3 Sphere; @@ -69,8 +69,8 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Plane_3& plane, // best fit plane typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Sphere_3*, // used for indirection + const K& k, // kernel const CGAL::PCA_dimension_2_tag& tag) { typedef typename K::FT FT; @@ -100,9 +100,9 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Line_3& line, // best fit line typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Sphere_3*, // used for indirection - const CGAL::PCA_dimension_3_tag& tag = CGAL::PCA_dimension_3_tag()) + const K& k, // kernel + const CGAL::PCA_dimension_3_tag& tag) { typedef typename K::FT FT; typedef typename K::Sphere_3 Sphere; @@ -131,8 +131,8 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Line_3& line, // best fit line typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Sphere_3*, // used for indirection + const K& k, // kernel const CGAL::PCA_dimension_2_tag& tag) { typedef typename K::FT FT; diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_tetrahedra_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_tetrahedra_3.h index f343882861c..de5a1ca37f4 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_tetrahedra_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_tetrahedra_3.h @@ -39,9 +39,9 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Plane_3& plane, // best fit plane typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Tetrahedron_3*, // used for indirection - const CGAL::PCA_dimension_3_tag& tag = CGAL::PCA_dimension_3_tag()) + const K& k, // kernel + const CGAL::PCA_dimension_3_tag& tag) { typedef typename K::FT FT; typedef typename K::Tetrahedron_3 Tetrahedron; @@ -70,8 +70,8 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Plane_3& plane, // best fit plane typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Tetrahedron_3*, // used for indirection + const K& k, // kernel const CGAL::PCA_dimension_2_tag& tag) { typedef typename K::FT FT; @@ -106,9 +106,9 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Plane_3& plane, // best fit plane typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Tetrahedron_3*, // used for indirection - const CGAL::PCA_dimension_1_tag& tag) + const K& k, // kernel + const CGAL::PCA_dimension_1_tag& tag) { typedef typename K::FT FT; typedef typename K::Tetrahedron_3 Tetrahedron; @@ -144,9 +144,9 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Plane_3& plane, // best fit plane typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Tetrahedron_3*, // used for indirection - const CGAL::PCA_dimension_0_tag& tag) + const K& k, // kernel + const CGAL::PCA_dimension_0_tag& tag) { typedef typename K::FT FT; typedef typename K::Tetrahedron_3 Tetrahedron; @@ -180,9 +180,9 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Line_3& line, // best fit line typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Tetrahedron_3*, // used for indirection - const CGAL::PCA_dimension_3_tag& tag = CGAL::PCA_dimension_3_tag()) + const K& k, // kernel + const CGAL::PCA_dimension_3_tag& tag) { typedef typename K::FT FT; typedef typename K::Tetrahedron_3 Tetrahedron; @@ -210,9 +210,9 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Line_3& line, // best fit line typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Tetrahedron_3*, // used for indirection - const CGAL::PCA_dimension_2_tag& tag) + const K& k, // kernel + const CGAL::PCA_dimension_2_tag& tag) { typedef typename K::FT FT; typedef typename K::Tetrahedron_3 Tetrahedron; @@ -246,9 +246,9 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Line_3& line, // best fit line typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Tetrahedron_3*, // used for indirection - const CGAL::PCA_dimension_1_tag& tag) + const K& k, // kernel + const CGAL::PCA_dimension_1_tag& tag) { typedef typename K::FT FT; typedef typename K::Tetrahedron_3 Tetrahedron; @@ -284,9 +284,9 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Line_3& line, // best fit line typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Tetrahedron_3*, // used for indirection - const CGAL::PCA_dimension_0_tag& tag) + const K& k, // kernel + const CGAL::PCA_dimension_0_tag& tag) { typedef typename K::FT FT; typedef typename K::Tetrahedron_3 Tetrahedron; diff --git a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_3.h b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_3.h index 2b15bb8f397..6bab479993b 100644 --- a/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_3.h +++ b/Principal_component_analysis/include/CGAL/linear_least_squares_fitting_triangles_3.h @@ -39,9 +39,9 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Plane_3& plane, // best fit plane typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Triangle_3*, // used for indirection - const CGAL::PCA_dimension_2_tag& tag = CGAL::PCA_dimension_2_tag()) + const K& k, // kernel + const CGAL::PCA_dimension_2_tag& tag) { typedef typename K::FT FT; typedef typename K::Triangle_3 Triangle; @@ -69,8 +69,8 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Plane_3& plane, // best fit plane typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Triangle_3*, // used for indirection + const K& k, // kernel const CGAL::PCA_dimension_1_tag& tag) { typedef typename K::FT FT; @@ -104,8 +104,8 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Plane_3& plane, // best fit plane typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Triangle_3*, // used for indirection + const K& k, // kernel const CGAL::PCA_dimension_0_tag& tag) { typedef typename K::FT FT; @@ -139,9 +139,9 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Line_3& line, // best fit line typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Triangle_3*, // used for indirection - const CGAL::PCA_dimension_2_tag& tag = CGAL::PCA_dimension_2_tag()) + const K& k, // kernel + const CGAL::PCA_dimension_2_tag& tag) { typedef typename K::FT FT; typedef typename K::Triangle_3 Triangle; @@ -169,8 +169,8 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Line_3& line, // best fit line typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Triangle_3*, // used for indirection + const K& k, // kernel const CGAL::PCA_dimension_1_tag& tag) { typedef typename K::FT FT; @@ -204,8 +204,8 @@ linear_least_squares_fitting_3(InputIterator first, InputIterator beyond, typename K::Line_3& line, // best fit line typename K::Point_3& c, // centroid - const K& k, // kernel const typename K::Triangle_3*, // used for indirection + const K& k, // kernel const CGAL::PCA_dimension_0_tag& tag) { typedef typename K::FT FT;