CFx SDK Documentation  2020SP3
GiProceduralGenerator.h
Go to the documentation of this file.
1 // Copyright (C) 2002-2017, Open Design Alliance (the "Alliance").
3 // All rights reserved.
4 //
5 // This software and its documentation and related materials are owned by
6 // the Alliance. The software may only be incorporated into application
7 // programs owned by members of the Alliance, subject to a signed
8 // Membership Agreement and Supplemental Software License Agreement with the
9 // Alliance. The structure and organization of this software are the valuable
10 // trade secrets of the Alliance and its suppliers. The software is also
11 // protected by copyright law and international treaty provisions. Application
12 // programs incorporating this software must include the following statement
13 // with their copyright notices:
14 //
15 // This application incorporates Teigha(R) software pursuant to a license
16 // agreement with Open Design Alliance.
17 // Teigha(R) Copyright (C) 2002-2017 by Open Design Alliance.
18 // All rights reserved.
19 //
20 // By use of this software, its documentation or related materials, you
21 // acknowledge and accept the above terms.
23 
24 // Procedural textures generator.
25 
26 #ifndef __ODGIPROCEDURALGENERATOR_H__
27 #define __ODGIPROCEDURALGENERATOR_H__
28 
29 #include "RootExport.h"
30 #include "GiExport.h"
31 #include "UInt32Array.h"
32 #include "GiImage.h"
33 #include "GiMaterial.h"
34 
35 #include "RxObject.h"
36 
37 #include "TD_PackPush.h"
38 
45 {
46  public:
48 
50 
60  OdGiImageBGRA32 &image, double renderCoef = 1.0) = 0;
61 };
62 
69 
79 {
80  public:
85  {
86  kLinearInterpolation = 0,
89  kCosInterpolation
90  };
98  {
99  kClampMode = 0,
100  kWrapMode
101  };
102  protected:
105  public:
109 
114  void createColorArray(OdUInt32 nColors);
125  void copyGradient(const OdUInt32Array &other);
131  void copyGradient(const ODCOLORREF *colors, OdUInt32 nColors);
139  void createGradient(ODCOLORREF color1, ODCOLORREF color2, OdUInt32 nColors,
149  void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, OdUInt32 nColors,
160  void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, OdUInt32 nColors,
171  void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, OdUInt32 nColors,
184  void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, OdUInt32 nColors,
197  void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, ODCOLORREF color5, OdUInt32 nColors,
212  void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, ODCOLORREF color5, OdUInt32 nColors,
215 
222  void fillInterval(ODCOLORREF color, double from = 0.0, double to = 1.0);
229  void fillInterval(ODCOLORREF color, OdUInt32 from, OdUInt32 to);
238  void generateInterval(ODCOLORREF color1, ODCOLORREF color2, double from = 0.0, double to = 1.0,
248  void generateInterval(ODCOLORREF color1, ODCOLORREF color2, OdUInt32 from, OdUInt32 to,
250 
259  ODCOLORREF colorAt(OdUInt32 nColor) const;
264  ODCOLORREF colorAt(double at) const;
268  bool isInitialized() const;
272  const OdUInt32Array &asArray() const;
273 
283 
293  static ODCOLORREF interpolateColor(ODCOLORREF color1, ODCOLORREF color2, double at,
296 
297  const OdGiGradientGenerator &operator =(const OdGiGradientGenerator &other);
298 
300 
302  void operator +=(const OdGiGradientGenerator &other);
303  friend OdGiGradientGenerator operator +(const OdGiGradientGenerator &g1, const OdGiGradientGenerator &g2);
304  protected:
312  OdUInt32 clampToRange(double inVal) const;
316  double toDoubleRange(OdUInt32 inVal) const;
317 
321  static double linterp(double a, double b, double t);
325  static double einterp(double a, double b, double t);
329  static double cinterp(double a, double b, double t);
333  static double ieinterp(double a, double b, double t);
334 };
335 
345 {
346  public:
348 
349  // High-level functions
350 
360  OdGiImageBGRA32 &image, double renderCoef = 1.0) = 0;
361 
373  virtual void generateProceduralWood(OdGiPixelBGRA32 color1, OdGiPixelBGRA32 color2, double radialNoise, double axialNoise, double grainThickness,
374  OdGiImageBGRA32 &image, double renderCoef = 1.0) = 0;
384  virtual void generateProceduralMarble(OdGiPixelBGRA32 stoneColor, OdGiPixelBGRA32 veinColor, double veinSpacing, double veinWidth,
385  OdGiImageBGRA32 &image, double renderCoef = 1.0) = 0;
386 
387  // Low-level functions
388 
397  virtual void setColorGradient(const OdGiGradientGenerator &gradient) = 0;
401  virtual const OdGiGradientGenerator &colorGradient() const = 0;
402 };
403 
410 
411 #include "TD_PackPop.h"
412 
413 #endif // __ODGIPROCEDURALGENERATOR_H__
OdGiGradientGenerator::OdGiGradientGenerator
OdGiGradientGenerator(const OdGiGradientGenerator &other)
OdGiProceduralGeneratorPE::generateProceduralTexture
virtual bool generateProceduralTexture(OdGiProceduralTexturePtr pTexture, OdGiImageBGRA32 &image, double renderCoef=1.0)=0
OdGiGradientGenerator::clampToRange
OdUInt32 clampToRange(OdUInt32 inVal) const
OdGiGradientGenerator::m_colorGradient
OdUInt32Array m_colorGradient
Definition: GiProceduralGenerator.h:103
OdUInt8
unsigned char OdUInt8
Definition: OdPlatformSettings.h:759
OdGiGradientGenerator::createColorArrayFilled
void createColorArrayFilled(ODCOLORREF color, OdUInt32 nColors)
OdGiProceduralGenerator::colorGradient
virtual const OdGiGradientGenerator & colorGradient() const =0
OdGiProceduralGeneratorPEPtr
OdSmartPtr< OdGiProceduralGeneratorPE > OdGiProceduralGeneratorPEPtr
Definition: GiProceduralGenerator.h:68
OdRxObject
Definition: RxObject.h:564
OdGiProceduralGenerator::setColorGradient
virtual void setColorGradient(const OdGiGradientGenerator &gradient)=0
OdArray< OdUInt32, OdMemoryAllocator< OdUInt32 > >
OdGiGradientGenerator::createGradient
void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl1, OdGiGradientGenerator::InterpolationType ipl2)
TD_PackPop.h
OdGiGradientGenerator::OdGiGradientGenerator
OdGiGradientGenerator()
OdGiGradientGenerator::createGradient
void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, ODCOLORREF color5, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation)
OdGiProceduralGeneratorPE::OdGiProceduralGeneratorPE
OdGiProceduralGeneratorPE()
OdGiGradientGenerator::createGradient
void createGradient(ODCOLORREF color1, ODCOLORREF color2, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation)
RxObject.h
OdUInt32
unsigned int OdUInt32
Definition: OdPlatformSettings.h:783
ODGI_EXPORT
#define ODGI_EXPORT
Definition: GiExport.h:35
OdGiProceduralGenerator::ODRX_DECLARE_MEMBERS
ODRX_DECLARE_MEMBERS(OdGiProceduralGenerator)
GiImage.h
OdGiGradientGenerator::setAddressMode
void setAddressMode(OdGiGradientGenerator::AddressMode mode)
OdGiGradientGenerator::copyGradient
void copyGradient(const ODCOLORREF *colors, OdUInt32 nColors)
OdGiGradientGenerator::asArray
const OdUInt32Array & asArray() const
OdGiGradientGenerator::fillInterval
void fillInterval(ODCOLORREF color, double from=0.0, double to=1.0)
OdGiProceduralGeneratorPE
Definition: GiProceduralGenerator.h:45
OdGiGradientGenerator::kWrapMode
@ kWrapMode
Definition: GiProceduralGenerator.h:100
RootExport.h
OdSmartPtr
Definition: SmartPtr.h:58
OdGiPixelBGRA32
Definition: GiImage.h:44
OdGiGradientGenerator::kInvExpInterpolation
@ kInvExpInterpolation
Definition: GiProceduralGenerator.h:88
OdGiGradientGenerator::cinterp
static double cinterp(double a, double b, double t)
OdGiGradientGenerator::einterp
static double einterp(double a, double b, double t)
GiMaterial.h
OdGiGradientGenerator::createGradient
void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation)
OdGiGradientGenerator::isInitialized
bool isInitialized() const
OdGiGradientGenerator::interpolateColor
static ODCOLORREF interpolateColor(ODCOLORREF color1, ODCOLORREF color2, double at, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation, OdGiGradientGenerator::AddressMode mode=OdGiGradientGenerator::kWrapMode)
OdGiGradientGenerator::createGradient
void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl1, OdGiGradientGenerator::InterpolationType ipl2, OdGiGradientGenerator::InterpolationType ipl3)
OdGiGradientGenerator::fillInterval
void fillInterval(ODCOLORREF color, OdUInt32 from, OdUInt32 to)
OdGiGradientGenerator::m_addressMode
AddressMode m_addressMode
Definition: GiProceduralGenerator.h:104
OdGiGradientGenerator::addressMode
OdGiGradientGenerator::AddressMode addressMode() const
OdGiGradientGenerator::clampToRange
OdUInt32 clampToRange(double inVal) const
OdGiProceduralGeneratorPtr
OdSmartPtr< OdGiProceduralGenerator > OdGiProceduralGeneratorPtr
Definition: GiProceduralGenerator.h:409
TD_PackPush.h
OdGiImageBGRA32
Definition: GiImage.h:213
OdGiGradientGenerator::ieinterp
static double ieinterp(double a, double b, double t)
OdGiGradientGenerator::appendGradient
void appendGradient(const OdGiGradientGenerator &other)
OdGiProceduralGenerator::generateProceduralMarble
virtual void generateProceduralMarble(OdGiPixelBGRA32 stoneColor, OdGiPixelBGRA32 veinColor, double veinSpacing, double veinWidth, OdGiImageBGRA32 &image, double renderCoef=1.0)=0
OdGiGradientGenerator::AddressMode
AddressMode
Definition: GiProceduralGenerator.h:98
OdGiGradientGenerator::createGradient
void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, ODCOLORREF color4, ODCOLORREF color5, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl1, OdGiGradientGenerator::InterpolationType ipl2, OdGiGradientGenerator::InterpolationType ipl3, OdGiGradientGenerator::InterpolationType ipl4)
OdGiGradientGenerator::colorAt
ODCOLORREF colorAt(double at) const
OdGiGradientGenerator
Definition: GiProceduralGenerator.h:79
OdGiProceduralGeneratorPE::ODRX_DECLARE_MEMBERS
ODRX_DECLARE_MEMBERS(OdGiProceduralGeneratorPE)
GiExport.h
OdGiGradientGenerator::~OdGiGradientGenerator
~OdGiGradientGenerator()
OdGiGradientGenerator::InterpolationType
InterpolationType
Definition: GiProceduralGenerator.h:85
OdGiGradientGenerator::createGradient
void createGradient(ODCOLORREF color1, ODCOLORREF color2, ODCOLORREF color3, OdUInt32 nColors, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation)
OdGiGradientGenerator::colorAt
ODCOLORREF colorAt(OdUInt32 nColor) const
OdGiGradientGenerator::copyGradient
void copyGradient(const OdUInt32Array &other)
ODCOLORREF
#define ODCOLORREF
Definition: OdPlatform.h:883
OdGiGradientGenerator::kLinearInterpolation
@ kLinearInterpolation
Definition: GiProceduralGenerator.h:86
OdGiGradientGenerator::createColorArray
void createColorArray(OdUInt32 nColors)
OdGiGradientGenerator::kExpInterpolation
@ kExpInterpolation
Definition: GiProceduralGenerator.h:87
OdGiGradientGenerator::toDoubleRange
double toDoubleRange(OdUInt32 inVal) const
OdGiGradientGenerator::generateInterval
void generateInterval(ODCOLORREF color1, ODCOLORREF color2, OdUInt32 from, OdUInt32 to, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation)
OdGiProceduralGenerator::generateProceduralTexture
virtual bool generateProceduralTexture(OdGiProceduralTexturePtr pTexture, OdGiImageBGRA32 &image, double renderCoef=1.0)=0
OdGiGradientGenerator::colorsCount
OdUInt32 colorsCount() const
alpha
GLfloat GLfloat GLfloat alpha
Definition: gles2_ext.h:147
OdGiGradientGenerator::createSpectrumGradient
static OdGiGradientGenerator createSpectrumGradient(OdUInt32 nColors, OdUInt8 alpha=0)
OdGiProceduralGenerator
Definition: GiProceduralGenerator.h:345
UInt32Array.h
OdGiGradientGenerator::generateInterval
void generateInterval(ODCOLORREF color1, ODCOLORREF color2, double from=0.0, double to=1.0, OdGiGradientGenerator::InterpolationType ipl=OdGiGradientGenerator::kLinearInterpolation)
OdGiGradientGenerator::linterp
static double linterp(double a, double b, double t)
OdGiProceduralGenerator::generateProceduralWood
virtual void generateProceduralWood(OdGiPixelBGRA32 color1, OdGiPixelBGRA32 color2, double radialNoise, double axialNoise, double grainThickness, OdGiImageBGRA32 &image, double renderCoef=1.0)=0