//
// (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;
namespace Revit.SDK.Samples.CurtainWallGrid.CS
{
///
/// a linear line in 2D point format
///
public class Line2D
{
#region Fields
// the start point of the line
Point m_startPoint;
// the end point of the line
Point m_endPoint;
#endregion
#region Properties
///
/// the start point of the line
///
public Point StartPoint
{
get
{
return m_startPoint;
}
set
{
m_startPoint = value;
}
}
///
/// the end point of the line
///
public Point EndPoint
{
get
{
return m_endPoint;
}
set
{
m_endPoint = value;
}
}
#endregion
#region Constructors
///
/// default constructor
///
public Line2D()
{
m_startPoint = Point.Empty;
m_endPoint = Point.Empty;
}
///
/// constructor
///
///
/// the start point for the line
///
///
/// the end point for the line
///
public Line2D(Point startPoint, Point endPoint)
{
m_startPoint = startPoint;
m_endPoint = endPoint;
}
///
/// copy constructor
///
///
/// the line to be copied
///
public Line2D(Line2D line2D)
{
m_startPoint = line2D.StartPoint;
m_endPoint = line2D.EndPoint;
}
#endregion
}
///
/// the class stores the baseline data for curtain wall
///
public class WallBaseline2D : Line2D
{
#region Fields
// an assistant point for temp usage
Point m_assistantPoint;
#endregion
#region Properties
///
/// an assistant point for temp usage
///
public Point AssistantPoint
{
get
{
return m_assistantPoint;
}
set
{
m_assistantPoint = value;
}
}
#endregion
#region Constructors
///
/// default constructor
///
public WallBaseline2D()
: base()
{
m_assistantPoint = Point.Empty;
}
///
/// constructor
///
///
/// the start point for the line
///
///
/// the end point for the line
///
public WallBaseline2D(Point startPoint, Point endPoint)
: base(startPoint, endPoint)
{
m_assistantPoint = Point.Empty;
}
///
/// copy constructor
///
///
/// the line to be copied
///
public WallBaseline2D(WallBaseline2D wallLine2D)
: base((Line2D)wallLine2D)
{
m_assistantPoint = wallLine2D.AssistantPoint;
}
#endregion
#region Public methods
///
/// clear the stored data
///
public void Clear()
{
this.StartPoint = Point.Empty;
this.EndPoint = Point.Empty;
m_assistantPoint = Point.Empty;
}
#endregion
}
///
/// the 2D format for the curtain grid line, it inherits from the Line2D class
///
public class GridLine2D : Line2D
{
#region Fields
// indicate whether the grid line is locked
bool m_locked;
// all the segments for the grid line
List m_segments;
// indicate how many segments have been removed from the grid line
private int m_removedNumber;
// indicate whether it's a U grid line
private bool m_isUGridLine;
#endregion
#region Properties
///
/// indicate whether the grid line is locked
///
public bool Locked
{
get
{
return m_locked;
}
set
{
m_locked = value;
}
}
///
/// all the segments for the grid line
///
public List Segments
{
get
{
return m_segments;
}
}
///
/// indicate how many segments have been removed from the grid line
///
public int RemovedNumber
{
get
{
return m_removedNumber;
}
set
{
m_removedNumber = value;
}
}
///
/// indicate whether it's a U grid line
///
public bool IsUGridLine
{
get
{
return m_isUGridLine;
}
set
{
m_isUGridLine = value;
}
}
#endregion
#region Constructors
///
/// default constructor, initialize all the members with default value
///
public GridLine2D()
: base()
{
m_segments = new List();
m_locked = false;
m_removedNumber = 0;
m_isUGridLine = false;
}
///
/// constructor, initialize the grid line with end points
///
///
/// the start point of the curtain grid line 2D
///
///
/// the end point of the curtain grid line 2D
///
public GridLine2D(Point startPoint, Point endPoint)
: base(startPoint, endPoint)
{
m_segments = new List();
m_locked = false;
m_removedNumber = 0;
m_isUGridLine = false;
}
///
/// copy constructor, initialize the curtain grid line with another grid line 2D
///
///
/// the source line
///
public GridLine2D(GridLine2D gridLine2D)
: base((Line2D)gridLine2D)
{
m_segments = new List();
m_locked = gridLine2D.Locked;
m_removedNumber = gridLine2D.RemovedNumber;
m_isUGridLine = gridLine2D.IsUGridLine;
foreach (SegmentLine2D segLine in gridLine2D.Segments)
{
m_segments.Add(new SegmentLine2D(segLine));
}
}
#endregion
}
///
/// the line class for the segment of grid line, it inherits from Line2D class
///
public class SegmentLine2D : Line2D
{
#region Fields
// indicates whether the segment is "isolated"
bool m_isolated;
// indicate whether the segment has been removed from the grid line
bool m_removed;
// the index of the segment in the grid line
private int m_segmentIndex;
// the index of its parent grid line in all the curtain grid's U/V grid lines
private int m_gridLineIndex;
// indicates whether the segment is in a U grid line
private bool m_isUSegment;
#endregion
#region Properties
///
/// indicates whether the segment is "isolated"
///
public bool Isolated
{
get
{
return m_isolated;
}
set
{
m_isolated = value;
}
}
#endregion
#region
///
/// indicate whether the segment has been removed from the grid line
///
public bool Removed
{
get
{
return m_removed;
}
set
{
m_removed = value;
}
}
///
/// the index of the segment in the grid line
///
public int SegmentIndex
{
get
{
return m_segmentIndex;
}
set
{
m_segmentIndex = value;
}
}
///
/// the index of its parent grid line in all the curtain grid's U/V grid lines
///
public int GridLineIndex
{
get
{
return m_gridLineIndex;
}
set
{
m_gridLineIndex = value;
}
}
///
/// indicates whether the segment is in a U grid line
///
public bool IsUSegment
{
get
{
return m_isUSegment;
}
set
{
m_isUSegment = value;
}
}
#endregion
#region Constructors
///
/// default constructor
///
public SegmentLine2D()
: base()
{
m_removed = false;
m_isolated = false;
m_segmentIndex = -1;
m_gridLineIndex = -1;
}
///
/// constructor, initialize the segment with end points
///
///
/// the start point of the segment
///
///
/// the end point of the segment
///
public SegmentLine2D(Point startPoint, Point endPoint)
: base(startPoint, endPoint)
{
m_removed = false;
m_isolated = false;
m_segmentIndex = -1;
m_gridLineIndex = -1;
}
///
/// copy constructor
///
///
/// the source segment line 2D
///
public SegmentLine2D(SegmentLine2D segLine2D)
: base((Line2D)segLine2D)
{
m_removed = segLine2D.Removed;
m_isolated = segLine2D.Isolated;
m_segmentIndex = segLine2D.SegmentIndex;
m_gridLineIndex = segLine2D.GridLineIndex;
}
#endregion
}
}