From e50b14122ced8f263af4a44b7c4a07d942a9fbad Mon Sep 17 00:00:00 2001 From: Martin Ashton Date: Tue, 26 Nov 2024 13:53:57 -0500 Subject: [PATCH 1/2] Added FamilyInstance.SuperComponent relation --- src/cpp/vim/object-model.h | 18 ++++++++++++ .../vim/Vim.Format/ObjectModel/ObjectModel.cs | 8 ++++- .../ObjectModel/ObjectModelGenerated.cs | 8 +++++ src/ts/src/objectModel.ts | 29 +++++++++++++++++++ 4 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/cpp/vim/object-model.h b/src/cpp/vim/object-model.h index 5421cd3..128d44a 100644 --- a/src/cpp/vim/object-model.h +++ b/src/cpp/vim/object-model.h @@ -5302,6 +5302,8 @@ namespace Vim Room* mFromRoom; int mToRoomIndex; Room* mToRoom; + int mSuperComponentIndex; + Element* mSuperComponent; int mElementIndex; Element* mElement; @@ -5352,6 +5354,7 @@ namespace Vim familyInstance->mHostIndex = GetHostIndex(familyInstanceIndex); familyInstance->mFromRoomIndex = GetFromRoomIndex(familyInstanceIndex); familyInstance->mToRoomIndex = GetToRoomIndex(familyInstanceIndex); + familyInstance->mSuperComponentIndex = GetSuperComponentIndex(familyInstanceIndex); familyInstance->mElementIndex = GetElementIndex(familyInstanceIndex); return familyInstance; } @@ -5385,6 +5388,7 @@ namespace Vim bool existsHost = mEntityTable.column_exists("index:Vim.Element:Host"); bool existsFromRoom = mEntityTable.column_exists("index:Vim.Room:FromRoom"); bool existsToRoom = mEntityTable.column_exists("index:Vim.Room:ToRoom"); + bool existsSuperComponent = mEntityTable.column_exists("index:Vim.Element:SuperComponent"); bool existsElement = mEntityTable.column_exists("index:Vim.Element:Element"); const auto count = GetCount(); @@ -5511,6 +5515,7 @@ namespace Vim const std::vector& hostData = mEntityTable.column_exists("index:Vim.Element:Host") ? mEntityTable.mIndexColumns["index:Vim.Element:Host"] : std::vector(); const std::vector& fromRoomData = mEntityTable.column_exists("index:Vim.Room:FromRoom") ? mEntityTable.mIndexColumns["index:Vim.Room:FromRoom"] : std::vector(); const std::vector& toRoomData = mEntityTable.column_exists("index:Vim.Room:ToRoom") ? mEntityTable.mIndexColumns["index:Vim.Room:ToRoom"] : std::vector(); + const std::vector& superComponentData = mEntityTable.column_exists("index:Vim.Element:SuperComponent") ? mEntityTable.mIndexColumns["index:Vim.Element:SuperComponent"] : std::vector(); const std::vector& elementData = mEntityTable.column_exists("index:Vim.Element:Element") ? mEntityTable.mIndexColumns["index:Vim.Element:Element"] : std::vector(); for (int i = 0; i < count; ++i) @@ -5567,6 +5572,7 @@ namespace Vim entity.mHostIndex = existsHost ? hostData[i] : -1; entity.mFromRoomIndex = existsFromRoom ? fromRoomData[i] : -1; entity.mToRoomIndex = existsToRoom ? toRoomData[i] : -1; + entity.mSuperComponentIndex = existsSuperComponent ? superComponentData[i] : -1; entity.mElementIndex = existsElement ? elementData[i] : -1; familyInstance->push_back(entity); } @@ -6290,6 +6296,18 @@ namespace Vim return mEntityTable.mIndexColumns["index:Vim.Room:ToRoom"][familyInstanceIndex]; } + int GetSuperComponentIndex(int familyInstanceIndex) + { + if (!mEntityTable.column_exists("index:Vim.Element:SuperComponent")) { + return -1; + } + + if (familyInstanceIndex < 0 || familyInstanceIndex >= GetCount()) + return -1; + + return mEntityTable.mIndexColumns["index:Vim.Element:SuperComponent"][familyInstanceIndex]; + } + int GetElementIndex(int familyInstanceIndex) { if (!mEntityTable.column_exists("index:Vim.Element:Element")) { diff --git a/src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs b/src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs index bfc6fb7..750da94 100644 --- a/src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs +++ b/src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs @@ -14,6 +14,10 @@ public static class SchemaVersion // ReSharper disable MemberHidesStaticFromOuterClass public static class History { + // Schema additions + // TODO... + public const string v5_4_0 = "5.4.0"; + // Schema additions // Vim.ParameterDescriptor__int:StorageType public const string v5_3_0 = "5.3.0"; @@ -163,7 +167,8 @@ public static class History // ReSharper enable MemberHidesStaticFromOuterClass // [MAINTAIN] Add more object model SerializableVersions below and update the current one. - public static SerializableVersion Current => v5_3_0; + public static SerializableVersion Current => v5_4_0; + public static SerializableVersion v5_4_0 => SerializableVersion.Parse(History.v5_4_0); public static SerializableVersion v5_3_0 => SerializableVersion.Parse(History.v5_3_0); public static SerializableVersion v5_2_0 => SerializableVersion.Parse(History.v5_2_0); public static SerializableVersion v5_1_0 => SerializableVersion.Parse(History.v5_1_0); @@ -817,6 +822,7 @@ public Vector3 HandOrientation public Relation _Host; public Relation _FromRoom; public Relation _ToRoom; + public Relation _SuperComponent; } /// diff --git a/src/cs/vim/Vim.Format/ObjectModel/ObjectModelGenerated.cs b/src/cs/vim/Vim.Format/ObjectModel/ObjectModelGenerated.cs index 88dae8d..1829b43 100644 --- a/src/cs/vim/Vim.Format/ObjectModel/ObjectModelGenerated.cs +++ b/src/cs/vim/Vim.Format/ObjectModel/ObjectModelGenerated.cs @@ -669,6 +669,7 @@ public partial class FamilyInstance public Vim.Format.ObjectModel.Element Host => _Host.Value; public Vim.Format.ObjectModel.Room FromRoom => _FromRoom.Value; public Vim.Format.ObjectModel.Room ToRoom => _ToRoom.Value; + public Vim.Format.ObjectModel.Element SuperComponent => _SuperComponent.Value; public Vim.Format.ObjectModel.Element Element => _Element.Value; public FamilyInstance() { @@ -676,6 +677,7 @@ public FamilyInstance() _Host = new Relation(); _FromRoom = new Relation(); _ToRoom = new Relation(); + _SuperComponent = new Relation(); _Element = new Relation(); } @@ -712,6 +714,7 @@ public override bool FieldsAreEqual(object obj) (_Host?.Index == other._Host?.Index) && (_FromRoom?.Index == other._FromRoom?.Index) && (_ToRoom?.Index == other._ToRoom?.Index) && + (_SuperComponent?.Index == other._SuperComponent?.Index) && (_Element?.Index == other._Element?.Index); if (!fieldsAreEqual) { @@ -2612,6 +2615,8 @@ public FamilyType GetFamilyType(int n) public int GetFamilyInstanceFromRoomIndex(int index) => FamilyInstanceFromRoomIndex?.ElementAtOrDefault(index, EntityRelation.None) ?? EntityRelation.None; public IArray FamilyInstanceToRoomIndex { get; } public int GetFamilyInstanceToRoomIndex(int index) => FamilyInstanceToRoomIndex?.ElementAtOrDefault(index, EntityRelation.None) ?? EntityRelation.None; + public IArray FamilyInstanceSuperComponentIndex { get; } + public int GetFamilyInstanceSuperComponentIndex(int index) => FamilyInstanceSuperComponentIndex?.ElementAtOrDefault(index, EntityRelation.None) ?? EntityRelation.None; public IArray FamilyInstanceElementIndex { get; } public int GetFamilyInstanceElementIndex(int index) => FamilyInstanceElementIndex?.ElementAtOrDefault(index, EntityRelation.None) ?? EntityRelation.None; public int NumFamilyInstance => FamilyInstanceEntityTable?.NumRows ?? 0; @@ -2649,6 +2654,7 @@ public FamilyInstance GetFamilyInstance(int n) r._Host = new Relation(GetFamilyInstanceHostIndex(n), GetElement); r._FromRoom = new Relation(GetFamilyInstanceFromRoomIndex(n), GetRoom); r._ToRoom = new Relation(GetFamilyInstanceToRoomIndex(n), GetRoom); + r._SuperComponent = new Relation(GetFamilyInstanceSuperComponentIndex(n), GetElement); r._Element = new Relation(GetFamilyInstanceElementIndex(n), GetElement); return r; } @@ -4174,6 +4180,7 @@ public DocumentModel(Document d, bool inParallel = true) FamilyInstanceHostIndex = FamilyInstanceEntityTable?.GetIndexColumnValues("index:Vim.Element:Host") ?? Array.Empty().ToIArray(); FamilyInstanceFromRoomIndex = FamilyInstanceEntityTable?.GetIndexColumnValues("index:Vim.Room:FromRoom") ?? Array.Empty().ToIArray(); FamilyInstanceToRoomIndex = FamilyInstanceEntityTable?.GetIndexColumnValues("index:Vim.Room:ToRoom") ?? Array.Empty().ToIArray(); + FamilyInstanceSuperComponentIndex = FamilyInstanceEntityTable?.GetIndexColumnValues("index:Vim.Element:SuperComponent") ?? Array.Empty().ToIArray(); FamilyInstanceElementIndex = FamilyInstanceEntityTable?.GetIndexColumnValues("index:Vim.Element:Element") ?? Array.Empty().ToIArray(); ViewCameraIndex = ViewEntityTable?.GetIndexColumnValues("index:Vim.Camera:Camera") ?? Array.Empty().ToIArray(); ViewFamilyTypeIndex = ViewEntityTable?.GetIndexColumnValues("index:Vim.FamilyType:FamilyType") ?? Array.Empty().ToIArray(); @@ -4617,6 +4624,7 @@ public static EntityTableBuilder ToFamilyInstanceTableBuilder(this IEnumerable x._Host?.Index ?? EntityRelation.None)); tb.AddIndexColumn("index:Vim.Room:FromRoom", typedEntities.Select(x => x._FromRoom?.Index ?? EntityRelation.None)); tb.AddIndexColumn("index:Vim.Room:ToRoom", typedEntities.Select(x => x._ToRoom?.Index ?? EntityRelation.None)); + tb.AddIndexColumn("index:Vim.Element:SuperComponent", typedEntities.Select(x => x._SuperComponent?.Index ?? EntityRelation.None)); tb.AddIndexColumn("index:Vim.Element:Element", typedEntities.Select(x => x._Element?.Index ?? EntityRelation.None)); return tb; } diff --git a/src/ts/src/objectModel.ts b/src/ts/src/objectModel.ts index c9a772f..4706160 100644 --- a/src/ts/src/objectModel.ts +++ b/src/ts/src/objectModel.ts @@ -3919,6 +3919,8 @@ export interface IFamilyInstance { fromRoom?: IRoom toRoomIndex?: number toRoom?: IRoom + superComponentIndex?: number + superComponent?: IElement elementIndex?: number element?: IElement } @@ -3987,6 +3989,9 @@ export interface IFamilyInstanceTable { getToRoomIndex(familyInstanceIndex: number): Promise getAllToRoomIndex(): Promise getToRoom(familyInstanceIndex: number): Promise + getSuperComponentIndex(familyInstanceIndex: number): Promise + getAllSuperComponentIndex(): Promise + getSuperComponent(familyInstanceIndex: number): Promise getElementIndex(familyInstanceIndex: number): Promise getAllElementIndex(): Promise getElement(familyInstanceIndex: number): Promise @@ -4026,6 +4031,8 @@ export class FamilyInstance implements IFamilyInstance { fromRoom?: IRoom toRoomIndex?: number toRoom?: IRoom + superComponentIndex?: number + superComponent?: IElement elementIndex?: number element?: IElement @@ -4061,6 +4068,7 @@ export class FamilyInstance implements IFamilyInstance { table.getHostIndex(index).then(v => result.hostIndex = v), table.getFromRoomIndex(index).then(v => result.fromRoomIndex = v), table.getToRoomIndex(index).then(v => result.toRoomIndex = v), + table.getSuperComponentIndex(index).then(v => result.superComponentIndex = v), table.getElementIndex(index).then(v => result.elementIndex = v), ]) @@ -4124,6 +4132,7 @@ export class FamilyInstanceTable implements IFamilyInstanceTable { let hostIndex: number[] | undefined let fromRoomIndex: number[] | undefined let toRoomIndex: number[] | undefined + let superComponentIndex: number[] | undefined let elementIndex: number[] | undefined await Promise.all([ @@ -4154,6 +4163,7 @@ export class FamilyInstanceTable implements IFamilyInstanceTable { (async () => { hostIndex = (await localTable.getNumberArray("index:Vim.Element:Host")) })(), (async () => { fromRoomIndex = (await localTable.getNumberArray("index:Vim.Room:FromRoom")) })(), (async () => { toRoomIndex = (await localTable.getNumberArray("index:Vim.Room:ToRoom")) })(), + (async () => { superComponentIndex = (await localTable.getNumberArray("index:Vim.Element:SuperComponent")) })(), (async () => { elementIndex = (await localTable.getNumberArray("index:Vim.Element:Element")) })(), ]) @@ -4190,6 +4200,7 @@ export class FamilyInstanceTable implements IFamilyInstanceTable { hostIndex: hostIndex ? hostIndex[i] : undefined, fromRoomIndex: fromRoomIndex ? fromRoomIndex[i] : undefined, toRoomIndex: toRoomIndex ? toRoomIndex[i] : undefined, + superComponentIndex: superComponentIndex ? superComponentIndex[i] : undefined, elementIndex: elementIndex ? elementIndex[i] : undefined }) } @@ -4453,6 +4464,24 @@ export class FamilyInstanceTable implements IFamilyInstanceTable { return await this.document.room?.get(index) } + async getSuperComponentIndex(familyInstanceIndex: number): Promise { + return await this.entityTable.getNumber(familyInstanceIndex, "index:Vim.Element:SuperComponent") + } + + async getAllSuperComponentIndex(): Promise { + return await this.entityTable.getNumberArray("index:Vim.Element:SuperComponent") + } + + async getSuperComponent(familyInstanceIndex: number): Promise { + const index = await this.getSuperComponentIndex(familyInstanceIndex) + + if (index === undefined) { + return undefined + } + + return await this.document.element?.get(index) + } + async getElementIndex(familyInstanceIndex: number): Promise { return await this.entityTable.getNumber(familyInstanceIndex, "index:Vim.Element:Element") } From e28c5b42f0b1f88c344ecd6062e07e17f515e8de Mon Sep 17 00:00:00 2001 From: Martin Ashton Date: Tue, 26 Nov 2024 16:03:25 -0500 Subject: [PATCH 2/2] Updated object model schema documentation to include SuperComponent --- docs/object-model-schema.json | 3 ++- docs/schema-diff.json | 5 +++++ src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs | 2 +- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/object-model-schema.json b/docs/object-model-schema.json index 6b76fe0..b72a965 100644 --- a/docs/object-model-schema.json +++ b/docs/object-model-schema.json @@ -1,6 +1,6 @@ { "VimFormatVersion": "1.0.0", - "SchemaVersion": "5.3.0", + "SchemaVersion": "5.4.0", "Tables": { "Vim.Area": [ "byte:IsGrossInterior", @@ -198,6 +198,7 @@ "float:Translation.Z", "index:Vim.Element:Element", "index:Vim.Element:Host", + "index:Vim.Element:SuperComponent", "index:Vim.FamilyType:FamilyType", "index:Vim.Room:FromRoom", "index:Vim.Room:ToRoom" diff --git a/docs/schema-diff.json b/docs/schema-diff.json index 4e6d481..6f4b52f 100644 --- a/docs/schema-diff.json +++ b/docs/schema-diff.json @@ -150,5 +150,10 @@ "Added": [ "Vim.ParameterDescriptor__int:StorageType" ] + }, + "5.3.0 to 5.4.0": { + "Added": [ + "Vim.FamilyInstance__index:Vim.Element:SuperComponent" + ] } } \ No newline at end of file diff --git a/src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs b/src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs index 750da94..6248574 100644 --- a/src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs +++ b/src/cs/vim/Vim.Format/ObjectModel/ObjectModel.cs @@ -15,7 +15,7 @@ public static class SchemaVersion public static class History { // Schema additions - // TODO... + // Vim.FamilyInstance__index:Vim.Element:SuperComponent public const string v5_4_0 = "5.4.0"; // Schema additions