-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathmain.cpp
More file actions
49 lines (40 loc) · 1.35 KB
/
main.cpp
File metadata and controls
49 lines (40 loc) · 1.35 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
// loop-subdivision
//
// Author : Mi, Liang
// Email : icemiliang@gmail.com
// Date : Jul 25th 2021
// License : MIT
#include <string.h>
#include "Mesh.h"
#include "Iterators.h"
#include "FormTrait.h"
#include "LOOP.h"
#include <iostream>
using namespace MeshLib;
int main(int argc, char *argv[]) {
int k = 1;
// recursive division
if (strcmp(argv[1], "-r") == 0) {
k = atoi(argv[2]);
}
std::cout << "--> Reading mesh..." << std::endl;
Mesh *oldMesh = new Mesh();
oldMesh->read_obj(argv[1 + (k > 1)*2]);
for (int i = 0; i < k; ++i) {
std::cout << "--> Subdviding mesh..." << std::endl;
FormTrait traits(oldMesh); // add temporary variables
Mesh *newMesh = new Mesh();
LOOP loop(oldMesh, newMesh);
loop.subdivide();
std::string outname = (std::string)argv[2 + (k > 1)*2];
if (outname.length() > 4 and outname.substr(outname.length()-4) == ".obj") {
outname = outname.substr(0, outname.length()-4) + "_" + std::to_string(i+1) + ".obj";
} else {
outname = outname + ((k == 1)? ".obj" : outname + "_" + std::to_string(i+1) + ".obj");
}
std::cout << "--> Writing mesh to " + outname + "..." << std::endl;
newMesh->write_obj(outname.c_str());
*oldMesh = *newMesh;
}
return 0;
}