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 <IGESGeom_SplineSurface.hxx>
20 #include <Standard_DimensionMismatch.hxx>
21 #include <Standard_OutOfRange.hxx>
22 #include <Standard_Type.hxx>
24 IMPLEMENT_STANDARD_RTTIEXT(IGESGeom_SplineSurface,IGESData_IGESEntity)
26 IGESGeom_SplineSurface::IGESGeom_SplineSurface () { }
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)
39 if (allUBreakPoints->Lower() != 1 || allVBreakPoints->Lower() != 1)
40 throw Standard_DimensionMismatch("IGESGeom_SplineSurface: Lower Indices of BreakPoints in Init");
42 Standard_Integer nbUSegs = allUBreakPoints->Length() - 1;
43 Standard_Integer nbVSegs = allVBreakPoints->Length() - 1;
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");
53 len = allXCoeffs->ColLength();
54 if ((len != allYCoeffs->ColLength()) || (len != allZCoeffs->ColLength()))
55 throw Standard_DimensionMismatch("IGESGeom_SplineSurface: Column Length of HArray2s in Init");
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++)
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");
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);
83 Standard_Integer IGESGeom_SplineSurface::NbUSegments () const
85 return (theUBreakPoints->Length() - 1);
88 Standard_Integer IGESGeom_SplineSurface::NbVSegments () const
90 return (theVBreakPoints->Length() - 1);
93 Standard_Integer IGESGeom_SplineSurface::BoundaryType () const
95 return theBoundaryType;
98 Standard_Integer IGESGeom_SplineSurface::PatchType () const
103 Standard_Real IGESGeom_SplineSurface::UBreakPoint
104 (const Standard_Integer Index) const
106 return theUBreakPoints->Value(Index);
109 Standard_Real IGESGeom_SplineSurface::VBreakPoint
110 (const Standard_Integer Index) const
112 return theVBreakPoints->Value(Index);
115 Handle(TColStd_HArray1OfReal) IGESGeom_SplineSurface::XPolynomial
116 (const Standard_Integer Index1, const Standard_Integer Index2) const
118 return(theXCoeffs->Value(Index1,Index2));
121 Handle(TColStd_HArray1OfReal) IGESGeom_SplineSurface::YPolynomial
122 (const Standard_Integer Index1, const Standard_Integer Index2) const
124 return(theYCoeffs->Value(Index1,Index2));
127 Handle(TColStd_HArray1OfReal) IGESGeom_SplineSurface::ZPolynomial
128 (const Standard_Integer Index1, const Standard_Integer Index2) const
130 return(theZCoeffs->Value(Index1,Index2));
133 void IGESGeom_SplineSurface::Polynomials
134 (Handle(IGESBasic_HArray2OfHArray1OfReal)& allXCoeffs,
135 Handle(IGESBasic_HArray2OfHArray1OfReal)& allYCoeffs,
136 Handle(IGESBasic_HArray2OfHArray1OfReal)& allZCoeffs) const
138 allXCoeffs = theXCoeffs;
139 allYCoeffs = theYCoeffs;
140 allZCoeffs = theZCoeffs;