internal override void parseJObject(JObject obj) { if (mDatabase.mContext == null) //this as IfcProjectLibrary == null || { mDatabase.mContext = this; } JToken token = obj.GetValue("ObjectType", StringComparison.InvariantCultureIgnoreCase); if (token != null) { ObjectType = token.Value <string>(); } token = obj.GetValue("LongName", StringComparison.InvariantCultureIgnoreCase); if (token != null) { LongName = token.Value <string>(); } token = obj.GetValue("Phase", StringComparison.InvariantCultureIgnoreCase); if (token != null) { Phase = token.Value <string>(); } mDatabase.extractJArray <IfcRelDefinesByProperties>(obj.GetValue("IsDefinedBy", StringComparison.InvariantCultureIgnoreCase) as JArray).ForEach(x => x.RelatedObjects.Add(this)); mDatabase.extractJArray <IfcRelDeclares>(obj.GetValue("Declares", StringComparison.InvariantCultureIgnoreCase) as JArray).ForEach(x => x.RelatingContext = this); RepresentationContexts.AddRange(mDatabase.extractJArray <IfcRepresentationContext>(obj.GetValue("RepresentationContexts", StringComparison.InvariantCultureIgnoreCase) as JArray)); UnitsInContext = mDatabase.ParseJObject <IfcUnitAssignment>(obj.GetValue("UnitsInContext", StringComparison.InvariantCultureIgnoreCase) as JObject); base.parseJObject(obj); }
/// <summary> /// Tests the express where-clause specified in param 'clause' /// </summary> /// <param name="clause">The express clause to test</param> /// <returns>true if the clause is satisfied.</returns> public bool ValidateClause(IfcProjectClause clause) { var retVal = false; try { switch (clause) { case IfcProjectClause.WR31: retVal = Functions.EXISTS(this /* as IfcRoot*/.Name); break; case IfcProjectClause.WR32: retVal = Functions.SIZEOF(RepresentationContexts.Where(Temp => Functions.TYPEOF(Temp).Contains("IFC2X3.IFCGEOMETRICREPRESENTATIONSUBCONTEXT"))) == 0; break; case IfcProjectClause.WR33: retVal = Functions.SIZEOF(this /* as IfcObjectDefinition*/.Decomposes) == 0; break; } } catch (Exception ex) { var log = Validation.ValidationLogging.CreateLogger <Xbim.Ifc2x3.Kernel.IfcProject>(); log?.LogError(string.Format("Exception thrown evaluating where-clause 'IfcProject.{0}' for #{1}.", clause, EntityLabel), ex); } return(retVal); }
public override string GetStepParameters() { var parameters = new List <string>(); parameters.Add(GlobalId != null ? GlobalId.ToStepValue() : "$"); parameters.Add(OwnerHistory != null ? OwnerHistory.ToStepValue() : "$"); parameters.Add(Name != null ? Name.ToStepValue() : "$"); parameters.Add(Description != null ? Description.ToStepValue() : "$"); parameters.Add(ObjectType != null ? ObjectType.ToStepValue() : "$"); parameters.Add(LongName != null ? LongName.ToStepValue() : "$"); parameters.Add(Phase != null ? Phase.ToStepValue() : "$"); parameters.Add(RepresentationContexts != null ? RepresentationContexts.ToStepValue() : "$"); parameters.Add(UnitsInContext != null ? UnitsInContext.ToStepValue() : "$"); return(string.Join(", ", parameters.ToArray())); }
public override string WhereRule() { string baseErr = base.WhereRule(); if (!Name.HasValue) { baseErr += "WR31 Project: The Name attribute has to be provided for the project. It is the short name for the project.\n"; } if (RepresentationContexts.OfType <IfcGeometricRepresentationSubContext>().Count() > 0) { baseErr += "WR32 Project: There shall be no instance of IfcGeometricRepresentationSubContext directly included in the set of RepresentationContexts.\n"; } if (Decomposes.Count() != 0) { baseErr += "WR33 Project: The Project represents the root of the any decomposition tree. It shall therefore not be used to decompose any other object definition.\n"; } return(baseErr); }
/// <summary> /// Sets up the default units as SI /// Creates the GeometricRepresentationContext for a Model view, required by Ifc compliance /// </summary> public void Initialize(ProjectUnits units) { var model = Model; if (units == ProjectUnits.SIUnitsUK) { var ua = model.Instances.New <IfcUnitAssignment>(); ua.Units.Add(model.Instances.New <IfcSIUnit>(s => { s.UnitType = IfcUnitEnum.LENGTHUNIT; s.Name = IfcSIUnitName.METRE; s.Prefix = IfcSIPrefix.MILLI; })); ua.Units.Add(model.Instances.New <IfcSIUnit>(s => { s.UnitType = IfcUnitEnum.AREAUNIT; s.Name = IfcSIUnitName.SQUARE_METRE; })); ua.Units.Add(model.Instances.New <IfcSIUnit>(s => { s.UnitType = IfcUnitEnum.VOLUMEUNIT; s.Name = IfcSIUnitName.CUBIC_METRE; })); ua.Units.Add(model.Instances.New <IfcSIUnit>(s => { s.UnitType = IfcUnitEnum.SOLIDANGLEUNIT; s.Name = IfcSIUnitName.STERADIAN; })); ua.Units.Add(model.Instances.New <IfcSIUnit>(s => { s.UnitType = IfcUnitEnum.PLANEANGLEUNIT; s.Name = IfcSIUnitName.RADIAN; })); ua.Units.Add(model.Instances.New <IfcSIUnit>(s => { s.UnitType = IfcUnitEnum.MASSUNIT; s.Name = IfcSIUnitName.GRAM; })); ua.Units.Add(model.Instances.New <IfcSIUnit>(s => { s.UnitType = IfcUnitEnum.TIMEUNIT; s.Name = IfcSIUnitName.SECOND; })); ua.Units.Add(model.Instances.New <IfcSIUnit>(s => { s.UnitType = IfcUnitEnum.THERMODYNAMICTEMPERATUREUNIT; s.Name = IfcSIUnitName.DEGREE_CELSIUS; })); ua.Units.Add(model.Instances.New <IfcSIUnit>(s => { s.UnitType = IfcUnitEnum.LUMINOUSINTENSITYUNIT; s.Name = IfcSIUnitName.LUMEN; })); UnitsInContext = ua; } //Create the Mandatory Model View if (ModelContext == null) { var origin = model.Instances.New <IfcCartesianPoint>(p => p.SetXYZ(0, 0, 0)); var axis3D = model.Instances.New <IfcAxis2Placement3D>(a => a.Location = origin); var gc = model.Instances.New <IfcGeometricRepresentationContext>(c => { c. ContextType = "Model"; c. ContextIdentifier = "Building Model"; c. CoordinateSpaceDimension = 3; c.Precision = 0.00001; c. WorldCoordinateSystem = axis3D; } ); RepresentationContexts.Add(gc); var origin2D = model.Instances.New <IfcCartesianPoint>(p => p.SetXY(0, 0)); var axis2D = model.Instances.New <IfcAxis2Placement2D>(a => a.Location = origin2D); var pc = model.Instances.New <IfcGeometricRepresentationContext>(c => { c. ContextType = "Plan"; c. ContextIdentifier = "Building Plan View"; c. CoordinateSpaceDimension = 2; c.Precision = 0.00001; c. WorldCoordinateSystem = axis2D; } ); RepresentationContexts.Add(pc); } }