Exemplo n.º 1
0
        /// <summary>
        /// 添加板件
        /// </summary>
        /// <param name="body"></param>
        /// <returns></returns>
        public bool AddMoldBody(Body body, string name)
        {
            StepBuilder               builder;
            BodyCircleFeater          bf   = new BodyCircleFeater(body);
            Matrix4                   inv  = this.analysis.Matr.GetInversMatrix();
            CartesianCoordinateSystem csys = BoundingBoxUtils.CreateCoordinateSystem(this.analysis.Matr, inv);

            if (bf.IsCylinderBody(out builder))
            {
                return(false);
            }
            else
            {
                MoldBaseModel mold = new MoldBaseModel(body, this.analysis.Matr, csys);
                mold.Name = name;
                this.OtherBaseModel.Add(mold);
                return(true);
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取模板和圆柱形
        /// </summary>
        /// <returns></returns>
        public void GetBase(out List <MoldBaseModel> moldBase, out List <AbstractCylinderBody> cylinder)
        {
            moldBase = new List <MoldBaseModel>();
            cylinder = new List <AbstractCylinderBody>();

            foreach (Body by in workPart.Bodies)
            {
                MoldBaseModel mm = new MoldBaseModel(by, this.Matr, csys);
                if ((UMathUtils.IsEqual(mm.CenterPt.X, 0) && UMathUtils.IsEqual(mm.CenterPt.Y, 0)) &&
                    ((Math.Round(mm.DisPt.X, 4) >= Math.Round(AMoldBase.DisPt.X, 4) &&
                      Math.Round(mm.DisPt.Y, 4) >= Math.Round(AMoldBase.DisPt.Y, 4))))
                {
                    moldBase.Add(mm);
                }
                else
                {
                    StepBuilder builder;
                    if (mm.DisPt.Z > mm.DisPt.X && mm.DisPt.Z > mm.DisPt.Y)
                    {
                        BodyCircleFeater bf = new BodyCircleFeater(by);
                        if (bf.IsCylinderBody(out builder))
                        {
                            AbstractCylinderBody ab = CylinderBodyFactory.Create(builder);
                            if (ab != null)
                            {
                                double angle = UMathUtils.Angle(ab.Direction, this.Matr.GetZAxis());
                                if (UMathUtils.IsEqual(angle, 0) || UMathUtils.IsEqual(angle, Math.PI))
                                {
                                    cylinder.Add(ab);
                                }
                            }
                        }
                    }
                    else if ((UMathUtils.IsEqual(mm.CenterPt.X, 0) || UMathUtils.IsEqual(mm.CenterPt.Y, 0)) &&
                             ((Math.Round(mm.DisPt.X, 4) >= Math.Round(AMoldBase.DisPt.X, 4) ||
                               Math.Round(mm.DisPt.Y, 4) >= Math.Round(AMoldBase.DisPt.Y, 4))))
                    {
                        moldBase.Add(mm);
                    }
                }
            }
        }