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 <IGESGeom_SplineSurface.hxx>
20 #include <Standard_DimensionMismatch.hxx>
21 #include <Standard_OutOfRange.hxx>
22 #include <Standard_Type.hxx>
23
IMPLEMENT_STANDARD_RTTIEXT(IGESGeom_SplineSurface,IGESData_IGESEntity)24 IMPLEMENT_STANDARD_RTTIEXT(IGESGeom_SplineSurface,IGESData_IGESEntity)
25
26 IGESGeom_SplineSurface::IGESGeom_SplineSurface () { }
27
28
Init(const Standard_Integer aBoundaryType,const Standard_Integer aPatchType,const Handle (TColStd_HArray1OfReal)& allUBreakPoints,const Handle (TColStd_HArray1OfReal)& allVBreakPoints,const Handle (IGESBasic_HArray2OfHArray1OfReal)& allXCoeffs,const Handle (IGESBasic_HArray2OfHArray1OfReal)& allYCoeffs,const Handle (IGESBasic_HArray2OfHArray1OfReal)& allZCoeffs)29 void IGESGeom_SplineSurface::Init
30 (const Standard_Integer aBoundaryType,
31 const Standard_Integer aPatchType,
32 const Handle(TColStd_HArray1OfReal)& allUBreakPoints,
33 const Handle(TColStd_HArray1OfReal)& allVBreakPoints,
34 const Handle(IGESBasic_HArray2OfHArray1OfReal)& allXCoeffs,
35 const Handle(IGESBasic_HArray2OfHArray1OfReal)& allYCoeffs,
36 const Handle(IGESBasic_HArray2OfHArray1OfReal)& allZCoeffs)
37 {
38 Standard_Integer i,j;
39 if (allUBreakPoints->Lower() != 1 || allVBreakPoints->Lower() != 1)
40 throw Standard_DimensionMismatch("IGESGeom_SplineSurface: Lower Indices of BreakPoints in Init");
41
42 Standard_Integer nbUSegs = allUBreakPoints->Length() - 1;
43 Standard_Integer nbVSegs = allVBreakPoints->Length() - 1;
44
45 Standard_Integer len = allXCoeffs->RowLength();
46 if ((len != allYCoeffs->RowLength()) || (len != allZCoeffs->RowLength()))
47 throw Standard_DimensionMismatch("IGESGeom_SplineSurface: Row Length of HArray2s in Init");
48 if (allXCoeffs->LowerCol() != 1 || allXCoeffs->LowerRow() != 1 ||
49 allYCoeffs->LowerCol() != 1 || allYCoeffs->LowerRow() != 1 ||
50 allZCoeffs->LowerCol() != 1 || allZCoeffs->LowerRow() != 1 )
51 throw Standard_DimensionMismatch("IGESGeom_SplineSurface: Lower Col-Row Indices of HArray2s in Init");
52
53 len = allXCoeffs->ColLength();
54 if ((len != allYCoeffs->ColLength()) || (len != allZCoeffs->ColLength()))
55 throw Standard_DimensionMismatch("IGESGeom_SplineSurface: Column Length of HArray2s in Init");
56
57 Handle(TColStd_HArray1OfReal) temp1;
58 Handle(TColStd_HArray1OfReal) temp2;
59 Handle(TColStd_HArray1OfReal) temp3;
60 for (i = 1; i <= nbUSegs; i++)
61 for (j = 1; j <= nbVSegs; j++)
62 {
63 temp1 = allXCoeffs->Value(i,j);
64 temp2 = allYCoeffs->Value(i,j);
65 temp3 = allZCoeffs->Value(i,j);
66 if ((temp1.IsNull() || temp1->Length() != 16) ||
67 (temp2.IsNull() || temp2->Length() != 16) ||
68 (temp3.IsNull() || temp3->Length() != 16))
69 throw Standard_DimensionMismatch("IGESGeom_SplineSurface: Lengths of elements of HArray2s in Init");
70 }
71
72
73 theBoundaryType = aBoundaryType;
74 thePatchType = aPatchType;
75 theUBreakPoints = allUBreakPoints;
76 theVBreakPoints = allVBreakPoints;
77 theXCoeffs = allXCoeffs;
78 theYCoeffs = allYCoeffs;
79 theZCoeffs = allZCoeffs;
80 InitTypeAndForm(114,0);
81 }
82
NbUSegments() const83 Standard_Integer IGESGeom_SplineSurface::NbUSegments () const
84 {
85 return (theUBreakPoints->Length() - 1);
86 }
87
NbVSegments() const88 Standard_Integer IGESGeom_SplineSurface::NbVSegments () const
89 {
90 return (theVBreakPoints->Length() - 1);
91 }
92
BoundaryType() const93 Standard_Integer IGESGeom_SplineSurface::BoundaryType () const
94 {
95 return theBoundaryType;
96 }
97
PatchType() const98 Standard_Integer IGESGeom_SplineSurface::PatchType () const
99 {
100 return thePatchType;
101 }
102
UBreakPoint(const Standard_Integer Index) const103 Standard_Real IGESGeom_SplineSurface::UBreakPoint
104 (const Standard_Integer Index) const
105 {
106 return theUBreakPoints->Value(Index);
107 }
108
VBreakPoint(const Standard_Integer Index) const109 Standard_Real IGESGeom_SplineSurface::VBreakPoint
110 (const Standard_Integer Index) const
111 {
112 return theVBreakPoints->Value(Index);
113 }
114
Handle(TColStd_HArray1OfReal)115 Handle(TColStd_HArray1OfReal) IGESGeom_SplineSurface::XPolynomial
116 (const Standard_Integer Index1, const Standard_Integer Index2) const
117 {
118 return(theXCoeffs->Value(Index1,Index2));
119 }
120
Handle(TColStd_HArray1OfReal)121 Handle(TColStd_HArray1OfReal) IGESGeom_SplineSurface::YPolynomial
122 (const Standard_Integer Index1, const Standard_Integer Index2) const
123 {
124 return(theYCoeffs->Value(Index1,Index2));
125 }
126
Handle(TColStd_HArray1OfReal)127 Handle(TColStd_HArray1OfReal) IGESGeom_SplineSurface::ZPolynomial
128 (const Standard_Integer Index1, const Standard_Integer Index2) const
129 {
130 return(theZCoeffs->Value(Index1,Index2));
131 }
132
Polynomials(Handle (IGESBasic_HArray2OfHArray1OfReal)& allXCoeffs,Handle (IGESBasic_HArray2OfHArray1OfReal)& allYCoeffs,Handle (IGESBasic_HArray2OfHArray1OfReal)& allZCoeffs) const133 void IGESGeom_SplineSurface::Polynomials
134 (Handle(IGESBasic_HArray2OfHArray1OfReal)& allXCoeffs,
135 Handle(IGESBasic_HArray2OfHArray1OfReal)& allYCoeffs,
136 Handle(IGESBasic_HArray2OfHArray1OfReal)& allZCoeffs) const
137 {
138 allXCoeffs = theXCoeffs;
139 allYCoeffs = theYCoeffs;
140 allZCoeffs = theZCoeffs;
141 }
142