//
// (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 Autodesk.Revit.DB;
namespace Revit.SDK.Samples.Reinforcement.CS
{
#region Struct Definition
///
/// a struct to store the geometry information of the rebar
///
public struct RebarGeometry
{
// Private members
Autodesk.Revit.DB.XYZ m_normal; // the direction of rebar distribution
IList m_curves; //the profile of the rebar
int m_number; //the number of the rebar
double m_spacing; //the spacing of the rebar
///
/// get and set the value of the normal
///
public Autodesk.Revit.DB.XYZ Normal
{
get
{
return m_normal;
}
set
{
m_normal = value;
}
}
///
/// get and set the value of curve array
///
public IList Curves
{
get
{
return m_curves;
}
set
{
m_curves = value;
}
}
///
/// get and set the number of the rebar
///
public int RebarNumber
{
get
{
return m_number;
}
set
{
m_number = value;
}
}
///
/// get and set the value of the rebar spacing
///
public double RebarSpacing
{
get
{
return m_spacing;
}
set
{
m_spacing = value;
}
}
///
/// consturctor
///
/// the normal information
/// the profile of the rebars
/// the number of the rebar
/// the number of the rebar
public RebarGeometry(Autodesk.Revit.DB.XYZ normal, IList curves, int number, double spacing)
{
// initialize the data members
m_normal = normal;
m_curves = curves;
m_number = number;
m_spacing = spacing;
}
}
///
/// A struct to store the const data which support beam reinforcement creation
///
public struct BeamRebarData
{
///
/// offset value of the top end rebar
///
public const double TopEndOffset = 0.2;
///
///offset value of the top center rebar
///
public const double TopCenterOffset = 0.23;
///
/// offset value of the transverse rebar
///
public const double TransverseOffset = 0.125;
///
/// offset value of the end transverse rebar
///
public const double TransverseEndOffset = 1.2;
///
/// the spacing value between end and center transvers rebar
///
public const double TransverseSpaceBetween = 1;
///
///offset value of bottom rebar
///
public const double BottomOffset = 0.271;
///
/// number of bottom rebar
///
public const int BottomRebarNumber = 5;
///
/// number of top rebar
///
public const int TopRebarNumber = 2;
}
///
/// A struct to store the const data which support column reinforcement creation
///
public struct ColumnRebarData
{
///
/// offset value of transverse rebar
///
public const double TransverseOffset = 0.125;
///
/// offset value of vertical rebar
///
public const double VerticalOffset = 0.234;
}
#endregion
#region Enum Definition
///
/// Indicate location of top rebar
///
public enum TopRebarLocation
{
///
/// locate start
///
Start,
///
/// locate center
///
Center,
///
/// locate end
///
End
}
///
/// Indicate location of transverse rebar
///
public enum TransverseRebarLocation
{
///
/// locate start
///
Start,
///
/// locate center
///
Center,
///
/// locate end
///
End
}
///
/// Indicate location of vertical rebar
///
public enum VerticalRebarLocation
{
///
/// locate north
///
North,
///
/// locate east
///
East,
///
/// locate south
///
South,
///
/// locate west
///
West
}
#endregion
///
/// A comparer for XYZ, and give a method to sort all the Autodesk.Revit.DB.XYZ points in a array
///
public class XYZHeightComparer : IComparer
{
int IComparer.Compare(Autodesk.Revit.DB.XYZ first, Autodesk.Revit.DB.XYZ second)
{
// first compare z coordinate, then y coordinate, at last x coordinate
if (GeomUtil.IsEqual(first.Z, second.Z))
{
if (GeomUtil.IsEqual(first.Y, second.Y))
{
if (GeomUtil.IsEqual(first.X, second.X))
{
return 0;
}
return (first.X > second.X) ? 1 : -1;
}
return (first.Y > second.Y) ? 1 : -1;
}
return (first.Z > second.Z) ? 1 : -1;
}
}
}