yangyanli / globfit

Code for SIGGRAPH 2011 paper GlobFit: Consistently Fitting Primitives by Discovering Global Relations
http://web.siat.ac.cn/~vcc/publications/2011/globfit/
32 stars 8 forks source link

Some functions in the file are not implemented. #2

Open huoyubai18 opened 4 years ago

huoyubai18 commented 4 years ago

I notice that in GlobFit.h, some functions can not be found in its corresponding cpp file, is it a complete file?

louiemay commented 4 years ago

I uploade the original GlobFit.h and GlobFit.cpp files. Please check in the attachment.

--

Ph.d. Student Mechanical Design and Theory School of Mechanical Engineering, Zhejiang University QQ: 2945374262 WeChat: louiemay Tel: (+86)18757133610

At 2020-03-30 15:33:52, "huoyubai18" notifications@github.com wrote:

I notice that in GlobFit.h, some functions can not be found in its corresponding cpp file, is it a complete file?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

include

include

include "Types.h"

include "Cone.h"

include "Plane.h"

include "Sphere.h"

include "Cylinder.h"

include "GlobFit.h"

GlobFit::GlobFit(void) { }

GlobFit::~GlobFit(void) { for (size_t i = 0, iEnd = _vecPointSet.size(); i < iEnd; ++ i) { delete _vecPointSet[i]; }

for (size_t i = 0, iEnd = _vecPrimitive.size(); i < iEnd; ++ i) { delete _vecPrimitive[i]; } }

bool GlobFit::load(const std::string& filename) { std::string line; std::ifstream fin(filename.c_str());

if (!fin.good()) { return false; }

size_t numPoint = 0; while (fin) { getline(fin, line); if (line.empty() || line[0]=='#') { continue; }

std::stringstream sin(line);
sin >> numPoint;
break;

}

while (fin && numPoint != 0){ getline(fin, line);

if (line.empty() || line[0]=='#') {
  continue;
}

--numPoint;

RichPoint* p = new RichPoint();
_vecPointSet.push_back(p);

double x, y, z, nx, ny, nz, confidence;

std::stringstream sin(line);
sin >> x >> y >> z >> nx >> ny >> nz >> confidence;

p->point        = Point(x, y, z);
p->normal       = Vector(nx, ny, nz)/sqrt(nx*nx+ny*ny+nz*nz);
p->confidence   = confidence;

}

size_t numPrimitive = 0; while (fin) { getline(fin, line); if (line.empty() || line[0]=='#') { continue; }

std::stringstream sin(line);
sin >> numPrimitive;
break;

}

while (fin && numPrimitive != 0){ getline(fin, line);

if (line.empty() || line[0]=='#') {
  continue;
}

std::string indication = line.substr(0, line.find_first_of(" \t"));
Primitive* pPrimitive = NULL;
if (indication == "plane") {
  pPrimitive = new Plane(_vecPointSet);
} else if (indication == "cylinder") {
  pPrimitive = new Cylinder(_vecPointSet);
} else if (indication == "cone") {
  pPrimitive = new Cone(_vecPointSet);
} else if (indication == "sphere") {
  pPrimitive = new Sphere(_vecPointSet);
}

if (pPrimitive == NULL) {
  std::cerr << "Error: bad file format!" << std::endl;
  continue;
}

fin.seekg(-((int)(line.size()+1)), std::ios::cur);
if (pPrimitive->load(fin)) {
  pPrimitive->setIdx(_vecPrimitive.size());
  _vecPrimitive.push_back(pPrimitive);
  --numPrimitive;
} else {
  delete pPrimitive;
  std::cerr << "Error: bad file format!" << std::endl;
}

}

return true; }

bool GlobFit::save(const std::string& filename) const { std::ofstream fout(filename.c_str()); if (!fout.good()) { return false; }

fout.precision(16);

fout << "# Number of Points" << std::endl; fout << _vecPointSet.size() << std::endl; fout << "# Here comes the " << _vecPointSet.size() << " Points" << std::endl; fout << "# point_x point_y point_z normal_x normal_y normal_z confidence" << std::endl; for (std::vector<RichPoint>::const_iterator it = _vecPointSet.begin(); it != _vecPointSet.end(); ++ it) { fout << (it)->point << " " << (it)->normal << " " << (it)->confidence << std::endl; } fout << "# End of Points" << std::endl;

fout << std::endl; fout << "# Number of Primitives" << std::endl; fout << _vecPrimitive.size() << std::endl; fout << "# Here comes the " << _vecPrimitive.size() << " Primitives" << std::endl; for (size_t i = 0, iEnd = _vecPrimitive.size(); i < iEnd; ++ i ) { fout << "# Primitive " << i << std::endl; _vecPrimitive[i]->save(fout); fout << std::endl; } fout << "# End of Primitives" << std::endl;

return true; }

huoyubai18 commented 4 years ago

thanks a lot! actually,i haven't run through the code yet,Are there any requirements?

louiemay commented 4 years ago

OSG and boost library have to be pre-installed. The development environment i'm using is OpenScenGraph3.4.0+boost1.66.0+visual studio2015 on win8 OS. Hope that can help you^_^