Пример #1
0
        //----------------------------------------------------------------------------------

        protected void ProcessFace(Face face)
        {
            if (face.Points.Count < 3)
            {
                return;
            }

            Exocortex.Geometry3D.Sign sign = _plane.GetSign(face);
            //Debug.WriteLine( "plane.GetSign( face ) = " + sign.ToString() );
            switch (sign)
            {
            case Exocortex.Geometry3D.Sign.Negative:
                RecordNegativeFace(face);
                break;

            case Exocortex.Geometry3D.Sign.Zero:
                if (Vector3D.Dot(_plane.Normal, face.GetNormal()) > 0)
                {
                    RecordCoplanarFace(face);
                }
                else
                {
                    RecordNegativeFace(face);
                }
                break;

            case Exocortex.Geometry3D.Sign.Positive:
                RecordPositiveFace(face);
                break;

            case Exocortex.Geometry3D.Sign.Mixed:
                RecordCutFace(face);
                Face faceA = (Face)face.Clone();
                _plane.ClipPolygon(faceA);
                if (_plane.GetSign(faceA) != Exocortex.Geometry3D.Sign.Mixed)
                {
                    ProcessFace(faceA);
                }
                Face faceB = (Face)face.Clone();
                _plane.GetFlipped().ClipPolygon(faceB);
                if (_plane.GetSign(faceB) != Exocortex.Geometry3D.Sign.Mixed)
                {
                    ProcessFace(faceB);
                }
                break;

            default:
                Debug.Assert(false);
                break;
            }
        }