=====
Lines
=====

In HOOPS Visualize Desktop, all lines are polylines, even if they consist of one segment. Like other geometry, the line object has a ``HPS::LineKey`` and ``HPS::LineKit``. Lines can also be specified without a kit using a ``PointArray`` object as shown below:

.. tabs::

	.. group-tab:: C++
	
		.. literalinclude:: ../../../internals/tests/docs/source/cpp/00700_lines.cpp
		   :start-after: //! [0204_a]
		   :end-before: //! [0204_a]
		   
	.. group-tab:: C#

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_lines.cs
		   :start-after: //! [0204_a]
		   :end-before: //! [0204_a]
		   
.. image:: images/two_segment_polyline.png

*A two-segment polyline*

Note that polylines are not assumed to be closed, so if a closed shape is desired, it must be explicitly specified.

Segment-level line attributes are set using the ``HPS::LineAttributeControl``. These attributes include line weight and pattern. The line above was rendered with a weight of 2. (See the chapter on :doc:`pattern <0406_line_patterns>` for more information about this topic.)

.. tabs::

	.. group-tab:: C++
	
		.. literalinclude:: ../../../internals/tests/docs/source/cpp/00700_lines.cpp
		   :start-after: //! [0204_b]
		   :end-before: //! [0204_b]
		   
	.. group-tab:: C#

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_lines.cs
		   :start-after: //! [0204_b]
		   :end-before: //! [0204_b]


.. _infinite:

Infinite Lines
==============

Infinite lines have no start or end point. They extend indefinitely into space. To draw an infinite line, call ``InsertInfiniteLine`` using your ``HPS::SegmentKey``. Two points along the line are needed. Note that the type of infinite line (``HPS::InfiniteLine`` or ``HPS::Ray``) must be specified. The different colors are set at the segment level using the segment key's ``HPS::MaterialMappingControl``. Continuing from the example above: 

.. tabs::

	.. group-tab:: C++
	
		.. literalinclude:: ../../../internals/tests/docs/source/cpp/00700_infinite_line.cpp
		   :start-after: //! [infinite_line]
		   :end-before: //! [infinite_line]
		   
	.. group-tab:: C#

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_infinite_line.cs
		   :start-after: //! [infinite_line]
		   :end-before: //! [infinite_line]

.. image:: images/infinite_line.png

*The infinite line drawn over the first polyline*

Note that infinite lines are considered unbounded geometry. Thus, they will be ignored in bounding calculations.


Rays
====

Rays are a type of infinite line. Just like the infinite line, two points are needed in order to insert it. However, in the case of the ray, the first point specified acts as the starting point of the ray. The other end extends indefinitely into space. The only other difference between the two is that the object type is set to ``HPS::InfiniteLine::Ray``.

.. tabs::

	.. group-tab:: C++
	
		.. literalinclude:: ../../../internals/tests/docs/source/cpp/00700_ray.cpp
		   :start-after: //! [ray]
		   :end-before: //! [ray]
		   
	.. group-tab:: C#

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_ray.cs
		   :start-after: //! [ray]
		   :end-before: //! [ray]
		   
.. image:: images/ray.png

*Rays are unbounded on one end*

Note that rays are considered unbounded geometry. Thus, they will be ignored in bounding calculations.


.. _editing:

Editing Lines
=============

Sometimes it is more desirable to edit a line in place instead of deleting and recreating it. HOOPS Visualize Desktop allows editing of line points through the use of a kit or through direct action on the key. Legal edits include inserting a point into the line, deleting points, and modifying points. In the example below, the position of the first point from the original blue polyline has been modified, then the polygon is closed by inserting a new point at the end of the point list.

.. tabs::

	.. group-tab:: C++
	
		.. literalinclude:: ../../../internals/tests/docs/source/cpp/00700_editing_lines.cpp
		   :start-after: //! [editing_lines]
		   :end-before: //! [editing_lines]
		   
	.. group-tab:: C#

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_editing_lines.cs
		   :start-after: //! [editing_lines]
		   :end-before: //! [editing_lines]
		   
.. image:: images/edited_line.png

*The blue edited polyline*

Infinite lines and rays can also be modified by calling ``SetFirst`` or ``SetSecond`` again.


.. _endcaps_joins:

End Caps and Joins
==================

Often, it is desirable to show a symbol as a line endpoint. Any :doc:`glyph <0405_glyphs>` can be used for this purpose. For example, to set the endpoints, use a ``HPS::LinePatternOptionsKit`` to set the start and end caps:

.. tabs::

	.. group-tab:: C++
	
		.. literalinclude:: ../../../internals/tests/docs/source/cpp/00700_end_caps_joins.cpp
		   :start-after: //! [end_caps_joins]
		   :end-before: //! [end_caps_joins]
		   
	.. group-tab:: C#

		.. literalinclude:: ../../../internals/tests/docs/source/cs/00700_end_caps_joins.cs
		   :start-after: //! [end_caps_joins]
		   :end-before: //! [end_caps_joins]
		   
HOOPS Visualize Desktop also supports joining of lines by styling the intersection of line segments. Three styles are offered: ``HPS::LinePattern::Join::Bevel``, ``HPS::LinePattern::Join::Mitre`` (the default), and ``HPS::LinePattern::Join::Round``. The image below shows each join, respectively.

.. image:: images/endcaps_joins.png

*A two-segment polyline showing start and end caps as well as the different types of joins offered by this HOOPS product*


Arrowheads
----------

In engineering drawings, arrowheads are a common endpoint to a line segment. In HOOPS Visualize Desktop, arrowheads are a type of line end cap. The ``HPS::Glyph::Default::SolidTriangleLeft`` and ``HPS::Glyph::Default::SolidTriangleRight`` glyphs are commonly used as arrowheads. All of the predefined glyphs can be found in :doc:`the appendix <appendix_default_glyphs>`.

