summaryrefslogtreecommitdiff
path: root/src/BRepBlend/BRepBlend_AppSurface.cxx
blob: 0a93e93e2f6d2b1a0e6352bf48d49ade5e95b2b8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
// File:	BrepBlend_AppSurface.cxx
// Created:	Tue Nov 26 09:43:16 1996
// Author:	Philippe MANGIN
//		<pmn@sgi29>


#include <BRepBlend_AppSurface.ixx>

#include <TColgp_Array1OfPnt.hxx>
#include <TColgp_Array1OfPnt2d.hxx>
#include <TColgp_Array1OfVec.hxx>
#include <TColgp_Array1OfVec2d.hxx>
#include <TColStd_Array1OfReal.hxx>

#include <StdFail_NotDone.hxx>


BRepBlend_AppSurface::BRepBlend_AppSurface(
			       Handle(Approx_SweepFunction)& Func,
			       const Standard_Real First, 
			       const Standard_Real Last,
			       const Standard_Real Tol3d, 
			       const Standard_Real Tol2d,
			       const Standard_Real TolAngular,
			       const GeomAbs_Shape Continuity,
			       const Standard_Integer Degmax, 
			       const Standard_Integer Segmax) :
			       approx(Func)
{
   Standard_Integer Nb2d = Func->Nb2dCurves();
   Standard_Integer NbPolSect, NbKnotSect, udeg;
   GeomAbs_Shape   continuity = Continuity;

// (1) Verification de la possibilite de derivation
  if (continuity != GeomAbs_C0) {
    if (Nb2d == 0) Nb2d =1;
    Func->SectionShape(NbPolSect, NbKnotSect, udeg);
    TColStd_Array1OfReal W  (1, NbPolSect);
    TColgp_Array1OfPnt   P  (1, NbPolSect);
    TColgp_Array1OfPnt2d P2d(1, Nb2d);
    TColgp_Array1OfVec   V  (1, NbPolSect);
    TColgp_Array1OfVec2d V2d(1, Nb2d);
    Standard_Boolean Ok;
    if (continuity == GeomAbs_C2) {
        Ok = Func->D2( First, First, Last, P, V, V, P2d, V2d, V2d, W, W, W);
	if (!Ok) { continuity = GeomAbs_C1; }
      }
    if (continuity == GeomAbs_C1) {
      Ok = (Func->D1(First, First, Last, P, V, P2d, V2d, W, W));
      if (!Ok) { continuity = GeomAbs_C0; }
    }
  }
  

// (2) Approximation
   approx.Perform(First, Last, 
		  Tol3d,  Tol3d,  Tol2d,  TolAngular, 
		  continuity, Degmax, Segmax);	  
 }

void BRepBlend_AppSurface::SurfShape (Standard_Integer& UDegree,
				  Standard_Integer& VDegree,
				  Standard_Integer& NbUPoles,
				  Standard_Integer& NbVPoles,
				  Standard_Integer& NbUKnots,
				  Standard_Integer& NbVKnots) const
{
  approx.SurfShape(UDegree, VDegree, 
		   NbUPoles, NbVPoles, 
		   NbUKnots,NbVKnots); 
}


void BRepBlend_AppSurface::Surface(TColgp_Array2OfPnt& TPoles,
			       TColStd_Array2OfReal& TWeights,
			       TColStd_Array1OfReal& TUKnots,
			       TColStd_Array1OfReal& TVKnots,
			       TColStd_Array1OfInteger& TUMults,
			       TColStd_Array1OfInteger& TVMults) const

{
  approx.Surface(TPoles, TWeights, TUKnots,TVKnots, TUMults,TVMults);
}


Standard_Real BRepBlend_AppSurface::MaxErrorOnSurf() const 
{
  return approx.MaxErrorOnSurf();
}


void BRepBlend_AppSurface::Curves2dShape(Standard_Integer& Degree,
				   Standard_Integer& NbPoles,
				   Standard_Integer& NbKnots) const
{
  approx.Curves2dShape( Degree, NbPoles, NbKnots);
}

void BRepBlend_AppSurface::Curve2d(const Standard_Integer Index,
			       TColgp_Array1OfPnt2d& TPoles,
			       TColStd_Array1OfReal& TKnots,
			       TColStd_Array1OfInteger& TMults) const
{
  approx.Curve2d(Index, TPoles, TKnots, TMults);
}

Standard_Real BRepBlend_AppSurface::Max2dError(const Standard_Integer Index) const 
{
  return approx.Max2dError(Index);
}


Standard_Real BRepBlend_AppSurface::TolCurveOnSurf(const Standard_Integer Index) const 
{
  return approx.TolCurveOnSurf(Index);
}

inline void  BRepBlend_AppSurface::TolReached (Standard_Real& Tol3d,
					 Standard_Real& Tol2d) const
{
  Tol3d = approx.MaxErrorOnSurf();
  Tol2d = 0;
  for (Standard_Integer ii=1; ii<=approx.NbCurves2d(); ii++) {
    Tol2d = Max(Tol2d, approx.Max2dError(ii));
  }
}

void BRepBlend_AppSurface::Dump(Standard_OStream& o) const 
{
  approx.Dump(o);
}