Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues/issue465 #1

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageId>Xbim.Geometry.Engine.Interop</PackageId>
<PackageIcon>xbim-toolkit-icon.png</PackageIcon>
<Version>5.1.437</Version>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.1" />
<PackageReference Include="System.Threading.Tasks" Version="4.3.0" />
<PackageReference Include="Xbim.Tessellator" Version="5.1.314" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.1" />
<PackageReference Include="System.Threading.Tasks" Version="4.3.0" />
<PackageReference Include="Xbim.Ifc" Version="5.1.341" />
<PackageReference Include="Xbim.Tessellator" Version="5.1.341" />
</ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion Xbim.Geometry.Regression/XbimRegression.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="2.1.1" />
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="2.1.1" />
<PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="NReco.Logging.File" Version="1.0.4" />
<PackageReference Include="Xbim.Ifc" Version="5.1.341" />
<PackageReference Include="Xbim.IO.Esent" Version="5.1.341" />
Expand Down
2 changes: 1 addition & 1 deletion Xbim.ModelGeometry.Scene/Xbim.ModelGeometry.Scene.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<EnableUnmanagedDebugging>true</EnableUnmanagedDebugging>
<PackageIcon>xbim-toolkit-icon.png</PackageIcon>
<Version>5.1.0.0-Dev</Version>
<Version>5.1.437</Version>
<AssemblyVersion>5.1.0.1</AssemblyVersion>
<FileVersion>5.1.0.1</FileVersion>
</PropertyGroup>
Expand Down
19 changes: 18 additions & 1 deletion Xbim.ModelGeometry.Scene/Xbim3DModelContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
using Xbim.Common.Exceptions;
using Xbim.Common.Geometry;
using Xbim.Geometry.Engine.Interop;
using Xbim.Ifc4;
using Xbim.Ifc4.Interfaces;
using Xbim.ModelGeometry.Scene.Clustering;
using Xbim.ModelGeometry.Scene.Extensions;
Expand Down Expand Up @@ -155,6 +156,7 @@ private struct GeometryReference
{
public XbimRect3D BoundingBox;
public int GeometryId;
public int EdgeId;
public int StyleLabel;
public XbimVector3D? LocalShapeDisplacement;
}
Expand Down Expand Up @@ -951,6 +953,7 @@ private HashSet<int> WriteProductsWithFeatures(XbimCreateContextHelper contextHe
{
using (var bw = new BinaryWriter(memStream))
{

Engine.WriteTriangulation(bw, geom, mf.Precision,
thisDeflectionDistance, thisDeflectionAngle);
}
Expand Down Expand Up @@ -1320,6 +1323,7 @@ private void WriteShapeGeometries(XbimCreateContextHelper contextHelper, ReportP
{
BoundingBox = (shapeGeom).BoundingBox,
GeometryId = geometryStore.AddShapeGeometry(shapeGeom),

// if shape had large coordinates these might be reduced. This represents the
// local displacement of the shape. It needs to be applied to shape (and bounding box) placement in the product.
LocalShapeDisplacement = shapeGeom.LocalShapeDisplacement
Expand Down Expand Up @@ -1367,16 +1371,19 @@ private void WriteShapeGeometries(XbimCreateContextHelper contextHelper, ReportP

// Console.WriteLine(shape.GetType().Name);
XbimShapeGeometry shapeGeom = null;
IXbimSolid xSolid = null;
IXbimGeometryObject geomModel = null;
if (!isFeatureElementShape && !isVoidedProductShape && xbimTessellator.CanMesh(shape)) // if we can mesh the shape directly just do it
{
shapeGeom = xbimTessellator.Mesh(shape);

}
else //we need to create a geometry object
{
try
{
geomModel = Engine.Create(shape, _logger);

}
catch (XbimGeometryFaceSetTooLargeException fse)
{
Expand All @@ -1389,8 +1396,14 @@ private void WriteShapeGeometries(XbimCreateContextHelper contextHelper, ReportP
}
if (geomModel != null && geomModel.IsValid)
{
if(!geomModel.IsSet)
{
xSolid = geomModel as IXbimSolid;
}

shapeGeom = Engine.CreateShapeGeometry(geomModel, precision, deflection, deflectionAngle, geomStorageType, _logger);


if (isFeatureElementShape)
{
var geomSet = geomModel as IXbimGeometryObjectSet;
Expand All @@ -1413,10 +1426,13 @@ private void WriteShapeGeometries(XbimCreateContextHelper contextHelper, ReportP
else
{
shapeGeom.IfcShapeLabel = shapeId;
var geomId = geometryStore.AddShapeGeometry(shapeGeom);

var reference = new GeometryReference
{
BoundingBox = shapeGeom.BoundingBox,
GeometryId = geometryStore.AddShapeGeometry(shapeGeom),
GeometryId = geomId,
EdgeId = xSolid != null ? geometryStore.AddEdgeGeometry(Model.Instances[shapeId].EntityLabel, xSolid.Edges) : -1,
// if shape had large coordinates these might be reduced. This represents the
// local displacement of the shape. It needs to be applied to shape (and bounding box) placement in the product.
// This is often the case for already triangulated geometry from infrastructure tools like Bentley.
Expand All @@ -1432,6 +1448,7 @@ private void WriteShapeGeometries(XbimCreateContextHelper contextHelper, ReportP
//keep a record of the IFC label and database record mapping
contextHelper.GeometryShapeLookup.TryAdd(shapeGeom.ShapeLabel, shapeGeom.IfcShapeLabel);
}


// shapeGeometries.Add(shapeGeom);
}
Expand Down