0024428: Implementation of LGPL license
[occt.git] / src / BRepBlend / BRepBlend_AppSurface.cxx
CommitLineData
b311480e 1// Created on: 1996-11-26
2// Created by: Philippe MANGIN
3// Copyright (c) 1996-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//
973c2be1 8// This library is free software; you can redistribute it and / or modify it
9// under the terms of the GNU Lesser General Public 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.
b311480e 13//
973c2be1 14// Alternatively, this file may be used under the terms of Open CASCADE
15// commercial license or contractual agreement.
7fd59977 16
17#include <BRepBlend_AppSurface.ixx>
18
19#include <TColgp_Array1OfPnt.hxx>
20#include <TColgp_Array1OfPnt2d.hxx>
21#include <TColgp_Array1OfVec.hxx>
22#include <TColgp_Array1OfVec2d.hxx>
23#include <TColStd_Array1OfReal.hxx>
24
25#include <StdFail_NotDone.hxx>
26
27
28BRepBlend_AppSurface::BRepBlend_AppSurface(
29 Handle(Approx_SweepFunction)& Func,
30 const Standard_Real First,
31 const Standard_Real Last,
32 const Standard_Real Tol3d,
33 const Standard_Real Tol2d,
34 const Standard_Real TolAngular,
35 const GeomAbs_Shape Continuity,
36 const Standard_Integer Degmax,
37 const Standard_Integer Segmax) :
38 approx(Func)
39{
40 Standard_Integer Nb2d = Func->Nb2dCurves();
41 Standard_Integer NbPolSect, NbKnotSect, udeg;
42 GeomAbs_Shape continuity = Continuity;
43
44// (1) Verification de la possibilite de derivation
45 if (continuity != GeomAbs_C0) {
46 if (Nb2d == 0) Nb2d =1;
47 Func->SectionShape(NbPolSect, NbKnotSect, udeg);
48 TColStd_Array1OfReal W (1, NbPolSect);
49 TColgp_Array1OfPnt P (1, NbPolSect);
50 TColgp_Array1OfPnt2d P2d(1, Nb2d);
51 TColgp_Array1OfVec V (1, NbPolSect);
52 TColgp_Array1OfVec2d V2d(1, Nb2d);
53 Standard_Boolean Ok;
54 if (continuity == GeomAbs_C2) {
55 Ok = Func->D2( First, First, Last, P, V, V, P2d, V2d, V2d, W, W, W);
56 if (!Ok) { continuity = GeomAbs_C1; }
57 }
58 if (continuity == GeomAbs_C1) {
59 Ok = (Func->D1(First, First, Last, P, V, P2d, V2d, W, W));
60 if (!Ok) { continuity = GeomAbs_C0; }
61 }
62 }
63
64
65// (2) Approximation
66 approx.Perform(First, Last,
67 Tol3d, Tol3d, Tol2d, TolAngular,
68 continuity, Degmax, Segmax);
69 }
70
71void BRepBlend_AppSurface::SurfShape (Standard_Integer& UDegree,
72 Standard_Integer& VDegree,
73 Standard_Integer& NbUPoles,
74 Standard_Integer& NbVPoles,
75 Standard_Integer& NbUKnots,
76 Standard_Integer& NbVKnots) const
77{
78 approx.SurfShape(UDegree, VDegree,
79 NbUPoles, NbVPoles,
80 NbUKnots,NbVKnots);
81}
82
83
84void BRepBlend_AppSurface::Surface(TColgp_Array2OfPnt& TPoles,
85 TColStd_Array2OfReal& TWeights,
86 TColStd_Array1OfReal& TUKnots,
87 TColStd_Array1OfReal& TVKnots,
88 TColStd_Array1OfInteger& TUMults,
89 TColStd_Array1OfInteger& TVMults) const
90
91{
92 approx.Surface(TPoles, TWeights, TUKnots,TVKnots, TUMults,TVMults);
93}
94
95
96Standard_Real BRepBlend_AppSurface::MaxErrorOnSurf() const
97{
98 return approx.MaxErrorOnSurf();
99}
100
101
102void BRepBlend_AppSurface::Curves2dShape(Standard_Integer& Degree,
103 Standard_Integer& NbPoles,
104 Standard_Integer& NbKnots) const
105{
106 approx.Curves2dShape( Degree, NbPoles, NbKnots);
107}
108
109void BRepBlend_AppSurface::Curve2d(const Standard_Integer Index,
110 TColgp_Array1OfPnt2d& TPoles,
111 TColStd_Array1OfReal& TKnots,
112 TColStd_Array1OfInteger& TMults) const
113{
114 approx.Curve2d(Index, TPoles, TKnots, TMults);
115}
116
117Standard_Real BRepBlend_AppSurface::Max2dError(const Standard_Integer Index) const
118{
119 return approx.Max2dError(Index);
120}
121
122
123Standard_Real BRepBlend_AppSurface::TolCurveOnSurf(const Standard_Integer Index) const
124{
125 return approx.TolCurveOnSurf(Index);
126}
127
128inline void BRepBlend_AppSurface::TolReached (Standard_Real& Tol3d,
129 Standard_Real& Tol2d) const
130{
131 Tol3d = approx.MaxErrorOnSurf();
132 Tol2d = 0;
133 for (Standard_Integer ii=1; ii<=approx.NbCurves2d(); ii++) {
134 Tol2d = Max(Tol2d, approx.Max2dError(ii));
135 }
136}
137
138void BRepBlend_AppSurface::Dump(Standard_OStream& o) const
139{
140 approx.Dump(o);
141}