0031687: Draw Harness, ViewerTest - extend command vrenderparams with option updating...
[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//
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.
7fd59977 16
7fd59977 17
42cf5bc1 18#include <Approx_SweepFunction.hxx>
19#include <BRepBlend_AppSurface.hxx>
20#include <Standard_DomainError.hxx>
21#include <Standard_OutOfRange.hxx>
22#include <StdFail_NotDone.hxx>
7fd59977 23#include <TColgp_Array1OfPnt.hxx>
24#include <TColgp_Array1OfPnt2d.hxx>
25#include <TColgp_Array1OfVec.hxx>
26#include <TColgp_Array1OfVec2d.hxx>
27#include <TColStd_Array1OfReal.hxx>
28
7fd59977 29BRepBlend_AppSurface::BRepBlend_AppSurface(
7f22979e 30 const Handle(Approx_SweepFunction)& Func,
7fd59977 31 const Standard_Real First,
32 const Standard_Real Last,
33 const Standard_Real Tol3d,
34 const Standard_Real Tol2d,
35 const Standard_Real TolAngular,
36 const GeomAbs_Shape Continuity,
37 const Standard_Integer Degmax,
38 const Standard_Integer Segmax) :
39 approx(Func)
40{
41 Standard_Integer Nb2d = Func->Nb2dCurves();
42 Standard_Integer NbPolSect, NbKnotSect, udeg;
43 GeomAbs_Shape continuity = Continuity;
44
45// (1) Verification de la possibilite de derivation
46 if (continuity != GeomAbs_C0) {
47 if (Nb2d == 0) Nb2d =1;
48 Func->SectionShape(NbPolSect, NbKnotSect, udeg);
49 TColStd_Array1OfReal W (1, NbPolSect);
50 TColgp_Array1OfPnt P (1, NbPolSect);
51 TColgp_Array1OfPnt2d P2d(1, Nb2d);
52 TColgp_Array1OfVec V (1, NbPolSect);
53 TColgp_Array1OfVec2d V2d(1, Nb2d);
54 Standard_Boolean Ok;
55 if (continuity == GeomAbs_C2) {
56 Ok = Func->D2( First, First, Last, P, V, V, P2d, V2d, V2d, W, W, W);
57 if (!Ok) { continuity = GeomAbs_C1; }
58 }
59 if (continuity == GeomAbs_C1) {
60 Ok = (Func->D1(First, First, Last, P, V, P2d, V2d, W, W));
61 if (!Ok) { continuity = GeomAbs_C0; }
62 }
63 }
64
65
66// (2) Approximation
67 approx.Perform(First, Last,
68 Tol3d, Tol3d, Tol2d, TolAngular,
69 continuity, Degmax, Segmax);
70 }
71
72void BRepBlend_AppSurface::SurfShape (Standard_Integer& UDegree,
73 Standard_Integer& VDegree,
74 Standard_Integer& NbUPoles,
75 Standard_Integer& NbVPoles,
76 Standard_Integer& NbUKnots,
77 Standard_Integer& NbVKnots) const
78{
79 approx.SurfShape(UDegree, VDegree,
80 NbUPoles, NbVPoles,
81 NbUKnots,NbVKnots);
82}
83
84
85void BRepBlend_AppSurface::Surface(TColgp_Array2OfPnt& TPoles,
86 TColStd_Array2OfReal& TWeights,
87 TColStd_Array1OfReal& TUKnots,
88 TColStd_Array1OfReal& TVKnots,
89 TColStd_Array1OfInteger& TUMults,
90 TColStd_Array1OfInteger& TVMults) const
91
92{
93 approx.Surface(TPoles, TWeights, TUKnots,TVKnots, TUMults,TVMults);
94}
95
96
97Standard_Real BRepBlend_AppSurface::MaxErrorOnSurf() const
98{
99 return approx.MaxErrorOnSurf();
100}
101
102
103void BRepBlend_AppSurface::Curves2dShape(Standard_Integer& Degree,
104 Standard_Integer& NbPoles,
105 Standard_Integer& NbKnots) const
106{
107 approx.Curves2dShape( Degree, NbPoles, NbKnots);
108}
109
110void BRepBlend_AppSurface::Curve2d(const Standard_Integer Index,
111 TColgp_Array1OfPnt2d& TPoles,
112 TColStd_Array1OfReal& TKnots,
113 TColStd_Array1OfInteger& TMults) const
114{
115 approx.Curve2d(Index, TPoles, TKnots, TMults);
116}
117
118Standard_Real BRepBlend_AppSurface::Max2dError(const Standard_Integer Index) const
119{
120 return approx.Max2dError(Index);
121}
122
123
124Standard_Real BRepBlend_AppSurface::TolCurveOnSurf(const Standard_Integer Index) const
125{
126 return approx.TolCurveOnSurf(Index);
127}
128
746cb7c3 129void BRepBlend_AppSurface::TolReached (Standard_Real& Tol3d,
130 Standard_Real& Tol2d) const
7fd59977 131{
132 Tol3d = approx.MaxErrorOnSurf();
133 Tol2d = 0;
134 for (Standard_Integer ii=1; ii<=approx.NbCurves2d(); ii++) {
135 Tol2d = Max(Tol2d, approx.Max2dError(ii));
136 }
137}
138
139void BRepBlend_AppSurface::Dump(Standard_OStream& o) const
140{
141 approx.Dump(o);
142}