19185c42a569ade9717b4f2253a23ddbf013beb9
[occt.git] / src / AIS / AIS_TexturedShape.cdl
1 -- Created on: 2001-07-02
2 -- Created by: Mathias BOSSHARD
3 -- Copyright (c) 2001-2012 OPEN CASCADE SAS
4 --
5 -- The content of this file is subject to the Open CASCADE Technology Public
6 -- License Version 6.5 (the "License"). You may not use the content of this file
7 -- except in compliance with the License. Please obtain a copy of the License
8 -- at http://www.opencascade.org and read it completely before using this file.
9 --
10 -- The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 -- main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 --
13 -- The Original Code and all software distributed under the License is
14 -- distributed on an "AS IS" basis, without warranty of any kind, and the
15 -- Initial Developer hereby disclaims all such warranties, including without
16 -- limitation, any warranties of merchantability, fitness for a particular
17 -- purpose or non-infringement. Please see the License for the specific terms
18 -- and conditions governing the rights and limitations under the License.
19
20
21
22 class TexturedShape from AIS inherits Shape from AIS
23
24         ---Purpose: This class allows to map textures on shapes
25         --  Textures are image files.
26         --   The texture itself is parametrized in (0,1)x(0,1).
27         --  Each face of a shape located in
28         -- UV space is provided with these parameters:
29         --    -      Umin - starting position in U
30         --    -      Umax - ending position in U
31         --    -      Vmin - starting position in V
32         --    -      Vmax - ending position in V
33         --  Each face is triangulated and a texel is assigned to each 
34         --  node. Facets are then filled using a linear interpolation 
35         --  of texture between each 'three texels'                              
36         --  User can act on :
37         --  - the number of occurences of the texture on the face
38         --  - the position of the origin of the texture
39         --  - the scale factor of the texture
40            
41
42
43 uses    
44     Pnt                   from gp,
45     Shape                 from TopoDS,
46     NameOfTexture2D       from Graphic3d,
47     AspectFillArea3d      from Graphic3d,
48     Texture2Dmanual       from Graphic3d,
49     PresentationManager3d from PrsMgr,
50     Presentation          from Prs3d,
51     AsciiString           from TCollection
52
53 is
54
55     Create (shap: Shape from TopoDS) 
56     returns mutable TexturedShape from AIS;
57         ---Purpose:      Initializes the textured shape ashape.
58
59
60     ------------------------------------------------------------
61     SetTextureFileName( me: mutable; 
62                         TextureFileName: AsciiString from TCollection) 
63     is virtual;
64                         
65                         
66         ---Purpose : Sets the name of the texture file to map. The accepted
67         --      file types are those used in AlienImage with extensions
68         --      such as xwd, bmp, gif, rgb, ras, rs and more.
69
70
71     ------------------------------------------------------------
72     SetTextureRepeat(   me: mutable; 
73                         RepeatYN: Boolean from Standard; 
74                         URepeat: Real from Standard = 1.0; 
75                         VRepeat: Real from Standard = 1.0)
76     is virtual;
77                         
78                         
79         ---Purpose : Sets the number of occurrences of
80         -- the texture on each face. The texture itself is parameterized
81         -- in (0,1) by (0,1) . Each face of the shape to be textured is
82         -- parameterized in UV space (Umin,Umax) by (Vmin,Vmax). If
83         -- RepeatYN is set to false, texture coordinates are clamped in the
84         -- range (0,1)x(0,1) of the face. 
85   
86
87     ------------------------------------------------------------
88     SetTextureOrigin(   me: mutable; 
89                         SetTextureOriginYN: Boolean from Standard; 
90                         UOrigin: Real from Standard = 0.0; 
91                         VOrigin: Real from Standard = 0.0)
92     is virtual;
93
94         ---Purpose : Use this method to change the origin of the 
95         --         texture. The texel (0,0) will be mapped to the 
96         --         surfel (UOrigin,VOrigin)
97     ------------------------------------------------------------
98    
99    
100      
101     ------------------------------------------------------------
102     SetTextureScale(    me: mutable; 
103                         SetTextureScaleYN: Boolean from Standard; 
104                         ScaleU: Real from Standard = 1.0; 
105                         ScaleV: Real from Standard = 1.0)
106     is virtual;   
107    
108
109         ---Purpose : Use this method to scale the texture (percent of
110         --         the face).
111         --         You can specify a scale factor for both U and V.
112         --         
113         --         example : if you set ScaleU and ScaleV to 0.5 and
114         --         you enable texture repeat, the texture will appear
115         --         twice on the face in each direction.
116     ------------------------------------------------------------
117
118
119    
120     ------------------------------------------------------------
121     ShowTriangles(  me : mutable; 
122                     ShowTrianglesYN: Boolean from Standard = Standard_False)
123     is virtual;
124     
125     
126         ---Purpose : Use this method to show the triangulation of 
127         --         the shape. This is not very esthetic but can be 
128         --         usefull for debug ... 
129     ------------------------------------------------------------
130
131     
132
133     ------------------------------------------------------------
134     SetTextureMapOn(me: mutable);
135    
136         ---Purpose : Enables texture mapping    
137     ------------------------------------------------------------
138    
139    
140
141     ------------------------------------------------------------
142     SetTextureMapOff(me: mutable);
143    
144         ---Purpose : Disables texture mapping    
145     ------------------------------------------------------------
146       
147    
148
149     ------------------------------------------------------------
150     EnableTextureModulate(me: mutable);
151    
152         ---Purpose : Enables texture modulation
153     ------------------------------------------------------------
154       
155
156
157     ------------------------------------------------------------
158     DisableTextureModulate(me: mutable);
159    
160         ---Purpose : Disables texture modulation    
161     ------------------------------------------------------------
162       
163    
164
165     ------------------------------------------------------------
166     UpdateAttributes(me: mutable);
167
168         ---Purpose : Use this method to display the textured shape 
169         --         without recomputing the whole presentation.
170         --         Use this method when ONLY the texture has been changed.
171         --         ie : myTShape->UpdateAttributes()
172         --          
173         --         If other parameters (ie: scale factors,
174         --         texture origin, texture repeat ...) have changed,
175         --         the whole presentation has to be recomputed.
176         --         ie : if (myShape->DisplayMode() == 3)
177         --                     myAISContext->RecomputePrsOnly(myShape);
178         --                  else
179         --                     {
180         --                       myAISContext->SetDisplayMode(myShape,3,Standard_False);
181         --                       myAISContext->Display(myShape, Standard_True);
182         --                     } 
183     ------------------------------------------------------------
184    
185    
186     
187     ------------------------------------------------------------
188     Compute(me                   : mutable;
189             aPresentationManager : PresentationManager3d from PrsMgr;
190             aPresentation        : mutable Presentation from Prs3d;
191             aMode                : Integer from Standard = 0) 
192     is redefined virtual protected;
193     
194     ------------------------------------------------------------
195    
196    
197
198     ------------------------------------------------------------
199     TriangleIsValid(me; 
200                     P1: Pnt from gp; 
201                     P2: Pnt from gp; 
202                     P3: Pnt from gp) 
203     returns Boolean from Standard is private;
204     
205     ------------------------------------------------------------
206
207
208     
209     ------------------------------------------------------------
210     --          
211     --          QUERY METHODS
212     --          
213     ------------------------------------------------------------
214     
215     
216     TextureMapState(me) returns Boolean from Standard;
217     
218
219     URepeat(me)         returns Real    from Standard;
220     
221
222     TextureRepeat(me)   returns Boolean from Standard;
223     
224     
225     Deflection(me)      returns Real    from Standard;
226     
227     
228     TextureFile(me)     returns CString from Standard;
229     
230
231     VRepeat(me)         returns Real    from Standard;
232     
233
234     ShowTriangles(me)   returns Boolean from Standard;
235     
236
237     TextureUOrigin(me)  returns Real    from Standard;
238     
239     
240     TextureVOrigin(me)  returns Real    from Standard;
241     
242
243     TextureScaleU(me)   returns Real    from Standard;
244     
245
246     TextureScaleV(me)   returns Real    from Standard;
247     
248
249     TextureScale(me)    returns Boolean from Standard;
250     
251
252     TextureOrigin(me)   returns Boolean from Standard;
253     
254
255     TextureModulate(me) returns Boolean from Standard;
256     
257     
258 fields
259     myPredefTexture    : NameOfTexture2D  from Graphic3d;
260     myTextureFile      : AsciiString      from TCollection;
261     DoRepeat           : Boolean          from Standard;
262     myURepeat          : Real             from Standard;
263     myVRepeat          : Real             from Standard;
264     DoMapTexture       : Boolean          from Standard;
265     DoSetTextureOrigin : Boolean          from Standard;
266     myUOrigin          : Real             from Standard;
267     myVOrigin          : Real             from Standard;
268     DoSetTextureScale  : Boolean          from Standard;
269     myScaleU           : Real             from Standard;
270     myScaleV           : Real             from Standard;
271     DoShowTriangles    : Boolean          from Standard;
272     myDeflection       : Real             from Standard;
273     myAspect           : AspectFillArea3d from Graphic3d;
274     mytexture          : Texture2Dmanual  from Graphic3d;
275     Umin               : Real             from Standard;
276     Umax               : Real             from Standard;
277     Vmin               : Real             from Standard;
278     Vmax               : Real             from Standard;
279     dUmax              : Real             from Standard;
280     dVmax              : Real             from Standard;
281     myModulate         : Boolean          from Standard;
282 end TexturedShape;