Beispiel #1
0
        public override Snap.NX.Face GetChamferFace()
        {
            if (ChamferFace != null)
            {
                return(ChamferFace);
            }
            Snap.NX.Face result  = null;
            var          results = new List <Snap.NX.Face>();

            if (BaseFace != null)
            {
                var baseFOriention = new Snap.Orientation(BaseFace.GetFaceDirection());
                var v1             = Snap.Vector.Unit(baseFOriention.AxisX);
                var v2             = Snap.Vector.Unit(baseFOriention.AxisY);
                var v3             = Snap.Vector.Unit(v1 + v2);
                var v4             = v3.Copy(Snap.Geom.Transform.CreateRotation(new Snap.Position(), BaseFace.GetFaceDirection(), 90)).Unitize();

                var chamferFaces = ElecBody.Faces.Where(u => u.ObjectSubType == Snap.NX.ObjectTypes.SubType.FacePlane && Snap.Compute.Distance(u, BaseFace) < SnapEx.Helper.Tolerance).ToList();
                chamferFaces.ForEach(u =>
                {
                    var faceDir = u.GetFaceDirection();
                    if (SnapEx.Helper.Equals(v3, faceDir, SnapEx.Helper.Tolerance) ||
                        SnapEx.Helper.Equals(-v3, faceDir, SnapEx.Helper.Tolerance) ||
                        SnapEx.Helper.Equals(-v4, faceDir, SnapEx.Helper.Tolerance) ||
                        SnapEx.Helper.Equals(v4, faceDir, SnapEx.Helper.Tolerance)
                        )
                    {
                        results.Add(u);
                    }
                });
            }

            result = results.FirstOrDefault();

            if (results.Count > 1)
            {
                var baseFaceBoxUV = BaseFace.BoxUV;
                var elecBasePos   = BaseFace.Position((baseFaceBoxUV.MinU + baseFaceBoxUV.MaxU) / 2, (baseFaceBoxUV.MinV + baseFaceBoxUV.MaxV) / 2);

                var faceDirection = BaseFace.GetFaceDirection();
                var plane         = new Snap.Geom.Surface.Plane(elecBasePos, faceDirection);

                foreach (var u in results)
                {
                    var uv          = u.BoxUV;
                    var cneterPoint = u.Position((uv.MaxU + uv.MinU) / 2, (uv.MaxV + uv.MaxV) / 2);
                    var resullt     = Snap.Compute.ClosestPoints(cneterPoint, plane);
                    var dir         = Snap.Vector.Unit(resullt.Point1 - resullt.Point2);
                    if (SnapEx.Helper.Equals(dir, -faceDirection) && Snap.Compute.Distance(BaseFace, u) < SnapEx.Helper.Tolerance)
                    {
                        result = u;
                        break;
                    }
                }
            }

            ChamferFace = result;

            return(result);
        }
Beispiel #2
0
        public override Snap.NX.Face GetChamferFace()
        {
            Snap.NX.Face result  = null;
            var          results = new List <Snap.NX.Face>();

            if (BaseFace != null && DiagonalLine != null)
            {
                var boxUV  = BaseFace.BoxUV;
                var points = new List <Snap.Position>();
                points.Add(BaseFace.Position(boxUV.MinU, boxUV.MinV));
                points.Add(BaseFace.Position(boxUV.MinU, boxUV.MaxV));
                points.Add(BaseFace.Position(boxUV.MaxU, boxUV.MinV));
                points.Add(BaseFace.Position(boxUV.MaxU, boxUV.MaxV));

                points.RemoveAll(u => SnapEx.Helper.Equals(u, DiagonalLine.StartPoint, SnapEx.Helper.Tolerance));
                points.RemoveAll(u => SnapEx.Helper.Equals(u, DiagonalLine.EndPoint, SnapEx.Helper.Tolerance));
                var v1 = Snap.Vector.Unit(points.First() - DiagonalLine.StartPoint);
                var v2 = Snap.Vector.Unit(points.First() - DiagonalLine.EndPoint);
                var v3 = Snap.Vector.Unit(v1 + v2);
                var v4 = v3.Copy(Snap.Geom.Transform.CreateRotation(new Snap.Position(), BaseFace.GetFaceDirection(), 90)).Unitize();

                if (points.Count > 0)
                {
                    ElecBody.Faces.Where(u => u.ObjectSubType == Snap.NX.ObjectTypes.SubType.FacePlane).ToList().ForEach(u =>
                    {
                        var faceDir = u.GetFaceDirection();
                        if (SnapEx.Helper.Equals(v3, faceDir, SnapEx.Helper.Tolerance) ||
                            SnapEx.Helper.Equals(-v3, faceDir, SnapEx.Helper.Tolerance) ||
                            SnapEx.Helper.Equals(-v4, faceDir, SnapEx.Helper.Tolerance) ||
                            SnapEx.Helper.Equals(v4, faceDir, SnapEx.Helper.Tolerance)
                            )
                        {
                            results.Add(u);
                        }
                    });
                }
            }

            result = results.FirstOrDefault();

            if (results.Count > 1)
            {
                var baseFaceBoxUV = BaseFace.BoxUV;
                var elecBasePos   = BaseFace.Position((baseFaceBoxUV.MinU + baseFaceBoxUV.MaxU) / 2, (baseFaceBoxUV.MinV + baseFaceBoxUV.MaxV) / 2);

                var faceDirection = BaseFace.GetFaceDirection();
                var plane         = new Snap.Geom.Surface.Plane(elecBasePos, faceDirection);

                results.ForEach(u => {
                    var uv          = u.BoxUV;
                    var cneterPoint = u.Position((uv.MaxU + uv.MinU) / 2, (uv.MaxV + uv.MaxV) / 2);
                    var resullt     = Snap.Compute.ClosestPoints(cneterPoint, plane);
                    var dir         = Snap.Vector.Unit(resullt.Point1 - resullt.Point2);
                    if (SnapEx.Helper.Equals(dir, -faceDirection))
                    {
                        result = u;
                        return;
                    }
                });
            }

            ChamferFace = result;

            return(result);
        }
Beispiel #3
0
        public virtual Snap.Position GetElecBasePos()
        {
            var uv = BaseFace.BoxUV;

            return(BaseFace.Position((uv.MinU + uv.MaxU) / 2, (uv.MinV + uv.MaxV) / 2));
        }