Example #1
0
        /// <summary>
        /// 判断是否是一个孔
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public bool IsTheSameHole(AbstractCircleFace other)
        {
            double angle = UMathUtils.Angle(this.Data.Dir, other.Data.Dir);

            if (UMathUtils.IsEqual(angle, 0) == false && UMathUtils.IsEqual(angle, Math.PI) == false)
            {
                return(false);
            }
            Vector3d vec1 = new Vector3d();
            Vector3d vec2 = new Vector3d();

            if (UMathUtils.IsEqual(this.CenterPt, other.CenterPt))
            {
                vec1 = this.Data.Dir;
                vec2 = new Vector3d(-vec1.X, -vec1.Y, -vec1.Z);
            }
            else
            {
                vec1 = UMathUtils.GetVector(this.CenterPt, other.CenterPt);
                vec2 = UMathUtils.GetVector(other.CenterPt, this.CenterPt);
            }
            angle = UMathUtils.Angle(this.Data.Dir, vec1);
            if (UMathUtils.IsEqual(angle, 0) == false && UMathUtils.IsEqual(angle, Math.PI) == false)
            {
                return(false);
            }
            if (TraceARay.AskTraceARay(this.Data.Face.GetBody(), this.CenterPt, vec1) > 1 && TraceARay.AskTraceARay(other.Data.Face.GetBody(), other.CenterPt, vec2) > 1)

            {
                return(false);
            }
            return(true);
        }
 public override void SetDimForFace(ref LinearDimension ld, Vector3d vec)
 {
     foreach (Face face in this.ToolingBox.GetBodies()[0].GetFaces())
     {
         if (face.SolidFaceType == Face.FaceType.Cylindrical)
         {
             Point3d  originPt = new Point3d(0, 0, 0);
             Vector3d normal   = new Vector3d(0, 0, 0);
             FaceUtils.AskFaceOriginAndNormal(face, out originPt, out normal);
             double angle1 = UMathUtils.Angle(vec, new Vector3d(1, 1, 1));
             if (UMathUtils.IsEqual(angle1, 0))
             {
                 ld.HandleOrientation = normal;
                 ld.HandleOrigin      = originPt;
             }
         }
         else
         {
             FaceData fd   = FaceUtils.AskFaceData(face);
             Vector3d temp = fd.Dir;
             this.Matr.ApplyVec(ref temp);
             double angle = UMathUtils.Angle(vec, temp);
             if (UMathUtils.IsEqual(angle, 0))
             {
                 ld.HandleOrientation = fd.Dir;
                 ld.HandleOrigin      = fd.Point;
             }
         }
     }
 }
        /// <summary>
        /// 获取最低面
        /// </summary>
        /// <returns></returns>
        private void PullFaceForWave(List <Body> bodys)
        {
            foreach (Body body in bodys)
            {
                FaceData maxFace = null;
                double   zMin    = 9999;

                foreach (Face face in body.GetFaces())
                {
                    FaceData data   = FaceUtils.AskFaceData(face);
                    Point3d  center = UMathUtils.GetMiddle(data.BoxMaxCorner, data.BoxMinCorner);
                    if (zMin > center.Z)
                    {
                        zMin    = center.Z;
                        maxFace = data;
                    }
                }
                if (maxFace != null)
                {
                    double z = maxFace.BoxMaxCorner.Z + this.datum.EleHeight;
                    if (z > 0)
                    {
                        try
                        {
                            SynchronousUtils.CreatePullFace(new Vector3d(0, 0, -1), z, maxFace.Face);
                        }
                        catch
                        {
                        }
                    }
                }
            }
        }
Example #4
0
        private void GetDowBaseModel()
        {
            List <MoldBaseModel> down = analysis.GetDownModel(this.moldbase);

            if (down.Count > 0)
            {
                if (down[down.Count - 1].DisPt.Z * 2 <= 10 && down.Count != 1)
                {
                    down.RemoveAt(down.Count - 1);
                }
                if (UMathUtils.IsEqual(down[0].CenterPt.Z + down[0].DisPt.Z, this.BMoldBase.CenterPt.Z - this.BMoldBase.DisPt.Z) &&
                    UMathUtils.IsEqual(down[0].CenterPt.X, 0) && UMathUtils.IsEqual(down[0].CenterPt.Y, 0))
                {
                    this.SupportPlate      = down[0];
                    this.SupportPlate.Name = "托板";
                }
                if (down.Count > 1)
                {
                    this.Baseplate      = down[down.Count - 1];
                    this.Baseplate.Name = "底板";
                }

                MoldBaseModel kon = this.analysis.GetKnockoutPlate(this.moldbase);
                if (kon != null)
                {
                    this.PushPlate      = kon;
                    this.PushPlate.Name = "推板";
                }
                List <MoldBaseModel> spa = this.analysis.GetSpacer(down); //方铁
                if (spa.Count > 0)
                {
                    this.Spacer.AddRange(spa);
                    List <MoldBaseModel> eiec = this.analysis.GetEiectorPlates(this.moldbase, spa);
                    if (eiec.Count != 0)
                    {
                        double max = eiec.Max(a => a.CenterPt.Z);
                        foreach (MoldBaseModel mm in eiec)
                        {
                            if (UMathUtils.IsEqual(mm.CenterPt.Z, max))
                            {
                                mm.Name = "面针板";
                                FaceEiectorPlates.Add(mm);
                            }
                            else
                            {
                                mm.Name = "底针板";
                                DowEiectorPlates.Add(mm);
                            }
                        }
                    }
                }
            }
            foreach (MoldBaseModel mm in down) //无名板
            {
                if (mm.Name == null || mm.Name.Equals(""))
                {
                    this.OtherBaseModel.Add(mm);
                }
            }
        }
Example #5
0
        /// <summary>
        /// 获取内边界
        /// </summary>
        /// <returns></returns>
        public List <BoundaryModel> GetHoleBoundary()
        {
            FaceLoopUtils.LoopList[] list   = FaceLoopUtils.AskFaceLoops(face.Tag);
            List <BoundaryModel>     models = new List <BoundaryModel>();

            foreach (FaceLoopUtils.LoopList loop in list)
            {
                if (loop.Type == 2)
                {
                    BoundaryModel model = new BoundaryModel();
                    List <Edge>   edges = GetLoopToEdge(loop);
                    double        zMax  = GetLoopMaxOfZ(edges);
                    model.BouudaryPt = new Point3d(0, 0, zMax);
                    model.Edges      = edges;
                    model.Types      = NXOpen.CAM.BoundarySet.BoundaryTypes.Closed;
                    model.PlaneTypes = NXOpen.CAM.BoundarySet.PlaneTypes.UserDefined;
                    if (UMathUtils.IsEqual(zMax, faceData.BoxMaxCorner.Z))
                    {
                        model.ToolSide = NXOpen.CAM.BoundarySet.ToolSideTypes.InsideOrLeft;
                    }
                    else
                    {
                        model.ToolSide = NXOpen.CAM.BoundarySet.ToolSideTypes.OutsideOrRight;
                    }
                    models.Add(model);
                }
            }
            return(models);
        }
Example #6
0
        /// <summary>
        /// 设置拖拉预览
        /// </summary>
        /// <param name="ld"></param>
        private void SetDimFeatuer(LinearDimension ld, int row, ref double[] offset)
        {
            double temp = UMathUtils.GetDis(ld.HandleOrigin, superBox.CenterPt);     //判断拖拉是否超过边界

            if (Math.Abs(ld.Value) >= 2 * temp && ld.Value < 0)
            {
                return;
            }
            if (boolOffset.Value)
            {
                SetDimSame(ld.Value, ref offset);
                dimOffset.Value = ld.Value;
                negativeX.Value = ld.Value;
                negativeY.Value = ld.Value;
                negativeZ.Value = ld.Value;

                positiveX.Value = ld.Value;
                positiveX.Value = ld.Value;
                positiveZ.Value = ld.Value;
            }
            else
            {
                offset[row] = ld.Value;
            }
            superBox.Update(matr, offset);
        }
Example #7
0
        protected bool IsPassThrough(AbstractCylinderBody ab, double start, double end)
        {
            double  anlge   = UMathUtils.Angle(analysis.Matr.GetZAxis(), ab.Direction);
            Point3d startPt = ab.StratPt;
            Point3d endPt   = ab.EndPt;

            this.analysis.Matr.ApplyPos(ref startPt);
            this.analysis.Matr.ApplyPos(ref endPt);

            if (UMathUtils.IsEqual(anlge, 0))
            {
                if (startPt.Z > start && endPt.Z < end)
                {
                    return(true);
                }
            }
            if (UMathUtils.IsEqual(anlge, Math.PI))
            {
                if (startPt.Z < start && endPt.Z > end)
                {
                    return(true);
                }
            }
            return(false);
        }
        /// <summary>
        ///判断是否是导套
        /// </summary>
        /// <returns></returns>
        public bool IsGuidePin()
        {
            Face face = this.Builder.CylFeater[0].CylinderFace[0].Data.Face;

            FaceLoopUtils.LoopList[] loopList = FaceLoopUtils.AskFaceLoops(face.Tag);
            string   err = "";
            Vector3d vec = new Vector3d(-this.Direction.X, -this.Direction.Y, -this.Direction.Z);

            if (loopList.Length != 2)
            {
                return(false);
            }
            foreach (FaceLoopUtils.LoopList lt in loopList)
            {
                if (lt.Type == 2 && lt.EdgeList.Length == 1)
                {
                    Edge edge = NXObjectManager.Get(lt.EdgeList[0]) as Edge;
                    if (edge.SolidEdgeType == Edge.EdgeType.Circular)

                    {
                        ArcEdgeData data = EdgeUtils.GetArcData(edge, ref err);
                        if (data.Radius >= 8 && UMathUtils.IsEqual(data.Angle, Math.PI * 2))
                        {
                            int count1 = TraceARay.AskTraceARay(this.Body, data.Center, vec);
                            int count2 = TraceARay.AskTraceARay(this.Body, data.Center, this.Direction);
                            if (count1 == 0 && count2 == 0)
                            {
                                return(true);
                            }
                        }
                    }
                }
            }
            return(false);
        }
Example #9
0
        /// <summary>
        /// 判断设定值是否正确
        /// </summary>
        /// <param name="ele"></param>
        /// <returns></returns>
        private bool IsSetValueOk()
        {
            Point pt = null;

            foreach (Point k in this.eleModel.PartTag.Points.ToArray())
            {
                if (k.Name.ToUpper().Equals(("SetValuePoint").ToUpper()))
                {
                    pt = k;
                }
            }
            if (pt == null)
            {
                return(false);
            }
            Tag     ptOccsTag = theUFSession.Assem.FindOccurrence(this.eleModel.GetPartComp(workPart).Tag, pt.Tag);
            Point   ptOcc     = NXObjectManager.Get(ptOccsTag) as Point;
            Point3d value     = ptOcc.Coordinates;
            Point3d eleSet    = new Point3d(this.eleModel.EleInfo.EleSetValue[0], this.eleModel.EleInfo.EleSetValue[1], this.eleModel.EleInfo.EleSetValue[2]);

            this.work.WorkMatr.ApplyPos(ref value);
            if (UMathUtils.IsEqual(value, eleSet))
            {
                return(true);
            }
            return(false);
        }
        /// <summary>
        /// 检查放电面积
        /// </summary>
        /// <param name="csys"></param>
        /// <param name="eleCt"></param>
        private void AskSetVaule(CartesianCoordinateSystem csys, ElectrodeSetValueInfo setValue, Component eleCt, ref List <string> err)
        {
            Part    elePart  = eleCt.Prototype as Part;
            Point3d setPoint = new Point3d(setValue.EleSetValue[0], setValue.EleSetValue[1], setValue.EleSetValue[2]);
            Point   pt       = GetSetPoint(elePart);

            if (pt == null)
            {
                err.Add(elePart.Name + "-" + setValue.Positioning + "               无法找到设定点!");
            }
            else if (!UMathUtils.IsEqual(setPoint, GetSetWorkPoint3d(pt, eleCt)))
            {
                err.Add(elePart.Name + "-" + setValue.Positioning + "                   设定值错误!");
            }
            Body     eleBody = GetOccsInBods(eleCt);
            BodyInfo info    = GetDischargeFace(csys, eleBody);

            if (info != null)
            {
                double newArea = info.GetProjectedArea(csys, work.Info.Matr);
                if (setValue.ProjectedArea >= 2 * newArea)
                {
                    setValue.ProjectedArea = newArea;
                    setValue.ContactArea   = info.ContactArea;
                    setValue.SetAttribute(eleCt);
                }
            }
        }
        /// <summary>
        /// 创建外形点
        /// </summary>
        /// <param name="centerPt"></param>
        /// <param name="disPt"></param>
        /// <returns></returns>
        public List <NXObject> CreatePoint()
        {
            UFSession theUFSession = UFSession.GetUFSession();

            if (UMathUtils.IsEqual(this.DisPt.X, 0) && UMathUtils.IsEqual(this.DisPt.Y, 0) && UMathUtils.IsEqual(this.DisPt.Z, 0))
            {
                return(null);
            }
            double[]        x      = { CenterPt.X - DisPt.X, CenterPt.X, CenterPt.X + DisPt.X };
            double[]        y      = { CenterPt.Y - DisPt.Y, CenterPt.Y, CenterPt.Y + DisPt.Y };
            double[]        z      = { CenterPt.Z - DisPt.Z, CenterPt.Z, CenterPt.Z + DisPt.Z };
            Matrix4         mat    = new Matrix4();
            List <NXObject> points = new List <NXObject>();

            mat.Identity();
            for (int i = 0; i < 3; i++)
            {
                for (int j = 0; j < 3; j++)
                {
                    for (int k = 0; k < 3; k++)
                    {
                        Point3d temp = new Point3d(x[i], y[j], z[k]);
                        mat.ApplyPos(ref temp);
                        Tag pointTag = Tag.Null;
                        theUFSession.Curve.CreatePoint(new double[] { temp.X, temp.Y, temp.Z }, out pointTag);
                        theUFSession.Obj.SetColor(pointTag, 186);
                        points.Add(NXObjectManager.Get(pointTag) as NXObject);
                    }
                }
            }
            return(points);
        }
Example #12
0
        /// <summary>
        /// 设置颜色
        /// </summary>
        public void SetSlopeEqualColor()
        {
            foreach (AnalyzeFaceSlopeAndRadius ar in this.analyze)
            {
                if (UMathUtils.IsEqual(ar.MaxSlope, ar.MinSlope))
                {
                    if ((ar.MaxSlope < Math.Round(Math.PI / 2, 3) && ar.MaxSlope > 0) && ar.ResultsNum == 0)
                    {
                        SetColor(ar.face, 36);//斜度
                        continue;
                    }

                    if ((ar.MaxSlope == Math.Round(Math.PI / 2, 3)) && ar.ResultsNum == 0)
                    {
                        SetColor(ar.face, 211); //垂直
                        continue;
                    }
                    if ((UMathUtils.IsEqual(ar.MaxSlope, 0) || ar.MaxSlope == Math.Round(Math.PI, 3)) && ar.ResultsNum == 0)
                    {
                        SetColor(ar.face, 25); //平面
                        continue;
                    }
                }
                else if (!(ar.MaxSlope > Math.Round(Math.PI / 2, 3) && ar.MaxSlope <= Math.Round(Math.PI, 3)) && ar.ResultsNum > 0)
                {
                    SetColor(ar.face, 36);//斜度
                }
            }
        }
 public override void GetSlopeAndDia(Vector3d vec, out double[] slope, out double[] dia)
 {
     slope    = new double[2];
     dia      = new double[2];
     slope[0] = slope[1] = UMathUtils.Angle(vec, Data.Dir);
     dia[0]   = dia[1] = 0;
 }
Example #14
0
        /// <summary>
        /// 设置圆柱的属性点
        /// </summary>
        private void GetFacePoint()
        {
            Part      workPart = Session.GetSession().Parts.Work;
            Matrix3x3 mat3     = workPart.WCS.CoordinateSystem.Orientation.Element;
            Point3d   centerPt = new Point3d();
            Point3d   disPt    = new Point3d();
            Point3d   start    = new Point3d();
            Point3d   end      = new Point3d();
            Matrix4   inve     = this.Matr.GetInversMatrix();
            double    angleX   = UMathUtils.Angle(this.Direction, new Vector3d(mat3.Xx, mat3.Xy, mat3.Xz));
            double    angleY   = UMathUtils.Angle(this.Direction, new Vector3d(mat3.Yx, mat3.Yy, mat3.Yz));
            double    angleZ   = UMathUtils.Angle(this.Direction, new Vector3d(mat3.Zx, mat3.Zy, mat3.Zz));

            if ((UMathUtils.IsEqual(angleX, 0) || UMathUtils.IsEqual(angleX, Math.PI)) ||
                (UMathUtils.IsEqual(angleY, 0) || UMathUtils.IsEqual(angleY, Math.PI)) ||
                (UMathUtils.IsEqual(angleZ, 0) || UMathUtils.IsEqual(angleZ, Math.PI)))
            {
                this.GetCenterAndDisForData(out centerPt, out disPt);
            }
            else
            {
                this.GetFaceBoundingBox(out centerPt, out disPt);
            }
            start.Z = centerPt.Z - disPt.Z;
            end.Z   = centerPt.Z + disPt.Z;
            inve.ApplyPos(ref centerPt);
            inve.ApplyPos(ref start);
            inve.ApplyPos(ref end);
            this.CenterPt = centerPt;
            this.StartPt  = start;
            this.EndPt    = end;
            this.Length   = disPt.Z * 2;
        }
Example #15
0
        public override List <StandardPartsName> GetGuidePillar()
        {
            List <MoldBaseModel>        dowFace = this.FaceEiectorPlates.FindAll(a => a.CenterPt.Z < 0);
            List <MoldBaseModel>        dow     = this.DowEiectorPlates.FindAll(a => a.CenterPt.Z < 0);
            List <AbstractCylinderBody> pillars = new List <AbstractCylinderBody>();
            List <AbstractCylinderBody> pillar  = this.cylinderBody.FindAll(a => a.Radius >= 7 && a.IsGuidePillar());

            foreach (AbstractCylinderBody ab in pin)
            {
                AbstractCylinderBody pi = pillar.Find(a => UMathUtils.IsEqual(a.StratPt.X, ab.StratPt.X) && UMathUtils.IsEqual(a.StratPt.Y, ab.StratPt.Y));
                //if (!pillars.Exists(a => a.Equals(pi)))
                //{
                //    pillars.Add(pi);
                //}
                if (pi != null)
                {
                    pi.Name = "导柱";
                    pillars.Add(pi);
                    pillar.Remove(pi);
                }
            }
            if (this.SupportPlate != null && dowFace.Count != 0 && dow.Count != 0)
            {
                foreach (AbstractCylinderBody ab in pillar)
                {
                    Point3d start = ab.StratPt;
                    Point3d end   = ab.EndPt;
                    this.analysis.Matr.ApplyPos(ref start);
                    this.analysis.Matr.ApplyPos(ref end);
                    Vector3d vec = UMathUtils.GetVector(this.DowEiectorPlates[0].CenterPt, this.SupportPlate.CenterPt);
                    if (UMathUtils.IsEqual(UMathUtils.Angle(vec, ab.Direction), 0) &&
                        UMathUtils.IsEqual(start.Z, dow[0].CenterPt.Z + dow[0].DisPt.Z) &&
                        end.Z > this.SupportPlate.CenterPt.Z - this.SupportPlate.DisPt.Z)
                    {
                        ab.Name = "回针";
                        pillars.Add(ab);
                    }
                }
            }
            else if (this.SupportPlate == null && dowFace.Count != 0 && dow.Count != 0)
            {
                foreach (AbstractCylinderBody ab in pillar)
                {
                    Point3d start = ab.StratPt;
                    Point3d end   = ab.EndPt;
                    this.analysis.Matr.ApplyPos(ref start);
                    this.analysis.Matr.ApplyPos(ref end);
                    Vector3d vec = UMathUtils.GetVector(this.DowEiectorPlates[0].CenterPt, this.BMoldBase.CenterPt);
                    if (UMathUtils.IsEqual(UMathUtils.Angle(vec, ab.Direction), 0) &&
                        UMathUtils.IsEqual(start.Z, dow[0].CenterPt.Z + dow[0].DisPt.Z) &&
                        end.Z > this.BMoldBase.CenterPt.Z - this.BMoldBase.DisPt.Z)
                    {
                        ab.Name = "回针";
                        pillars.Add(ab);
                    }
                }
            }
            return(GetCyliderName(pillars));
        }
        protected override void GetDirection()
        {
            Point3d  pt1 = this.Builder.CylFeater[0].Cylinder.CenterPt;
            Point3d  pt2 = this.Builder.CylFeater[1].Cylinder.CenterPt;
            Vector3d vec = UMathUtils.GetVector(pt1, pt2);

            this.Direction = vec;
            this.Builder.SetDirection(vec);
        }
Example #17
0
 /// <summary>
 /// 分析面
 /// </summary>
 /// <param name="vec"></param>
 public void AnalyzeFace(Vector3d vec)
 {
     this.FaceData   = FaceUtils.AskFaceData(this.face);
     this.ResultsNum = TraceARay.AskTraceARayForFaceData(face, vec);
     this.Vec        = vec;
     if (this.face.SolidFaceType == Face.FaceType.Planar) //平面
     {
         this.MaxRadius = 0;
         this.MinRadius = 0;
         double angle = Math.Round(UMathUtils.Angle(vec, this.FaceData.Dir), 3);
         this.MaxSlope = angle;
         this.MinSlope = angle;
         return;
     }
     if (this.face.SolidFaceType == Face.FaceType.Cylindrical)
     {
         this.MaxRadius = Math.Round(this.FaceData.Radius, 3) * this.FaceData.IntNorm;
         this.MinRadius = Math.Round(this.FaceData.Radius, 3) * this.FaceData.IntNorm;
         AskFace(vec);
         return;
     }
     if (this.face.SolidFaceType == Face.FaceType.Conical)
     {
         this.MaxRadius = Math.Round(this.FaceData.Radius, 3) * this.FaceData.IntNorm;
         this.MinRadius = Math.Round(this.FaceData.RadData, 3) * this.FaceData.IntNorm;
         AskFace(vec);
         return;
     }
     else
     {
         double[] slope;
         double[] rad;
         FaceUtils.GetSweptSlope(this.face, vec, out slope, out rad);
         foreach (double temp in slope)
         {
             if (this.MaxSlope > temp)
             {
                 this.MaxSlope = Math.Round(temp, 3);
             }
             if (this.MinSlope < temp)
             {
                 this.MinSlope = Math.Round(temp, 3);
             }
         }
         foreach (double temp in rad)
         {
             if (this.MaxRadius > temp)
             {
                 this.MaxRadius = Math.Round(temp, 3);
             }
             if (this.MinRadius < temp)
             {
                 this.MinRadius = Math.Round(temp, 3);
             }
         }
     }
 }
Example #18
0
        /// <summary>
        /// 获取上模板
        /// </summary>
        protected override void GetUpBaseModel()
        {
            List <MoldBaseModel> up = analysis.GetUpModel(this.moldbase);

            if (up.Count > 0)
            {
                if (up[up.Count - 1].DisPt.Z <= 5 && up.Count != 1)
                {
                    up.RemoveAt(up.Count - 1);
                }
                if (up.Count == 1)
                {
                    this.UpBaseplate      = up[0];
                    this.UpBaseplate.Name = "水口板";
                }
                else
                {
                    if (UMathUtils.IsEqual(up[0].CenterPt.Z - up[0].DisPt.Z, this.AMoldBase.CenterPt.Z + this.AMoldBase.DisPt.Z))
                    {
                        this.ShuiSupportPlate      = up[0];
                        this.ShuiSupportPlate.Name = "水口推板";
                    }
                    this.UpBaseplate      = up[up.Count - 1];
                    this.UpBaseplate.Name = "水口板";
                }
                List <MoldBaseModel> spa = this.analysis.GetSpacer(up); //方铁
                if (spa.Count > 0)
                {
                    this.Spacer.AddRange(spa);
                    List <MoldBaseModel> eiec = this.analysis.GetEiectorPlates(this.moldbase, spa);
                    if (eiec.Count > 0)
                    {
                        double max = eiec.Max(a => a.CenterPt.Z);
                        foreach (MoldBaseModel mm in eiec)
                        {
                            if (UMathUtils.IsEqual(mm.CenterPt.Z, max))
                            {
                                mm.Name = "底针板";
                                DowEiectorPlates.Add(mm);
                            }
                            else
                            {
                                mm.Name = "面针板";
                                this.FaceEiectorPlates.Add(mm);
                            }
                        }
                    }
                }
            }
            foreach (MoldBaseModel mm in up) //无名板
            {
                if (mm.Name == null || mm.Name.Equals(""))
                {
                    this.OtherBaseModel.Add(mm);
                }
            }
        }
Example #19
0
 public override int FaceColour()
 {
     if (UMathUtils.IsEqual(analy.MaxSlope, 0) && UMathUtils.IsEqual(analy.MaxSlope, analy.MinSlope))
     {
         return(25);
     }
     else
     {
         return(base.NextColour());
     }
 }
Example #20
0
 /// <summary>
 /// 以向量排序
 /// </summary>
 /// <param name="dir"></param>
 private void CylinderFeaterSort(Vector3d dir)
 {
     this.CylFeater.Sort(delegate(CylinderFeater a, CylinderFeater b)
     {
         Point3d pt1 = UMathUtils.GetMiddle(a.StartPt, a.EndPt);
         Point3d pt2 = UMathUtils.GetMiddle(b.StartPt, b.EndPt);
         this.CylFeater[0].Cylinder.Matr.ApplyPos(ref pt1);
         this.CylFeater[0].Cylinder.Matr.ApplyPos(ref pt2);
         return(pt1.Z.CompareTo(pt2.Z));
     });
 }
Example #21
0
 public int CompareTo(BoundaryModel other)
 {
     if (!UMathUtils.IsEqual(this.CenterPt.X, other.CenterPt.X))
     {
         return(this.CenterPt.X.CompareTo(other.CenterPt.X));
     }
     else
     {
         return(this.CenterPt.Y.CompareTo(other.CenterPt.Y));
     }
 }
Example #22
0
 public int CompareTo(ElectrodeToolhClassify other)
 {
     if (UMathUtils.IsEqual(this.X, other.X))
     {
         return(this.Y.CompareTo(other.Y));
     }
     else
     {
         return(this.X.CompareTo(other.X));
     }
 }
Example #23
0
 public override string GetFaceType()
 {
     if (UMathUtils.IsEqual(analy.MaxSlope, 0) && UMathUtils.IsEqual(analy.MaxSlope, analy.MinSlope))
     {
         return("平面");
     }
     else
     {
         return(base.NextFacetype());
     }
 }
Example #24
0
 /// <summary>
 /// 基准面设定属性
 /// </summary>
 /// <param name="body"></param>
 private void SetDatumAttr(Body body)
 {
     foreach (Face fe in body.GetFaces())
     {
         FaceData data = FaceUtils.AskFaceData(fe);
         if (UMathUtils.IsEqual(data.BoxMinCorner.Z, data.BoxMaxCorner.Z) &&
             UMathUtils.IsEqual(data.BoxMinCorner.Z, this.sketch.LeiLine[0].StartPoint.Z))
         {
             AttributeUtils.AttributeOperation("DatumFace", "Datum", fe);
         }
     }
 }
Example #25
0
        /// <summary>
        /// 分析面
        /// </summary>
        /// <param name="face"></param>
        /// <param name="vec"></param>
        private void AnalyzeFace(Face face, Vector3d vec)
        {
            AnalyzeFaceSlopeAndRadius af = new AnalyzeFaceSlopeAndRadius(face);

            af.AnalyzeFace(vec);
            analyze.Add(af);
            if (Math.Abs(this.MinRadius) >= Math.Abs(af.MinRadius) && !UMathUtils.IsEqual(af.MinRadius, 0) &&
                UMathUtils.IsEqual(af.FaceData.IntNorm, -1))
            {
                this.MinRadius = af.MinRadius;
            }
        }
Example #26
0
        /// <summary>
        /// 获取边
        /// </summary>
        /// <param name="xEdge"></param>
        /// <param name="yEdge"></param>
        public void GetEdge(out List <Edge> xEdge, out Point centerCom)
        {
            xEdge     = new List <Edge>();
            centerCom = null;
            string         str = "";
            ElectrodeModel ele = null;

            foreach (ElectrodeModel em in eleModels)
            {
                if (em.Info.AllInfo.SetValue.Positioning == "" || em.Info.AllInfo.SetValue.Positioning.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                {
                    ele = em;
                }
            }
            if (ele == null)
            {
                return;
            }

            List <Face> faces = new List <Face>();

            faces.AddRange(ele.PartTag.Bodies.ToArray()[0].GetFaces());
            Point elePoint = ele.GetSetPoint();

            faces.Sort(delegate(Face a, Face b)
            {
                FaceData data1 = FaceUtils.AskFaceData(a);
                FaceData data2 = FaceUtils.AskFaceData(b);
                return(data1.Point.Z.CompareTo((data2.Point.Z)));
            });
            foreach (Component ct in AssmbliesUtils.GetPartComp(this.PartTag, ele.PartTag))
            {
                ElectrodeSetValueInfo value = ElectrodeSetValueInfo.GetAttribute(ct);
                if (value.Positioning == "" || value.Positioning.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                {
                    centerCom = AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, elePoint.Tag) as Point;
                    foreach (Edge eg in faces[10].GetEdges())
                    {
                        NXOpen.UF.UFEval.Line lineData;
                        if (EdgeUtils.GetLineData(eg, out lineData, ref str))
                        {
                            if (UMathUtils.IsEqual(lineData.start[1], lineData.end[1]))
                            {
                                xEdge.Add(AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, eg.Tag) as Edge);
                            }
                        }
                    }
                }
            }
        }
Example #27
0
        /// <summary>
        /// 获取垫脚
        /// </summary>
        /// <param name="molds"></param>
        /// <returns></returns>
        public List <MoldBaseModel> GetSpacer(List <MoldBaseModel> molds)
        {
            List <MoldBaseModel> spacer = new List <MoldBaseModel>();

            foreach (MoldBaseModel mm in molds)
            {
                if (!(UMathUtils.IsEqual(mm.CenterPt.X, 0) && UMathUtils.IsEqual(mm.CenterPt.Y, 0)))
                {
                    mm.Name = "方铁";
                    spacer.Add(mm);
                }
            }
            return(spacer);
        }
Example #28
0
        public int CompareTo(AnalyzeFaceSlopeAndRadius other)
        {
            CoordinateSystem wcs = workPart.WCS.CoordinateSystem;
            Matrix4          mat = new Matrix4();

            mat.Identity();
            mat.TransformToZAxis(wcs.Origin, this.Vec);
            Point3d centerPt1 = UMathUtils.GetMiddle(this.FaceData.BoxMinCorner, this.FaceData.BoxMaxCorner);
            Point3d centerPt2 = UMathUtils.GetMiddle(other.FaceData.BoxMinCorner, other.FaceData.BoxMaxCorner);

            mat.ApplyPos(ref centerPt1);
            mat.ApplyPos(ref centerPt2);
            return(centerPt2.Z.CompareTo(centerPt1.Z));
        }
        /// <summary>
        /// 以vec向量为Z向高低排序
        /// </summary>
        /// <param name="other"></param>
        /// <returns></returns>
        public int CompareTo(AnalysisFaceSlopeAndDia other)
        {
            Part             workPart = Session.GetSession().Parts.Work;
            CoordinateSystem wcs      = workPart.WCS.CoordinateSystem;
            Matrix4          mat      = new Matrix4();

            mat.Identity();
            mat.TransformToZAxis(wcs.Origin, this.vec);
            Point3d centerPt1 = UMathUtils.GetMiddle(this.Data.BoxMinCorner, this.Data.BoxMaxCorner);
            Point3d centerPt2 = UMathUtils.GetMiddle(other.Data.BoxMinCorner, other.Data.BoxMaxCorner);

            mat.ApplyPos(ref centerPt1);
            mat.ApplyPos(ref centerPt2);
            return(centerPt1.Z.CompareTo(centerPt2.Z));
        }
 public override void SetDimForFace(ref LinearDimension ld, Vector3d vec)
 {
     foreach (Face face in this.ToolingBox.GetBodies()[0].GetFaces())
     {
         FaceData fd   = FaceUtils.AskFaceData(face);
         Vector3d temp = fd.Dir;
         this.Matr.ApplyVec(ref temp);
         double angle = UMathUtils.Angle(vec, temp);
         if (UMathUtils.IsEqual(angle, 0))
         {
             ld.HandleOrientation = fd.Dir;
             ld.HandleOrigin      = fd.Point;
         }
     }
 }