private static ConditionResult VerifyCondition(List <object> objects, IsInBoundingBox bbc) { ConditionResult result = new ConditionResult() { Condition = bbc }; List <string> failInfo = new List <string>(); foreach (var obj in objects) { bool passed = false; IObject iObj = obj as IObject; if (iObj != null) { passed = BH.Engine.CIH.Query.IsContaining(bbc.BoundingBox, iObj, bbc.ContainmentRule); if (passed) { result.PassedObjects.Add(obj); } else { result.FailedObjects.Add(obj); failInfo.Add($"{(string.IsNullOrWhiteSpace(bbc.Clause) ? "" : bbc.Clause + " failed: ")}" + $"Object not in the specified Bounding Box."); } } else { result.FailedObjects.Add(obj); failInfo.Add($"Could not evaluate containment for an object of type `{obj.GetType().Name}`."); } result.Pattern.Add(passed); } result.FailInfo = failInfo; return(result); }
private static ConditionResult VerifyCondition(List <object> objects, ISpatialCondition cond) { // First apply filter to get relevant objects BoundingBox containingBox = null; Element0DCondition spec0D = cond as Element0DCondition; if (spec0D != null) { containingBox = Query.ElementBoundingBox(spec0D.ReferencePoint, spec0D.LocalXDimension, spec0D.LocalYDimension, spec0D.LocalZDimension); } Element1DCondition spec1D = cond as Element1DCondition; if (spec1D != null) { containingBox = Query.ElementBoundingBox(spec1D.ReferenceLine, spec1D.LocalYDimension, spec1D.LocalZDimension); } Element2DCondition spec2D = cond as Element2DCondition; if (spec2D != null) { containingBox = Query.ElementBoundingBox(spec2D.ReferenceElement, spec2D.LocalZDimension); } IsInBoundingBox bbc = cond as IsInBoundingBox; if (bbc != null) { containingBox = bbc.BoundingBox; } ConditionResult result = new ConditionResult() { Condition = cond }; List <string> info = new List <string>(); foreach (var obj in objects) { bool passed = false; IObject iObj = obj as IObject; if (iObj != null) { passed = BH.Engine.CIH.Query.IsContaining(containingBox, iObj); if (passed) { result.PassedObjects.Add(obj); } else { result.FailedObjects.Add(obj); info.Add($"Object was not {new IsInBoundingBox() { BoundingBox = containingBox }.ToString()}."); } } else { result.FailedObjects.Add(obj); info.Add($"Could not evaluate containment for an object of type `{obj.GetType().Name}`."); } result.Pattern.Add(passed); } result.FailInfo = info; return(result); }