Skip to content

Commit

Permalink
Added support for OFF and XYZ point clouds.
Browse files Browse the repository at this point in the history
  • Loading branch information
ennetws committed Feb 14, 2013
1 parent f2860a4 commit ae3657e
Show file tree
Hide file tree
Showing 3 changed files with 14,438 additions and 4 deletions.
70 changes: 66 additions & 4 deletions hullmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,21 @@ void make_output(simplex *root,
/* efclose(F); */
}

bool strequals(const std::string& a, const std::string& b)
{
unsigned int sz = a.size();
if (b.size() != sz)
return false;
for (unsigned int i = 0; i < sz; ++i)
if (tolower(a[i]) != tolower(b[i]))
return false;
return true;
}

#include <iostream>
#include <fstream>
#include <sstream>

int main(int argc, char **argv) {

long seed = 0, poleid=0;
Expand All @@ -365,9 +380,9 @@ int main(int argc, char **argv) {
;
int option, num_poles=0;
double pole_angle;
char ofile[50] = "",
ifile[50] = "",
ofilepre[50] = "";
char ofile[256] = "",
ifile[256] = "",
ofilepre[256] = "";
FILE *INPOLE, *OUTPOLE, *HEAD,*POLEINFO;
int main_out_form=0, i,k;

Expand Down Expand Up @@ -405,7 +420,54 @@ int main(int argc, char **argv) {
bad = 1;
break;
case 'i' :
strcpy(ifile, optarg);
{
std::string filename = optarg;
std::string ext = filename.substr(filename.length() - 3, 3);

if( strequals( ext, "off" ) )
{
// Generate .pts file instead
std::ifstream in(filename);
std::ofstream out(filename + ".pts");

std::string line;
int nv = 0, nf = 0, ne = 0;
in >> line;
in >> nv >> nf >> ne;

for(int i = 0; i < nv; i++)
{
double x,y,z;
in >> x >> y >> z;
out << x << " " << y << " " << z << "\n";
}

in.close();
out.close();

strcpy(ifile, (filename + ".pts").c_str());
}
else if( strequals( ext, "xyz" ) )
{
// Generate .pts file instead
std::ifstream in(filename);
std::ofstream out(filename + ".pts");

while(!in.eof())
{
double x,y,z,nx,ny,nz;
in >> x >> y >> z >> nx >> ny >> nz;
out << x << " " << y << " " << z << "\n";
}

in.close();
out.close();

strcpy(ifile, (filename + ".pts").c_str());
}
else
strcpy(ifile, optarg);
}
break;
case 'X' :
DFILE = efopen(optarg, "w");
Expand Down
Loading

0 comments on commit ae3657e

Please sign in to comment.