1 // Created on: 2003-11-12
2 // Created by: Alexander SOLOVYOV
3 // Copyright (c) 2003-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 #ifndef _MeshVS_NodalColorPrsBuilder_HeaderFile
17 #define _MeshVS_NodalColorPrsBuilder_HeaderFile
19 #include <MeshVS_DataMapOfIntegerColor.hxx>
20 #include <Aspect_SequenceOfColor.hxx>
21 #include <TColStd_DataMapOfIntegerReal.hxx>
22 #include <Quantity_Color.hxx>
23 #include <MeshVS_PrsBuilder.hxx>
24 #include <MeshVS_DisplayModeFlags.hxx>
25 #include <MeshVS_BuilderPriority.hxx>
26 #include <TColStd_PackedMapOfInteger.hxx>
27 #include <MeshVS_HArray1OfSequenceOfInteger.hxx>
28 #include <TColStd_Array1OfInteger.hxx>
29 #include <TColStd_Array1OfReal.hxx>
32 class MeshVS_DataSource;
34 class Graphic3d_Texture2D;
35 class Graphic3d_ArrayOfPrimitives;
37 DEFINE_STANDARD_HANDLE(MeshVS_NodalColorPrsBuilder, MeshVS_PrsBuilder)
39 //! This class provides methods to create presentation of nodes with assigned color.
40 //! There are two ways of presentation building
41 //! 1. Without using texture.
42 //! In this case colors of nodes are specified with DataMapOfIntegerColor and presentation
43 //! is built with gradient fill between these nodes (default behaviour)
45 //! In this case presentation is built with spectrum filling between nodes. For example, if
46 //! one node has blue color and second one has violet color, parameters of this class may be
47 //! set to fill presentation between nodes with solar spectrum.
49 //! UseTexture - activates/deactivates this way
50 //! SetColorMap - sets colors used for generation of texture
51 //! SetColorindices - specifies correspondence between node IDs and indices of colors from color map
52 class MeshVS_NodalColorPrsBuilder : public MeshVS_PrsBuilder
58 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);
60 //! Builds presentation of nodes with assigned color.
61 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;
63 //! Returns map of colors assigned to nodes.
64 Standard_EXPORT const MeshVS_DataMapOfIntegerColor& GetColors() const;
66 //! Sets map of colors assigned to nodes.
67 Standard_EXPORT void SetColors (const MeshVS_DataMapOfIntegerColor& Map);
69 //! Returns true, if map isn't empty
70 Standard_EXPORT Standard_Boolean HasColors() const;
72 //! Returns color assigned to single node
73 Standard_EXPORT Standard_Boolean GetColor (const Standard_Integer ID, Quantity_Color& theColor) const;
75 //! Sets color assigned to single node
76 Standard_EXPORT void SetColor (const Standard_Integer ID, const Quantity_Color& theColor);
78 //! Specify whether texture must be used to build presentation
79 Standard_EXPORT void UseTexture (const Standard_Boolean theToUse);
81 //! Verify whether texture is used to build presentation
82 Standard_EXPORT Standard_Boolean IsUseTexture() const;
84 //! Set colors to be used for texrture presentation
85 //! theColors - colors for valid coordinates (laying in range [0, 1])
86 Standard_EXPORT void SetColorMap (const Aspect_SequenceOfColor& theColors);
88 //! Return colors used for texrture presentation
89 Standard_EXPORT const Aspect_SequenceOfColor& GetColorMap() const;
91 //! Set color representing invalid texture coordinate
92 //! (laying outside range [0, 1])
93 Standard_EXPORT void SetInvalidColor (const Quantity_Color& theInvalidColor);
95 //! Return color representing invalid texture coordinate
96 //! (laying outside range [0, 1])
97 Standard_EXPORT Quantity_Color GetInvalidColor() const;
99 //! Specify correspondence between node IDs and texture coordinates (range [0, 1])
100 Standard_EXPORT void SetTextureCoords (const TColStd_DataMapOfIntegerReal& theMap);
102 //! Get correspondence between node IDs and texture coordinates (range [0, 1])
103 Standard_EXPORT const TColStd_DataMapOfIntegerReal& GetTextureCoords() const;
105 //! Specify correspondence between node ID and texture coordinate (range [0, 1])
106 Standard_EXPORT void SetTextureCoord (const Standard_Integer theID, const Standard_Real theCoord);
108 //! Return correspondence between node IDs and texture coordinate (range [0, 1])
109 Standard_EXPORT Standard_Real GetTextureCoord (const Standard_Integer theID);
111 //! Add to array polygons or polylines representing volume
112 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;
117 DEFINE_STANDARD_RTTIEXT(MeshVS_NodalColorPrsBuilder,MeshVS_PrsBuilder)
127 //! Create texture in accordance with myTextureColorMap
128 Standard_EXPORT Handle(Graphic3d_Texture2D) CreateTexture() const;
130 MeshVS_DataMapOfIntegerColor myNodeColorMap;
131 Standard_Boolean myUseTexture;
132 Aspect_SequenceOfColor myTextureColorMap;
133 TColStd_DataMapOfIntegerReal myTextureCoords;
134 Quantity_Color myInvalidColor;
145 #endif // _MeshVS_NodalColorPrsBuilder_HeaderFile