Beispiel #1
0
        protected override void OnPost(Model model, ModelViewModel viewModel)
        {
            base.OnPost(model, viewModel);
            if (viewModel.features != null)
            {
                var fList         = model.Features.ToList();
                var featuresCount = model.Features.Count;
                for (var i = 0; i < featuresCount; i++)
                {
                    var ff = fList[i];
                    model.Features.Remove(ff);
                }

                foreach (var f in viewModel.features)
                {
                    var fe = unitOfWork.Features.GetAll().ToList().Where(x => x.Id == f.Id).Single();
                    var fm = new ModelFeature()
                    {
                        ModelId   = model.Id,
                        FeatureId = fe.Id
                    };

                    model.Features.Add(fm);
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// 获取模型特征
 /// </summary>
 /// <param name="listTriangle"></param>
 /// <returns>中心点</returns>
 public static ModelFeature GetModelFeature(List <Triangle> listTriangle)
 {
     try
     {
         List <double> XCoordinate = new List <double>();
         List <double> YCoordinate = new List <double>();
         List <double> ZCoordinate = new List <double>();
         foreach (Triangle triangle in listTriangle)
         {
             XCoordinate.Add(triangle.P1.X);
             XCoordinate.Add(triangle.P2.X);
             XCoordinate.Add(triangle.P3.X);
             YCoordinate.Add(triangle.P1.Y);
             YCoordinate.Add(triangle.P2.Y);
             YCoordinate.Add(triangle.P3.Y);
             ZCoordinate.Add(triangle.P1.Z);
             ZCoordinate.Add(triangle.P2.Z);
             ZCoordinate.Add(triangle.P3.Z);
         }
         XCoordinate.Sort();
         YCoordinate.Sort();
         ZCoordinate.Sort();
         Point modelCenter = new Point((XCoordinate[0] + XCoordinate[XCoordinate.Count - 1]) / 2,
                                       (YCoordinate[0] + YCoordinate[YCoordinate.Count - 1]) / 2,
                                       (ZCoordinate[0] + ZCoordinate[ZCoordinate.Count - 1]) / 2);
         //获取模型X,Y,Z方向最大尺寸
         double       XMax         = XCoordinate[XCoordinate.Count - 1] - XCoordinate[0];
         double       YMax         = YCoordinate[YCoordinate.Count - 1] - XCoordinate[0];
         double       ZMax         = XCoordinate[ZCoordinate.Count - 1] - XCoordinate[0];
         double       modelScale   = (XMax > YMax) ? (XMax > ZMax ? XMax : ZMax) : (YMax > ZMax ? YMax : ZMax);
         ModelFeature modelFeature = new ModelFeature
         {
             modelCenter = modelCenter,
             modelScale  = modelScale
         };
         return(modelFeature);
     }
     catch (Exception e)
     {
         System.Windows.Forms.MessageBox.Show("警告!模型数据存在问题");
         return(new ModelFeature());
     }
 }