Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
7 changes: 4 additions & 3 deletions Xbim.Common/Geometry/IXbimGeometryObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,9 @@ public interface IXbimGeometryObject : IDisposable
/// Gets or sets an arbitrary object value that can be used to store custom information about this element
/// </summary>
object Tag { get; set; }



/// <summary>
/// Returns the volume which is closed and valid, if there's an existing closed shell.
/// </summary>
double? Volume { get; }
}
}
5 changes: 4 additions & 1 deletion Xbim.Common/Geometry/IXbimGeometryObjectSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,10 @@ public interface IXbimGeometryObjectSet : IEnumerable<IXbimGeometryObject>, IXbi
/// Converts the object to a string in BRep format
/// </summary>
String ToBRep { get; }

/// <summary>
/// Returns the partial volume of the set which is closed and valid.
/// </summary>
double VolumeValid { get; }
}

}
5 changes: 5 additions & 0 deletions Xbim.Common/Geometry/IXbimShapeGeometryData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,10 @@ public interface IXbimShapeGeometryData
/// LocalShapeDisplacement and should be added to placement of the shape in the product.
/// </summary>
IVector3D LocalShapeDisplacement { get; }

/// <summary>
/// Returns the volume which is closed and valid, if there's an existing closed shell.
/// </summary>
double? Volume { get; }
}
}
5 changes: 5 additions & 0 deletions Xbim.Common/Geometry/IXbimShellSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,10 @@ public interface IXbimShellSet : IEnumerable<IXbimShell>, IXbimGeometryObject
/// </summary>
/// <param name="tolerance"></param>
void Union(double tolerance);

/// <summary>
/// Returns the partial volume of the set which is closed and valid.
/// </summary>
double VolumeValid { get; }
}
}
3 changes: 1 addition & 2 deletions Xbim.Common/Geometry/IXbimSolid.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ public interface IXbimSolid : IXbimGeometryObject, IEquatable<IXbimSolid>
IXbimShellSet Shells { get; }
IXbimFaceSet Faces { get; }
IXbimEdgeSet Edges { get; }
IXbimVertexSet Vertices { get; }
double Volume { get; }
IXbimVertexSet Vertices { get; }
double SurfaceArea { get; }
bool IsPolyhedron { get; }
IXbimSolidSet Cut(IXbimSolidSet toCut, double tolerance, ILogger logger=null);
Expand Down
4 changes: 4 additions & 0 deletions Xbim.Common/Geometry/IXbimSolidSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,9 @@ public interface IXbimSolidSet : IEnumerable<IXbimSolid>, IXbimGeometryObject
/// Converts the object to a string in BRep format
/// </summary>
String ToBRep { get; }
/// <summary>
/// Returns the partial volume of the set which is closed and valid.
/// </summary>
double VolumeValid { get; }
}
}
6 changes: 6 additions & 0 deletions Xbim.Common/Geometry/XbimRegionCollection.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;
using System.IO.Compression;
Expand Down Expand Up @@ -282,5 +283,10 @@ byte[] IXbimShapeGeometryData.ShapeData
}

IVector3D IXbimShapeGeometryData.LocalShapeDisplacement => null;

///<summary>
///Returns the sum of bounding box volumes of this region collection.
///</summary>
public double? Volume => this.Select(r => r.ToXbimRect3D().Volume).Sum();
}
}
14 changes: 13 additions & 1 deletion Xbim.Common/Geometry/XbimShapeGeometry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,10 @@ public IEnumerable<WexBimMeshFace> Faces
/// </summary>
byte[] _shapeData;

/// <summary>
/// The volume if available
/// </summary>
double? _volume;


/// <summary>
Expand Down Expand Up @@ -410,7 +414,15 @@ public override string ToString()
IVector3D IXbimShapeGeometryData.LocalShapeDisplacement => LocalShapeDisplacement;
public XbimVector3D? LocalShapeDisplacement { get; set; }


public double? Volume
{
get {
return _volume;
}
set {
_volume = value;
}
}
}

public class WexBimMeshFace
Expand Down
20 changes: 19 additions & 1 deletion Xbim.Tessellator/MeshUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@
using System.Collections.Generic;
using System.Diagnostics;

using Xbim.Common.Geometry;
using Xbim.Common.XbimExtensions;
using Xbim.Ifc4.MeasureResource;

namespace Xbim.Tessellator
{
public struct Vec3EqualityComparer : IEqualityComparer<Vec3>
Expand Down Expand Up @@ -106,7 +110,19 @@ public static bool Colinear( Vec3 a, Vec3 b, Vec3 c)
// ReSharper restore CompareOfFloatsByEqualityOperator
}


public Vec3(XbimTriplet<IfcParameterValue> triple)
{
X = triple.A;
Y = triple.B;
Z = triple.C;
}

public Vec3(XbimPoint3D p)
{
X = p.X;
Y = p.Y;
Z = p.Z;
}

public Vec3(double x, double y, double z)
{
Expand Down Expand Up @@ -151,6 +167,7 @@ public bool IsValid
{
get { return Length2 > 0; }
}

public static double Angle(ref Vec3 v1, ref Vec3 v2)
{
double cosinus;
Expand All @@ -163,6 +180,7 @@ public static double Angle(ref Vec3 v1, ref Vec3 v2)
if (cosinus < 0.0) return Math.PI - Math.Asin(sinus);
return Math.Asin(sinus);
}

public static void Neg(ref Vec3 v)
{
v.X = -v.X;
Expand Down
Loading