1 // Created by: CKY / Contract Toubro-Larsen
2 // Copyright (c) 1993-1999 Matra Datavision
3 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 // This file is part of Open CASCADE Technology software library.
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.
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
16 //--------------------------------------------------------------------
17 //--------------------------------------------------------------------
19 #include <gp_GTrsf.hxx>
23 #include <IGESGeom_CopiousData.hxx>
24 #include <Standard_DimensionMismatch.hxx>
25 #include <Standard_NullObject.hxx>
26 #include <Standard_OutOfRange.hxx>
27 #include <Standard_Type.hxx>
29 IMPLEMENT_STANDARD_RTTIEXT(IGESGeom_CopiousData,IGESData_IGESEntity)
31 IGESGeom_CopiousData::IGESGeom_CopiousData ()
33 theDataType = 0; // to allow Setting Form Number before Init
37 void IGESGeom_CopiousData::Init
38 (const Standard_Integer aDataType,
39 const Standard_Real aZPlane,
40 const Handle(TColStd_HArray1OfReal)& allData)
42 // PTV OCC386 crach application while reading So5771b.igs
44 throw Standard_NullObject("IGESGeom_CopiousData : Init with null data");
46 if (allData->Lower() != 1) throw Standard_DimensionMismatch("IGESGeom_CopiousData : Init");
47 theDataType = aDataType;
50 // FormNumber = DataType + <N> N=0 -> Set of Points. N=10 : PolyLine
51 // or N=62 (DataType=1 only, gives FormNumber=63) : 2D closed path
52 InitTypeAndForm(106,FormNumber());
55 void IGESGeom_CopiousData::SetPolyline (const Standard_Boolean F)
57 Standard_Integer newfn = theDataType;
59 InitTypeAndForm(106,newfn);
62 void IGESGeom_CopiousData::SetClosedPath2D ()
64 InitTypeAndForm(106,63); // et verifier DataType !
68 Standard_Boolean IGESGeom_CopiousData::IsPointSet () const
70 return (FormNumber() < 10);
73 Standard_Boolean IGESGeom_CopiousData::IsPolyline () const
75 return (FormNumber()/10 == 1);
78 Standard_Boolean IGESGeom_CopiousData::IsClosedPath2D () const
80 return (FormNumber() == 63);
84 Standard_Integer IGESGeom_CopiousData::DataType () const
89 Standard_Integer IGESGeom_CopiousData::NbPoints () const
91 Standard_Integer nbtuples;
96 nbtuples = theData->Length();
97 if (theDataType == 1) nbtuples /= 2;
98 else if (theDataType == 2) nbtuples /= 3;
99 else if (theDataType == 3) nbtuples /= 6;
103 Standard_Real IGESGeom_CopiousData::Data
104 (const Standard_Integer nump, const Standard_Integer numdata) const
106 Standard_Integer numd = 0;
107 if (theDataType == 1) numd = 2*(nump - 1) + numdata; // 1-2
108 else if (theDataType == 2) numd = 3*(nump - 1) + numdata; // 1-2-3
109 else if (theDataType == 3) numd = 6*(nump - 1) + numdata; // 1-2-3-4-5-6
110 return theData->Value(numd);
113 Standard_Real IGESGeom_CopiousData::ZPlane () const
118 gp_Pnt IGESGeom_CopiousData::Point (const Standard_Integer anIndex) const
120 Standard_Integer lower = theData->Lower();
121 Standard_Integer real_index;
122 Standard_Real X=0.,Y=0.,Z=0. ;
123 if (theDataType == 1) {
124 real_index = lower + 2 * (anIndex-1);
125 X = theData->Value(real_index);
126 Y = theData->Value(real_index+1);
130 if (theDataType == 2) {
131 real_index = lower + 3 * (anIndex-1);
132 X = theData->Value(real_index);
133 Y = theData->Value(real_index+1);
134 Z = theData->Value(real_index+2);
137 if (theDataType == 3) {
138 real_index = lower + 6 * (anIndex-1);
139 X = theData->Value(real_index);
140 Y = theData->Value(real_index+1);
141 Z = theData->Value(real_index+2);
148 gp_Pnt IGESGeom_CopiousData::TransformedPoint
149 (const Standard_Integer anIndex) const
151 if (!HasTransf()) return Point(anIndex);
152 gp_XYZ xyz (Point(anIndex).XYZ());
153 Location().Transforms(xyz);
157 gp_Vec IGESGeom_CopiousData::Vector (const Standard_Integer anIndex) const
159 Standard_Integer lower = theData->Lower();
160 Standard_Integer Real_Index;
161 if (theDataType != 3) return gp_Vec(0.0, 0.0, 0.0);
162 Real_Index = lower + 6*(anIndex-1) +3;
163 Standard_Real I = theData->Value(Real_Index);
164 Standard_Real J = theData->Value(Real_Index+1);
165 Standard_Real K = theData->Value(Real_Index+2);
166 return gp_Vec(I, J, K);
169 gp_Vec IGESGeom_CopiousData::TransformedVector
170 (const Standard_Integer anIndex) const
172 if (!HasTransf()) return Vector (anIndex);
173 gp_XYZ xyz (Vector(anIndex).XYZ());
174 gp_GTrsf loc = Location();
175 loc.SetTranslationPart(gp_XYZ(0.,0.,0.));