Ejemplo n.º 1
0
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region Make

        protected override bool MakeInternal(MakeFlags flags)
        {
            var makeCylinder = ((SegmentAngle <= 0) || (SegmentAngle >= 360))
                ? new BRepPrimAPI_MakeCylinder(Radius, Height)
                : new BRepPrimAPI_MakeCylinder(Radius, Height, SegmentAngle.Clamp(0.001, 360.0).ToRad());

            BRep = makeCylinder.Solid();
            return(base.MakeInternal(flags));
        }
Ejemplo n.º 2
0
        //--------------------------------------------------------------------------------------------------

        #endregion

        #region Make

        protected override bool MakeInternal(MakeFlags flags)
        {
            double?segAngle = null;

            if (SegmentAngle > 0)
            {
                segAngle = SegmentAngle.Clamp(0, 360);
            }

            double?topAngle = null;

            if (MaxLatitude < 90)
            {
                topAngle = MaxLatitude.Clamp(-90, 90);
            }

            double?bottomAngle = null;

            if (MinLatitude > -90)
            {
                bottomAngle = MinLatitude.Clamp(-90, 90);
            }

            bool useLatitudeExtents = (topAngle.HasValue || bottomAngle.HasValue);

            if (useLatitudeExtents)
            {
                if (!topAngle.HasValue)
                {
                    topAngle = 90;
                }
                if (!bottomAngle.HasValue)
                {
                    bottomAngle = -90;
                }

                if (topAngle.Value <= bottomAngle.Value)
                {
                    return(false);
                }
            }

            BRepPrimAPI_MakeSphere makeSphere;

            if (segAngle.HasValue)
            {
                if (useLatitudeExtents)
                {
                    makeSphere = new BRepPrimAPI_MakeSphere(Radius, bottomAngle.Value.ToRad(), topAngle.Value.ToRad(), segAngle.Value.ToRad());
                }
                else
                {
                    makeSphere = new BRepPrimAPI_MakeSphere(Radius, segAngle.Value.ToRad());
                }
            }
            else
            {
                if (useLatitudeExtents)
                {
                    makeSphere = new BRepPrimAPI_MakeSphere(Radius, bottomAngle.Value.ToRad(), topAngle.Value.ToRad());
                }
                else
                {
                    makeSphere = new BRepPrimAPI_MakeSphere(Radius);
                }
            }
            BRep = makeSphere.Solid();
            return(base.MakeInternal(flags));
        }
Ejemplo n.º 3
0
        //--------------------------------------------------------------------------------------------------

        protected override bool MakeInternal(MakeFlags flags)
        {
            // Currently we work with 1 source shape only
            if (Operands.Count != 1)
            {
                Messages.Error("Revolve needs exactly one source shape.");
                HasErrors = true;
                return(false);
            }

            // We work with 2D shapes as source
            var faceShape = GetOperand2DFaces(0, null);

            if (faceShape == null)
            {
                return(false);
            }

            // If the shape is empty, just copy the source shape
            if (faceShape.Faces().Count == 0)
            {
                Messages.Error("The sketch does not contain any valid contours.");
                return(false);
            }

            // Get axis
            var axis = ComputeAxis();

            if (axis == null)
            {
                Messages.Error("The revolving axis cannot be computed.");
                return(false);
            }

            // Check segment
            if (_SegmentAngle == 0.0)
            {
                BRep = faceShape;
                return(true);
            }

            // Do it!
            var makePrism = ((_SegmentAngle <= -360) || (_SegmentAngle >= 360))
                ? new BRepPrimAPI_MakeRevol(faceShape, axis.Value, true)
                : new BRepPrimAPI_MakeRevol(faceShape, axis.Value, SegmentAngle.Clamp(-360.0, 360.0).ToRad(), true);

            if (!makePrism.IsDone())
            {
                Messages.Error("The revolving cannot be computed without errors around this axis with the given parameters.");
                return(false);
            }

            // Get final shape
            BRep = makePrism.Shape();

            // Check it
            var analyzer = new BRepCheck_Analyzer(BRep);

            if (!analyzer.IsValid())
            {
                Messages.Warning("The resulting solid is not valid and may cause problems in subsequent operations. Check input shape, parameters and axis.");
            }

            return(base.MakeInternal(flags));
        }