11-16-2020, 12:58 PM
This was an interesting problem.
It seems that it was possible to export to other file formats, but not to stl.
After using a debug version of assimp importer, I found out that when exporting to stl the assimp exporter does not "want" that the SceneFlags has the NonVerboseFormat flag set. If this flag is set, then the following code throws an exception:
if (pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) {
throw DeadlyImportError("Post-processing order mismatch: expecting pseudo-indexed (\"verbose\") vertices here");
}
This is done before calculating the normals. I do not know why this is needed to calculate the normals. I also do not know why models created from code (SphereVisual3D, BoxVisual3D, ...) work well, but files imported from stl files throw that exception.
The description of the NonVerboseFormat flag is:
This flag is currently only set by the aiProcess_JoinIdenticalVertices step.
It indicates that the vertices of the output meshes aren't in the internal verbose format anymore. In the verbose format all vertices are unique, no vertex is ever referenced by more than one face.
But it seems that it is used in some other places. This flag is also set by the AssimpWpfExporter. This was done based on the comment from Exporter.cpp file in assimp importer.
But if the flag is not set, then it seems that exporting works fine for stl file and for other files also.
Therefore I have removed setting this flag. This will be available in the next version.
Until then you can use a workaround and manually set the SceneFlags to None. In the AssimpWpfExporterSample this can be done by adding the following line after "assimpWpfExporter.AddViewport3D(viewport3D);":
assimpWpfExporter.AssimpScene.SceneFlags = SceneFlags.None;
It seems that it was possible to export to other file formats, but not to stl.
After using a debug version of assimp importer, I found out that when exporting to stl the assimp exporter does not "want" that the SceneFlags has the NonVerboseFormat flag set. If this flag is set, then the following code throws an exception:
if (pScene->mFlags & AI_SCENE_FLAGS_NON_VERBOSE_FORMAT) {
throw DeadlyImportError("Post-processing order mismatch: expecting pseudo-indexed (\"verbose\") vertices here");
}
This is done before calculating the normals. I do not know why this is needed to calculate the normals. I also do not know why models created from code (SphereVisual3D, BoxVisual3D, ...) work well, but files imported from stl files throw that exception.
The description of the NonVerboseFormat flag is:
This flag is currently only set by the aiProcess_JoinIdenticalVertices step.
It indicates that the vertices of the output meshes aren't in the internal verbose format anymore. In the verbose format all vertices are unique, no vertex is ever referenced by more than one face.
But it seems that it is used in some other places. This flag is also set by the AssimpWpfExporter. This was done based on the comment from Exporter.cpp file in assimp importer.
But if the flag is not set, then it seems that exporting works fine for stl file and for other files also.
Therefore I have removed setting this flag. This will be available in the next version.
Until then you can use a workaround and manually set the SceneFlags to None. In the AssimpWpfExporterSample this can be done by adding the following line after "assimpWpfExporter.AddViewport3D(viewport3D);":
assimpWpfExporter.AssimpScene.SceneFlags = SceneFlags.None;
Andrej Benedik

