.. role:: ts-api-decorator

##############
CuttingSection
##############

.. container:: ts-api-section

   .. js:class:: CuttingSection

      Object representing an individual cutting section, more information can be found [here](https://docs.techsoft3d.com/communicator/latest/prog_guide/viewing/scene_attributes/cutting-planes.html).
      A cutting section groups up to 6 cutting planes together and behaves independently of other cutting sections.



.. container:: api-index-section

   .. rubric:: Methods

   .. rst-class:: api-index-list-item api-kind-method api-parent-kind-class

   * :js:meth:`~CuttingSection.activate`
   * :js:meth:`~CuttingSection.addPlane`
   * :js:meth:`~CuttingSection.applyPlaneOpacity`
   * :js:meth:`~CuttingSection.clear`
   * :js:meth:`~CuttingSection.deactivate`
   * :js:meth:`~CuttingSection.fromJson`
   * :js:meth:`~CuttingSection.getCount`
   * :js:meth:`~CuttingSection.getNodeId`
   * :js:meth:`~CuttingSection.getPlane`
   * :js:meth:`~CuttingSection.getPlaneIndexByNodeId`
   * :js:meth:`~CuttingSection.getPlaneOpacity`
   * :js:meth:`~CuttingSection.getReferenceGeometry`
   * :js:meth:`~CuttingSection.isActive`
   * :js:meth:`~CuttingSection.removePlane`
   * :js:meth:`~CuttingSection.resetPlanesOpacity`
   * :js:meth:`~CuttingSection.setColor`
   * :js:meth:`~CuttingSection.setOpacity`
   * :js:meth:`~CuttingSection.setPlane`
   * :js:meth:`~CuttingSection.setPlaneOpacity`
   * :js:meth:`~CuttingSection.toJson`
   * :js:meth:`~CuttingSection.updatePlane`





------------

Methods
=======

.. rst-class:: ts-api-section

activate
--------

.. js:method:: CuttingSection.activate()



   Activates a cutting section for use. A cutting section must have at least one plane to be activated.

   :returns: a promise if the cutting section was activated.


   :rtype: Promise <void>

.. rst-class:: ts-api-section

addPlane
--------

.. js:method:: CuttingSection.addPlane( plane, referenceGeometry)

   :param plane: The plane to be used for cutting.
   :type plane: Plane
   :param referenceGeometry: An optional list of four points representing a quad to be used as reference geometry for the cutting plane. Pass null to use no reference geometry for this cutting plane.
   :type referenceGeometry: null | [Point3]


   Adds a plane to the cutting section.


   :rtype: Promise <boolean>

.. rst-class:: ts-api-section

applyPlaneOpacity
-----------------

.. js:method:: CuttingSection.applyPlaneOpacity( index[, opacity])

   :param index: The index of the cutting plane.
   :type index: number
   :param opacity: :ts-api-decorator:`optional` The value used to change the opacity if needed
   :type opacity: number


   Apply the opacity factor to the plane.


   :rtype: void

.. rst-class:: ts-api-section

clear
-----

.. js:method:: CuttingSection.clear()



   Removes all planes from this cutting section. This will also deactivate the cutting section.


   :rtype: Promise <void>

.. rst-class:: ts-api-section

deactivate
----------

.. js:method:: CuttingSection.deactivate()



   Removes a cutting section from use.


   :rtype: Promise <void>

.. rst-class:: ts-api-section

fromJson
--------

.. js:method:: CuttingSection.fromJson( json)

   :param json: None
   :type json: object


   :rtype: Promise <void>

.. rst-class:: ts-api-section

getCount
--------

.. js:method:: CuttingSection.getCount()



   Gets the number of planes in this cutting secton.

   :returns: the number of planes in this cutting section


   :rtype: number

.. rst-class:: ts-api-section

getNodeId
---------

.. js:method:: CuttingSection.getNodeId( index)

   :param index: the index of the cutting plane.
   :type index: number


   Gets the [[NodeId]] for the reference geometry for the cutting plane at the given index.
   In the case of an invalid index or a cutting plane with no reference geometry, null will be returned.

   :returns: [[NodeId]] of the reference geometry for the cutting plane at the given index or null.


   :rtype: null | number

.. rst-class:: ts-api-section

getPlane
--------

.. js:method:: CuttingSection.getPlane( index)

   :param index: The index of the cutting plane.
   :type index: number


   Gets the plane for the item at the given index. In the case of an invalid index, null will be returned.

   :returns: Plane that is used for cutting at the given index or null.


   :rtype: null | Plane

.. rst-class:: ts-api-section

getPlaneIndexByNodeId
---------------------

.. js:method:: CuttingSection.getPlaneIndexByNodeId( id)

   :param id: The [[NodeId]] for the plane reference geometry.
   :type id: number


   Gets the index of a plane for the corresponding node id. In the case of an invalid id, null will be returned.

   :returns: The index of a plane associated with the provided [[NodeId]], or null if no plane is found.


   :rtype: null | number

.. rst-class:: ts-api-section

getPlaneOpacity
---------------

.. js:method:: CuttingSection.getPlaneOpacity( index)

   :param index: The index of the cutting plane.
   :type index: number


   Gets the opacity for the plane at the given index.


   :rtype: undefined | number

.. rst-class:: ts-api-section

getReferenceGeometry
--------------------

.. js:method:: CuttingSection.getReferenceGeometry( index)

   :param index: The index of the cutting plane.
   :type index: number


   Gets the reference geometry for the item at the given index. In the case of an invalid index, null will be returned

   :returns: A list of four points representing a quad to be used as reference geometry for the cutting plane, or null if there is no reference geometry.


   :rtype: null | [Point3]

.. rst-class:: ts-api-section

isActive
--------

.. js:method:: CuttingSection.isActive()



   Gets whether a cutting section is active

   :returns: boolean value indicating whether this cutting section is active


   :rtype: boolean

.. rst-class:: ts-api-section

removePlane
-----------

.. js:method:: CuttingSection.removePlane( index)

   :param index: The index of the cutting plane to remove.
   :type index: number


   Removes the cutting plane at the specified index.


   :rtype: Promise <void>

.. rst-class:: ts-api-section

resetPlanesOpacity
------------------

.. js:method:: CuttingSection.resetPlanesOpacity()



   Reapply the opacity of the cutting planes to the engine
   This function must be explicitly called after _resetOpacity has been emitted by the engine


   :rtype: void

.. rst-class:: ts-api-section

setColor
--------

.. js:method:: CuttingSection.setColor( color)

   :param color: Color to set
   :type color: Color


   Sets the color for all planes in the cutting section

   :returns: Promise that resolves when the operation has completed.


   :rtype: Promise <void>

.. rst-class:: ts-api-section

setOpacity
----------

.. js:method:: CuttingSection.setOpacity( opacity)

   :param opacity: opacity to set
   :type opacity: number


   Sets the opacity for all planes in the cutting section


   :rtype: void

.. rst-class:: ts-api-section

setPlane
--------

.. js:method:: CuttingSection.setPlane( index, plane, referenceGeometry)

   :param index: The index of the cutting plane to replace.
   :type index: number
   :param plane: The plane to be used for cutting.
   :type plane: Plane
   :param referenceGeometry: a list of four points representing a quad to be used as reference geometry for the cutting plane. Pass null to use no reference geometry for this cutting plane.
   :type referenceGeometry: null | [Point3]


   Sets a plane currently in the cutting section at a given index.


   :rtype: Promise <void>

.. rst-class:: ts-api-section

setPlaneOpacity
---------------

.. js:method:: CuttingSection.setPlaneOpacity( index, opacity)

   :param index: The index of the cutting plane.
   :type index: number
   :param opacity: A number between 0 and 1.
   :type opacity: number


   Sets the opacity for the plane at the given index.

   Equivalent to ``section.applyPlaneOpacity(index, opacity)``


   :rtype: void

.. rst-class:: ts-api-section

toJson
------

.. js:method:: CuttingSection.toJson()



   Creates an object ready for JSON serialization.

   :returns: The prepared object.


   :rtype: object

.. rst-class:: ts-api-section

updatePlane
-----------

.. js:method:: CuttingSection.updatePlane( index, plane, geometryMatrix, finalizePosition, resetTranslation)

   :param index: The index of the cutting plane.
   :type index: number
   :param plane: The plane to use for cutting.
   :type plane: Plane
   :param geometryMatrix: A matrix that is multiplied by the previous position matrix to update the geometry position.
   :type geometryMatrix: Matrix
   :param finalizePosition: If true, sets the result of the geometry matrix multiplication as the new position matrix.
   :type finalizePosition: boolean
   :param resetTranslation: If true, uses the provided geometry matrix for the geometry position.
   :type resetTranslation: boolean


   Updates the position of a cutting plane and stand-in geometry if present.


   :rtype: Promise <void>

