0031668: Visualization - WebGL sample doesn't work on Emscripten 1.39
[occt.git] / src / IGESDraw / IGESDraw_RectArraySubfigure.cxx
1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
18
19 #include <gp_GTrsf.hxx>
20 #include <gp_Pnt.hxx>
21 #include <gp_XYZ.hxx>
22 #include <IGESData_IGESEntity.hxx>
23 #include <IGESDraw_RectArraySubfigure.hxx>
24 #include <Standard_DimensionMismatch.hxx>
25 #include <Standard_OutOfRange.hxx>
26 #include <Standard_Type.hxx>
27
28 IMPLEMENT_STANDARD_RTTIEXT(IGESDraw_RectArraySubfigure,IGESData_IGESEntity)
29
30 IGESDraw_RectArraySubfigure::IGESDraw_RectArraySubfigure ()    {  }
31
32
33     void IGESDraw_RectArraySubfigure::Init
34   (const Handle(IGESData_IGESEntity)&      aBase,
35    const Standard_Real                     aScale,
36    const gp_XYZ&                           aCorner,
37    const Standard_Integer                  nbCols,
38    const Standard_Integer                  nbRows,
39    const Standard_Real                     hDisp,
40    const Standard_Real                     vtDisp,
41    const Standard_Real                     rotationAngle,
42    const Standard_Integer                  doDont,
43    const Handle(TColStd_HArray1OfInteger)& allNumPos)
44 {
45   if (!allNumPos.IsNull())
46     if (allNumPos->Lower() != 1)
47       throw Standard_DimensionMismatch("IGESDraw_RectArraySubfigure : Init");
48   theBaseEntity       = aBase;
49   theScaleFactor      = aScale;
50   theLowerLeftCorner  = aCorner;
51   theNbColumns        = nbCols;
52   theNbRows           = nbRows;
53   theColumnSeparation = hDisp;
54   theRowSeparation    = vtDisp;
55   theRotationAngle    = rotationAngle;
56   theDoDontFlag       = doDont != 0;
57   thePositions        = allNumPos;
58   InitTypeAndForm(412,0);
59 }
60
61     Handle(IGESData_IGESEntity) IGESDraw_RectArraySubfigure::BaseEntity () const
62 {
63   return theBaseEntity;
64 }
65
66     Standard_Real IGESDraw_RectArraySubfigure::ScaleFactor () const
67 {
68   return theScaleFactor;
69 }
70
71     gp_Pnt IGESDraw_RectArraySubfigure::LowerLeftCorner () const
72 {
73   gp_Pnt tempLowerLeftCorner(theLowerLeftCorner);
74   return tempLowerLeftCorner;
75 }
76
77     gp_Pnt IGESDraw_RectArraySubfigure::TransformedLowerLeftCorner () const
78 {
79   gp_XYZ tempLowerLeftCorner = theLowerLeftCorner;
80   if (HasTransf()) Location().Transforms(tempLowerLeftCorner);
81   gp_Pnt tempRes(tempLowerLeftCorner);
82
83   return (tempRes);
84 }
85
86     Standard_Integer IGESDraw_RectArraySubfigure::NbColumns () const
87 {
88   return theNbColumns;
89 }
90
91     Standard_Integer IGESDraw_RectArraySubfigure::NbRows () const
92 {
93   return theNbRows;
94 }
95
96     Standard_Real IGESDraw_RectArraySubfigure::ColumnSeparation () const
97 {
98   return theColumnSeparation;
99 }
100
101     Standard_Real IGESDraw_RectArraySubfigure::RowSeparation () const
102 {
103   return theRowSeparation;
104 }
105
106     Standard_Real IGESDraw_RectArraySubfigure::RotationAngle () const
107 {
108   return theRotationAngle;
109 }
110
111     Standard_Boolean IGESDraw_RectArraySubfigure::DisplayFlag () const
112 {
113   return (thePositions.IsNull());
114 }
115
116     Standard_Integer IGESDraw_RectArraySubfigure::ListCount () const
117 {
118   return ( thePositions.IsNull() ? 0 : thePositions->Length() );
119   // Return 0 if HArray1 thePositions is NULL Handle
120 }
121
122     Standard_Boolean IGESDraw_RectArraySubfigure::DoDontFlag () const
123 {
124   return (theDoDontFlag);
125 }
126
127     Standard_Boolean IGESDraw_RectArraySubfigure::PositionNum
128   (const Standard_Integer Index) const
129 {
130   // Method : If thePositions array length is Zero return theDoDontFlag;
131   //          else Search Index in to the Array. If 'Index' found in the
132   //          array return theDoDontFlag else return !theDoDontFlag.
133
134   if (thePositions.IsNull())   return theDoDontFlag;
135
136   Standard_Integer I;
137   Standard_Integer up  = thePositions->Upper();
138   for (I = 1; I <= up; I++) {
139     if (thePositions->Value(I) == Index)   return theDoDontFlag;
140   }
141   return (! theDoDontFlag);
142 }
143
144     Standard_Integer IGESDraw_RectArraySubfigure::ListPosition
145   (const Standard_Integer Index) const
146 {
147   return thePositions->Value(Index);
148   // raise OutOfRange from Standard if Index is out-of-bound
149   // Exception NoSuchObject will be raised if thePositions == Null Handle
150 }