// // (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.IO; using System.Runtime.Serialization; using Autodesk.Revit.DB; using Autodesk.Revit.DB.PointClouds; namespace Revit.SDK.Samples.CS.PointCloudEngine { /// /// An implementation for a non file-based point cloud. In this implementaiton, the location of the cells, including their colors and options, /// are hardcoded. /// public class PredefinedPointCloud : PointCloudAccessBase, IPointCloudAccess { #region Class Member Variables String m_identifier; #endregion #region Class Methods /// /// Constructs a new predefined point cloud access instance. /// /// The identifier of the point cloud. public PredefinedPointCloud(String identifier) { m_identifier = identifier; Setup(false); } /// /// Constructs a new predefined point cloud access instance. /// /// The identifier of the point cloud. /// True to use randomization for the point location and number, false otherwise. public PredefinedPointCloud(String identifier, bool randomizedPoints) { m_identifier = identifier; Setup(randomizedPoints); } /// /// Sets up the predefined point cloud. /// /// True to use randomization for the point location and number, false otherwise. private void Setup(bool randomizedPoints) { AddCell(new XYZ(0, 0, 0), new XYZ(0.5, 100, 10), 0x00CCCC, randomizedPoints); AddCell(new XYZ(0, 0, 0), new XYZ(50, 0.5, 10), 0x00CCCC, randomizedPoints); AddCell(new XYZ(49.5, 0, 0), new XYZ(50, 100, 10), 0x00CCCC, randomizedPoints); AddCell(new XYZ(0, 99.5, 0), new XYZ(50, 100, 10), 0x00CCCC, randomizedPoints); AddCell(new XYZ(10, 0, 0), new XYZ(14, 0.5, 7), 0xCC99CC, randomizedPoints); AddCell(new XYZ(30, 0, 3), new XYZ(33, 0.5, 8), 0xA0A0A0, randomizedPoints); AddCell(new XYZ(33, 0, 3), new XYZ(36, 0.5, 8), 0xA0A0A0, randomizedPoints); AddCell(new XYZ(0, 24, 3), new XYZ(0.5, 27, 8), 0xA0A0A0, randomizedPoints); AddCell(new XYZ(0, 27, 3), new XYZ(0.5, 30, 8), 0xA0A0A0, randomizedPoints); AddCell(new XYZ(0, 46, 0), new XYZ(0.5, 50, 7), 0xCC99CC, randomizedPoints); AddCell(new XYZ(0, 50, 0), new XYZ(0.5, 54, 7), 0xCC99CC, randomizedPoints); AddCell(new XYZ(0, 70, 3), new XYZ(0.5, 73, 8), 0xA0A0A0, randomizedPoints); AddCell(new XYZ(0, 73, 3), new XYZ(0.5, 76, 8), 0xA0A0A0, randomizedPoints); } #endregion #region IPointCloudAccess Members /// /// The implementation of IPointCloudAccess.GetName(). /// /// The name (the file name). public String GetName() { return "apipc: " + m_identifier; } /// /// The implementation of IPointCloudAccess.GetColorEncoding() /// /// The color encoding. public PointCloudColorEncoding GetColorEncoding() { return PointCloudColorEncoding.ABGR; } /// /// The implementation of IPointCloudAccess.CreatePointSetIterator(). /// /// The filter. /// The view id (unused). /// The new iterator. public IPointSetIterator CreatePointSetIterator(PointCloudFilter rFilter, ElementId viewId) { return new PointCloudAccessBase.PointCloudAccessBaseIterator(this, rFilter); } /// /// The implementation of IPointCloudAccess.CreatePointSetIterator(). /// /// The filter. /// The density. /// The view id (unused). /// The new iterator. public IPointSetIterator CreatePointSetIterator(PointCloudFilter rFilter, double density, ElementId viewId) { throw new NotImplementedException(); } /// /// The implementation of IPointCloudAccess.GetExtent(). /// /// The extents of the point cloud. public Outline GetExtent() { return GetOutline(); } /// /// The implementation of IPointCloudAccess.GetOffset(). /// /// This method is not used by Revit and will be removed in a later pre-release build. /// Zero. public XYZ GetOffset() { return XYZ.Zero; } /// /// The implementation of IPointCloudAccess.GetUnitsToFeetConversionFactor(). /// /// The scale. public double GetUnitsToFeetConversionFactor() { return GetScale(); } /// /// The implementation of IPointCloudAccess.ReadPoints(). /// /// The filter. /// The view id (unused). /// The point cloud buffer. /// The maximum number of points. /// The number of points read. public int ReadPoints(PointCloudFilter rFilter, ElementId viewId, IntPtr buffer, int nBufferSize) { int read = ReadSomePoints(rFilter, buffer, nBufferSize, 0); return read; } /// /// The implementation of IPointCloudAccess.Free(). /// public void Free() { } #endregion } }