// // (C) Copyright 2003-2019 by Autodesk, Inc. // // Permission to use, copy, modify, and distribute this software in // object code form for any purpose and without fee is hereby granted, // provided that the above copyright notice appears in all copies and // that both that copyright notice and the limited warranty and // restricted rights notice below appear in all supporting // documentation. // // AUTODESK PROVIDES THIS PROGRAM "AS IS" AND WITH ALL FAULTS. // AUTODESK SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTY OF // MERCHANTABILITY OR FITNESS FOR A PARTICULAR USE. AUTODESK, INC. // DOES NOT WARRANT THAT THE OPERATION OF THE PROGRAM WILL BE // UNINTERRUPTED OR ERROR FREE. // // Use, duplication, or disclosure by the U.S. Government is subject to // restrictions set forth in FAR 52.227-19 (Commercial Computer // Software - Restricted Rights) and DFAR 252.227-7013(c)(1)(ii) // (Rights in Technical Data and Computer Software), as applicable. // using System; using System.Collections.Generic; using System.Text; using System.Drawing; using System.Collections.ObjectModel; using Autodesk.Revit.DB; namespace Revit.SDK.Samples.ObjectViewer.CS { /// /// data class for graphics 2D /// public class Graphics2DData { // curves represent the wireframe of the 2D geometry private readonly List m_curves = new List(); // the number of points consists of m_curves private readonly int m_numPoints; private static EmptyGraphics2DData m_empty = new EmptyGraphics2DData(); // boundingbox of the 2D geometry private RectangleF m_bbox = new RectangleF(0.0f, 0.0f, 1.0f, 1.0f); /// /// Represents a new instance of the Graphics2DData class with member data left uninitialized /// public static Graphics2DData Empty { get { return m_empty; } } /// /// Number of points consists of 2D geometry's wireframe /// public int NumPoints { get { return m_numPoints; } } /// /// BoundingBox of the 2D geometry /// public RectangleF BBox { get { return m_bbox; } } /// /// Curves represent the wireframe of the 2D geometry /// public List ConstCurves { get { return m_curves; } } /// /// only for Empty class /// protected Graphics2DData() { } /// /// constructor /// /// curves represent the wireframe of the 2D geometry public Graphics2DData(List> curves) { // initialize m_curves and m_bbox bool isFirst = true; // is the first List instance in curves foreach (List uvs in curves) { PointF[] pnts = new PointF[uvs.Count]; m_curves.Add(pnts); for (int i = 0; i < uvs.Count; i++) { Autodesk.Revit.DB.UV uv = uvs[i]; pnts[i] = new PointF((float)uv.U, (float)uv.V); RectangleF tmpBBox = new RectangleF(pnts[i], new SizeF(0.0f, 0.0f)); m_numPoints++; if (!isFirst) { // union the m_bbox with next curve's BBox m_bbox = RectangleF.Union(m_bbox, tmpBBox); } else { m_bbox = tmpBBox; isFirst = false; } } } } /// /// Represents a PointF class with member data left uninitialized /// class EmptyGraphics2DData : Graphics2DData { } } }