OBB Class

The OBB class represents an oriented 3d bounding box.
Inheritance Hierarchy
SystemObject
  Tekla.Structures.Geometry3dOBB

Namespace:  Tekla.Structures.Geometry3d
Assembly:  Tekla.Structures (in Tekla.Structures.dll) Version: 2023.0.3
Syntax
[SerializableAttribute]
public sealed class OBB : IEquatable<OBB>

The OBB type exposes the following members.

Constructors
Properties
  NameDescription
Public propertyAxis0
Gets an axis parallel to one side of the OBB, a unit-length vector orthogonal to Axis1 and Axis2.
Public propertyAxis1
Gets an axis parallel to the second side of the OBB, a unit-length vector orthogonal to Axis0 and Axis2.
Public propertyAxis2
Gets an axis parallel to the third side of the OBB, a unit-length vector orthogonal to Axis0 and Axis1.
Public propertyCenter
Gets or sets the center point of the box.
Public propertyExtent0
Gets or sets the extent parallel to Axis0.
Public propertyExtent1
Gets or sets the extent parallel to Axis1.
Public propertyExtent2
Gets or sets the extent parallel to Axis2.
Top
Methods
  NameDescription
Public methodClosestPointTo(Line)
Calculates the closest point in OBB to given Line.
Public methodClosestPointTo(LineSegment)
Calculates the closest point in OBB to given LineSegment.
Public methodClosestPointTo(Point)
Calculates the closest point in OBB to given point.
Public methodComputeVertices
Calculates the corner points of the OBB.
Public methodDistanceTo(Line)
Calculates the distance from OBB to given Line.
Public methodDistanceTo(LineSegment)
Calculates the distance from OBB to given LineSegment.
Public methodDistanceTo(Point)
Calculates the distance from OBB to given point.
Public methodEquals(Object)
Tests for the exact equality of two OBBs.
(Overrides ObjectEquals(Object).)
Public methodEquals(OBB)
Tests for the exact equality of two OBBs.
Public methodGetHashCode
Gets the hash code for the obb.
(Overrides ObjectGetHashCode.)
Public methodIntersectionPointsWith(Line)
Calculates the intersection points between OBB and given Line.
Public methodIntersectionPointsWith(LineSegment)
Calculates the intersection points between OBB and given LineSegment.
Public methodIntersectionWith(Line)
Creates an intersection between the OBB and the given Line.
Public methodIntersectionWith(LineSegment)
Creates an intersection between the OBB and the given LineSegment.
Public methodIntersects(GeometricPlane)
Tests if current OBB intersects with the given GeometricPlane
Public methodIntersects(Line)
Tests if current OBB intersects with the given Line
Public methodIntersects(LineSegment)
Tests if current OBB intersects with the given LineSegment
Public methodIntersects(OBB)
Tests if current OBB intersects with the given OBB
Public methodSetAxis(Vector)
Sets the Axis to the OBB.
Public methodSetAxis(Vector, Vector, Vector)
Sets the Axis to the OBB.
Public methodSetExtent(Double)
Sets the extents to the OBB.
Public methodSetExtent(Double, Double, Double)
Sets the extents to the OBB.
Public methodShortestSegmentTo(Line)
Calculates the shortest LineSegment from OBB to the given Line.
Public methodShortestSegmentTo(LineSegment)
Calculates the shortest LineSegment from OBB to the given LineSegment.
Public methodShortestSegmentTo(Point)
Calculates the shortest LineSegment from OBB to the given point.
Top
Examples
using System;
using Tekla.Structures.Geometry3d;
using Tekla.Structures.Model;

public class Example
{
   public void Example1()
   {
        OBB obb = null;

        // In this simplified example, there are two existing beams in the model.
        ModelObjectEnumerator beamsEnumerator =
            TeklaModel.GetModelObjectSelector().GetAllObjectsWithType(ModelObject.ModelObjectEnum.BEAM);

        if (beamsEnumerator != null)
        {
            while (beamsEnumerator.MoveNext())
            {
                Beam beam = beamsEnumerator.Current as Beam;

                if (beam != null)
                {
                    if (obb == null)
                    {
                        obb = CreateOrientedBoundingBox(beam);
                    }
                    else
                    {
                        if (obb.Intersects(CreateOrientedBoundingBox(beam)))
                        {
                            // Boxes intersect.
                        }
                        else
                        {
                            // Boxes did not intersect.
                        }
                    }
                }
            }
        }     
    }

    private Point CalculateCenterPoint(Point min, Point max)
    {
        double x = min.X + ((max.X - min.X) / 2);
        double y = min.Y + ((max.Y - min.Y) / 2);
        double z = min.Z + ((max.Z - min.Z) / 2);

        return new Point(x, y, z);
    }

    private OBB CreateOrientedBoundingBox(Beam beam)
    {
        OBB obb = null;

        if (beam != null)
        {
            WorkPlaneHandler workPlaneHandler = TeklaModel.GetWorkPlaneHandler();
            TransformationPlane originalTransformationPlane = workPlaneHandler.GetCurrentTransformationPlane();

            Solid solid = beam.GetSolid();
            Point minPointInCurrentPlane = solid.MinimumPoint;
            Point maxPointInCurrentPlane = solid.MaximumPoint;

            Point centerPoint = CalculateCenterPoint(minPointInCurrentPlane, maxPointInCurrentPlane);

            CoordinateSystem coordSys = beam.GetCoordinateSystem();
            TransformationPlane localTransformationPlane = new TransformationPlane(coordSys);
            workPlaneHandler.SetCurrentTransformationPlane(localTransformationPlane);

            solid = beam.GetSolid();
            Point minPoint = solid.MinimumPoint;
            Point maxPoint = solid.MaximumPoint;
            double extent0 = (maxPoint.X - minPoint.X) / 2;
            double extent1 = (maxPoint.Y - minPoint.Y) / 2;
            double extent2 = (maxPoint.Z - minPoint.Z) / 2;

            workPlaneHandler.SetCurrentTransformationPlane(originalTransformationPlane);

            obb = new OBB(centerPoint, coordSys.AxisX, coordSys.AxisY,
                            coordSys.AxisX.Cross(coordSys.AxisY), extent0, extent1, extent2);
        }

        return obb;
    }
}
See Also
Was this helpful?
The feedback you give here is not visible to other users. We use your comments to improve the content.
Previous
Next