示例#1
0
        //--------------------------------------------------------------------------------------------------

        public static void UpdateFaceOrientation(TopoDS_Face face, Dir referenceDirection)
        {
            if (FaceAlgo.GetFaceCenterNormal(face).Direction.IsOpposite(referenceDirection, Maths.HalfPI))
            {
                face.Reverse();
            }
        }
        //--------------------------------------------------------------------------------------------------

        bool _FindParameters()
        {
            if (ReferenceFace == null)
            {
                Messages.Error("Reference face is not valid.");
                return(false);
            }

            // Get Opface
            var opFace = FaceAlgo.FindOppositeFace(SourceShape, ReferenceFace, farthest: true, FaceAlgo.FaceDistanceMethod.UseFacePlane);

            if (opFace == null)
            {
                Messages.Error("Reference face has no opposite face, so it seems that the shape has no thickness.");
                return(false);
            }

            if (_DebugOutput)
            {
                Messages.Trace($"Reference face index {SourceShape.Faces().IndexOf(ReferenceFace)}, " +
                               $"opposite face has index {SourceShape.Faces().IndexOf(opFace)}, " +
                               $"thickness is {SliceThickness}");
            }

            // Calc cutting plane
            if (!(FaceAlgo.GetCenteredPlaneFromFace(ReferenceFace, out var cutPlane) &&
                  FaceAlgo.GetCenteredPlaneFromFace(opFace, out var opPlane)))
            {
                Messages.Error("Cannot create cutting plane from reference or opposite face.");
                return(false);
            }

            SliceThickness = cutPlane.Distance(opPlane);
            SliceDirection = cutPlane.Axis.Direction.Reversed();
            _RefPlane      = new Pln(new Ax3(cutPlane.Location, SliceDirection));

            return(true);
        }