예제 #1
0
        /// <summary>
        /// calculates the tansform to convert models to metres and centre on the most populated region, includes reference models
        /// </summary>
        /// <returns></returns>
        private XbimMatrix3D GetGlobalModelTransform()
        {
            XbimRegion largest = _context.GetLargestRegion();

            XbimRect3D bb = XbimRect3D.Empty;

            if (largest != null)
            {
                bb = new XbimRect3D(largest.Centre, largest.Centre);
            }

            foreach (var refModel in _context.Model.ReferencedModels)
            {
                XbimRegion         r;
                Xbim3DModelContext refContext = new Xbim3DModelContext(refModel.Model);
                r = refContext.GetLargestRegion();
                if (r != null)
                {
                    if (bb.IsEmpty)
                    {
                        bb = new XbimRect3D(r.Centre, r.Centre);
                    }
                    else
                    {
                        bb.Union(r.Centre);
                    }
                }
            }
            XbimPoint3D p = bb.Centroid();
            var         modelTranslation = new XbimVector3D(-p.X, -p.Y, -p.Z);
            double      metreFactor      = 1.0 / _context.Model.ModelFactors.OneMetre;

            return(XbimMatrix3D.CreateTranslation(modelTranslation) * XbimMatrix3D.CreateScale(metreFactor));
        }
예제 #2
0
 public XbimModelPositioning(XbimModel model)
 {
     _model = model;
     Context = new Xbim3DModelContext(model);
     var supportLevel = model.GeometrySupportLevel;
   
     switch (supportLevel)
     {
         case 1:
             LargestRegion = GetLargestRegion(model);
             break;
         case 2:
             LargestRegion = Context.GetLargestRegion();
             break;
     }
 }
예제 #3
0
        private XbimPoint3D[] MinMaxPoints(XbimRegion rect, double oneMeter =  1.0)
        {
            var pMin = new XbimPoint3D(
                (rect.Centre.X - (rect.Size.X / 2)) / oneMeter,
                (rect.Centre.Y - (rect.Size.Y / 2)) / oneMeter,
                (rect.Centre.Z - (rect.Size.Z / 2)) / oneMeter
                );

            var pMax = new XbimPoint3D(
                (rect.Centre.X + (rect.Size.X / 2)) / oneMeter,
                (rect.Centre.Y + (rect.Size.Y / 2)) / oneMeter,
                (rect.Centre.Z + (rect.Size.Z / 2)) / oneMeter
                );

            return new[] { pMin, pMax };
        }