-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathImportPointClouds.cpp
More file actions
executable file
·80 lines (67 loc) · 2.64 KB
/
Copy pathImportPointClouds.cpp
File metadata and controls
executable file
·80 lines (67 loc) · 2.64 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
#include <fstream>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include "ImportPointClouds.h"
#include "plyRead.h"
#include "xyzAsciiReader.h"
// #include "xyzBinaryReader.h"
// #include "spbr.h"
// #include "spcomment.h"
const int BUF_MAX = 1024;
ImportPointClouds::ImportPointClouds( void ): m_hasFace( false ) {
}
ImportPointClouds::ImportPointClouds( char *filename ): m_hasFace( false ) {
classification( filename );
}
int ImportPointClouds::breakWord( char* buf, std::string *str ) {
char* data;
int n = 0;
data = strtok( buf, " \t" );
while( data != NULL ) {
str[n] = data;
data = strtok( NULL, " \t" );
n++;
}
return n;
}
void ImportPointClouds::classification( char* filename ) {
std::ifstream fin( filename );
if( !fin ) {
std::cout << "ERROR: Cannot Open File: " << filename << std::endl;
exit(1);
}
SuperClass::setPolygonType( kvs::PolygonObject::UnknownPolygonType );
SuperClass::setColorType( kvs::PolygonObject::VertexColor );
SuperClass::setNormalType( kvs::PolygonObject::VertexNormal );
size_t numVert = 0;
char buf[ BUF_MAX];
std::string word[ 15 ];
//--- Check File Type
fin.getline( buf, BUF_MAX, '\n' );
std::cout << "~~~~~ " << buf << std::endl;
breakWord( buf, word );
if( !strncmp( word[0].c_str(), "ply", 3 ) ) {
std::cout << "PLY file reading....." << std::endl;
kvs::PolygonObject* ply = new plyRead( filename, m_hasFace );
SuperClass::setCoords( ply->coords() );
SuperClass::setNormals( ply->normals() );
SuperClass::setColors( ply->colors() );
numVert = ply->numberOfVertices();
if( m_hasFace ) {
SuperClass::setConnections( ply->connections() );
SuperClass::setPolygonType( ply->polygonType() );
}
} else {
m_hasFace = false;
std::cout << "XYZRGB file or Other type file reading....." << std::endl;
xyzAsciiReader* ply = new xyzAsciiReader( filename );
m_ft = ply->featureData();
SuperClass::setCoords( ply->coords() );
SuperClass::setNormals( ply->normals() );
SuperClass::setColors( ply->colors() );
numVert = ply->numberOfVertices();
}
// std::cout << "Number of Popints : " << numVert << std::endl;
fin.close();
}