0027816: Visualization - provide an API for overriding clipping planes list
[occt.git] / src / Graphic3d / Graphic3d_Texture2D.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
42cf5bc1 17#include <Graphic3d_Texture2D.hxx>
d2edda76 18
42cf5bc1 19#include <Standard_OutOfRange.hxx>
7fd59977 20
92efcf78 21IMPLEMENT_STANDARD_RTTIEXT(Graphic3d_Texture2D,Graphic3d_TextureMap)
22
7fd59977 23static const char *NameOfTexture_to_FileName[] =
24{
25 "2d_MatraDatavision.rgb",
26 "2d_alienskin.rgb",
27 "2d_blue_rock.rgb",
28 "2d_bluewhite_paper.rgb",
29 "2d_brushed.rgb",
30 "2d_bubbles.rgb",
31 "2d_bumps.rgb",
32 "2d_cast.rgb",
33 "2d_chipbd.rgb",
34 "2d_clouds.rgb",
35 "2d_flesh.rgb",
36 "2d_floor.rgb",
37 "2d_galvnisd.rgb",
38 "2d_grass.rgb",
39 "2d_aluminum.rgb",
40 "2d_rock.rgb",
41 "2d_knurl.rgb",
42 "2d_maple.rgb",
43 "2d_marble.rgb",
44 "2d_mottled.rgb",
45 "2d_rain.rgb"
46};
47
bf75be98 48// =======================================================================
49// function : Graphic3d_Texture2D
50// purpose :
51// =======================================================================
52Graphic3d_Texture2D::Graphic3d_Texture2D (const TCollection_AsciiString& theFileName,
53 const Graphic3d_TypeOfTexture theType)
54: Graphic3d_TextureMap (theFileName, theType),
55 myName (Graphic3d_NOT_2D_UNKNOWN)
7fd59977 56{
57}
58
bf75be98 59// =======================================================================
60// function : Graphic3d_Texture2D
61// purpose :
62// =======================================================================
63Graphic3d_Texture2D::Graphic3d_Texture2D (const Graphic3d_NameOfTexture2D theNOT,
64 const Graphic3d_TypeOfTexture theType)
65: Graphic3d_TextureMap (NameOfTexture_to_FileName[theNOT], theType),
66 myName (theNOT)
7fd59977 67{
bf75be98 68 myPath.SetTrek (Graphic3d_TextureRoot::TexturesFolder());
69 myTexId = TCollection_AsciiString ("Graphic3d_Texture2D_")
70 + NameOfTexture_to_FileName[theNOT];
7fd59977 71}
72
f376ac72 73// =======================================================================
74// function : Graphic3d_Texture2D
75// purpose :
76// =======================================================================
77Graphic3d_Texture2D::Graphic3d_Texture2D (const Handle(Image_PixMap)& thePixMap,
78 const Graphic3d_TypeOfTexture theType)
79: Graphic3d_TextureMap (thePixMap, theType),
80 myName (Graphic3d_NOT_2D_UNKNOWN)
81{
82}
83
bf75be98 84// =======================================================================
85// function : NumberOfTextures
86// purpose :
87// =======================================================================
88Standard_Integer Graphic3d_Texture2D::NumberOfTextures()
89{
7fd59977 90 return sizeof(NameOfTexture_to_FileName)/sizeof(char*);
91}
92
bf75be98 93// =======================================================================
94// function : Name
95// purpose :
96// =======================================================================
97Graphic3d_NameOfTexture2D Graphic3d_Texture2D::Name() const
98{
7fd59977 99 return myName;
100}
101
bf75be98 102// =======================================================================
103// function : TextureName
104// purpose :
105// =======================================================================
106TCollection_AsciiString Graphic3d_Texture2D::TextureName (const Standard_Integer theRank)
107{
108 if (theRank < 1 || theRank > NumberOfTextures())
109 {
110 Standard_OutOfRange::Raise ("BAD index of texture");
111 }
112
113 TCollection_AsciiString aFileName (NameOfTexture_to_FileName[theRank - 1]);
114 Standard_Integer i = aFileName.SearchFromEnd (".");
115 return aFileName.SubString (4, i - 1);
7fd59977 116}
d2edda76 117
118// =======================================================================
119// function : SetImage
120// purpose :
121// =======================================================================
122void Graphic3d_Texture2D::SetImage (const Handle(Image_PixMap)& thePixMap)
123{
124 myPixMap = thePixMap;
125 myPath = OSD_Path();
126 myName = Graphic3d_NOT_2D_UNKNOWN;
127}