Modularized grid mode. Updated help dialogue.
This commit is contained in:
parent
db17de29f4
commit
59a9be347e
1 changed files with 38 additions and 34 deletions
|
@ -47,18 +47,17 @@ std::vector<CompFab::Vec3> createVec3d(std::vector<CompFab::Vec3> &t, int layers
|
|||
double ws = width + spacing;
|
||||
|
||||
// Will be used later to determine the direction of the translation matrix.
|
||||
// This is used to bypass needing to create a rotation matrix.
|
||||
// Should consider doing so anyway to speed up process, use less memory, and add modularization.
|
||||
double angle = 0.0;
|
||||
|
||||
CompFab::Vec3 *temp = new CompFab::Vec3(-ls, -ws, 0);
|
||||
|
||||
// Vec3 to hold our current translation matrix.
|
||||
CompFab::Vec3 *trans = new CompFab::Vec3(0, spacing, 0);
|
||||
CompFab::Vec3 *trans = new CompFab::Vec3(ls, ws, 0);
|
||||
|
||||
//Vec3 to hold our current height multiplier.
|
||||
//Vec3 to hold our current height multiplication materx.
|
||||
CompFab::Vec3 *mult = new CompFab::Vec3(1,1,1);
|
||||
|
||||
//push_back initial templat's mesh, multiplied by the height multiplication matrix.
|
||||
for(int i = 0; i < t.size(); i++)
|
||||
{
|
||||
output->push_back(mmult(*mult, t[i]));
|
||||
|
@ -67,10 +66,11 @@ std::vector<CompFab::Vec3> createVec3d(std::vector<CompFab::Vec3> &t, int layers
|
|||
// cl for current layer.
|
||||
for(int cl = 1; cl < layers; cl++)
|
||||
{
|
||||
// Constructor used to bypass needing to create a new operator override for multiplication.
|
||||
// Should also consider doing so anyway to speed up process, use less memory, and add modularization.
|
||||
// Constructor used to re-initialize temp.
|
||||
*temp = CompFab::Vec3(-ls*cl, -ws*cl, 0);
|
||||
mult->m_z = 1.0 - (cl*1.0)/layers;
|
||||
|
||||
// Used to change the multiplciation matrix per layer.
|
||||
mult->m_z = 1.0/(cl +1);
|
||||
|
||||
|
||||
for(int c = 0; c < cl*8; c++)
|
||||
|
@ -110,36 +110,44 @@ int main(int argc, char **argv)
|
|||
// Error checking.
|
||||
if(argc < 3)
|
||||
{
|
||||
std::cout << "Usage: [executable] [template].obj output.obj [optional: -d for debugging output]" << std::endl;
|
||||
std::cout << "Usage: [executable] [template].obj output.obj [mode (-g, etc.)] [optional: -d for debugging output]" << std::endl;
|
||||
std::exit(1);
|
||||
}
|
||||
|
||||
// TODO: Modularize these.
|
||||
int layers = 10;
|
||||
double spacing = 0.5;
|
||||
|
||||
// Create Mesh object from file, output to manipulate from template Mesh.
|
||||
Mesh *test = new Mesh(argv[1], false);
|
||||
|
||||
double l = 0, w = 0;
|
||||
double *length = &l, *width = &w;
|
||||
|
||||
// Find the X and Y dimensions for the mesh. Assumes the mesh is facing upright.
|
||||
findLW(*test, *length, *width);
|
||||
|
||||
// Calculate the translation matrices needed and apply them.
|
||||
std::vector<CompFab::Vec3> vv = createVec3d(test->v, layers, spacing, *length, *width);
|
||||
|
||||
// Copying needed triangle data.
|
||||
std::vector<CompFab::Vec3i> tt = createVec3id(test->t, test->v, layers);
|
||||
|
||||
// Using contructor to create new output Mesh.
|
||||
Mesh *output = new Mesh(vv, tt);
|
||||
// Initialization of needed output variables.
|
||||
std::vector<CompFab::Vec3> vv;
|
||||
std::vector<CompFab::Vec3i> tt;
|
||||
Mesh *output = new Mesh();
|
||||
|
||||
// Debugging
|
||||
if(argc > 3)
|
||||
{
|
||||
if(strcmp(argv[3], "-d") == 0)
|
||||
if(strcmp(argv[3], "-g") == 0 || strcmp(argv[3], "-d") == 0)
|
||||
{
|
||||
// TODO: Modularize these.
|
||||
int layers = 10;
|
||||
double spacing = 1;
|
||||
|
||||
// Create Mesh object from file, output to manipulate from template Mesh.
|
||||
Mesh *test = new Mesh(argv[1], false);
|
||||
|
||||
double l = 0, w = 0;
|
||||
double *length = &l, *width = &w;
|
||||
|
||||
// Find the X and Y dimensions for the mesh. Assumes the mesh is facing upright.
|
||||
findLW(*test, *length, *width);
|
||||
|
||||
// Calculate the translation matrices needed and apply them.
|
||||
vv = createVec3d(test->v, layers, spacing, *length, *width);
|
||||
|
||||
// Copying needed triangle data.
|
||||
tt = createVec3id(test->t, test->v, layers);
|
||||
|
||||
// Using contructor to create new output Mesh.
|
||||
*output = Mesh(vv, tt);
|
||||
}
|
||||
|
||||
if(strcmp(argv[argc - 1], "-d") == 0)
|
||||
{
|
||||
for(int j = 0; j < output->v.size(); j++)
|
||||
{
|
||||
|
@ -151,10 +159,6 @@ int main(int argc, char **argv)
|
|||
std::cout << output->t[k].m_x << " " << output->t[k].m_y << " " << output->t[k].m_z << std::endl;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
std::cout << "Usage: [executable] [template].obj output.obj [optional: -d for debugging output]" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
output->save(argv[2]);
|
||||
|
|
Reference in a new issue