示例#1
0
        public AxisAlignedBox3f GetPrintMeshesBounds(bool bPrecise)
        {
            AxisAlignedBox3f b = AxisAlignedBox3f.Empty;

            foreach (PrintMeshSO so in PrintMeshes)
            {
                if (SceneUtil.IsVisible(so) == false)
                {
                    continue;
                }

                if (bPrecise)
                {
                    var xform = SceneTransforms.ObjectToSceneXForm(so);
                    foreach (Vector3d v in so.Mesh.Vertices())
                    {
                        b.Contain((Vector3f)xform.TransformP(v));
                    }
                }
                else
                {
                    Box3f sobox = so.GetBoundingBox(CoordSpace.SceneCoords);
                    if (sobox.Volume > 0)
                    {
                        foreach (Vector3d v in sobox.VerticesItr())
                        {
                            b.Contain(v);
                        }
                    }
                }
            }
            return(b);
        }
示例#2
0
        /// <summary>
        /// Compute AABB of scene in given space. Note that this will *not* be the same box
        /// in world space as in scene space.
        /// This computation ignores SOs with zero volume.
        /// </summary>
        public AxisAlignedBox3f GetBoundingBox(CoordSpace eSpace, bool bIncludeBoundsObjects)
        {
            if (eSpace == CoordSpace.ObjectCoords)
            {
                eSpace = CoordSpace.SceneCoords;
            }

            AxisAlignedBox3f b = AxisAlignedBox3f.Empty;

            foreach (SceneObject so in SceneObjects)
            {
                Box3f sobox = so.GetBoundingBox(eSpace);
                if (sobox.Volume > 0)
                {
                    foreach (Vector3d v in sobox.VerticesItr())
                    {
                        b.Contain(v);
                    }
                }
            }
            if (bIncludeBoundsObjects)
            {
                AxisAlignedBox3f sceneBounds =
                    UnityUtil.GetGeometryBoundingBox(BoundsObjects, true);
                if (sceneBounds.Volume > 0)
                {
                    if (eSpace == CoordSpace.WorldCoords)
                    {
                        for (int k = 0; k < 8; ++k)
                        {
                            b.Contain(ToWorldP(sceneBounds.Corner(k)));
                        }
                    }
                    else
                    {
                        b.Contain(sceneBounds);
                    }
                }
            }
            if (b.Volume == 0)
            {
                b = new AxisAlignedBox3f(1.0f);
            }
            return(b);
        }