├── .gitattributes ├── LICENSE ├── README.md ├── prebuilt-win32 └── mod-11.07-win32.rar ├── project_urban.jpg ├── src └── BldRecons │ ├── .gitignore │ ├── BPFitPlane │ ├── .gitignore │ ├── BPCloud.cpp │ ├── BPCloud.h │ ├── BPFitPlane.cpp │ ├── BPFitPlane.vcproj │ ├── BPGrid.cpp │ ├── BPGrid.h │ ├── ParamManager.cpp │ ├── ParamManager.h │ ├── ReadMe.txt │ ├── stdafx.cpp │ └── stdafx.h │ ├── BPO2SimpOBJ │ ├── .gitignore │ ├── AuxOutline.cpp │ ├── AuxOutline.h │ ├── BPO2SimpOBJ.cpp │ ├── BPO2SimpOBJ.vcproj │ ├── HistGrid.cpp │ ├── HistGrid.h │ ├── OutlineSimplifier.cpp │ ├── OutlineSimplifier.h │ ├── ParamManager.cpp │ ├── ParamManager.h │ ├── ReadMe.txt │ ├── stdafx.cpp │ └── stdafx.h │ ├── BPO2UnSimpOBJ │ ├── .gitignore │ ├── BPO2UnSimpOBJ.cpp │ ├── BPO2UnSimpOBJ.vcproj │ ├── ParamManager.cpp │ ├── ParamManager.h │ ├── ReadMe.txt │ ├── stdafx.cpp │ └── stdafx.h │ ├── BPO2XML │ └── .gitignore │ ├── BPOHist │ ├── .gitignore │ ├── BPOHist.cpp │ ├── BPOHist.vcproj │ ├── HistGrid.cpp │ ├── HistGrid.h │ ├── ParamManager.cpp │ ├── ParamManager.h │ ├── ReadMe.txt │ ├── stdafx.cpp │ └── stdafx.h │ ├── BldRecons.sln │ ├── Common │ ├── .gitignore │ ├── Common.vcproj │ ├── Geometry │ │ ├── BoundingBox.cpp │ │ ├── BoundingBox.h │ │ ├── IndexingGrid.cpp │ │ ├── IndexingGrid.h │ │ ├── LinePlane.h │ │ ├── Mesh.cpp │ │ ├── Mesh.h │ │ ├── Outline.cpp │ │ ├── Outline.h │ │ ├── PointCloud.cpp │ │ ├── PointCloud.h │ │ ├── Vector3D.cpp │ │ └── Vector3D.h │ ├── Grid │ │ ├── StreamingGrid.cpp │ │ └── StreamingGrid.h │ ├── Include │ │ └── liblas │ │ │ ├── capi │ │ │ ├── las_config.h │ │ │ ├── las_version.h │ │ │ └── liblas.h │ │ │ ├── cstdint.hpp │ │ │ ├── detail │ │ │ ├── endian.hpp │ │ │ ├── file.hpp │ │ │ ├── fwd.hpp │ │ │ ├── reader.hpp │ │ │ ├── reader10.hpp │ │ │ ├── reader11.hpp │ │ │ ├── sha1.hpp │ │ │ ├── sharedptr.hpp │ │ │ ├── timer.hpp │ │ │ ├── utility.hpp │ │ │ ├── writer.hpp │ │ │ ├── writer10.hpp │ │ │ └── writer11.hpp │ │ │ ├── exception.hpp │ │ │ ├── guid.hpp │ │ │ ├── iterator.hpp │ │ │ ├── laserror.hpp │ │ │ ├── lasfile.hpp │ │ │ ├── lasheader.hpp │ │ │ ├── laspoint.hpp │ │ │ ├── lasreader.hpp │ │ │ ├── lasrecordheader.hpp │ │ │ ├── laswriter.hpp │ │ │ └── liblas.hpp │ ├── Lidar │ │ └── LidarCommon.h │ ├── Miscs │ │ ├── BPCommon.h │ │ ├── BPOCommon.h │ │ ├── BPOReader.cpp │ │ ├── BPOReader.h │ │ ├── BPOWriter.cpp │ │ ├── BPOWriter.h │ │ ├── BPReader.cpp │ │ ├── BPReader.h │ │ ├── BPWriter.cpp │ │ ├── BPWriter.h │ │ ├── HistCommon.h │ │ ├── HistReader.cpp │ │ ├── HistReader.h │ │ ├── HistWriter.cpp │ │ ├── HistWriter.h │ │ ├── Histogram.cpp │ │ ├── Histogram.h │ │ ├── MeshWriter.cpp │ │ ├── MeshWriter.h │ │ ├── NumericalSolver.cpp │ │ ├── NumericalSolver.h │ │ ├── OBJWriter.cpp │ │ ├── OBJWriter.h │ │ ├── TimeMeter.cpp │ │ └── TimeMeter.h │ ├── ReadMe.txt │ ├── Streaming │ │ ├── SPACommon.h │ │ ├── SPAReader.cpp │ │ ├── SPAReader.h │ │ ├── SPAWriter.cpp │ │ ├── SPAWriter.h │ │ ├── SPBCommon.h │ │ ├── SPBReader.cpp │ │ ├── SPBReader.h │ │ ├── SPBWriter.cpp │ │ ├── SPBWriter.h │ │ ├── SPCommon.h │ │ ├── SPReader.cpp │ │ ├── SPReader.h │ │ ├── SPWriter.cpp │ │ └── SPWriter.h │ ├── stdafx.cpp │ └── stdafx.h │ ├── DualContouring │ ├── .gitignore │ ├── DCContourer.cpp │ ├── DCContourer.h │ ├── DCGrid.cpp │ ├── DCGrid.h │ ├── DCGridCluster.cpp │ ├── DCGridGeometry.cpp │ ├── DCGridHermiteData.cpp │ ├── DCGridNumerical.cpp │ ├── DCGridPrint.cpp │ ├── DCGridSort.cpp │ ├── DualContouring.cpp │ ├── DualContouring.vcproj │ ├── HistGrid.cpp │ ├── HistGrid.h │ ├── MeshBoundary.cpp │ ├── MeshBoundary.h │ ├── ParamManager.cpp │ ├── ParamManager.h │ ├── ReadMe.txt │ ├── nr │ │ ├── nr.h │ │ ├── nrutil.c │ │ └── nrutil.h │ ├── stdafx.cpp │ └── stdafx.h │ ├── LASFinalize │ ├── .gitignore │ ├── FinalizeGrid.cpp │ ├── FinalizeGrid.h │ ├── LASFinalize.cpp │ ├── LASFinalize.vcproj │ ├── ParamManager.cpp │ ├── ParamManager.h │ ├── ReadMe.txt │ ├── stdafx.cpp │ └── stdafx.h │ ├── LasLib │ ├── .gitignore │ ├── LasLib.vcproj │ ├── ReadMe.txt │ └── src │ │ ├── detail │ │ ├── file.cpp │ │ ├── reader.cpp │ │ ├── reader10.cpp │ │ ├── reader11.cpp │ │ ├── writer.cpp │ │ ├── writer10.cpp │ │ └── writer11.cpp │ │ ├── las_c_api.cpp │ │ ├── laserror.cpp │ │ ├── lasfile.cpp │ │ ├── lasheader.cpp │ │ ├── laspoint.cpp │ │ ├── lasreader.cpp │ │ ├── lasrecordheader.cpp │ │ └── laswriter.cpp │ ├── ManifoldContouring │ ├── .gitignore │ ├── HistGrid.cpp │ ├── HistGrid.h │ ├── MCBoundary.cpp │ ├── MCBoundary.h │ ├── MCContourer.cpp │ ├── MCContourer.h │ ├── MCGrid.cpp │ ├── MCGrid.h │ ├── MCGridCluster.cpp │ ├── MCGridFeature.cpp │ ├── MCGridGeometry.cpp │ ├── MCGridHermiteData.cpp │ ├── MCGridNumerical.cpp │ ├── MCGridPrint.cpp │ ├── MCGridSort.cpp │ ├── ManifoldContouring.cpp │ ├── ManifoldContouring.vcproj │ ├── MeshBoundary.cpp │ ├── MeshBoundary.h │ ├── ParamManager.cpp │ ├── ParamManager.h │ ├── ReadMe.txt │ ├── nr │ │ ├── nr.h │ │ ├── nrutil.c │ │ └── nrutil.h │ ├── stdafx.cpp │ └── stdafx.h │ ├── Miscs │ └── peak.m │ ├── README.txt │ ├── SPA2LAS │ ├── .gitignore │ ├── ParamManager.cpp │ ├── ParamManager.h │ ├── ReadMe.txt │ ├── SPA2LAS.cpp │ ├── SPA2LAS.vcproj │ ├── stdafx.cpp │ └── stdafx.h │ ├── SPB2BP │ ├── .gitignore │ ├── ConvertChunk.cpp │ ├── ConvertChunk.h │ ├── ConvertGrid.cpp │ ├── ConvertGrid.h │ ├── ParamManager.cpp │ ├── ParamManager.h │ ├── ReadMe.txt │ ├── SPB2BP.cpp │ ├── SPB2BP.vcproj │ ├── stdafx.cpp │ └── stdafx.h │ ├── SPB2LAS │ ├── .gitignore │ ├── ParamManager.cpp │ ├── ParamManager.h │ ├── ReadMe.txt │ ├── SPB2LAS.cpp │ ├── SPB2LAS.vcproj │ ├── stdafx.cpp │ └── stdafx.h │ ├── SPB2OBJ │ ├── .gitignore │ ├── MeshChunk.cpp │ ├── MeshChunk.h │ ├── MeshGrid.cpp │ ├── MeshGrid.h │ ├── ParamManager.cpp │ ├── ParamManager.h │ ├── ReadMe.txt │ ├── SPB2OBJ.cpp │ ├── SPB2OBJ.vcproj │ ├── stdafx.cpp │ └── stdafx.h │ ├── SPClassify │ ├── .gitignore │ ├── ClassifyChunk.cpp │ ├── ClassifyChunk.h │ ├── ClassifyGrid.cpp │ ├── ClassifyGrid.h │ ├── FeatureCalculator.cpp │ ├── FeatureCalculator.h │ ├── ParamManager.cpp │ ├── ParamManager.h │ ├── ReadMe.txt │ ├── SPClassify.cpp │ ├── SPClassify.vcproj │ ├── stdafx.cpp │ └── stdafx.h │ ├── SPInfo │ ├── .gitignore │ ├── ReadMe.txt │ ├── SPInfo.cpp │ ├── SPInfo.vcproj │ ├── stdafx.cpp │ └── stdafx.h │ ├── SPSplit │ ├── .gitignore │ ├── FixedPatchSet.cpp │ ├── FixedPatchSet.h │ ├── ParamManager.cpp │ ├── ParamManager.h │ ├── ReadMe.txt │ ├── RefineChunk.cpp │ ├── RefineChunk.h │ ├── RefineGrid.cpp │ ├── RefineGrid.h │ ├── SPSplit.cpp │ ├── SPSplit.vcproj │ ├── SplitChunk.cpp │ ├── SplitChunk.h │ ├── SplitGrid.cpp │ ├── SplitGrid.h │ ├── stdafx.cpp │ └── stdafx.h │ ├── config.ini │ ├── huma │ ├── .gitignore │ ├── ChildFrm.cpp │ ├── ChildFrm.h │ ├── Common │ │ ├── COMMON.CPP │ │ ├── COMMON.H │ │ ├── Geometry.cpp │ │ └── Geometry.h │ ├── Display │ │ ├── Display.cpp │ │ ├── Display.h │ │ ├── scene.cpp │ │ └── scene.h │ ├── DlgInput.cpp │ ├── DlgInput.h │ ├── MainFrm.cpp │ ├── MainFrm.h │ ├── Model │ │ ├── mesh.cpp │ │ ├── mesh.h │ │ └── model.h │ ├── ReadMe.txt │ ├── Resource.h │ ├── StdAfx.cpp │ ├── StdAfx.h │ ├── Worker │ │ ├── Worker.cpp │ │ └── Worker.h │ ├── huma.cpp │ ├── huma.h │ ├── huma.rc │ ├── huma.sln │ ├── huma.vcproj │ ├── humaDoc.cpp │ ├── humaDoc.h │ ├── humaView.cpp │ ├── humaView.h │ └── res │ │ ├── Toolbar.bmp │ │ ├── huma.ico │ │ ├── huma.rc2 │ │ └── humaDoc.ico │ └── install.bat └── src_dualcontouring ├── DCContourer.cpp ├── DCContourer.h ├── DCGrid.cpp ├── DCGrid.h ├── DCGridCluster.cpp ├── DCGridGeometry.cpp ├── DCGridHermiteData.cpp ├── DCGridNumerical.cpp ├── DCGridSort.cpp ├── Debug └── config.ini ├── DualContouring.cpp ├── DualContouring.sln ├── DualContouring.vcproj ├── ParamManager.cpp ├── ParamManager.h ├── ReadMe.txt ├── Release └── config.ini ├── common ├── BoundingBox.cpp ├── BoundingBox.h ├── IndexingGrid.cpp ├── IndexingGrid.h ├── Mesh.cpp ├── Mesh.h ├── MeshWriter.cpp ├── MeshWriter.h ├── PointCloud.cpp ├── PointCloud.h ├── Vector3D.cpp └── Vector3D.h ├── config.ini ├── nr ├── nr.h ├── nrutil.c └── nrutil.h ├── stdafx.cpp ├── stdafx.h └── targetver.h /.gitattributes: -------------------------------------------------------------------------------- 1 | *.rar filter=lfs diff=lfs merge=lfs -text 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 Qianyi Zhou 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /prebuilt-win32/mod-11.07-win32.rar: -------------------------------------------------------------------------------- 1 | version https://git-lfs.github.com/spec/v1 2 | oid sha256:f91fb7ec967a3718de79ffc6f481233f6ec901cfd367b51a07f8147dc2a2c5bf 3 | size 196322951 4 | -------------------------------------------------------------------------------- /project_urban.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianyizh/UrbanReconstruction/8b058349fd860ea9029623a92d705dd93a4e4878/project_urban.jpg -------------------------------------------------------------------------------- /src/BldRecons/.gitignore: -------------------------------------------------------------------------------- 1 | /*.ncb 2 | /*.suo 3 | /Debug/ 4 | /Release/ 5 | -------------------------------------------------------------------------------- /src/BldRecons/BPFitPlane/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/BPFitPlane/BPCloud.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "BPCloud.h" 3 | 4 | CBPCloud::CBPCloud(void) 5 | { 6 | } 7 | 8 | CBPCloud::~CBPCloud(void) 9 | { 10 | } 11 | 12 | void CBPCloud::LoadFromBP( char filename[] ) 13 | { 14 | 15 | m_cReader.OpenFile( filename ); 16 | BPHeader header = m_cReader.ReadHeader(); 17 | 18 | m_n64Patch = header.patch; 19 | m_dbGridLength = header.grid_length; 20 | m_dbGroundZ = header.ground_z; 21 | m_cBoundingBox.Reset(); 22 | 23 | m_vecPoint.clear(); 24 | m_vecPoint.resize( header.number ); 25 | 26 | for ( int i = 0; i < header.number; i++ ) { 27 | BPPoint point = m_cReader.ReadPoint(); 28 | 29 | m_vecPoint[ i ].type = PT_Building; 30 | m_vecPoint[ i ].patch.base = point.plane; 31 | m_vecPoint[ i ].patch.num = 0; 32 | m_vecPoint[ i ].v = CVector3D( point.pos ); 33 | m_vecPoint[ i ].n = CVector3D( point.n ); 34 | m_vecPoint[ i ].flatness = point.flatness; 35 | 36 | m_cBoundingBox.Push( m_vecPoint[ i ].v ); 37 | } 38 | 39 | m_cReader.CloseFile(); 40 | 41 | m_nUnitNumber[ 0 ] = ( int )( m_cBoundingBox.GetLength( 0 ) / m_dbGridLength ) + 3; 42 | m_nUnitNumber[ 1 ] = ( int )( m_cBoundingBox.GetLength( 1 ) / m_dbGridLength ) + 3; 43 | 44 | } 45 | 46 | void CBPCloud::SaveToBP( char filename[] ) 47 | { 48 | 49 | m_cWriter.OpenFile( filename ); 50 | 51 | m_cWriter.WriteHeader( m_n64Patch, ( int )m_vecPoint.size(), m_dbGroundZ, m_dbGridLength ); 52 | 53 | for ( int i = 0; i < ( int )m_vecPoint.size(); i++ ) { 54 | BPPoint point; 55 | 56 | point.plane = m_vecPoint[ i ].patch.base; 57 | point.flatness = m_vecPoint[ i ].flatness; 58 | point.pos[ 0 ] = m_vecPoint[ i ].v[ 0 ]; 59 | point.pos[ 1 ] = m_vecPoint[ i ].v[ 1 ]; 60 | point.pos[ 2 ] = m_vecPoint[ i ].v[ 2 ]; 61 | point.n[ 0 ] = m_vecPoint[ i ].n[ 0 ]; 62 | point.n[ 1 ] = m_vecPoint[ i ].n[ 1 ]; 63 | point.n[ 2 ] = m_vecPoint[ i ].n[ 2 ]; 64 | 65 | m_cWriter.WritePoint( point ); 66 | } 67 | 68 | m_cWriter.CloseFile(); 69 | 70 | } 71 | -------------------------------------------------------------------------------- /src/BldRecons/BPFitPlane/BPCloud.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Geometry\BoundingBox.h" 4 | #include "Geometry\Outline.h" 5 | #include "Lidar\LidarCommon.h" 6 | #include "Miscs\BPReader.h" 7 | #include "Miscs\BPWriter.h" 8 | 9 | class CBPCloud 10 | { 11 | public: 12 | CBPCloud(void); 13 | ~CBPCloud(void); 14 | 15 | public: 16 | std::vector< PatchPointData > m_vecPoint; 17 | CBPReader m_cReader; 18 | CBPWriter m_cWriter; 19 | CBoundingBox m_cBoundingBox; 20 | PatchIndex m_n64Patch; 21 | double m_dbGridLength; 22 | double m_dbGroundZ; 23 | int m_nUnitNumber[ 2 ]; 24 | 25 | public: 26 | void LoadFromBP( char filename[] ); 27 | void SaveToBP( char filename[] ); 28 | }; 29 | -------------------------------------------------------------------------------- /src/BldRecons/BPFitPlane/BPFitPlane.cpp: -------------------------------------------------------------------------------- 1 | // BPFitPlane.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "ParamManager.h" 6 | #include "BPCloud.h" 7 | #include "BPGrid.h" 8 | 9 | void main(int argc, char * argv[]) 10 | { 11 | 12 | CParamManager * manager = CParamManager::GetParamManager(); 13 | manager->RegisterCommandLine( argc, argv ); 14 | 15 | char pSearch[ 1024 ]; 16 | sprintf_s( pSearch, 1024, "%s*.bp", manager->m_pWorkingDir ); 17 | 18 | WIN32_FIND_DATA finder; 19 | HANDLE handle = FindFirstFile( pSearch, & finder ); 20 | BOOL not_finished = ( handle != INVALID_HANDLE_VALUE ); 21 | 22 | while ( not_finished ) { 23 | 24 | if ( strcmp( finder.cFileName, "." ) != 0 && strcmp( finder.cFileName, ".." ) != 0 ) { 25 | 26 | if ( ( finder.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) != FILE_ATTRIBUTE_DIRECTORY ) { 27 | 28 | fprintf_s( stderr, "Processing %s ... ", finder.cFileName ); 29 | 30 | char filename[ 1024 ]; 31 | memset( filename, 0, 1024 ); 32 | sprintf_s( filename, 1024, "%s%s", manager->m_pWorkingDir, finder.cFileName ); 33 | CBPCloud cloud; 34 | CBPGrid grid( & cloud ); 35 | cloud.LoadFromBP( filename ); 36 | 37 | grid.BuildGridIndex(); 38 | grid.PlaneFitting_RegionGrow(); 39 | grid.GenerateOutline(); 40 | 41 | cloud.SaveToBP( filename ); 42 | 43 | sprintf_s( filename, 1024, "%s%so", manager->m_pWorkingDir, finder.cFileName ); 44 | grid.WriteOutline( filename ); 45 | 46 | fprintf_s( stderr, "done.\n" ); 47 | 48 | } 49 | 50 | not_finished = FindNextFile( handle, &finder ); 51 | 52 | } 53 | 54 | } 55 | 56 | FindClose( handle ); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /src/BldRecons/BPFitPlane/BPGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "BPCloud.h" 4 | #include "Geometry\Outline.h" 5 | 6 | typedef std::vector< int > PatchVector; 7 | 8 | class CBPGrid 9 | { 10 | public: 11 | CBPGrid( CBPCloud * pCloud ); 12 | ~CBPGrid(void); 13 | 14 | public: 15 | std::vector< PatchPointDataVector > m_vecGridIndex; 16 | std::vector< PatchVector > m_vecGridPatch; 17 | std::vector< CPlane > m_vecPlane; 18 | std::vector< COutline > m_vecOutline; 19 | 20 | protected: 21 | CBPCloud * m_pCloud; 22 | 23 | public: 24 | void BuildGridIndex(); 25 | void PlaneFitting_RegionGrow(); 26 | void GenerateOutline(); 27 | void WriteOutline( char filename[] ); 28 | 29 | protected: 30 | int Index( const CVector3D & v ); 31 | int Index( int x, int y ); 32 | int IndexX( const CVector3D & v ); 33 | int IndexY( const CVector3D & v ); 34 | void RegularizeX( int & x ); 35 | void RegularizeY( int & y ); 36 | 37 | protected: 38 | CPlane FitPlane( PatchPointDataVector & data ); 39 | void RollBack( PatchPointDataVector & data ); 40 | void PlaneFitting_RegionGrow_NormalCheck( CPlane & plane, PatchPointDataVector & data_nc, PatchPointData & seed ); 41 | void PlaneFitting_RegionGrow_DoubleCheck( CPlane & plane, PatchPointDataVector & data_nc, PatchPointDataVector & data_dc, PatchPointData & seed ); 42 | 43 | protected: 44 | bool CheckPatchVector( int index, int patch ); 45 | void PushPatchVector( int index, int patch ); 46 | 47 | protected: 48 | void InitOutline(); 49 | void GenerateSingleOutline( int plane_index ); 50 | }; 51 | -------------------------------------------------------------------------------- /src/BldRecons/BPFitPlane/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define __pi 3.1415926535897932384626 6 | #define __arc(x) (x) / 180.0 * __pi 7 | 8 | struct PlaneFittingParam { 9 | double m_dbSeedMaxFlat; 10 | double m_dbAngleMaxDifference; 11 | double m_dbMaxDistance; 12 | double m_nAcceptPointNumber; 13 | 14 | double m_dbCosAngleMaxDifference; 15 | 16 | static const int m_nPlaneFitting_RegionGrow_NormalCheck_IterationStep = 3; 17 | }; 18 | 19 | class CParamManager 20 | { 21 | public: 22 | CParamManager(void); 23 | ~CParamManager(void); 24 | 25 | protected: 26 | static CParamManager * singletonInstance; 27 | 28 | public: 29 | static CParamManager * GetParamManager( void ) 30 | { 31 | if ( singletonInstance == NULL ) 32 | { 33 | singletonInstance = new CParamManager( ); 34 | } 35 | return singletonInstance; 36 | } 37 | 38 | void RegisterCommandLine( int argc, char * argv[] ); 39 | 40 | private: 41 | void GetNames(); 42 | void LoadConfiguration(); 43 | 44 | public: 45 | char m_pExeName[ 1024 ]; 46 | char m_pTrueName[ 1024 ]; 47 | char m_pDirName[ 1024 ]; 48 | char m_pIniName[ 1024 ]; 49 | 50 | char m_pWorkingDir[ 1024 ]; 51 | 52 | PlaneFittingParam m_cFittingParam; 53 | 54 | int m_nOutlineNeighbor; 55 | }; 56 | -------------------------------------------------------------------------------- /src/BldRecons/BPFitPlane/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : BPFitPlane Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this BPFitPlane application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your BPFitPlane application. 9 | 10 | 11 | BPFitPlane.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | BPFitPlane.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named BPFitPlane.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/BPFitPlane/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BPFitPlane.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/BPFitPlane/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | // TODO: reference additional headers your program requires here 19 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2SimpOBJ/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2SimpOBJ/AuxOutline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Geometry\Outline.h" 4 | 5 | struct AuxLine { 6 | CLine line; 7 | std::vector< int > vi; 8 | bool snapped; 9 | 10 | AuxLine() : snapped( false ) {} 11 | }; 12 | 13 | class CAuxOutline 14 | { 15 | public: 16 | CAuxOutline(void); 17 | ~CAuxOutline(void); 18 | 19 | public: 20 | COutline * m_pOutline; 21 | std::vector< AuxLine > m_vecLine; 22 | std::vector< int > m_vecLineIndex; 23 | 24 | public: 25 | void RegisterOutline( COutline * outline ); 26 | void ProduceOutline( COutline & outline ); 27 | 28 | private: 29 | bool CheckDistance2D( CVector3D & v, CVector3D & v0, double corner_tolerance ); 30 | bool CheckAngle2D( CVector3D & v, int l0, int l1, double cos_angle_tolerance ); 31 | 32 | private: 33 | ////////////////////////////////////////////////////////////////////////// 34 | // Basic querying structure for CAuxOutline 35 | // 36 | // line -> vertex : m_vecLine::vi 37 | // vertex -> line : m_vecLineIndex 38 | // line -> first vertex : m_vecLine::vi[0] 39 | // line -> last vertex : m_vecLine::vi[n-1] 40 | // line -> prev line : m_vecLineIndex[ m_vecLine::vi[0]::prev ] 41 | // line -> next line : m_vecLineIndex[ m_vecLine::vi[n-1]::next ] 42 | ////////////////////////////////////////////////////////////////////////// 43 | int Line_VertexIndex( int l, int k ) { return m_vecLine[ l ].vi[ k ]; } 44 | int Vertex_LineIndex( int v ) { return m_vecLineIndex[ v ]; } 45 | 46 | int Line_FirstVertexIndex( int l ) { 47 | return m_vecLine[ l ].vi[ 0 ]; 48 | } 49 | int Line_LastVertexIndex( int l ) { 50 | return m_vecLine[ l ].vi.back(); 51 | } 52 | 53 | int Line_PrevLineIndex( int l ) { 54 | int first_v = Line_FirstVertexIndex( l ); 55 | int prev_v = m_pOutline->m_vecVertex[ first_v ].prev; 56 | return m_vecLineIndex[ prev_v ]; 57 | } 58 | int Line_NextLineIndex( int l ) { 59 | int last_v = Line_LastVertexIndex( l ); 60 | int next_v = m_pOutline->m_vecVertex[ last_v ].next; 61 | return m_vecLineIndex[ next_v ]; 62 | } 63 | }; 64 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2SimpOBJ/BPO2SimpOBJ.cpp: -------------------------------------------------------------------------------- 1 | // BPO2SimpOBJ.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "ParamManager.h" 6 | #include "HistGrid.h" 7 | 8 | void main( int argc, char * argv[] ) 9 | { 10 | 11 | CParamManager * manager = CParamManager::GetParamManager(); 12 | manager->RegisterCommandLine( argc, argv ); 13 | 14 | CHistGrid grid; 15 | 16 | grid.Init(); 17 | 18 | grid.Simplify(); 19 | 20 | } 21 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2SimpOBJ/HistGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Geometry\Vector3D.h" 4 | #include "Geometry\BoundingBox.h" 5 | #include "Geometry\Outline.h" 6 | #include "Miscs\Histogram.h" 7 | #include "Miscs\HistWriter.h" 8 | #include "Miscs\HistReader.h" 9 | #include "AuxOutline.h" 10 | 11 | class CHistGrid 12 | { 13 | public: 14 | CHistGrid(void); 15 | ~CHistGrid(void); 16 | 17 | public: 18 | std::vector< CVector3D > m_vecCenter; 19 | std::vector< CHistogram > m_vecHistogram; 20 | CBoundingBox m_cBoundingBox; 21 | int m_nGridNumber[ 2 ]; 22 | CHistWriter m_cWriter; 23 | CHistReader m_cReader; 24 | HistHeader m_cHeader; 25 | 26 | public: 27 | void Init(); 28 | void Simplify(); 29 | 30 | private: 31 | void LoadFromHist( char filename[] ); 32 | CHistogram & LocateHistogram( CVector3D & v ); 33 | 34 | private: 35 | void SimplifyOutline( std::vector< COutline > & vecOutline, std::vector< COutline > & vecSimpOutline ); 36 | void SnapLines( std::vector< CAuxOutline > & vecAuxOutline, std::vector< COutline > & vecOutline ); 37 | 38 | private: 39 | // fitting along principal directions 40 | int FittingPrincipalDirection( COutline & outline, CAuxOutline & aux, std::vector< int > & vertex_loop ); 41 | 42 | private: 43 | int CompareVector2D( CVector3D & v0, CVector3D & v1 ) { 44 | if ( v0[0] > v1[0] ) { 45 | return 1; 46 | } else if ( v0[0] == v1[0] ) { 47 | if ( v0[1] > v1[1] ) 48 | return 1; 49 | else if ( v0[1] == v1[1] ) 50 | return 0; 51 | else 52 | return -1; 53 | } else { 54 | return -1; 55 | } 56 | } 57 | }; 58 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2SimpOBJ/OutlineSimplifier.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Geometry\Outline.h" 4 | #include "AuxOutline.h" 5 | #include "ParamManager.h" 6 | 7 | struct LineSearchStructure { 8 | CLine line; 9 | int s, e; 10 | bool valid; 11 | }; 12 | 13 | class COutlineSimplifier 14 | { 15 | public: 16 | COutlineSimplifier(void); 17 | ~COutlineSimplifier(void); 18 | 19 | public: 20 | static int Simplify( COutline & outline, CAuxOutline & aux, std::vector< int > & vlist, double tolerance, CParamManager::LineFittingMode fitting_mode = CParamManager::LFM_DirectConnect ); 21 | 22 | private: 23 | static CLine LineFitting_DirectConnect( COutline & outline, std::vector< int > & vlist, int s, int e ); 24 | static CLine LineFitting_LeastSquare( COutline & outline, std::vector< int > & vlist, int s, int e ); 25 | static bool CheckTolerance( COutline & outline, std::vector< int > & vlist, int s, int e, CLine & line, double tolerance ); 26 | }; 27 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2SimpOBJ/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define __pi 3.1415926535897932384626 6 | #define __arc(x) (x) / 180.0 * __pi 7 | 8 | class CParamManager 9 | { 10 | public: 11 | CParamManager(void); 12 | ~CParamManager(void); 13 | 14 | public: 15 | enum LineFittingMode { LFM_DirectConnect, LFM_LeastSquare }; 16 | 17 | protected: 18 | static CParamManager * singletonInstance; 19 | 20 | public: 21 | static CParamManager * GetParamManager( void ) 22 | { 23 | if ( singletonInstance == NULL ) 24 | { 25 | singletonInstance = new CParamManager( ); 26 | } 27 | return singletonInstance; 28 | } 29 | 30 | void RegisterCommandLine( int argc, char * argv[] ); 31 | 32 | private: 33 | void GetNames(); 34 | void LoadConfiguration(); 35 | 36 | public: 37 | char m_pExeName[ 1024 ]; 38 | char m_pTrueName[ 1024 ]; 39 | char m_pDirName[ 1024 ]; 40 | char m_pIniName[ 1024 ]; 41 | 42 | char m_pWorkingDir[ 1024 ]; 43 | char m_pSPBFile[ 1024 ]; 44 | char m_pHistFile[ 1024 ]; 45 | 46 | int m_nSegmentMinimumPointNumber; 47 | double m_dbLineErrorTolerance; 48 | double m_dbCornerErrorTolerance; 49 | double m_dbCornerAngleTolerance; 50 | double m_dbCosCornerAngleTolerance; 51 | LineFittingMode m_nFittingMode; 52 | bool m_bLineSnapping; 53 | bool m_bWallRectangle; 54 | 55 | static const int m_nLineFitting_IterationStep = 3; 56 | }; 57 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2SimpOBJ/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : BPO2SimpOBJ Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this BPO2SimpOBJ application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your BPO2SimpOBJ application. 9 | 10 | 11 | BPO2SimpOBJ.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | BPO2SimpOBJ.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named BPO2SimpOBJ.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2SimpOBJ/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BPO2SimpOBJ.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2SimpOBJ/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | 14 | #include 15 | 16 | 17 | // TODO: reference additional headers your program requires here 18 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2UnSimpOBJ/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2UnSimpOBJ/BPO2UnSimpOBJ.cpp: -------------------------------------------------------------------------------- 1 | // BPO2OBJ.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "Geometry\Outline.h" 6 | #include "Miscs\BPOReader.h" 7 | #include "Miscs\OBJWriter.h" 8 | #include "ParamManager.h" 9 | 10 | void main( int argc, char * argv[] ) 11 | { 12 | 13 | CParamManager * manager = CParamManager::GetParamManager(); 14 | manager->RegisterCommandLine( argc, argv ); 15 | 16 | char pSearch[ 1024 ]; 17 | sprintf_s( pSearch, 1024, "%s*.bpo", manager->m_pWorkingDir ); 18 | 19 | WIN32_FIND_DATA finder; 20 | HANDLE handle = FindFirstFile( pSearch, & finder ); 21 | BOOL not_finished = ( handle != INVALID_HANDLE_VALUE ); 22 | 23 | while ( not_finished ) { 24 | 25 | if ( strcmp( finder.cFileName, "." ) != 0 && strcmp( finder.cFileName, ".." ) != 0 ) { 26 | 27 | if ( ( finder.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) != FILE_ATTRIBUTE_DIRECTORY ) { 28 | 29 | fprintf_s( stderr, "Processing %s ... ", finder.cFileName ); 30 | 31 | char filename[ 1024 ]; 32 | memset( filename, 0, 1024 ); 33 | sprintf_s( filename, 1024, "%s%s", manager->m_pWorkingDir, finder.cFileName ); 34 | CBPOReader reader; 35 | reader.OpenFile( filename ); 36 | 37 | char truename[ 1024 ]; 38 | memset( truename, 0, 1024 ); 39 | strncat_s( truename, 1024, filename, strlen( filename ) - 3 ); 40 | sprintf_s( filename, "%sobj", truename ); 41 | COBJWriter writer; 42 | writer.OpenFile( filename ); 43 | 44 | BPOHeader header = reader.ReadHeader(); 45 | std::vector< COutline > vecOutline( header.number ); 46 | 47 | writer.WriteHeader(); 48 | 49 | for ( int i = 0; i < header.number; i++ ) { 50 | reader.ReadOutline( vecOutline[ i ] ); 51 | writer.WriteOutline( vecOutline[ i ], header.ground_z, manager->m_bWallRectangle ); 52 | } 53 | 54 | reader.CloseFile(); 55 | writer.CloseFile(); 56 | 57 | fprintf_s( stderr, "done.\n" ); 58 | 59 | } 60 | 61 | not_finished = FindNextFile( handle, &finder ); 62 | 63 | } 64 | 65 | } 66 | 67 | FindClose( handle ); 68 | 69 | } 70 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2UnSimpOBJ/ParamManager.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include 3 | #include 4 | #include "ParamManager.h" 5 | #include 6 | 7 | CParamManager::CParamManager(void) 8 | { 9 | GetNames(); 10 | LoadConfiguration(); 11 | } 12 | 13 | CParamManager::~CParamManager(void) 14 | { 15 | } 16 | 17 | void CParamManager::GetNames() 18 | { 19 | USES_CONVERSION; 20 | 21 | memset( m_pExeName, 0, sizeof(char) * 1024 ); 22 | memset( m_pDirName, 0, sizeof(char) * 1024 ); 23 | memset( m_pTrueName, 0, sizeof(char) * 1024 ); 24 | memset( m_pIniName, 0, sizeof(char) * 1024 ); 25 | 26 | TCHAR pFileName[MAX_PATH]; 27 | ::GetModuleFileName( NULL, pFileName, MAX_PATH ); 28 | sprintf_s( m_pExeName, 1024, T2A( pFileName ) ); 29 | 30 | _getcwd(m_pDirName, sizeof(m_pDirName)); 31 | 32 | char * pTemp = strrchr( m_pExeName, '\\' ); 33 | pTemp = strrchr( m_pExeName, '.' ); 34 | strncat_s( m_pTrueName, 1024, m_pExeName, pTemp - m_pExeName ); 35 | 36 | sprintf_s( m_pIniName, 1024, "%s\\config.ini", m_pDirName ); 37 | } 38 | 39 | void CParamManager::LoadConfiguration() 40 | { 41 | const int MAX_STRING = 1024; 42 | //char pString[ MAX_STRING ]; 43 | 44 | // m_pWorkingDir 45 | ::GetPrivateProfileStringA( "BPO2UnSimpOBJ", "WorkingDir", "C:\\Lidar\\", m_pWorkingDir, 1024, m_pIniName ); 46 | 47 | // m_bWallRectangle 48 | m_bWallRectangle = ( bool )::GetPrivateProfileIntA( "BPO2UnSimpOBJ", "WallRectangle", 0, m_pIniName ); 49 | } 50 | 51 | void CParamManager::RegisterCommandLine( int argc, char *argv[] ) 52 | { 53 | if ( argc > 1 ) { 54 | sprintf_s( m_pWorkingDir, 1024, "%s", argv[ 1 ] ); 55 | } 56 | } 57 | 58 | CParamManager * CParamManager::singletonInstance = NULL; 59 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2UnSimpOBJ/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define __pi 3.1415926535897932384626 6 | #define __arc(x) (x) / 180.0 * __pi 7 | 8 | class CParamManager 9 | { 10 | public: 11 | CParamManager(void); 12 | ~CParamManager(void); 13 | 14 | protected: 15 | static CParamManager * singletonInstance; 16 | 17 | public: 18 | static CParamManager * GetParamManager( void ) 19 | { 20 | if ( singletonInstance == NULL ) 21 | { 22 | singletonInstance = new CParamManager( ); 23 | } 24 | return singletonInstance; 25 | } 26 | 27 | void RegisterCommandLine( int argc, char * argv[] ); 28 | 29 | private: 30 | void GetNames(); 31 | void LoadConfiguration(); 32 | 33 | public: 34 | char m_pExeName[ 1024 ]; 35 | char m_pTrueName[ 1024 ]; 36 | char m_pDirName[ 1024 ]; 37 | char m_pIniName[ 1024 ]; 38 | 39 | char m_pWorkingDir[ 1024 ]; 40 | 41 | bool m_bWallRectangle; 42 | }; 43 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2UnSimpOBJ/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : BPO2OBJ Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this BPO2OBJ application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your BPO2OBJ application. 9 | 10 | 11 | BPO2OBJ.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | BPO2OBJ.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named BPO2OBJ.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2UnSimpOBJ/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BPO2OBJ.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2UnSimpOBJ/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | 14 | #include 15 | 16 | 17 | // TODO: reference additional headers your program requires here 18 | -------------------------------------------------------------------------------- /src/BldRecons/BPO2XML/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/BPOHist/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/BPOHist/BPOHist.cpp: -------------------------------------------------------------------------------- 1 | // BPOHist.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "HistGrid.h" 6 | #include "ParamManager.h" 7 | 8 | void main( int argc, char * argv[] ) 9 | { 10 | 11 | CParamManager * manager = CParamManager::GetParamManager(); 12 | manager->RegisterCommandLine( argc, argv ); 13 | 14 | CHistGrid grid; 15 | 16 | grid.Init(); 17 | 18 | grid.Count(); 19 | 20 | grid.SaveToHist( manager->m_pOutputFile ); 21 | 22 | // grid.Debug_SaveToTxt(); 23 | 24 | } 25 | -------------------------------------------------------------------------------- /src/BldRecons/BPOHist/HistGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Geometry\Vector3D.h" 4 | #include "Geometry\BoundingBox.h" 5 | #include "Miscs\Histogram.h" 6 | #include "Miscs\HistWriter.h" 7 | #include "Miscs\HistReader.h" 8 | 9 | class CHistGrid 10 | { 11 | public: 12 | CHistGrid(void); 13 | ~CHistGrid(void); 14 | 15 | public: 16 | std::vector< CVector3D > m_vecCenter; 17 | std::vector< CHistogram > m_vecHistogram; 18 | CBoundingBox m_cBoundingBox; 19 | int m_nGridNumber[ 2 ]; 20 | CHistWriter m_cWriter; 21 | CHistReader m_cReader; 22 | 23 | public: 24 | void Init(); 25 | void Count(); 26 | 27 | public: 28 | void SaveToHist( char filename[] ); 29 | 30 | private: 31 | double GetAngle( CVector3D & d ); 32 | 33 | public: 34 | void Debug_SaveToTxt(); 35 | }; 36 | -------------------------------------------------------------------------------- /src/BldRecons/BPOHist/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define __pi 3.1415926535897932384626 6 | #define __arc(x) (x) / 180.0 * __pi 7 | 8 | class CParamManager 9 | { 10 | public: 11 | CParamManager(void); 12 | ~CParamManager(void); 13 | 14 | protected: 15 | static CParamManager * singletonInstance; 16 | 17 | public: 18 | static CParamManager * GetParamManager( void ) 19 | { 20 | if ( singletonInstance == NULL ) 21 | { 22 | singletonInstance = new CParamManager( ); 23 | } 24 | return singletonInstance; 25 | } 26 | 27 | void RegisterCommandLine( int argc, char * argv[] ); 28 | 29 | private: 30 | void GetNames(); 31 | void LoadConfiguration(); 32 | 33 | public: 34 | char m_pExeName[ 1024 ]; 35 | char m_pTrueName[ 1024 ]; 36 | char m_pDirName[ 1024 ]; 37 | char m_pIniName[ 1024 ]; 38 | 39 | char m_pWorkingDir[ 1024 ]; 40 | char m_pSPBFile[ 1024 ]; 41 | char m_pOutputFile[ 1024 ]; 42 | 43 | int m_nHistogramPrecision; 44 | double m_dbCenterDistance; 45 | double m_dbHistogramDistance; 46 | double m_dbHistogramSmoothSigma; 47 | double m_dbHistogramPeakTolerance; 48 | }; 49 | -------------------------------------------------------------------------------- /src/BldRecons/BPOHist/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : BPOHist Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this BPOHist application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your BPOHist application. 9 | 10 | 11 | BPOHist.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | BPOHist.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named BPOHist.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/BPOHist/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // BPOHist.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/BPOHist/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | 14 | #include 15 | 16 | 17 | // TODO: reference additional headers your program requires here 18 | -------------------------------------------------------------------------------- /src/BldRecons/Common/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Geometry/BoundingBox.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include ".\boundingbox.h" 3 | 4 | CBoundingBox::CBoundingBox(void) 5 | { 6 | Reset(); 7 | } 8 | 9 | CBoundingBox::~CBoundingBox(void) 10 | { 11 | } 12 | 13 | void CBoundingBox::Reset() 14 | { 15 | m_vMin[0] = m_vMin[1] = m_vMin[2] = 1e10; 16 | m_vMax[0] = m_vMax[1] = m_vMax[2] = -1e10; 17 | } 18 | 19 | void CBoundingBox::Push( float m_fVertex[3] ) 20 | { 21 | for (int i = 0; i < 3; i++) { 22 | if (m_fVertex[i] < m_vMin[i]) 23 | m_vMin[i] = m_fVertex[i]; 24 | if (m_fVertex[i] > m_vMax[i]) 25 | m_vMax[i] = m_fVertex[i]; 26 | } 27 | } 28 | 29 | void CBoundingBox::Push( double m_dbVertex[3] ) 30 | { 31 | for (int i = 0; i < 3; i++) { 32 | if (m_dbVertex[i] < m_vMin[i]) 33 | m_vMin[i] = m_dbVertex[i]; 34 | if (m_dbVertex[i] > m_vMax[i]) 35 | m_vMax[i] = m_dbVertex[i]; 36 | } 37 | } 38 | 39 | void CBoundingBox::Push( const CVector3D & v ) 40 | { 41 | for (int i = 0; i < 3; i++) { 42 | if (v.pVec[i] < m_vMin[i]) 43 | m_vMin[i] = v.pVec[i]; 44 | if (v.pVec[i] > m_vMax[i]) 45 | m_vMax[i] = v.pVec[i]; 46 | } 47 | } 48 | 49 | CVector3D CBoundingBox::GetPosition() 50 | { 51 | return CVector3D( 52 | (m_vMin[0] + m_vMax[0]) / 2.0, 53 | (m_vMin[1] + m_vMax[1]) / 2.0, 54 | (m_vMin[2] + m_vMax[2]) / 2.0 55 | ); 56 | } 57 | 58 | double CBoundingBox::GetLength() 59 | { 60 | double temp[3] = { m_vMax[0] - m_vMin[0], m_vMax[1] - m_vMin[1], m_vMax[2] - m_vMin[2] }; 61 | return __max( temp[2], __max( temp[0], temp[1] ) ); 62 | } 63 | 64 | double CBoundingBox::GetLength( int i ) 65 | { 66 | return m_vMax[ i ] - m_vMin[ i ]; 67 | } 68 | 69 | CVector3D CBoundingBox::GetCorner(int i, int j, int k) 70 | { 71 | CVector3D vPos = GetPosition(); 72 | double dbLength = GetLength(); 73 | return vPos + CVector3D( 74 | (i - 0.5) * dbLength, 75 | (j - 0.5) * dbLength, 76 | (k - 0.5) * dbLength 77 | ); 78 | } 79 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Geometry/BoundingBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vector3D.h" 4 | 5 | class CBoundingBox 6 | { 7 | public: 8 | CBoundingBox(void); 9 | ~CBoundingBox(void); 10 | 11 | public: 12 | CVector3D m_vMin; 13 | CVector3D m_vMax; 14 | 15 | void Reset(); 16 | void Push( float m_fVertex[3] ); 17 | void Push( double m_dbVertex[3] ); 18 | void Push( const CVector3D & v ); 19 | CVector3D GetPosition(); 20 | double GetLength(); 21 | double GetLength( int i ); 22 | CVector3D GetCorner(int i, int j, int k); 23 | 24 | void PrintInfo() { 25 | fprintf_s( stderr, "Bounding Box:\n\tFrom : ( %.2f, %.2f, %.2f )\n\tTo : ( %.2f, %.2f, %.2f )\n", m_vMin[0], m_vMin[1], m_vMin[2], m_vMax[0], m_vMax[1], m_vMax[2] ); 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Geometry/IndexingGrid.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "IndexingGrid.h" 3 | 4 | CIndexingGrid::CIndexingGrid(void) 5 | { 6 | } 7 | 8 | CIndexingGrid::~CIndexingGrid(void) 9 | { 10 | } 11 | 12 | void CIndexingGrid::BuildIndexingGrid( CPointCloud * pointcloud, double unit_length ) 13 | { 14 | m_pPointCloud = pointcloud; 15 | m_dbGridLength = unit_length; 16 | CBoundingBox & box = pointcloud->m_cBoundingBox; 17 | 18 | // setup protected boundary 19 | m_nWidth = ( int )( box.GetLength( 0 ) / unit_length ) + 1 + 2; 20 | m_nHeight = ( int )( box.GetLength( 1 ) / unit_length ) + 1 + 2; 21 | 22 | // create index 23 | CreateIndex(); 24 | } 25 | 26 | void CIndexingGrid::CreateIndex() 27 | { 28 | m_vecIndex.clear(); 29 | m_vecIndex.resize( m_nWidth * m_nHeight ); 30 | 31 | for ( int i = 0; i < ( int )m_pPointCloud->m_vecPoint.size(); i++ ) { 32 | CVector3D & v = m_pPointCloud->m_vecPoint[ i ]; 33 | m_vecIndex[ Index( v[ 0 ], v[ 1 ] ) ].push_back( i ); 34 | } 35 | } -------------------------------------------------------------------------------- /src/BldRecons/Common/Geometry/IndexingGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Geometry\PointCloud.h" 6 | #include "Geometry\BoundingBox.h" 7 | 8 | ////////////////////////////////////////////////////////////////////////// 9 | // This is a indexing grid with PROTECTED boundary 10 | // Boundary cells are guaranteed to be empty cells 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | class CIndexingGrid 14 | { 15 | public: 16 | typedef std::vector< int > Grid_Index; 17 | 18 | public: 19 | CIndexingGrid(void); 20 | ~CIndexingGrid(void); 21 | 22 | public: 23 | CPointCloud * m_pPointCloud; 24 | 25 | int m_nWidth; 26 | int m_nHeight; 27 | double m_dbGridLength; 28 | 29 | std::vector< Grid_Index > m_vecIndex; 30 | 31 | public: 32 | void BuildIndexingGrid( CPointCloud * pointcloud, double unit_length ); 33 | 34 | protected: 35 | void CreateIndex(); 36 | 37 | protected: 38 | int XtoI( double x ) { 39 | int i = ( int )( ( x - m_pPointCloud->m_cBoundingBox.m_vMin[ 0 ] ) / m_dbGridLength ) + 1; 40 | if ( i < 1 ) i = 1; 41 | if ( i >= m_nWidth - 1 ) i = m_nWidth - 2; 42 | return i; 43 | } 44 | int YtoJ( double y ) { 45 | int j = ( int )( ( y - m_pPointCloud->m_cBoundingBox.m_vMin[ 1 ] ) / m_dbGridLength ) + 1; 46 | if ( j < 1 ) j = 1; 47 | if ( j >= m_nHeight - 1 ) j = m_nHeight - 2; 48 | return j; 49 | } 50 | 51 | bool IIsValid( int i ) { 52 | return ( i >= 0 && i < m_nWidth ); 53 | } 54 | bool JIsValid( int j ) { 55 | return ( j >= 0 && j < m_nHeight ); 56 | } 57 | 58 | int Index( int i, int j ) { 59 | return ( i * m_nHeight + j ); 60 | } 61 | 62 | int Index( double x, double y ) { 63 | return Index( XtoI( x ), YtoJ( y ) ); 64 | } 65 | 66 | int GetI( int index ) { 67 | return index / m_nHeight; 68 | } 69 | 70 | int GetJ( int index ) { 71 | return index % m_nHeight; 72 | } 73 | }; 74 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Geometry/LinePlane.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vector3D.h" 4 | 5 | class CLine 6 | { 7 | public: 8 | CVector3D p; // p[2] == 0 9 | CVector3D d; // d[2] == 0, |d| == 1 10 | 11 | double dis( CVector3D & v ) { 12 | CVector3D n( d[ 1 ], -d[ 0 ], 0.0 ); 13 | return abs( ( v - p ) * n ); 14 | } 15 | 16 | CVector3D n() { 17 | return CVector3D( d[ 1 ], -d[ 0 ], 0.0 ); 18 | } 19 | 20 | CVector3D project( CVector3D & v ) { 21 | CVector3D n( d[ 1 ], -d[ 0 ], 0.0 ); 22 | return ( v - ( ( v - p ) * n ) * n ); 23 | } 24 | 25 | bool check( CVector3D & v, double tolerance ) { 26 | return dis( v ) < tolerance; 27 | } 28 | 29 | friend CVector3D operator^( CLine & line0, CLine & line1 ) { 30 | CVector3D vtemp; 31 | 32 | double c0 = line0.d[0]; 33 | double s0 = line0.d[1]; 34 | double c1 = line1.d[0]; 35 | double s1 = line1.d[1]; 36 | 37 | if ( abs( s0 * c1 - s1 * c0 ) < DOUBLE_TOLERANCE ) { 38 | return CVector3D::INFINITE_VECTOR3D; 39 | } 40 | 41 | CVector3D & v0 = line0.p; 42 | CVector3D & v1 = line1.p; 43 | 44 | vtemp[0] = ( c0 * c1 * ( v1[1] - v0[1] ) + s0 * c1 * v0[0] - s1 * c0 * v1[0] ) / ( s0 * c1 - s1 * c0 ); 45 | vtemp[1] = ( s0 * s1 * ( v1[0] - v0[0] ) + c0 * s1 * v0[1] - c1 * s0 * v1[1] ) / ( c0 * s1 - c1 * s0 ); 46 | vtemp[2] = 0.0; 47 | 48 | return vtemp; 49 | } 50 | }; 51 | 52 | class CPlane 53 | { 54 | public: 55 | CVector3D pos; 56 | CVector3D norm; // |norm| = 1 57 | int index; 58 | 59 | double dis( CVector3D & v ) { 60 | return ( v - pos ) * norm; 61 | } 62 | 63 | CVector3D project( CVector3D & v ) { 64 | return ( v - dis( v ) * norm ); 65 | } 66 | 67 | CVector3D onplane( CVector3D & v ) { 68 | if ( abs( norm[ 2 ] ) < DOUBLE_TOLERANCE ) 69 | return CVector3D::INFINITE_VECTOR3D; 70 | else 71 | return CVector3D( v[0], v[1], pos[2] - ( norm[0] * ( v[0] - pos[0] ) + norm[1] * ( v[1] - pos[1] ) ) / norm[2] ); 72 | } 73 | }; 74 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Geometry/Mesh.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Mesh.h" 3 | 4 | #include "Miscs\MeshWriter.h" 5 | 6 | CMesh::CMesh(void) 7 | { 8 | } 9 | 10 | CMesh::~CMesh(void) 11 | { 12 | } 13 | 14 | void CMesh::SaveToObj( char filename[] ) 15 | { 16 | CMeshWriter writer; 17 | writer.OpenFile( filename ); 18 | writer.WriteHeader(); 19 | 20 | for ( int i = 0; i < ( int )m_vecVertex.size(); i++ ) { 21 | writer.WriteVertex( m_vecVertex[ i ].v.pVec ); 22 | } 23 | 24 | for ( int i = 0; i < ( int )m_vecTriangle.size(); i++ ) { 25 | writer.WriteFace( m_vecTriangle[ i ].i ); 26 | } 27 | 28 | for ( int i = 0; i < ( int )m_vecQuad.size(); i++ ) { 29 | writer.WriteQuad( m_vecQuad[ i ].i, false ); 30 | } 31 | 32 | writer.CloseFile(); 33 | } -------------------------------------------------------------------------------- /src/BldRecons/Common/Geometry/Mesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Geometry\Vector3D.h" 6 | 7 | class CMesh 8 | { 9 | public: 10 | CMesh(void); 11 | ~CMesh(void); 12 | 13 | public: 14 | struct MeshVertex { 15 | CVector3D v; 16 | MeshVertex( const CVector3D & vv ) : v( vv ) { } 17 | MeshVertex() {} 18 | }; 19 | struct MeshTriangle { 20 | int i[ 3 ]; 21 | MeshTriangle( int i0, int i1, int i2 ) { 22 | i[ 0 ] = i0; 23 | i[ 1 ] = i1; 24 | i[ 2 ] = i2; 25 | } 26 | MeshTriangle() {} 27 | }; 28 | struct MeshQuad { 29 | int i[ 4 ]; 30 | MeshQuad( int i0, int i1, int i2, int i3 ) { 31 | i[ 0 ] = i0; 32 | i[ 1 ] = i1; 33 | i[ 2 ] = i2; 34 | i[ 3 ] = i3; 35 | } 36 | MeshQuad() {} 37 | }; 38 | 39 | public: 40 | std::vector< MeshVertex > m_vecVertex; 41 | std::vector< MeshTriangle > m_vecTriangle; 42 | std::vector< MeshQuad > m_vecQuad; 43 | 44 | public: 45 | void SaveToObj( char filename[] ); 46 | }; 47 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Geometry/Outline.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "LinePlane.h" 6 | 7 | class COutlineVertex 8 | { 9 | public: 10 | CVector3D v; 11 | CVector3D d; 12 | int prev; 13 | int next; 14 | }; 15 | 16 | class COutlineTriangle 17 | { 18 | public: 19 | int vi[ 3 ]; 20 | 21 | public: 22 | COutlineTriangle() { 23 | } 24 | COutlineTriangle( int i, int j, int k ) { 25 | vi[0] = i; vi[1] = j; vi[2] = k; 26 | } 27 | }; 28 | 29 | class COutline 30 | { 31 | public: 32 | COutline(void); 33 | ~COutline(void); 34 | 35 | public: 36 | CPlane m_cPlane; 37 | std::vector< COutlineVertex > m_vecVertex; 38 | std::vector< COutlineTriangle > m_vecRoofTriangle; 39 | 40 | public: 41 | void Add( int v0, int v1 ); 42 | void ComputeDirection( int nNeighbor ); 43 | void Save( FILE * pFile ); 44 | void Load( FILE * pFile ); 45 | 46 | public: 47 | void GenerateRoofTriangle(); 48 | 49 | void WriteOBJVertex( FILE * pFile, double ground_z ); 50 | void WriteOBJFace( FILE * pFile, int offset, bool wall_rectangle ); 51 | 52 | private: 53 | bool InPolygon( double x, double y, int n, const double * px, const double * py ); 54 | }; 55 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Geometry/PointCloud.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "PointCloud.h" 3 | #include "Miscs\BPReader.h" 4 | #include "Miscs\BPWriter.h" 5 | 6 | CPointCloud::CPointCloud(void) 7 | { 8 | } 9 | 10 | CPointCloud::~CPointCloud(void) 11 | { 12 | } 13 | 14 | void CPointCloud::LoadFromBP( char filename[] ) 15 | { 16 | 17 | CBPReader reader; 18 | 19 | reader.OpenFile( filename ); 20 | BPHeader header = reader.ReadHeader(); 21 | 22 | m_dbGroundZ = header.ground_z; 23 | m_cBoundingBox.Reset(); 24 | 25 | m_vecPoint.clear(); 26 | m_vecPoint.resize( header.number ); 27 | m_vecNormal.clear(); 28 | m_vecNormal.resize( header.number ); 29 | 30 | for ( int i = 0; i < header.number; i++ ) { 31 | BPPoint point = reader.ReadPoint(); 32 | 33 | m_vecPoint[ i ] = CVector3D( point.pos ); 34 | m_vecNormal[ i ] = CVector3D( point.n ); 35 | 36 | m_cBoundingBox.Push( m_vecPoint[ i ] ); 37 | } 38 | 39 | reader.CloseFile(); 40 | 41 | } 42 | 43 | void CPointCloud::LoadFromXYZN( char filename[] ) 44 | { 45 | m_cBoundingBox.Reset(); 46 | 47 | m_vecPoint.clear(); 48 | m_vecNormal.clear(); 49 | 50 | FILE * file; 51 | fopen_s( & file, filename, "r" ); 52 | 53 | char buf[ 1024 ]; 54 | double x, y, z, nx, ny, nz; 55 | while ( fgets( buf, 1024, file ) != NULL ) { 56 | if ( buf[ 0 ] == '#' ) { 57 | if ( strncmp( buf, "# ground ", 9 ) == 0 ) { 58 | sscanf_s( & buf[ 9 ], "%lf", & m_dbGroundZ ); 59 | } 60 | } else { 61 | sscanf_s( buf, "%lf %lf %lf %lf %lf %lf", &x, &y, &z, &nx, &ny, &nz ); 62 | m_vecPoint.push_back( CVector3D( x, y, z ) ); 63 | m_vecNormal.push_back( CVector3D( nx, ny, nz ) ); 64 | 65 | m_cBoundingBox.Push( m_vecPoint.back() ); 66 | } 67 | } 68 | 69 | fclose( file ); 70 | } 71 | 72 | void CPointCloud::SaveToXYZN( char filename[] ) 73 | { 74 | FILE * file; 75 | fopen_s( & file, filename, "w" ); 76 | 77 | fprintf_s( file, "# ground %.10f\n", m_dbGroundZ ); 78 | 79 | for ( int i = 0; i < ( int )m_vecPoint.size(); i++ ) { 80 | CVector3D & p = m_vecPoint[ i ]; 81 | CVector3D & n = m_vecNormal[ i ]; 82 | fprintf_s( file, "%.10f %.10f %.10f %.10f %.10f %.10f\n", p[ 0 ], p[ 1 ], p[ 2 ], n[ 0 ], n[ 1 ], n[ 2 ] ); 83 | } 84 | 85 | fclose( file ); 86 | } -------------------------------------------------------------------------------- /src/BldRecons/Common/Geometry/PointCloud.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Geometry\Vector3D.h" 6 | #include "Geometry\BoundingBox.h" 7 | #include "Lidar\LidarCommon.h" 8 | 9 | class CPointCloud 10 | { 11 | public: 12 | CPointCloud(void); 13 | ~CPointCloud(void); 14 | 15 | public: 16 | std::vector< CVector3D > m_vecPoint; 17 | std::vector< CVector3D > m_vecNormal; 18 | 19 | CBoundingBox m_cBoundingBox; 20 | double m_dbGroundZ; 21 | 22 | public: 23 | void LoadFromBP( char filename[] ); 24 | void LoadFromXYZN( char filename[] ); 25 | void SaveToXYZN( char filename[] ); 26 | }; 27 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Geometry/Vector3D.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include ".\Vector3D.h" 3 | 4 | CVector3D& CVector3D::operator=(const CVector3D& v) 5 | { 6 | pVec[0] = v.pVec[0]; pVec[1] = v.pVec[1]; pVec[2] = v.pVec[2]; 7 | return (*this); 8 | } 9 | CVector3D& CVector3D::operator+=(const CVector3D& v) 10 | { 11 | pVec[0] += v.pVec[0]; pVec[1] += v.pVec[1]; pVec[2] += v.pVec[2]; 12 | return (*this); 13 | } 14 | CVector3D& CVector3D::operator-=(const CVector3D& v) 15 | { 16 | pVec[0] -= v.pVec[0]; pVec[1] -= v.pVec[1]; pVec[2] -= v.pVec[2]; 17 | return (*this); 18 | } 19 | CVector3D& CVector3D::operator*=(double u) 20 | { 21 | pVec[0] *= u; pVec[1] *= u; pVec[2] *= u; 22 | return (*this); 23 | } 24 | CVector3D& CVector3D::operator/=(double u) 25 | { 26 | if (abs(u) > 1e-10) 27 | {pVec[0] /= u; pVec[1] /= u; pVec[2] /= u;} 28 | return(*this); 29 | } 30 | CVector3D& CVector3D::operator^=(const CVector3D& v) 31 | { 32 | double xx = pVec[1]*v.pVec[2] - pVec[2]*v.pVec[1]; 33 | double yy = pVec[2]*v.pVec[0] - pVec[0]*v.pVec[2]; 34 | double zz = pVec[0]*v.pVec[1] - pVec[1]*v.pVec[0]; 35 | pVec[0] = xx; pVec[1] = yy; pVec[2] = zz; 36 | return (*this); 37 | } 38 | 39 | 40 | CVector3D operator+(const CVector3D& lv, const CVector3D& rv) 41 | { 42 | CVector3D rel = lv; 43 | rel += rv; 44 | return rel; 45 | } 46 | 47 | 48 | CVector3D operator-(const CVector3D& lv, const CVector3D& rv) 49 | { 50 | CVector3D rel = lv; 51 | rel -= rv; 52 | return rel; 53 | } 54 | 55 | CVector3D operator*(const double u, const CVector3D& rv) 56 | { 57 | CVector3D rel = rv; 58 | rel *= u; 59 | return rel; 60 | } 61 | 62 | CVector3D operator*(const CVector3D& lv, const double u) 63 | { 64 | CVector3D rel = lv; 65 | rel *= u; 66 | return rel; 67 | } 68 | 69 | CVector3D operator/(const CVector3D& lv, const double u) 70 | { 71 | CVector3D rel = lv; 72 | rel /= u; 73 | return rel; 74 | } 75 | 76 | double operator*(const CVector3D& lv, const CVector3D& rv) 77 | { 78 | return lv.pVec[0]*rv.pVec[0] + lv.pVec[1]*rv.pVec[1] + lv.pVec[2]*rv.pVec[2]; 79 | } 80 | 81 | CVector3D operator^(const CVector3D& lv, const CVector3D& rv) 82 | { 83 | CVector3D rel = lv; 84 | rel ^= rv; 85 | return rel; 86 | } 87 | 88 | const CVector3D CVector3D::INFINITE_VECTOR3D = CVector3D( 1e300, 1e300, 1e300 ); -------------------------------------------------------------------------------- /src/BldRecons/Common/Geometry/Vector3D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define DOUBLE_TOLERANCE 1e-10 6 | 7 | class CVector3D 8 | { 9 | public: 10 | CVector3D(void) { pVec[0] = pVec[1] = pVec[2] = 0.0; } 11 | CVector3D(double x, double y, double z) { pVec[0] = x; pVec[1] = y; pVec[2] = z; } 12 | CVector3D(double xx[3]) { pVec[0] = xx[0]; pVec[1] = xx[1], pVec[2] = xx[2]; } 13 | CVector3D(const CVector3D & v) { pVec[0] = v.pVec[0]; pVec[1] = v.pVec[1]; pVec[2] = v.pVec[2]; } 14 | ~CVector3D(void) {} 15 | 16 | public : 17 | double pVec[3]; 18 | 19 | // operator 20 | double length() { return sqrt(pVec[0] * pVec[0] + pVec[1] * pVec[1] + pVec[2] * pVec[2]); } 21 | double length2() { return pVec[0] * pVec[0] + pVec[1] * pVec[1] + pVec[2] * pVec[2]; } 22 | double normalize() { double len = length(); if (abs(len) > DOUBLE_TOLERANCE) {pVec[0]/=len;pVec[1]/=len;pVec[2]/=len;} return len; } 23 | bool IsInfinite() { return ( pVec[0] == 1e300 && pVec[1] == 1e300 && pVec[2] == 1e300 ); } 24 | CVector3D XY() { return CVector3D( pVec[0], pVec[1], 0.0 ); } 25 | 26 | double & operator[]( const int i ) { return pVec[i]; } 27 | 28 | CVector3D& operator=(const CVector3D& v); 29 | CVector3D& operator+=(const CVector3D& v); 30 | CVector3D& operator-=(const CVector3D& v); 31 | CVector3D& operator*=(double u); 32 | CVector3D& operator/=(double u); 33 | CVector3D& operator^=(const CVector3D& v); 34 | 35 | friend CVector3D operator+(const CVector3D& lv, const CVector3D& rv); 36 | friend CVector3D operator-(const CVector3D& lv, const CVector3D& rv); 37 | friend CVector3D operator*(const double u, const CVector3D& rv); 38 | friend CVector3D operator*(const CVector3D& lv, const double u); 39 | friend CVector3D operator/(const CVector3D& lv, const double u); 40 | friend double operator*(const CVector3D& lv, const CVector3D& rv); 41 | friend CVector3D operator^(const CVector3D& lv, const CVector3D& rv); 42 | 43 | public: 44 | static const CVector3D INFINITE_VECTOR3D; 45 | }; 46 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Grid/StreamingGrid.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "StreamingGrid.h" 3 | 4 | CStreamingGrid::CStreamingGrid(void) 5 | { 6 | } 7 | 8 | CStreamingGrid::~CStreamingGrid(void) 9 | { 10 | } 11 | 12 | int CStreamingGrid::Index( const CVector3D & v ) 13 | { 14 | CVector3D diff = v - m_cBoundingBox.m_vMin; 15 | int x = ( int )( diff[0] / m_dbUnit[0] ); 16 | Regularize( x ); 17 | int y = ( int )( diff[1] / m_dbUnit[1] ); 18 | Regularize( y ); 19 | return Index( x, y ); 20 | } 21 | 22 | void CStreamingGrid::Regularize( int & i ) 23 | { 24 | if ( i < 0 ) 25 | i = 0; 26 | if ( i >= m_nSideNumber ) 27 | i = m_nSideNumber - 1; 28 | } 29 | 30 | void CStreamingGrid::InitPrintProgress() 31 | { 32 | m_nProgressNumber = 0; 33 | m_nReadNumber = 0; 34 | fprintf_s( stderr, " 0.0%%" ); 35 | } 36 | 37 | void CStreamingGrid::PrintProgress() 38 | { 39 | int progress = ( int )( m_nReadNumber * 1000.0 / m_nPointNumber ); 40 | if ( progress > m_nProgressNumber ) { 41 | m_nProgressNumber = progress; 42 | fprintf_s( stderr, "\b\b\b\b\b\b%3d.%1d%%", m_nProgressNumber / 10, m_nProgressNumber % 10 ); 43 | } 44 | } 45 | 46 | void CStreamingGrid::IncReadNumber() 47 | { 48 | m_nReadNumber++; 49 | } -------------------------------------------------------------------------------- /src/BldRecons/Common/Grid/StreamingGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Geometry\BoundingBox.h" 4 | 5 | class CStreamingGrid 6 | { 7 | public: 8 | CStreamingGrid(void); 9 | ~CStreamingGrid(void); 10 | 11 | public: 12 | CBoundingBox m_cBoundingBox; 13 | int m_nCellDepth; 14 | double m_dbGridLength; 15 | int m_nSideNumber; // 2^k 16 | int m_nUnitNumber[ 2 ]; // unit_length = unit_number * grid_length 17 | double m_dbUnit[ 2 ]; 18 | int m_nPointNumber; 19 | 20 | protected: 21 | int m_nProgressNumber; 22 | int m_nReadNumber; 23 | void InitPrintProgress(); 24 | void PrintProgress(); 25 | void IncReadNumber(); 26 | 27 | protected: 28 | int Index( const CVector3D & v ); 29 | void Regularize( int & i ); 30 | 31 | inline int Index( int x, int y ) { 32 | return ( x * m_nSideNumber + y ); 33 | } 34 | inline int I2X( int i ) { 35 | return i / m_nSideNumber; 36 | } 37 | inline int I2Y( int i ) { 38 | return i % m_nSideNumber; 39 | } 40 | 41 | inline int MinBound( int xy ) { 42 | return __max( 0, xy - 1 ); 43 | } 44 | inline int MaxBound( int xy ) { 45 | return __min( m_nSideNumber - 1, xy + 1 ); 46 | } 47 | inline int InBound( int x, int y ) { 48 | return ( x >= 0 && x < m_nSideNumber && y >= 0 && y < m_nSideNumber ); 49 | } 50 | }; 51 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Lidar/LidarCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Geometry\Vector3D.h" 4 | #include 5 | 6 | enum PointType { 7 | PT_Unclassified = 0, 8 | PT_Ground = 1, 9 | PT_Building = 2, 10 | PT_Tree = 3, 11 | PT_Noise = 4 12 | }; 13 | 14 | struct PointData { 15 | PointType type; 16 | CVector3D v; 17 | CVector3D n; 18 | double feature[ 5 ]; 19 | double buildingness; 20 | }; 21 | 22 | typedef std::vector< PointData * > PointDataVector; 23 | 24 | typedef __int64 PatchIndex; 25 | 26 | struct PatchInfo { 27 | PatchIndex base; 28 | int num; 29 | }; 30 | 31 | struct PatchInfoEx : public PatchInfo { 32 | double height; 33 | }; 34 | 35 | struct PatchPointData { 36 | PointType type; 37 | PatchInfo patch; 38 | CVector3D v; 39 | CVector3D n; 40 | double flatness; 41 | }; 42 | 43 | typedef std::vector< PatchPointData * > PatchPointDataVector; 44 | 45 | #define GLOBAL_INDEX( i ) ( int )( ( ( i ) >> 32 ) & 0xffffffff ) 46 | #define LOCAL_INDEX( i ) ( int )( ( i ) & 0xffffffff ) 47 | #define PATCH_INDEX( i, j ) ( ( ( __int64 )( i ) ) << 32 ) | ( __int64 )( j ) -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/BPCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct BPHeader { 4 | char signature[16]; 5 | int version; 6 | int number; 7 | __int64 patch; 8 | double ground_z; 9 | double grid_length; 10 | }; 11 | 12 | struct BPPoint { 13 | __int64 plane; 14 | double flatness; 15 | double pos[3]; 16 | double n[3]; 17 | }; 18 | 19 | static const char signature_bp[] = "bp format"; 20 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/BPOCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct BPOHeader { 4 | char signature[16]; 5 | int version; 6 | int number; 7 | __int64 patch; 8 | double ground_z; 9 | double grid_length; 10 | }; 11 | 12 | static const char signature_bpo[] = "bpo format"; 13 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/BPOReader.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "BPOReader.h" 3 | 4 | #include 5 | #include 6 | 7 | CBPOReader::CBPOReader(void) 8 | { 9 | m_pFile = NULL; 10 | } 11 | 12 | CBPOReader::~CBPOReader(void) 13 | { 14 | } 15 | 16 | void CBPOReader::OpenFile(const char filename[]) 17 | { 18 | fopen_s( &m_pFile, filename, "rb" ); 19 | } 20 | 21 | void CBPOReader::CloseFile() 22 | { 23 | fclose( m_pFile ); 24 | } 25 | 26 | BPOHeader CBPOReader::ReadHeader() 27 | { 28 | //struct BPOHeader { 29 | // char signature[16]; 30 | // int version; 31 | // int number; 32 | // __int64 patch; 33 | // double ground_z; 34 | // double grid_length; 35 | //}; 36 | 37 | BPOHeader header; 38 | fread( &header, sizeof( BPOHeader ), 1, m_pFile ); 39 | 40 | if ( strcmp( header.signature, signature_bpo ) != 0 ) { 41 | fprintf_s( stderr, "BPO file signature unrecognized!\n" ); 42 | } 43 | 44 | return header; 45 | } 46 | 47 | void CBPOReader::ReadOutline( COutline & outline ) 48 | { 49 | outline.Load( m_pFile ); 50 | } 51 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/BPOReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Miscs\BPOCommon.h" 4 | #include "Geometry\Outline.h" 5 | 6 | class CBPOReader 7 | { 8 | public: 9 | CBPOReader(void); 10 | ~CBPOReader(void); 11 | 12 | protected: 13 | FILE * m_pFile; 14 | 15 | public: 16 | void OpenFile(const char filename[]); 17 | BPOHeader ReadHeader( ); 18 | void ReadOutline( COutline & outline ); 19 | void CloseFile(); 20 | }; 21 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/BPOWriter.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "BPOWriter.h" 3 | 4 | #include 5 | #include 6 | 7 | CBPOWriter::CBPOWriter(void) 8 | { 9 | m_pFile = NULL; 10 | } 11 | 12 | CBPOWriter::~CBPOWriter(void) 13 | { 14 | } 15 | 16 | void CBPOWriter::OpenFile( char filename[] ) 17 | { 18 | fopen_s( &m_pFile, filename, "wb" ); 19 | } 20 | 21 | void CBPOWriter::CloseFile() 22 | { 23 | fclose( m_pFile ); 24 | } 25 | 26 | void CBPOWriter::WriteHeader( PatchIndex patch, int number, double ground_z, double grid_length ) 27 | { 28 | if ( m_pFile == NULL ) 29 | return; 30 | 31 | //struct BPOHeader { 32 | // char signature[16]; 33 | // int version; 34 | // int element_size; 35 | // __int64 patch; 36 | // double grid_length; 37 | //}; 38 | 39 | BPOHeader header; 40 | 41 | memset( header.signature, 0, 16 ); 42 | memcpy_s( header.signature, 16, signature_bpo, strlen( signature_bpo ) ); 43 | 44 | header.version = 1; 45 | 46 | header.number = number; 47 | 48 | header.patch = patch; 49 | 50 | header.ground_z = ground_z; 51 | 52 | header.grid_length = grid_length; 53 | 54 | fwrite( &header, sizeof( BPOHeader ), 1, m_pFile ); 55 | } 56 | 57 | void CBPOWriter::WriteOutline( COutline & outline ) 58 | { 59 | outline.Save( m_pFile ); 60 | } 61 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/BPOWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Miscs\BPOCommon.h" 4 | #include "Lidar\LidarCommon.h" 5 | #include "Geometry\Outline.h" 6 | 7 | class CBPOWriter 8 | { 9 | public: 10 | CBPOWriter(void); 11 | ~CBPOWriter(void); 12 | 13 | protected: 14 | FILE * m_pFile; 15 | 16 | public: 17 | void OpenFile( char filename[] ); 18 | void WriteHeader( PatchIndex patch, int number, double ground_z, double grid_length ); 19 | void WriteOutline( COutline & outline ); 20 | void CloseFile(); 21 | }; 22 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/BPReader.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "BPReader.h" 3 | 4 | #include 5 | #include 6 | 7 | CBPReader::CBPReader(void) 8 | { 9 | m_pFile = NULL; 10 | } 11 | 12 | CBPReader::~CBPReader(void) 13 | { 14 | } 15 | 16 | void CBPReader::OpenFile( char filename[] ) 17 | { 18 | fopen_s( &m_pFile, filename, "rb" ); 19 | } 20 | 21 | void CBPReader::CloseFile() 22 | { 23 | fclose( m_pFile ); 24 | } 25 | 26 | BPHeader CBPReader::ReadHeader() 27 | { 28 | //struct BPHeader { 29 | // char signature[16]; 30 | // int version; 31 | // int number; 32 | // __int64 patch; 33 | // double grid_length; 34 | //}; 35 | 36 | BPHeader header; 37 | fread( &header, sizeof( BPHeader ), 1, m_pFile ); 38 | 39 | if ( strcmp( header.signature, signature_bp ) != 0 ) { 40 | fprintf_s( stderr, "BP file signature unrecognized!\n" ); 41 | } 42 | 43 | return header; 44 | } 45 | 46 | BPPoint CBPReader::ReadPoint() 47 | { 48 | BPPoint point; 49 | fread( &point, sizeof( BPPoint ), 1, m_pFile ); 50 | 51 | return point; 52 | } 53 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/BPReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Miscs\BPCommon.h" 4 | #include "Lidar\LidarCommon.h" 5 | 6 | class CBPReader 7 | { 8 | public: 9 | CBPReader(void); 10 | ~CBPReader(void); 11 | 12 | protected: 13 | FILE * m_pFile; 14 | 15 | public: 16 | void OpenFile( char filename[] ); 17 | BPHeader ReadHeader( ); 18 | BPPoint ReadPoint( ); 19 | void CloseFile(); 20 | }; 21 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/BPWriter.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "BPWriter.h" 3 | 4 | #include 5 | #include 6 | 7 | CBPWriter::CBPWriter(void) 8 | { 9 | m_pFile = NULL; 10 | } 11 | 12 | CBPWriter::~CBPWriter(void) 13 | { 14 | } 15 | 16 | void CBPWriter::OpenFile( char filename[] ) 17 | { 18 | fopen_s( &m_pFile, filename, "wb" ); 19 | } 20 | 21 | void CBPWriter::CloseFile() 22 | { 23 | fclose( m_pFile ); 24 | } 25 | 26 | void CBPWriter::WriteHeader( PatchIndex patch, int number, double ground_z, double grid_length ) 27 | { 28 | if ( m_pFile == NULL ) 29 | return; 30 | 31 | //struct BPHeader { 32 | // char signature[16]; 33 | // int version; 34 | // int element_size; 35 | // __int64 patch; 36 | // double grid_length; 37 | //}; 38 | 39 | BPHeader header; 40 | 41 | memset( header.signature, 0, 16 ); 42 | memcpy_s( header.signature, 16, signature_bp, strlen( signature_bp ) ); 43 | 44 | header.version = 1; 45 | 46 | header.patch = patch; 47 | 48 | header.number = number; 49 | 50 | header.ground_z = ground_z; 51 | 52 | header.grid_length = grid_length; 53 | 54 | fwrite( &header, sizeof( BPHeader ), 1, m_pFile ); 55 | } 56 | 57 | void CBPWriter::WritePoint( const double pos[3], const double n[3], const double flatness, const __int64 plane ) 58 | { 59 | BPPoint point; 60 | point.plane = plane; 61 | point.flatness = flatness; 62 | point.pos[0] = pos[0]; 63 | point.pos[1] = pos[1]; 64 | point.pos[2] = pos[2]; 65 | point.n[0] = n[0]; 66 | point.n[1] = n[1]; 67 | point.n[2] = n[2]; 68 | fwrite( &point, sizeof( BPPoint ), 1, m_pFile ); 69 | } 70 | 71 | void CBPWriter::WritePoint( const BPPoint & point ) 72 | { 73 | fwrite( &point, sizeof( BPPoint ), 1, m_pFile ); 74 | } 75 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/BPWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Miscs\BPCommon.h" 4 | #include "Lidar\LidarCommon.h" 5 | 6 | class CBPWriter 7 | { 8 | public: 9 | CBPWriter(void); 10 | ~CBPWriter(void); 11 | 12 | protected: 13 | FILE * m_pFile; 14 | 15 | public: 16 | void OpenFile( char filename[] ); 17 | void WriteHeader( PatchIndex patch, int number, double ground_z, double grid_length ); 18 | void WritePoint( const double pos[3], const double n[3], const double flatness, const __int64 plane ); 19 | void WritePoint( const BPPoint & point ); 20 | void CloseFile(); 21 | }; 22 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/HistCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct HistHeader { 4 | char signature[16]; 5 | int version; 6 | int number; 7 | double center_distance; 8 | double histogram_distance; 9 | }; 10 | 11 | static const char signature_hist[] = "hist format"; 12 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/HistReader.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "HistReader.h" 3 | 4 | #include 5 | #include 6 | 7 | CHistReader::CHistReader(void) 8 | { 9 | m_pFile = NULL; 10 | } 11 | 12 | CHistReader::~CHistReader(void) 13 | { 14 | } 15 | 16 | void CHistReader::OpenFile( char filename[] ) 17 | { 18 | fopen_s( &m_pFile, filename, "rb" ); 19 | } 20 | 21 | void CHistReader::CloseFile() 22 | { 23 | fclose( m_pFile ); 24 | } 25 | 26 | HistHeader CHistReader::ReadHeader() 27 | { 28 | //struct HistHeader { 29 | // char signature[16]; 30 | // int version; 31 | // int number; 32 | // double center_distance; 33 | // double histogram_distance; 34 | //}; 35 | 36 | HistHeader header; 37 | fread( &header, sizeof( HistHeader ), 1, m_pFile ); 38 | 39 | if ( strcmp( header.signature, signature_hist ) != 0 ) { 40 | fprintf_s( stderr, "HIST file signature unrecognized!\n" ); 41 | } 42 | 43 | return header; 44 | } 45 | 46 | void CHistReader::ReadCenter( CVector3D & center ) 47 | { 48 | fread( ¢er, sizeof( CVector3D ), 1, m_pFile ); 49 | } 50 | 51 | void CHistReader::ReadHistogram( CHistogram & histogram ) 52 | { 53 | histogram.Load( m_pFile ); 54 | } 55 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/HistReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Miscs\HistCommon.h" 4 | #include "Miscs\Histogram.h" 5 | #include "Geometry\Vector3D.h" 6 | 7 | class CHistReader 8 | { 9 | public: 10 | CHistReader(void); 11 | ~CHistReader(void); 12 | 13 | protected: 14 | FILE * m_pFile; 15 | 16 | public: 17 | void OpenFile( char filename[] ); 18 | HistHeader ReadHeader( ); 19 | void ReadCenter( CVector3D & center ); 20 | void ReadHistogram( CHistogram & histogram ); 21 | void CloseFile(); 22 | }; 23 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/HistWriter.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "HistWriter.h" 3 | 4 | #include 5 | #include 6 | 7 | CHistWriter::CHistWriter(void) 8 | { 9 | m_pFile = NULL; 10 | } 11 | 12 | CHistWriter::~CHistWriter(void) 13 | { 14 | } 15 | 16 | void CHistWriter::OpenFile( char filename[] ) 17 | { 18 | fopen_s( &m_pFile, filename, "wb" ); 19 | } 20 | 21 | void CHistWriter::CloseFile() 22 | { 23 | fclose( m_pFile ); 24 | } 25 | 26 | void CHistWriter::WriteHeader( int number, double center_distance, double histogram_distance ) 27 | { 28 | if ( m_pFile == NULL ) 29 | return; 30 | 31 | //struct HistHeader { 32 | // char signature[16]; 33 | // int version; 34 | // int number; 35 | // double center_distance; 36 | // double histogram_distance; 37 | //}; 38 | 39 | HistHeader header; 40 | 41 | memset( header.signature, 0, 16 ); 42 | memcpy_s( header.signature, 16, signature_hist, strlen( signature_hist ) ); 43 | 44 | header.version = 1; 45 | 46 | header.number = number; 47 | 48 | header.center_distance = center_distance; 49 | 50 | header.histogram_distance = histogram_distance; 51 | 52 | fwrite( &header, sizeof( HistHeader ), 1, m_pFile ); 53 | } 54 | 55 | void CHistWriter::WriteCenter( CVector3D & center ) 56 | { 57 | fwrite( ¢er, sizeof( CVector3D ), 1, m_pFile ); 58 | } 59 | 60 | void CHistWriter::WriteHistogram( CHistogram & histogram ) 61 | { 62 | histogram.Save( m_pFile ); 63 | } 64 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/HistWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Miscs\HistCommon.h" 4 | #include "Miscs\Histogram.h" 5 | #include "Geometry\Vector3D.h" 6 | 7 | class CHistWriter 8 | { 9 | public: 10 | CHistWriter(void); 11 | ~CHistWriter(void); 12 | 13 | protected: 14 | FILE * m_pFile; 15 | 16 | public: 17 | void OpenFile( char filename[] ); 18 | void WriteHeader( int number, double center_distance, double histogram_distance ); 19 | void WriteCenter( CVector3D & center ); 20 | void WriteHistogram( CHistogram & histogram ); 21 | void CloseFile(); 22 | }; 23 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/Histogram.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | class CHistogram 6 | { 7 | public: 8 | CHistogram(void); 9 | CHistogram( int precision, double s_min, double s_max ); 10 | ~CHistogram(void); 11 | 12 | public: 13 | int m_nPrecision; 14 | int m_nNumber; 15 | double m_dbSection[ 2 ]; 16 | std::vector< int > m_vecHist; 17 | std::vector< double > m_vecSmoothHist; 18 | std::vector< double > m_vecPeak; 19 | 20 | public: 21 | void Init( int precision, double s_min, double s_max ); 22 | void Add( double value, bool rotate = true ); 23 | void Add( int section ); 24 | 25 | void Save( FILE * pFile ); 26 | void Load( FILE * pFile ); 27 | 28 | public: 29 | void GetPeak( double sigma, double tolerance ); 30 | 31 | private: 32 | void Smooth( double sigma ); 33 | double MinSmoothHist(); 34 | double HistBarValue( int i ); 35 | }; 36 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/MeshWriter.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "MeshWriter.h" 3 | 4 | CMeshWriter::CMeshWriter(void) 5 | { 6 | m_pFile = NULL; 7 | } 8 | 9 | CMeshWriter::~CMeshWriter(void) 10 | { 11 | } 12 | 13 | void CMeshWriter::OpenFile( char filename[] ) 14 | { 15 | fopen_s( & m_pFile, filename, "w" ); 16 | } 17 | 18 | void CMeshWriter::WriteHeader() 19 | { 20 | fprintf_s( m_pFile, "#\n" ); 21 | } 22 | 23 | void CMeshWriter::WriteVertex( const double v[ 3 ] ) 24 | { 25 | fprintf_s( m_pFile, "v %.8f %.8f %.8f\n", v[0], v[1], v[2] ); 26 | } 27 | 28 | void CMeshWriter::WriteFace( const int i[ 3 ] ) 29 | { 30 | fprintf_s( m_pFile, "f %d %d %d\n", i[0]+1, i[1]+1, i[2]+1 ); 31 | } 32 | 33 | void CMeshWriter::WriteQuad( const int i[ 4 ], bool split ) 34 | { 35 | if ( split ) { 36 | fprintf_s( m_pFile, "f %d %d %d\n", i[0]+1, i[1]+1, i[2]+1 ); 37 | fprintf_s( m_pFile, "f %d %d %d\n", i[2]+1, i[3]+1, i[0]+1 ); 38 | } else { 39 | fprintf_s( m_pFile, "f %d %d %d %d\n", i[0]+1, i[1]+1, i[2]+1, i[3]+1 ); 40 | } 41 | } 42 | 43 | void CMeshWriter::CloseFile() 44 | { 45 | fclose( m_pFile ); 46 | } 47 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/MeshWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CMeshWriter 4 | { 5 | public: 6 | CMeshWriter(void); 7 | ~CMeshWriter(void); 8 | 9 | protected: 10 | FILE * m_pFile; 11 | 12 | public: 13 | void OpenFile( char filename[] ); 14 | void WriteHeader(); 15 | void WriteVertex( const double v[ 3 ] ); 16 | void WriteFace( const int i[3] ); 17 | void WriteQuad( const int i[4], bool split = false ); 18 | void CloseFile(); 19 | }; 20 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/NumericalSolver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CNumericalSolver 4 | { 5 | public: 6 | CNumericalSolver(void); 7 | ~CNumericalSolver(void); 8 | 9 | public: 10 | static void SolveEigenVectors3( double e[][3], double v[][3], double d[] ); 11 | static void SolveEigenVectors2( double e[][2], double v[][2], double d[] ); 12 | }; 13 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/OBJWriter.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "OBJWriter.h" 3 | 4 | #include 5 | #include 6 | 7 | COBJWriter::COBJWriter(void) 8 | { 9 | m_pFile = NULL; 10 | } 11 | 12 | COBJWriter::~COBJWriter(void) 13 | { 14 | } 15 | 16 | void COBJWriter::OpenFile( char filename[] ) 17 | { 18 | fopen_s( &m_pFile, filename, "w" ); 19 | } 20 | 21 | void COBJWriter::CloseFile() 22 | { 23 | fclose( m_pFile ); 24 | } 25 | 26 | void COBJWriter::WriteHeader( ) 27 | { 28 | if ( m_pFile == NULL ) 29 | return; 30 | 31 | fprintf_s( m_pFile, "#\n" ); 32 | m_nVertexOffset = 1; 33 | } 34 | 35 | void COBJWriter::WriteOutline( COutline & outline, double ground_z, bool wall_rectangle ) 36 | { 37 | outline.GenerateRoofTriangle(); 38 | outline.WriteOBJVertex( m_pFile, ground_z ); 39 | outline.WriteOBJFace( m_pFile, m_nVertexOffset, wall_rectangle ); 40 | m_nVertexOffset += ( int )outline.m_vecVertex.size() * 2; 41 | } 42 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/OBJWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Geometry\Outline.h" 4 | 5 | class COBJWriter 6 | { 7 | public: 8 | COBJWriter(void); 9 | ~COBJWriter(void); 10 | 11 | protected: 12 | FILE * m_pFile; 13 | int m_nVertexOffset; 14 | 15 | public: 16 | void OpenFile( char filename[] ); 17 | void WriteHeader( ); 18 | void WriteOutline( COutline & outline, double ground_z, bool wall_rectangle = false ); 19 | void CloseFile(); 20 | }; 21 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/TimeMeter.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include ".\timemeter.h" 3 | 4 | CTimeMeter::CTimeMeter(void) 5 | { 6 | } 7 | 8 | CTimeMeter::~CTimeMeter(void) 9 | { 10 | } 11 | 12 | void CTimeMeter::Start() 13 | { 14 | m_dwStart = ::GetTickCount(); 15 | } 16 | 17 | void CTimeMeter::End() 18 | { 19 | m_dwEnd = ::GetTickCount(); 20 | } 21 | 22 | void CTimeMeter::Print() 23 | { 24 | fprintf(stderr, "%d.%d seconds", (m_dwEnd - m_dwStart) / 1000, (m_dwEnd - m_dwStart) % 1000); 25 | } 26 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Miscs/TimeMeter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CTimeMeter 4 | { 5 | public: 6 | CTimeMeter(void); 7 | ~CTimeMeter(void); 8 | 9 | public: 10 | DWORD m_dwStart; 11 | DWORD m_dwEnd; 12 | 13 | void Start(); 14 | void End(); 15 | void Print(); 16 | }; 17 | -------------------------------------------------------------------------------- /src/BldRecons/Common/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | STATIC LIBRARY : Common Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this Common library project for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your Common application. 9 | 10 | 11 | Common.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | 18 | ///////////////////////////////////////////////////////////////////////////// 19 | 20 | StdAfx.h, StdAfx.cpp 21 | These files are used to build a precompiled header (PCH) file 22 | named Common.pch and a precompiled types file named StdAfx.obj. 23 | 24 | ///////////////////////////////////////////////////////////////////////////// 25 | Other notes: 26 | 27 | AppWizard uses "TODO:" comments to indicate parts of the source code you 28 | should add to or customize. 29 | 30 | ///////////////////////////////////////////////////////////////////////////// 31 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Streaming/SPACommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct SPAHeader { 4 | char signature[16]; 5 | int version; 6 | int number; 7 | double pos_min[3]; 8 | double pos_max[3]; 9 | int element_size; 10 | int cell_depth; 11 | double grid_length; 12 | int unit_number[2]; 13 | }; 14 | 15 | struct SPAPoint { 16 | __int64 type; 17 | double flatness; 18 | double pos[3]; 19 | double n[3]; 20 | }; 21 | 22 | struct SPACell { 23 | int type; // 0 - begin chunk; 1 - end chunk; (-1) - EOF 24 | int chunk_index; 25 | int point_number; 26 | }; 27 | 28 | #define BLOCK_SIZE_A __max( sizeof( SPAPoint ), sizeof( SPACell ) ) 29 | 30 | struct ElementBufferA { 31 | unsigned int descriptor; 32 | char buffer[ BLOCK_SIZE_A * 32 ]; 33 | }; 34 | 35 | static const char signature_spa[] = "spa format"; 36 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Streaming/SPAReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Streaming\SPACommon.h" 4 | #include "Grid\StreamingGrid.h" 5 | 6 | class CSplitGrid; 7 | 8 | class CSPAReader 9 | { 10 | public: 11 | CSPAReader(void); 12 | ~CSPAReader(void); 13 | 14 | protected: 15 | FILE * m_pFile; 16 | ElementBufferA m_cBuffer; 17 | int m_nElementsInBuffer; 18 | char * m_pElementInBuffer; 19 | CStreamingGrid * m_pGrid; 20 | 21 | public: 22 | void OpenFile( char filename[] ); 23 | void RegisterGrid( CStreamingGrid * grid ); 24 | void ReadHeader(); 25 | bool ReadNextElement(); 26 | SPAPoint * GetPoint(); 27 | SPACell * GetCell(); 28 | void CloseFile(); 29 | 30 | private: 31 | void InitBuffer(); 32 | }; 33 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Streaming/SPAWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Streaming\SPACommon.h" 4 | #include "Grid\StreamingGrid.h" 5 | #include "Lidar\LidarCommon.h" 6 | 7 | class CClassifyGrid; 8 | 9 | class CSPAWriter 10 | { 11 | public: 12 | CSPAWriter(void); 13 | ~CSPAWriter(void); 14 | 15 | protected: 16 | FILE * m_pFile; 17 | CStreamingGrid * m_pGrid; 18 | ElementBufferA m_cBuffer; 19 | int m_nElementsInBuffer; 20 | 21 | public: 22 | void OpenFile( char filename[] ); 23 | void RegisterGrid( CStreamingGrid * grid ); 24 | void WriteHeader(); 25 | void WritePoint( const CVector3D & v ); 26 | void WritePoint( const PointData & point ); 27 | void WriteBeginCell( int index, int number ); 28 | void WriteFinalizeCell( int index, int number ); 29 | void WriteEOF(); 30 | void CloseFile(); 31 | 32 | private: 33 | void InitBuffer(); 34 | }; 35 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Streaming/SPBCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct SPBHeader { 4 | char signature[16]; 5 | int version; 6 | int number; 7 | double pos_min[3]; 8 | double pos_max[3]; 9 | int element_size; 10 | int cell_depth; 11 | double grid_length; 12 | int unit_number[2]; 13 | }; 14 | 15 | struct SPBPoint { 16 | __int64 type; 17 | __int64 patch; 18 | double flatness; 19 | double pos[3]; 20 | double n[3]; 21 | }; 22 | 23 | struct SPBCell { 24 | int type; // 0 - begin chunk; 1 - end chunk; (-1) - EOF 25 | int chunk_index; 26 | int point_number; 27 | }; 28 | 29 | #define BLOCK_SIZE_B __max( sizeof( SPBPoint ), sizeof( SPBCell ) ) 30 | 31 | struct ElementBufferB { 32 | unsigned int descriptor; 33 | char buffer[ BLOCK_SIZE_B * 32 ]; 34 | }; 35 | 36 | static const char signature_spb[] = "spb format"; 37 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Streaming/SPBReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Streaming\SPBCommon.h" 4 | #include "Grid\StreamingGrid.h" 5 | 6 | class CSPBReader 7 | { 8 | public: 9 | CSPBReader(void); 10 | ~CSPBReader(void); 11 | 12 | protected: 13 | FILE * m_pFile; 14 | ElementBufferB m_cBuffer; 15 | int m_nElementsInBuffer; 16 | char * m_pElementInBuffer; 17 | CStreamingGrid * m_pGrid; 18 | 19 | public: 20 | void OpenFile( char filename[] ); 21 | void RegisterGrid( CStreamingGrid * grid ); 22 | void ReadHeader(); 23 | bool ReadNextElement(); 24 | SPBPoint * GetPoint(); 25 | SPBCell * GetCell(); 26 | void CloseFile(); 27 | 28 | private: 29 | void InitBuffer(); 30 | }; 31 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Streaming/SPBWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Streaming\SPBCommon.h" 4 | #include "Grid\StreamingGrid.h" 5 | #include "Lidar\LidarCommon.h" 6 | 7 | class CSPBWriter 8 | { 9 | public: 10 | CSPBWriter(void); 11 | ~CSPBWriter(void); 12 | 13 | protected: 14 | FILE * m_pFile; 15 | CStreamingGrid * m_pGrid; 16 | ElementBufferB m_cBuffer; 17 | int m_nElementsInBuffer; 18 | 19 | public: 20 | void OpenFile( char filename[] ); 21 | void RegisterGrid( CStreamingGrid * grid ); 22 | void WriteHeader(); 23 | void WritePoint( const CVector3D & v ); 24 | void WritePoint( const PatchPointData & point ); 25 | void WriteBeginCell( int index, int number ); 26 | void WriteFinalizeCell( int index, int number ); 27 | void WriteEOF(); 28 | void CloseFile(); 29 | 30 | private: 31 | void InitBuffer(); 32 | }; 33 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Streaming/SPCommon.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | struct SPHeader { 4 | char signature[16]; 5 | int version; 6 | int number; 7 | double pos_min[3]; 8 | double pos_max[3]; 9 | int element_size; 10 | int cell_depth; 11 | double grid_length; 12 | int unit_number[2]; 13 | }; 14 | 15 | struct SPPoint { 16 | double pos[3]; 17 | }; 18 | 19 | struct SPCell { 20 | int type; // 0 - begin chunk; 1 - end chunk; (-1) - EOF 21 | int chunk_index; 22 | int point_number; 23 | }; 24 | 25 | #define BLOCK_SIZE __max( sizeof( SPPoint ), sizeof( SPCell ) ) 26 | 27 | struct ElementBuffer { 28 | unsigned int descriptor; 29 | char buffer[ BLOCK_SIZE * 32 ]; 30 | }; 31 | 32 | static const char signature_sp[] = "sp format"; 33 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Streaming/SPReader.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Streaming\SPCommon.h" 4 | #include "Grid\StreamingGrid.h" 5 | 6 | class CClassifyGrid; 7 | 8 | class CSPReader 9 | { 10 | public: 11 | CSPReader(void); 12 | ~CSPReader(void); 13 | 14 | protected: 15 | FILE * m_pFile; 16 | ElementBuffer m_cBuffer; 17 | CStreamingGrid * m_pGrid; 18 | int m_nElementsInBuffer; 19 | char * m_pElementInBuffer; 20 | 21 | public: 22 | void OpenFile( char filename[] ); 23 | void RegisterGrid( CStreamingGrid * grid ); 24 | void ReadHeader(); 25 | bool ReadNextElement(); 26 | SPPoint * GetPoint(); 27 | SPCell * GetCell(); 28 | void CloseFile(); 29 | 30 | private: 31 | void InitBuffer(); 32 | }; 33 | -------------------------------------------------------------------------------- /src/BldRecons/Common/Streaming/SPWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Streaming\SPCommon.h" 4 | #include "Grid\StreamingGrid.h" 5 | 6 | class CSPWriter 7 | { 8 | public: 9 | CSPWriter(void); 10 | ~CSPWriter(void); 11 | 12 | protected: 13 | FILE * m_pFile; 14 | CStreamingGrid * m_pGrid; 15 | ElementBuffer m_cBuffer; 16 | int m_nElementsInBuffer; 17 | 18 | public: 19 | void OpenFile( char filename[] ); 20 | void RegisterGrid( CStreamingGrid * grid ); 21 | void WriteHeader(); 22 | void WritePoint( const CVector3D & v ); 23 | void WriteBeginCell( int index, int number ); 24 | void WriteFinalizeCell( int index, int number ); 25 | void WriteEOF(); 26 | void CloseFile(); 27 | 28 | private: 29 | void InitBuffer(); 30 | }; 31 | -------------------------------------------------------------------------------- /src/BldRecons/Common/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // Common.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/Common/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 7 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 8 | #endif 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /src/BldRecons/DualContouring/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/DualContouring/DCGrid.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "DCGrid.h" 3 | 4 | CDCGrid::CDCGrid(void) 5 | { 6 | } 7 | 8 | CDCGrid::~CDCGrid(void) 9 | { 10 | } 11 | 12 | ////////////////////////////////////////////////////////////////////////// 13 | // main functions 14 | ////////////////////////////////////////////////////////////////////////// 15 | 16 | void CDCGrid::AssignPointCloud( CPointCloud * pointcloud, double unit_length, double ground_z, bool enable_topology_check ) 17 | { 18 | CIndexingGrid::BuildIndexingGrid( pointcloud, unit_length ); 19 | pointcloud->m_dbGroundZ = ground_z; 20 | m_bTopologyCheck = enable_topology_check; 21 | 22 | } 23 | 24 | void CDCGrid::ComputeHermiteData( int accept_number, double relative_distance, double relative_z ) 25 | { 26 | // parameters set the segmentation criteria 27 | // points are assigned to the same segmentation iff. point_distance < relative_distance && z_difference < relative_z 28 | // segments with less than accept_number points are dropped as outliers 29 | 30 | m_nAcceptNumber = accept_number; 31 | m_dbSegmentationDistance = relative_distance * m_dbGridLength; 32 | m_dbSegmentationZ = relative_z * m_dbGridLength; 33 | 34 | double max_length = m_nHeight > m_nWidth ? m_nHeight - 1 : m_nWidth - 1; 35 | m_nLevel = 1 + ( int )( log( ( double )max_length ) / log( 2.0 ) ); 36 | m_nHDSideNumber = ( 1 << m_nLevel ) + 1; 37 | m_vecHermiteDataXY.resize( m_nHDSideNumber * m_nHDSideNumber ); 38 | m_vecHermiteDataZ.resize( m_nHDSideNumber * m_nHDSideNumber * 2 ); 39 | 40 | ComputeHermiteData_XY(); 41 | ComputeHermiteData_Z(); 42 | } 43 | 44 | void CDCGrid::DualContouringGeometry( double boundary_weight, double error_tolerance, double singular_tolerance ) 45 | { 46 | m_dbBoundaryWeight = boundary_weight; 47 | m_dbErrorTolerance = error_tolerance; 48 | m_dbSingularTolerance = singular_tolerance; 49 | 50 | m_vecNodes.clear(); 51 | m_vecNodes.resize( m_nLevel + 1 ); 52 | 53 | BuildQuadTreeAtLevel0(); 54 | 55 | for ( int l = 1; l <= m_nLevel; l++ ) { 56 | BuildQuadTreeAtLevelN( l ); 57 | } 58 | //PrintLayerNumber(); 59 | } 60 | -------------------------------------------------------------------------------- /src/BldRecons/DualContouring/DCGridSort.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "DCGrid.h" 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // sort functions 6 | ////////////////////////////////////////////////////////////////////////// 7 | 8 | int compare( const void *arg1, const void *arg2 ) { 9 | CDCGrid::DistanceSorting * n1 = ( CDCGrid::DistanceSorting * ) arg1; 10 | CDCGrid::DistanceSorting * n2 = ( CDCGrid::DistanceSorting * ) arg2; 11 | if ( n1->distance < n2->distance ) 12 | return -1; 13 | else 14 | return 1; 15 | } 16 | 17 | void CDCGrid::SortDistance2D( CVector3DPointer_Vector & points, CVector3D & ref_v, std::vector< int > & cluster, int cluster_index, DistanceSorting_Vector & sorting_result ) 18 | { 19 | for ( int i = 0; i < ( int )cluster.size(); i++ ) { 20 | if ( cluster[ i ] == cluster_index ) { 21 | sorting_result.push_back( DistanceSorting( i, ( * points[ i ] - ref_v ).XY().length() ) ); 22 | } 23 | } 24 | qsort( &( sorting_result[0] ), sorting_result.size(), sizeof( DistanceSorting ), compare ); 25 | } 26 | 27 | void CDCGrid::QSort( DistanceSorting_Vector & sorting_result ) 28 | { 29 | qsort( &( sorting_result[0] ), sorting_result.size(), sizeof( DistanceSorting ), compare ); 30 | } 31 | -------------------------------------------------------------------------------- /src/BldRecons/DualContouring/MeshBoundary.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Geometry\Mesh.h" 4 | 5 | class CMeshBoundary 6 | { 7 | public: 8 | CMeshBoundary(void); 9 | ~CMeshBoundary(void); 10 | 11 | public: 12 | friend class CDCContourer; 13 | friend class CHistGrid; 14 | 15 | protected: 16 | class CVertexGroupInfo { 17 | public: 18 | int number; 19 | int index; 20 | bool fixed; 21 | CVertexGroupInfo( int ll, int ii ) : number(ll), index(ii), fixed(false) {} 22 | }; 23 | 24 | class CAuxVertex { 25 | public: 26 | std::vector< int > ei; 27 | }; 28 | 29 | class CAuxEdge { 30 | public: 31 | int vi[2]; 32 | int fi; 33 | int twin; 34 | int next; 35 | }; 36 | 37 | class CAuxFace { 38 | public: 39 | int vi[3]; 40 | int ei[3]; 41 | }; 42 | 43 | class CAuxBoundary { 44 | public: 45 | std::vector< int > vi; 46 | std::vector< int > ei; 47 | double height; 48 | }; 49 | 50 | protected: 51 | CMesh * m_pMesh; 52 | std::vector< CVertexGroupInfo > m_vecGroupInfo; 53 | std::vector< CAuxVertex > m_vecVertex; 54 | std::vector< CAuxEdge > m_vecEdge; 55 | std::vector< CAuxFace > m_vecFace; 56 | std::vector< CAuxBoundary > m_vecBoundary; 57 | std::vector< int > m_vecBoundarySeq; 58 | 59 | public: 60 | void Init( CMesh * mesh ); 61 | 62 | protected: 63 | void CreateHalfEdgeMesh(); 64 | void CreateBoundary(); 65 | int GetNextEdge( int ei ); 66 | void SortBoundary(); 67 | }; 68 | -------------------------------------------------------------------------------- /src/BldRecons/DualContouring/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define __pi 3.1415926535897932384626 6 | 7 | struct DualContouringParam { 8 | double m_dbGridLength; 9 | int m_nAcceptNumber; 10 | double m_dbRelativeDistance; 11 | double m_dbRelativeZ; 12 | double m_dbWeight; 13 | double m_dbErrorTolerance; 14 | double m_dbSingularTolerance; 15 | }; 16 | 17 | struct SnappingParam { 18 | bool m_bEnableSnapping; 19 | char m_pSPBFile[ 1024 ]; 20 | char m_pHistFile[ 1024 ]; 21 | double m_dbErrorTolerance; 22 | double m_dbMinimumLength; 23 | }; 24 | 25 | class CParamManager 26 | { 27 | public: 28 | CParamManager(void); 29 | ~CParamManager(void); 30 | 31 | protected: 32 | static CParamManager * singletonInstance; 33 | 34 | public: 35 | static CParamManager * GetParamManager( void ) 36 | { 37 | if ( singletonInstance == NULL ) 38 | { 39 | singletonInstance = new CParamManager( ); 40 | } 41 | return singletonInstance; 42 | } 43 | 44 | void RegisterCommandLine( int argc, char * argv[] ); 45 | 46 | private: 47 | void GetNames(); 48 | void LoadConfiguration(); 49 | 50 | public: 51 | char m_pExeName[ 1024 ]; 52 | char m_pTrueName[ 1024 ]; 53 | char m_pDirName[ 1024 ]; 54 | char m_pIniName[ 1024 ]; 55 | 56 | char m_pWorkingDir[ 1024 ]; 57 | 58 | DualContouringParam m_cDCParam; 59 | 60 | bool m_bWallRectangle; 61 | bool m_bAntiNonManifold; 62 | 63 | SnappingParam m_cSnappingParam; 64 | }; 65 | -------------------------------------------------------------------------------- /src/BldRecons/DualContouring/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : DualContouring Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this DualContouring application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your DualContouring application. 9 | 10 | 11 | DualContouring.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | DualContouring.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named DualContouring.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/DualContouring/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // DualContouring.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/DualContouring/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | // TODO: reference additional headers your program requires here 19 | -------------------------------------------------------------------------------- /src/BldRecons/LASFinalize/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/LASFinalize/FinalizeGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Grid\StreamingGrid.h" 5 | #include "liblas\laspoint.hpp" 6 | #include "Streaming\SPWriter.h" 7 | #include "Streaming\SPAWriter.h" 8 | #include "Streaming\SPBWriter.h" 9 | 10 | typedef std::vector< CVector3D > ChunkData; 11 | 12 | class CFinalizeGrid : public CStreamingGrid 13 | { 14 | public: 15 | CFinalizeGrid(void); 16 | ~CFinalizeGrid(void); 17 | 18 | public: 19 | std::vector< int > m_vecGridIndex; 20 | std::vector< int > m_vecGridNumber; 21 | CSPWriter m_cWriter; 22 | CSPAWriter m_cAWriter; 23 | CSPBWriter m_cBWriter; 24 | 25 | public: 26 | void ComputeBoundingBox(); // first pass 27 | void Stream_ComputeGridIndex(); // second pass 28 | void Stream_WriteGrid(); // third pass 29 | 30 | protected: 31 | void ComputeGridLength(); 32 | bool CheckPoint( const liblas::LASPoint & point ); 33 | void InitWrite(); 34 | void FinWrite(); 35 | void WriteChunk( ChunkData * data, int index, int number ); 36 | }; 37 | -------------------------------------------------------------------------------- /src/BldRecons/LASFinalize/LASFinalize.cpp: -------------------------------------------------------------------------------- 1 | // LASFinalize.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "ParamManager.h" 6 | #include "FinalizeGrid.h" 7 | 8 | #include "Miscs\TimeMeter.h" 9 | 10 | void main(int argc, char * argv[]) 11 | { 12 | CTimeMeter timer; 13 | timer.Start(); 14 | 15 | CParamManager::GetParamManager()->RegisterCommandLine( argc, argv ); 16 | 17 | CFinalizeGrid grid; 18 | 19 | grid.ComputeBoundingBox(); 20 | grid.Stream_ComputeGridIndex(); 21 | grid.Stream_WriteGrid(); 22 | 23 | timer.End(); 24 | fprintf_s( stderr, "Total time cost is " ); 25 | timer.Print(); 26 | fprintf_s( stderr, ".\n" ); 27 | } 28 | -------------------------------------------------------------------------------- /src/BldRecons/LASFinalize/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | struct FileNameString { 6 | char name[ 1024 ]; 7 | }; 8 | 9 | class CParamManager 10 | { 11 | public: 12 | CParamManager(void); 13 | ~CParamManager(void); 14 | 15 | protected: 16 | static CParamManager * singletonInstance; 17 | 18 | public: 19 | static CParamManager * GetParamManager( void ) 20 | { 21 | if ( singletonInstance == NULL ) 22 | { 23 | singletonInstance = new CParamManager( ); 24 | } 25 | return singletonInstance; 26 | } 27 | 28 | void RegisterCommandLine( int argc, char * argv[] ); 29 | 30 | private: 31 | void GetNames(); 32 | void LoadConfiguration(); 33 | void LoadFileList(); 34 | 35 | public: 36 | enum FinalizerOutputFormat { FOF_SP, FOF_SPA, FOF_SPB }; 37 | FinalizerOutputFormat m_cOutputFormat; 38 | 39 | public: 40 | char m_pExeName[ 1024 ]; 41 | char m_pTrueName[ 1024 ]; 42 | char m_pDirName[ 1024 ]; 43 | char m_pIniName[ 1024 ]; 44 | 45 | char m_pFileList[ 1024 ]; 46 | char m_pOutputFile[ 1024 ]; 47 | int m_nFiles; 48 | std::vector< FileNameString > m_vecInputFiles; 49 | 50 | int m_nCellDepth; 51 | double m_dbGridLength; 52 | double m_dbScale; 53 | }; 54 | -------------------------------------------------------------------------------- /src/BldRecons/LASFinalize/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : LASFinalize Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this LASFinalize application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your LASFinalize application. 9 | 10 | 11 | LASFinalize.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | LASFinalize.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named LASFinalize.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/LASFinalize/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // LASFinalize.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/LASFinalize/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | // TODO: reference additional headers your program requires here 19 | -------------------------------------------------------------------------------- /src/BldRecons/LasLib/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/LasLib/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | STATIC LIBRARY : LasLib Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this LasLib library project for you. 6 | 7 | No source files were created as part of your project. 8 | 9 | 10 | LasLib.vcproj 11 | This is the main project file for VC++ projects generated using an Application Wizard. 12 | It contains information about the version of Visual C++ that generated the file, and 13 | information about the platforms, configurations, and project features selected with the 14 | Application Wizard. 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | Other notes: 18 | 19 | AppWizard uses "TODO:" comments to indicate parts of the source code you 20 | should add to or customize. 21 | 22 | ///////////////////////////////////////////////////////////////////////////// 23 | -------------------------------------------------------------------------------- /src/BldRecons/ManifoldContouring/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/ManifoldContouring/MCGrid.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "MCGrid.h" 3 | #include "MCBoundary.h" 4 | 5 | CMCGrid::CMCGrid(void) 6 | { 7 | } 8 | 9 | CMCGrid::~CMCGrid(void) 10 | { 11 | } 12 | 13 | ////////////////////////////////////////////////////////////////////////// 14 | // main functions 15 | ////////////////////////////////////////////////////////////////////////// 16 | 17 | void CMCGrid::AssignPointCloud( CPointCloud * pointcloud, double unit_length, double ground_z ) 18 | { 19 | CIndexingGrid::BuildIndexingGrid( pointcloud, unit_length ); 20 | pointcloud->m_dbGroundZ = ground_z; 21 | } 22 | 23 | void CMCGrid::ComputeHermiteData( int accept_number, double relative_distance, double relative_z ) 24 | { 25 | // parameters set the segmentation criteria 26 | // points are assigned to the same segmentation iff. point_distance < relative_distance && z_difference < relative_z 27 | // segments with less than accept_number points are dropped as outliers 28 | 29 | m_nAcceptNumber = accept_number; 30 | m_dbSegmentationDistance = relative_distance * m_dbGridLength; 31 | m_dbSegmentationZ = relative_z * m_dbGridLength; 32 | 33 | double max_length = m_nHeight > m_nWidth ? m_nHeight - 1 : m_nWidth - 1; 34 | m_nLevel = 1 + ( int )( log( ( double )max_length ) / log( 2.0 ) ); 35 | m_nHDSideNumber = ( 1 << m_nLevel ) + 1; 36 | m_vecHermiteDataXY.resize( m_nHDSideNumber * m_nHDSideNumber ); 37 | m_vecHermiteDataZ.resize( m_nHDSideNumber * m_nHDSideNumber * 2 ); 38 | 39 | ComputeHermiteData_XY(); 40 | ComputeHermiteData_Z(); 41 | } 42 | 43 | void CMCGrid::DualContouringGeometry( double boundary_weight, double error_tolerance, double singular_tolerance, int min_boundary_remaining ) 44 | { 45 | m_dbBoundaryWeight = boundary_weight; 46 | m_dbErrorTolerance = error_tolerance; 47 | m_dbSingularTolerance = singular_tolerance; 48 | m_nMinBoundaryRemaining = min_boundary_remaining; 49 | 50 | m_vecNodes.clear(); 51 | m_vecNodes.resize( m_nLevel + 1 ); 52 | 53 | BuildQuadTreeAtLevel0(); 54 | 55 | DetectTopologyFeatures(); 56 | 57 | CMCBoundary boundary; 58 | boundary.GetDummyBoundary( this ); 59 | 60 | //BuildQuadTreeAtLevelN( 1 ); 61 | //BuildQuadTreeAtLevelN( 2 ); 62 | 63 | for ( int l = 1; l <= m_nLevel; l++ ) { 64 | BuildQuadTreeAtLevelN( l ); 65 | } 66 | //PrintLayerNumber(); 67 | } 68 | -------------------------------------------------------------------------------- /src/BldRecons/ManifoldContouring/MCGridSort.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "MCGrid.h" 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // sort functions 6 | ////////////////////////////////////////////////////////////////////////// 7 | 8 | int compare( const void *arg1, const void *arg2 ) { 9 | CMCGrid::DistanceSorting * n1 = ( CMCGrid::DistanceSorting * ) arg1; 10 | CMCGrid::DistanceSorting * n2 = ( CMCGrid::DistanceSorting * ) arg2; 11 | if ( n1->distance < n2->distance ) 12 | return -1; 13 | else 14 | return 1; 15 | } 16 | 17 | void CMCGrid::SortDistance2D( CVector3DPointer_Vector & points, CVector3D & ref_v, std::vector< int > & cluster, int cluster_index, DistanceSorting_Vector & sorting_result ) 18 | { 19 | for ( int i = 0; i < ( int )cluster.size(); i++ ) { 20 | if ( cluster[ i ] == cluster_index ) { 21 | sorting_result.push_back( DistanceSorting( i, ( * points[ i ] - ref_v ).XY().length() ) ); 22 | } 23 | } 24 | qsort( &( sorting_result[0] ), sorting_result.size(), sizeof( DistanceSorting ), compare ); 25 | } 26 | 27 | void CMCGrid::QSort( DistanceSorting_Vector & sorting_result ) 28 | { 29 | qsort( &( sorting_result[0] ), sorting_result.size(), sizeof( DistanceSorting ), compare ); 30 | } 31 | -------------------------------------------------------------------------------- /src/BldRecons/ManifoldContouring/MeshBoundary.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Geometry\Mesh.h" 4 | 5 | class CMeshBoundary 6 | { 7 | public: 8 | CMeshBoundary(void); 9 | ~CMeshBoundary(void); 10 | 11 | public: 12 | friend class CMCContourer; 13 | friend class CHistGrid; 14 | 15 | protected: 16 | class CVertexGroupInfo { 17 | public: 18 | int number; 19 | int index; 20 | bool fixed; 21 | CVertexGroupInfo( int ll, int ii ) : number(ll), index(ii), fixed(false) {} 22 | }; 23 | 24 | class CAuxVertex { 25 | public: 26 | std::vector< int > ei; 27 | }; 28 | 29 | class CAuxEdge { 30 | public: 31 | int vi[2]; 32 | int fi; 33 | int twin; 34 | int next; 35 | }; 36 | 37 | class CAuxFace { 38 | public: 39 | int vi[3]; 40 | int ei[3]; 41 | }; 42 | 43 | class CAuxBoundary { 44 | public: 45 | std::vector< int > vi; 46 | std::vector< int > ei; 47 | double height; 48 | }; 49 | 50 | protected: 51 | CMesh * m_pMesh; 52 | std::vector< CVertexGroupInfo > m_vecGroupInfo; 53 | std::vector< CAuxVertex > m_vecVertex; 54 | std::vector< CAuxEdge > m_vecEdge; 55 | std::vector< CAuxFace > m_vecFace; 56 | std::vector< CAuxBoundary > m_vecBoundary; 57 | std::vector< int > m_vecBoundarySeq; 58 | 59 | public: 60 | void Init( CMesh * mesh ); 61 | 62 | protected: 63 | void CreateHalfEdgeMesh(); 64 | void CreateBoundary(); 65 | int GetNextEdge( int ei ); 66 | void SortBoundary(); 67 | }; 68 | -------------------------------------------------------------------------------- /src/BldRecons/ManifoldContouring/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define __pi 3.1415926535897932384626 6 | 7 | struct ManifoldContouringParam { 8 | double m_dbGridLength; 9 | int m_nAcceptNumber; 10 | double m_dbRelativeDistance; 11 | double m_dbRelativeZ; 12 | double m_dbWeight; 13 | double m_dbErrorTolerance; 14 | double m_dbSingularTolerance; 15 | }; 16 | 17 | struct SnappingParam { 18 | bool m_bEnableSnapping; 19 | char m_pSPBFile[ 1024 ]; 20 | char m_pHistFile[ 1024 ]; 21 | double m_dbErrorTolerance; 22 | double m_dbMinimumLength; 23 | }; 24 | 25 | class CParamManager 26 | { 27 | public: 28 | CParamManager(void); 29 | ~CParamManager(void); 30 | 31 | protected: 32 | static CParamManager * singletonInstance; 33 | 34 | public: 35 | static CParamManager * GetParamManager( void ) 36 | { 37 | if ( singletonInstance == NULL ) 38 | { 39 | singletonInstance = new CParamManager( ); 40 | } 41 | return singletonInstance; 42 | } 43 | 44 | void RegisterCommandLine( int argc, char * argv[] ); 45 | 46 | private: 47 | void GetNames(); 48 | void LoadConfiguration(); 49 | 50 | public: 51 | char m_pExeName[ 1024 ]; 52 | char m_pTrueName[ 1024 ]; 53 | char m_pDirName[ 1024 ]; 54 | char m_pIniName[ 1024 ]; 55 | 56 | char m_pWorkingDir[ 1024 ]; 57 | 58 | ManifoldContouringParam m_cMCParam; 59 | 60 | bool m_bWallRectangle; 61 | 62 | SnappingParam m_cSnappingParam; 63 | }; 64 | -------------------------------------------------------------------------------- /src/BldRecons/ManifoldContouring/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : ManifoldContouring Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this ManifoldContouring application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your ManifoldContouring application. 9 | 10 | 11 | ManifoldContouring.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | ManifoldContouring.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named ManifoldContouring.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/ManifoldContouring/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // ManifoldContouring.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/ManifoldContouring/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | // TODO: reference additional headers your program requires here 19 | -------------------------------------------------------------------------------- /src/BldRecons/Miscs/peak.m: -------------------------------------------------------------------------------- 1 | function [c, p] = peak(hist, sigma, scale) 2 | 3 | nhist = length( hist ); 4 | y = normpdf( -5:1:5, 0, sigma ); 5 | 6 | c = zeros( nhist, 1 ); 7 | 8 | for i = 1 : nhist 9 | for j = 1 : 11 10 | c(i) = c(i) + y(j) * hist( mod(i + j - 7, nhist) + 1 ); 11 | end 12 | end 13 | 14 | min_x = min(c); 15 | 16 | k = 1; 17 | for i = 1 : nhist 18 | if ( c(i) >= c(mod(i,nhist) + 1) && c(i) > c(mod(i-2,nhist) + 1) && c(i) > min_x * scale ) 19 | p(k) = pi / nhist * ( i - 0.5 ); 20 | k = k + 1; 21 | end 22 | end -------------------------------------------------------------------------------- /src/BldRecons/README.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | = Notes = 4 | This might be needed to compile Huma: 5 | C:\Program Files\Microsoft Visual Studio 9.0\VC\include\GL -------------------------------------------------------------------------------- /src/BldRecons/SPA2LAS/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/SPA2LAS/ParamManager.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include 3 | #include 4 | #include "ParamManager.h" 5 | #include 6 | 7 | CParamManager::CParamManager(void) 8 | { 9 | GetNames(); 10 | LoadConfiguration(); 11 | } 12 | 13 | CParamManager::~CParamManager(void) 14 | { 15 | } 16 | 17 | void CParamManager::GetNames() 18 | { 19 | USES_CONVERSION; 20 | 21 | memset( m_pExeName, 0, sizeof(char) * 1024 ); 22 | memset( m_pDirName, 0, sizeof(char) * 1024 ); 23 | memset( m_pTrueName, 0, sizeof(char) * 1024 ); 24 | memset( m_pIniName, 0, sizeof(char) * 1024 ); 25 | 26 | TCHAR pFileName[MAX_PATH]; 27 | ::GetModuleFileName( NULL, pFileName, MAX_PATH ); 28 | sprintf_s( m_pExeName, 1024, T2A( pFileName ) ); 29 | 30 | _getcwd(m_pDirName, sizeof(m_pDirName)); 31 | 32 | char * pTemp = strrchr( m_pExeName, '\\' ); 33 | pTemp = strrchr( m_pExeName, '.' ); 34 | strncat_s( m_pTrueName, 1024, m_pExeName, pTemp - m_pExeName ); 35 | 36 | sprintf_s( m_pIniName, 1024, "%s\\config.ini", m_pDirName ); 37 | } 38 | 39 | void CParamManager::LoadConfiguration() 40 | { 41 | const int MAX_STRING = 1024; 42 | char pString[ MAX_STRING ]; 43 | 44 | // m_pInputList 45 | ::GetPrivateProfileStringA( "SPA2LAS", "Input", "stdin", m_pInputFile, 1024, m_pIniName ); 46 | 47 | // m_pOutputFile 48 | ::GetPrivateProfileStringA( "SPA2LAS", "Output", "stdout", m_pOutputFile, 1024, m_pIniName ); 49 | 50 | // m_bClip, m_dbClip 51 | ::GetPrivateProfileStringA( "SPA2LAS", "Clip", "", pString, MAX_STRING, m_pIniName ); 52 | if ( sscanf_s( pString, "%lf,%lf,%lf,%lf", &m_dbClip[0][0], &m_dbClip[1][0], & m_dbClip[0][1], &m_dbClip[1][1] ) < 4 ) { 53 | m_bClip = false; 54 | } else { 55 | m_bClip = true; 56 | } 57 | 58 | // m_dbSampleRate 59 | ::GetPrivateProfileStringA( "SPA2LAS", "SampleRate", "0.99", pString, MAX_STRING, m_pIniName ); 60 | m_dbSampleRate = atof( pString ); 61 | } 62 | 63 | void CParamManager::RegisterCommandLine( int argc, char *argv[] ) 64 | { 65 | if ( argc > 1 ) { 66 | sprintf_s( m_pInputFile, 1024, "%s", argv[ 1 ] ); 67 | } 68 | if ( argc > 2 ) { 69 | sprintf_s( m_pOutputFile, 1024, "%s", argv[ 2 ] ); 70 | } 71 | } 72 | 73 | CParamManager * CParamManager::singletonInstance = NULL; 74 | -------------------------------------------------------------------------------- /src/BldRecons/SPA2LAS/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CParamManager 4 | { 5 | public: 6 | CParamManager(void); 7 | ~CParamManager(void); 8 | 9 | protected: 10 | static CParamManager * singletonInstance; 11 | 12 | public: 13 | static CParamManager * GetParamManager( void ) 14 | { 15 | if ( singletonInstance == NULL ) 16 | { 17 | singletonInstance = new CParamManager( ); 18 | } 19 | return singletonInstance; 20 | } 21 | 22 | void RegisterCommandLine( int argc, char * argv[] ); 23 | 24 | private: 25 | void GetNames(); 26 | void LoadConfiguration(); 27 | 28 | public: 29 | char m_pExeName[ 1024 ]; 30 | char m_pTrueName[ 1024 ]; 31 | char m_pDirName[ 1024 ]; 32 | char m_pIniName[ 1024 ]; 33 | 34 | char m_pInputFile[ 1024 ]; 35 | char m_pOutputFile[ 1024 ]; 36 | 37 | double m_dbSampleRate; 38 | 39 | bool m_bClip; 40 | double m_dbClip[2][2]; 41 | }; 42 | -------------------------------------------------------------------------------- /src/BldRecons/SPA2LAS/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : SPA2LAS Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this SPA2LAS application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your SPA2LAS application. 9 | 10 | 11 | SPA2LAS.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | SPA2LAS.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named SPA2LAS.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/SPA2LAS/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SPA2LAS.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/SPA2LAS/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | // TODO: reference additional headers your program requires here 19 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2BP/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2BP/ConvertChunk.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "ConvertChunk.h" 3 | #include "ConvertGrid.h" 4 | 5 | CConvertChunk::CConvertChunk( int index, int number, CConvertGrid * grid ) : 6 | m_vecPatchPointData( number ), 7 | m_iPointIndex( 0 ), 8 | m_pGrid( grid ), 9 | m_iIndex( index ), 10 | m_iX( index / grid->m_nSideNumber ), 11 | m_iY( index % grid->m_nSideNumber ), 12 | m_vPosition( grid->m_cBoundingBox.m_vMin + CVector3D( m_iX * grid->m_dbUnit[ 0 ], m_iY * grid->m_dbUnit[ 1 ], 0.0 ) ) 13 | { 14 | } 15 | 16 | CConvertChunk::~CConvertChunk(void) 17 | { 18 | } 19 | 20 | void CConvertChunk::PushPoint( SPBPoint * p ) 21 | { 22 | m_vecPatchPointData[ m_iPointIndex ].type = ( PointType )p->type; 23 | m_vecPatchPointData[ m_iPointIndex ].v = CVector3D( p->pos[ 0 ], p->pos[ 1 ], p->pos[ 2 ] ); 24 | m_vecPatchPointData[ m_iPointIndex ].n = CVector3D( p->n[ 0 ], p->n[ 1 ], p->n[ 2 ] ); 25 | m_vecPatchPointData[ m_iPointIndex ].flatness = p->flatness; 26 | m_vecPatchPointData[ m_iPointIndex ].patch.base = p->patch; 27 | m_vecPatchPointData[ m_iPointIndex ].patch.num = 0; 28 | m_iPointIndex ++; 29 | } 30 | 31 | ////////////////////////////////////////////////////////////////////////// 32 | // auxiliary functions 33 | ////////////////////////////////////////////////////////////////////////// 34 | 35 | int CConvertChunk::Index( int x, int y ) 36 | { 37 | return ( x * m_pGrid->m_nUnitNumber[ 1 ] + y ); 38 | } 39 | 40 | int CConvertChunk::Index( const CVector3D & v ) 41 | { 42 | CVector3D diff = v - m_vPosition; 43 | int x = ( int )( diff[0] / m_pGrid->m_dbGridLength ) ; 44 | RegularizeX( x ); 45 | int y = ( int )( diff[1] / m_pGrid->m_dbGridLength ); 46 | RegularizeY( y ); 47 | return Index( x, y ); 48 | } 49 | 50 | void CConvertChunk::RegularizeX( int & x ) 51 | { 52 | if ( x < 0 ) 53 | x = 0; 54 | if ( x >= m_pGrid->m_nUnitNumber[ 0 ] ) 55 | x = m_pGrid->m_nUnitNumber[ 0 ] - 1; 56 | } 57 | 58 | void CConvertChunk::RegularizeY( int & y ) 59 | { 60 | if ( y < 0 ) 61 | y = 0; 62 | if ( y >= m_pGrid->m_nUnitNumber[ 1 ] ) 63 | y = m_pGrid->m_nUnitNumber[ 1 ] - 1; 64 | } 65 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2BP/ConvertChunk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Lidar\LidarCommon.h" 4 | #include "Streaming\SPBCommon.h" 5 | 6 | class CConvertGrid; 7 | 8 | class CConvertChunk 9 | { 10 | public: 11 | CConvertChunk( int index, int number, CConvertGrid * grid ); 12 | ~CConvertChunk( void ); 13 | 14 | public: 15 | std::vector< PatchPointData > m_vecPatchPointData; 16 | 17 | int m_iPointIndex; 18 | int m_iIndex; 19 | int m_iX; 20 | int m_iY; 21 | CVector3D m_vPosition; 22 | 23 | protected: 24 | CConvertGrid * m_pGrid; 25 | 26 | public: 27 | void PushPoint( SPBPoint * p ); 28 | 29 | public: 30 | int Index( const CVector3D & v ); 31 | int Index( int x, int y ); 32 | void RegularizeX( int & x ); 33 | void RegularizeY( int & y ); 34 | }; 35 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2BP/ConvertGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Grid\StreamingGrid.h" 6 | #include "Streaming\SPBReader.h" 7 | #include "Miscs\BPWriter.h" 8 | #include "ConvertChunk.h" 9 | 10 | struct PatchWriterInfo { 11 | int begin_cell; 12 | int final_cell; 13 | int number; 14 | double ground_z; 15 | }; 16 | 17 | class CConvertGrid : public CStreamingGrid 18 | { 19 | public: 20 | CConvertGrid(void); 21 | ~CConvertGrid(void); 22 | 23 | public: 24 | CSPBReader m_cReader; 25 | stdext::hash_map< PatchIndex, PatchWriterInfo > m_hashWriterInfo; 26 | stdext::hash_map< PatchIndex, CBPWriter > m_hashWriter; 27 | stdext::hash_map< int, std::vector< PatchIndex > > m_hashFinalizedPatch; 28 | 29 | std::vector< CConvertChunk * > m_vecPointer; 30 | 31 | public: 32 | void Convert(); 33 | 34 | private: 35 | int ReadNextChunk(); 36 | 37 | void InitCount(); 38 | void CountChunk( CConvertChunk * chunk ); 39 | void FinCount(); 40 | 41 | void InitWrite(); 42 | void WriteChunk( CConvertChunk * chunk ); 43 | void FinWrite(); 44 | 45 | bool CheckPoint( PatchPointData & point ); 46 | double MinGroundZ( CConvertChunk * chunk ); 47 | }; 48 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2BP/ParamManager.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include 3 | #include 4 | #include "ParamManager.h" 5 | #include 6 | 7 | CParamManager::CParamManager(void) 8 | { 9 | GetNames(); 10 | LoadConfiguration(); 11 | } 12 | 13 | CParamManager::~CParamManager(void) 14 | { 15 | } 16 | 17 | void CParamManager::GetNames() 18 | { 19 | USES_CONVERSION; 20 | 21 | memset( m_pExeName, 0, sizeof(char) * 1024 ); 22 | memset( m_pDirName, 0, sizeof(char) * 1024 ); 23 | memset( m_pTrueName, 0, sizeof(char) * 1024 ); 24 | memset( m_pIniName, 0, sizeof(char) * 1024 ); 25 | 26 | TCHAR pFileName[MAX_PATH]; 27 | ::GetModuleFileName( NULL, pFileName, MAX_PATH ); 28 | sprintf_s( m_pExeName, 1024, T2A( pFileName ) ); 29 | 30 | _getcwd(m_pDirName, sizeof(m_pDirName)); 31 | 32 | char * pTemp = strrchr( m_pExeName, '\\' ); 33 | pTemp = strrchr( m_pExeName, '.' ); 34 | strncat_s( m_pTrueName, 1024, m_pExeName, pTemp - m_pExeName ); 35 | 36 | sprintf_s( m_pIniName, 1024, "%s\\config.ini", m_pDirName ); 37 | } 38 | 39 | void CParamManager::LoadConfiguration() 40 | { 41 | const int MAX_STRING = 1024; 42 | char pString[ MAX_STRING ]; 43 | 44 | // m_pInputFile 45 | ::GetPrivateProfileStringA( "SPB2BP", "Input", "stdin", m_pInputFile, 1024, m_pIniName ); 46 | 47 | // m_pOutputDir 48 | ::GetPrivateProfileStringA( "SPB2BP", "OutputDir", "C:\\Lidar\\", m_pOutputDir, 1024, m_pIniName ); 49 | 50 | // m_bClip, m_dbClip 51 | ::GetPrivateProfileStringA( "SPB2BP", "Clip", "", pString, MAX_STRING, m_pIniName ); 52 | if ( sscanf_s( pString, "%lf,%lf,%lf,%lf", &m_dbClip[0][0], &m_dbClip[1][0], & m_dbClip[0][1], &m_dbClip[1][1] ) < 4 ) { 53 | m_bClip = false; 54 | } else { 55 | m_bClip = true; 56 | } 57 | } 58 | 59 | void CParamManager::RegisterCommandLine( int argc, char *argv[] ) 60 | { 61 | if ( argc > 1 ) { 62 | sprintf_s( m_pInputFile, 1024, "%s", argv[ 1 ] ); 63 | } 64 | if ( argc > 2 ) { 65 | sprintf_s( m_pOutputDir, 1024, "%s", argv[ 2 ] ); 66 | } 67 | } 68 | 69 | CParamManager * CParamManager::singletonInstance = NULL; 70 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2BP/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CParamManager 4 | { 5 | public: 6 | CParamManager(void); 7 | ~CParamManager(void); 8 | 9 | protected: 10 | static CParamManager * singletonInstance; 11 | 12 | public: 13 | static CParamManager * GetParamManager( void ) 14 | { 15 | if ( singletonInstance == NULL ) 16 | { 17 | singletonInstance = new CParamManager( ); 18 | } 19 | return singletonInstance; 20 | } 21 | 22 | void RegisterCommandLine( int argc, char * argv[] ); 23 | 24 | private: 25 | void GetNames(); 26 | void LoadConfiguration(); 27 | 28 | public: 29 | char m_pExeName[ 1024 ]; 30 | char m_pTrueName[ 1024 ]; 31 | char m_pDirName[ 1024 ]; 32 | char m_pIniName[ 1024 ]; 33 | 34 | char m_pInputFile[ 1024 ]; 35 | char m_pOutputDir[ 1024 ]; 36 | 37 | bool m_bClip; 38 | double m_dbClip[2][2]; 39 | }; 40 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2BP/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : SPB2BP Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this SPB2BP application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your SPB2BP application. 9 | 10 | 11 | SPB2BP.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | SPB2BP.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named SPB2BP.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2BP/SPB2BP.cpp: -------------------------------------------------------------------------------- 1 | // SPB2BP.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "ParamManager.h" 6 | #include "ConvertGrid.h" 7 | 8 | void main(int argc, char * argv[]) 9 | { 10 | CParamManager * manager = CParamManager::GetParamManager(); 11 | manager->RegisterCommandLine( argc, argv ); 12 | 13 | CConvertGrid grid; 14 | 15 | grid.Convert(); 16 | } 17 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2BP/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SPB2BP.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2BP/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | // TODO: reference additional headers your program requires here 19 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2LAS/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2LAS/ParamManager.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include 3 | #include 4 | #include "ParamManager.h" 5 | #include 6 | 7 | CParamManager::CParamManager(void) 8 | { 9 | GetNames(); 10 | LoadConfiguration(); 11 | } 12 | 13 | CParamManager::~CParamManager(void) 14 | { 15 | } 16 | 17 | void CParamManager::GetNames() 18 | { 19 | USES_CONVERSION; 20 | 21 | memset( m_pExeName, 0, sizeof(char) * 1024 ); 22 | memset( m_pDirName, 0, sizeof(char) * 1024 ); 23 | memset( m_pTrueName, 0, sizeof(char) * 1024 ); 24 | memset( m_pIniName, 0, sizeof(char) * 1024 ); 25 | 26 | TCHAR pFileName[MAX_PATH]; 27 | ::GetModuleFileName( NULL, pFileName, MAX_PATH ); 28 | sprintf_s( m_pExeName, 1024, T2A( pFileName ) ); 29 | 30 | _getcwd(m_pDirName, sizeof(m_pDirName)); 31 | 32 | char * pTemp = strrchr( m_pExeName, '\\' ); 33 | pTemp = strrchr( m_pExeName, '.' ); 34 | strncat_s( m_pTrueName, 1024, m_pExeName, pTemp - m_pExeName ); 35 | 36 | sprintf_s( m_pIniName, 1024, "%s\\config.ini", m_pDirName ); 37 | } 38 | 39 | void CParamManager::LoadConfiguration() 40 | { 41 | const int MAX_STRING = 1024; 42 | char pString[ MAX_STRING ]; 43 | 44 | // m_pInputList 45 | ::GetPrivateProfileStringA( "SPB2LAS", "Input", "stdin", m_pInputFile, 1024, m_pIniName ); 46 | 47 | // m_pOutputFile 48 | ::GetPrivateProfileStringA( "SPB2LAS", "Output", "stdout", m_pOutputFile, 1024, m_pIniName ); 49 | 50 | // m_bClip, m_dbClip 51 | ::GetPrivateProfileStringA( "SPB2LAS", "Clip", "", pString, MAX_STRING, m_pIniName ); 52 | if ( sscanf_s( pString, "%lf,%lf,%lf,%lf", &m_dbClip[0][0], &m_dbClip[1][0], & m_dbClip[0][1], &m_dbClip[1][1] ) < 4 ) { 53 | m_bClip = false; 54 | } else { 55 | m_bClip = true; 56 | } 57 | 58 | // m_dbSampleRate 59 | ::GetPrivateProfileStringA( "SPB2LAS", "SampleRate", "0.99", pString, MAX_STRING, m_pIniName ); 60 | m_dbSampleRate = atof( pString ); 61 | 62 | // m_bIntensity 63 | m_bIntensity = ( bool )::GetPrivateProfileIntA( "SPB2LAS", "PatchToIntensity", 1, m_pIniName ); 64 | 65 | } 66 | 67 | void CParamManager::RegisterCommandLine( int argc, char *argv[] ) 68 | { 69 | if ( argc > 1 ) { 70 | sprintf_s( m_pInputFile, 1024, "%s", argv[ 1 ] ); 71 | } 72 | if ( argc > 2 ) { 73 | sprintf_s( m_pOutputFile, 1024, "%s", argv[ 2 ] ); 74 | } 75 | } 76 | 77 | CParamManager * CParamManager::singletonInstance = NULL; 78 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2LAS/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CParamManager 4 | { 5 | public: 6 | CParamManager(void); 7 | ~CParamManager(void); 8 | 9 | protected: 10 | static CParamManager * singletonInstance; 11 | 12 | public: 13 | static CParamManager * GetParamManager( void ) 14 | { 15 | if ( singletonInstance == NULL ) 16 | { 17 | singletonInstance = new CParamManager( ); 18 | } 19 | return singletonInstance; 20 | } 21 | 22 | void RegisterCommandLine( int argc, char * argv[] ); 23 | 24 | private: 25 | void GetNames(); 26 | void LoadConfiguration(); 27 | 28 | public: 29 | char m_pExeName[ 1024 ]; 30 | char m_pTrueName[ 1024 ]; 31 | char m_pDirName[ 1024 ]; 32 | char m_pIniName[ 1024 ]; 33 | 34 | char m_pInputFile[ 1024 ]; 35 | char m_pOutputFile[ 1024 ]; 36 | 37 | double m_dbSampleRate; 38 | 39 | bool m_bClip; 40 | double m_dbClip[2][2]; 41 | 42 | bool m_bIntensity; 43 | }; 44 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2LAS/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : SPB2LAS Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this SPB2LAS application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your SPB2LAS application. 9 | 10 | 11 | SPB2LAS.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | SPB2LAS.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named SPB2LAS.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2LAS/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SPA2LAS.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2LAS/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | // TODO: reference additional headers your program requires here 19 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2OBJ/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2OBJ/MeshChunk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Lidar\LidarCommon.h" 4 | #include "Streaming\SPBCommon.h" 5 | 6 | class CMeshGrid; 7 | 8 | class CMeshChunk 9 | { 10 | public: 11 | CMeshChunk( int index, int number, CMeshGrid * grid ); 12 | ~CMeshChunk( void ); 13 | 14 | public: 15 | std::vector< PatchPointData > m_vecPatchPointData; 16 | std::vector< PatchPointDataVector > m_vecGridIndex; 17 | 18 | int m_iPointIndex; 19 | int m_iIndex; 20 | int m_iX; 21 | int m_iY; 22 | CVector3D m_vPosition; 23 | 24 | protected: 25 | CMeshGrid * m_pGrid; 26 | 27 | public: 28 | void PushPoint( SPBPoint * p ); 29 | void BuildGridIndex(); 30 | 31 | public: 32 | int Index( const CVector3D & v ); 33 | int Index( int x, int y ); 34 | void RegularizeX( int & x ); 35 | void RegularizeY( int & y ); 36 | }; 37 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2OBJ/MeshGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Grid\StreamingGrid.h" 6 | #include "Streaming\SPBReader.h" 7 | #include "Miscs\MeshWriter.h" 8 | #include "MeshChunk.h" 9 | 10 | class CMeshGrid : public CStreamingGrid 11 | { 12 | public: 13 | CMeshGrid(void); 14 | ~CMeshGrid(void); 15 | 16 | public: 17 | CSPBReader m_cReader; 18 | CMeshWriter m_cWriter; 19 | 20 | std::vector< CMeshChunk * > m_vecPointer; 21 | 22 | std::vector< double > m_vecHeight; 23 | 24 | public: 25 | void Mesh(); 26 | 27 | private: 28 | void Init(); 29 | void ComputeGroundHeight( CMeshChunk * chunk ); 30 | void Fin(); 31 | void Interpolate(); 32 | void WriteMesh( int sample_grid ); 33 | 34 | private: 35 | int ReadNextChunk(); 36 | 37 | protected: 38 | int m_nVertexNumber; 39 | int m_nFaceNumber; 40 | 41 | protected: 42 | int m_nClip[ 2 ][ 2 ]; 43 | void InitClip(); 44 | int ClipIndex( int x, int y ); 45 | }; 46 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2OBJ/ParamManager.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include 3 | #include 4 | #include "ParamManager.h" 5 | #include 6 | 7 | CParamManager::CParamManager(void) 8 | { 9 | GetNames(); 10 | LoadConfiguration(); 11 | } 12 | 13 | CParamManager::~CParamManager(void) 14 | { 15 | } 16 | 17 | void CParamManager::GetNames() 18 | { 19 | USES_CONVERSION; 20 | 21 | memset( m_pExeName, 0, sizeof(char) * 1024 ); 22 | memset( m_pDirName, 0, sizeof(char) * 1024 ); 23 | memset( m_pTrueName, 0, sizeof(char) * 1024 ); 24 | memset( m_pIniName, 0, sizeof(char) * 1024 ); 25 | 26 | TCHAR pFileName[MAX_PATH]; 27 | ::GetModuleFileName( NULL, pFileName, MAX_PATH ); 28 | sprintf_s( m_pExeName, 1024, T2A( pFileName ) ); 29 | 30 | _getcwd(m_pDirName, sizeof(m_pDirName)); 31 | 32 | char * pTemp = strrchr( m_pExeName, '\\' ); 33 | pTemp = strrchr( m_pExeName, '.' ); 34 | strncat_s( m_pTrueName, 1024, m_pExeName, pTemp - m_pExeName ); 35 | 36 | sprintf_s( m_pIniName, 1024, "%s\\config.ini", m_pDirName ); 37 | } 38 | 39 | void CParamManager::LoadConfiguration() 40 | { 41 | const int MAX_STRING = 1024; 42 | char pString[ MAX_STRING ]; 43 | 44 | // m_pInputList 45 | ::GetPrivateProfileStringA( "SPB2OBJ", "Input", "stdin", m_pInputFile, 1024, m_pIniName ); 46 | 47 | // m_pOutputFile 48 | ::GetPrivateProfileStringA( "SPB2OBJ", "Output", "stdout", m_pOutputFile, 1024, m_pIniName ); 49 | 50 | // m_bClip, m_dbClip 51 | ::GetPrivateProfileStringA( "SPB2OBJ", "Clip", "", pString, MAX_STRING, m_pIniName ); 52 | if ( sscanf_s( pString, "%lf,%lf,%lf,%lf", &m_dbClip[0][0], &m_dbClip[1][0], & m_dbClip[0][1], &m_dbClip[1][1] ) < 4 ) { 53 | m_bClip = false; 54 | } else { 55 | m_bClip = true; 56 | } 57 | 58 | // m_nSampleGrid 59 | m_nSampleGrid = ::GetPrivateProfileIntA( "SPB2OBJ", "SampleGrid", 1, m_pIniName ); 60 | } 61 | 62 | void CParamManager::RegisterCommandLine( int argc, char *argv[] ) 63 | { 64 | if ( argc > 1 ) { 65 | sprintf_s( m_pInputFile, 1024, "%s", argv[ 1 ] ); 66 | } 67 | if ( argc > 2 ) { 68 | sprintf_s( m_pOutputFile, 1024, "%s", argv[ 2 ] ); 69 | } 70 | } 71 | 72 | CParamManager * CParamManager::singletonInstance = NULL; 73 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2OBJ/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CParamManager 4 | { 5 | public: 6 | CParamManager(void); 7 | ~CParamManager(void); 8 | 9 | protected: 10 | static CParamManager * singletonInstance; 11 | 12 | public: 13 | static CParamManager * GetParamManager( void ) 14 | { 15 | if ( singletonInstance == NULL ) 16 | { 17 | singletonInstance = new CParamManager( ); 18 | } 19 | return singletonInstance; 20 | } 21 | 22 | void RegisterCommandLine( int argc, char * argv[] ); 23 | 24 | private: 25 | void GetNames(); 26 | void LoadConfiguration(); 27 | 28 | public: 29 | char m_pExeName[ 1024 ]; 30 | char m_pTrueName[ 1024 ]; 31 | char m_pDirName[ 1024 ]; 32 | char m_pIniName[ 1024 ]; 33 | 34 | char m_pInputFile[ 1024 ]; 35 | char m_pOutputFile[ 1024 ]; 36 | 37 | bool m_bClip; 38 | double m_dbClip[2][2]; 39 | int m_nSampleGrid; 40 | }; 41 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2OBJ/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : SPB2OBJ Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this SPB2OBJ application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your SPB2OBJ application. 9 | 10 | 11 | SPB2OBJ.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | SPB2OBJ.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named SPB2OBJ.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2OBJ/SPB2OBJ.cpp: -------------------------------------------------------------------------------- 1 | // SPB2OBJ.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "ParamManager.h" 6 | #include "MeshGrid.h" 7 | 8 | void main( int argc, char * argv[] ) 9 | { 10 | 11 | CParamManager::GetParamManager()->RegisterCommandLine( argc, argv ); 12 | 13 | CMeshGrid grid; 14 | 15 | grid.Mesh(); 16 | 17 | } 18 | 19 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2OBJ/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SPA2LAS.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/SPB2OBJ/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | // TODO: reference additional headers your program requires here 19 | -------------------------------------------------------------------------------- /src/BldRecons/SPClassify/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/SPClassify/ClassifyChunk.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "ClassifyChunk.h" 3 | #include "ClassifyGrid.h" 4 | 5 | CClassifyChunk::CClassifyChunk( int index, int number, CClassifyGrid * grid ) : 6 | m_vecPointData( number ), 7 | m_iPointIndex( 0 ), 8 | m_pGrid( grid ), 9 | m_iIndex( index ), 10 | m_iX( index / grid->m_nSideNumber ), 11 | m_iY( index % grid->m_nSideNumber ), 12 | m_vPosition( grid->m_cBoundingBox.m_vMin + CVector3D( m_iX * grid->m_dbUnit[ 0 ], m_iY * grid->m_dbUnit[ 1 ], 0.0 ) ) 13 | { 14 | } 15 | 16 | CClassifyChunk::~CClassifyChunk(void) 17 | { 18 | } 19 | 20 | void CClassifyChunk::PushPoint( SPPoint * p ) 21 | { 22 | m_vecPointData[ m_iPointIndex ].type = PT_Unclassified; 23 | m_vecPointData[ m_iPointIndex ].v = CVector3D( p->pos[ 0 ], p->pos[ 1 ], p->pos[ 2 ] ); 24 | m_iPointIndex ++; 25 | } 26 | 27 | void CClassifyChunk::BuildGridIndex() 28 | { 29 | m_vecGridIndex.clear(); 30 | m_vecGridIndex.resize( m_pGrid->m_nUnitNumber[ 0 ] * m_pGrid->m_nUnitNumber[ 1 ] ); 31 | 32 | for ( int i = 0; i < ( int )m_vecPointData.size(); i++ ) { 33 | m_vecGridIndex[ Index( m_vecPointData[ i ].v ) ].push_back( & ( m_vecPointData[ i ] ) ); 34 | } 35 | } 36 | 37 | ////////////////////////////////////////////////////////////////////////// 38 | // auxiliary functions 39 | ////////////////////////////////////////////////////////////////////////// 40 | 41 | int CClassifyChunk::Index( int x, int y ) 42 | { 43 | return ( x * m_pGrid->m_nUnitNumber[ 1 ] + y ); 44 | } 45 | 46 | int CClassifyChunk::Index( const CVector3D & v ) 47 | { 48 | CVector3D diff = v - m_vPosition; 49 | int x = ( int )( diff[0] / m_pGrid->m_dbGridLength ) ; 50 | RegularizeX( x ); 51 | int y = ( int )( diff[1] / m_pGrid->m_dbGridLength ); 52 | RegularizeY( y ); 53 | return Index( x, y ); 54 | } 55 | 56 | void CClassifyChunk::RegularizeX( int & x ) 57 | { 58 | if ( x < 0 ) 59 | x = 0; 60 | if ( x >= m_pGrid->m_nUnitNumber[ 0 ] ) 61 | x = m_pGrid->m_nUnitNumber[ 0 ] - 1; 62 | } 63 | 64 | void CClassifyChunk::RegularizeY( int & y ) 65 | { 66 | if ( y < 0 ) 67 | y = 0; 68 | if ( y >= m_pGrid->m_nUnitNumber[ 1 ] ) 69 | y = m_pGrid->m_nUnitNumber[ 1 ] - 1; 70 | } 71 | -------------------------------------------------------------------------------- /src/BldRecons/SPClassify/ClassifyChunk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Lidar\LidarCommon.h" 4 | #include "Streaming\SPCommon.h" 5 | 6 | class CClassifyGrid; 7 | 8 | class CClassifyChunk 9 | { 10 | public: 11 | enum ClassifyChunkState { 12 | CCS_New = 0, 13 | CCS_Read = 1, 14 | CCS_Normaled = 2, 15 | CCS_Classified = 3, 16 | CCS_Refined = 4, 17 | CCS_Written = 5 18 | }; 19 | 20 | public: 21 | CClassifyChunk( int index, int number, CClassifyGrid * grid ); 22 | ~CClassifyChunk(void); 23 | 24 | public: 25 | std::vector< PointData > m_vecPointData; 26 | std::vector< PointDataVector > m_vecGridIndex; 27 | //ClassifyChunkState m_cState; 28 | int m_iPointIndex; 29 | int m_iIndex; 30 | int m_iX; 31 | int m_iY; 32 | CVector3D m_vPosition; 33 | 34 | protected: 35 | CClassifyGrid * m_pGrid; 36 | 37 | public: 38 | void PushPoint( SPPoint * p ); 39 | void BuildGridIndex(); 40 | 41 | public: 42 | int Index( const CVector3D & v ); 43 | int Index( int x, int y ); 44 | void RegularizeX( int & x ); 45 | void RegularizeY( int & y ); 46 | }; 47 | -------------------------------------------------------------------------------- /src/BldRecons/SPClassify/ClassifyGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Grid\StreamingGrid.h" 5 | #include "Streaming\SPReader.h" 6 | #include "Streaming\SPAWriter.h" 7 | #include "ClassifyChunk.h" 8 | 9 | class CClassifyGrid : public CStreamingGrid 10 | { 11 | public: 12 | CClassifyGrid(void); 13 | ~CClassifyGrid(void); 14 | 15 | public: 16 | CSPReader m_cReader; 17 | CSPAWriter m_cWriter; 18 | 19 | std::vector< CClassifyChunk * > m_vecPointer; 20 | std::vector< CClassifyChunk::ClassifyChunkState > m_vecState; 21 | 22 | public: 23 | void Classify(); 24 | 25 | private: 26 | void Init(); 27 | void Fin(); 28 | 29 | int ReadNextChunk(); 30 | 31 | void NormalChunk( CClassifyChunk * chunk ); 32 | void ClassifyChunk( CClassifyChunk * chunk ); 33 | void RefineChunk( CClassifyChunk * chunk ); 34 | void WriteChunk( CClassifyChunk * chunk ); 35 | 36 | //void NotifyCCSRead( CClassifyChunk * chunk ); 37 | //void NotifyCCSNormaled( CClassifyChunk * chunk ); 38 | //void NotifyCCSClassified( CClassifyChunk * chunk ); 39 | //void NotifyCCSRefined( CClassifyChunk * chunk ); 40 | void NotifyCCSRead( int ix, int iy ); 41 | void NotifyCCSNormaled( int ix, int iy ); 42 | void NotifyCCSClassified( int ix, int iy ); 43 | void NotifyCCSRefined( int ix, int iy ); 44 | 45 | inline bool CheckCCSRead( int idx ) { 46 | return ( m_vecState[ idx ] >= CClassifyChunk::CCS_Read ); 47 | } 48 | inline bool CheckCCSNormaled( int idx ) { 49 | return ( m_vecState[ idx ] >= CClassifyChunk::CCS_Normaled ); 50 | } 51 | inline bool CheckCCSClassified( int idx ) { 52 | return ( m_vecState[ idx ] >= CClassifyChunk::CCS_Classified ); 53 | } 54 | inline bool CheckCCSRefined( int idx ) { 55 | return ( m_vecState[ idx ] >= CClassifyChunk::CCS_Refined ); 56 | } 57 | 58 | private: 59 | PointDataVector m_vecPointData; 60 | void GetNeighbor( PointData & point, int dis, CClassifyChunk * chunk, int x, int y ); 61 | 62 | protected: 63 | int m_nTotalNumber; 64 | int m_nBuildingNumber; 65 | int m_nTreeNumber; 66 | int m_nNoiseNumber; 67 | 68 | private: 69 | void PrintGridState( const char filename[] ); 70 | }; 71 | -------------------------------------------------------------------------------- /src/BldRecons/SPClassify/FeatureCalculator.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Lidar\LidarCommon.h" 4 | 5 | class CFeatureCalculator 6 | { 7 | public: 8 | CFeatureCalculator(void); 9 | ~CFeatureCalculator(void); 10 | 11 | public: 12 | static void ComputeCoVariance( PointData & point, PointDataVector & data ); 13 | static void ComputeNormalCoVariance( PointData & point, PointDataVector & data ); 14 | static void RefineClassification( PointData & point, PointDataVector & data ); 15 | }; 16 | -------------------------------------------------------------------------------- /src/BldRecons/SPClassify/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define __pi 3.1415926535897932384626 6 | #define __arc(x) (x) / 180.0 * __pi 7 | 8 | struct ClassifyParam { 9 | std::vector< double > w; 10 | double c; 11 | double c_refine; 12 | }; 13 | 14 | class CParamManager 15 | { 16 | public: 17 | CParamManager(void); 18 | ~CParamManager(void); 19 | 20 | protected: 21 | static CParamManager * singletonInstance; 22 | 23 | public: 24 | static CParamManager * GetParamManager( void ) 25 | { 26 | if ( singletonInstance == NULL ) 27 | { 28 | singletonInstance = new CParamManager( ); 29 | } 30 | return singletonInstance; 31 | } 32 | 33 | void RegisterCommandLine( int argc, char * argv[] ); 34 | 35 | private: 36 | void GetNames(); 37 | void LoadConfiguration(); 38 | void LoadParamFile(); 39 | 40 | public: 41 | char m_pExeName[ 1024 ]; 42 | char m_pTrueName[ 1024 ]; 43 | char m_pDirName[ 1024 ]; 44 | char m_pIniName[ 1024 ]; 45 | 46 | char m_pInputFile[ 1024 ]; 47 | char m_pOutputFile[ 1024 ]; 48 | char m_pParamFile[ 1024 ]; 49 | 50 | int m_nFeatureNum; 51 | ClassifyParam m_cParam; 52 | 53 | int m_nNeighborRequirement; 54 | double m_dbVerticalDegreeRequirement; 55 | double m_dbCosVerticalDegree; 56 | 57 | bool m_bDebugPrintOut; 58 | char m_pDebugPrintOutFile[ 1024 ]; 59 | }; 60 | -------------------------------------------------------------------------------- /src/BldRecons/SPClassify/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : SPClassify Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this SPClassify application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your SPClassify application. 9 | 10 | 11 | SPClassify.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | SPClassify.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named SPClassify.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/SPClassify/SPClassify.cpp: -------------------------------------------------------------------------------- 1 | // SPClassify.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "ParamManager.h" 6 | #include "ClassifyGrid.h" 7 | 8 | void main(int argc, char * argv[]) 9 | { 10 | CParamManager::GetParamManager()->RegisterCommandLine( argc, argv ); 11 | 12 | CClassifyGrid grid; 13 | 14 | grid.Classify(); 15 | } 16 | -------------------------------------------------------------------------------- /src/BldRecons/SPClassify/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SPClassify.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/SPClassify/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | // TODO: reference additional headers your program requires here 19 | -------------------------------------------------------------------------------- /src/BldRecons/SPInfo/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/SPInfo/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : SPInfo Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this SPInfo application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your SPInfo application. 9 | 10 | 11 | SPInfo.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | SPInfo.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named SPInfo.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/SPInfo/SPInfo.cpp: -------------------------------------------------------------------------------- 1 | // SPInfo.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include 6 | #include "Streaming\SPReader.h" 7 | #include "Grid\StreamingGrid.h" 8 | 9 | void PrintHelp() { 10 | fprintf_s( stderr, "Please use correct command format:\n\n" ); 11 | fprintf_s( stderr, "\t> SPInfo input_file output_file\n\n" ); 12 | } 13 | 14 | void main( int argc, char * argv[] ) 15 | { 16 | if ( argc <= 2 ) { 17 | PrintHelp(); 18 | exit( 0 ); 19 | } 20 | 21 | CStreamingGrid grid; 22 | 23 | CSPReader reader; 24 | reader.OpenFile( argv[ 1 ] ); 25 | reader.RegisterGrid( &grid ); 26 | reader.ReadHeader(); 27 | 28 | std::vector< int > grid_index( grid.m_nSideNumber * grid.m_nSideNumber, -1 ); 29 | 30 | int num = 0; 31 | int chunk_num = 0; 32 | int progress = 0; 33 | 34 | fprintf_s( stderr, "Converting progress ... 0%%" ); 35 | 36 | bool bLoop = true; 37 | while ( bLoop ) { 38 | if ( reader.ReadNextElement() ) { // read chunk information 39 | 40 | SPCell * cell = reader.GetCell(); 41 | if ( cell->type == -1 ) { 42 | bLoop = false; 43 | } else if ( cell->type == 1 ) { 44 | grid_index[ cell->chunk_index ] = chunk_num; 45 | chunk_num++; 46 | } 47 | 48 | } else { 49 | 50 | num++; 51 | 52 | int new_progress = ( int )( num * 100.0 / grid.m_nPointNumber ); 53 | if ( new_progress > progress ) { 54 | progress = new_progress; 55 | fprintf_s( stderr, "\b\b\b\b%3d%%", progress ); 56 | } 57 | 58 | } 59 | } 60 | 61 | fprintf_s( stderr, " ... done.\n" ); 62 | fprintf_s( stderr, "Writing to info file ...... " ); 63 | 64 | FILE * file; 65 | fopen_s( & file, argv[ 2 ], "w" ); 66 | for ( int x = 0; x < grid.m_nSideNumber; x++ ) { 67 | for ( int y = 0; y < grid.m_nSideNumber; y++ ) { 68 | fprintf_s( file, "%d ", grid_index[ x * grid.m_nSideNumber + y ] ); 69 | } 70 | fprintf_s( file, "\n" ); 71 | } 72 | 73 | fprintf_s( stderr, "done.\n" ); 74 | 75 | } 76 | -------------------------------------------------------------------------------- /src/BldRecons/SPInfo/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SPInfo.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/SPInfo/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | // TODO: reference additional headers your program requires here 19 | -------------------------------------------------------------------------------- /src/BldRecons/SPSplit/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/SPSplit/FixedPatchSet.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | #include "Lidar\LidarCommon.h" 5 | 6 | class CFixedPatchSet 7 | { 8 | public: 9 | class CFixedPatchSet_hash_compare 10 | { // traits class for hash containers 11 | public: 12 | enum 13 | { // parameters for hash table 14 | bucket_size = 4, // 0 < bucket_size 15 | min_buckets = 8}; // min_buckets = 2 ^^ N, 0 < N 16 | 17 | CFixedPatchSet_hash_compare() 18 | { // construct with default comparator 19 | } 20 | 21 | size_t operator()(const PatchIndex & _Keyval) const 22 | { // hash _Keyval to size_t value by pseudorandomizing transform 23 | long _Quot = GLOBAL_INDEX( _Keyval ) ^ LOCAL_INDEX( _Keyval ); 24 | ldiv_t _Qrem = ldiv(_Quot, 127773); 25 | 26 | _Qrem.rem = 16807 * _Qrem.rem - 2836 * _Qrem.quot; 27 | if (_Qrem.rem < 0) 28 | _Qrem.rem += LONG_MAX; 29 | return ((size_t)_Qrem.rem); 30 | } 31 | 32 | bool operator()(const PatchIndex & _Keyval1, const PatchIndex & _Keyval2) const 33 | { // test if _Keyval1 ordered before _Keyval2 34 | return (_Keyval1 < _Keyval2); 35 | } 36 | }; 37 | 38 | public: 39 | CFixedPatchSet(void); 40 | ~CFixedPatchSet(void); 41 | 42 | protected: 43 | static CFixedPatchSet * singletonInstance; 44 | 45 | public: 46 | static CFixedPatchSet * GetFixedPatchSet( void ) 47 | { 48 | if ( singletonInstance == NULL ) 49 | { 50 | singletonInstance = new CFixedPatchSet( ); 51 | } 52 | return singletonInstance; 53 | } 54 | 55 | public: 56 | stdext::hash_map< PatchIndex, PatchInfoEx, CFixedPatchSet_hash_compare > m_hashData; 57 | int m_nMerged; 58 | 59 | public: 60 | void Init(); 61 | void Push( PatchIndex patch, int num ); 62 | void PushEx( PatchIndex patch, int num, double height ); 63 | PatchInfo * Find( PatchInfo * patch ); 64 | PatchInfoEx * FindEx( PatchInfo * patch ); 65 | void Merge( PatchInfo * patch1, PatchInfo * patch2 ); 66 | 67 | public: 68 | void Save( char filename[] ); 69 | void Load( char filename[] ); 70 | static const char file_signature[]; 71 | static const int file_version; 72 | }; 73 | -------------------------------------------------------------------------------- /src/BldRecons/SPSplit/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CParamManager 4 | { 5 | public: 6 | CParamManager(void); 7 | ~CParamManager(void); 8 | 9 | protected: 10 | static CParamManager * singletonInstance; 11 | 12 | public: 13 | static CParamManager * GetParamManager( void ) 14 | { 15 | if ( singletonInstance == NULL ) 16 | { 17 | singletonInstance = new CParamManager( ); 18 | } 19 | return singletonInstance; 20 | } 21 | 22 | void RegisterCommandLine( int argc, char * argv[] ); 23 | 24 | private: 25 | void GetNames(); 26 | void LoadConfiguration(); 27 | 28 | public: 29 | char m_pExeName[ 1024 ]; 30 | char m_pTrueName[ 1024 ]; 31 | char m_pDirName[ 1024 ]; 32 | char m_pIniName[ 1024 ]; 33 | 34 | char m_pInputFile[ 1024 ]; 35 | char m_pTempFile[ 1024 ]; 36 | char m_pTempSetFile[ 1024 ]; 37 | char m_pOutputFile[ 1024 ]; 38 | 39 | double m_dbNeighborDistance; 40 | int m_nGroundPatchAssignment; 41 | int m_nLargePatchPointNumber; 42 | double m_dbLargeGroundPatchHeightDifference; 43 | double m_dbSmallGroundPatchHeightDifference; 44 | double m_dbLargeGroundPatchMaxHeight; 45 | 46 | bool m_bDebugPrintOut; 47 | char m_pDebugPrintOutFile[ 1024 ]; 48 | }; 49 | -------------------------------------------------------------------------------- /src/BldRecons/SPSplit/ReadMe.txt: -------------------------------------------------------------------------------- 1 | ======================================================================== 2 | CONSOLE APPLICATION : SPSplit Project Overview 3 | ======================================================================== 4 | 5 | AppWizard has created this SPSplit application for you. 6 | 7 | This file contains a summary of what you will find in each of the files that 8 | make up your SPSplit application. 9 | 10 | 11 | SPSplit.vcproj 12 | This is the main project file for VC++ projects generated using an Application Wizard. 13 | It contains information about the version of Visual C++ that generated the file, and 14 | information about the platforms, configurations, and project features selected with the 15 | Application Wizard. 16 | 17 | SPSplit.cpp 18 | This is the main application source file. 19 | 20 | ///////////////////////////////////////////////////////////////////////////// 21 | Other standard files: 22 | 23 | StdAfx.h, StdAfx.cpp 24 | These files are used to build a precompiled header (PCH) file 25 | named SPSplit.pch and a precompiled types file named StdAfx.obj. 26 | 27 | ///////////////////////////////////////////////////////////////////////////// 28 | Other notes: 29 | 30 | AppWizard uses "TODO:" comments to indicate parts of the source code you 31 | should add to or customize. 32 | 33 | ///////////////////////////////////////////////////////////////////////////// 34 | -------------------------------------------------------------------------------- /src/BldRecons/SPSplit/RefineChunk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Lidar\LidarCommon.h" 4 | #include "Streaming\SPBCommon.h" 5 | 6 | class CRefineGrid; 7 | 8 | class CRefineChunk 9 | { 10 | public: 11 | CRefineChunk( int index, int number, CRefineGrid * grid ); 12 | ~CRefineChunk( void ); 13 | 14 | public: 15 | std::vector< PatchPointData > m_vecPatchPointData; 16 | std::vector< PatchPointDataVector > m_vecGridIndex; 17 | 18 | int m_iPointIndex; 19 | int m_iIndex; 20 | int m_iX; 21 | int m_iY; 22 | CVector3D m_vPosition; 23 | 24 | protected: 25 | CRefineGrid * m_pGrid; 26 | 27 | public: 28 | void PushPoint( SPBPoint * p ); 29 | void BuildGridIndex(); 30 | 31 | public: 32 | int Index( const CVector3D & v ); 33 | int Index( int x, int y ); 34 | void RegularizeX( int & x ); 35 | void RegularizeY( int & y ); 36 | }; 37 | -------------------------------------------------------------------------------- /src/BldRecons/SPSplit/RefineGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Grid\StreamingGrid.h" 6 | #include "Streaming\SPBReader.h" 7 | #include "Streaming\SPBWriter.h" 8 | #include "RefineChunk.h" 9 | #include "FixedPatchSet.h" 10 | 11 | class CRefineGrid : public CStreamingGrid 12 | { 13 | public: 14 | CRefineGrid(void); 15 | ~CRefineGrid(void); 16 | 17 | public: 18 | CSPBReader m_cReader; 19 | CSPBWriter m_cWriter; 20 | 21 | std::vector< CRefineChunk * > m_vecPointer; 22 | 23 | CFixedPatchSet * m_pFixedSet; 24 | 25 | PatchIndex m_iGround; 26 | 27 | public: 28 | void Refine(); 29 | 30 | private: 31 | int ReadNextChunk(); 32 | 33 | void InitRoofPatch(); 34 | void MergeRoofPatch( CRefineChunk * chunk ); 35 | void FinRoofPatch(); 36 | 37 | void InitWritePatch(); 38 | void WritePatch( CRefineChunk * chunk ); 39 | void FinWritePatch(); 40 | 41 | protected: 42 | int m_nTotalNumber; 43 | int m_nBuildingNumber; 44 | int m_nTreeNumber; 45 | int m_nNoiseNumber; 46 | int m_nGroundNumber; 47 | }; 48 | 49 | /* 50 | CFixedPatchSet m_cLargePatchSet; 51 | void MergeLargeGround(); 52 | void MergeSmallGround(); 53 | 54 | void InitLargeGround(); 55 | void FinLargeGround(); 56 | */ 57 | -------------------------------------------------------------------------------- /src/BldRecons/SPSplit/SPSplit.cpp: -------------------------------------------------------------------------------- 1 | // SPSplit.cpp : Defines the entry point for the console application. 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "ParamManager.h" 6 | #include "SplitGrid.h" 7 | #include "RefineGrid.h" 8 | 9 | void main(int argc, char * argv[]) 10 | { 11 | CParamManager::GetParamManager()->RegisterCommandLine( argc, argv ); 12 | 13 | CSplitGrid grid; 14 | 15 | grid.Split(); 16 | 17 | // CFixedPatchSet::GetFixedPatchSet()->Load( CParamManager::GetParamManager()->m_pTempSetFile ); 18 | 19 | CRefineGrid rgrid; 20 | 21 | rgrid.Refine(); 22 | } 23 | -------------------------------------------------------------------------------- /src/BldRecons/SPSplit/SplitChunk.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Lidar\LidarCommon.h" 4 | #include "Streaming\SPACommon.h" 5 | 6 | class CSplitGrid; 7 | 8 | class CSplitChunk 9 | { 10 | public: 11 | enum SplitChunkState { 12 | SCS_New = 0, 13 | SCS_Read = 1, 14 | SCS_Splitted = 2, 15 | SCS_Written = 3 16 | }; 17 | 18 | public: 19 | CSplitChunk( int index, int number, CSplitGrid * grid ); 20 | ~CSplitChunk( void ); 21 | 22 | public: 23 | std::vector< PatchPointData > m_vecPatchPointData; 24 | std::vector< PatchPointDataVector > m_vecGridIndex; 25 | 26 | int m_iPointIndex; 27 | int m_iIndex; 28 | int m_iX; 29 | int m_iY; 30 | CVector3D m_vPosition; 31 | 32 | protected: 33 | CSplitGrid * m_pGrid; 34 | 35 | public: 36 | void PushPoint( SPAPoint * p ); 37 | void BuildGridIndex(); 38 | 39 | public: 40 | int Index( const CVector3D & v ); 41 | int Index( int x, int y ); 42 | void RegularizeX( int & x ); 43 | void RegularizeY( int & y ); 44 | }; 45 | -------------------------------------------------------------------------------- /src/BldRecons/SPSplit/SplitGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Grid\StreamingGrid.h" 6 | #include "Streaming\SPAReader.h" 7 | #include "Streaming\SPBWriter.h" 8 | #include "SplitChunk.h" 9 | #include "FixedPatchSet.h" 10 | 11 | class CSplitGrid : public CStreamingGrid 12 | { 13 | public: 14 | CSplitGrid(void); 15 | ~CSplitGrid(void); 16 | 17 | public: 18 | CSPAReader m_cReader; 19 | CSPBWriter m_cWriter; 20 | 21 | std::vector< CSplitChunk * > m_vecPointer; 22 | std::vector< CSplitChunk::SplitChunkState > m_vecState; 23 | 24 | CFixedPatchSet * m_pFixedSet; 25 | 26 | public: 27 | void Split(); 28 | 29 | private: 30 | void Init(); 31 | int ReadNextChunk(); 32 | 33 | void SplitChunk( CSplitChunk * chunk ); 34 | void WriteChunk( CSplitChunk * chunk ); 35 | 36 | void NotifySCSRead( int ix, int iy ); 37 | void NotifySCSSplitted( int ix, int iy ); 38 | 39 | inline bool CheckSCSRead( int idx ) { 40 | return ( m_vecState[ idx ] >= CSplitChunk::SCS_Read ); 41 | } 42 | inline bool CheckSCSSplitted( int idx ) { 43 | return ( m_vecState[ idx ] >= CSplitChunk::SCS_Splitted ); 44 | } 45 | inline bool CheckSCSWritten( int idx ) { 46 | return ( m_vecState[ idx ] >= CSplitChunk::SCS_Written ); 47 | } 48 | 49 | protected: 50 | void MergeNeighbor( PatchPointData & point, int ndis, double distance, CSplitChunk * chunk, int x, int y ); 51 | PatchInfo * FindPatch( PatchInfo * info, bool & fixed ); 52 | void MergePatch( PatchInfo * info1, PatchInfo * info2 ); 53 | void FixChunk( CSplitChunk * chunk, int ndis ); 54 | 55 | private: 56 | void PrintGridState( const char filename[] ); 57 | }; 58 | -------------------------------------------------------------------------------- /src/BldRecons/SPSplit/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // SPSplit.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src/BldRecons/SPSplit/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. 9 | #define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | 17 | 18 | // TODO: reference additional headers your program requires here 19 | -------------------------------------------------------------------------------- /src/BldRecons/huma/.gitignore: -------------------------------------------------------------------------------- 1 | /Debug/ 2 | /Release/ 3 | /*.user 4 | -------------------------------------------------------------------------------- /src/BldRecons/huma/ChildFrm.cpp: -------------------------------------------------------------------------------- 1 | // ChildFrm.cpp : implementation of the CChildFrame class 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "huma.h" 6 | 7 | #include "ChildFrm.h" 8 | 9 | #ifdef _DEBUG 10 | #define new DEBUG_NEW 11 | #undef THIS_FILE 12 | static char THIS_FILE[] = __FILE__; 13 | #endif 14 | 15 | ///////////////////////////////////////////////////////////////////////////// 16 | // CChildFrame 17 | 18 | IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd) 19 | 20 | BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd) 21 | //{{AFX_MSG_MAP(CChildFrame) 22 | ON_COMMAND_EX(ID_VIEW_FIGURE, OnBarCheck) 23 | ON_UPDATE_COMMAND_UI(ID_VIEW_FIGURE, OnUpdateControlBarMenu) 24 | 25 | //}}AFX_MSG_MAP 26 | END_MESSAGE_MAP() 27 | 28 | ///////////////////////////////////////////////////////////////////////////// 29 | // CChildFrame construction/destruction 30 | 31 | CChildFrame::CChildFrame() 32 | { 33 | // TODO: add member initialization code here 34 | 35 | } 36 | 37 | CChildFrame::~CChildFrame() 38 | { 39 | } 40 | 41 | BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs) 42 | { 43 | // TODO: Modify the Window class or styles here by modifying 44 | // the CREATESTRUCT cs 45 | 46 | if( !CMDIChildWnd::PreCreateWindow(cs) ) 47 | return FALSE; 48 | 49 | return TRUE; 50 | } 51 | 52 | void CChildFrame::ActivateFrame(int nCmdShow) 53 | { 54 | // TODO: Modify this function to change how the frame is activated. 55 | 56 | nCmdShow = SW_SHOWMAXIMIZED; 57 | CMDIChildWnd::ActivateFrame(nCmdShow); 58 | } 59 | 60 | 61 | ///////////////////////////////////////////////////////////////////////////// 62 | // CChildFrame diagnostics 63 | 64 | #ifdef _DEBUG 65 | void CChildFrame::AssertValid() const 66 | { 67 | CMDIChildWnd::AssertValid(); 68 | } 69 | 70 | void CChildFrame::Dump(CDumpContext& dc) const 71 | { 72 | CMDIChildWnd::Dump(dc); 73 | } 74 | 75 | #endif //_DEBUG 76 | 77 | ///////////////////////////////////////////////////////////////////////////// 78 | // CChildFrame message handlers 79 | 80 | -------------------------------------------------------------------------------- /src/BldRecons/huma/ChildFrm.h: -------------------------------------------------------------------------------- 1 | // ChildFrm.h : interface of the CChildFrame class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_CHILDFRM_H__4A79584E_8AD6_48CD_A4DB_15B342E3B1E6__INCLUDED_) 6 | #define AFX_CHILDFRM_H__4A79584E_8AD6_48CD_A4DB_15B342E3B1E6__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | 13 | class CChildFrame : public CMDIChildWnd 14 | { 15 | DECLARE_DYNCREATE(CChildFrame) 16 | public: 17 | CChildFrame(); 18 | 19 | // Attributes 20 | public: 21 | 22 | // Operations 23 | public: 24 | 25 | // Overrides 26 | // ClassWizard generated virtual function overrides 27 | //{{AFX_VIRTUAL(CChildFrame) 28 | public: 29 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 30 | virtual void ActivateFrame(int nCmdShow); 31 | //}}AFX_VIRTUAL 32 | 33 | // Implementation 34 | public: 35 | virtual ~CChildFrame(); 36 | #ifdef _DEBUG 37 | virtual void AssertValid() const; 38 | virtual void Dump(CDumpContext& dc) const; 39 | #endif 40 | 41 | // Generated message map functions 42 | protected: 43 | //{{AFX_MSG(CChildFrame) 44 | //}}AFX_MSG 45 | DECLARE_MESSAGE_MAP() 46 | }; 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | 50 | //{{AFX_INSERT_LOCATION}} 51 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 52 | 53 | #endif // !defined(AFX_CHILDFRM_H__4A79584E_8AD6_48CD_A4DB_15B342E3B1E6__INCLUDED_) 54 | -------------------------------------------------------------------------------- /src/BldRecons/huma/Common/COMMON.CPP: -------------------------------------------------------------------------------- 1 | /************************************************************ 2 | * Common.cpp : common include things * 3 | * Version : 1.0 * 4 | * Copyright : THU NCC * 5 | * * 6 | * ------- EditLog ------- * 7 | * Apr.12,2002 : Created by windbell9@sina.com * 8 | * * 9 | ************************************************************/ 10 | 11 | #include "common.h" 12 | 13 | const double COMMON::_double_eps = 1e-16; 14 | const int COMMON::NONE = 0; 15 | const int COMMON::TRIANGLE = 3; -------------------------------------------------------------------------------- /src/BldRecons/huma/Common/COMMON.H: -------------------------------------------------------------------------------- 1 | /************************************************************ 2 | * Common.h : common include things * 3 | * Version : 1.0 * 4 | * Copyright : THU NCC * 5 | * * 6 | * ------- EditLog ------- * 7 | * Apr.12,2002 : Created by windbell9@sina.com * 8 | * * 9 | ************************************************************/ 10 | 11 | #ifndef _COMMON_H_ 12 | #define _COMMON_H_ 13 | 14 | //#include 15 | //#include "gl/gl.h" 16 | //#include "gl/glu.h" 17 | //#include "gl/glaux.h" 18 | 19 | #define DOUBLE_EPS 1e-16 20 | // double zero eps 21 | #define EQUALZERO(x) (fabs((x)) < DOUBLE_EPS) 22 | 23 | #endif 24 | -------------------------------------------------------------------------------- /src/BldRecons/huma/Display/Display.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianyizh/UrbanReconstruction/8b058349fd860ea9029623a92d705dd93a4e4878/src/BldRecons/huma/Display/Display.cpp -------------------------------------------------------------------------------- /src/BldRecons/huma/Display/Display.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianyizh/UrbanReconstruction/8b058349fd860ea9029623a92d705dd93a4e4878/src/BldRecons/huma/Display/Display.h -------------------------------------------------------------------------------- /src/BldRecons/huma/Display/scene.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianyizh/UrbanReconstruction/8b058349fd860ea9029623a92d705dd93a4e4878/src/BldRecons/huma/Display/scene.cpp -------------------------------------------------------------------------------- /src/BldRecons/huma/Display/scene.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianyizh/UrbanReconstruction/8b058349fd860ea9029623a92d705dd93a4e4878/src/BldRecons/huma/Display/scene.h -------------------------------------------------------------------------------- /src/BldRecons/huma/DlgInput.cpp: -------------------------------------------------------------------------------- 1 | // DlgInput.cpp : implementation file 2 | // 3 | 4 | #include "stdafx.h" 5 | #include "huma.h" 6 | #include "DlgInput.h" 7 | 8 | #ifdef _DEBUG 9 | #define new DEBUG_NEW 10 | #undef THIS_FILE 11 | static char THIS_FILE[] = __FILE__; 12 | #endif 13 | 14 | ///////////////////////////////////////////////////////////////////////////// 15 | // CDlgInput dialog 16 | 17 | 18 | CDlgInput::CDlgInput(CWnd* pParent /*=NULL*/) 19 | : CDialog(CDlgInput::IDD, pParent) 20 | { 21 | //{{AFX_DATA_INIT(CDlgInput) 22 | m_InputNumber = 100; 23 | m_bInfinite = TRUE; 24 | //}}AFX_DATA_INIT 25 | } 26 | 27 | 28 | void CDlgInput::DoDataExchange(CDataExchange* pDX) 29 | { 30 | CDialog::DoDataExchange(pDX); 31 | //{{AFX_DATA_MAP(CDlgInput) 32 | DDX_Text(pDX, IDC_EDIT1, m_InputNumber); 33 | DDV_MinMaxUInt(pDX, m_InputNumber, 1, 5000); 34 | DDX_Check(pDX, IDC_CHECK_INFINITE, m_bInfinite); 35 | //}}AFX_DATA_MAP 36 | } 37 | 38 | 39 | BEGIN_MESSAGE_MAP(CDlgInput, CDialog) 40 | //{{AFX_MSG_MAP(CDlgInput) 41 | //}}AFX_MSG_MAP 42 | END_MESSAGE_MAP() 43 | 44 | ///////////////////////////////////////////////////////////////////////////// 45 | // CDlgInput message handlers 46 | 47 | void CDlgInput::OnOK() 48 | { 49 | // TODO: Add extra validation here 50 | UpdateData(); 51 | CDialog::OnOK(); 52 | } 53 | 54 | void CDlgInput::OnCancel() 55 | { 56 | // TODO: Add extra cleanup here 57 | CDialog::OnCancel(); 58 | } 59 | -------------------------------------------------------------------------------- /src/BldRecons/huma/DlgInput.h: -------------------------------------------------------------------------------- 1 | #if !defined(AFX_DLGINPUT_H__23AF49E1_5C77_46DC_AC6E_CAB27361187E__INCLUDED_) 2 | #define AFX_DLGINPUT_H__23AF49E1_5C77_46DC_AC6E_CAB27361187E__INCLUDED_ 3 | 4 | #if _MSC_VER > 1000 5 | #pragma once 6 | #endif // _MSC_VER > 1000 7 | // DlgInput.h : header file 8 | // 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // CDlgInput dialog 12 | 13 | class CDlgInput : public CDialog 14 | { 15 | // Construction 16 | public: 17 | CDlgInput(CWnd* pParent = NULL); // standard constructor 18 | 19 | // Dialog Data 20 | //{{AFX_DATA(CDlgInput) 21 | enum { IDD = IDD_INPUT_DIALOG }; 22 | UINT m_InputNumber; 23 | BOOL m_bInfinite; 24 | //}}AFX_DATA 25 | 26 | 27 | // Overrides 28 | // ClassWizard generated virtual function overrides 29 | //{{AFX_VIRTUAL(CDlgInput) 30 | protected: 31 | virtual void DoDataExchange(CDataExchange* pDX); // DDX/DDV support 32 | //}}AFX_VIRTUAL 33 | 34 | // Implementation 35 | protected: 36 | 37 | // Generated message map functions 38 | //{{AFX_MSG(CDlgInput) 39 | virtual void OnOK(); 40 | virtual void OnCancel(); 41 | //}}AFX_MSG 42 | DECLARE_MESSAGE_MAP() 43 | }; 44 | 45 | //{{AFX_INSERT_LOCATION}} 46 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 47 | 48 | #endif // !defined(AFX_DLGINPUT_H__23AF49E1_5C77_46DC_AC6E_CAB27361187E__INCLUDED_) 49 | -------------------------------------------------------------------------------- /src/BldRecons/huma/MainFrm.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianyizh/UrbanReconstruction/8b058349fd860ea9029623a92d705dd93a4e4878/src/BldRecons/huma/MainFrm.cpp -------------------------------------------------------------------------------- /src/BldRecons/huma/MainFrm.h: -------------------------------------------------------------------------------- 1 | // MainFrm.h : interface of the CMainFrame class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_MAINFRM_H__F48341A2_90BE_4150_8F7C_F1D464410620__INCLUDED_) 6 | #define AFX_MAINFRM_H__F48341A2_90BE_4150_8F7C_F1D464410620__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | class CMainFrame : public CMDIFrameWnd 13 | { 14 | DECLARE_DYNAMIC(CMainFrame) 15 | public: 16 | CMainFrame(); 17 | 18 | // Attributes 19 | public: 20 | 21 | // Operations 22 | public: 23 | 24 | // Overrides 25 | // ClassWizard generated virtual function overrides 26 | //{{AFX_VIRTUAL(CMainFrame) 27 | public: 28 | virtual BOOL PreCreateWindow(CREATESTRUCT& cs); 29 | //}}AFX_VIRTUAL 30 | 31 | // Implementation 32 | public: 33 | virtual ~CMainFrame(); 34 | #ifdef _DEBUG 35 | virtual void AssertValid() const; 36 | virtual void Dump(CDumpContext& dc) const; 37 | #endif 38 | 39 | protected: // control bar embedded members 40 | CStatusBar m_wndStatusBar; 41 | CToolBar m_wndToolBar; 42 | 43 | // Generated message map functions 44 | protected: 45 | //{{AFX_MSG(CMainFrame) 46 | afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct); 47 | // NOTE - the ClassWizard will add and remove member functions here. 48 | // DO NOT EDIT what you see in these blocks of generated code! 49 | //}}AFX_MSG 50 | DECLARE_MESSAGE_MAP() 51 | }; 52 | 53 | ///////////////////////////////////////////////////////////////////////////// 54 | 55 | //{{AFX_INSERT_LOCATION}} 56 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 57 | 58 | #endif // !defined(AFX_MAINFRM_H__F48341A2_90BE_4150_8F7C_F1D464410620__INCLUDED_) 59 | -------------------------------------------------------------------------------- /src/BldRecons/huma/Model/mesh.cpp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianyizh/UrbanReconstruction/8b058349fd860ea9029623a92d705dd93a4e4878/src/BldRecons/huma/Model/mesh.cpp -------------------------------------------------------------------------------- /src/BldRecons/huma/Model/mesh.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianyizh/UrbanReconstruction/8b058349fd860ea9029623a92d705dd93a4e4878/src/BldRecons/huma/Model/mesh.h -------------------------------------------------------------------------------- /src/BldRecons/huma/Model/model.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianyizh/UrbanReconstruction/8b058349fd860ea9029623a92d705dd93a4e4878/src/BldRecons/huma/Model/model.h -------------------------------------------------------------------------------- /src/BldRecons/huma/StdAfx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // huma.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /src/BldRecons/huma/StdAfx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #if !defined(AFX_STDAFX_H__4B445B86_FF90_4051_B0ED_217497A0A9A9__INCLUDED_) 7 | #define AFX_STDAFX_H__4B445B86_FF90_4051_B0ED_217497A0A9A9__INCLUDED_ 8 | 9 | #if _MSC_VER > 1000 10 | #pragma once 11 | #endif // _MSC_VER > 1000 12 | 13 | #define VC_EXTRALEAN // Exclude rarely-used stuff from Windows headers 14 | 15 | #include // MFC core and standard components 16 | #include // MFC extensions 17 | #include // MFC Automation classes 18 | #include // MFC support for Internet Explorer 4 Common Controls 19 | #ifndef _AFX_NO_AFXCMN_SUPPORT 20 | #include // MFC support for Windows Common Controls 21 | #endif // _AFX_NO_AFXCMN_SUPPORT 22 | 23 | 24 | //{{AFX_INSERT_LOCATION}} 25 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 26 | 27 | #endif // !defined(AFX_STDAFX_H__4B445B86_FF90_4051_B0ED_217497A0A9A9__INCLUDED_) 28 | -------------------------------------------------------------------------------- /src/BldRecons/huma/Worker/Worker.cpp: -------------------------------------------------------------------------------- 1 | // Worker.cpp: implementation of the CWorker class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | #include "stdafx.h" 5 | #include "Worker.h" 6 | 7 | #ifdef _DEBUG 8 | #undef THIS_FILE 9 | static char THIS_FILE[]=__FILE__; 10 | #define new DEBUG_NEW 11 | #endif 12 | 13 | ////////////////////////////////////////////////////////////////////// 14 | // Construction/Destruction 15 | ////////////////////////////////////////////////////////////////////// 16 | 17 | CWorker::CWorker() 18 | { 19 | 20 | } 21 | 22 | CWorker::~CWorker() 23 | { 24 | 25 | } 26 | -------------------------------------------------------------------------------- /src/BldRecons/huma/Worker/Worker.h: -------------------------------------------------------------------------------- 1 | // Worker.h: interface for the CWorker class. 2 | // 3 | ////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_WORKER_H__E1E55FEA_3BC3_4ED3_B2DD_CEF37B06BC8F__INCLUDED_) 6 | #define AFX_WORKER_H__E1E55FEA_3BC3_4ED3_B2DD_CEF37B06BC8F__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | //#include //for CDC class 13 | 14 | 15 | class CWorker 16 | { 17 | public: 18 | CWorker(); 19 | virtual ~CWorker(); 20 | // virtual void Draw(CDC* pDC); 21 | }; 22 | 23 | #endif // !defined(AFX_WORKER_H__E1E55FEA_3BC3_4ED3_B2DD_CEF37B06BC8F__INCLUDED_) 24 | -------------------------------------------------------------------------------- /src/BldRecons/huma/huma.h: -------------------------------------------------------------------------------- 1 | // huma.h : main header file for the HUMA application 2 | // 3 | 4 | #if !defined(AFX_HUMA_H__274E36E6_E064_49FF_B730_E7C905887172__INCLUDED_) 5 | #define AFX_HUMA_H__274E36E6_E064_49FF_B730_E7C905887172__INCLUDED_ 6 | 7 | #if _MSC_VER > 1000 8 | #pragma once 9 | #endif // _MSC_VER > 1000 10 | 11 | #ifndef __AFXWIN_H__ 12 | #error include 'stdafx.h' before including this file for PCH 13 | #endif 14 | 15 | #include "resource.h" // main symbols 16 | 17 | ///////////////////////////////////////////////////////////////////////////// 18 | // CHumaApp: 19 | // See huma.cpp for the implementation of this class 20 | // 21 | 22 | class CHumaApp : public CWinApp 23 | { 24 | public: 25 | CHumaApp(); 26 | 27 | // Overrides 28 | // ClassWizard generated virtual function overrides 29 | //{{AFX_VIRTUAL(CHumaApp) 30 | public: 31 | virtual BOOL InitInstance(); 32 | //}}AFX_VIRTUAL 33 | 34 | // Implementation 35 | //{{AFX_MSG(CHumaApp) 36 | afx_msg void OnAppAbout(); 37 | // NOTE - the ClassWizard will add and remove member functions here. 38 | // DO NOT EDIT what you see in these blocks of generated code ! 39 | //}}AFX_MSG 40 | DECLARE_MESSAGE_MAP() 41 | }; 42 | 43 | 44 | ///////////////////////////////////////////////////////////////////////////// 45 | 46 | //{{AFX_INSERT_LOCATION}} 47 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 48 | 49 | #endif // !defined(AFX_HUMA_H__274E36E6_E064_49FF_B730_E7C905887172__INCLUDED_) 50 | -------------------------------------------------------------------------------- /src/BldRecons/huma/huma.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 10.00 2 | # Visual Studio 2008 3 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "huma", "huma.vcproj", "{8A58DFB4-ACDD-4DEE-AE89-2D2220B1DD8E}" 4 | EndProject 5 | Global 6 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 7 | Debug|Win32 = Debug|Win32 8 | Release|Win32 = Release|Win32 9 | EndGlobalSection 10 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 11 | {8A58DFB4-ACDD-4DEE-AE89-2D2220B1DD8E}.Debug|Win32.ActiveCfg = Debug|Win32 12 | {8A58DFB4-ACDD-4DEE-AE89-2D2220B1DD8E}.Debug|Win32.Build.0 = Debug|Win32 13 | {8A58DFB4-ACDD-4DEE-AE89-2D2220B1DD8E}.Release|Win32.ActiveCfg = Release|Win32 14 | {8A58DFB4-ACDD-4DEE-AE89-2D2220B1DD8E}.Release|Win32.Build.0 = Release|Win32 15 | EndGlobalSection 16 | GlobalSection(SolutionProperties) = preSolution 17 | HideSolutionNode = FALSE 18 | EndGlobalSection 19 | EndGlobal 20 | -------------------------------------------------------------------------------- /src/BldRecons/huma/humaDoc.h: -------------------------------------------------------------------------------- 1 | // humaDoc.h : interface of the CHumaDoc class 2 | // 3 | ///////////////////////////////////////////////////////////////////////////// 4 | 5 | #if !defined(AFX_HUMADOC_H__5C5B097B_351F_4EEC_B830_9A643EA0BBE8__INCLUDED_) 6 | #define AFX_HUMADOC_H__5C5B097B_351F_4EEC_B830_9A643EA0BBE8__INCLUDED_ 7 | 8 | #if _MSC_VER > 1000 9 | #pragma once 10 | #endif // _MSC_VER > 1000 11 | 12 | #include "model\mesh.h" 13 | 14 | class CHumaDoc : public CDocument 15 | { 16 | protected: // create from serialization only 17 | CHumaDoc(); 18 | DECLARE_DYNCREATE(CHumaDoc) 19 | 20 | // Attributes 21 | public: 22 | CMesh* m_pMesh;//temp 23 | CMesh* m_pTempMesh; 24 | 25 | // Operations 26 | public: 27 | 28 | // Overrides 29 | // ClassWizard generated virtual function overrides 30 | //{{AFX_VIRTUAL(CHumaDoc) 31 | public: 32 | virtual BOOL OnNewDocument(); 33 | virtual void Serialize(CArchive& ar); 34 | virtual BOOL OnOpenDocument(LPCTSTR lpszPathName); 35 | virtual BOOL OnSaveDocument(LPCTSTR lpszPathName); 36 | //}}AFX_VIRTUAL 37 | 38 | // Implementation 39 | public: 40 | virtual ~CHumaDoc(); 41 | #ifdef _DEBUG 42 | virtual void AssertValid() const; 43 | virtual void Dump(CDumpContext& dc) const; 44 | #endif 45 | 46 | protected: 47 | 48 | // Generated message map functions 49 | protected: 50 | //{{AFX_MSG(CHumaDoc) 51 | // NOTE - the ClassWizard will add and remove member functions here. 52 | // DO NOT EDIT what you see in these blocks of generated code ! 53 | //}}AFX_MSG 54 | DECLARE_MESSAGE_MAP() 55 | }; 56 | 57 | ///////////////////////////////////////////////////////////////////////////// 58 | 59 | //{{AFX_INSERT_LOCATION}} 60 | // Microsoft Visual C++ will insert additional declarations immediately before the previous line. 61 | 62 | #endif // !defined(AFX_HUMADOC_H__5C5B097B_351F_4EEC_B830_9A643EA0BBE8__INCLUDED_) 63 | -------------------------------------------------------------------------------- /src/BldRecons/huma/humaView.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianyizh/UrbanReconstruction/8b058349fd860ea9029623a92d705dd93a4e4878/src/BldRecons/huma/humaView.h -------------------------------------------------------------------------------- /src/BldRecons/huma/res/Toolbar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianyizh/UrbanReconstruction/8b058349fd860ea9029623a92d705dd93a4e4878/src/BldRecons/huma/res/Toolbar.bmp -------------------------------------------------------------------------------- /src/BldRecons/huma/res/huma.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianyizh/UrbanReconstruction/8b058349fd860ea9029623a92d705dd93a4e4878/src/BldRecons/huma/res/huma.ico -------------------------------------------------------------------------------- /src/BldRecons/huma/res/huma.rc2: -------------------------------------------------------------------------------- 1 | // 2 | // HUMA.RC2 - resources Microsoft Visual C++ does not edit directly 3 | // 4 | 5 | #ifdef APSTUDIO_INVOKED 6 | #error this file is not editable by Microsoft Visual C++ 7 | #endif //APSTUDIO_INVOKED 8 | 9 | 10 | ///////////////////////////////////////////////////////////////////////////// 11 | // Add manually edited resources here... 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | -------------------------------------------------------------------------------- /src/BldRecons/huma/res/humaDoc.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/qianyizh/UrbanReconstruction/8b058349fd860ea9029623a92d705dd93a4e4878/src/BldRecons/huma/res/humaDoc.ico -------------------------------------------------------------------------------- /src/BldRecons/install.bat: -------------------------------------------------------------------------------- 1 | Copy Release\*.exe C:\bin 2 | 3 | pause 4 | -------------------------------------------------------------------------------- /src_dualcontouring/DCGrid.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "DCGrid.h" 3 | 4 | CDCGrid::CDCGrid(void) 5 | { 6 | } 7 | 8 | CDCGrid::~CDCGrid(void) 9 | { 10 | } 11 | 12 | ////////////////////////////////////////////////////////////////////////// 13 | // main functions 14 | ////////////////////////////////////////////////////////////////////////// 15 | 16 | void CDCGrid::AssignPointCloud( CPointCloud * pointcloud, double unit_length, double ground_z, bool enable_topology_check ) 17 | { 18 | CIndexingGrid::BuildIndexingGrid( pointcloud, unit_length ); 19 | pointcloud->m_dbGroundZ = ground_z; 20 | m_bTopologyCheck = enable_topology_check; 21 | 22 | } 23 | 24 | void CDCGrid::ComputeHermiteData( int accept_number, double relative_distance, double relative_z ) 25 | { 26 | // parameters set the segmentation criteria 27 | // points are assigned to the same segmentation iff. point_distance < relative_distance && z_difference < relative_z 28 | // segments with less than accept_number points are dropped as outliers 29 | 30 | m_nAcceptNumber = accept_number; 31 | m_dbSegmentationDistance = relative_distance * m_dbGridLength; 32 | m_dbSegmentationZ = relative_z * m_dbGridLength; 33 | 34 | double max_length = m_nHeight > m_nWidth ? m_nHeight - 1 : m_nWidth - 1; 35 | m_nLevel = 1 + ( int )( log( ( double )max_length ) / log( 2.0 ) ); 36 | m_nHDSideNumber = ( 1 << m_nLevel ) + 1; 37 | m_vecHermiteDataXY.resize( m_nHDSideNumber * m_nHDSideNumber ); 38 | m_vecHermiteDataZ.resize( m_nHDSideNumber * m_nHDSideNumber * 2 ); 39 | 40 | ComputeHermiteData_XY(); 41 | ComputeHermiteData_Z(); 42 | } 43 | 44 | void CDCGrid::DualContouringGeometry( double boundary_weight, double error_tolerance, double singular_tolerance ) 45 | { 46 | m_dbBoundaryWeight = boundary_weight; 47 | m_dbErrorTolerance = error_tolerance; 48 | m_dbSingularTolerance = singular_tolerance; 49 | 50 | m_vecNodes.clear(); 51 | m_vecNodes.resize( m_nLevel + 1 ); 52 | 53 | BuildQuadTreeAtLevel0(); 54 | 55 | for ( int l = 1; l <= m_nLevel; l++ ) { 56 | BuildQuadTreeAtLevelN( l ); 57 | } 58 | //PrintLayerNumber(); 59 | } 60 | -------------------------------------------------------------------------------- /src_dualcontouring/DCGridSort.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "DCGrid.h" 3 | 4 | ////////////////////////////////////////////////////////////////////////// 5 | // sort functions 6 | ////////////////////////////////////////////////////////////////////////// 7 | 8 | int compare( const void *arg1, const void *arg2 ) { 9 | CDCGrid::DistanceSorting * n1 = ( CDCGrid::DistanceSorting * ) arg1; 10 | CDCGrid::DistanceSorting * n2 = ( CDCGrid::DistanceSorting * ) arg2; 11 | if ( n1->distance < n2->distance ) 12 | return -1; 13 | else 14 | return 1; 15 | } 16 | 17 | void CDCGrid::SortDistance2D( CVector3DPointer_Vector & points, CVector3D & ref_v, std::vector< int > & cluster, int cluster_index, DistanceSorting_Vector & sorting_result ) 18 | { 19 | for ( int i = 0; i < ( int )cluster.size(); i++ ) { 20 | if ( cluster[ i ] == cluster_index ) { 21 | sorting_result.push_back( DistanceSorting( i, ( * points[ i ] - ref_v ).XY().length() ) ); 22 | } 23 | } 24 | qsort( &( sorting_result[0] ), sorting_result.size(), sizeof( DistanceSorting ), compare ); 25 | } 26 | 27 | void CDCGrid::QSort( DistanceSorting_Vector & sorting_result ) 28 | { 29 | qsort( &( sorting_result[0] ), sorting_result.size(), sizeof( DistanceSorting ), compare ); 30 | } 31 | -------------------------------------------------------------------------------- /src_dualcontouring/Debug/config.ini: -------------------------------------------------------------------------------- 1 | [DualContouring] 2 | WorkingDir ="..\..\models\" 3 | GridLength =1.0 4 | AcceptNumber =4 5 | RelativeDistance =100.0 6 | RelativeZ =1.0 7 | Weight =1.0 8 | ErrorTolerance =1.0 9 | SingularTolerance =0.15 10 | WallRectangle =0 11 | AntiNonManifold =1 12 | SnappingErrorTolerance =1.2 13 | SnappingMinimumLength =7.0 14 | -------------------------------------------------------------------------------- /src_dualcontouring/DualContouring.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 10.00 3 | # Visual Studio 2008 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "DualContouring", "DualContouring.vcproj", "{CD154938-E606-4C4F-BA36-B9267289D030}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Release|Win32 = Release|Win32 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {CD154938-E606-4C4F-BA36-B9267289D030}.Debug|Win32.ActiveCfg = Debug|Win32 13 | {CD154938-E606-4C4F-BA36-B9267289D030}.Debug|Win32.Build.0 = Debug|Win32 14 | {CD154938-E606-4C4F-BA36-B9267289D030}.Release|Win32.ActiveCfg = Release|Win32 15 | {CD154938-E606-4C4F-BA36-B9267289D030}.Release|Win32.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | -------------------------------------------------------------------------------- /src_dualcontouring/ParamManager.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define __pi 3.1415926535897932384626 6 | 7 | struct DualContouringParam { 8 | double m_dbGridLength; 9 | int m_nAcceptNumber; 10 | double m_dbRelativeDistance; 11 | double m_dbRelativeZ; 12 | double m_dbWeight; 13 | double m_dbErrorTolerance; 14 | double m_dbSingularTolerance; 15 | }; 16 | 17 | class CParamManager 18 | { 19 | public: 20 | CParamManager(void); 21 | ~CParamManager(void); 22 | 23 | protected: 24 | static CParamManager * singletonInstance; 25 | 26 | public: 27 | static CParamManager * GetParamManager( void ) 28 | { 29 | if ( singletonInstance == NULL ) 30 | { 31 | singletonInstance = new CParamManager( ); 32 | } 33 | return singletonInstance; 34 | } 35 | 36 | void RegisterCommandLine( int argc, char * argv[] ); 37 | 38 | private: 39 | void GetNames(); 40 | void LoadConfiguration(); 41 | 42 | public: 43 | char m_pExeName[ 1024 ]; 44 | char m_pTrueName[ 1024 ]; 45 | char m_pDirName[ 1024 ]; 46 | char m_pIniName[ 1024 ]; 47 | 48 | char m_pWorkingDir[ 1024 ]; 49 | 50 | DualContouringParam m_cDCParam; 51 | }; 52 | -------------------------------------------------------------------------------- /src_dualcontouring/ReadMe.txt: -------------------------------------------------------------------------------- 1 | Dual Contouring Demo 2 | Qian-Yi Zhou (qianyizh@usc.edu) 3 | Version: 1.01, last updated 10/5/2010 4 | Project page: 5 | http://graphics.usc.edu/~qianyizh/projects/dualcontouring.html 6 | http://graphics.usc.edu/~qianyizh/projects/buildingreconstruction.html 7 | http://graphics.usc.edu/~qianyizh/software.html 8 | 9 | 10 | I. Introduction 11 | 12 | This program is a demo of 2.5D dual contouring, based on paper '2.5D Dual Contouring: A Robust Approach to Creating Building Models from Aerial LiDAR Point Clouds', published on ECCV 2010. 13 | All the related resources can be found on the project page. 14 | 15 | 16 | II. Usage 17 | 18 | The configuration of the demo is stored in config.ini which should be put in the same directory of the executable program. 19 | 20 | In the configuration file, items mean: 21 | 22 | [DualContouring] 23 | WorkingDir ="..\models\" 24 | -- Working directory, in which the program will traverse all the files ending in "xyzn" and apply our algorithm to produce "obj" files 25 | GridLength =1.0 26 | -- Unit length of the uniform grid 27 | AcceptNumber =4 28 | -- During segmentation, this is the minimum point number of a potential roof cluster 29 | RelativeDistance =100.0 30 | RelativeZ =1.0 31 | -- Segmentation takes two points in the same cluster iff ( distance < RelativeDistance && height_difference < RelativeZ ) 32 | Weight =1.0 33 | -- Weight w to balance 2D boundary error term and 3D surface error term 34 | ErrorTolerance =1.0 35 | -- Threshold used to control bottom-up simplification 36 | SingularTolerance =0.15 37 | -- Threshold used to determine if singular treatment is needed when solving matrix 38 | WallRectangle =0 39 | AntiNonManifold =1 40 | SnappingErrorTolerance =1.2 41 | SnappingMinimumLength =7.0 42 | -- Advanced functions not supported in this demo 43 | 44 | ******** for a fully functional program, visit our website ******** 45 | http://graphics.usc.edu/~qianyizh/projects/buildingreconstruction.html 46 | 47 | 48 | III. Release Notes 49 | 50 | 1.01 51 | Fixed a bug that may cause program crash. 52 | 53 | 1.00 54 | A first console executable file, containing all the basic functions. 55 | -------------------------------------------------------------------------------- /src_dualcontouring/Release/config.ini: -------------------------------------------------------------------------------- 1 | [DualContouring] 2 | WorkingDir ="..\..\models\" 3 | GridLength =1.0 4 | AcceptNumber =4 5 | RelativeDistance =100.0 6 | RelativeZ =1.0 7 | Weight =1.0 8 | ErrorTolerance =1.0 9 | SingularTolerance =0.15 10 | WallRectangle =0 11 | AntiNonManifold =1 12 | SnappingErrorTolerance =1.2 13 | SnappingMinimumLength =7.0 14 | -------------------------------------------------------------------------------- /src_dualcontouring/common/BoundingBox.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include 3 | #include ".\boundingbox.h" 4 | 5 | CBoundingBox::CBoundingBox(void) 6 | { 7 | Reset(); 8 | } 9 | 10 | CBoundingBox::~CBoundingBox(void) 11 | { 12 | } 13 | 14 | void CBoundingBox::Reset() 15 | { 16 | m_vMin[0] = m_vMin[1] = m_vMin[2] = 1e10; 17 | m_vMax[0] = m_vMax[1] = m_vMax[2] = -1e10; 18 | } 19 | 20 | void CBoundingBox::Push( float m_fVertex[3] ) 21 | { 22 | for (int i = 0; i < 3; i++) { 23 | if (m_fVertex[i] < m_vMin[i]) 24 | m_vMin[i] = m_fVertex[i]; 25 | if (m_fVertex[i] > m_vMax[i]) 26 | m_vMax[i] = m_fVertex[i]; 27 | } 28 | } 29 | 30 | void CBoundingBox::Push( double m_dbVertex[3] ) 31 | { 32 | for (int i = 0; i < 3; i++) { 33 | if (m_dbVertex[i] < m_vMin[i]) 34 | m_vMin[i] = m_dbVertex[i]; 35 | if (m_dbVertex[i] > m_vMax[i]) 36 | m_vMax[i] = m_dbVertex[i]; 37 | } 38 | } 39 | 40 | void CBoundingBox::Push( const CVector3D & v ) 41 | { 42 | for (int i = 0; i < 3; i++) { 43 | if (v.pVec[i] < m_vMin[i]) 44 | m_vMin[i] = v.pVec[i]; 45 | if (v.pVec[i] > m_vMax[i]) 46 | m_vMax[i] = v.pVec[i]; 47 | } 48 | } 49 | 50 | CVector3D CBoundingBox::GetPosition() 51 | { 52 | return CVector3D( 53 | (m_vMin[0] + m_vMax[0]) / 2.0, 54 | (m_vMin[1] + m_vMax[1]) / 2.0, 55 | (m_vMin[2] + m_vMax[2]) / 2.0 56 | ); 57 | } 58 | 59 | double CBoundingBox::GetLength() 60 | { 61 | double temp[3] = { m_vMax[0] - m_vMin[0], m_vMax[1] - m_vMin[1], m_vMax[2] - m_vMin[2] }; 62 | return __max( temp[2], __max( temp[0], temp[1] ) ); 63 | } 64 | 65 | double CBoundingBox::GetLength( int i ) 66 | { 67 | return m_vMax[ i ] - m_vMin[ i ]; 68 | } 69 | 70 | CVector3D CBoundingBox::GetCorner(int i, int j, int k) 71 | { 72 | CVector3D vPos = GetPosition(); 73 | double dbLength = GetLength(); 74 | return vPos + CVector3D( 75 | (i - 0.5) * dbLength, 76 | (j - 0.5) * dbLength, 77 | (k - 0.5) * dbLength 78 | ); 79 | } 80 | -------------------------------------------------------------------------------- /src_dualcontouring/common/BoundingBox.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include "Vector3D.h" 4 | 5 | class CBoundingBox 6 | { 7 | public: 8 | CBoundingBox(void); 9 | ~CBoundingBox(void); 10 | 11 | public: 12 | CVector3D m_vMin; 13 | CVector3D m_vMax; 14 | 15 | void Reset(); 16 | void Push( float m_fVertex[3] ); 17 | void Push( double m_dbVertex[3] ); 18 | void Push( const CVector3D & v ); 19 | CVector3D GetPosition(); 20 | double GetLength(); 21 | double GetLength( int i ); 22 | CVector3D GetCorner(int i, int j, int k); 23 | 24 | void PrintInfo() { 25 | fprintf_s( stderr, "Bounding Box:\n\tFrom : ( %.2f, %.2f, %.2f )\n\tTo : ( %.2f, %.2f, %.2f )\n", m_vMin[0], m_vMin[1], m_vMin[2], m_vMax[0], m_vMax[1], m_vMax[2] ); 26 | } 27 | }; 28 | -------------------------------------------------------------------------------- /src_dualcontouring/common/IndexingGrid.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "IndexingGrid.h" 3 | 4 | CIndexingGrid::CIndexingGrid(void) 5 | { 6 | } 7 | 8 | CIndexingGrid::~CIndexingGrid(void) 9 | { 10 | } 11 | 12 | void CIndexingGrid::BuildIndexingGrid( CPointCloud * pointcloud, double unit_length ) 13 | { 14 | m_pPointCloud = pointcloud; 15 | m_dbGridLength = unit_length; 16 | CBoundingBox & box = pointcloud->m_cBoundingBox; 17 | 18 | // setup protected boundary 19 | m_nWidth = ( int )( box.GetLength( 0 ) / unit_length ) + 1 + 2; 20 | m_nHeight = ( int )( box.GetLength( 1 ) / unit_length ) + 1 + 2; 21 | 22 | // create index 23 | CreateIndex(); 24 | } 25 | 26 | void CIndexingGrid::CreateIndex() 27 | { 28 | m_vecIndex.clear(); 29 | m_vecIndex.resize( m_nWidth * m_nHeight ); 30 | 31 | for ( int i = 0; i < ( int )m_pPointCloud->m_vecPoint.size(); i++ ) { 32 | CVector3D & v = m_pPointCloud->m_vecPoint[ i ]; 33 | m_vecIndex[ Index( v[ 0 ], v[ 1 ] ) ].push_back( i ); 34 | } 35 | } -------------------------------------------------------------------------------- /src_dualcontouring/common/IndexingGrid.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "PointCloud.h" 6 | #include "BoundingBox.h" 7 | 8 | ////////////////////////////////////////////////////////////////////////// 9 | // This is a indexing grid with PROTECTED boundary 10 | // Boundary cells are guaranteed to be empty cells 11 | ////////////////////////////////////////////////////////////////////////// 12 | 13 | class CIndexingGrid 14 | { 15 | public: 16 | typedef std::vector< int > Grid_Index; 17 | 18 | public: 19 | CIndexingGrid(void); 20 | ~CIndexingGrid(void); 21 | 22 | public: 23 | CPointCloud * m_pPointCloud; 24 | 25 | int m_nWidth; 26 | int m_nHeight; 27 | double m_dbGridLength; 28 | 29 | std::vector< Grid_Index > m_vecIndex; 30 | 31 | public: 32 | void BuildIndexingGrid( CPointCloud * pointcloud, double unit_length ); 33 | 34 | protected: 35 | void CreateIndex(); 36 | 37 | protected: 38 | int XtoI( double x ) { 39 | int i = ( int )( ( x - m_pPointCloud->m_cBoundingBox.m_vMin[ 0 ] ) / m_dbGridLength ) + 1; 40 | if ( i < 1 ) i = 1; 41 | if ( i >= m_nWidth - 1 ) i = m_nWidth - 2; 42 | return i; 43 | } 44 | int YtoJ( double y ) { 45 | int j = ( int )( ( y - m_pPointCloud->m_cBoundingBox.m_vMin[ 1 ] ) / m_dbGridLength ) + 1; 46 | if ( j < 1 ) j = 1; 47 | if ( j >= m_nHeight - 1 ) j = m_nHeight - 2; 48 | return j; 49 | } 50 | 51 | bool IIsValid( int i ) { 52 | return ( i >= 0 && i < m_nWidth ); 53 | } 54 | bool JIsValid( int j ) { 55 | return ( j >= 0 && j < m_nHeight ); 56 | } 57 | 58 | int Index( int i, int j ) { 59 | return ( i * m_nHeight + j ); 60 | } 61 | 62 | int Index( double x, double y ) { 63 | return Index( XtoI( x ), YtoJ( y ) ); 64 | } 65 | 66 | int GetI( int index ) { 67 | return index / m_nHeight; 68 | } 69 | 70 | int GetJ( int index ) { 71 | return index % m_nHeight; 72 | } 73 | }; 74 | -------------------------------------------------------------------------------- /src_dualcontouring/common/Mesh.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "Mesh.h" 3 | 4 | #include "MeshWriter.h" 5 | 6 | CMesh::CMesh(void) 7 | { 8 | } 9 | 10 | CMesh::~CMesh(void) 11 | { 12 | } 13 | 14 | void CMesh::SaveToObj( char filename[] ) 15 | { 16 | CMeshWriter writer; 17 | writer.OpenFile( filename ); 18 | writer.WriteHeader(); 19 | 20 | for ( int i = 0; i < ( int )m_vecVertex.size(); i++ ) { 21 | writer.WriteVertex( m_vecVertex[ i ].v.pVec ); 22 | } 23 | 24 | for ( int i = 0; i < ( int )m_vecTriangle.size(); i++ ) { 25 | writer.WriteFace( m_vecTriangle[ i ].i ); 26 | } 27 | 28 | for ( int i = 0; i < ( int )m_vecQuad.size(); i++ ) { 29 | writer.WriteQuad( m_vecQuad[ i ].i, false ); 30 | } 31 | 32 | writer.CloseFile(); 33 | } -------------------------------------------------------------------------------- /src_dualcontouring/common/Mesh.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Vector3D.h" 6 | 7 | class CMesh 8 | { 9 | public: 10 | CMesh(void); 11 | ~CMesh(void); 12 | 13 | public: 14 | struct MeshVertex { 15 | CVector3D v; 16 | MeshVertex( const CVector3D & vv ) : v( vv ) { } 17 | MeshVertex() {} 18 | }; 19 | struct MeshTriangle { 20 | int i[ 3 ]; 21 | MeshTriangle( int i0, int i1, int i2 ) { 22 | i[ 0 ] = i0; 23 | i[ 1 ] = i1; 24 | i[ 2 ] = i2; 25 | } 26 | MeshTriangle() {} 27 | }; 28 | struct MeshQuad { 29 | int i[ 4 ]; 30 | MeshQuad( int i0, int i1, int i2, int i3 ) { 31 | i[ 0 ] = i0; 32 | i[ 1 ] = i1; 33 | i[ 2 ] = i2; 34 | i[ 3 ] = i3; 35 | } 36 | MeshQuad() {} 37 | }; 38 | 39 | public: 40 | std::vector< MeshVertex > m_vecVertex; 41 | std::vector< MeshTriangle > m_vecTriangle; 42 | std::vector< MeshQuad > m_vecQuad; 43 | 44 | public: 45 | void SaveToObj( char filename[] ); 46 | }; 47 | -------------------------------------------------------------------------------- /src_dualcontouring/common/MeshWriter.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "MeshWriter.h" 3 | 4 | CMeshWriter::CMeshWriter(void) 5 | { 6 | m_pFile = NULL; 7 | } 8 | 9 | CMeshWriter::~CMeshWriter(void) 10 | { 11 | } 12 | 13 | void CMeshWriter::OpenFile( char filename[] ) 14 | { 15 | fopen_s( & m_pFile, filename, "w" ); 16 | } 17 | 18 | void CMeshWriter::WriteHeader() 19 | { 20 | fprintf_s( m_pFile, "#\n" ); 21 | } 22 | 23 | void CMeshWriter::WriteVertex( const double v[ 3 ] ) 24 | { 25 | fprintf_s( m_pFile, "v %.8f %.8f %.8f\n", v[0], v[1], v[2] ); 26 | } 27 | 28 | void CMeshWriter::WriteFace( const int i[ 3 ] ) 29 | { 30 | fprintf_s( m_pFile, "f %d %d %d\n", i[0]+1, i[1]+1, i[2]+1 ); 31 | } 32 | 33 | void CMeshWriter::WriteQuad( const int i[ 4 ], bool split ) 34 | { 35 | if ( split ) { 36 | fprintf_s( m_pFile, "f %d %d %d\n", i[0]+1, i[1]+1, i[2]+1 ); 37 | fprintf_s( m_pFile, "f %d %d %d\n", i[2]+1, i[3]+1, i[0]+1 ); 38 | } else { 39 | fprintf_s( m_pFile, "f %d %d %d %d\n", i[0]+1, i[1]+1, i[2]+1, i[3]+1 ); 40 | } 41 | } 42 | 43 | void CMeshWriter::CloseFile() 44 | { 45 | fclose( m_pFile ); 46 | } 47 | -------------------------------------------------------------------------------- /src_dualcontouring/common/MeshWriter.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | class CMeshWriter 4 | { 5 | public: 6 | CMeshWriter(void); 7 | ~CMeshWriter(void); 8 | 9 | protected: 10 | FILE * m_pFile; 11 | 12 | public: 13 | void OpenFile( char filename[] ); 14 | void WriteHeader(); 15 | void WriteVertex( const double v[ 3 ] ); 16 | void WriteFace( const int i[3] ); 17 | void WriteQuad( const int i[4], bool split = false ); 18 | void CloseFile(); 19 | }; 20 | -------------------------------------------------------------------------------- /src_dualcontouring/common/PointCloud.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include "PointCloud.h" 3 | 4 | CPointCloud::CPointCloud(void) 5 | { 6 | } 7 | 8 | CPointCloud::~CPointCloud(void) 9 | { 10 | } 11 | 12 | void CPointCloud::LoadFromXYZN( char filename[] ) 13 | { 14 | m_cBoundingBox.Reset(); 15 | 16 | m_vecPoint.clear(); 17 | m_vecNormal.clear(); 18 | 19 | FILE * file; 20 | fopen_s( & file, filename, "r" ); 21 | 22 | char buf[ 1024 ]; 23 | double x, y, z, nx, ny, nz; 24 | while ( fgets( buf, 1024, file ) != NULL ) { 25 | if ( buf[ 0 ] == '#' ) { 26 | if ( strncmp( buf, "# ground ", 9 ) == 0 ) { 27 | sscanf_s( & buf[ 9 ], "%lf", & m_dbGroundZ ); 28 | } 29 | } else { 30 | sscanf_s( buf, "%lf %lf %lf %lf %lf %lf", &x, &y, &z, &nx, &ny, &nz ); 31 | m_vecPoint.push_back( CVector3D( x, y, z ) ); 32 | m_vecNormal.push_back( CVector3D( nx, ny, nz ) ); 33 | 34 | m_cBoundingBox.Push( m_vecPoint.back() ); 35 | } 36 | } 37 | 38 | fclose( file ); 39 | } 40 | 41 | void CPointCloud::SaveToXYZN( char filename[] ) 42 | { 43 | FILE * file; 44 | fopen_s( & file, filename, "w" ); 45 | 46 | fprintf_s( file, "# ground %.10f\n", m_dbGroundZ ); 47 | 48 | for ( int i = 0; i < ( int )m_vecPoint.size(); i++ ) { 49 | CVector3D & p = m_vecPoint[ i ]; 50 | CVector3D & n = m_vecNormal[ i ]; 51 | fprintf_s( file, "%.10f %.10f %.10f %.10f %.10f %.10f\n", p[ 0 ], p[ 1 ], p[ 2 ], n[ 0 ], n[ 1 ], n[ 2 ] ); 52 | } 53 | 54 | fclose( file ); 55 | } -------------------------------------------------------------------------------- /src_dualcontouring/common/PointCloud.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #include "Vector3D.h" 6 | #include "BoundingBox.h" 7 | 8 | class CPointCloud 9 | { 10 | public: 11 | CPointCloud(void); 12 | ~CPointCloud(void); 13 | 14 | public: 15 | std::vector< CVector3D > m_vecPoint; 16 | std::vector< CVector3D > m_vecNormal; 17 | 18 | CBoundingBox m_cBoundingBox; 19 | double m_dbGroundZ; 20 | 21 | public: 22 | void LoadFromXYZN( char filename[] ); 23 | void SaveToXYZN( char filename[] ); 24 | }; 25 | -------------------------------------------------------------------------------- /src_dualcontouring/common/Vector3D.cpp: -------------------------------------------------------------------------------- 1 | #include "StdAfx.h" 2 | #include ".\Vector3D.h" 3 | 4 | CVector3D& CVector3D::operator=(const CVector3D& v) 5 | { 6 | pVec[0] = v.pVec[0]; pVec[1] = v.pVec[1]; pVec[2] = v.pVec[2]; 7 | return (*this); 8 | } 9 | CVector3D& CVector3D::operator+=(const CVector3D& v) 10 | { 11 | pVec[0] += v.pVec[0]; pVec[1] += v.pVec[1]; pVec[2] += v.pVec[2]; 12 | return (*this); 13 | } 14 | CVector3D& CVector3D::operator-=(const CVector3D& v) 15 | { 16 | pVec[0] -= v.pVec[0]; pVec[1] -= v.pVec[1]; pVec[2] -= v.pVec[2]; 17 | return (*this); 18 | } 19 | CVector3D& CVector3D::operator*=(double u) 20 | { 21 | pVec[0] *= u; pVec[1] *= u; pVec[2] *= u; 22 | return (*this); 23 | } 24 | CVector3D& CVector3D::operator/=(double u) 25 | { 26 | if (abs(u) > 1e-10) 27 | {pVec[0] /= u; pVec[1] /= u; pVec[2] /= u;} 28 | return(*this); 29 | } 30 | CVector3D& CVector3D::operator^=(const CVector3D& v) 31 | { 32 | double xx = pVec[1]*v.pVec[2] - pVec[2]*v.pVec[1]; 33 | double yy = pVec[2]*v.pVec[0] - pVec[0]*v.pVec[2]; 34 | double zz = pVec[0]*v.pVec[1] - pVec[1]*v.pVec[0]; 35 | pVec[0] = xx; pVec[1] = yy; pVec[2] = zz; 36 | return (*this); 37 | } 38 | 39 | 40 | CVector3D operator+(const CVector3D& lv, const CVector3D& rv) 41 | { 42 | CVector3D rel = lv; 43 | rel += rv; 44 | return rel; 45 | } 46 | 47 | 48 | CVector3D operator-(const CVector3D& lv, const CVector3D& rv) 49 | { 50 | CVector3D rel = lv; 51 | rel -= rv; 52 | return rel; 53 | } 54 | 55 | CVector3D operator*(const double u, const CVector3D& rv) 56 | { 57 | CVector3D rel = rv; 58 | rel *= u; 59 | return rel; 60 | } 61 | 62 | CVector3D operator*(const CVector3D& lv, const double u) 63 | { 64 | CVector3D rel = lv; 65 | rel *= u; 66 | return rel; 67 | } 68 | 69 | CVector3D operator/(const CVector3D& lv, const double u) 70 | { 71 | CVector3D rel = lv; 72 | rel /= u; 73 | return rel; 74 | } 75 | 76 | double operator*(const CVector3D& lv, const CVector3D& rv) 77 | { 78 | return lv.pVec[0]*rv.pVec[0] + lv.pVec[1]*rv.pVec[1] + lv.pVec[2]*rv.pVec[2]; 79 | } 80 | 81 | CVector3D operator^(const CVector3D& lv, const CVector3D& rv) 82 | { 83 | CVector3D rel = lv; 84 | rel ^= rv; 85 | return rel; 86 | } 87 | 88 | const CVector3D CVector3D::INFINITE_VECTOR3D = CVector3D( 1e300, 1e300, 1e300 ); -------------------------------------------------------------------------------- /src_dualcontouring/common/Vector3D.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | #include 4 | 5 | #define DOUBLE_TOLERANCE 1e-10 6 | 7 | class CVector3D 8 | { 9 | public: 10 | CVector3D(void) { pVec[0] = pVec[1] = pVec[2] = 0.0; } 11 | CVector3D(double x, double y, double z) { pVec[0] = x; pVec[1] = y; pVec[2] = z; } 12 | CVector3D(double xx[3]) { pVec[0] = xx[0]; pVec[1] = xx[1], pVec[2] = xx[2]; } 13 | CVector3D(const CVector3D & v) { pVec[0] = v.pVec[0]; pVec[1] = v.pVec[1]; pVec[2] = v.pVec[2]; } 14 | ~CVector3D(void) {} 15 | 16 | public : 17 | double pVec[3]; 18 | 19 | // operator 20 | double length() { return sqrt(pVec[0] * pVec[0] + pVec[1] * pVec[1] + pVec[2] * pVec[2]); } 21 | double length2() { return pVec[0] * pVec[0] + pVec[1] * pVec[1] + pVec[2] * pVec[2]; } 22 | double normalize() { double len = length(); if (abs(len) > DOUBLE_TOLERANCE) {pVec[0]/=len;pVec[1]/=len;pVec[2]/=len;} return len; } 23 | bool IsInfinite() { return ( pVec[0] == 1e300 && pVec[1] == 1e300 && pVec[2] == 1e300 ); } 24 | CVector3D XY() { return CVector3D( pVec[0], pVec[1], 0.0 ); } 25 | 26 | double & operator[]( const int i ) { return pVec[i]; } 27 | 28 | CVector3D& operator=(const CVector3D& v); 29 | CVector3D& operator+=(const CVector3D& v); 30 | CVector3D& operator-=(const CVector3D& v); 31 | CVector3D& operator*=(double u); 32 | CVector3D& operator/=(double u); 33 | CVector3D& operator^=(const CVector3D& v); 34 | 35 | friend CVector3D operator+(const CVector3D& lv, const CVector3D& rv); 36 | friend CVector3D operator-(const CVector3D& lv, const CVector3D& rv); 37 | friend CVector3D operator*(const double u, const CVector3D& rv); 38 | friend CVector3D operator*(const CVector3D& lv, const double u); 39 | friend CVector3D operator/(const CVector3D& lv, const double u); 40 | friend double operator*(const CVector3D& lv, const CVector3D& rv); 41 | friend CVector3D operator^(const CVector3D& lv, const CVector3D& rv); 42 | 43 | public: 44 | static const CVector3D INFINITE_VECTOR3D; 45 | }; 46 | -------------------------------------------------------------------------------- /src_dualcontouring/config.ini: -------------------------------------------------------------------------------- 1 | [DualContouring] 2 | WorkingDir ="..\models\" 3 | GridLength =1.0 4 | AcceptNumber =4 5 | RelativeDistance =100.0 6 | RelativeZ =1.0 7 | Weight =1.0 8 | ErrorTolerance =1.0 9 | SingularTolerance =0.15 10 | WallRectangle =0 11 | AntiNonManifold =1 12 | SnappingErrorTolerance =1.2 13 | SnappingMinimumLength =7.0 14 | -------------------------------------------------------------------------------- /src_dualcontouring/stdafx.cpp: -------------------------------------------------------------------------------- 1 | // stdafx.cpp : source file that includes just the standard includes 2 | // DualContouring.pch will be the pre-compiled header 3 | // stdafx.obj will contain the pre-compiled type information 4 | 5 | #include "stdafx.h" 6 | 7 | // TODO: reference any additional headers you need in STDAFX.H 8 | // and not in this file 9 | -------------------------------------------------------------------------------- /src_dualcontouring/stdafx.h: -------------------------------------------------------------------------------- 1 | // stdafx.h : include file for standard system include files, 2 | // or project specific include files that are used frequently, but 3 | // are changed infrequently 4 | // 5 | 6 | #pragma once 7 | 8 | #include "targetver.h" 9 | 10 | #include 11 | #include 12 | 13 | #include 14 | 15 | // TODO: reference additional headers your program requires here 16 | -------------------------------------------------------------------------------- /src_dualcontouring/targetver.h: -------------------------------------------------------------------------------- 1 | #pragma once 2 | 3 | // The following macros define the minimum required platform. The minimum required platform 4 | // is the earliest version of Windows, Internet Explorer etc. that has the necessary features to run 5 | // your application. The macros work by enabling all features available on platform versions up to and 6 | // including the version specified. 7 | 8 | // Modify the following defines if you have to target a platform prior to the ones specified below. 9 | // Refer to MSDN for the latest info on corresponding values for different platforms. 10 | #ifndef _WIN32_WINNT // Specifies that the minimum required platform is Windows Vista. 11 | #define _WIN32_WINNT 0x0600 // Change this to the appropriate value to target other versions of Windows. 12 | #endif 13 | 14 | --------------------------------------------------------------------------------