/// <summary> /// Returns all chidren of this OSCADObject /// </summary> /// <param name="recursive">If true, returns all descendants. If false, returns only direct children.</param> /// <returns></returns> public IEnumerable <OSCADObject> Children(bool recursive = true) { if (recursive == false) { return(new List <OSCADObject>(this.m_children)); } // Initial children are reversed here because for objects with multiple children (such as boolean operations) // the natural collection order would yield opposite the expected order in a stack (first child would be the last popped) Stack <OSCADObject> toTraverse = new Stack <OSCADObject>(this.m_children.Reverse <OSCADObject>()); List <OSCADObject> allChildren = new List <OSCADObject>(); OSCADObject child = null; while (toTraverse.Count > 0) { child = toTraverse.Pop(); allChildren.Add(child); foreach (var subChild in child.m_children) { toTraverse.Push(subChild); } } return(allChildren); }
protected SingleStatementObject(OSCADObject obj) { this.obj = obj; this.m_children.Add(obj); obj.Parent = this; }
/// <summary> /// Creates a colorized object /// </summary> /// <param name="obj">The object(s) to which color will be applied</param> /// <param name="color">The string-wise name of the color to be applied</param> /// <param name="opacity">Opacity from 0.0 to 1.0 </param> internal ColoredObject(OSCADObject obj, string color = "Yellow", double opacity = 1.0) : base(obj) { this.ColorName = color; this.Opacity = opacity; }
internal TranslatedObject(OSCADObject obj) : base(obj) { }
/// <summary> /// Creates a translated object /// </summary> /// <param name="obj">Object(s) to translate</param> /// <param name="vector">Amount to translate by</param> internal TranslatedObject(OSCADObject obj, Vector3 vector) : base(obj) { this.Vector = vector; }
/// <summary> /// Creates a scaled object /// </summary> /// <param name="obj">Object(s) to be scaled</param> /// <param name="scale">Scale factor in x/y/z components</param> internal ScaledObject(OSCADObject obj, Vector3 scale) : base(obj) { this.ScaleFactor = scale; }
/// <summary> /// Indicates whether this OSCADObject is the same as another OSCADObject. /// This processes the scripts for both objects and is computationally expensive. /// DO NOT use on deeply nested structures. /// </summary> /// <param name="other">OSCADObject to compare to</param> /// <returns>True if scripts are exactly the same, false otherwise</returns> public bool IsSameAs(OSCADObject other) { return(this.ToString() == other.ToString()); }
private OSCADObject doBlockStatement(string name, OSCADObject[] objects, Func<IEnumerable<OSCADObject>, OSCADObject> factory) { if (objects == null || objects.Length < 1) { throw new ArgumentException(name + " requires at least one non-null entities"); } IEnumerable<OSCADObject> children = new List<OSCADObject>() { this }; children = children.Concat(objects); return factory(children); }
/// <summary> /// Creates an object that's mirrored on a plane /// </summary> /// <param name="obj">The object(s) to be mirrored</param> /// <param name="normal">The normal vector of the plane on the object's origin to mirror upon</param> internal MirroredObject(OSCADObject obj, Vector3 normal) : base(obj) { this.Normal = normal; }
/// <summary> /// Creates a resized object /// </summary> /// <param name="obj">The object(s) to be resized</param> /// <param name="size">The size to resize to, in terms of x/y/z dimensions</param> internal ResizedObject(OSCADObject obj, Vector3 size) : base(obj) { Size = size; }
internal ResizedObject(OSCADObject obj) : base(obj) { }
/// <summary> /// Indicates whether this OSCADObject is the same as another OSCADObject. /// This processes the scripts for both objects and is computationally expensive. /// DO NOT use on deeply nested structures. /// </summary> /// <param name="other">OSCADObject to compare to</param> /// <returns>True if scripts are exactly the same, false otherwise</returns> public bool IsSameAs(OSCADObject other) { return this.ToString() == other.ToString(); }
/// <summary> /// Creates an object with rotation applied /// </summary> /// <param name="obj">The object being rotated</param> /// <param name="angle">The angle to rotate</param> internal RotatedObject(OSCADObject obj, Vector3 angle) : base(obj) { this.Angle = angle; }