//
// (C) Copyright 2003-2013 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.Linq;
using System.Text;
using Autodesk.Revit.DB.ExtensibleStorage;
using Autodesk.Revit.DB;
using CodeCheckingConcreteExample.Utility;
namespace CodeCheckingConcreteExample.Main
{
///
/// Container for surface element results data
///
[Autodesk.Revit.DB.ExtensibleStorage.Framework.Attributes.Schema("ResultSurface", "37147943-1A9A-44E8-8BAC-20628BC26896")]
public class ResultSurfaceElement : Autodesk.Revit.DB.ExtensibleStorage.Framework.SchemaClass
{
///
/// Collection of values representing element results in raw format
///
[Autodesk.Revit.DB.ExtensibleStorage.Framework.Attributes.SchemaProperty(Unit = Autodesk.Revit.DB.UnitType.UT_Length, DisplayUnit = Autodesk.Revit.DB.DisplayUnitType.DUT_METERS)]
public List ValuesInPointsData { get; set; }
///
/// Information that the surface object is multilayer.
///
[Autodesk.Revit.DB.ExtensibleStorage.Framework.Attributes.SchemaProperty()]
public bool MultiLayer { get; set; }
///
/// Collection of layer thickness
///
[Autodesk.Revit.DB.ExtensibleStorage.Framework.Attributes.SchemaProperty(Unit = Autodesk.Revit.DB.UnitType.UT_Length, DisplayUnit = Autodesk.Revit.DB.DisplayUnitType.DUT_METERS)]
public List StructuralLayersThickness { get; set; }
///
/// Collection of layer materials name
///
[Autodesk.Revit.DB.ExtensibleStorage.Framework.Attributes.SchemaProperty()]
public List StructuralLayersMaterialName { get; set; }
///
/// Informationa about structural layers for multilayers object
///
/// List of names and thickness of structural layers
public List> GetStructuralLayers()
{
int numberOfLayers = StructuralLayersThickness.Count();
if (numberOfLayers != StructuralLayersMaterialName.Count())
throw new Exception("Invalid layers properties");
List> layers = new List>();
for (int layersId = 0; layersId < numberOfLayers; layersId++)
{
layers.Add(new Tuple(StructuralLayersMaterialName[layersId],StructuralLayersThickness[layersId]));
}
return layers;
}
///
/// Removing information about all structural layers
///
public void ClearStructuralLayers()
{
StructuralLayersThickness.Clear();
StructuralLayersMaterialName.Clear();
}
///
/// Adds new structural layer
///
/// Material name for layer
/// Thickness of layer
public void AddStructuralLayer(string materialName, double thickness)
{
StructuralLayersThickness.Add(thickness);
StructuralLayersMaterialName.Add(materialName);
}
///
/// Gets results in point formatted as a list of ResultInPointSurface elements
///
/// List of ResultInPointSurface
public List GetResultsInPointsCollection()
{
IEnumerable vType = Enum.GetValues(typeof(ResultTypeSurface)).OfType();
int numberOfValsInPoint = vType.Count(),
numberOfPoints = ValuesInPointsData.Count / numberOfValsInPoint;
List resultsInPoints = new List();
for (int ptId = 0; ptId < numberOfPoints; ptId++)
{
resultsInPoints.Add(new ResultInPointSurface(ValuesInPointsData.GetRange(ptId * numberOfValsInPoint, numberOfValsInPoint)));
}
return resultsInPoints;
}
///
/// Creates default ResultSurfaceElement
///
public ResultSurfaceElement()
{
ValuesInPointsData = new List();
StructuralLayersThickness = new List();
StructuralLayersMaterialName = new List();
MultiLayer = false;
}
}
}