Point
Namespace: Digi21.DigiNG.Entities
Assembly: Digi21.DigiNG
Read/write point: an insertion coordinate and a rotation.
public class Point : ReadOnlyPoint, IDesplazable
Inheritance: Object → Entity → ReadOnlyPoint → Point
Implements: IDesplazable and, through inheritance, ISnapable, IWindow3D, ICloneable and IDisposable.
A Point created using its constructors belongs to no drawing file (Owner is null) and can be modified. When added to a drawing file using IDrawingFile.Add, Owner becomes that file and the entity becomes read-only: set accessors and Offset methods throw InvalidOperationException. To modify a stored point, modify the copy returned by Clone.
A new Point has coordinate (0, 0, 0) and rotation 0, and its minimum and maximum coordinates (IWindow3D) have not been calculated: Valid is false, Xmin is null, and Width, Center, Color, Weight and FillColor throw InvalidOperationException. Assigning Coordinate or calling any Offset method recalculates minimum and maximum coordinates. Offset also recalculates those of each entity containing the point, such as the complex it belongs to.
Other members (codes, colors, attributes, Clone, Dispose…) are inherited from Entity and ReadOnlyPoint.
Constructors
| Member | Description |
|---|---|
Point(Code code) |
Creates a point with one code. |
Point(IEnumerable<Code> codes) |
Creates a point with multiple codes, in enumeration order. |
Properties
| Member | Description |
|---|---|
Point3D Coordinate { get; set; } |
Insertion coordinate. |
double Rotation { get; set; } |
Symbol rotation, in degrees, counterclockwise from the X axis. |
Methods
| Member | Description |
|---|---|
void Offset(Point2D offset) |
Adds offset.X and offset.Y to the coordinate. Z is unchanged. |
void Offset(Point3D offset) |
Adds offset to the coordinate. |
void Offset(double x, double y) |
Adds x and y to the coordinate. Z is unchanged. |
void Offset(double x, double y, double z) |
Adds x, y and z to the coordinate. |
All four Offset methods throw InvalidOperationException if the point is read-only (ReadOnly is true).
Example
This program creates a point with rotation, stores it in a .bind file and stores a copy offset by 10 units in X:
using Digi21.DigiNG.Entities;
using Digi21.DigiNG.IO.BinDouble;
using Digi21.Math;
if (args.Length != 1)
{
Console.WriteLine("Uso: Puntos <salida.bind>");
return 1;
}
using var archivo = new BinDouble(args[0]);
var vértice = new Point(new Code("030101"))
{
Coordinate = new Point3D(450000.0, 4480000.0, 650.0),
Rotation = 45.0, // degrees
};
// Add returns the same instance as ReadOnlyPoint: from here on it is read-only.
ReadOnlyPoint guardado = archivo.Add(vértice);
Console.WriteLine($"{guardado.Coordinate} rotación {guardado.Rotation}°, ReadOnly = {guardado.ReadOnly}");
// To modify a stored point, work on a copy.
Point copia = guardado.Clone();
copia.Offset(10.0, 0.0);
archivo.Add(copia);
return 0;