-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
executable file
·104 lines (82 loc) · 3.13 KB
/
main.cpp
File metadata and controls
executable file
·104 lines (82 loc) · 3.13 KB
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// ===============================
// Convert .ply to .spbr
// ===============================
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <vector>
#include "importPointClouds.h"
#include "writeSPBR.h"
#include <kvs/PolygonObject>
#include <kvs/PointObject>
#include <kvs/glut/Application>
#include <kvs/glut/Screen>
#include <kvs/Camera>
#include <kvs/PointRenderer>
#include <kvs/Coordinate>
#define DEBUG_SELECT_AREA
#define EXEC_VIA_SPBR
//#define EXEC_VIA_KVS
const char OUT_FILE[] = "SPBR_DATA/out.spbr";
int main( int argc, char** argv ) {
char outSPBRfile[512];
strcpy( outSPBRfile, OUT_FILE );
if ( argc < 9 ) {
std::cout << "\nUSAGE: " << "$ " << argv[0] << " [input_file] [output_file] [x_min] [y_min] [z_min] [x_max] [y_max] [z_max]\n"
<< "EXAMPLE: " << "$ " << argv[0] << " input.ply output.spbr\n" << std::endl;
exit(1);
} else {
strcpy( outSPBRfile, argv[2] );
}
// ----- Import "point cloud data(.ply, argv[1])" that user selected
// ----- Inheritance of KVS::PolygonObject -----
ImportPointClouds *ply = new ImportPointClouds( argv[1] );
ply->updateMinMaxCoords();
std::cout << "PLY Min, Max Coords:" << std::endl;
std::cout << "Min : " << ply->minObjectCoord() << std::endl;
std::cout << "Max : " << ply->maxObjectCoord() << std::endl;
//ply->setColors( kvs::ValueArray<kvs::UInt8>( colors ) );
// ----- Write .spbr file -----
// set
float select_area_min_max[6]={0};
for (int i = 0; i < 6; i++) {
select_area_min_max[i] = atof(argv[3+i]);
}
WritingDataType type = Ascii;
writeSPBR( ply, /* kvs::PolygonObject *_ply */
outSPBRfile, /* char* _filename */
select_area_min_max, /* float _select_area_min_max[] */
type /* WritingDataType _type */
);
// ----- Convert "PolygonObject(KVS)" to "PointObject(KVS)" -----
kvs::PointObject* object = new kvs::PointObject( *ply );
object->setSize( 1 );
object->updateMinMaxCoords();
// ----- Exec. SPBR -----
#ifdef EXEC_VIA_SPBR
std::string out_noised_spbr( outSPBRfile );
// std::string EXEC("spbr ");
std::string EXEC("spbr_auto_snap ");
EXEC += out_noised_spbr;
system( EXEC.c_str() );
return 0;
#endif
// ----- Exec. KVS -----
#ifdef EXEC_VIA_KVS
kvs::glut::Application app( argc, argv );
kvs::glut::Screen screen( &app );
kvs::PointRenderer* renderer = new kvs::PointRenderer();
renderer->enableTwoSideLighting();
screen.setTitle( "Point Object" );
kvs::Vector3f cam_pos(0, 8, 0);
kvs::Vector3f cam_up(0, 0, 1);
screen.setBackgroundColor( kvs::RGBColor(0, 0, 0) );
//screen.setBackgroundColor( kvs::RGBColor(255, 255, 255) );
screen.setGeometry(0, 0, 1000, 1000);
screen.scene()->camera()->setPosition(cam_pos);
screen.scene()->camera()->setUpVector(cam_up);
screen.registerObject(object, renderer);
screen.show();
return app.run();
#endif
}