diff --git a/cmath3d/TriangleMesh.cpp b/cmath3d/TriangleMesh.cpp
index 834e67678643aaa1dcd9db4c047256f4691598a8..56bb04ee112bb9f4a1cc428edf6f52c0566b1fcb 100644
--- a/cmath3d/TriangleMesh.cpp
+++ b/cmath3d/TriangleMesh.cpp
@@ -181,6 +181,28 @@ int ActiveMesh::ImportSTL(const char *filename)
 	return(0);
 }
 
+int ActiveMesh::ExportSTL(const char *filename)
+{
+	//try to open the file
+	std::ofstream file(filename);
+	if (!file.is_open()) return(1);
+
+	file << "solid Vladimir Ulman - meshSurface testing app\n";
+
+	for (unsigned int i=0; i < ID.size(); i+=3)
+	{
+		file << "facet normal " << norm[i/3].x << " " << norm[i/3].y << " " << norm[i/3].z << "\n";
+		file << "outer loop\n";
+		file << "vertex " << Pos[ID[i+0]].x << " " << Pos[ID[i+0]].y << " " << Pos[ID[i+0]].z << "\n";
+		file << "vertex " << Pos[ID[i+1]].x << " " << Pos[ID[i+1]].y << " " << Pos[ID[i+1]].z << "\n";
+		file << "vertex " << Pos[ID[i+2]].x << " " << Pos[ID[i+2]].y << " " << Pos[ID[i+2]].z << "\n";
+		file << "endloop\nendfacet\n";
+	}
+
+	file.close();
+	return(0);
+}
+
 
 int ActiveMesh::ImportVTK(const char *filename) //surface version
 {
diff --git a/cmath3d/TriangleMesh.h b/cmath3d/TriangleMesh.h
index f332791295842ec0f97211386abe2628f9ca88f7..e28d8ca2605058ec6d44187611bba5dc23f80abe 100644
--- a/cmath3d/TriangleMesh.h
+++ b/cmath3d/TriangleMesh.h
@@ -96,6 +96,7 @@ class ActiveMesh
 	///input is filename
 	///returns 0 on success, otherwise non-zero
 	int ImportSTL(const char* filename);
+	int ExportSTL(const char* filename);
 	int ImportVTK(const char* filename);
 	int ImportVTK_Volumetric(const char* filename);