public void WriteShell() { string name = this.name + ".stl"; STLWriter.WriteSTLOfMesh(mFilter.mesh, name); }
// Write a set of STLs for a juncture, and an OpenSCAD file that // compiles them all into one fused part. public string WriteSTLOfJuncture(Vector3 minOffset, string objName) { List <string> unionSTLs = new List <string>(); List <string> diffSTLs = new List <string>(); string bulbSTL = ""; // If there is a parent segment, write that if (parentSegment) { TelescopeShell last = parentSegment.LastShell; // Export them in world coordinates so that the full // object can just be assembled without moving pieces around STLWriter.VectorTransform f = (v => last.transform.rotation * v + last.transform.position - minOffset); if (parentSegment.NumShells > 1 && parentSegment.Reversed) { Mesh inner = last.GenerateInnerVolume(parentSegment.shells[parentSegment.NumShells - 2].getParameters(), -Constants.WALL_THICKNESS, extraRings: Constants.CUTS_PER_CYLINDER / 2); string parentVolumeSTL = objName + "-parentInner.stl"; STLWriter.WriteSTLOfMesh(inner, "scad/" + parentVolumeSTL, f); diffSTLs.Add(parentVolumeSTL); } } // Write each child segment as well int childNum = 0; foreach (TelescopeSegment childSegment in childSegments) { TelescopeShell first = childSegment.FirstShell; STLWriter.VectorTransform f = (v => first.transform.rotation * v + first.transform.position - minOffset); // Write a mesh for the inner volume contained in the shell, // so that it can be subtracted out from the juncture if (childSegment.NumShells > 1 && !childSegment.Reversed) { Mesh inner = first.GenerateInnerVolume(childSegment.shells[1].getParameters(), -Constants.WALL_THICKNESS, extraRings: Constants.CUTS_PER_CYLINDER / 2); string childVolumeSTL = objName + "-childInner" + childNum + ".stl"; STLWriter.WriteSTLOfMesh(inner, "scad/" + childVolumeSTL, f); diffSTLs.Add(childVolumeSTL); } childNum++; } // Write this piece if (junctureType != JunctureType.None) { STLWriter.VectorTransform f = (v => transform.rotation * v + transform.position - minOffset); bulbSTL = objName + ".stl"; STLWriter.WriteSTLOfMesh(mFilter.mesh, "scad/" + bulbSTL, f); } string scadFile = objName + ".scad"; STLWriter.WriteSCADOfJunctureSTLs(bulbSTL, unionSTLs, diffSTLs, "scad/" + scadFile); return(scadFile); }