design1.ActiveViewport.DisplayMode = displayType.Shaded;
design1.Shaded.EdgeColorMethod = edgeColorMethodType.EntityColor;
design1.Shaded.EdgeThickness = 2;
// Side surface
Plane pln = new Plane(new Point3D(20, 0, 0), Vector3D.AxisMinusX);
Arc a1 = new Arc(pln, new Point2D(12,0), new Point2D(10, 10), new Point2D(0,26), false);
Plane pln2 = new Plane(new Point3D(80, 0, 0), Vector3D.AxisMinusX);
Arc a2 = new Arc(pln2, new Point2D(21,0), new Point3D(14,19), new Point3D(0,40), false);
devDept.Eyeshot.Entities.Point p = new devDept.Eyeshot.Entities.Point(Point3D.Origin, 8);
Surface s = Surface.Loft(new ICurve[] { p, a1, a2 }, 3)[0];
design1.Entities.Add(s, Color.WhiteSmoke);
// Handle
// Creates the handle's hole
Plane plc1 = new Plane(new Point3D(40, 0,21), Vector3D.AxisY);
Plane plc2 = new Plane(new Point3D(59, 0,24), Vector3D.AxisY);
Circle c1 = new Circle(plc1, plc1.Origin, 4);
Circle c2 = new Circle(plc2, plc2.Origin, 6);
Arc is1 = (Arc)UtilityEx.GetCirclesTangentToTwoCircles(c2, c1, 35, true)[2];
Arc is2 = (Arc)UtilityEx.GetCirclesTangentToTwoCircles(c1,c2, 45, true)[2];
Arc is3 = new Arc(plc1, c1.Center, c1.Radius, Math.PI * 2);
is3.TrimBy(is2.StartPoint, false);
is3.TrimBy(is1.EndPoint, true);
plc2.Rotate(Math.PI * 3 / 2, Vector3D.AxisY);
Arc is4 = new Arc(plc2, c2.Center, c2.Radius, Math.PI * 2);
is4.TrimBy(is2.EndPoint, true);
is4.TrimBy(is1.StartPoint, false);
CompositeCurve Hole = new CompositeCurve(new ICurve[]{
is1,
is2, is3, is4
});
Plane plsection = new Plane(Hole.StartPoint, Hole.StartTangent);
Arc section = new Arc(plsection, new Point2D(0, 0), new Point2D(3.3, 19), new Point2D(7, 27), true);
Surface trumpet1 = section.SweepAsSurface(Hole, 0.01, sweepMethodType.FrenetSerret)[0];
Surface trumpet2 = section.SweepAsSurface(Hole, 0.01, sweepMethodType.FrenetSerret)[1];
Surface trumpet3 = section.SweepAsSurface(Hole, 0.01, sweepMethodType.FrenetSerret)[2];
Surface trumpet4 = section.SweepAsSurface(Hole, 0.01, sweepMethodType.FrenetSerret)[3];
Surface[] trumpet = new Surface[] { trumpet1, trumpet2, trumpet3, trumpet4 };
design1.Entities.AddRange(trumpet, Color.LightSkyBlue);
// Creates the fillet between main shape and trumpet
var g1 = Surface.Fillet(new Surface[] { s }, trumpet, 4.5, 0.01, true, true, true, true, true, false, out Surface[] fillets);
design1.Entities.AddRange(fillets, Color.DarkBlue);
// Main shape
// Oblique cut
Line Sep = new Line(new Point3D(80, 0, 0), new Point3D(70, 0,44));
Surface[] plsep = Sep.ExtrudeAsSurface(Vector3D.AxisMinusY * 50);
design1.Entities.AddRange(plsep, Color.DarkBlue);
Surface.Trim(new Surface[] { s }, plsep, 0.1, false, true);
// Base of main shape
Line Base = new Line(new Point3D(0, 0, 0), new Point3D(80, 0, 0));
Surface[] plBase = Base.ExtrudeAsSurface(Vector3D.AxisMinusY * 50);
design1.Entities.AddRange(plBase, Color.LightBlue);
Surface.Trim(s , plBase[0], 0.001, false, true);
// Elliptical cut
Plane plelc = new Plane(new Point3D(80, 0, 0), Vector3D.AxisMinusY);
EllipticalArc elc = new EllipticalArc(plelc,10,20, -Math.PI, -Math.PI / 2);
Surface[] s1 = elc.ExtrudeAsSurface(Vector3D.AxisMinusY * 50);
design1.Entities.AddRange(s1, Color.LightGray);
Surface.Trim(new Surface[] { plsep[0], s, plBase[0] }, s1, 0.1, true, true);
// Reflect all Entities respect plane XZ
// Copy
Surface[] copy = new Surface[] { (Surface)fillets[0].Clone(), (Surface)fillets[1].Clone(), (Surface)fillets[2].Clone(), (Surface)fillets[3].Clone(), (Surface)plsep[0].Clone(), (Surface)plBase[0].Clone(), (Surface)trumpet[0].Clone(),
(Surface)trumpet[1].Clone(),(Surface) trumpet[2].Clone(),(Surface) trumpet[3].Clone(),(Surface)s.Clone(),(Surface)s1[0].Clone()};
// Mirror
Mirror mirrorTransformation = new Mirror(Plane.XZ);
foreach (Surface su in copy)
{
su.TransformBy(mirrorTransformation);
}
design1.Entities.AddRange((Surface[])copy);
// Creates the knob
Plane plnKnob = new Plane(new Point3D(47, 0, 16), Vector3D.AxisY);
ICurve[] knobCurve1 = new ICurve[]
{
new Line(plnKnob, new Point2D(-3,5.4),new Point2D(2.7,5.2)),
new Arc(plnKnob, new Point2D(2.7, 5.2),new Point2D(2.98,1),new Point2D(3,0),true),
};
Curve.Fillet(knobCurve1[0], knobCurve1[1], 1, true, false, true, true, out Arc fillet);
knobCurve1[0].TrimBy(fillet.StartPoint, false);
knobCurve1[1].TrimBy(fillet.EndPoint, true);
CompositeCurve knobCurve2 = new CompositeCurve(new ICurve[]
{
knobCurve1[0],
knobCurve1[1],
fillet
});
Surface[] knob = knobCurve2.RevolveAsSurface(0, 2 * Math.PI, plnKnob.AxisX, plnKnob.Origin);
design1.Entities.AddRange(knob, Color.LightSteelBlue);
Surface.Trim(new Surface[] { copy[6], trumpet[0] }, knob, 0.01, true, false);
// Iron plate
// First part
ICurve[] edgesBase = plBase[0].ExtractEdges();
Double lenoffset = 0.6;
ICurve edgeoffset = edgesBase[1].Offset(lenoffset, Vector3D.AxisZ, true)[0];
ICurve edgeoffset1 = (ICurve)edgeoffset.Clone();
((Entity)edgeoffset1).TransformBy(new Mirror(Plane.XZ));
Point3D[] intersectpoint1 = edgeoffset.IntersectWith(edgeoffset1);
edgeoffset.TrimBy(intersectpoint1[0], false);
edgeoffset1.TrimBy(intersectpoint1[0], false);
Line edgeoffset2 = new Line(new Point3D(60 - lenoffset, 20.8374,0), new Point3D(60 - lenoffset, -20.8374,0));
Point3D[] intersectpoint2 = edgeoffset2.IntersectWith(edgeoffset);
Point3D[] intersectpoint3 = edgeoffset2.IntersectWith(edgeoffset1);
edgeoffset2.TrimBy(intersectpoint2[0], false);
edgeoffset.TrimBy(intersectpoint2[0], true);
edgeoffset1.TrimBy(intersectpoint3[0], true);
edgeoffset2.TrimBy(intersectpoint3[0], true);
CompositeCurve offsetBase = new CompositeCurve(new ICurve[] { edgeoffset, edgeoffset1, edgeoffset2 });
design1.Entities.Add(offsetBase);
devDept.Eyeshot.Entities.Region r1 = new devDept.Eyeshot.Entities.Region(offsetBase, Plane.XY, true);
Surface[] s2 = r1.ExtrudeAsSurface(-.9 * Vector3D.AxisZ);
design1.Entities.AddRange(s2, Color.LightGray);
// Second part
ICurve copy_edge_bases = (ICurve)edgesBase[1].Clone();
((Entity)copy_edge_bases).TransformBy(mirrorTransformation);
CompositeCurve FerroBase = new CompositeCurve(new ICurve[]{
edgesBase[1], copy_edge_bases,
new Line(edgesBase[1].StartPoint, copy_edge_bases.StartPoint),
new Arc(edgesBase[1].EndPoint, new Point3D(0.1,0,0), copy_edge_bases.EndPoint, true)
});
devDept.Eyeshot.Entities.Region r2 = new devDept.Eyeshot.Entities.Region(FerroBase, Plane.XY, true);
r2.Translate(-.9 * Vector3D.AxisZ);
Surface[] plate = r2.ExtrudeAsSurface(-1.5 * Vector3D.AxisZ);
design1.Entities.AddRange(plate, Color.Gray);
design1.Entities.Regen();
Mesh generation
// Mesh generation of side surface
SurfaceMesher sm = new SurfaceMesher(s, 3);
sm.DoWork();
design1.ActiveViewport.DisplayMode = displayType.Shaded;
design1.Entities.Add(sm.Result);
Comments
Please sign in to leave a comment.