1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2012 OPEN CASCADE SAS
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.
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.
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.
20 //--------------------------------------------------------------------
21 //--------------------------------------------------------------------
23 #include <IGESGeom_CopiousData.ixx>
24 #include <Standard_DimensionMismatch.hxx>
26 #include <gp_GTrsf.hxx>
27 #include <Standard_NullObject.hxx>
29 IGESGeom_CopiousData::IGESGeom_CopiousData ()
31 theDataType = 0; // to allow Setting Form Number before Init
35 void IGESGeom_CopiousData::Init
36 (const Standard_Integer aDataType,
37 const Standard_Real aZPlane,
38 const Handle(TColStd_HArray1OfReal)& allData)
40 // PTV OCC386 crach application while reading So5771b.igs
42 Standard_NullObject::Raise("IGESGeom_CopiousData : Init with null data");
44 if (allData->Lower() != 1) Standard_DimensionMismatch::Raise("IGESGeom_CopiousData : Init");
45 theDataType = aDataType;
48 // FormNumber = DataType + <N> N=0 -> Set of Points. N=10 : PolyLine
49 // or N=62 (DataType=1 only, gives FormNumber=63) : 2D closed path
50 InitTypeAndForm(106,FormNumber());
53 void IGESGeom_CopiousData::SetPolyline (const Standard_Boolean F)
55 Standard_Integer newfn = theDataType;
57 InitTypeAndForm(106,newfn);
60 void IGESGeom_CopiousData::SetClosedPath2D ()
62 InitTypeAndForm(106,63); // et verifier DataType !
66 Standard_Boolean IGESGeom_CopiousData::IsPointSet () const
68 return (FormNumber() < 10);
71 Standard_Boolean IGESGeom_CopiousData::IsPolyline () const
73 return (FormNumber()/10 == 1);
76 Standard_Boolean IGESGeom_CopiousData::IsClosedPath2D () const
78 return (FormNumber() == 63);
82 Standard_Integer IGESGeom_CopiousData::DataType () const
87 Standard_Integer IGESGeom_CopiousData::NbPoints () const
89 Standard_Integer nbtuples;
94 nbtuples = theData->Length();
95 if (theDataType == 1) nbtuples /= 2;
96 else if (theDataType == 2) nbtuples /= 3;
97 else if (theDataType == 3) nbtuples /= 6;
101 Standard_Real IGESGeom_CopiousData::Data
102 (const Standard_Integer nump, const Standard_Integer numdata) const
104 Standard_Integer numd = 0;
105 if (theDataType == 1) numd = 2*(nump - 1) + numdata; // 1-2
106 else if (theDataType == 2) numd = 3*(nump - 1) + numdata; // 1-2-3
107 else if (theDataType == 3) numd = 6*(nump - 1) + numdata; // 1-2-3-4-5-6
108 return theData->Value(numd);
111 Standard_Real IGESGeom_CopiousData::ZPlane () const
116 gp_Pnt IGESGeom_CopiousData::Point (const Standard_Integer anIndex) const
118 Standard_Integer lower = theData->Lower();
119 Standard_Integer real_index;
120 Standard_Real X=0.,Y=0.,Z=0. ;
121 if (theDataType == 1) {
122 real_index = lower + 2 * (anIndex-1);
123 X = theData->Value(real_index);
124 Y = theData->Value(real_index+1);
128 if (theDataType == 2) {
129 real_index = lower + 3 * (anIndex-1);
130 X = theData->Value(real_index);
131 Y = theData->Value(real_index+1);
132 Z = theData->Value(real_index+2);
135 if (theDataType == 3) {
136 real_index = lower + 6 * (anIndex-1);
137 X = theData->Value(real_index);
138 Y = theData->Value(real_index+1);
139 Z = theData->Value(real_index+2);
146 gp_Pnt IGESGeom_CopiousData::TransformedPoint
147 (const Standard_Integer anIndex) const
149 if (!HasTransf()) return Point(anIndex);
150 gp_XYZ xyz (Point(anIndex).XYZ());
151 Location().Transforms(xyz);
155 gp_Vec IGESGeom_CopiousData::Vector (const Standard_Integer anIndex) const
157 Standard_Integer lower = theData->Lower();
158 Standard_Integer Real_Index;
159 if (theDataType != 3) return gp_Vec(0.0, 0.0, 0.0);
160 Real_Index = lower + 6*(anIndex-1) +3;
161 Standard_Real I = theData->Value(Real_Index);
162 Standard_Real J = theData->Value(Real_Index+1);
163 Standard_Real K = theData->Value(Real_Index+2);
164 return gp_Vec(I, J, K);
167 gp_Vec IGESGeom_CopiousData::TransformedVector
168 (const Standard_Integer anIndex) const
170 if (!HasTransf()) return Vector (anIndex);
171 gp_XYZ xyz (Vector(anIndex).XYZ());
172 gp_GTrsf loc = Location();
173 loc.SetTranslationPart(gp_XYZ(0.,0.,0.));