0024002: Overall code and build procedure refactoring -- automatic
[occt.git] / src / Graphic3d / Graphic3d_Texture1Dsegment.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
18#include <Graphic3d_Texture1Dsegment.hxx>
bf75be98 19#include <Graphic3d_TextureParams.hxx>
42cf5bc1 20#include <Graphic3d_TypeOfTextureMode.hxx>
21#include <Standard_Type.hxx>
22#include <TCollection_AsciiString.hxx>
7fd59977 23
bf75be98 24// =======================================================================
25// function : Graphic3d_Texture1Dsegment
26// purpose :
27// =======================================================================
28Graphic3d_Texture1Dsegment::Graphic3d_Texture1Dsegment (const TCollection_AsciiString& theFileName)
29: Graphic3d_Texture1D (theFileName, Graphic3d_TOT_1D),
30 myX1 (0.0f),
31 myY1 (0.0f),
32 myZ1 (0.0f),
33 myX2 (0.0f),
34 myY2 (0.0f),
35 myZ2 (0.0f)
7fd59977 36{
bf75be98 37 myParams->SetRepeat (Standard_True);
38 myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
39 Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f),
40 Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f));
7fd59977 41}
42
bf75be98 43// =======================================================================
44// function : Graphic3d_Texture1Dsegment
45// purpose :
46// =======================================================================
47Graphic3d_Texture1Dsegment::Graphic3d_Texture1Dsegment (const Graphic3d_NameOfTexture1D theNOT)
48: Graphic3d_Texture1D (theNOT, Graphic3d_TOT_1D),
49 myX1 (0.0f),
50 myY1 (0.0f),
51 myZ1 (0.0f),
52 myX2 (0.0f),
53 myY2 (0.0f),
54 myZ2 (0.0f)
f376ac72 55{
56 myParams->SetRepeat (Standard_True);
57 myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
58 Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f),
59 Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f));
60}
61
62// =======================================================================
63// function : Graphic3d_Texture1Dsegment
64// purpose :
65// =======================================================================
66Graphic3d_Texture1Dsegment::Graphic3d_Texture1Dsegment (const Handle(Image_PixMap)& thePixMap)
67: Graphic3d_Texture1D (thePixMap, Graphic3d_TOT_1D),
68 myX1 (0.0f),
69 myY1 (0.0f),
70 myZ1 (0.0f),
71 myX2 (0.0f),
72 myY2 (0.0f),
73 myZ2 (0.0f)
7fd59977 74{
bf75be98 75 myParams->SetRepeat (Standard_True);
76 myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
77 Graphic3d_Vec4 (0.0f, 0.0f, 1.0f, 0.0f),
78 Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f));
7fd59977 79}
80
bf75be98 81// =======================================================================
82// function : SetSegment
83// purpose :
84// =======================================================================
85void Graphic3d_Texture1Dsegment::SetSegment (const Standard_ShortReal X1,
86 const Standard_ShortReal Y1,
87 const Standard_ShortReal Z1,
88 const Standard_ShortReal X2,
89 const Standard_ShortReal Y2,
90 const Standard_ShortReal Z2)
7fd59977 91{
bf75be98 92 myX1 = X1;
93 myY1 = Y1;
94 myZ1 = Z1;
95 myX2 = X2;
96 myY2 = Y2;
97 myZ2 = Z2;
98 Graphic3d_Vec4 aPlaneX (X2 - X1, Y2 - Y1, Z2 - Z1, 0.0f);
7fd59977 99
bf75be98 100 Standard_ShortReal aSqNorm = aPlaneX.x() * aPlaneX.x()
101 + aPlaneX.y() * aPlaneX.y()
102 + aPlaneX.z() * aPlaneX.z();
103 aPlaneX.x() /= aSqNorm;
104 aPlaneX.y() /= aSqNorm;
105 aPlaneX.z() /= aSqNorm;
106 aPlaneX.w() = -aPlaneX.x() * X1
107 -aPlaneX.y() * Y1
108 -aPlaneX.z() * Z1;
7fd59977 109
bf75be98 110 myParams->SetGenMode (Graphic3d_TOTM_OBJECT,
111 aPlaneX,
112 Graphic3d_Vec4 (0.0f, 0.0f, 0.0f, 0.0f));
7fd59977 113}
114
bf75be98 115// =======================================================================
116// function : Segment
117// purpose :
118// =======================================================================
119void Graphic3d_Texture1Dsegment::Segment (Standard_ShortReal& X1,
120 Standard_ShortReal& Y1,
121 Standard_ShortReal& Z1,
122 Standard_ShortReal& X2,
123 Standard_ShortReal& Y2,
124 Standard_ShortReal& Z2) const
7fd59977 125{
bf75be98 126 X1 = myX1;
127 Y1 = myY1;
128 Z1 = myZ1;
129 X2 = myX2;
130 Y2 = myY2;
131 Z2 = myZ2;
7fd59977 132}