/// <summary> /// Clones the contextual picture by cloning the current one and adding only the last object of the configuration /// represented in the pictures. The last object must already be constructed in the underlying <see cref="Pictures"/>. /// Throws an <see cref="InconsistentPicturesException"/> if it cannot be done. /// </summary> /// <param name="newPictures">The pictures that should be used to construct the contextual picture.</param> /// <returns>The contextual picture containing this cloned picture.</returns> public ContextualPicture ConstructByCloning(PicturesOfConfiguration newPictures) { // Create an empty picture var newPicture = new ContextualPicture(newPictures, createEmpty: true); // We need to have geometric objects cloned // Thus we prepare a dictionary mapping old to newly created ones // To get all the geometric objects we take some map from the _objects var geometricObjectMap = _objects.First().Value.Select(pair => pair.Item1).Select(geometricObject => geometricObject switch { // Point PointObject point => (oldObject: geometricObject, newObject: new PointObject(point.ConfigurationObject) as GeometricObject), // Point LineObject line => (oldObject: geometricObject, newObject: new LineObject(line.ConfigurationObject)), // Circle CircleObject circle => (oldObject: geometricObject, newObject: new CircleObject(circle.ConfigurationObject)), // Unhandled cases _ => throw new ConstructorException($"Unhandled type of {nameof(GeometricObject)}: {geometricObject.GetType()}") })
/// <summary> /// Adds the points to the object. /// </summary> /// <param name="point">The point.</param> internal void AddPoint(PointObject point) => _points.Add(point);
/// <summary> /// Initializes a new instance of the <see cref="InconsistentIncidenceException"/> class. /// </summary> /// <param name="point">The point whose incidence wasn't determined consistently.</param> /// <param name="lineOrCircle">The line or circle where the point doesn't lie consistently.</param> public InconsistentIncidenceException(PointObject point, ConfigurationObject lineOrCircle) { Point = point ?? throw new ArgumentNullException(nameof(point)); LineOrCircle = lineOrCircle ?? throw new ArgumentNullException(nameof(lineOrCircle)); }
/// <summary> /// Initializes a new instance of the <see cref="InconsistentIncidenceException"/> class. /// </summary> /// <param name="point">The point whose incidence wasn't determined consistently.</param> /// <param name="geometricLineOrCircle">The geometric line or circle where the point doesn't lie consistently.</param> public InconsistentIncidenceException(PointObject point, DefinableByPoints geometricLineOrCircle) { Point = point ?? throw new ArgumentNullException(nameof(point)); GeometricLineOrCircle = geometricLineOrCircle ?? throw new ArgumentNullException(nameof(geometricLineOrCircle)); }