protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options) { base.setJSON(obj, host, options); if (!double.IsNaN(mTransparency)) { obj["Transparency"] = Transparency; } setJSON(DiffuseColour, "DiffuseColour", obj, this, options); setJSON(TransmissionColour, "TransmissionColour", obj, this, options); setJSON(DiffuseTransmissionColour, "DiffuseTransmissionColour", obj, this, options); setJSON(ReflectionColour, "ReflectionColour", obj, this, options); setJSON(SpecularColour, "SpecularColour", obj, this, options); if (SpecularHighlight != null) { BaseClassIfc baseClass = SpecularHighlight as BaseClassIfc; if (baseClass != null) { obj["SpecularHighlight"] = baseClass.getJson(this, options); } else { IfcValue value = SpecularHighlight as IfcValue; if (value != null) { obj["SpecularHighlight"] = DatabaseIfc.extract(value); } ; } } obj["ReflectanceMethod"] = ReflectanceMethod.ToString(); }
internal static JObject extract(IfcValue value) { JObject result = new JObject(); result[value.GetType().Name] = value.ValueString; return(result); }
internal override void ParseXml(XmlElement xml) { base.ParseXml(xml); foreach (XmlNode child in xml.ChildNodes) { string name = child.Name; if (string.Compare(name, "RowCells") == 0) { List <IfcValue> cells = new List <IfcValue>(); foreach (XmlNode node in child.ChildNodes) { IfcValue v = extractValue(child); if (v != null) { cells.Add(v); } } RowCells = cells; } } if (xml.HasAttribute("IsHeading")) { mIsHeading = bool.Parse(xml.Attributes["IsHeading"].Value); } }
internal static XmlNode convert(XmlDocument doc, IfcValue value, string name) { XmlElement element = doc.CreateElement(name); string keyword = value.GetType().Name; XmlElement v = doc.CreateElement(keyword + "-wrapper"); v.InnerText = value.Value.ToString(); element.AppendChild(v); return(element); }
protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options) { base.setJSON(obj, host, options); setAttribute(obj, "Name", Name); setAttribute(obj, "Description", Description); if (mAppliedValue != null) { IfcValue value = mAppliedValue as IfcValue; if (value != null) { obj["AppliedValue"] = DatabaseIfc.extract(value); } else { obj["AppliedValue"] = mAppliedValue.getJson(this, options); } } if (mUnitBasis > 0) { obj["UnitBasis"] = UnitBasis.getJson(this, options); } //todo setAttribute(obj, "Category", Category); setAttribute(obj, "Condition", Condition); if (mArithmeticOperator != IfcArithmeticOperatorEnum.NONE) { obj["ArithmeticOperator"] = ArithmeticOperator.ToString(); } if (mComponents.Count > 0) { obj["Components"] = new JArray(Components.ToList().ConvertAll(x => x.getJson(this, options))); } if (mHasExternalReference.Count > 0) { obj["HasExternalReference"] = new JArray(HasExternalReference.ToList().ConvertAll(x => x.getJson(this, options))); } if (mHasConstraintRelationships.Count > 0) { JArray array = new JArray(); foreach (IfcResourceConstraintRelationship r in HasConstraintRelationships) { if (r.mIndex != host.mIndex) { array.Add(r.getJson(this, options)); } } if (array.Count > 0) { obj["HasConstraintRelationships"] = array; } } }
internal static XmlNode convert(XmlDocument doc, IfcValue value, string name, string ifcnamespace) { string keyword = value.GetType().Name; XmlElement v = doc.CreateElement(keyword + "-wrapper", ifcnamespace); v.InnerText = value.ValueString; if (string.IsNullOrEmpty(name)) { return(v); } XmlElement element = doc.CreateElement(name, ifcnamespace); element.AppendChild(v); return(element); }
protected override void setJSON(JObject obj, BaseClassIfc host, HashSet <int> processed) { base.setJSON(obj, host, processed); IfcValue value = mValueComponent; if (value != null) { obj["ValueComponent"] = DatabaseIfc.extract(value); } IfcUnit unit = UnitComponent; if (unit != null) { obj["UnitComponent"] = mDatabase[mUnitComponent].getJson(this, processed); } }
protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options) { base.setJSON(obj, host, options); IfcValue value = NominalValue; if (value != null) { obj["NominalValue"] = DatabaseIfc.extract(value); } IfcUnit unit = Unit; if (unit != null) { obj["Unit"] = unit.getJson(this, options); } }
protected override void setJSON(JObject obj, BaseClassIfc host, SetJsonOptions options) { base.setJSON(obj, host, options); IfcValue value = mValueComponent; if (value != null) { obj["ValueComponent"] = DatabaseIfc.extract(value); } IfcUnit unit = UnitComponent; if (unit != null) { obj["UnitComponent"] = mUnitComponent.getJson(this, options); } }
internal override void SetXML(XmlElement xml, BaseClassIfc host, Dictionary<string, XmlElement> processed) { base.SetXML(xml, host, processed); setAttribute(xml, "Name", Name); setAttribute(xml, "Description", Description); if(mAppliedValue != null && (host == null || host != mAppliedValue)) { IfcValue value = mAppliedValue as IfcValue; if(value != null) xml.AppendChild(convert(xml.OwnerDocument, value, "AppliedValue", mDatabase.mXmlNamespace)); else xml.AppendChild((mAppliedValue as BaseClassIfc).GetXML(xml.OwnerDocument, "AppliedValue", this, processed)); } if (mUnitBasis > 0) xml.AppendChild(UnitBasis.GetXML(xml.OwnerDocument, "UnitBasis", this, processed)); //todo setAttribute(xml, "Category", Category); setAttribute(xml, "Condition", Condition); if (mArithmeticOperator != IfcArithmeticOperatorEnum.NONE) xml.SetAttribute("ArithmeticOperator", mArithmeticOperator.ToString().ToLower()); if (mComponents.Count > 0) { XmlElement element = xml.OwnerDocument.CreateElement("Components", mDatabase.mXmlNamespace); xml.AppendChild(element); foreach (IfcAppliedValue v in Components) element.AppendChild(v.GetXML(xml.OwnerDocument, "", this, processed)); } if (mHasExternalReference.Count > 0) { XmlElement element = xml.OwnerDocument.CreateElement("HasExternalReference", mDatabase.mXmlNamespace); xml.AppendChild(element); foreach (IfcExternalReferenceRelationship r in HasExternalReference) element.AppendChild(r.GetXML(xml.OwnerDocument, "", this, processed)); } if (mHasConstraintRelationships.Count > 0) { XmlElement element = xml.OwnerDocument.CreateElement("HasConstraintRelationships", mDatabase.mXmlNamespace); foreach (IfcResourceConstraintRelationship r in HasConstraintRelationships) { if (r.mIndex != host.mIndex) element.AppendChild(r.GetXML(xml.OwnerDocument, "", this, processed)); } if (element.HasChildNodes) xml.AppendChild(element); } }
internal override void parse(string str, ref int pos, ReleaseVersion release, int len, ConcurrentDictionary <int, BaseClassIfc> dictionary) { TimeStamp = IfcDateTime.ParseSTEP(ParserSTEP.StripField(str, ref pos, len)); string s = ParserSTEP.StripField(str, ref pos, len); if (s != "$") { List <string> ss = ParserSTEP.SplitLineFields(s.Substring(1, s.Length - 2)); for (int icounter = 0; icounter < ss.Count; icounter++) { IfcValue v = ParserIfc.parseValue(ss[icounter]); if (v != null) { mListValues.Add(v); } } } }
protected override string BuildStringSTEP(ReleaseVersion release) { string result = base.BuildStringSTEP(release) + (mName == "$" ? ",$," : ",'" + mName + "',") + (mDescription == "$" ? "$," : "'" + mDescription + "',"); if (mAppliedValue == null) { result += "$"; } else { IfcValue val = mAppliedValue as IfcValue; if (val != null) { result += val.ToString(); } else { result += ParserSTEP.LinkToString((mAppliedValue as BaseClassIfc).StepId); } } result += "," + ParserSTEP.LinkToString(mUnitBasis) + ","; if (release < ReleaseVersion.IFC4) { return(result + (mSSApplicableDate == null ? ",$" : ",#" + mSSApplicableDate.Index) + (mSSFixedUntilDate == null ? ",$" : ",#" + mSSFixedUntilDate.Index)); } string str = "$"; if (mComponents.Count > 0) { result += IfcDate.STEPAttribute(mApplicableDate) + "," + IfcDate.STEPAttribute(mFixedUntilDate); str = "(" + ParserSTEP.LinkToString(mComponents[0]); for (int icounter = 1; icounter < mComponents.Count; icounter++) { str += "," + ParserSTEP.LinkToString(mComponents[icounter]); } str += ")"; } result += (mCategory == "$" ? ",$," : ",'" + mCategory + "',") + (mCondition == "$" ? "$," : "'" + mCondition + "',"); return(result + (mArithmeticOperator == IfcArithmeticOperatorEnum.NONE ? "$," : "." + mArithmeticOperator.ToString() + ".,") + str); }
internal override void ParseXml(XmlElement xml) { base.ParseXml(xml); foreach (XmlNode child in xml.ChildNodes) { string name = child.Name; if (string.Compare(name, "EnumerationValues") == 0) { foreach (XmlNode c in child.ChildNodes) { IfcValue val = extractValue(c); if (val != null) { mEnumerationValues.Add(val); } } } else if (string.Compare(name, "EnumerationReference") == 0) { EnumerationReference = mDatabase.ParseXml <IfcPropertyEnumeration>(child as XmlElement); } } }
internal override void ParseXml(XmlElement xml) { base.ParseXml(xml); Name = extractString(xml, "Name"); foreach (XmlNode child in xml.ChildNodes) { string name = child.Name; if (string.Compare(name, "EnumerationValues") == 0) { foreach (XmlNode node in child.ChildNodes) { IfcValue val = extractValue(node); if (val != null) { mEnumerationValues.Add(val); } } } else if (string.Compare(name, "Unit") == 0) { Unit = mDatabase.ParseXml <IfcUnit>(child as XmlElement); } } }
internal static bool TryGetDouble(IfcValue v, out double val) { IfcReal r = v as IfcReal; if (r != null) { val = r.mValue; return(true); } IfcInteger i = v as IfcInteger; if (i != null) { val = i.mValue; return(true); } IfcPositiveLengthMeasure plm = v as IfcPositiveLengthMeasure; if (plm != null) { val = plm.mValue; return(true); } IfcDynamicViscosityMeasure dvm = v as IfcDynamicViscosityMeasure; if (dvm != null) { val = dvm.mValue; return(true); } IfcMassDensityMeasure mdm = v as IfcMassDensityMeasure; if (mdm != null) { val = mdm.mValue; return(true); } IfcModulusOfElasticityMeasure mem = v as IfcModulusOfElasticityMeasure; if (mem != null) { val = mem.mValue; return(true); } IfcPositiveRatioMeasure prm = v as IfcPositiveRatioMeasure; if (prm != null) { val = prm.mValue; return(true); } IfcThermalExpansionCoefficientMeasure tec = v as IfcThermalExpansionCoefficientMeasure; if (tec != null) { val = tec.mValue; return(true); } val = 0; return(false); }
internal List <ValidationResult> validatePropertySetTemplate(IfcPropertySetTemplate propertySetTemplate) { List <ValidationResult> result = new List <ValidationResult>(); if (propertySetTemplate.IsApplicable(this)) { IfcPropertySet pset = FindPropertySet(propertySetTemplate.Name) as IfcPropertySet; if (pset == null) { result.Add(new ValidationResult("Missing Property Set " + propertySetTemplate.Name)); } else { foreach (var propertyTemplate in propertySetTemplate.HasPropertyTemplates.Values) { IfcSimplePropertyTemplate simplePropertyTemplate = propertyTemplate as IfcSimplePropertyTemplate; if (simplePropertyTemplate != null) { if (simplePropertyTemplate.TemplateType == IfcSimplePropertyTemplateTypeEnum.P_SINGLEVALUE) { IfcPropertySingleValue property = pset.FindProperty(propertyTemplate.Name) as IfcPropertySingleValue; if (property == null) { result.Add(new ValidationResult("Missing Property " + propertySetTemplate.Name + " : " + propertyTemplate.Name)); } else { IfcValue value = property.NominalValue; if (value == null) { result.Add(new ValidationResult("Missing Property Value " + propertySetTemplate.Name + " : " + propertyTemplate.Name)); } else { string valueString = value.ValueString; if (string.IsNullOrEmpty(valueString)) { result.Add(new ValidationResult("Missing Property Value " + propertySetTemplate.Name + " : " + propertyTemplate.Name)); } else { string primary = simplePropertyTemplate.PrimaryMeasureType; if (!string.IsNullOrEmpty(primary)) { string valueClass = value.StepClassName; if (string.Compare(valueClass, primary, true) != 0) { result.Add(new ValidationResult(" Unexpected value type " + valueClass + " for " + propertySetTemplate.Name + " : " + propertyTemplate.Name)); } } } } } } else { result.Add(new ValidationResult("!!! Unhandled PropertyTemplate " + propertyTemplate.ToString())); } } else { result.Add(new ValidationResult("!!! Unhandled PropertyTemplate " + propertyTemplate.ToString())); } } } } return(result); }