Drawings SDK Developer Guide > Working with .dwg Files > Working with Entities > Working with Specific Entitites > Working with Lines > Computed Line Properties
Computed Line Properties

The parameter of a line is the distance measured from the start point in drawing units. A positive parameter value defines the distance in the direction towards the end point. A negative parameter value defines the distance in the opposite direction from the end point. A zero value defines the start point. A parameter can be changed in the range from negative infinity to positive infinity, but the practical meaning has the range from zero (start point) to the length of the line (end point). The parameter determines the significant properties computed at its value (features). In examples, the pLine variable stores a pointer to the line object.

Start and End Parameters

The Start and End Parameter properties define the start and end parameters of the line, that is, the available range of its variation. The start parameter is zero by default and defines the start point. The end parameter is the line length by default and defines the end point. A value between the start and end parameters defines a point on the line.

To get the start parameter, use the getStartParam() method which requires a reference to a variable of the Double type in which the start parameter value must be saved as an argument and returns the start value through this argument or an error code as a result. For example:


double vStartParam;
OdResult eRes = pLine->getStartParam(vStartParam);
if(eRes == eOk)
  odPrintConsoleString(L"\nStart parameter = %g", vStartParam);

To get the end parameter, use the getEndParam() method which requires a reference to a variable of the Double type in which the end parameter value must be saved as an argument and returns the end value through this argument or an error code as a result. For example:


double vEndParam;
OdResult eRes = pLine->getEndParam(vEndParam);
if(eRes == eOk)
  odPrintConsoleString(L"\nEnd parameter = %g", vEndParam);

Start and End Points

The Start and End Point properties define the start and end points of the line computed at a parameter in three-dimensional coordinates. The start point is computed at a parameter equal to zero. The end point is computed at a parameter equal to the length. The computed start point coincides with the point specified by the setStartPoint() and startPoint() methods. The computed end point coincides with the point specified by the setEndPoint() and endPoint() methods.

To get the start point computed at a parameter, use the getStartPoint() method which requires a reference to a variable of the OdGePoint3d type in which the start point instance must be saved as an argument and returns the computed three-dimensional point through this argument or an error code as a result. For example:


OdGePoint3d start;
OdResult eRes = pLine->getStartPoint(start);
if(eRes == eOk)
  odPrintConsoleString(L"\nStart point = (%g,%g,%g)", start.x, start.y, start.z);

To get the end point computed at a parameter, use the getEndPoint() method which requires a reference to a variable of the OdGePoint3d type in which the end point instance must be saved as an argument and returns the computed three-dimensional point through this argument or an error code as a result. For example:


OdGePoint3d end;
OdResult eRes = pLine->getEndPoint(end);
if(eRes == eOk)
  odPrintConsoleString(L"\nEnd point = (%g,%g,%g)", end.x, end.y, end.z);

First and Second Derivatives

The First and Second Derivative properties define the first and second derivatives on the point of the line computed at the parameter as vectors in three-dimensional coordinates. Both derivatives are constant for any point of the line. The line object returns the derivatives for any parameter value.

To get the first derivative, use the getFirstDeriv() method which requires a parameter value specifying the point on the line as the first argument of the Double type, requires a reference to a variable of the OdGeVector3d type in which the first derivative vector instance must be saved as the second argument, and returns the computed three-dimensional vector through the second argument or an error code as a result. For example:


OdGeVector3d vecFirst;
OdResult eRes = pLine->getFirstDeriv(vStartParam, vecFirst);
if(eRes == eOk)
  odPrintConsoleString(L"\nFirst derivative vector = (%g,%g,%g)", vecFirst.x, vecFirst.y, vecFirst.z);

To get the second derivative, use the getSecondDeriv() method which requires a parameter value specifying the point on the line as the first argument of the Double type, requires a reference to a variable of the OdGeVector3d type in which the second derivative vector instance must be saved as the second argument, and returns the computed three-dimensional vector through the second argument or an error code as a result. For example:


OdGeVector3d vecSecond;
OdResult eRes = pLine->getSecondDeriv(vEndParam, vecSecond);
if(eRes == eOk)
  odPrintConsoleString(L"\nSecond derivative vector = (%g,%g,%g)", vecSecond.x, vecSecond.y, vecSecond.z);

Distance and Parameter

The Distance property defines the distance along the line from the start point to the point computed at a parameter in drawing units. The line object allows calculating the distance at a parameter and calculating the parameter at a distance.

To get the distance using a parameter, use the getDistAtParam() method which requires a parameter value specifying the point on the line as the first argument of the Double type, requires a reference to a variable of the Double type in which the distance value must be saved as the second argument, and returns the distance through the second argument or an error code as a result. When the parameter is out of range, the method returns the estimated distance. For example:


double vDistance;
OdResult eRes = pLine->getDistAtParam((vEndParam + vStartParam) / 2, vDistance);
if(eRes == eOk)
  odPrintConsoleString(L"\nHalf-length = %g", vDistance);

To compute the line length, use the end parameter value. For example:


double vLength;
OdResult eRes = pLine->getDistAtParam(vEndParam, vLength);
if(eRes == eOk)
  odPrintConsoleString(L"\nLine length = %g", vLength);

To get the parameter using distance, use the getParamAtDist() method which requires a distance value specifying the displacement along the line as the first argument of the Double type, requires a reference to a variable of the Double type in which the parameter value must be saved as the second argument, and returns the parameter corresponding to the distance through the second argument or an error code as a result. The distance must be between zero and the length, otherwise errors occur. For example:


double vParam;
OdResult eRes = pLine->getParamAtDist(vLength / 4, vParam);
if(eRes == eOk)
  odPrintConsoleString(L"\nParameter(length/4) = %g", vParam);

Point and Parameter

The Point property defines a point on the line computed at a parameter in three-dimensional coordinates. The line object allows calculating the point at a parameter and calculating the parameter at a point.

To get the point using a parameter, use the getPointAtParam() method which requires a parameter value specifying the point on the line as the first argument of the Double type, requires a reference to a variable of the OdGePoint3d type in which the point instance must be saved as the second argument, and returns the computed three-dimensional point through the second argument or an error code as a result. When the parameter is out of range, errors occur. For example:


OdGePoint3d middle;
OdResult eRes = pLine->getPointAtParam((vEndParam + vStartParam) / 2, middle);
if(eRes == eOk)
  odPrintConsoleString(L"\nMiddle point = (%g,%g,%g)", middle.x, middle.y, middle.z);

To get the parameter using a point, use the getParamAtPoint() method which requires the point instance of the OdGePoint3d type as the first argument, requires a reference to a variable of the Double type in which the parameter value must be saved as the second argument, and returns the parameter corresponding to the point through the second argument or an error code as a result. When the point is not placed on the line, errors occur. For example:


double vParam;
OdResult eRes = pLine->getParamAtPoint(middle, vParam);
if(eRes == eOk)
  odPrintConsoleString(L"\nParameter = %g", vParam);

Area

The Area property defines the area which is always zero for lines. To get the area, use the getArea() method which requires a reference to a variable of the Double type in which the area value must be saved as an argument and returns the area value through this argument or an error code as a result. For example:


double vArea;
OdResult eRes = pLine->getArea(vArea);
if(eRes == eOk)
  odPrintConsoleString(L"\nArea = %g", vArea);

Note: Other methods inherited from the OdDbCurve class are not overridden in the OdDbLine class.

See Also

Working with Lines

Specific Line Properties

Example of Working with the Line Object

Copyright © 2002 – 2020. Open Design Alliance. All rights reserved.