// check object name and then layer path for all supported schemas private void ApplyNamingFilter() { for (int j = objsToBeFiltered.Count - 1; j >= 0; j--) { RhinoObject obj = objsToBeFiltered[j]; string objName = obj.Attributes.Name; string objPath = Doc.Layers[obj.Attributes.LayerIndex].FullPath; SupportedSchema foundSchema = SupportedSchema.none; foreach (SupportedSchema schema in Enum.GetValues(typeof(SupportedSchema))) { if (objName != null && objName.Contains(schema.ToString())) { foundSchema = schema; break; } } if (foundSchema == SupportedSchema.none) { foreach (SupportedSchema schema in Enum.GetValues(typeof(SupportedSchema))) { if (objPath.Contains(schema.ToString())) { foundSchema = schema; break; } } } if (foundSchema != SupportedSchema.none) { // add to filter dict and remove from filter list filterDictionary[foundSchema].Add(obj); objsToBeFiltered.RemoveAt(j); } } }
// check object name and then layer path for all supported schema strings private void ApplyNamingFilter(List <RhinoObject> objs, out List <RhinoObject> unfilteredObjs) { // create temp filter dictionary var filterDictionary = new Dictionary <SupportedSchema, List <RhinoObject> >(); foreach (SupportedSchema schema in Enum.GetValues(typeof(SupportedSchema))) { filterDictionary.Add(schema, new List <RhinoObject>()); } unfilteredObjs = objs; for (int j = unfilteredObjs.Count - 1; j >= 0; j--) { RhinoObject obj = unfilteredObjs[j]; string objName = obj.Attributes.Name; string objPath = Doc.Layers[obj.Attributes.LayerIndex].FullPath; SupportedSchema foundSchema = SupportedSchema.none; foreach (SupportedSchema schema in Enum.GetValues(typeof(SupportedSchema))) { if (objName != null && objName.Contains(schema.ToString())) { foundSchema = schema; break; } } if (foundSchema == SupportedSchema.none) { foreach (SupportedSchema schema in Enum.GetValues(typeof(SupportedSchema))) { if (objPath.Contains(schema.ToString())) { foundSchema = schema; break; } } } if (foundSchema != SupportedSchema.none) { // add to filter dict and remove from filter list filterDictionary[foundSchema].Add(obj); unfilteredObjs.RemoveAt(j); } } // process the filter dictionary and add all viable geom to the output dict foreach (SupportedSchema schema in filterDictionary.Keys) { foreach (RhinoObject obj in filterDictionary[schema]) { if (IsViableSchemaObject(schema, obj)) { SchemaDictionary[schema.ToString()].Add(obj); } } } }
private XmlSerializerNamespaces XmlSerializerNamespaces(SupportedSchema schema) { var ns = new XmlSerializerNamespaces(); ns.Add("", ""); var configs = _configuration.GetSection("App:XmlFile").Get <XmlFileConfiguration[]>(); var config = configs.SingleOrDefault(x => x.SupportedSchema == schema); if (config?.Namespaces == null) { return(ns); } foreach (var(key, value) in config.Namespaces) { ns.Add(key, value); } return(ns); }
private bool IsViableSchemaObject(SupportedSchema schema, RhinoObject obj) { switch (schema) { case SupportedSchema.Column: try // assumes non xy linear curve > 45 deg { Curve crv = obj.Geometry as Curve; // assumes this has already been filtered for linearity double angleRad = Vector3d.VectorAngle(crv.PointAtEnd - crv.PointAtStart, Vector3d.ZAxis); if (angleRad < Math.PI / 4) { return(true); } } catch { } break; case SupportedSchema.Beam: try // assumes xy linear curve of angle =< 45 deg { Curve crv = obj.Geometry as Curve; // assumes this has already been filtered for linearity double angleRad = Vector3d.VectorAngle(crv.PointAtEnd - crv.PointAtStart, Vector3d.ZAxis); if (angleRad >= Math.PI / 4) { return(true); } } catch { } break; case SupportedSchema.Floor: case SupportedSchema.Ceiling: case SupportedSchema.Roof: try // assumes xy planar single surface { Brep brp = obj.Geometry as Brep; // assumes this has already been filtered for single surface if (IsPlanar(brp.Surfaces.First(), out bool singleH, out bool singleV)) { if (singleH) { return(true); } } } catch { } break; case SupportedSchema.Wall: try // assumes z vertical planar single surface { Brep brp = obj.Geometry as Brep; // assumes this has already been filtered for single surface if (IsPlanar(brp.Surfaces.First(), out bool singleH, out bool singleV)) { if (singleV) { return(true); } } } catch { } break; case SupportedSchema.FaceWall: try { Brep brp = obj.Geometry as Brep; // assumes this has already been filtered for single surface return(true); } catch { } break; default: return(false); } return(false); }
private bool IsViableObject(SupportedSchema schema, RhinoObject obj) { switch (schema) { case SupportedSchema.Column: try // assumes non xy linear curve { Curve crv = obj.Geometry as Curve; if (crv.IsLinear()) { if (crv.PointAtStart.Z < crv.PointAtEnd.Z) { return(true); } } } catch { } break; case SupportedSchema.Beam: try // assumes xy linear curve { Curve crv = obj.Geometry as Curve; if (crv.IsLinear()) { if (crv.PointAtStart.Z == crv.PointAtEnd.Z) { return(true); } } } catch { } break; case SupportedSchema.Floor: case SupportedSchema.Ceiling: case SupportedSchema.Roof: try // assumes xy planar single surface { Brep brp = obj.Geometry as Brep; if (brp.Surfaces.Count > 1) { return(false); } if (IsPlanar(brp.Surfaces.First(), out bool singleH, out bool singleV)) { if (singleH) { return(true); } } } catch { } break; case SupportedSchema.Wall: try // assumes z vertical planar single surface { Brep brp = obj.Geometry as Brep; if (brp.Surfaces.Count > 1) { return(false); } if (IsPlanar(brp.Surfaces.First(), out bool singleH, out bool singleV)) { if (singleV) { return(true); } } } catch { } break; default: return(false); } return(false); }
public async Task <ActionResult <IReadOnlyCollection <ValidationMessage> > > Validate([FromQuery] SupportedSchema schema, [OpenApiFile] IFormFile file) { await using var stream = System.IO.File.Create(Path.GetTempFileName()); await file.CopyToAsync(stream); stream.Position = 0; var result = _reportService.Validate(schema, stream); return(Ok(result)); }
public IReadOnlyCollection <ValidationMessage> Validate(SupportedSchema schema, Stream file) { var schemaService = _schemaServices[schema]; return(schemaService.Validate(file)); }