0024704: Visualization - inherit OpenGl_Structure from Graphic3d_CStructure
[occt.git] / src / Graphic3d / Graphic3d_Texture1D.cxx
CommitLineData
b311480e 1// Created on: 1997-07-28
2// Created by: Pierre CHALAMET
3// Copyright (c) 1997-1999 Matra Datavision
973c2be1 4// Copyright (c) 1999-2014 OPEN CASCADE SAS
b311480e 5//
973c2be1 6// This file is part of Open CASCADE Technology software library.
b311480e 7//
d5f74e42 8// This library is free software; you can redistribute it and/or modify it under
9// the terms of the GNU Lesser General Public License version 2.1 as published
973c2be1 10// by the Free Software Foundation, with special exception defined in the file
11// OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
12// distribution for complete text of the license and disclaimer of any warranty.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
b311480e 16
7fd59977 17#include <Graphic3d_Texture1D.ixx>
7fd59977 18#include <TCollection_AsciiString.hxx>
7fd59977 19
bf75be98 20static const char *NameOfTexture_to_FileName[] =
7fd59977 21{
22 "1d_elevation.rgb"
23};
24
bf75be98 25// =======================================================================
26// function : Graphic3d_Texture1D
27// purpose :
28// =======================================================================
29Graphic3d_Texture1D::Graphic3d_Texture1D (const TCollection_AsciiString& theFileName,
30 const Graphic3d_TypeOfTexture theType)
31: Graphic3d_TextureMap (theFileName, theType),
32 myName (Graphic3d_NOT_1D_UNKNOWN)
7fd59977 33{
34}
35
bf75be98 36// =======================================================================
37// function : Graphic3d_Texture1D
38// purpose :
39// =======================================================================
40Graphic3d_Texture1D::Graphic3d_Texture1D (const Graphic3d_NameOfTexture1D theNOT,
41 const Graphic3d_TypeOfTexture theType)
42: Graphic3d_TextureMap (NameOfTexture_to_FileName[theNOT], theType),
43 myName (theNOT)
7fd59977 44{
bf75be98 45 myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder());
46 myTexId = TCollection_AsciiString ("Graphic3d_Texture1D_")
47 + NameOfTexture_to_FileName[theNOT];
7fd59977 48}
49
f376ac72 50// =======================================================================
51// function : Graphic3d_Texture1D
52// purpose :
53// =======================================================================
54Graphic3d_Texture1D::Graphic3d_Texture1D (const Handle(Image_PixMap)& thePixMap,
55 const Graphic3d_TypeOfTexture theType)
56: Graphic3d_TextureMap (thePixMap, theType),
57 myName (Graphic3d_NOT_1D_UNKNOWN)
58{
59}
60
bf75be98 61// =======================================================================
62// function : Name
63// purpose :
64// =======================================================================
65Graphic3d_NameOfTexture1D Graphic3d_Texture1D::Name() const
66{
7fd59977 67 return myName;
68}
69
bf75be98 70// =======================================================================
71// function : NumberOfTextures
72// purpose :
73// =======================================================================
74Standard_Integer Graphic3d_Texture1D::NumberOfTextures()
75{
7fd59977 76 return sizeof(NameOfTexture_to_FileName)/sizeof(char*);
77}
78
bf75be98 79// =======================================================================
80// function : TextureName
81// purpose :
82// =======================================================================
83TCollection_AsciiString Graphic3d_Texture1D::TextureName (const Standard_Integer theRank)
84{
85 if (theRank < 1 || theRank > NumberOfTextures())
86 {
87 Standard_OutOfRange::Raise ("BAD index of texture");
88 }
7fd59977 89
bf75be98 90 TCollection_AsciiString aFileName (NameOfTexture_to_FileName[theRank - 1]);
91 Standard_Integer i = aFileName.SearchFromEnd (".");
92 return aFileName.SubString (4, i - 1);
7fd59977 93}