private TextHighliter ReportEntity(int EntityLabel, int RecursiveDepth = 0, int IndentationLevel = 0, bool Verbose = false) { // Debug.WriteLine("EL: " + EntityLabel.ToString()); TextHighliter sb = new TextHighliter(); string IndentationHeader = new String('\t', IndentationLevel); try { var entity = Model.Instances[EntityLabel]; if (entity != null) { IfcType ifcType = IfcMetaData.IfcType(entity); sb.Append( string.Format(IndentationHeader + "=== {0} [#{1}]", ifcType, EntityLabel.ToString()), Brushes.Blue ); var props = ifcType.IfcProperties.Values; if (props.Count > 0) sb.AppendFormat(IndentationHeader + "Properties: {0}", props.Count); foreach (var prop in props) { var PropLabels = ReportProp(sb, IndentationHeader, entity, prop, Verbose); foreach (var PropLabel in PropLabels) { if ( PropLabel != EntityLabel && (RecursiveDepth > 0 || RecursiveDepth < 0) && PropLabel != 0 ) { sb.Append(ReportEntity(PropLabel, RecursiveDepth - 1, IndentationLevel + 1)); } } } var Invs = ifcType.IfcInverses; if (Invs.Count > 0) sb.AppendFormat(IndentationHeader + "Inverses: {0}", Invs.Count); foreach (var inverse in Invs) { ReportProp(sb, IndentationHeader, entity, inverse, Verbose); } /* * suspended until more geomtery primitives are exposed. * if (entity is IfcProduct) { IfcProduct p = entity as IfcProduct; IXbimGeometryModel ret = XbimMesher.GenerateGeometry(Model, p); var factorCubicMetre = Math.Pow(Model.GetModelFactors.OneMetre, 3); sb.AppendFormat("XbimVolume: {0}\r\n", ret.Volume / factorCubicMetre); // looks for the product shape without subtractions/additions // XbimMesher.GenerateGeometry(model, foreach (var representation in p.Representation.Representations) { if (representation.RepresentationIdentifier == "Body") { IXbimGeometryModel uncut = XbimMesher.GenerateGeometry(Model, representation); if (uncut != null) sb.AppendFormat("XbimUncutVolume: {0}\r\n", uncut.Volume / factorCubicMetre); } } } */ } else { sb.AppendFormat(IndentationHeader + "=== Entity #{0} is null", EntityLabel); } } catch (Exception ex) { sb.AppendFormat(IndentationHeader + "\r\nException Thrown: {0} ({1})\r\n{2}", ex.Message, ex.GetType().ToString(), ex.StackTrace); } return sb; }
private TextHighliter ReportType(string type, int beVerbose, string indentationHeader = "") { var tarr = type.Split(new string[] { "." }, StringSplitOptions.RemoveEmptyEntries); type = tarr[tarr.Length - 1]; TextHighliter sb = new TextHighliter(); IfcType ot = IfcMetaData.IfcType(type.ToUpper()); if (ot != null) { sb.Append( string.Format(indentationHeader + "=== {0}", ot.Name), Brushes.Blue ); sb.AppendFormat(indentationHeader + "Namespace: {0}", ot.Type.Namespace); // sb.AppendFormat(indentationHeader + "Xbim Type Id: {0}", ot.TypeId); sb.DefaultBrush = Brushes.DarkOrange; List<string> supertypes = new List<string>(); var iterSuper = ot.IfcSuperType; while (iterSuper != null) { supertypes.Add(iterSuper.Name); iterSuper = iterSuper.IfcSuperType; } if (ot.IfcSuperType != null) sb.AppendFormat(indentationHeader + "Parents hierarchy: {0}", string.Join(" => ", supertypes.ToArray())); if (ot.IfcSubTypes.Count > 0) { if (beVerbose > 1) { sb.DefaultBrush = null; sb.AppendFormat(indentationHeader + "Subtypes tree:"); sb.DefaultBrush = Brushes.DarkOrange; ChildTree(ot, sb, indentationHeader, 0); } else { sb.DefaultBrush = null; sb.AppendFormat(indentationHeader + "Subtypes: {0}", ot.IfcSubTypes.Count); sb.DefaultBrush = Brushes.DarkOrange; foreach (var item in ot.IfcSubTypes) { sb.AppendFormat(indentationHeader + "- {0}", item); } } } if (beVerbose > 0) { if (beVerbose > 1) { var allSub = ot.NonAbstractSubTypes; sb.DefaultBrush = null; sb.AppendFormat(indentationHeader + "All non abstract subtypes: {0}", allSub.Count()); sb.DefaultBrush = Brushes.DarkOrange; foreach (var item in allSub) { sb.AppendFormat(indentationHeader + "- {0}", item.Name); } } sb.DefaultBrush = null; sb.AppendFormat(indentationHeader + "Interfaces: {0}", ot.Type.GetInterfaces().Count()); sb.DefaultBrush = Brushes.DarkOrange; foreach (var item in ot.Type.GetInterfaces()) { sb.AppendFormat(indentationHeader + "- {0}", item.Name); } sb.DefaultBrush = null; // sb.DefaultBrush = Brushes.DimGray; sb.AppendFormat(indentationHeader + "Properties: {0}", ot.IfcProperties.Count()); sb.DefaultBrush = null; Brush[] brushArray = new Brush[] { Brushes.DimGray, Brushes.DarkGray, Brushes.DimGray }; foreach (var item in ot.IfcProperties.Values) { var topParent = ot.IfcSuperType; string sTopParent = ""; while (topParent != null && topParent.IfcProperties.Where(x => x.Value.PropertyInfo.Name == item.PropertyInfo.Name).Count() > 0) { sTopParent = " \tfrom: " + topParent.ToString(); topParent = topParent.IfcSuperType; } sb.AppendSpans( new string[] { indentationHeader + "- " + item.PropertyInfo.Name + "\t\t", CleanPropertyName(item.PropertyInfo.PropertyType.FullName), sTopParent }, brushArray); // sb.AppendFormat(\t{1}{2}", , , ); } sb.AppendFormat(indentationHeader + "Inverses: {0}", ot.IfcInverses.Count()); foreach (var item in ot.IfcInverses) { var topParent = ot.IfcSuperType; string sTopParent = ""; while (topParent != null && topParent.IfcInverses.Where(x => x.PropertyInfo.Name == item.PropertyInfo.Name).Count() > 0) { sTopParent = " \tfrom: " + topParent.ToString(); topParent = topParent.IfcSuperType; } //sb.AppendFormat(indentationHeader + "- {0}\t{1}{2}", item.PropertyInfo.Name, CleanPropertyName(item.PropertyInfo.PropertyType.FullName), sTopParent); sb.AppendSpans( new string[] { indentationHeader + "- " + item.PropertyInfo.Name + "\t\t", CleanPropertyName(item.PropertyInfo.PropertyType.FullName), sTopParent }, brushArray); } } sb.DefaultBrush = null; sb.AppendFormat(""); } else { // test to see if it's a select type... Module ifcModule2 = typeof(IfcMaterialSelect).Module; var SelectType = ifcModule2.GetTypes().Where( t => t.Name.Contains(type) ).FirstOrDefault(); if (SelectType != null) { sb.AppendFormat("=== {0} is a Select type", type); Module ifcModule = typeof(IfcActor).Module; IEnumerable<Type> SelectSubTypes = ifcModule.GetTypes().Where( t => t.GetInterfaces().Contains(SelectType) ); // CommontIF sets up the infrastructure to check for common interfaces shared by the select type elements Type[] CommontIF = null; foreach (var item in SelectSubTypes) { if (CommontIF == null) CommontIF = item.GetInterfaces(); else { var chk = item.GetInterfaces(); for (int i = 0; i < CommontIF.Length; i++) { if (!chk.Contains(CommontIF[i])) { CommontIF[i] = null; } } } } Type[] ExistingIF = SelectType.GetInterfaces(); sb.AppendFormat(indentationHeader + "Interfaces: {0}", ExistingIF.Length); foreach (var item in ExistingIF) { sb.AppendFormat(indentationHeader + "- {0}", item.Name); } // need to remove implemented interfaces from the ones shared for (int i = 0; i < CommontIF.Length; i++) { if (CommontIF[i] == SelectType) CommontIF[i] = null; if (ExistingIF.Contains(CommontIF[i])) { CommontIF[i] = null; } } foreach (var item in CommontIF) { if (item != null) sb.AppendFormat(indentationHeader + "Missing Common Interface: {0}", item.Name); } if (beVerbose == 1) { foreach (var item in SelectSubTypes) { sb.Append(ReportType(item.Name, beVerbose, indentationHeader + " ")); } } sb.AppendFormat(""); } } return sb; }
private void DisplayHelp() { TextHighliter t = new TextHighliter(); t.AppendFormat("Commands:"); t.AppendFormat("- select [count|list|short] [transverse] [highlight] <startingElement> [Property [Property...]]"); t.Append(" <startingElement>: <EntityLabel, <EntityLabel>> or <ifcTypeName>", Brushes.Gray); t.Append(" [Property] is a Property or Inverse name", Brushes.Gray); t.Append(" [highlight] puts the returned set in the viewer selection", Brushes.Gray); t.AppendFormat("- EntityLabel label [recursion]"); t.Append(" [recursion] is an int representing the depth of children to report", Brushes.Gray); t.AppendFormat("- IfcSchema [list|count|short|full] <TypeName>"); t.Append(" <TypeName> can contain wildcards", Brushes.Gray); t.Append(" use / in <TypeName> to select all root types", Brushes.Gray); t.AppendFormat("- GeometryInfo [binary|viewer] <EntityLabel,<EntityLabel>>"); t.Append(" Provide textual information on meshes.", Brushes.Gray); t.AppendFormat("- Reload <EntityLabel,<EntityLabel>>"); t.Append(" <EntityLabel> filters the elements to load in the viewer.", Brushes.Gray); t.AppendFormat("- clip [off|<Elevation>|<px>, <py>, <pz>, <nx>, <ny>, <nz>|<Storey name>]"); t.Append(" Clipping the 3D model is still and unstable feature. Use with caution.", Brushes.Gray); t.AppendFormat("- zoom <Region name>"); t.Append(" 'zoom ?' provides a list of valid region names", Brushes.Gray); t.AppendFormat("- Visual [list|tree|[on|off <name>]|mode <ModeCommand>]"); t.Append(" 'Visual list' provides a list of valid layer names", Brushes.Gray); t.Append(" 'Visual tree' provides a tree layer structure", Brushes.Gray); t.Append(" 'Visual mode ...' changes the mode of the layer tree structure", Brushes.Gray); t.Append(" <ModeCommand> in: type, entity, oddeven or demo.", Brushes.Gray); t.AppendFormat("- clear [on|off]"); t.AppendFormat("- SelectionHighlighting [WholeMesh|Normals]"); t.Append(" defines the graphical style for selection highliting.", Brushes.Gray); t.AppendFormat("- SimplifyGUI"); t.Append(" opens a GUI for simplifying IFC files (useful for debugging purposes).", Brushes.Gray); t.AppendFormat(""); t.Append("Commands are executed on <ctrl>+<Enter>.", Brushes.Blue); t.AppendFormat("double slash (//) are the comments token and the remainder of lines is ignored."); t.AppendFormat("If a portion of text is selected, only selected text will be executed."); t.DropInto(txtOut.Document); }