Tekla Open API

Detailed and full API reference helps you master Tekla Open API

This is the most recent version of Tekla Open API.
For older versions, please visit Tekla Warehouse.

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: 2018.1.0.0 (2018.1.0.0)
Syntax
[SerializableAttribute]
public sealed class OBB : IEquatable<OBB>

The OBB type exposes the following members.

Constructors
Properties
  Name Description
Public property Axis0
Gets an axis parallel to one side of the OBB, a unit-length vector orthogonal to Axis1 and Axis2.
Public property Axis1
Gets an axis parallel to the second side of the OBB, a unit-length vector orthogonal to Axis0 and Axis2.
Public property Axis2
Gets an axis parallel to the third side of the OBB, a unit-length vector orthogonal to Axis0 and Axis1.
Public property Center
Gets or sets the center point of the box.
Public property Extent0
Gets or sets the extent parallel to Axis0.
Public property Extent1
Gets or sets the extent parallel to Axis1.
Public property Extent2
Gets or sets the extent parallel to Axis2.
Top
Methods
  Name Description
Public method ClosestPointTo(Line)
Calculates the closest point in OBB to given Line.
Public method ClosestPointTo(LineSegment)
Calculates the closest point in OBB to given LineSegment.
Public method ClosestPointTo(Point)
Calculates the closest point in OBB to given point.
Public method ComputeVertices
Calculates the corner points of the OBB.
Public method DistanceTo(Line)
Calculates the distance from OBB to given Line.
Public method DistanceTo(LineSegment)
Calculates the distance from OBB to given LineSegment.
Public method DistanceTo(Point)
Calculates the distance from OBB to given point.
Public method Equals(Object)
Tests for the exact equality of two OBBs.
(Overrides ObjectEquals(Object).)
Public method Equals(OBB)
Tests for the exact equality of two OBBs.
Public method GetHashCode
Gets the hash code for the obb.
(Overrides ObjectGetHashCode.)
Public method IntersectionPointsWith(Line)
Calculates the intersection points between OBB and given Line.
Public method IntersectionPointsWith(LineSegment)
Calculates the intersection points between OBB and given LineSegment.
Public method IntersectionWith(Line)
Creates an intersection between the OBB and the given Line.
Public method IntersectionWith(LineSegment)
Creates an intersection between the OBB and the given LineSegment.
Public method Intersects(GeometricPlane)
Tests if current OBB intersects with the given GeometricPlane
Public method Intersects(Line)
Tests if current OBB intersects with the given Line
Public method Intersects(LineSegment)
Tests if current OBB intersects with the given LineSegment
Public method Intersects(OBB)
Tests if current OBB intersects with the given OBB
Public method SetAxis(Vector)
Sets the Axis to the OBB.
Public method SetAxis(Vector, Vector, Vector)
Sets the Axis to the OBB.
Public method SetExtent(Double)
Sets the extents to the OBB.
Public method SetExtent(Double, Double, Double)
Sets the extents to the OBB.
Public method ShortestSegmentTo(Line)
Calculates the shortest LineSegment from OBB to the given Line.
Public method ShortestSegmentTo(LineSegment)
Calculates the shortest LineSegment from OBB to the given LineSegment.
Public method ShortestSegmentTo(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