Skip to content

Commit

Permalink
Minor update
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsy committed Apr 18, 2016
1 parent bbfd8f4 commit 2c4fa76
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
13 changes: 11 additions & 2 deletions sources/shape/meshio.cc
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,17 @@ std::vector<std::shared_ptr<Shape>> OBJMeshIO::load(const std::string& filename,

void OBJMeshIO::save(const std::string& filename,
const std::vector<Triangle>& trimesh) const {
std::cerr << "[ERROR] not implemented yet" << std::endl;
std::abort();
std::ofstream ofs(filename, std::ios::out);
for (const auto& t : trimesh) {
ofs << "v " << t[0].x() << " " << t[0].y() << " " << t[0].z() << std::endl;
ofs << "v " << t[1].x() << " " << t[1].y() << " " << t[1].z() << std::endl;
ofs << "v " << t[2].x() << " " << t[2].y() << " " << t[2].z() << std::endl;
}

for (int i = 0; i < trimesh.size(); i++) {
ofs << "f " << (3 * i + 1) << " " << (i * 3 + 2) << " " << (i * 3 + 3) << std::endl;
}
ofs.close();
}

Image OBJMeshIO::getTexture(const std::string& filename) {
Expand Down
4 changes: 2 additions & 2 deletions sources/shape/sphere.cc
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ double Sphere::area() const {
}

std::vector<Triangle> Sphere::triangulate() const {
static const int nTheta = 64;
static const int nPhi = 128;
static const int nTheta = 32;
static const int nPhi = 64;

std::vector<Triangle> tris;
for (int i = 0; i < nTheta; i++) {
Expand Down

0 comments on commit 2c4fa76

Please sign in to comment.