b311480e |
1 | // Created on: 1993-06-22 |
2 | // Created by: Martine LANGLOIS |
3 | // Copyright (c) 1993-1999 Matra Datavision |
4 | // Copyright (c) 1999-2012 OPEN CASCADE SAS |
5 | // |
6 | // The content of this file is subject to the Open CASCADE Technology Public |
7 | // License Version 6.5 (the "License"). You may not use the content of this file |
8 | // except in compliance with the License. Please obtain a copy of the License |
9 | // at http://www.opencascade.org and read it completely before using this file. |
10 | // |
11 | // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its |
12 | // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France. |
13 | // |
14 | // The Original Code and all software distributed under the License is |
15 | // distributed on an "AS IS" basis, without warranty of any kind, and the |
16 | // Initial Developer hereby disclaims all such warranties, including without |
17 | // limitation, any warranties of merchantability, fitness for a particular |
18 | // purpose or non-infringement. Please see the License for the specific terms |
19 | // and conditions governing the rights and limitations under the License. |
20 | |
7fd59977 |
21 | // .cxx |
7fd59977 |
22 | |
23 | #include <GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface.ixx> |
24 | #include <StdFail_NotDone.hxx> |
25 | #include <Geom_BSplineSurface.hxx> |
26 | #include <StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface.hxx> |
27 | #include <StepGeom_CartesianPoint.hxx> |
28 | #include <GeomToStep_MakeCartesianPoint.hxx> |
29 | #include <StepGeom_HArray2OfCartesianPoint.hxx> |
30 | #include <TColStd_HArray1OfInteger.hxx> |
31 | #include <TColStd_HArray1OfReal.hxx> |
32 | #include <TColStd_HArray2OfReal.hxx> |
33 | #include <TColgp_Array2OfPnt.hxx> |
34 | #include <GeomAbs_BSplKnotDistribution.hxx> |
35 | #include <StepGeom_KnotType.hxx> |
36 | #include <TCollection_HAsciiString.hxx> |
37 | |
38 | //============================================================================= |
39 | // Creation d' une bspline_Surface_with_knots_and_rational_bspline_Surface de |
40 | // prostep a partir d' une BSplineSurface de Geom |
41 | //============================================================================= |
42 | |
43 | GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface:: |
44 | GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface( const |
45 | Handle(Geom_BSplineSurface)& BS ) |
46 | |
47 | { |
48 | Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface) BSWK; |
49 | Standard_Integer aUDegree, aVDegree, NU, NV, i, j, NUknots, NVknots, itampon; |
50 | Standard_Real rtampon; |
51 | Handle(StepGeom_CartesianPoint) Pt = new StepGeom_CartesianPoint; |
52 | Handle(StepGeom_HArray2OfCartesianPoint) aControlPointsList; |
53 | StepGeom_BSplineSurfaceForm aSurfaceForm; |
54 | StepData_Logical aUClosed, aVClosed, aSelfIntersect; |
55 | Handle(TColStd_HArray1OfInteger) aUMultiplicities, aVMultiplicities; |
56 | Handle(TColStd_HArray1OfReal) aUKnots, aVKnots; |
57 | Handle(TColStd_HArray2OfReal) aWeightsData; |
58 | GeomAbs_BSplKnotDistribution UDistribution, VDistribution; |
59 | StepGeom_KnotType KnotSpec; |
60 | |
61 | aUDegree = BS->UDegree(); |
62 | aVDegree = BS->VDegree(); |
63 | |
64 | NU = BS->NbUPoles(); |
65 | NV = BS->NbVPoles(); |
66 | TColgp_Array2OfPnt P(1,NU,1,NV); |
67 | BS->Poles(P); |
68 | aControlPointsList = new StepGeom_HArray2OfCartesianPoint(1,NU,1,NV); |
69 | for ( i=P.LowerRow(); i<=P.UpperRow(); i++) { |
70 | for ( j=P.LowerCol(); j<=P.UpperCol(); j++) { |
71 | GeomToStep_MakeCartesianPoint MkPoint(P.Value(i,j)); |
72 | Pt = MkPoint.Value(); |
73 | aControlPointsList->SetValue(i, j, Pt); |
74 | } |
75 | } |
76 | |
77 | aSurfaceForm = StepGeom_bssfUnspecified; |
78 | |
79 | if (BS->IsUClosed()) |
80 | aUClosed = StepData_LTrue; |
81 | else |
82 | aUClosed = StepData_LFalse; |
83 | |
84 | if (BS->IsVClosed()) |
85 | aVClosed = StepData_LTrue; |
86 | else |
87 | aVClosed = StepData_LFalse; |
88 | |
89 | aSelfIntersect = StepData_LFalse; |
90 | |
91 | NUknots = BS->NbUKnots(); |
92 | NVknots = BS->NbVKnots(); |
93 | TColStd_Array1OfInteger MU(1,NUknots); |
94 | BS->UMultiplicities(MU); |
95 | aUMultiplicities = new TColStd_HArray1OfInteger(1,NUknots); |
96 | for ( i=MU.Lower(); i<=MU.Upper(); i++) { |
97 | itampon = MU.Value(i); |
98 | aUMultiplicities->SetValue(i, itampon); |
99 | } |
100 | TColStd_Array1OfInteger MV(1,NVknots); |
101 | BS->VMultiplicities(MV); |
102 | aVMultiplicities = new TColStd_HArray1OfInteger(1,NVknots); |
103 | for ( i=MV.Lower(); i<=MV.Upper(); i++) { |
104 | itampon = MV.Value(i); |
105 | aVMultiplicities->SetValue(i, itampon); |
106 | } |
107 | |
108 | TColStd_Array1OfReal KU(1,NUknots); |
109 | TColStd_Array1OfReal KV(1,NVknots); |
110 | BS->UKnots(KU); |
111 | BS->VKnots(KV); |
112 | aUKnots = new TColStd_HArray1OfReal(1,NUknots); |
113 | aVKnots = new TColStd_HArray1OfReal(1,NVknots); |
114 | for ( i=KU.Lower(); i<=KU.Upper(); i++) { |
115 | rtampon = KU.Value(i); |
116 | aUKnots->SetValue(i, rtampon); |
117 | } |
118 | for ( i=KV.Lower(); i<=KV.Upper(); i++) { |
119 | rtampon = KV.Value(i); |
120 | aVKnots->SetValue(i, rtampon); |
121 | } |
122 | |
123 | UDistribution = BS->UKnotDistribution(); |
124 | VDistribution = BS->VKnotDistribution(); |
125 | if ( UDistribution == GeomAbs_NonUniform && |
126 | VDistribution == GeomAbs_NonUniform ) |
127 | KnotSpec = StepGeom_ktUnspecified; |
128 | else if ( UDistribution == GeomAbs_Uniform && |
129 | VDistribution == GeomAbs_Uniform ) |
130 | KnotSpec = StepGeom_ktUniformKnots; |
131 | else if ( UDistribution == GeomAbs_QuasiUniform && |
132 | VDistribution == GeomAbs_QuasiUniform ) |
133 | KnotSpec = StepGeom_ktQuasiUniformKnots; |
134 | else if ( UDistribution == GeomAbs_PiecewiseBezier && |
135 | VDistribution == GeomAbs_PiecewiseBezier ) |
136 | KnotSpec = StepGeom_ktPiecewiseBezierKnots; |
137 | else |
138 | KnotSpec = StepGeom_ktUnspecified; |
139 | |
140 | TColStd_Array2OfReal W(1,NU,1,NV); |
141 | BS->Weights(W); |
142 | aWeightsData = new TColStd_HArray2OfReal(1,NU,1,NV); |
143 | for ( i=W.LowerRow(); i<=W.UpperRow(); i++) { |
144 | for (j=W.LowerCol(); j<=W.UpperCol(); j++) { |
145 | rtampon = W.Value(i,j); |
146 | aWeightsData->SetValue(i, j, rtampon); |
147 | } |
148 | } |
149 | |
150 | BSWK = new StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface; |
151 | Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString(""); |
152 | BSWK->Init(name,aUDegree, aVDegree, aControlPointsList, aSurfaceForm, |
153 | aUClosed, aVClosed, aSelfIntersect, aUMultiplicities, |
154 | aVMultiplicities, aUKnots, aVKnots, KnotSpec, aWeightsData ); |
155 | |
156 | theBSplineSurfaceWithKnotsAndRationalBSplineSurface = BSWK; |
157 | done = Standard_True; |
158 | } |
159 | |
160 | //============================================================================= |
161 | // renvoi des valeurs |
162 | //============================================================================= |
163 | |
164 | const Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface) & |
165 | GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface::Value() const |
166 | { |
167 | StdFail_NotDone_Raise_if(!done == Standard_True,""); |
168 | return theBSplineSurfaceWithKnotsAndRationalBSplineSurface; |
169 | } |