Beispiel #1
0
        public HbCurve Hb(ArcCurve arcCurveRhino)
        {
            HbCurve hbCurve       = new HbCurve();
            Point3d xyzRhinoStart = arcCurveRhino.PointAtStart;
            Point3d xyzRhinoEnd   = arcCurveRhino.PointAtEnd;
            Point3d xyzRhinoMid   = arcCurveRhino.PointAtNormalizedLength(0.5);

            if (arcCurveRhino.IsArc())
            {
                HbArc hbArcRevit = new HbArc();
                hbArcRevit.PointStart = new HbXYZ(xyzRhinoStart.X, xyzRhinoStart.Y, xyzRhinoStart.Z);
                hbArcRevit.PointEnd   = new HbXYZ(xyzRhinoEnd.X, xyzRhinoEnd.Y, xyzRhinoEnd.Z);
                hbArcRevit.PointMid   = new HbXYZ(xyzRhinoMid.X, xyzRhinoMid.Y, xyzRhinoMid.Z);
                hbCurve = hbArcRevit;
            }
            return(hbCurve);
        }
Beispiel #2
0
        public List <Curve> buildGear(List <Circle> C, double Teeth, double Angle, double profileShift, double addendum, double dedendum, out List <int> teethNumber)
        {
            List <Curve> curves = new List <Curve>();
            ArcCurve     sC     = new ArcCurve(C[0]);

            if (C.Count > 1)
            {
                sC = smallestCircle(C);
            }

            double m = (2 * sC.Radius) / Teeth;

            addendum = addendum * m;
            dedendum = dedendum * m;

            teethNumber = new List <int>();
            for (int i = 0; i < C.Count; i++)
            {
                List <Curve> profiles = new List <Curve>();
                Circle       baseCir  = new Circle(C[i].Plane, C[i].Radius * Math.Cos(toRadian(Angle)));
                Circle       addCir   = new Circle(C[i].Plane, C[i].Radius + addendum);
                Circle       dedCir   = new Circle(C[i].Plane, C[i].Radius - dedendum);
                Curve        profile  = involute(baseCir, Angle, addCir, dedCir);

                int teethCount = (int)(Teeth * (C[i].Radius / sC.Radius)); // teeth number
                teethNumber.Add(teethCount);
                //mirror profile
                Vector3d newX = C[i].Plane.XAxis;
                //the thickness of gear, should be halt of pitch angle
                if (profileShift != 0)
                {
                    newX.Rotate((Math.PI + profileShift * Math.PI * Math.Tan(Angle)) / (double)teethCount, C[i].Normal); //circular pitch
                }
                else
                {
                    newX.Rotate(Math.PI / teethCount, C[i].Normal);
                }
                Curve     mirProfile = profile.DuplicateCurve();
                Transform mirror     = Transform.Mirror(new Plane(C[i].Center, newX + C[i].Plane.XAxis, C[i].Normal));
                mirProfile.Transform(mirror);

                //align the profile
                var       ccx     = Rhino.Geometry.Intersect.Intersection.CurveCurve(profile, new ArcCurve(C[i]), 1, 1);
                Transform aligned = Transform.Rotation(ccx[0].PointA - C[i].Center, C[i].Plane.XAxis, C[i].Center);
                profile.Transform(aligned);
                mirProfile.Transform(aligned);

                //tip and buttom arc
                double   addAngle = Vector3d.VectorAngle(profile.PointAtEnd - C[i].Center, mirProfile.PointAtEnd - C[i].Center);
                double   dedAngle = (1.0 / (double)teethCount) * Math.PI * 2 - Vector3d.VectorAngle(profile.PointAtStart - C[i].Center, mirProfile.PointAtStart - C[i].Center);
                Plane    addPln   = new Plane(C[i].Center, profile.PointAtEnd - C[i].Center, C[i].Plane.YAxis);
                Plane    dedPln   = new Plane(C[i].Center, mirProfile.PointAtStart - C[i].Center, C[i].Plane.YAxis);
                ArcCurve tip      = new ArcCurve(new Arc(addPln, C[i].Radius + addendum, addAngle));
                ArcCurve buttom   = new ArcCurve(new Arc(dedPln, C[i].Radius - dedendum, dedAngle));

                //display
                locations.Add(tip.PointAtNormalizedLength(0.5)); //tip
                texts.Add(Math.Round(tip.GetLength(), 2).ToString());
                sizes.Add((addendum + dedendum) * 4);
                locations.Add(profile.PointAtStart); //profile
                texts.Add(Math.Round(profile.GetLength(), 2).ToString());
                sizes.Add((addendum + dedendum) * 4);

                //teeth
                mirProfile.Reverse();
                List <Curve> CS = new List <Curve> {
                    profile, tip, mirProfile, buttom
                };
                Curve teethC = Curve.JoinCurves(CS, 0.1, true)[0];
                for (int j = 0; j < teethCount; j++)
                {
                    Curve     presentProfile = teethC.DuplicateCurve();
                    double    step           = ((double)j / (double)teethCount) * Math.PI * 2;
                    Transform rotate         = Transform.Rotation(step, C[i].Normal, C[i].Center);
                    presentProfile.Transform(rotate);

                    profiles.Add(presentProfile);
                }

                curves.Add(Curve.JoinCurves(profiles, 0.01, true)[0]);
            }
            return(curves);
        }