コード例 #1
0
        public BoundingBox GetBoundingBox(bool accurate)
        {
#if RHINO_SDK
            RhinoObject parent_object = ParentRhinoObject();
#endif
            if (accurate)
            {
                BoundingBox bbox = new BoundingBox();
                Transform   xf   = new Transform();
#if RHINO_SDK
                // 3 July 2018 S. Baer (RH-46926)
                // When the object is non-const there is a good chance the geometry is
                // different than what is in the original parent object' geometry. Skip
                // using the parent's bbox getter when in this situation
                if (null != parent_object && !IsNonConst)
                {
                    IntPtr ptr_parent_rhinoobject = parent_object.ConstPointer();
                    if (UnsafeNativeMethods.CRhinoObject_GetTightBoundingBox(ptr_parent_rhinoobject, ref bbox, ref xf, false))
                    {
                        return(bbox);
                    }
                }
#endif
                AnnotationBase ann = this as AnnotationBase;
                if (ann != null)
                {
                    return(ann.InternalGetBoundingBox());
                }

                IntPtr ptr = ConstPointer();
                return(UnsafeNativeMethods.ON_Geometry_GetTightBoundingBox(ptr, ref bbox, ref xf, false) ? bbox : BoundingBox.Empty);
            }
            else
            {
                BoundingBox rc = new BoundingBox();
#if RHINO_SDK
                if (null != parent_object && !IsNonConst)
                {
                    IntPtr ptr_parent_rhinoobject = parent_object.ConstPointer();
                    if (UnsafeNativeMethods.CRhinoObject_BoundingBox(ptr_parent_rhinoobject, ref rc))
                    {
                        return(rc);
                    }
                }
#endif
                AnnotationBase ann = this as AnnotationBase;
                if (ann != null)
                {
                    return(ann.InternalGetBoundingBox());
                }

                IntPtr ptr = ConstPointer();
                UnsafeNativeMethods.ON_Geometry_BoundingBox(ptr, ref rc);
                return(rc);
            }
        }
コード例 #2
0
    internal static GeometryBase CreateGeometryHelper(IntPtr pGeometry, object parent, int subobject_index)
    {
      if (IntPtr.Zero == pGeometry)
        return null;

      int type = UnsafeNativeMethods.ON_Geometry_GetGeometryType(pGeometry);
      if (type < 0)
        return null;
      GeometryBase rc = null;

      switch (type)
      {
        case idxON_Curve: //1
          rc = new Curve(pGeometry, parent, subobject_index);
          break;
        case idxON_NurbsCurve: //2
          rc = new NurbsCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_PolyCurve: // 3
          rc = new PolyCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_PolylineCurve: //4
          rc = new PolylineCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_ArcCurve: //5
          rc = new ArcCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_LineCurve: //6
          rc = new LineCurve(pGeometry, parent, subobject_index);
          break;
        case idxON_Mesh: //7
          rc = new Mesh(pGeometry, parent);
          break;
        case idxON_Point: //8
          rc = new Point(pGeometry, parent);
          break;
        case idxON_TextDot: //9
          rc = new TextDot(pGeometry, parent);
          break;
        case idxON_Surface: //10
          rc = new Surface(pGeometry, parent);
          break;
        case idxON_Brep: //11
          rc = new Brep(pGeometry, parent);
          break;
        case idxON_NurbsSurface: //12
          rc = new NurbsSurface(pGeometry, parent);
          break;
        case idxON_RevSurface: //13
          rc = new RevSurface(pGeometry, parent);
          break;
        case idxON_PlaneSurface: //14
          rc = new PlaneSurface(pGeometry, parent);
          break;
        case idxON_ClippingPlaneSurface: //15
          rc = new ClippingPlaneSurface(pGeometry, parent);
          break;
        case idxON_Annotation2: // 16
          rc = new AnnotationBase(pGeometry, parent);
          break;
        case idxON_Hatch: // 17
          rc = new Hatch(pGeometry, parent);
          break;
        case idxON_TextEntity2: //18
          rc = new TextEntity(pGeometry, parent);
          break;
        case idxON_SumSurface: //19
          rc = new SumSurface(pGeometry, parent);
          break;
        case idxON_BrepFace: //20
          {
            int faceindex = -1;
            IntPtr pBrep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref faceindex);
            if (pBrep != IntPtr.Zero && faceindex >= 0)
            {
              Brep b = new Brep(pBrep, parent);
              rc = b.Faces[faceindex];
            }
          }
          break;
        case idxON_BrepEdge: // 21
          {
            int edgeindex = -1;
            IntPtr pBrep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref edgeindex);
            if (pBrep != IntPtr.Zero && edgeindex >= 0)
            {
              Brep b = new Brep(pBrep, parent);
              rc = b.Edges[edgeindex];
            }
          }
          break;
        case idxON_InstanceDefinition: // 22
          rc = new InstanceDefinitionGeometry(pGeometry, parent);
          break;
        case idxON_InstanceReference: // 23
          rc = new InstanceReferenceGeometry(pGeometry, parent);
          break;
#if USING_V5_SDK
        case idxON_Extrusion: //24
          rc = new Extrusion(pGeometry, parent);
          break;
#endif
        case idxON_LinearDimension2: //25
          rc = new LinearDimension(pGeometry, parent);
          break;
        case idxON_PointCloud: // 26
          rc = new PointCloud(pGeometry, parent);
          break;
        case idxON_DetailView: // 27
          rc = new DetailView(pGeometry, parent);
          break;
        case idxON_AngularDimension2: // 28
          rc = new AngularDimension(pGeometry, parent);
          break;
        case idxON_RadialDimension2: // 29
          rc = new RadialDimension(pGeometry, parent);
          break;
        case idxON_Leader: // 30
          rc = new Leader(pGeometry, parent);
          break;
        case idxON_OrdinateDimension2: // 31
          rc = new OrdinateDimension(pGeometry, parent);
          break;
        case idxON_Light: //32
          rc = new Light(pGeometry, parent);
          break;
        case idxON_PointGrid: //33
          rc = new Point3dGrid(pGeometry, parent);
          break;
        case idxON_MorphControl: //34
          rc = new MorphControl(pGeometry, parent);
          break;
        case idxON_BrepLoop: //35
          {
            int loopindex = -1;
            IntPtr pBrep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref loopindex);
            if (pBrep != IntPtr.Zero && loopindex >= 0)
            {
              Brep b = new Brep(pBrep, parent);
              rc = b.Loops[loopindex];
            }
          }
          break;
        case idxON_BrepTrim: // 36
          {
            int trimindex = -1;
            IntPtr pBrep = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref trimindex);
            if (pBrep != IntPtr.Zero && trimindex >= 0)
            {
              Brep b = new Brep(pBrep, parent);
              rc = b.Trims[trimindex];
            }
          }
          break;
        default:
          rc = new UnknownGeometry(pGeometry, parent, subobject_index);
          break;
      }

      return rc;
    }
コード例 #3
0
        internal static GeometryBase CreateGeometryHelper(IntPtr pGeometry, object parent, int subobject_index)
        {
            if (IntPtr.Zero == pGeometry)
            {
                return(null);
            }

            int type = UnsafeNativeMethods.ON_Geometry_GetGeometryType(pGeometry);

            if (type < 0)
            {
                return(null);
            }
            GeometryBase rc = null;

            switch (type)
            {
            case idxON_Curve: //1
                rc = new Curve(pGeometry, parent, subobject_index);
                break;

            case idxON_NurbsCurve: //2
                rc = new NurbsCurve(pGeometry, parent, subobject_index);
                break;

            case idxON_PolyCurve: // 3
                rc = new PolyCurve(pGeometry, parent, subobject_index);
                break;

            case idxON_PolylineCurve: //4
                rc = new PolylineCurve(pGeometry, parent, subobject_index);
                break;

            case idxON_ArcCurve: //5
                rc = new ArcCurve(pGeometry, parent, subobject_index);
                break;

            case idxON_LineCurve: //6
                rc = new LineCurve(pGeometry, parent, subobject_index);
                break;

            case idxON_Mesh: //7
                rc = new Mesh(pGeometry, parent);
                break;

            case idxON_Point: //8
                rc = new Point(pGeometry, parent);
                break;

            case idxON_TextDot: //9
                rc = new TextDot(pGeometry, parent);
                break;

            case idxON_Surface: //10
                rc = new Surface(pGeometry, parent);
                break;

            case idxON_Brep: //11
                rc = new Brep(pGeometry, parent);
                break;

            case idxON_NurbsSurface: //12
                rc = new NurbsSurface(pGeometry, parent);
                break;

            case idxON_RevSurface: //13
                rc = new RevSurface(pGeometry, parent);
                break;

            case idxON_PlaneSurface: //14
                rc = new PlaneSurface(pGeometry, parent);
                break;

            case idxON_ClippingPlaneSurface: //15
                rc = new ClippingPlaneSurface(pGeometry, parent);
                break;

            case idxON_Annotation2: // 16
                rc = new AnnotationBase(pGeometry, parent);
                break;

            case idxON_Hatch: // 17
                rc = new Hatch(pGeometry, parent);
                break;

            case idxON_TextEntity2: //18
                rc = new TextEntity(pGeometry, parent);
                break;

            case idxON_SumSurface: //19
                rc = new SumSurface(pGeometry, parent);
                break;

            case idxON_BrepFace: //20
            {
                int    faceindex = -1;
                IntPtr pBrep     = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref faceindex);
                if (pBrep != IntPtr.Zero && faceindex >= 0)
                {
                    Brep b = new Brep(pBrep, parent);
                    rc = b.Faces[faceindex];
                }
            }
            break;

            case idxON_BrepEdge: // 21
            {
                int    edgeindex = -1;
                IntPtr pBrep     = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref edgeindex);
                if (pBrep != IntPtr.Zero && edgeindex >= 0)
                {
                    Brep b = new Brep(pBrep, parent);
                    rc = b.Edges[edgeindex];
                }
            }
            break;

            case idxON_InstanceDefinition: // 22
                rc = new InstanceDefinitionGeometry(pGeometry, parent);
                break;

            case idxON_InstanceReference: // 23
                rc = new InstanceReferenceGeometry(pGeometry, parent);
                break;

#if USING_V5_SDK
            case idxON_Extrusion: //24
                rc = new Extrusion(pGeometry, parent);
                break;
#endif
            case idxON_LinearDimension2: //25
                rc = new LinearDimension(pGeometry, parent);
                break;

            case idxON_PointCloud: // 26
                rc = new PointCloud(pGeometry, parent);
                break;

            case idxON_DetailView: // 27
                rc = new DetailView(pGeometry, parent);
                break;

            case idxON_AngularDimension2: // 28
                rc = new AngularDimension(pGeometry, parent);
                break;

            case idxON_RadialDimension2: // 29
                rc = new RadialDimension(pGeometry, parent);
                break;

            case idxON_Leader: // 30
                rc = new Leader(pGeometry, parent);
                break;

            case idxON_OrdinateDimension2: // 31
                rc = new OrdinateDimension(pGeometry, parent);
                break;

            case idxON_Light: //32
                rc = new Light(pGeometry, parent);
                break;

            case idxON_PointGrid: //33
                rc = new Point3dGrid(pGeometry, parent);
                break;

            case idxON_MorphControl: //34
                rc = new MorphControl(pGeometry, parent);
                break;

            case idxON_BrepLoop: //35
            {
                int    loopindex = -1;
                IntPtr pBrep     = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref loopindex);
                if (pBrep != IntPtr.Zero && loopindex >= 0)
                {
                    Brep b = new Brep(pBrep, parent);
                    rc = b.Loops[loopindex];
                }
            }
            break;

            case idxON_BrepTrim: // 36
            {
                int    trimindex = -1;
                IntPtr pBrep     = UnsafeNativeMethods.ON_BrepSubItem_Brep(pGeometry, ref trimindex);
                if (pBrep != IntPtr.Zero && trimindex >= 0)
                {
                    Brep b = new Brep(pBrep, parent);
                    rc = b.Trims[trimindex];
                }
            }
            break;

            default:
                rc = new UnknownGeometry(pGeometry, parent, subobject_index);
                break;
            }

            return(rc);
        }
コード例 #4
0
 /// <summary>
 ///  Creates a Leader geometry object
 /// </summary>
 /// <param name="text"></param>
 /// <param name="plane"></param>
 /// <param name="dimstyle"></param>
 /// <param name="points"></param>
 /// <returns></returns>
 public static Leader Create(string text, Plane plane, DimensionStyle dimstyle, Point3d[] points)
 {
     return(CreateWithRichText(AnnotationBase.PlainTextToRtf(text), plane, dimstyle, points));
 }
コード例 #5
0
 /// <summary> Create Text geometry or null if input is invalid </summary>
 /// <param name="text"></param>
 /// <param name="plane"></param>
 /// <param name="style"></param>
 /// <param name="wrapped"></param>
 /// <param name="rectWidth"></param>
 /// <param name="rotationRadians"></param>
 /// <returns></returns>
 public static TextEntity Create(string text, Plane plane, DimensionStyle style, bool wrapped, double rectWidth, double rotationRadians)
 {
     return(CreateWithRichText(AnnotationBase.PlainTextToRtf(text), plane, style, wrapped, rectWidth,
                               rotationRadians));
 }