当前位置: 首页>>代码示例>>C#>>正文


C# BoundingBox.GetCorners方法代码示例

本文整理汇总了C#中Rhino.Geometry.BoundingBox.GetCorners方法的典型用法代码示例。如果您正苦于以下问题:C# BoundingBox.GetCorners方法的具体用法?C# BoundingBox.GetCorners怎么用?C# BoundingBox.GetCorners使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Rhino.Geometry.BoundingBox的用法示例。


在下文中一共展示了BoundingBox.GetCorners方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Contains

    /// <summary>
    /// Test a boundingbox for Box inclusion.
    /// </summary>
    /// <param name="box">Box to test.</param>
    /// <param name="strict">If true, the boundingbox needs to be fully on the inside of this Box. 
    /// I.e. coincident boxes will be considered 'outside'.</param>
    /// <returns>true if the box is (strictly) on the inside of this Box.</returns>
    public bool Contains(BoundingBox box, bool strict)
    {
      if (!box.IsValid) { return false; }

      Point3d[] c = box.GetCorners();
      for (int i = 0; i < c.Length; i++)
      {
        if (!Contains(c[i], strict)) { return false; }
      }
      return true;
    }
开发者ID:austinlaw,项目名称:rhinocommon,代码行数:18,代码来源:opennurbs_box.cs

示例2: DrawBoxCorners

    /// <summary>
    /// Draws corner widgets of a world aligned boundingbox. 
    /// </summary>
    /// <param name="box">Box to draw.</param>
    /// <param name="color">Color to draw with.</param>
    /// <param name="size">Size (in model units) of the corner widgets.</param>
    /// <param name="thickness">Thickness (in pixels) of the corner widgets.</param>
    public void DrawBoxCorners(BoundingBox box, System.Drawing.Color color, double size, int thickness)
    {
      if (!box.IsValid) { return; }

      // Size of box in all directions.
      double dx = box.m_max.m_x - box.m_min.m_x;
      double dy = box.m_max.m_y - box.m_min.m_y;
      double dz = box.m_max.m_z - box.m_min.m_z;

      // Singleton flags for all directions.
      bool fx = dx < 1e-6;
      bool fy = dy < 1e-6;
      bool fz = dz < 1e-6;

      // Singular box, don't draw.
      if (fx && fy && fz) { return; }

      // Linear box, don't draw.
      if (fx && fy) { return; }
      if (fx && fz) { return; }
      if (fy && fz) { return; }

      Point3d[] c = box.GetCorners();

      // Draw edges parallel to world Xaxis.
      if (dx > 1e-6)
      {
        if ((2.0 * size) >= dx)
        {
          // Draw single connecting wires.
          DrawLine(c[0], c[1], color, thickness);
          DrawLine(c[3], c[2], color, thickness);
          DrawLine(c[4], c[5], color, thickness);
          DrawLine(c[7], c[6], color, thickness);
        }
        else
        {
          // Draw corner widgets.
          DrawLine(c[0], new Point3d(c[0].m_x + size, c[0].m_y, c[0].m_z), color, thickness);
          DrawLine(c[3], new Point3d(c[3].m_x + size, c[3].m_y, c[3].m_z), color, thickness);
          DrawLine(c[4], new Point3d(c[4].m_x + size, c[4].m_y, c[4].m_z), color, thickness);
          DrawLine(c[7], new Point3d(c[7].m_x + size, c[7].m_y, c[7].m_z), color, thickness);
          DrawLine(c[1], new Point3d(c[1].m_x - size, c[1].m_y, c[1].m_z), color, thickness);
          DrawLine(c[2], new Point3d(c[2].m_x - size, c[2].m_y, c[2].m_z), color, thickness);
          DrawLine(c[5], new Point3d(c[5].m_x - size, c[5].m_y, c[5].m_z), color, thickness);
          DrawLine(c[6], new Point3d(c[6].m_x - size, c[6].m_y, c[6].m_z), color, thickness);
        }
      }

      // Draw edges parallel to world Yaxis.
      if (dy > 1e-6)
      {
        if ((2.0 * size) >= dy)
        {
          // Draw single connecting wires.
          DrawLine(c[0], c[3], color, thickness);
          DrawLine(c[1], c[2], color, thickness);
          DrawLine(c[4], c[7], color, thickness);
          DrawLine(c[5], c[6], color, thickness);
        }
        else
        {
          // Draw corner widgets.
          DrawLine(c[0], new Point3d(c[0].m_x, c[0].m_y + size, c[0].m_z), color, thickness);
          DrawLine(c[1], new Point3d(c[1].m_x, c[1].m_y + size, c[1].m_z), color, thickness);
          DrawLine(c[4], new Point3d(c[4].m_x, c[4].m_y + size, c[4].m_z), color, thickness);
          DrawLine(c[5], new Point3d(c[5].m_x, c[5].m_y + size, c[5].m_z), color, thickness);
          DrawLine(c[2], new Point3d(c[2].m_x, c[2].m_y - size, c[2].m_z), color, thickness);
          DrawLine(c[3], new Point3d(c[3].m_x, c[3].m_y - size, c[3].m_z), color, thickness);
          DrawLine(c[6], new Point3d(c[6].m_x, c[6].m_y - size, c[6].m_z), color, thickness);
          DrawLine(c[7], new Point3d(c[7].m_x, c[7].m_y - size, c[7].m_z), color, thickness);
        }
      }

      // Draw edges parallel to world Zaxis.
      if (dz > 1e-6)
      {
        if ((2.0 * size) >= dz)
        {
          // Draw single connecting wires.
          DrawLine(c[0], c[4], color, thickness);
          DrawLine(c[1], c[5], color, thickness);
          DrawLine(c[2], c[6], color, thickness);
          DrawLine(c[3], c[7], color, thickness);
        }
        else
        {
          // Draw corner widgets.
          DrawLine(c[0], new Point3d(c[0].m_x, c[0].m_y, c[0].m_z + size), color, thickness);
          DrawLine(c[1], new Point3d(c[1].m_x, c[1].m_y, c[1].m_z + size), color, thickness);
          DrawLine(c[2], new Point3d(c[2].m_x, c[2].m_y, c[2].m_z + size), color, thickness);
          DrawLine(c[3], new Point3d(c[3].m_x, c[3].m_y, c[3].m_z + size), color, thickness);
          DrawLine(c[4], new Point3d(c[4].m_x, c[4].m_y, c[4].m_z - size), color, thickness);
//.........这里部分代码省略.........
开发者ID:gwinsky,项目名称:rhinocommon,代码行数:101,代码来源:rhinosdkdisplaypipeline.cs

示例3: GetBoundingBoxNearFarHelper

        private static void GetBoundingBoxNearFarHelper(BoundingBox bbox, 
																										bool isPerspective, 
																										Rhino.Geometry.Point3d camLoc, 
																										Rhino.Geometry.Vector3d camZ, 
																										double box_near, 
																										double box_far)
        {
            double n = 0.005;
            double f = 1000.0;
            if (bbox.IsValid)
            {
                Rhino.Geometry.Point3d p = new Point3d(0,0,0);
                double d;
                bool bFirstPoint = true;
                int i,j,k;

                for ( i = 0; i < 2; i++ )
                {
                    p.X = bbox.GetCorners () [i].X;
                    for ( j = 0; j < 2; j++)
                    {
                        p.Y = bbox.GetCorners()[j].Y;
                        for ( k = 0; k < 2; k++)
                        {
                            p.Z = bbox.GetCorners()[k].Z;

                            d = (camLoc-p)*camZ;
                            if ( bFirstPoint )
                            {
                                n=d;
                                f=d;
                                bFirstPoint=false;
                            }
                            else
                            {
                                if (d < n)
                                    n = d;
                                else if (d > f)
                                    f = d;
                            }
                        }
                    }
                }
                // if n is invalid or f is invalid
                if ( double.IsNaN(n) || double.IsNaN(f) || f < n )
                {
                    n = 0.005;
                    f = 1000.0;
                } else 	{

                    // Bump things out just a bit so objects right on
                    // the edge of the bounding box do not land
                    // on the near/far plane.
                    if (isPerspective)
                    {
                        // perspective projection
                        if ( f <= 1.0e-12 )
                        {
                            // everything is behind camera
                            n = 0.005;
                            f = 1000.0;
                        }
                        else if ( n <= 0.0 )
                        {
                            // grow f and handle n later
                            f *= 1.01;
                        }
                        else if ( f <= n + 1.490116119385000000e-8 * n )
                        {
                            // 0 < n and f is nearly equal to n
                            n *= 0.675;
                            f *= 1.125;
                            if ( f < 1.0e-6 )
                                f = 1.0e-6;
                        }
                        else
                        {
                            n *= 0.99;
                            f *= 1.01;
                        }
                    }
                    else // parallel projection
                    {
                        // with a parallel projection, we just add a 5% buffer.
                        // The next step will move the camera back if n is negative.
                        d = 0.05*Math.Abs(f-n);
                        if ( d < 0.5 )
                            d = 0.5;
                        n -= d;
                        f += d;
                    }
                }
            }

            if (!double.IsNaN(box_near))
                box_near = n;
            if (!double.IsNaN(box_far))
                box_far = f;
        }
开发者ID:HovAvet,项目名称:RhinoMobile,代码行数:99,代码来源:ClippingPlanes.cs


注:本文中的Rhino.Geometry.BoundingBox.GetCorners方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。