b311480e |
1 | // Created on: 1993-06-22 |
2 | // Created by: Martine LANGLOIS |
3 | // Copyright (c) 1993-1999 Matra Datavision |
973c2be1 |
4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e |
5 | // |
973c2be1 |
6 | // This file is part of Open CASCADE Technology software library. |
b311480e |
7 | // |
d5f74e42 |
8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published |
973c2be1 |
10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT |
12 | // distribution for complete text of the license and disclaimer of any warranty. |
b311480e |
13 | // |
973c2be1 |
14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. |
b311480e |
16 | |
7fd59977 |
17 | // .cxx |
7fd59977 |
18 | |
7fd59977 |
19 | #include <Geom_BSplineSurface.hxx> |
42cf5bc1 |
20 | #include <GeomAbs_BSplKnotDistribution.hxx> |
21 | #include <GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface.hxx> |
22 | #include <GeomToStep_MakeCartesianPoint.hxx> |
23 | #include <StdFail_NotDone.hxx> |
7fd59977 |
24 | #include <StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface.hxx> |
25 | #include <StepGeom_CartesianPoint.hxx> |
7fd59977 |
26 | #include <StepGeom_HArray2OfCartesianPoint.hxx> |
42cf5bc1 |
27 | #include <StepGeom_KnotType.hxx> |
28 | #include <TColgp_Array2OfPnt.hxx> |
29 | #include <TCollection_HAsciiString.hxx> |
7fd59977 |
30 | #include <TColStd_HArray1OfInteger.hxx> |
31 | #include <TColStd_HArray1OfReal.hxx> |
32 | #include <TColStd_HArray2OfReal.hxx> |
7fd59977 |
33 | |
34 | //============================================================================= |
35 | // Creation d' une bspline_Surface_with_knots_and_rational_bspline_Surface de |
36 | // prostep a partir d' une BSplineSurface de Geom |
37 | //============================================================================= |
7fd59977 |
38 | GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface:: |
39 | GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface( const |
40 | Handle(Geom_BSplineSurface)& BS ) |
41 | |
42 | { |
43 | Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface) BSWK; |
44 | Standard_Integer aUDegree, aVDegree, NU, NV, i, j, NUknots, NVknots, itampon; |
45 | Standard_Real rtampon; |
46 | Handle(StepGeom_CartesianPoint) Pt = new StepGeom_CartesianPoint; |
47 | Handle(StepGeom_HArray2OfCartesianPoint) aControlPointsList; |
48 | StepGeom_BSplineSurfaceForm aSurfaceForm; |
49 | StepData_Logical aUClosed, aVClosed, aSelfIntersect; |
50 | Handle(TColStd_HArray1OfInteger) aUMultiplicities, aVMultiplicities; |
51 | Handle(TColStd_HArray1OfReal) aUKnots, aVKnots; |
52 | Handle(TColStd_HArray2OfReal) aWeightsData; |
53 | GeomAbs_BSplKnotDistribution UDistribution, VDistribution; |
54 | StepGeom_KnotType KnotSpec; |
55 | |
56 | aUDegree = BS->UDegree(); |
57 | aVDegree = BS->VDegree(); |
58 | |
59 | NU = BS->NbUPoles(); |
60 | NV = BS->NbVPoles(); |
61 | TColgp_Array2OfPnt P(1,NU,1,NV); |
62 | BS->Poles(P); |
63 | aControlPointsList = new StepGeom_HArray2OfCartesianPoint(1,NU,1,NV); |
64 | for ( i=P.LowerRow(); i<=P.UpperRow(); i++) { |
65 | for ( j=P.LowerCol(); j<=P.UpperCol(); j++) { |
66 | GeomToStep_MakeCartesianPoint MkPoint(P.Value(i,j)); |
67 | Pt = MkPoint.Value(); |
68 | aControlPointsList->SetValue(i, j, Pt); |
69 | } |
70 | } |
71 | |
72 | aSurfaceForm = StepGeom_bssfUnspecified; |
73 | |
74 | if (BS->IsUClosed()) |
75 | aUClosed = StepData_LTrue; |
76 | else |
77 | aUClosed = StepData_LFalse; |
78 | |
79 | if (BS->IsVClosed()) |
80 | aVClosed = StepData_LTrue; |
81 | else |
82 | aVClosed = StepData_LFalse; |
83 | |
84 | aSelfIntersect = StepData_LFalse; |
85 | |
86 | NUknots = BS->NbUKnots(); |
87 | NVknots = BS->NbVKnots(); |
88 | TColStd_Array1OfInteger MU(1,NUknots); |
89 | BS->UMultiplicities(MU); |
90 | aUMultiplicities = new TColStd_HArray1OfInteger(1,NUknots); |
91 | for ( i=MU.Lower(); i<=MU.Upper(); i++) { |
92 | itampon = MU.Value(i); |
93 | aUMultiplicities->SetValue(i, itampon); |
94 | } |
95 | TColStd_Array1OfInteger MV(1,NVknots); |
96 | BS->VMultiplicities(MV); |
97 | aVMultiplicities = new TColStd_HArray1OfInteger(1,NVknots); |
98 | for ( i=MV.Lower(); i<=MV.Upper(); i++) { |
99 | itampon = MV.Value(i); |
100 | aVMultiplicities->SetValue(i, itampon); |
101 | } |
102 | |
103 | TColStd_Array1OfReal KU(1,NUknots); |
104 | TColStd_Array1OfReal KV(1,NVknots); |
105 | BS->UKnots(KU); |
106 | BS->VKnots(KV); |
107 | aUKnots = new TColStd_HArray1OfReal(1,NUknots); |
108 | aVKnots = new TColStd_HArray1OfReal(1,NVknots); |
109 | for ( i=KU.Lower(); i<=KU.Upper(); i++) { |
110 | rtampon = KU.Value(i); |
111 | aUKnots->SetValue(i, rtampon); |
112 | } |
113 | for ( i=KV.Lower(); i<=KV.Upper(); i++) { |
114 | rtampon = KV.Value(i); |
115 | aVKnots->SetValue(i, rtampon); |
116 | } |
117 | |
118 | UDistribution = BS->UKnotDistribution(); |
119 | VDistribution = BS->VKnotDistribution(); |
120 | if ( UDistribution == GeomAbs_NonUniform && |
121 | VDistribution == GeomAbs_NonUniform ) |
122 | KnotSpec = StepGeom_ktUnspecified; |
123 | else if ( UDistribution == GeomAbs_Uniform && |
124 | VDistribution == GeomAbs_Uniform ) |
125 | KnotSpec = StepGeom_ktUniformKnots; |
126 | else if ( UDistribution == GeomAbs_QuasiUniform && |
127 | VDistribution == GeomAbs_QuasiUniform ) |
128 | KnotSpec = StepGeom_ktQuasiUniformKnots; |
129 | else if ( UDistribution == GeomAbs_PiecewiseBezier && |
130 | VDistribution == GeomAbs_PiecewiseBezier ) |
131 | KnotSpec = StepGeom_ktPiecewiseBezierKnots; |
132 | else |
133 | KnotSpec = StepGeom_ktUnspecified; |
134 | |
135 | TColStd_Array2OfReal W(1,NU,1,NV); |
136 | BS->Weights(W); |
137 | aWeightsData = new TColStd_HArray2OfReal(1,NU,1,NV); |
138 | for ( i=W.LowerRow(); i<=W.UpperRow(); i++) { |
139 | for (j=W.LowerCol(); j<=W.UpperCol(); j++) { |
140 | rtampon = W.Value(i,j); |
141 | aWeightsData->SetValue(i, j, rtampon); |
142 | } |
143 | } |
144 | |
145 | BSWK = new StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface; |
146 | Handle(TCollection_HAsciiString) name = new TCollection_HAsciiString(""); |
147 | BSWK->Init(name,aUDegree, aVDegree, aControlPointsList, aSurfaceForm, |
148 | aUClosed, aVClosed, aSelfIntersect, aUMultiplicities, |
149 | aVMultiplicities, aUKnots, aVKnots, KnotSpec, aWeightsData ); |
150 | |
151 | theBSplineSurfaceWithKnotsAndRationalBSplineSurface = BSWK; |
152 | done = Standard_True; |
153 | } |
154 | |
155 | //============================================================================= |
156 | // renvoi des valeurs |
157 | //============================================================================= |
158 | |
159 | const Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface) & |
160 | GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface::Value() const |
161 | { |
2d2b3d53 |
162 | StdFail_NotDone_Raise_if (!done, "GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface::Value() - no result"); |
7fd59977 |
163 | return theBSplineSurfaceWithKnotsAndRationalBSplineSurface; |
164 | } |