1 // Created on: 1993-06-22
2 // Created by: Martine LANGLOIS
3 // Copyright (c) 1993-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
19 #include <Geom_BSplineSurface.hxx>
20 #include <GeomAbs_BSplKnotDistribution.hxx>
21 #include <GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface.hxx>
22 #include <GeomToStep_MakeCartesianPoint.hxx>
23 #include <StdFail_NotDone.hxx>
24 #include <StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface.hxx>
25 #include <StepGeom_CartesianPoint.hxx>
26 #include <StepGeom_HArray2OfCartesianPoint.hxx>
27 #include <StepGeom_KnotType.hxx>
28 #include <TColgp_Array2OfPnt.hxx>
29 #include <TCollection_HAsciiString.hxx>
30 #include <TColStd_HArray1OfInteger.hxx>
31 #include <TColStd_HArray1OfReal.hxx>
32 #include <TColStd_HArray2OfReal.hxx>
34 //=============================================================================
35 // Creation d' une bspline_Surface_with_knots_and_rational_bspline_Surface de
36 // prostep a partir d' une BSplineSurface de Geom
37 //=============================================================================
38 GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface::
39 GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface( const
40 Handle(Geom_BSplineSurface)& BS )
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;
56 aUDegree = BS->UDegree();
57 aVDegree = BS->VDegree();
61 TColgp_Array2OfPnt P(1,NU,1,NV);
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));
68 aControlPointsList->SetValue(i, j, Pt);
72 aSurfaceForm = StepGeom_bssfUnspecified;
75 aUClosed = StepData_LTrue;
77 aUClosed = StepData_LFalse;
80 aVClosed = StepData_LTrue;
82 aVClosed = StepData_LFalse;
84 aSelfIntersect = StepData_LFalse;
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);
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);
103 TColStd_Array1OfReal KU(1,NUknots);
104 TColStd_Array1OfReal KV(1,NVknots);
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);
113 for ( i=KV.Lower(); i<=KV.Upper(); i++) {
114 rtampon = KV.Value(i);
115 aVKnots->SetValue(i, rtampon);
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;
133 KnotSpec = StepGeom_ktUnspecified;
135 TColStd_Array2OfReal W(1,NU,1,NV);
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);
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 );
151 theBSplineSurfaceWithKnotsAndRationalBSplineSurface = BSWK;
152 done = Standard_True;
155 //=============================================================================
156 // renvoi des valeurs
157 //=============================================================================
159 const Handle(StepGeom_BSplineSurfaceWithKnotsAndRationalBSplineSurface) &
160 GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface::Value() const
162 StdFail_NotDone_Raise_if (!done, "GeomToStep_MakeBSplineSurfaceWithKnotsAndRationalBSplineSurface::Value() - no result");
163 return theBSplineSurfaceWithKnotsAndRationalBSplineSurface;