Line segment objects are represented by the OdGeLineSeg2d and OdGeLineSeg3d classes and inherit the functionality
of the OdGeLinearEnt2d and OdGeLinearEnt3d classes respectively. This topic demonstrates the most common operations
with line segments as an object of the OdGeLineSeg3d class. The functionality of 2D line segment objects is similar.
For creation of a line object you can use one of the OdGeLineSeg3d() constructors:
OdGeLineSeg3d::OdGeLineSeg3d() — Default constructor. Creates a line segment with the start point at (0,0,0) and the end point at (1,0,0).
OdGeLineSeg3d::OdGeLineSeg3d(const OdGeLineSeg3d& source) — Creates a line segment cloned from the source object.
OdGeLineSeg3d::OdGeLineSeg3d(const OdGePoint3d& point, const OdGeVector3d& vect) — Creates a line segment between the point and point + vect. Vect must have non-zero length.
OdGeLineSeg3d::OdGeLineSeg3d(const OdGePoint3d& point1, const OdGePoint3d& point2) — Creates a line segment between non-coincident point1 and point2.
The startPoint() method returns the start point of the line segment:
OdGePoint3d point1 = seg1.startPoint();
The endPoint() method returns the end point of the line segment:
OdGePoint3d point1 = seg1.endPoint();
The midPoint() method returns the middle point of the line segment:
OdGePoint3d point1 = seg1.midPoint();
The baryComb() method returns the point of the line segment calculated as the weighted average of the start and endpoints depending on the input weight parameter blendCoeff. If blendCoeff is 0.0, this function returns the start point of the line segment. If blendCoeff is 1.0, this function returns the endpoint of the line segment. If blendCoeff is between 0.0 and 1.0, the returned point lies on the line segment. For example, to get the middle point of the line segment :
OdGePoint3d point1 = seg1.baryComb(0.5);
If the parameter is out of 1...0 the returned point is on the indefinite line that is coincident with the line segment.
The pointOnLine() method returns an arbitrary point of the line segment:
OdGePoint3d point1 = seg1.pointOnLine();
The direction() method returns the direction vector of the line segment:
OdGeVector3d direction = seg1.direction();
The distanceTo() method finds the distance to the point on the line segment closest to the specified point or curve: