|
@@ -54,14 +54,17 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
#include <assimp/ByteSwapper.h>
|
|
#include <assimp/ByteSwapper.h>
|
|
|
|
|
|
using namespace Assimp;
|
|
using namespace Assimp;
|
|
|
|
+
|
|
namespace Assimp {
|
|
namespace Assimp {
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
// Worker function for exporting a scene to Stereolithograpy. Prototyped and registered in Exporter.cpp
|
|
// Worker function for exporting a scene to Stereolithograpy. Prototyped and registered in Exporter.cpp
|
|
-void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/)
|
|
|
|
|
|
+void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties )
|
|
{
|
|
{
|
|
|
|
+ bool exportPointClouds = pProperties->GetPropertyBool(AI_CONFIG_EXPORT_POINT_CLOUDS);
|
|
|
|
+
|
|
// invoke the exporter
|
|
// invoke the exporter
|
|
- STLExporter exporter(pFile, pScene);
|
|
|
|
|
|
+ STLExporter exporter(pFile, pScene, exportPointClouds );
|
|
|
|
|
|
if (exporter.mOutput.fail()) {
|
|
if (exporter.mOutput.fail()) {
|
|
throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile));
|
|
throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile));
|
|
@@ -75,10 +78,12 @@ void ExportSceneSTL(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene
|
|
|
|
|
|
outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1);
|
|
outfile->Write( exporter.mOutput.str().c_str(), static_cast<size_t>(exporter.mOutput.tellp()),1);
|
|
}
|
|
}
|
|
-void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* /*pProperties*/)
|
|
|
|
|
|
+void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene* pScene, const ExportProperties* pProperties )
|
|
{
|
|
{
|
|
|
|
+ bool exportPointClouds = pProperties->GetPropertyBool(AI_CONFIG_EXPORT_POINT_CLOUDS);
|
|
|
|
+
|
|
// invoke the exporter
|
|
// invoke the exporter
|
|
- STLExporter exporter(pFile, pScene, true);
|
|
|
|
|
|
+ STLExporter exporter(pFile, pScene, exportPointClouds, true);
|
|
|
|
|
|
if (exporter.mOutput.fail()) {
|
|
if (exporter.mOutput.fail()) {
|
|
throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile));
|
|
throw DeadlyExportError("output data creation failed. Most likely the file became too large: " + std::string(pFile));
|
|
@@ -97,7 +102,7 @@ void ExportSceneSTLBinary(const char* pFile,IOSystem* pIOSystem, const aiScene*
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------------------------------------------------------------
|
|
// ------------------------------------------------------------------------------------------------
|
|
-STLExporter :: STLExporter(const char* _filename, const aiScene* pScene, bool binary)
|
|
|
|
|
|
+STLExporter::STLExporter(const char* _filename, const aiScene* pScene, bool exportPointClouds, bool binary)
|
|
: filename(_filename)
|
|
: filename(_filename)
|
|
, endl("\n")
|
|
, endl("\n")
|
|
{
|
|
{
|
|
@@ -118,12 +123,37 @@ STLExporter :: STLExporter(const char* _filename, const aiScene* pScene, bool bi
|
|
}
|
|
}
|
|
AI_SWAP4(meshnum);
|
|
AI_SWAP4(meshnum);
|
|
mOutput.write((char *)&meshnum, 4);
|
|
mOutput.write((char *)&meshnum, 4);
|
|
|
|
+
|
|
|
|
+ if (exportPointClouds) {
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
|
|
for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
|
|
WriteMeshBinary(pScene->mMeshes[i]);
|
|
WriteMeshBinary(pScene->mMeshes[i]);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
const std::string& name = "AssimpScene";
|
|
const std::string& name = "AssimpScene";
|
|
|
|
|
|
|
|
+ // Exporting only point clouds
|
|
|
|
+ if (exportPointClouds) {
|
|
|
|
+ mOutput << "solid " << name << endl;
|
|
|
|
+ aiVector3D nor;
|
|
|
|
+ mOutput << " facet normal " << nor.x << " " << nor.y << " " << nor.z << endl;
|
|
|
|
+ for (unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
|
|
|
|
+ aiMesh *mesh = pScene->mMeshes[i];
|
|
|
|
+ if (mesh->mNormals) {
|
|
|
|
+ for (unsigned int a = 0; a < mesh->mNumVertices; ++a) {
|
|
|
|
+ const aiVector3D& v = mesh->mVertices[a];
|
|
|
|
+ mOutput << " vertex " << v.x << " " << v.y << " " << v.z << endl;
|
|
|
|
+ mOutput << " vertex " << v.x << " " << v.y << " " << v.z << endl;
|
|
|
|
+ mOutput << " vertex " << v.x << " " << v.y << " " << v.z << endl;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ mOutput << "endsolid " << name << endl;
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
mOutput << "solid " << name << endl;
|
|
mOutput << "solid " << name << endl;
|
|
for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
|
|
for(unsigned int i = 0; i < pScene->mNumMeshes; ++i) {
|
|
WriteMesh(pScene->mMeshes[i]);
|
|
WriteMesh(pScene->mMeshes[i]);
|