Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
1562121
Added fractional feet and inches formatting
mavimaec Jul 25, 2025
1b412d4
(wip) refactored units and tests, working on LevelInfo
mavimaec Jul 25, 2025
2dbf64c
LevelInfo now reads parameter information
mavimaec Jul 28, 2025
9da79fa
(wip) Optimizing GetOrAdd calls
mavimaec Jul 28, 2025
5f5ae7b
Refactored to use explicit EntitySetBuilders for performance gains
mavimaec Jul 29, 2025
c6090de
Added ObjectModelBuilder.Clear()
mavimaec Jul 29, 2025
5772545
Avoiding linq in entity table construction
mavimaec Jul 29, 2025
47c7332
(wip) initial family instance level info coded; requires testing
mavimaec Jul 30, 2025
052fe24
Small refactoring
mavimaec Jul 30, 2025
f49a004
Cleanup
mavimaec Jul 31, 2025
c882cc8
Renamed to LevelInfoService
mavimaec Jul 31, 2025
e471c31
(WIP - DNC) Checkpoint: refactoring to ElementGeometryMap to re-use b…
mavimaec Jul 31, 2025
6c60c63
Refactored to ElementGeometryMap
mavimaec Aug 1, 2025
5f96298
Bug fixes
mavimaec Aug 1, 2025
28c2205
Performance improvements and bug fixes. Added more test files.
mavimaec Aug 1, 2025
e534919
"stringbuffer" to "stringtable". Added functions to directly access t…
mavimaec Aug 1, 2025
381f8e9
Refactored LevelInfoService
mavimaec Aug 4, 2025
293224d
Refactored FamilyInstanceLevelInfo to ElementLevelInfo
mavimaec Aug 4, 2025
e029b85
Unit test fix
mavimaec Aug 4, 2025
f722c7e
Added Transform for DVector3
mavimaec Aug 5, 2025
06f0cf7
Refactored to ElementParameterInfoService and added ElementMeasureInfo
mavimaec Aug 6, 2025
f65d8de
Added ElementKind
mavimaec Aug 8, 2025
470e26b
Added tiny house imperial and metric
mavimaec Aug 11, 2025
6b64b91
Updated ElementKind code generation
mavimaec Aug 11, 2025
76e5174
Streamlined entity kind validation test
mavimaec Aug 11, 2025
be207e6
Added ParameterMeasureInfo. Refactored ElementMeasureInfo for perform…
mavimaec Aug 11, 2025
7606738
Added convenience function for CategoryTable.GetNameFull
mavimaec Aug 12, 2025
875e1d1
Added support for more measure types
mavimaec Aug 14, 2025
02ec562
Improved consistency of fractional feet and inches formatting when va…
mavimaec Aug 14, 2025
248e644
Bug fix for null reference exception and centralizing on TableNames.<…
mavimaec Aug 16, 2025
4bb73c9
Typo fix
mavimaec Aug 16, 2025
1eb08f1
Other typo fix
mavimaec Aug 16, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions data/Dwelling.r2019.om_v5.5.0.vim

This file was deleted.

3 changes: 3 additions & 0 deletions data/Dwelling.r2024.om_v5.6.0.vim
Git LFS file not shown
3 changes: 3 additions & 0 deletions data/Empty.vim
Git LFS file not shown
3 changes: 3 additions & 0 deletions data/IfcTest.vim
Git LFS file not shown
3 changes: 3 additions & 0 deletions data/Tiny_House_Imperial.r2024.om_v5.6.0.vim
Git LFS file not shown
3 changes: 3 additions & 0 deletions data/Tiny_House_Metric.r2024.om_v5.6.0.vim
Git LFS file not shown
3 changes: 3 additions & 0 deletions data/Wolford_Residence.navis2023.om_v5.6.0.vim
Git LFS file not shown
3 changes: 3 additions & 0 deletions data/Wolford_Residence.r2025.om_v5.6.0.vim
Git LFS file not shown
4 changes: 0 additions & 4 deletions src/cs/math3d/Vim.Math3D/Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,5 @@ public static class Constants
public const double DegreesToRadians = 0.017453292519943295769236907684886;

public const double OneTenthOfADegree = DegreesToRadians / 10;

// TODO: BUG: these two values are inverted dumb-dumb
public const double MmToFeet = 0.00328084;
public const double FeetToMm = 1 / MmToFeet;
}
}
10 changes: 10 additions & 0 deletions src/cs/math3d/Vim.Math3D/StructsPartial.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,16 @@ public partial struct DVector3
public Vector3 Vector3
=> new Vector3((float)X, (float)Y, (float)Z);

/// <summary>
/// Transforms a vector by the given matrix.
/// </summary>
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public DVector3 Transform(DMatrix4x4 matrix)
=> new DVector3(
X * matrix.M11 + Y * matrix.M21 + Z * matrix.M31 + matrix.M41,
X * matrix.M12 + Y * matrix.M22 + Z * matrix.M32 + matrix.M42,
X * matrix.M13 + Y * matrix.M23 + Z * matrix.M33 + matrix.M43);

/// <summary>
/// Computes the cross product of two vectors.
/// </summary>
Expand Down
57 changes: 29 additions & 28 deletions src/cs/samples/Vim.Gltf.Converter/GltfToVimStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Vim.Format;
using Vim.Format.ObjectModel;
using Vim.Math3d;
using Vim.Util;

namespace Vim.Gltf.Converter
{
Expand All @@ -21,7 +22,7 @@ public class GltfToVimStore : ObjectModelStore
private const string GeneratorString = "Vim.Gltf.Converter";

// NOTE: In GLTF, units are assumed to be in meters however in VIM they are in feet.
public const float MetersToFeet = 3.280839895f;
public const float MetersToFeet = (float) Units.MetersToFeetRatio;

/// <summary>
/// Converts a GLTF file into a VIM file.
Expand Down Expand Up @@ -73,20 +74,20 @@ private void VisitGltf()
/// Stores a default empty display unit entity.
/// </summary>
private DisplayUnit StoreDefaultDisplayUnit()
=> ObjectModelBuilder.Add(DisplayUnit.Empty);
=> ObjectModelBuilder.DisplayUnitBuilder.Add(DisplayUnit.Empty).Entity;

/// <summary>
/// Since GLTF does not contain Category information, we will store a single default Category
/// entity which will be applied to all elements.
/// </summary>
private Category StoreDefaultCategory()
=> ObjectModelBuilder.Add(new Category
=> ObjectModelBuilder.CategoryBuilder.Add(new Category
{
Id = VimConstants.SyntheticCategoryId,
BuiltInCategory = "GLTF_CATEGORY",
Name = "GLTF Object",
CategoryType = "GLTF",
});
}).Entity;

/// <summary>
/// Since GLTF does not contain Family information, we will store a single default Family
Expand All @@ -96,18 +97,18 @@ private Family StoreDefaultFamily(
BimDocument bimDocument,
Category category)
{
var familyElement = ObjectModelBuilder.Add(new Element
var familyElement = ObjectModelBuilder.ElementBuilder.Add(new Element
{
Id = VimConstants.SyntheticElementId,
Name = "GLTF Family",
_BimDocument = { Index = bimDocument.Index },
_Category = { Index = category.Index }
});
}).Entity;

return ObjectModelBuilder.Add(new Family
return ObjectModelBuilder.FamilyBuilder.Add(new Family
{
_Element = { Index = familyElement.Index },
});
}).Entity;
}

/// <summary>
Expand All @@ -119,19 +120,19 @@ private FamilyType StoreDefaultFamilyType(
Category category,
Family family)
{
var familyTypeElement = ObjectModelBuilder.Add(new Element
var familyTypeElement = ObjectModelBuilder.ElementBuilder.Add(new Element
{
Id = VimConstants.SyntheticElementId,
Name = "GLTF Family Type",
_BimDocument = { Index = bimDocument.Index },
_Category = { Index = category.Index }
});
}).Entity;

return ObjectModelBuilder.Add(new FamilyType
return ObjectModelBuilder.FamilyTypeBuilder.Add(new FamilyType
{
_Element = { Index = familyTypeElement.Index },
_Family = { Index = family.Index }
});
}).Entity;
}

/// <summary>
Expand All @@ -140,15 +141,15 @@ private FamilyType StoreDefaultFamilyType(
private BimDocument StoreGltfModel(string gltfFilePath, SharpGLTF.Schema2.ModelRoot gltfModel, Category category)
{
// Create a BIM document representing the GLTF model.
var bimDocument = ObjectModelBuilder.Add(new BimDocument
var bimDocument = ObjectModelBuilder.BimDocumentBuilder.Add(new BimDocument
{
Title = Path.GetFileNameWithoutExtension(gltfFilePath),
Name = Path.GetFileName(gltfFilePath),
PathName = gltfFilePath,
});
}).Entity;

// Create an element to hold the BIM document's parameters.
var elementEntity = ObjectModelBuilder.Add(bimDocument.CreateParameterHolderElement());
var elementEntity = ObjectModelBuilder.ElementBuilder.Add(bimDocument.CreateParameterHolderElement()).Entity;
elementEntity._Category.Index = category.Index;
elementEntity._BimDocument.Index = bimDocument.Index;
bimDocument._Element.Index = elementEntity.Index;
Expand All @@ -167,14 +168,14 @@ private BimDocument StoreGltfModel(string gltfFilePath, SharpGLTF.Schema2.ModelR
private void StoreParameter(Element elementEntity, string name, string value)
{
// Get (or add) the cached parameter descriptor associated with the name.
var parameterDescriptor = ObjectModelBuilder.GetOrAdd(name, _ => new ParameterDescriptor()
var parameterDescriptor = ObjectModelBuilder.ParameterDescriptorBuilder.GetOrAdd(name, _ => new ParameterDescriptor()
{
Name = name,
_DisplayUnit = { Index = _defaultDisplayUnit.Index },
}).Entity;

// Store the parameter value. We use AddUntracked because it doesn't waste time doing a cache lookup.
ObjectModelBuilder.AddUntracked(new Parameter
ObjectModelBuilder.ParameterBuilder.AddUntracked(new Parameter
{
Values = (value, value),
_ParameterDescriptor = { Index = parameterDescriptor.Index },
Expand All @@ -191,15 +192,15 @@ private void StoreGltfScene(
Category category)
{
// For illustrative purposes, we'll convert a GLTF scene into a Site entity.
var siteElement = ObjectModelBuilder.Add(new Element()
var siteElement = ObjectModelBuilder.ElementBuilder.Add(new Element()
{
Id = gltfScene.LogicalIndex,
Name = gltfScene.Name,
_BimDocument = { Index = bimDocument.Index },
_Category = { Index = category.Index },
});
}).Entity;

ObjectModelBuilder.Add(new Site
ObjectModelBuilder.SiteBuilder.Add(new Site
{
_Element = { Index = siteElement.Index }
});
Expand Down Expand Up @@ -232,21 +233,21 @@ private void StoreGltfNode(
FamilyType familyType)
{
// Create the element associated to the node.
var familyInstanceElement = ObjectModelBuilder.Add(new Element
var familyInstanceElement = ObjectModelBuilder.ElementBuilder.Add(new Element
{
Id = gltfNode.LogicalIndex,
Name = gltfNode.Name,
_BimDocument = { Index = bimDocument.Index },
_Category = { Index = category.Index },
});
}).Entity;

// Store some sample parameters related to the GLTF node.
StoreParameter(familyInstanceElement, nameof(gltfNode.IsSkinJoint), gltfNode.IsSkinJoint.ToString());
StoreParameter(familyInstanceElement, nameof(gltfNode.IsSkinSkeleton), gltfNode.IsSkinSkeleton.ToString());
StoreParameter(familyInstanceElement, nameof(gltfNode.IsTransformAnimated), gltfNode.IsTransformAnimated.ToString());

// Create a family instance pointing to the element and family type.
ObjectModelBuilder.Add(new FamilyInstance
ObjectModelBuilder.FamilyInstanceBuilder.Add(new FamilyInstance
{
_Element = { Index = familyInstanceElement.Index },
_FamilyType = { Index = familyType.Index }
Expand All @@ -268,7 +269,7 @@ private void StoreGltfNode(

// Store the node associated to the geometric instance.
// This ordered 1:1 relationship connects the entities with the geometric instances.
ObjectModelBuilder.Add(new Vim.Format.ObjectModel.Node
ObjectModelBuilder.NodeBuilder.Add(new Vim.Format.ObjectModel.Node
{
_Element = { Index = familyInstanceElement.Index },
});
Expand Down Expand Up @@ -368,9 +369,9 @@ private int StoreGltfMaterial(
BimDocument bimDocument,
Category category)
{
var getOrAddResult = ObjectModelBuilder.GetOrAdd(
var getOrAddResult = ObjectModelBuilder.MaterialBuilder.GetOrAdd(
gltfMaterial.LogicalIndex,
_ =>
() =>
{
var maybeChannel = gltfMaterial.FindChannel("BaseColor") ?? gltfMaterial.FindChannel("Diffuse");
if (maybeChannel == null)
Expand All @@ -388,13 +389,13 @@ private int StoreGltfMaterial(
return materialIndex; // If the GetOrAdd operation already contained the material, then return early.

// The material entity was just added so apply an Element to it.
var materialElement = ObjectModelBuilder.Add(new Element()
var materialElement = ObjectModelBuilder.ElementBuilder.Add(new Element()
{
Id = VimConstants.SyntheticElementId,
Name = gltfMaterial.Name,
_BimDocument = { Index = bimDocument.Index },
_Category = { Index = category.Index },
});
}).Entity;

// Connect the material entity to the element we created.
material._Element.Index = materialElement.Index;
Expand Down
4 changes: 2 additions & 2 deletions src/cs/samples/Vim.Gltf.Converter/VimToGltfStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ namespace Vim.Gltf.Converter
/// </summary>
public class VimToGltfStore
{
public const float FeetToMeters = 1.0f / 3.280839895f;


/// <summary>
/// Converts the given VIM file into a GLTF (.glb) file.
/// </summary>
public static void Convert(string vimFilePath, string gltfFilePath, float scale = FeetToMeters, bool validateGltf = true)
public static void Convert(string vimFilePath, string gltfFilePath, float scale = (float) Util.Units.FeetToMetersRatio, bool validateGltf = true)
{
var vim = VimScene.LoadVim(vimFilePath);

Expand Down
49 changes: 0 additions & 49 deletions src/cs/util/Vim.Util.Tests/FeetAndInchParsingTests.cs

This file was deleted.

Loading
Loading