Skip to content

Commit

Permalink
v0.2.07
Browse files Browse the repository at this point in the history
  • Loading branch information
jmirtsch committed Nov 22, 2022
1 parent 359ae62 commit 09a0f17
Show file tree
Hide file tree
Showing 34 changed files with 838 additions and 777 deletions.
144 changes: 61 additions & 83 deletions Core/IFC/DatabaseIFC.cs
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,21 @@ internal static ReleaseVersion versionFromModelView(ModelView modelView)
return ReleaseVersion.IFC4X3;
return ReleaseVersion.IFC4A2;
}

internal override void ProcessFileDescription()
{
base.ProcessFileDescription();
foreach (string description in OriginatingFileInformation.FileDescriptions)
{
string modelView = description.ToLower();
if (modelView.Contains("coordination"))
ModelView = ModelView.Ifc2x3Coordination;
else if (modelView.Contains("referenceview"))
ModelView = ModelView.Ifc4Reference;
else if (modelView.Contains("designtransfer"))
ModelView = ModelView.Ifc4DesignTransfer;
}
}
public double Tolerance
{
get { return mModelTolerance; }
Expand Down Expand Up @@ -462,6 +477,8 @@ public string ToString(FormatIfcSerialization format)
return null;
}
}


public class DuplicateMapping
{
private Dictionary<string, int> mDictionary = new Dictionary<string, int>();
Expand Down Expand Up @@ -2482,13 +2499,13 @@ private void processDataLine(string line)
if(obj is IfcRoot root)
root.GlobalId = ParserSTEP.StripString(def, ref pos, def.Length);
else if(obj is IfcProperty property)
property.Name = ParserIfc.Decode(ParserSTEP.StripString(def, ref pos, def.Length));
property.Name = ParserSTEP.Decode(ParserSTEP.StripString(def, ref pos, def.Length));
else if(obj is IfcPropertyTemplate propertyTemplate)
propertyTemplate.Name = ParserIfc.Decode(ParserSTEP.StripString(def, ref pos, def.Length));
propertyTemplate.Name = ParserSTEP.Decode(ParserSTEP.StripString(def, ref pos, def.Length));
else if(obj is IfcPhysicalQuantity quantity)
quantity.Name = ParserIfc.Decode(ParserSTEP.StripString(def, ref pos, def.Length));
quantity.Name = ParserSTEP.Decode(ParserSTEP.StripString(def, ref pos, def.Length));
else if(obj is IfcMaterialConstituent materialConstituent)
materialConstituent.Name = ParserIfc.Decode(ParserSTEP.StripString(def, ref pos, def.Length));
materialConstituent.Name = ParserSTEP.Decode(ParserSTEP.StripString(def, ref pos, def.Length));
}
}
catch (Exception) { }
Expand All @@ -2509,86 +2526,47 @@ protected bool isDataLineOrProcessFileLine(string trimmedLine)
}
internal bool processFileHeaderLine(string line)
{
string ts = line.Replace(" ", "");
if (ts.StartsWith("FILE_SCHEMA(('IFC2X4", true, CultureInfo.CurrentCulture) ||
ts.StartsWith("FILE_SCHEMA(('IFC4", true, CultureInfo.CurrentCulture))
{
if (ts.StartsWith("FILE_SCHEMA(('IFC4X1", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X1;
else if (ts.StartsWith("FILE_SCHEMA(('IFC4X2", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X2;
else if (ts.StartsWith("FILE_SCHEMA(('IFC4X3_RC1", true, CultureInfo.CurrentCulture) ||
ts.StartsWith("FILE_SCHEMA(('IFC4X3_RC1", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X3_RC1;
else if (ts.StartsWith("FILE_SCHEMA(('IFC4X3_RC2", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X3_RC2;
else if (ts.StartsWith("FILE_SCHEMA(('IFC4X3_RC3", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X3_RC3;
else if (ts.StartsWith("FILE_SCHEMA(('IFC4X3_RC4", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X3_RC4;
else if (ts.StartsWith("FILE_SCHEMA(('IFC4X3", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X3;
else
mDatabase.Release = ReleaseVersion.IFC4;
if (mDatabase.Release > ReleaseVersion.IFC2x3)
{
if (mDatabase.Release == ReleaseVersion.IFC4X1)
mDatabase.ModelView = ModelView.Ifc4X1NotAssigned;
else if (mDatabase.Release == ReleaseVersion.IFC4X2)
mDatabase.ModelView = ModelView.Ifc4X2NotAssigned;
else if(mDatabase.Release > ReleaseVersion.IFC4X2)
{
mDatabase.ModelView = ModelView.Ifc4X3NotAssigned;
}
else if (mDatabase.ModelView == ModelView.Ifc2x3Coordination || mDatabase.ModelView == ModelView.Ifc2x3NotAssigned)
mDatabase.ModelView = ModelView.Ifc4NotAssigned;
}
return true;
}
if (ts.StartsWith("FILE_DESCRIPTION", true, System.Globalization.CultureInfo.CurrentCulture))
string lineNoSpaces = ParserSTEP.StripComments(line).Replace(" ", "");
if(lineNoSpaces.StartsWith("FILE_SCHEMA"))
{
int pos1 = ts.IndexOf('('), pos2 = ts.LastIndexOf(')');
if (pos1 > 1 && pos2 > pos1)
if (lineNoSpaces.StartsWith("FILE_SCHEMA(('IFC2X4", true, CultureInfo.CurrentCulture) ||
lineNoSpaces.StartsWith("FILE_SCHEMA(('IFC4", true, CultureInfo.CurrentCulture))
{
string str = ts.Substring(pos1 + 1, pos2 - pos1 - 2);
List<string> fields = ParserSTEP.SplitLineFields(str);
if(fields.Count > 0)
{
string modelView = fields[0].ToLower();
if (modelView.Contains("coordination"))
mDatabase.ModelView = ModelView.Ifc2x3Coordination;
else if (modelView.Contains("referenceview"))
mDatabase.ModelView = ModelView.Ifc4Reference;
else if (modelView.Contains("designtransfer"))
mDatabase.ModelView = ModelView.Ifc4DesignTransfer;
}
}
return true;
}
if (ts.StartsWith("FILE_NAME", true, System.Globalization.CultureInfo.CurrentCulture))
{
try
{
int pos1 = ts.IndexOf('('), pos2 = ts.LastIndexOf(')');
if (pos1 > 1 && pos2 > pos1)
if (lineNoSpaces.StartsWith("FILE_SCHEMA(('IFC4X1", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X1;
else if (lineNoSpaces.StartsWith("FILE_SCHEMA(('IFC4X2", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X2;
else if (lineNoSpaces.StartsWith("FILE_SCHEMA(('IFC4X3_RC1", true, CultureInfo.CurrentCulture) ||
lineNoSpaces.StartsWith("FILE_SCHEMA(('IFC4X3_RC1", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X3_RC1;
else if (lineNoSpaces.StartsWith("FILE_SCHEMA(('IFC4X3_RC2", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X3_RC2;
else if (lineNoSpaces.StartsWith("FILE_SCHEMA(('IFC4X3_RC3", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X3_RC3;
else if (lineNoSpaces.StartsWith("FILE_SCHEMA(('IFC4X3_RC4", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X3_RC4;
else if (lineNoSpaces.StartsWith("FILE_SCHEMA(('IFC4X3", true, CultureInfo.CurrentCulture))
mDatabase.Release = ReleaseVersion.IFC4X3;
else
mDatabase.Release = ReleaseVersion.IFC4;
if (mDatabase.Release > ReleaseVersion.IFC2x3)
{
string str = ts.Substring(pos1 + 1, pos2 - pos1 - 2);
List<string> fields = ParserSTEP.SplitLineFields(str);
if (fields.Count > 1)
if (mDatabase.Release == ReleaseVersion.IFC4X1)
mDatabase.ModelView = ModelView.Ifc4X1NotAssigned;
else if (mDatabase.Release == ReleaseVersion.IFC4X2)
mDatabase.ModelView = ModelView.Ifc4X2NotAssigned;
else if (mDatabase.Release > ReleaseVersion.IFC4X2)
{
string field = ParserSTEP.StripComments(fields[1].Replace("'", "").Trim());
DateTime dateTime = DateTime.MinValue;
if (DateTime.TryParse(field, out dateTime))
mDatabase.TimeStamp = dateTime;
if(fields.Count > 5)
mDatabase.OriginatingSystem = ParserSTEP.StripComments(fields[5].Replace("'", ""));
mDatabase.ModelView = ModelView.Ifc4X3NotAssigned;
}
else if (mDatabase.ModelView == ModelView.Ifc2x3Coordination || mDatabase.ModelView == ModelView.Ifc2x3NotAssigned)
mDatabase.ModelView = ModelView.Ifc4NotAssigned;
}
return true;
}
catch { }
return true;
}
return false;

return mDatabase.processFileHeaderLine(line);
}


Expand Down Expand Up @@ -2743,27 +2721,27 @@ internal List<string> getHeaderLines(string fileName)
lines.Add("ISO-10303-21;\r\nHEADER;\r\nFILE_DESCRIPTION(('ViewDefinition [" + modelView + "]'),'2;1');");

lines.Add("FILE_NAME(");
lines.Add("/* name */ '" + ParserIfc.Encode(fileName) + "',");
lines.Add("/* name */ '" + ParserSTEP.Encode(fileName) + "',");
DateTime now = DateTime.Now;
lines.Add("/* time_stamp */ '" + now.Year + "-" + (now.Month < 10 ? "0" : "") + now.Month + "-" + (now.Day < 10 ? "0" : "") + now.Day + "T" + (now.Hour < 10 ? "0" : "") + now.Hour + ":" + (now.Minute < 10 ? "0" : "") + now.Minute + ":" + (now.Second < 10 ? "0" : "") + now.Second + "',");
IfcPerson person = mDatabase.Factory.mPerson;
string authorName = person == null ? mDatabase.Factory.PersonIdentification() : person.Name;
lines.Add("/* author */ ('" + ParserIfc.Encode(authorName) + "'),");
lines.Add("/* author */ ('" + ParserSTEP.Encode(authorName) + "'),");
string organizationName = IfcOrganization.Organization;
IfcOrganization organization = mDatabase.Factory.Organization;
if (organization != null)
organizationName = organization.Name;
lines.Add("/* organization */ ('" + ParserIfc.Encode(organizationName) + "'),");
lines.Add("/* preprocessor_version */ '" + ParserIfc.Encode(mDatabase.Factory.ToolkitName) + "',");
lines.Add("/* originating_system */ '" + ParserIfc.Encode(mDatabase.Factory.ApplicationFullName) + "',");
lines.Add("/* organization */ ('" + ParserSTEP.Encode(organizationName) + "'),");
lines.Add("/* preprocessor_version */ '" + ParserSTEP.Encode(mDatabase.Factory.ToolkitName) + "',");
lines.Add("/* originating_system */ '" + ParserSTEP.Encode(mDatabase.Factory.ApplicationFullName) + "',");

lines.Add("/* authorization */ '" + (string.IsNullOrEmpty(mDatabase.Authorization) ? "None" : ParserIfc.Encode(mDatabase.Authorization)) + "'");
lines.Add("/* authorization */ '" + (string.IsNullOrEmpty(mDatabase.Authorization) ? "None" : ParserSTEP.Encode(mDatabase.Authorization)) + "'");
if(mDatabase.Comments.Count > 0)
{
foreach (string comment in mDatabase.Comments)
{
if(!string.IsNullOrEmpty(comment))
lines.Add("/* " + ParserIfc.Encode(comment) + "*/");
lines.Add("/* " + ParserSTEP.Encode(comment) + "*/");
}
}
lines.Add(");");
Expand Down
6 changes: 3 additions & 3 deletions Core/IFC/IFC A.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1459,9 +1459,9 @@ public partial class IfcApplication : BaseClassIfc, NamedObjectIfc
internal string mApplicationIdentifier;// : IfcIdentifier;

public IfcOrganization ApplicationDeveloper { get { return mApplicationDeveloper; } set { mApplicationDeveloper = value; } }
public string Version { get { return mVersion; } set { mVersion = ParserIfc.Encode(value); } }
public string ApplicationFullName { get { return ParserIfc.Decode(mApplicationFullName); } set { mApplicationFullName = ParserIfc.Encode(value); } }
public string ApplicationIdentifier { get { return ParserIfc.Decode(mApplicationIdentifier); } set { mApplicationIdentifier = ParserIfc.Encode(value); } }
public string Version { get { return mVersion; } set { mVersion = ParserSTEP.Encode(value); } }
public string ApplicationFullName { get { return ParserSTEP.Decode(mApplicationFullName); } set { mApplicationFullName = ParserSTEP.Encode(value); } }
public string ApplicationIdentifier { get { return ParserSTEP.Decode(mApplicationIdentifier); } set { mApplicationIdentifier = ParserSTEP.Encode(value); } }

public string Name { get { return ApplicationFullName; } set { ApplicationFullName = value; } }

Expand Down
4 changes: 2 additions & 2 deletions Core/IFC/IFC C.cs
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ public DateTime EditionDate
public string Name { get { return mName; } set { mName = (string.IsNullOrEmpty(value) ? "Unknown" : value); } }
public string Description { get { return mDescription; } set { mDescription = value; } }
public string Specification { get { return mSpecification; } set { mSpecification = value; } }
public List<string> ReferenceTokens { get { return mReferenceTokens.ConvertAll(x => ParserIfc.Decode(x)); } }
public List<string> ReferenceTokens { get { return mReferenceTokens.ConvertAll(x => ParserSTEP.Decode(x)); } }
public SET<IfcRelAssociatesClassification> ClassificationForObjects { get { return mClassificationForObjects; } }
public SET<IfcClassificationReference> HasReferences { get { return mHasReferences; } }

Expand Down Expand Up @@ -1658,7 +1658,7 @@ public enum CommonUnitName
public SET<IfcExternalReferenceRelationship> HasExternalReference { get { return mHasExternalReference; } }
public SET<IfcResourceConstraintRelationship> HasConstraintRelationships { get { return mHasConstraintRelationships; } }

public string Name { get { return ParserIfc.Decode(mName); } set { mName = ParserIfc.Encode(value); } }
public string Name { get { return ParserSTEP.Decode(mName); } set { mName = ParserSTEP.Encode(value); } }
public IfcMeasureWithUnit ConversionFactor { get { return mConversionFactor; } set { mConversionFactor = value; } }

internal IfcConversionBasedUnit() : base() { }
Expand Down
2 changes: 1 addition & 1 deletion Core/IFC/IFC F.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ internal IfcFacetedBrepWithVoids(DatabaseIfc db, IfcFacetedBrepWithVoids b, Dupl
public IfcFacetedBrepWithVoids(IfcClosedShell s, IEnumerable<IfcClosedShell> voids) : base(s) { mVoids.AddRange(voids); }
}
[Serializable]
public partial class IfcFacility : IfcSpatialStructureElement //IFC4x2 //SUPERTYPE OF(IfcBridge, IfcBuilding)
public partial class IfcFacility : IfcSpatialStructureElement //SUPERTYPE OF(IfcBridge , IfcBuilding , IfcMarineFacility , IfcRailway , IfcRoad)
{
internal IfcFacility() : base() { }
public IfcFacility(DatabaseIfc db) : base(db.Factory.RootPlacement) { }
Expand Down
9 changes: 6 additions & 3 deletions Core/IFC/IFC P.cs
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ protected IfcPhysicalSimpleQuantity(DatabaseIfc db, string name) : base(db, name

public abstract IfcMeasureValue MeasureValue { get; }
}
[Serializable]
[Serializable, VersionAdded(ReleaseVersion.IFC2x2)]
public partial class IfcPile : IfcDeepFoundation
{
private IfcPileTypeEnum mPredefinedType = IfcPileTypeEnum.NOTDEFINED;// OPTIONAL : IfcPileTypeEnum;
Expand Down Expand Up @@ -510,6 +510,9 @@ internal IfcPlateType() : base() { }
[Serializable]
public abstract partial class IfcPoint : IfcGeometricRepresentationItem, IfcGeometricSetSelect, IfcPointOrVertexPoint /*ABSTRACT SUPERTYPE OF (ONEOF (IfcCartesianPoint ,IfcPointOnCurve ,IfcPointOnSurface))*/
{
//INVERSE
internal IfcVertexPoint mOfVertex = null; // GG attribute

protected IfcPoint() : base() { }
protected IfcPoint(DatabaseIfc db) : base(db) { }
protected IfcPoint(DatabaseIfc db, IfcPoint p, DuplicateOptions options) : base(db, p, options) { }
Expand Down Expand Up @@ -1658,7 +1661,7 @@ public partial class IfcProjectedCRS : IfcCoordinateReferenceSystem //IFC4
internal string mMapZone = "";// : OPTIONAL IfcIdentifier
internal IfcNamedUnit mMapUnit = null;// : OPTIONAL IfcNamedUnit;

public string MapProjection { get { return mMapProjection; } set { mMapProjection = ParserIfc.Encode(value); } }
public string MapProjection { get { return mMapProjection; } set { mMapProjection = value; } }
public string MapZone { get { return mMapZone; } set { mMapZone = value; } }
public IfcNamedUnit MapUnit { get { return mMapUnit; } set { mMapUnit = value; } }

Expand Down Expand Up @@ -1976,7 +1979,7 @@ public partial class IfcPropertyEnumeration : IfcPropertyAbstraction, NamedObjec
internal LIST<IfcValue> mEnumerationValues = new LIST<IfcValue>();// : LIST [1:?] OF UNIQUE IfcValue
internal IfcUnit mUnit; // : OPTIONAL IfcUnit;

public string Name { get { return ParserIfc.Decode(mName); } set { mName = (string.IsNullOrEmpty(value) ? "Unknown" : ParserIfc.Encode(value)); } }
public string Name { get { return mName; } set { mName = (string.IsNullOrEmpty(value) ? "Unknown" : value); } }
public LIST<IfcValue> EnumerationValues { get { return mEnumerationValues; } }
public IfcUnit Unit { get { return mUnit; } set { mUnit = value; } }

Expand Down
4 changes: 2 additions & 2 deletions Core/IFC/IFC R.cs
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,7 @@ public partial class IfcReinforcementBarProperties : IfcPreDefinedProperties
internal double mBarCount = double.NaN; // : OPTIONAL IfcCountMeasure;

public double TotalCrossSectionArea { get { return mTotalCrossSectionArea; } set { mTotalCrossSectionArea = value; } }
public string SteelGrade { get { return ParserIfc.Decode(mSteelGrade); } set { mSteelGrade = ParserIfc.Encode(value); } }
public string SteelGrade { get { return mSteelGrade; } set { mSteelGrade = string.IsNullOrEmpty(value) ? "Unknown" : value; } }
public IfcReinforcingBarSurfaceEnum BarSurface { get { return mBarSurface; } set { mBarSurface = value; } }
public double EffectiveDepth { get { return mEffectiveDepth; } set { mEffectiveDepth = value; } }
public double NominalBarDiameter { get { return mNominalBarDiameter; } set { mNominalBarDiameter = value; } }
Expand Down Expand Up @@ -1327,7 +1327,7 @@ public partial class IfcRelConnectsStructuralElement : IfcRelConnects //DELETED
internal IfcStructuralMember mRelatedStructuralMember;// : IfcStructuralMember;

public IfcElement RelatingElement { get { return mRelatingElement as IfcElement; } set { mRelatingElement = value; value.mHasStructuralMember.Add(this); } }
public IfcStructuralMember RelatedStructuralMember { get { return mRelatedStructuralMember as IfcStructuralMember; } set { mRelatedStructuralMember = value; value.mStructuralMemberForGG = this; } }
public IfcStructuralMember RelatedStructuralMember { get { return mRelatedStructuralMember as IfcStructuralMember; } set { mRelatedStructuralMember = value; value.mStructuralMemberFor = this; } }

internal IfcRelConnectsStructuralElement() : base() { }
internal IfcRelConnectsStructuralElement(DatabaseIfc db, IfcRelConnectsStructuralElement c, DuplicateOptions options) : base(db, c, options)
Expand Down
7 changes: 5 additions & 2 deletions Core/IFC/IFC S.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1850,7 +1850,10 @@ public IfcStructuralLoadLinearForce(DatabaseIfc db) : base(db) { }
[Serializable]
public partial class IfcStructuralLoadPlanarForce : IfcStructuralLoadStatic
{
internal double mPlanarForceX = 0, mPlanarForceY = 0, mPlanarForceZ = 0;// : OPTIONAL IfcPlanarForceMeasure;
private double mPlanarForceX = double.NaN, mPlanarForceY = double.NaN, mPlanarForceZ = double.NaN;// : OPTIONAL IfcPlanarForceMeasure;
public double PlanarForceX { get { return double.IsNaN(mPlanarForceX) ? 0 : mPlanarForceX; } set { mPlanarForceX = value; } }
public double PlanarForceY { get { return double.IsNaN(mPlanarForceY) ? 0 : mPlanarForceY; } set { mPlanarForceY = value; } }
public double PlanarForceZ { get { return double.IsNaN(mPlanarForceZ) ? 0 : mPlanarForceZ; } set { mPlanarForceZ = value; } }
internal IfcStructuralLoadPlanarForce() : base() { }
internal IfcStructuralLoadPlanarForce(DatabaseIfc db, IfcStructuralLoadPlanarForce f) : base(db,f) { mPlanarForceX = f.mPlanarForceX; mPlanarForceY = f.mPlanarForceY; mPlanarForceZ = f.mPlanarForceZ; }
public IfcStructuralLoadPlanarForce(DatabaseIfc db) : base(db) { }
Expand Down Expand Up @@ -1921,7 +1924,7 @@ public abstract partial class IfcStructuralMember : IfcStructuralItem //ABSTRACT
{
//INVERSE
internal SET<IfcRelConnectsStructuralMember> mConnectedBy = new SET<IfcRelConnectsStructuralMember>();// : SET [0:?] OF IfcRelConnectsStructuralMember FOR RelatingStructuralMember
internal IfcRelConnectsStructuralElement mStructuralMemberForGG = null;
internal IfcRelConnectsStructuralElement mStructuralMemberFor = null; // GG attribute

public SET<IfcRelConnectsStructuralMember> ConnectedBy { get { return mConnectedBy; } }

Expand Down
Loading

0 comments on commit 09a0f17

Please sign in to comment.