123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350 |
- using System;
- using System.Collections.Generic;
- using Autodesk.Revit.DB;
- using SAGA.RevitUtils.Extends;
- namespace SAGA.RevitUtils
- {
- public static class GlobalStaticData
- {
- public static object FormData = null;
- public static void Dispose()
- {
- if (FormData != null)
- {
- FormData = null;
- }
- }
- }
- [Flags]
- public enum XyzOptions : uint
- {
- X = 1,
- Y = 2,
- Z = 4,
- }
- public class XyzComparerOption : IComparer<XYZ>
- {
- private XyzOptions _whereToCompare;
- public XyzComparerOption(XyzOptions whereToCompare)
- {
- this._whereToCompare = whereToCompare;
- }
- public int Compare(XYZ pt1, XYZ pt2)
- {
- return pt1.CompareTo(pt2, _whereToCompare);
- }
- }
- public class XyzComparerX : IComparer<XYZ>
- {
- public int Compare(XYZ pt1, XYZ pt2)
- {
- return pt1.CompareTo(pt2, XyzOptions.X);
- }
- }
- public class XyzComparerY : IComparer<XYZ>
- {
- public int Compare(XYZ pt1, XYZ pt2)
- {
- return pt1.CompareTo(pt2, XyzOptions.Y);
- }
- }
- public class XyzComparerZ : IComparer<XYZ>
- {
- public int Compare(XYZ pt1, XYZ pt2)
- {
- return pt1.CompareTo(pt2, XyzOptions.Z);
- }
- }
- public enum DirectionEnum : uint
- {
- BottomTop = 6,
- BottomTopLeftRight = 7,
- BottomTopRightLeft = 8,
- LeftBottomRightTop = 12,
- LeftRight = 0,
- LeftRightBottomTop = 1,
- LeftRightTopBottom = 2,
- LeftTopRightBottom = 13,
- RightBottomLeftTop = 14,
- RightLeft = 3,
- RightLeftBottomTop = 4,
- RightLeftTopBottom = 5,
- RightTopLeftBottom = 15,
- TopBottom = 9,
- TopBottomLeftRight = 10,
- TopBottomRightLeft = 11
- }
-
- public class CurveXyzComparer : IComparer<XYZ>
- {
- private bool _start;
- private Curve _curve;
- public CurveXyzComparer(Curve curve, bool blnStart = true)
- {
- _curve = curve;
- _start = blnStart;
- }
- #region IComparer<XYZ> 成员
- int IComparer<XYZ>.Compare(XYZ first, XYZ second)
- {
- return first.CompareTo(second, _curve, _start);
- }
- #endregion
- }
- public class XyzEqualComparer : IEqualityComparer<XYZ>
- {
- private double _tolerance = 0;
- public XyzEqualComparer(double tolerance = 0)
- {
- _tolerance = tolerance;
- }
- public bool Equals(XYZ x, XYZ y)
- {
- return x.IsEqual(y, _tolerance);
- }
- public int GetHashCode(XYZ obj)
- {
- return 0;
- }
- }
- public class CurveEqualComparer : IEqualityComparer<Curve>
- {
- private readonly double _tolerance = 0;
- public CurveEqualComparer(double tolerance = 0)
- {
- _tolerance = tolerance;
- }
- bool IEqualityComparer<Curve>.Equals(Curve x, Curve y)
- {
- return x.IsEqual(y, _tolerance);
- }
- int IEqualityComparer<Curve>.GetHashCode(Curve obj)
- {
- return 0;
- }
- }
- public class CurveEqualComparer2 : IEqualityComparer<Curve>
- {
- private double _tolerance = 0;
- public CurveEqualComparer2(double tolerance = 0)
- {
- _tolerance = tolerance;
- }
- bool IEqualityComparer<Curve>.Equals(Curve x, Curve y)
- {
- return x.IsEqual2(y, _tolerance);
- }
- int IEqualityComparer<Curve>.GetHashCode(Curve obj)
- {
- return 0;
- }
- }
- /// <summary>
- /// Curve平行,比较器
- /// </summary>
- public class CurveParallelEqualComparer : IEqualityComparer<Curve>
- {
- private double _tolerance = 0;
- public CurveParallelEqualComparer(double tolerance = 0)
- {
- _tolerance = tolerance;
- }
- bool IEqualityComparer<Curve>.Equals(Curve x, Curve y)
- {
- return x.IsParallel(y, _tolerance);
- }
- int IEqualityComparer<Curve>.GetHashCode(Curve obj)
- {
- return 0;
- }
- }
- public class ElementEqualComparer : IEqualityComparer<Element>
- {
- bool IEqualityComparer<Element>.Equals(Element el1, Element el2)
- {
- return el1.Id.IntegerValue == el2.Id.IntegerValue;
- }
- int IEqualityComparer<Element>.GetHashCode(Element element)
- {
- return 0;
- }
- }
- public class WallEqualComparer : IEqualityComparer<Wall>
- {
- bool IEqualityComparer<Wall>.Equals(Wall x, Wall y)
- {
- return x.IsEqual(y);
- }
- int IEqualityComparer<Wall>.GetHashCode(Wall obj)
- {
- return 0;
- }
- }
- /// <summary>
- /// 轴网的排序类
- /// </summary>
- public class ComparerGrid : IComparer<Grid>
- {
- #region IComparer<Grid> 成员
- public int Compare(Grid x, Grid y)
- {
- int result = 0;
- if (x.Curve.StartPoint().Y == x.Curve.EndPoint().Y)
- {
- if (x.Curve.StartPoint().Y > y.Curve.StartPoint().Y)
- {
- result = 1;
- }
- else if (x.Curve.StartPoint().Y < y.Curve.StartPoint().Y)
- {
- result = -1;
- }
- }
- else
- {
- if (x.Curve.StartPoint().X > y.Curve.StartPoint().X)
- {
- result = 1;
- }
- else if (x.Curve.StartPoint().X < y.Curve.StartPoint().X)
- {
- result = -1;
- }
- }
- return result;
- }
- #endregion
- }
- public class CompareReference : IEqualityComparer<Reference>
- {
- #region IEqualityComparer<Reference> 成员
- public bool Equals(Reference x, Reference y)
- {
- if (x.ElementId.IntegerValue.Equals(y.ElementId.IntegerValue))
- return true;
- else
- return false;
- }
- public int GetHashCode(Reference obj)
- {
- return obj.ElementId.GetHashCode();
- }
- #endregion
- }
- /// <summary>
- /// 柱定位点相等比较(默认比较x值)
- /// </summary>
- public class ColumnLocationCompare : IComparer<FamilyInstance>
- {
- private XyzOptions _xyzOption = XyzOptions.X;
- public ColumnLocationCompare()
- {
- }
- public ColumnLocationCompare(XyzOptions xyzOption)
- {
- this._xyzOption = xyzOption;
- }
- public int Compare(FamilyInstance instance1, FamilyInstance instance2)
- {
- LocationPoint point1 = instance1.Location as LocationPoint;
- LocationPoint point2 = instance2.Location as LocationPoint;
- return point1.Point.CompareTo(point2.Point, _xyzOption);
- }
- }
- /// <summary>
- /// 梁比较器,判断梁线Z值是否相同
- /// </summary>
- public class CompareBeamZ : IComparer<FamilyInstance>
- {
- public int Compare(FamilyInstance instance1, FamilyInstance instance2)
- {
- LocationCurve locationCurve1 = instance1.Location as LocationCurve;
- LocationCurve locationCurve2 = instance2.Location as LocationCurve;
- return locationCurve1.Curve.StartPoint().Z.CompareTo(locationCurve2.Curve.StartPoint().Z);
- }
- }
- public class CurveCompare : IComparer<Curve>
- {
- public int Compare(Curve x, Curve y)
- {
- if (x.Length > y.Length)
- return 1;
- else if (x.Length < y.Length)
- return -1;
- else
- return 0;
- }
- }
- public class CategoryCompare : IComparer<Category>
- {
- public int Compare(Category cat1, Category cat2)
- {
- return cat1.Name.CompareTo(cat2.Name);
- }
- }
- public class ElementCompare : IComparer<Element>
- {
- public int Compare(Element ele1, Element ele2)
- {
- return ele1.Name.CompareTo(ele2.Name);
- }
- }
- public interface IAllowSendCmd
- {
- event EventHandler SelectChanged;
- }
- }
|