/// <summary> /// Generates a row of cylinders tessellated w/ different chord lengths /// eg 10x1cm : CalibrationModelGenerator.MakePrintStepSizeTest(10.0f, 10.0f, 0.1, 1.0, 10); /// </summary> public static DMesh3 MakePrintStepSizeTest(double cylDiam, double cylHeight, double lowStep, double highStep, int nSteps) { double spacing = 2.0f; float r = (float)cylDiam * 0.5f; double cx = 0.5 * (nSteps * cylDiam + (nSteps - 1) * spacing); DMesh3 accumMesh = new DMesh3(); double cur_x = -cx + cylDiam / 2; for (int k = 0; k < nSteps; ++k) { double t = (double)k / (double)(nSteps - 1); double chord_len = (1.0 - t) * lowStep + (t) * highStep; int slices = (int)((MathUtil.TwoPI * r) / chord_len); CappedCylinderGenerator cylgen = new CappedCylinderGenerator() { BaseRadius = r, TopRadius = r, Height = (float)cylHeight, Slices = slices, NoSharedVertices = false }; DMesh3 cylMesh = cylgen.Generate().MakeDMesh(); MeshTransforms.Translate(cylMesh, -cylMesh.CachedBounds.Min.y * Vector3d.AxisY); MeshTransforms.Translate(cylMesh, cur_x * Vector3d.AxisX); cur_x += cylDiam + spacing; MeshEditor.Append(accumMesh, cylMesh); } MeshTransforms.ConvertYUpToZUp(accumMesh); return(accumMesh); }
public static Mesh CreateCylinder(float radius, float height, int nSlices, float fStartAngleDeg = 0.0f, float fEndAngleDeg = 360.0f) { CappedCylinderGenerator gen = new CappedCylinderGenerator() { BaseRadius = radius, TopRadius = radius, Height = height, Slices = nSlices, Clockwise = true, StartAngleDeg = fStartAngleDeg, EndAngleDeg = fEndAngleDeg }; gen.Generate(); return gen.MakeUnityMesh(false); }
protected void generate(float fDiameter, float fHeight, float fWallThickness, float fBaseThickness) { base.reset_holes(); CappedCylinderGenerator outer_cylgen = new CappedCylinderGenerator() { BaseRadius = fDiameter / 2, TopRadius = fDiameter / 2, Height = fHeight + 10, Slices = 60, Clockwise = true }; DMesh3 outer_mesh = outer_cylgen.Generate().MakeDMesh(); float fInnerDiam = fDiameter - 2 * fWallThickness; CappedCylinderGenerator inner_cylgen = new CappedCylinderGenerator() { BaseRadius = fInnerDiam / 2, TopRadius = fInnerDiam / 2, Height = fHeight + 10, Slices = 60, Clockwise = false }; DMesh3 inner_mesh = inner_cylgen.Generate().MakeDMesh(); MeshTransforms.Translate(inner_mesh, fBaseThickness * Vector3d.AxisY); DMesh3[] meshes = new DMesh3[2] { outer_mesh, inner_mesh }; foreach (DMesh3 mesh in meshes) { Remesher r = new Remesher(mesh); r.SetTargetEdgeLength(TargetEdgeLength); r.SmoothSpeedT = 0.5f; r.SetExternalConstraints(new MeshConstraints()); MeshConstraintUtil.FixAllGroupBoundaryEdges(r.Constraints, mesh, true); r.SetProjectionTarget(MeshProjectionTarget.Auto(mesh)); for (int k = 0; k < 10; ++k) { r.BasicRemeshPass(); } } Vector3d vCutPos = new Vector3d(0, fHeight, 0); Vector3d vCutNormal = Vector3d.AxisY; foreach (DMesh3 mesh in meshes) { MeshPlaneCut cut = new MeshPlaneCut(mesh, new Vector3d(0, fHeight, 0), Vector3d.AxisY); cut.Cut(); } base.set_output_meshes(inner_mesh, outer_mesh); }
public static void basic_tests() { System.Console.WriteLine("DMesh3:basic_tests() starting"); CappedCylinderGenerator cylgen = new CappedCylinderGenerator(); cylgen.Generate(); NTMesh3 tmp = cylgen.MakeNTMesh(); tmp.CheckValidity(); System.Console.WriteLine("cylinder ok"); }
void update_hole_mesh() { CappedCylinderGenerator cylgen = new CappedCylinderGenerator() { BaseRadius = 0.5f, TopRadius = 0.5f, Height = 1, Slices = this.subdivisions, Clockwise = true }; DMesh3 mesh = cylgen.Generate().MakeDMesh(); MeshTransforms.Rotate(mesh, Vector3d.Zero, Quaterniond.AxisAngleD(Vector3d.AxisX, 90)); CavityPreviewSO.ReplaceMesh(mesh, true); }
virtual protected DMesh3 make_shape_cylinder() { Vector3d origin = new Vector3d(0, ShapeHeight / 2, 0); CappedCylinderGenerator cylgen = new CappedCylinderGenerator() { BaseRadius = (float)ShapeWidth / 2, TopRadius = (float)ShapeWidth / 2, Height = (float)ShapeHeight, Slices = Math.Max(2, Subdivisions), Clockwise = true }; return(cylgen.Generate().MakeDMesh()); }
static void Main(string[] args) { CappedCylinderGenerator cylgen = new CappedCylinderGenerator() { BaseRadius = 10, TopRadius = 5, Height = 20, Slices = 32 }; DMesh3 mesh = cylgen.Generate().MakeDMesh(); MeshTransforms.ConvertYUpToZUp(mesh); // g3 meshes are usually Y-up // center mesh above origin AxisAlignedBox3d bounds = mesh.CachedBounds; Vector3d baseCenterPt = bounds.Center - bounds.Extents.z * Vector3d.AxisZ; MeshTransforms.Translate(mesh, -baseCenterPt); // create print mesh set PrintMeshAssembly meshes = new PrintMeshAssembly(); meshes.AddMesh(mesh, PrintMeshOptions.Default()); // create settings //MakerbotSettings settings = new MakerbotSettings(Makerbot.Models.Replicator2); //PrintrbotSettings settings = new PrintrbotSettings(Printrbot.Models.Plus); //MonopriceSettings settings = new MonopriceSettings(Monoprice.Models.MP_Select_Mini_V2); RepRapSettings settings = new RepRapSettings(RepRap.Models.Unknown); // do slicing MeshPlanarSlicer slicer = new MeshPlanarSlicer() { LayerHeightMM = settings.LayerHeightMM }; slicer.Add(meshes); PlanarSliceStack slices = slicer.Compute(); // run print generator SingleMaterialFFFPrintGenerator printGen = new SingleMaterialFFFPrintGenerator(meshes, slices, settings); if (printGen.Generate()) { // export gcode GCodeFile gcode = printGen.Result; using (StreamWriter w = new StreamWriter("c:\\demo\\cone.gcode")) { StandardGCodeWriter writer = new StandardGCodeWriter(); writer.WriteFile(gcode, w); } } }
public static DMesh3 MakeCappedCylinder(bool bNoSharedVertices, int nSlices = 16, bool bHole = false) { DMesh3 mesh = new DMesh3(true, false, false, true); CappedCylinderGenerator cylgen = new CappedCylinderGenerator() { NoSharedVertices = bNoSharedVertices, Slices = nSlices }; cylgen.Generate(); cylgen.MakeMesh(mesh); mesh.ReverseOrientation(); if (bHole) { mesh.RemoveTriangle(0); } return(mesh); }