Exemple #1
0
        private Brep OffsetRevolvedShell(List <Surface> surfs, double thickness, bool flipNorm, bool inner, Point3D relOrigin)
        {
            var hasOffset = Math.Abs(thickness) > 0.0;

            var outerInner = GetOuterInnerSurfaces(surfs, relOrigin);
            var bound      = (inner) ? outerInner.Item1 : outerInner.Item2;
            var curves     = bound.Section(Plane.XZ, 0.0001).ToList();

            curves = UtilityEx.GetConnectedCurves(curves, 0.0001).ToList();
            var flat  = curves.Any(c => c.IsInPlane(Plane.XY, 0.0001));
            var curve = (flat)
                ? curves.OrderByDescending(c => c.StartPoint.DistanceTo(Point3D.Origin)).Last()
                : curves.OrderByDescending(c => c.StartPoint.DistanceTo(Point3D.Origin)).First();
            var direction = 1.0;

            if (inner)
            {
                curve.Reverse();
                direction *= -1.0;
            }

            if ((curve.StartPoint.X > 0.0 && curve.EndPoint.X < 0.0) ||
                (curve.StartPoint.X < 0.0 && curve.EndPoint.X > 0.0))
            {
                var len = curve.Length();
                curve.SubCurve(curve.StartPoint, curve.GetPointsByLength(len / 2.0)[1], out curve);
            }

            var reg = new Region(curve);

            if (hasOffset && flat)
            {
                reg.Translate(Vector3D.AxisZ * direction * thickness);
            }
            else if (hasOffset)
            {
                reg = new Region(curve.Offset(direction * thickness, Vector3D.AxisY, 0.0001, true));
            }

            var b = reg.RevolveAsBrep(0.0, 2.0 * Math.PI, Vector3D.AxisZ, Point3D.Origin, 0.0001);

            if ((flipNorm ^ inner) && !flat)
            {
                b.FlipNormal();
            }

            return(b);
        }
Exemple #2
0
        private bool SetIntersectionCurves(CaseArgs args)
        {
            if (!GetIntersectionCurves(args.Shell, args.Neck, out var tmpCurves))
            {
                return(false);
            }

            tmpCurves = UtilityEx.GetConnectedCurves(tmpCurves, 0.0001).ToList();
            var ordered = tmpCurves.OrderByDescending(c => c.StartPoint.X);

            _intersectionCurves.Add(ordered.Last());
            if (tmpCurves.Count > 1)
            {
                _intersectionCurves.Add(ordered.First());
            }
            _intersectOrigin = FindCenter(_innerIntersectionCurve.GetIndividualCurves());
            _relOrigin       = new Point3D(0, 0, _intersectOrigin.Z);

            return(true);
        }