This commit is contained in:
Jon Mirtschin 2022-12-10 15:35:14 +11:00
Родитель 09a0f173b5
Коммит 00c1767d7c
12 изменённых файлов: 79 добавлений и 29 удалений

Просмотреть файл

@ -34,7 +34,6 @@ using System.Xml;
using GeometryGym.STEP;
using System.Diagnostics;
using System.Runtime.InteropServices;
#if (NET || !NOIFCJSON)
#if (NEWTONSOFT)
@ -111,7 +110,11 @@ namespace GeometryGym.Ifc
public FactoryIfc Factory { get { return mFactory; } }
public DatabaseIfc() : base() { mFactory = new FactoryIfc(this); Format = FormatIfcSerialization.STEP; }
public DatabaseIfc(string filePath) : this() { SourceFilePath = filePath; new SerializationIfc(this).ReadFile(filePath); }
public DatabaseIfc(string filePath) : this()
{
SourceFilePath = filePath;
new SerializationIfc(this).ReadFile(filePath);
}
public DatabaseIfc(TextReader stream) : this() { new SerializationIfc(this).ReadFile(stream); }
public DatabaseIfc(ModelView view) : this(versionFromModelView(view), view) { }
public DatabaseIfc(ReleaseVersion schema) : this(schema, schema < ReleaseVersion.IFC4 ? ModelView.Ifc2x3NotAssigned : ModelView.Ifc4NotAssigned) { }
@ -2724,18 +2727,33 @@ namespace GeometryGym.Ifc
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;
string authorName = "", organizationName = "", authorization = "None";
if (mDatabase.OriginatingFileInformation != null)
{
authorName = mDatabase.OriginatingFileInformation.Author.First();
organizationName = mDatabase.OriginatingFileInformation.Organization.First();
authorization = mDatabase.OriginatingFileInformation.Authorization;
}
if (!string.IsNullOrEmpty(mDatabase.Authorization))
authorization = mDatabase.Authorization;
if (string.IsNullOrEmpty(authorName))
{
IfcPerson person = mDatabase.Factory.mPerson;
authorName = person == null ? mDatabase.Factory.PersonIdentification() : person.Name;
}
if(string.IsNullOrEmpty(organizationName))
{
organizationName = IfcOrganization.Organization;
IfcOrganization organization = mDatabase.Factory.Organization;
if (organization != null)
organizationName = organization.Name;
}
lines.Add("/* author */ ('" + ParserSTEP.Encode(authorName) + "'),");
string organizationName = IfcOrganization.Organization;
IfcOrganization organization = mDatabase.Factory.Organization;
if (organization != null)
organizationName = organization.Name;
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" : ParserSTEP.Encode(mDatabase.Authorization)) + "'");
lines.Add("/* authorization */ '" + ParserSTEP.Encode(authorization) + "'");
if(mDatabase.Comments.Count > 0)
{
foreach (string comment in mDatabase.Comments)

Просмотреть файл

@ -532,7 +532,7 @@ namespace GeometryGym.Ifc
protected IfcAlignment2DSegment(DatabaseIfc db) : base(db) { }
protected IfcAlignment2DSegment(DatabaseIfc db, IfcAlignment2DSegment s, DuplicateOptions options) : base(db, s, options)
{
TangentialContinuity = s.TangentialContinuity;
mTangentialContinuity = s.mTangentialContinuity;
StartTag = s.StartTag;
EndTag = s.EndTag;
}

Просмотреть файл

@ -749,23 +749,19 @@ namespace GeometryGym.Ifc
internal IfcDoorType() : base() { }
internal IfcDoorType(DatabaseIfc db, IfcDoorType t, DuplicateOptions options) : base(db, t, options) { PredefinedType = t.PredefinedType; mOperationType = t.mOperationType; mParameterTakesPrecedence = t.mParameterTakesPrecedence; mUserDefinedOperationType = t.mUserDefinedOperationType; }
public IfcDoorType(DatabaseIfc db, string name, IfcDoorTypeEnum type) : this(db, name, type, IfcDoorTypeOperationEnum.NOTDEFINED, false) { }
public IfcDoorType(DatabaseIfc db, string name, IfcDoorTypeEnum type) : base(db, name) { mPredefinedType = type; }
internal IfcDoorType(DatabaseIfc db, string name, IfcDoorTypeEnum type, IfcDoorTypeOperationEnum operation, IfcDoorLiningProperties lp, List<IfcDoorPanelProperties> pps)
: base(db)
: this(db, name, type)
{
Name = name;
if (lp != null) mHasPropertySets.Add(lp);
if (pps != null && pps.Count > 0) mHasPropertySets.AddRange(pps);
PredefinedType = type;
mOperationType = operation;
mParameterTakesPrecedence = true;
}
internal IfcDoorType(DatabaseIfc db, string name, IfcDoorTypeEnum type, IfcDoorTypeOperationEnum operation, bool parameterTakesPrecendence)
: base(db)
: this(db, name, type)
{
Name = name;
PredefinedType = type;
mOperationType = operation;
mParameterTakesPrecedence = parameterTakesPrecendence;
}

Просмотреть файл

@ -574,6 +574,11 @@ namespace GeometryGym.Ifc
if (p.mPlacementRefDirection != null)
PlacementRefDirection = db.Factory.Duplicate(p.PlacementRefDirection) as IfcGridPlacementDirectionSelect;
}
internal override bool isXYPlaneWorker(double tol)
{
return false;
}
}
public interface IfcGridPlacementDirectionSelect : IBaseClassIfc { } // SELECT(IfcVirtualGridIntersection, IfcDirection);
[Serializable]

Просмотреть файл

@ -402,6 +402,10 @@ namespace GeometryGym.Ifc
PlacementMeasuredAlong = placementMeasuredAlong;
Distance = distance;
}
internal override bool isXYPlaneWorker(double tol)
{
return false;
}
}
[Serializable]
public partial class IfcLinearPositioningElement : IfcPositioningElement //IFC4.1
@ -530,7 +534,7 @@ namespace GeometryGym.Ifc
PlacementRelTo = relativeTo;
}
internal override bool isXYPlane(double tol)
internal override bool isXYPlaneWorker(double tol)
{
IfcLocalPlacement placement = PlacementRelTo as IfcLocalPlacement;
if (RelativePlacement.IsXYPlane(tol) && (placement == null || placement.isXYPlane(tol)))

Просмотреть файл

@ -240,13 +240,17 @@ namespace GeometryGym.Ifc
foreach (IfcMaterialConstituent constituent in m.MaterialConstituents.Values)
MaterialConstituents[constituent.Name] = db.Factory.Duplicate(constituent) as IfcMaterialConstituent;
}
public IfcMaterialConstituentSet(string name, IEnumerable<IfcMaterialConstituent> materialConstituents)
public IfcMaterialConstituentSet(IEnumerable<IfcMaterialConstituent> materialConstituents)
: base(materialConstituents.First().Database)
{
Name = name;
foreach (IfcMaterialConstituent constituent in materialConstituents)
mMaterialConstituents[constituent.Name] = constituent;
}
public IfcMaterialConstituentSet(string name, IEnumerable<IfcMaterialConstituent> materialConstituents)
: this(materialConstituents)
{
Name = name;
}
}
[Serializable]
public abstract partial class IfcMaterialDefinition : BaseClassIfc, IfcObjectReferenceSelect, IfcMaterialSelect, IfcResourceObjectSelect // ABSTRACT SUPERTYPE OF (ONEOF (IfcMaterial ,IfcMaterialConstituent ,IfcMaterialConstituentSet ,IfcMaterialLayer ,IfcMaterialProfile ,IfcMaterialProfileSet));
@ -484,9 +488,8 @@ namespace GeometryGym.Ifc
public IfcMaterial PrimaryMaterial() { return mMaterials.First(); }
internal IfcMaterialList() : base() { }
internal IfcMaterialList(DatabaseIfc db, IfcMaterialList m) : base(db)
{
Materials.AddRange(m.Materials.Select(x=>db.Factory.Duplicate(x))); }
internal IfcMaterialList(DatabaseIfc db, IfcMaterialList m) : base(db) { Materials.AddRange(m.Materials.Select(x=>db.Factory.Duplicate(x))); }
public IfcMaterialList(IEnumerable<IfcMaterial> materials) : base(materials.First().Database) { Materials.AddRange(materials); }
protected override void initialize()
{
base.initialize();

Просмотреть файл

@ -707,6 +707,7 @@ namespace GeometryGym.Ifc
{
public bool CheckRelatedObjects = true;
public double Tolerance = 1e-5;
public bool IgnoreTypeRepresentationMaps = false;
public OptionsTestDuplicate(double tol)
{
Tolerance = tol;
@ -821,7 +822,14 @@ namespace GeometryGym.Ifc
}
protected virtual IfcObjectPlacement DuplicateWorker(DatabaseIfc db) { return null; }
internal virtual bool isXYPlane(double tol) { return false; }
internal bool isXYPlane(double tol)
{
IfcSpatialStructureElement spatial = PlacesObject.OfType<IfcSpatialStructureElement>().FirstOrDefault() as IfcSpatialStructureElement;
if (spatial != null && spatial.WorkingInLocalCoordinates())
return true;
return isXYPlaneWorker(tol);
}
internal abstract bool isXYPlaneWorker(double tol);
}
[Serializable]
public partial class IfcObjective : IfcConstraint

Просмотреть файл

@ -1632,7 +1632,7 @@ namespace GeometryGym.Ifc
Name = "UNKNOWN PROJECT";
}
public IfcSpatialElement RootElement() { return (mIsDecomposedBy.Count == 0 ? null : mIsDecomposedBy.First().RelatedObjects.First() as IfcSpatialElement); }
public IfcSpatialStructureElement RootElement() { return (mIsDecomposedBy.Count == 0 ? null : mIsDecomposedBy.First().RelatedObjects.First() as IfcSpatialStructureElement); }
internal IfcSite getSite() { return (mIsDecomposedBy.Count == 0 ? null : mIsDecomposedBy.First().RelatedObjects.First() as IfcSite); }
public IfcSite UppermostSite() { return getSite(); }
public IfcBuilding UppermostBuilding()

Просмотреть файл

@ -1169,7 +1169,17 @@ additional types some additional representation types are given:
host.AddAggregated(this);
}
protected IfcSpatialElement(IfcObjectPlacement placement) : base(placement) { }
protected IfcSpatialElement(IfcObjectDefinition host, IfcObjectPlacement placement, IfcProductDefinitionShape representation) : base(host, placement, representation) { }
protected IfcSpatialElement(IfcObjectDefinition host, IfcObjectPlacement placement, IfcProductDefinitionShape representation) : base(host, placement, representation)
{
if(placement == null)
{
IfcAxis2Placement3D relativePlacement = mDatabase.Factory.XYPlanePlacement;
if (host is IfcProduct product && product.ObjectPlacement != null)
ObjectPlacement = new IfcLocalPlacement(product.ObjectPlacement, relativePlacement);
else
ObjectPlacement = new IfcLocalPlacement(relativePlacement);
}
}
protected override void initialize()
{
base.initialize();
@ -1290,6 +1300,11 @@ additional types some additional representation types are given:
protected IfcSpatialStructureElement(DatabaseIfc db, IfcSpatialStructureElement e, DuplicateOptions options) : base(db, e, options) { mCompositionType = e.mCompositionType; }
protected IfcSpatialStructureElement(IfcSpatialStructureElement host, string name) : base(host,name) { if (mDatabase.mRelease < ReleaseVersion.IFC4) mCompositionType = IfcElementCompositionEnum.ELEMENT; }
protected IfcSpatialStructureElement(IfcObjectDefinition host, IfcObjectPlacement placement, IfcProductDefinitionShape representation) : base(host, placement, representation) { }
private bool mWorkInLocalCoordinates = false; //Identify Transform when ignoring placement for Site
public void EnableLocalCoordinates() { mWorkInLocalCoordinates = true; }
public void DisableLocalCoordinates() { mWorkInLocalCoordinates = false; }
public bool WorkingInLocalCoordinates() { return mWorkInLocalCoordinates; }
}
[Serializable]
public abstract partial class IfcSpatialStructureElementType : IfcSpatialElementType //ABSTRACT SUPERTYPE OF (ONEOF (IfcSpaceType))

Просмотреть файл

@ -313,7 +313,7 @@ namespace GeometryGym.Ifc
{
protected override string BuildStringSTEP(ReleaseVersion release)
{
return StepOptionalLengthString(mStartDistAlong) + ",(#" + string.Join(",", mSegments.ConvertAll(x => "#" + x.StepId)) + ")";
return StepOptionalLengthString(mStartDistAlong) + ",(" + string.Join(",", mSegments.ConvertAll(x => "#" + x.StepId)) + ")";
}
internal override void parse(string str, ref int pos, ReleaseVersion release, int len, ConcurrentDictionary<int, BaseClassIfc> dictionary)
{

Просмотреть файл

@ -1121,7 +1121,8 @@ namespace GeometryGym.Ifc
protected override string BuildStringSTEP(ReleaseVersion release)
{
List<IfcPropertySetDefinition> psets = HasPropertySets.Where(x => !x.isEmpty).ToList();
return base.BuildStringSTEP(release) + (mApplicableOccurrence == "$" ? ",$," : ",'" + mApplicableOccurrence + "',") +(psets.Count == 0 ? "$" : "(" + string.Join("," , psets.ConvertAll(x=>"#" + x.StepId)) + ")");
return base.BuildStringSTEP(release) + (string.IsNullOrEmpty(mApplicableOccurrence) ? ",$," : ",'" + mApplicableOccurrence + "',") +
(psets.Count == 0 ? "$" : "(" + string.Join("," , psets.ConvertAll(x=>"#" + x.StepId)) + ")");
}
internal override void parse(string str, ref int pos, ReleaseVersion release, int len, ConcurrentDictionary<int,BaseClassIfc> dictionary)
{

Просмотреть файл

@ -1599,7 +1599,7 @@ namespace GeometryGym.STEP
{
pos = icounter + 1;
progressToNext(s, ref pos, len);
return "$";
return "";
}
string result = stripstring(s, ref icounter, len);
pos = icounter;