0028572: Modeling Algorithms - Wrong result of the mkface command
[occt.git] / src / AIS / AIS_Triangulation.hxx
CommitLineData
42cf5bc1 1// Created on: 2009-12-10
2// Created by: Paul SUPRYATKIN
3// Copyright (c) 2009-2014 OPEN CASCADE SAS
4//
5// This file is part of Open CASCADE Technology software library.
6//
7// This library is free software; you can redistribute it and/or modify it under
8// the terms of the GNU Lesser General Public License version 2.1 as published
9// by the Free Software Foundation, with special exception defined in the file
10// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11// distribution for complete text of the license and disclaimer of any warranty.
12//
13// Alternatively, this file may be used under the terms of Open CASCADE
14// commercial license or contractual agreement.
15
16#ifndef _AIS_Triangulation_HeaderFile
17#define _AIS_Triangulation_HeaderFile
18
42cf5bc1 19#include <TColStd_HArray1OfInteger.hxx>
42cf5bc1 20#include <AIS_InteractiveObject.hxx>
42cf5bc1 21
7dd7c146 22class Poly_Triangulation;
42cf5bc1 23
42cf5bc1 24DEFINE_STANDARD_HANDLE(AIS_Triangulation, AIS_InteractiveObject)
25
26//! Interactive object that draws data from Poly_Triangulation, optionally with colors associated
27//! with each triangulation vertex. For maximum efficiency colors are represented as 32-bit integers
28//! instead of classic Quantity_Color values.
29//! Interactive selection of triangles and vertices is not yet implemented.
30class AIS_Triangulation : public AIS_InteractiveObject
31{
7dd7c146 32 DEFINE_STANDARD_RTTIEXT(AIS_Triangulation, AIS_InteractiveObject)
42cf5bc1 33public:
34
42cf5bc1 35 //! Constructs the Triangulation display object
36 Standard_EXPORT AIS_Triangulation(const Handle(Poly_Triangulation)& aTriangulation);
37
38
39 //! Set the color for each node.
40 //! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
41 //! Order of color components is essential for further usage by OpenGL
42 Standard_EXPORT void SetColors (const Handle(TColStd_HArray1OfInteger)& aColor);
43
44
45 //! Get the color for each node.
46 //! Each 32-bit color is Alpha << 24 + Blue << 16 + Green << 8 + Red
47 Standard_EXPORT Handle(TColStd_HArray1OfInteger) GetColors() const;
dcc17419 48
49 //! Returns true if triangulation has vertex colors.
50 Standard_Boolean HasVertexColors() const
51 {
52 return (myFlagColor == 1);
53 }
42cf5bc1 54
55 Standard_EXPORT void SetTriangulation (const Handle(Poly_Triangulation)& aTriangulation);
56
57 //! Returns Poly_Triangulation .
58 Standard_EXPORT Handle(Poly_Triangulation) GetTriangulation() const;
59
dcc17419 60 //! Sets the value aValue for transparency in the reconstructed compound shape.
61 Standard_EXPORT virtual void SetTransparency (const Standard_Real aValue = 0.6) Standard_OVERRIDE;
42cf5bc1 62
dcc17419 63 //! Removes the setting for transparency in the reconstructed compound shape.
64 Standard_EXPORT virtual void UnsetTransparency() Standard_OVERRIDE;
42cf5bc1 65
42cf5bc1 66protected:
67
dcc17419 68 Standard_EXPORT void updatePresentation();
42cf5bc1 69
70
71
72private:
73
74
75 Standard_EXPORT virtual void Compute (const Handle(PrsMgr_PresentationManager3d)& aPresentationManager, const Handle(Prs3d_Presentation)& aPresentation, const Standard_Integer aMode = 0) Standard_OVERRIDE;
76
77 Standard_EXPORT virtual void ComputeSelection (const Handle(SelectMgr_Selection)& aSelection, const Standard_Integer aMode) Standard_OVERRIDE;
78
79 //! Attenuates 32-bit color by a given attenuation factor (0...1):
80 //! aColor = Alpha << 24 + Blue << 16 + Green << 8 + Red
81 //! All color components are multiplied by aComponent, the result is then packed again as 32-bit integer.
82 //! Color attenuation is applied to the vertex colors in order to have correct visual result
83 //! after glColorMaterial(GL_AMBIENT_AND_DIFFUSE). Without it, colors look unnatural and flat.
dcc17419 84 Standard_EXPORT Graphic3d_Vec4ub attenuateColor (const Standard_Integer theColor, const Standard_Real theComponent);
42cf5bc1 85
86 Handle(Poly_Triangulation) myTriangulation;
87 Handle(TColStd_HArray1OfInteger) myColor;
88 Standard_Integer myFlagColor;
89 Standard_Integer myNbNodes;
90 Standard_Integer myNbTriangles;
91
42cf5bc1 92};
93
42cf5bc1 94#endif // _AIS_Triangulation_HeaderFile