-
Notifications
You must be signed in to change notification settings - Fork 42
/
DualContouring.cpp
73 lines (50 loc) · 2.2 KB
/
DualContouring.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
// DualContouring.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include "ParamManager.h"
#include "DCGrid.h"
#include "DCContourer.h"
void main( int argc, char * argv[])
{
fprintf_s( stderr, "2.5D Dual Contouring Demo\n" );
fprintf_s( stderr, "Author: Qian-Yi Zhou ([email protected])\n");
fprintf_s( stderr, "Version: 1.01, last updated on 10/5/2010.\n");
fprintf_s( stderr, "Project page:\n http://graphics.usc.edu/~qianyizh/projects/dualcontouring.html\n");
fprintf_s( stderr, "\n" );
fprintf_s( stderr, "========================= Processing ========================\n" );
CParamManager * manager = CParamManager::GetParamManager();
manager->RegisterCommandLine( argc, argv );
DualContouringParam & param = manager->m_cDCParam;
char pSearch[ 1024 ];
sprintf_s( pSearch, 1024, "%s*.xyzn", manager->m_pWorkingDir );
WIN32_FIND_DATA finder;
HANDLE handle = FindFirstFile( pSearch, & finder );
BOOL not_finished = ( handle != INVALID_HANDLE_VALUE );
while ( not_finished ) {
if ( strcmp( finder.cFileName, "." ) != 0 && strcmp( finder.cFileName, ".." ) != 0 ) {
if ( ( finder.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) != FILE_ATTRIBUTE_DIRECTORY ) {
fprintf_s( stderr, "Processing %s ... ", finder.cFileName );
char filename[ 1024 ];
memset( filename, 0, 1024 );
sprintf_s( filename, 1024, "%s%s", manager->m_pWorkingDir, finder.cFileName );
CPointCloud pointcloud;
pointcloud.LoadFromXYZN( filename );
CDCGrid grid;
grid.AssignPointCloud( & pointcloud, param.m_dbGridLength, pointcloud.m_dbGroundZ );
grid.ComputeHermiteData( param.m_nAcceptNumber, param.m_dbRelativeDistance, param.m_dbRelativeZ );
grid.DualContouringGeometry( param.m_dbWeight, param.m_dbErrorTolerance, param.m_dbSingularTolerance );
CDCContourer contourer;
contourer.AssignDCGrid( & grid );
contourer.Contouring();
char truename[ 1024 ];
memset( truename, 0, 1024 );
strncat_s( truename, 1024, filename, strlen( filename ) - 4 );
sprintf_s( filename, "%sobj", truename );
contourer.SaveToObj( filename );
fprintf_s( stderr, "done.\n" );
}
not_finished = FindNextFile( handle, &finder );
}
}
FindClose( handle );
}