Skip to content
Browse files

I'm an idiot for not getting assimp into this project earlier

  • Loading branch information...
1 parent bd790de commit ea4404d3d3ea20f3985e4790ff5c068c90875c86 @FarMcKon FarMcKon committed May 4, 2012
View
3 .gitmodules
@@ -1,3 +1,6 @@
[submodule "submodules/rtree"]
path = submodules/rtree
url = https://github.com/nushoin/RTree.git
+[submodule "submodules/assimp"]
+ path = submodules/assimp
+ url = git@github.com:makerbot/assimp.git
View
11 src/main/cpp/src/BinaryStlFormatter.cpp
@@ -238,7 +238,7 @@ void BinaryStlFormatter::writeMesh(std::ostream& outFh, const libthing::Mesh& me
char nameField[COMMENT_MAX_LEN];
strncpy(nameField, mesh.getComment().c_str(), COMMENT_MAX_LEN);
outFh.write(nameField, COMMENT_MAX_LEN);
- cout << "BLARG " << endl;
+ //cout << "BLARG " << endl;
const FaceNormalTriangleMesh* fntMesh = dynamic_cast<const FaceNormalTriangleMesh*>(&mesh);
@@ -247,17 +247,10 @@ void BinaryStlFormatter::writeMesh(std::ostream& outFh, const libthing::Mesh& me
std::vector<FaceNormTriangle3> tris = fntMesh->readAllTriangles();
uint32_t faces = tris.size();
writeUInt32(outFh, faces);
- cout << "blarg 2" << tris.size() << endl;
+ //cout << "blarg 2" << tris.size() << endl;
FOREACH(I, tris) { //FUTURE: make this a C++11 foreach someday soon
writeTriangleBinary(outFh, *I, (*I).normal());
outFh.write(padding, 2);//padding
}
}
- throw -1;
-
-// uint32_t triCount = countTris(&node);
-// outf.write((const char*)&triCount,sizeof(triCount));
-//
-// writeBinMeshRecurse(outf, &node, transformation);
-
}
View
15 src/main/cpp/src/ObjFormatter.cpp
@@ -111,7 +111,14 @@ Mesh* ObjFormatter::readMesh(istream& in) {
return mesh;
}
- void ObjFormatter::writeMesh(ostream& outFh, const Mesh& mesh)
- {
- throw -1;
- }
+void ObjFormatter::writeMesh(ostream& outFh, const Mesh& mesh)
+{
+ FaceNormalTriangleMesh* fntMesh = dyamic_cast<FaceNormalTriangleMesh>(mesh);
+ VertexNormalTriangleMesh* vntMesh = dyamic_cast<VertexNormalTriangleMesh>(mesh);
+
+ if(vntMesh != NULL) {
+ std::vector<VertexNormTriangle3> tris = vntMesh.readAllTriangles();
+
+
+ throw -1;
+}
View
40 src/test/cpp/ModelReaderTestCase.cc
@@ -17,7 +17,7 @@
#include "libthing/StlFormatters.h"
#include "libthing/PlatformTools.h"
-
+#include "libthing/ObjFormatter.h"
CPPUNIT_TEST_SUITE_REGISTRATION( ModelReaderTestCase );
using namespace std;
@@ -187,7 +187,7 @@ void ModelReaderTestCase::testBinaryStlFormatterCycle()
unsigned int t0,t1;
string target = inputsDir + "flat.bin.stl";
string drop = outputsDir + "flat.bin.stl";
-// string drop2 = outputsDir + "teapot_v2.bin.stl";
+ string drop2 = outputsDir + "flat_v2.bin.stl";
BinaryStlFormatter BinaryStlFormatter;
@@ -201,7 +201,7 @@ void ModelReaderTestCase::testBinaryStlFormatterCycle()
stream.close();
//mesh->dump(cout);
cout << "Read: " << target <<" in seconds: " << t1 << endl;
-//
+
cout << "Writing test file:" << drop << endl;
std::ofstream outStream;
outStream.open(drop.c_str());
@@ -212,22 +212,22 @@ void ModelReaderTestCase::testBinaryStlFormatterCycle()
cout << "Wrote: " << drop <<" in seconds: " << t1 << endl;
-// cout << "Reload test, reloading file: " << drop << endl;
-// stream.open(drop.c_str());
-// t0=clock();
-// Mesh* mesh2 = BinaryStlFormatter.readMesh(stream);
-// stream.close();
-// t1=clock()-t0;
-// cout << "Re-Read: " << target <<" in seconds: " << t1 << endl;
+ cout << "Reload test, reloading file: " << drop << endl;
+ stream.open(drop.c_str());
+ t0=clock();
+ Mesh* mesh2 = BinaryStlFormatter.readMesh(stream);
+ stream.close();
+ t1=clock()-t0;
+ cout << "Re-Read: " << target <<" in seconds: " << t1 << endl;
- //CPPUNIT_ASSERT(*mesh1 == *mesh2);
+// //CPPUNIT_ASSERT(*mesh1 == *mesh2);
-// cout << "Re-Writing test file: " << drop2 << endl;
-// outStream.open(drop2.c_str());
-// BinaryStlFormatter.writeMesh(outStream,*mesh2);
-// outStream.close();
-// unsigned int t2=clock()-t1;
-// cout << "Re-Wrote: " << drop2 <<" in seconds: " << t2 << endl;
+ cout << "Re-Writing test file: " << drop2 << endl;
+ outStream.open(drop2.c_str());
+ BinaryStlFormatter.writeMesh(outStream,*mesh2);
+ outStream.close();
+ unsigned int t2=clock()-t1;
+ cout << "Re-Wrote: " << drop2 <<" in seconds: " << t2 << endl;
}
@@ -238,12 +238,12 @@ void ModelReaderTestCase::testObjFormatterCycle()
unsigned int t0,t1;
string target = inputsDir + "teapot.obj";
string drop = outputsDir + "teapot.obj";
-// string drop2 = outputsDir + "teapot.2.obj";
+ string drop2 = outputsDir + "teapot.2.obj";
- BinaryStlFormatter BinaryStlFormatter;
+ ObjFormatter objf;
cout << "Reading test file:" << target << endl;
- std::ifstream stream;
+// std::ifstream stream;
}
1 submodules/assimp
@@ -0,0 +1 @@
+Subproject commit 13774c5f87ba19e96c3157e75ff01455d74464d1
View
BIN test_cases/modelReaderTestCase/flat.bin.stl
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit ea4404d

Please sign in to comment.
Something went wrong with that request. Please try again.