0030416: Incorrect implementation of the method Bnd_OBB::SquareExtent
[occt.git] / src / MeshVS / MeshVS_NodalColorPrsBuilder.hxx
... / ...
CommitLineData
1// Created on: 2003-11-12
2// Created by: Alexander SOLOVYOV
3// Copyright (c) 2003-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 _MeshVS_NodalColorPrsBuilder_HeaderFile
17#define _MeshVS_NodalColorPrsBuilder_HeaderFile
18
19#include <Standard.hxx>
20#include <Standard_Type.hxx>
21
22#include <MeshVS_DataMapOfIntegerColor.hxx>
23#include <Standard_Boolean.hxx>
24#include <Aspect_SequenceOfColor.hxx>
25#include <TColStd_DataMapOfIntegerReal.hxx>
26#include <Quantity_Color.hxx>
27#include <MeshVS_PrsBuilder.hxx>
28#include <MeshVS_DisplayModeFlags.hxx>
29#include <Standard_Integer.hxx>
30#include <MeshVS_BuilderPriority.hxx>
31#include <TColStd_PackedMapOfInteger.hxx>
32#include <Standard_Real.hxx>
33#include <MeshVS_HArray1OfSequenceOfInteger.hxx>
34#include <TColStd_Array1OfInteger.hxx>
35#include <TColStd_Array1OfReal.hxx>
36class MeshVS_Mesh;
37class MeshVS_DataSource;
38class Prs3d_Presentation;
39class Quantity_Color;
40class Graphic3d_Texture2D;
41class Graphic3d_ArrayOfPrimitives;
42
43
44class MeshVS_NodalColorPrsBuilder;
45DEFINE_STANDARD_HANDLE(MeshVS_NodalColorPrsBuilder, MeshVS_PrsBuilder)
46
47//! This class provides methods to create presentation of nodes with assigned color.
48//! There are two ways of presentation building
49//! 1. Without using texture.
50//! In this case colors of nodes are specified with DataMapOfIntegerColor and presentation
51//! is built with gradient fill between these nodes (default behaviour)
52//! 2. Using texture.
53//! In this case presentation is built with spectrum filling between nodes. For example, if
54//! one node has blue color and second one has violet color, parameters of this class may be
55//! set to fill presentation between nodes with solar spectrum.
56//! Methods:
57//! UseTexture - activates/deactivates this way
58//! SetColorMap - sets colors used for generation of texture
59//! SetColorindices - specifies correspondence between node IDs and indices of colors from color map
60class MeshVS_NodalColorPrsBuilder : public MeshVS_PrsBuilder
61{
62
63public:
64
65
66 Standard_EXPORT MeshVS_NodalColorPrsBuilder(const Handle(MeshVS_Mesh)& Parent, const MeshVS_DisplayModeFlags& Flags = MeshVS_DMF_NodalColorDataPrs, const Handle(MeshVS_DataSource)& DS = 0, const Standard_Integer Id = -1, const MeshVS_BuilderPriority& Priority = MeshVS_BP_NodalColor);
67
68 //! Builds presentation of nodes with assigned color.
69 Standard_EXPORT virtual void Build (const Handle(Prs3d_Presentation)& Prs, const TColStd_PackedMapOfInteger& IDs, TColStd_PackedMapOfInteger& IDsToExclude, const Standard_Boolean IsElement, const Standard_Integer DisplayMode) const Standard_OVERRIDE;
70
71 //! Returns map of colors assigned to nodes.
72 Standard_EXPORT const MeshVS_DataMapOfIntegerColor& GetColors() const;
73
74 //! Sets map of colors assigned to nodes.
75 Standard_EXPORT void SetColors (const MeshVS_DataMapOfIntegerColor& Map);
76
77 //! Returns true, if map isn't empty
78 Standard_EXPORT Standard_Boolean HasColors() const;
79
80 //! Returns color assigned to single node
81 Standard_EXPORT Standard_Boolean GetColor (const Standard_Integer ID, Quantity_Color& theColor) const;
82
83 //! Sets color assigned to single node
84 Standard_EXPORT void SetColor (const Standard_Integer ID, const Quantity_Color& theColor);
85
86 //! Specify whether texture must be used to build presentation
87 Standard_EXPORT void UseTexture (const Standard_Boolean theToUse);
88
89 //! Verify whether texture is used to build presentation
90 Standard_EXPORT Standard_Boolean IsUseTexture() const;
91
92 //! Set colors to be used for texrture presentation
93 //! theColors - colors for valid coordinates (laying in range [0, 1])
94 Standard_EXPORT void SetColorMap (const Aspect_SequenceOfColor& theColors);
95
96 //! Return colors used for texrture presentation
97 Standard_EXPORT const Aspect_SequenceOfColor& GetColorMap() const;
98
99 //! Set color representing invalid texture coordinate
100 //! (laying outside range [0, 1])
101 Standard_EXPORT void SetInvalidColor (const Quantity_Color& theInvalidColor);
102
103 //! Return color representing invalid texture coordinate
104 //! (laying outside range [0, 1])
105 Standard_EXPORT Quantity_Color GetInvalidColor() const;
106
107 //! Specify correspondence between node IDs and texture coordinates (range [0, 1])
108 Standard_EXPORT void SetTextureCoords (const TColStd_DataMapOfIntegerReal& theMap);
109
110 //! Get correspondence between node IDs and texture coordinates (range [0, 1])
111 Standard_EXPORT const TColStd_DataMapOfIntegerReal& GetTextureCoords() const;
112
113 //! Specify correspondence between node ID and texture coordinate (range [0, 1])
114 Standard_EXPORT void SetTextureCoord (const Standard_Integer theID, const Standard_Real theCoord);
115
116 //! Return correspondence between node IDs and texture coordinate (range [0, 1])
117 Standard_EXPORT Standard_Real GetTextureCoord (const Standard_Integer theID);
118
119 //! Add to array polygons or polylines representing volume
120 Standard_EXPORT void AddVolumePrs (const Handle(MeshVS_HArray1OfSequenceOfInteger)& theTopo, const TColStd_Array1OfInteger& theNodes, const TColStd_Array1OfReal& theCoords, const Handle(Graphic3d_ArrayOfPrimitives)& theArray, const Standard_Boolean theIsShaded, const Standard_Integer theNbColors, const Standard_Integer theNbTexColors, const Standard_Real theColorRatio) const;
121
122
123
124
125 DEFINE_STANDARD_RTTIEXT(MeshVS_NodalColorPrsBuilder,MeshVS_PrsBuilder)
126
127protected:
128
129
130
131
132private:
133
134
135 //! Create texture in accordance with myTextureColorMap
136 Standard_EXPORT Handle(Graphic3d_Texture2D) CreateTexture() const;
137
138 MeshVS_DataMapOfIntegerColor myNodeColorMap;
139 Standard_Boolean myUseTexture;
140 Aspect_SequenceOfColor myTextureColorMap;
141 TColStd_DataMapOfIntegerReal myTextureCoords;
142 Quantity_Color myInvalidColor;
143
144
145};
146
147
148
149
150
151
152
153#endif // _MeshVS_NodalColorPrsBuilder_HeaderFile