cee::ug::ElementHighlighter

class ElementHighlighter

Helper class for annotating elements.

Creates MarkupModel triangles to highlight the element surfaces and label to show the element id/index. Also helper methods to get access to data referenced by the given hit item.

Public Functions

ElementHighlighter(const UnstructGridModel *model, vis::MarkupModel *markupModel)

Creates the helper class with the given unstruct model and the markup model.

The add* methods in this class will add items to the given markup model. This class does not remove or modify any existing parts in the markup model, so this needs to be handled outside this class.

void addElementHighlight(const HitItem &item, const Color3f &surfaceColor)

Adds triangles for all surfaces of the element specified by the hit item to the markup model.

The method will create a MarkupPartTriangles part and add it to the markup model. The part will contain a triangulation of all element surfaces on the given element. The part will be given the specified color and will use Polygon Offset so it can be rendered together with the UnstructGridModel and still be visible.

void addElementHighlight(const HitItem &item, const Color3f &surfaceColor, const Color3f &lineColor)

Adds triangles and lines for all surfaces of the element specified by the hit item to the markup model.

The method will create a MarkupPartTriangles part and add it to the markup model. The part will contain a triangulation of all element surfaces on the given element. A [MarkupPartLines] (cee::vis::MarkupPartLines) part drawing the element edges as lines are also added to the model. The parts will be given the specified colors and will use Polygon Offset so it can be rendered together with the UnstructGridModel and still be visible.

void addElementHighlight(const std::vector<HitItem> &items, const Color3f &surfaceColor)

Adds triangles for all surfaces of the elements specified by the hit items to the markup model.

The method will create a single MarkupPartTriangles part and add it to the markup model. The part will contain a triangulation of all element surfaces of all the given elements. Adding all the highlighted elements to the same part improves performance compared to calling addElementHighlight() for each item. The part will be given the specified color and will use Polygon Offset so it can be rendered together with the UnstructGridModel and still be visible.

void addElementHighlight(const std::vector<HitItem> &items, const Color3f &surfaceColor, const Color3f &lineColor)

Adds triangles and lines for all surfaces of the elements specified by the hit items to the markup model.

The method will create a single MarkupPartTriangles part and add it to the markup model. The part will contain a triangulation of all element surfaces of all the given elements. A single [MarkupPartLines] (cee::vis::MarkupPartLines) part drawing the element edges as lines for all the given elements are also added to the model. Adding all the highlighted elements to the same parts improves performance compared to calling addElementHighlight() for each item. The parts will be given the specified colors and will use Polygon Offset so it can be rendered together with the UnstructGridModel and still be visible.

void addElementHighlight(const std::vector<int> &elementSetIds, const Color3f &surfaceColor, const Color3f &lineColor)

Adds triangles and lines for all surfaces of the elements contained in the given element sets to the markup model.

The method will create a single MarkupPartTriangles part and add it to the markup model. The part will contain a triangulation of all element surfaces of all the elements contained in the given sets (identified by their set ids). A single MarkupPartLines part drawing the element edges as lines for all the elements are also added to the model. The elements are found in the current state and frame of the associated UnstructGridModel. The parts will be given the specified colors and will use Polygon Offset so it can be rendered together with the UnstructGridModel and still be visible.

Note! The element set MUST exist in the current data model. To highlight elements of an element set that does not yet exist in the data model, the set must be loaded manually, call cee::ug::DataSourceInterface::loadState().

void addElementLabel(const HitItem &item, vis::MarkupPartLabels::LabelDrawMode labelDrawMode = vis::MarkupPartLabels::DRAW_WITHOUT_ZBUFFER_TEST, cee::vis::Font *font = NULL)

Adds a label with the element id/index in the elementLabelPosition() to the markup model.

void addElementNodeLabels(const HitItem &item, vis::MarkupPartLabels::LabelDrawMode labelDrawMode = vis::MarkupPartLabels::DRAW_WITHOUT_ZBUFFER_TEST, cee::vis::Font *font = NULL)

Adds labels with the element node id/index to the markup model.

void addElementSurfaceHighlight(const HitItem &item, const Color3f &surfaceColor)

Adds triangles for the surface of the element specified by the hit item to the markup model.

The method will create a MarkupPartTriangles part and add it to the markup model. The part will contain a triangulation of the element surface on the given element. The part will be given the specified color and will use Polygon Offset so it can be rendered together with the UnstructGridModel and still be visible.

void addElementSurfaceHighlight(const HitItem &item, const Color3f &surfaceColor, const Color3f &lineColor)

Adds triangles and lines for all surfaces of the element specified by the hit item to the markup model.

The method will create a MarkupPartTriangles part and add it to the markup model. The part will contain a triangulation of all element surfaces on the given element. A [MarkupPartLines] (cee::vis::MarkupPartLines) part drawing the element edges as lines are also added to the model. The parts will be given the specified colors and will use Polygon Offset so it can be rendered together with the UnstructGridModel and still be visible.

void addElementSurfaceLabel(const HitItem &item, vis::MarkupPartLabels::LabelDrawMode labelDrawMode = vis::MarkupPartLabels::DRAW_WITHOUT_ZBUFFER_TEST, cee::vis::Font *font = NULL)

Adds a label with the element id/index and surface index in the elementLabelPosition() to the markup model.

void addElementSurfaceNodeLabels(const HitItem &item, vis::MarkupPartLabels::LabelDrawMode labelDrawMode = vis::MarkupPartLabels::DRAW_WITHOUT_ZBUFFER_TEST, cee::vis::Font *font = NULL)

Adds labels with the element node id/index and surface index to the markup model.

Vec3d elementLabelPosition(const HitItem &item) const

Returns a suitable position for drawing a label with element information.

If the element has multiple surfaces (volume element) it will return the centroid of the surface that is specified in the hit item. For other elements (shell, beam, points) it will return the centroid of the element.

const ug::DataElements *elementsFromHitItem(const HitItem &item) const

Returns the DataElements object specified by the item. NULL if not found or invalid.

const ug::DataNodes *nodesFromHitItem(const HitItem &item) const

Returns the DataNodes object specified by the item. NULL if not found or invalid.