summaryrefslogtreecommitdiff
path: root/src/FilletSurf/FilletSurf_Builder.cxx
blob: 5c119e7be7fdea93fbe227c75d841772787b6dd8 (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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
// File:	FilletSurf_Builder.cxx
// Created:	???
// Author:	
//		
// Modifed:     Portage NT 7-5-97 DPF (return)

#include <FilletSurf_Builder.ixx>
#include <FilletSurf_InternalBuilder.hxx>
#include <TopoDS.hxx>
#include <Geom_Surface.hxx>
#include <Geom_Curve.hxx>
#include <Geom2d_Curve.hxx>
#include <ChFi3d_FilletShape.hxx>
#include <Geom_TrimmedCurve.hxx>
#include <StdFail_NotDone.hxx>
#include <FilletSurf_ErrorTypeStatus.hxx>

//=======================================================================
//function : FilletSurf_Builder
//purpose  : 
//=======================================================================

FilletSurf_Builder::FilletSurf_Builder(const TopoDS_Shape& S, 
	                               const TopTools_ListOfShape& E, 
				       const Standard_Real R,			       
				       const Standard_Real Ta,
                                       const Standard_Real Tapp3d,
                                       const Standard_Real Tapp2d ):
                                       myIntBuild(S,ChFi3d_Polynomial,Ta,Tapp3d,Tapp2d)
{
  myisdone=FilletSurf_IsOk;
  int add =myIntBuild.Add(E,R);
  if (add!=0) { 
    myisdone=FilletSurf_IsNotOk;  
    if     (add==1)  myerrorstatus=FilletSurf_EmptyList;
    else if(add==2)  myerrorstatus=FilletSurf_EdgeNotG1;              
    else if(add==3)  myerrorstatus=FilletSurf_FacesNotG1;
    else if(add==4)  myerrorstatus=FilletSurf_EdgeNotOnShape;
    else if(add==5)  myerrorstatus=FilletSurf_NotSharpEdge;
  }
}
//========================================================
//
//============================================================

void FilletSurf_Builder::Perform()
{
  if (myisdone==FilletSurf_IsOk) {
    myIntBuild.Perform();
    if (myIntBuild.Done()) myisdone=FilletSurf_IsOk;
    else if (myIntBuild.NbSurface()!=0) {
      myisdone=FilletSurf_IsPartial;
      myerrorstatus=FilletSurf_PbFilletCompute; 
    }
    else { 
      myisdone=FilletSurf_IsNotOk;
      myerrorstatus=FilletSurf_PbFilletCompute; 
    }
  }  
}

//=======================================================================
//function : IsDone 
//purpose  :  gives the status of the computation of the fillet 
//=======================================================================
FilletSurf_StatusDone FilletSurf_Builder::IsDone() const 
{
 return myisdone;
}

//=======================================================================
//function : ErrorTypeStatus
//purpose  :  gives the status  of the error 
//=======================================================================
FilletSurf_ErrorTypeStatus FilletSurf_Builder::StatusError() const 
{
 return  myerrorstatus;
}


//=======================================================================
//function : NbSurface
//purpose  :  gives the number of NUBS surfaces  of the Fillet
//=======================================================================

Standard_Integer FilletSurf_Builder::NbSurface() const 
{
  if (IsDone()!=FilletSurf_IsNotOk)  return myIntBuild.NbSurface();
  StdFail_NotDone::Raise("FilletSurf_Builder::NbSurface");
  return 0;
}

//=======================================================================
//function : SurfaceFillet
//purpose  : gives the NUBS surface of index Index
//=======================================================================

const Handle(Geom_Surface)& FilletSurf_Builder::SurfaceFillet(const Standard_Integer Index) const 
{
  if ( (Index<1)||(Index>NbSurface())) Standard_OutOfRange::Raise("FilletSurf_Builder::SurfaceFillet");
  return myIntBuild.SurfaceFillet(Index); 
}

//=======================================================================
//function : TolApp3d
//purpose  :  gives the 3d tolerance reached during approximation 
//=======================================================================
Standard_Real  FilletSurf_Builder::TolApp3d(const Standard_Integer Index) const 
{
  if ( (Index<1)||(Index>NbSurface())) 
    Standard_OutOfRange::Raise("FilletSurf_Builder::TolApp3d");
  return myIntBuild.TolApp3d(Index);
}

//=======================================================================
//function : SupportFace1 
//purpose  : gives the first support  face relative to SurfaceFillet(Index)
//=======================================================================
const TopoDS_Face& FilletSurf_Builder::SupportFace1(const Standard_Integer Index) const
{
  if ( (Index<1)||(Index>NbSurface())) 
    Standard_OutOfRange::Raise("FilletSurf_Builder::SupportFace1");
  return myIntBuild.SupportFace1(Index); 
}

//=======================================================================
//function : SupportFace2
//purpose  : gives the second support face relative to SurfaceFillet(Index)
//=======================================================================
const TopoDS_Face& FilletSurf_Builder::SupportFace2(const Standard_Integer Index) const 
{
 if ( (Index<1)||(Index>NbSurface())) 
   Standard_OutOfRange::Raise("FilletSurf_Builder::SupportFace2");
 return myIntBuild.SupportFace2(Index);
  
}

//===============================================================================
//function : CurveOnFace1 
//purpose  :  gives  the 3d curve  of SurfaceFillet(Index)  on SupportFace1(Index)
//===============================================================================
const Handle(Geom_Curve)& FilletSurf_Builder::CurveOnFace1(const Standard_Integer Index) const 
{
  if ( (Index<1)||(Index>NbSurface())) 
    Standard_OutOfRange::Raise("FilletSurf_Builder::CurveOnFace1"); 
  return myIntBuild.CurveOnFace1(Index);
}

//=======================================================================
//function : CurveOnFace2
//purpose  : gives the 3d  curve of  SurfaceFillet(Index) on SupportFace2(Index
//=======================================================================
const Handle(Geom_Curve)& FilletSurf_Builder::CurveOnFace2(const Standard_Integer Index) const 
{ 
  if ( (Index<1)||(Index>NbSurface())) 
    Standard_OutOfRange::Raise("FilletSurf_Builder::CurveOnFace2"); 
  return myIntBuild.CurveOnFace2(Index);
}

//=======================================================================
//function : PCurveOnFace1
//purpose  : gives the  PCurve associated to CurveOnFace1(Index)  on the support face
//=======================================================================
const Handle(Geom2d_Curve)& FilletSurf_Builder::PCurveOnFace1(const Standard_Integer Index) const 
{ 
  if ( (Index<1)||(Index>NbSurface())) 
    Standard_OutOfRange::Raise( "FilletSurf_Builder::PCurveOnFace1"); 
  return myIntBuild.PCurveOnFace1(Index);
}

//=======================================================================
//function : PCurve1OnFillet
//purpose  : gives the PCurve associated to CurveOnFace1(Index) on the Fillet
//=======================================================================
const Handle(Geom2d_Curve)& FilletSurf_Builder::PCurve1OnFillet(const Standard_Integer Index) const 
{ 
  if ( (Index<1)||(Index>NbSurface())) 
    Standard_OutOfRange::Raise("FilletSurf_Builder::PCurve1OnFillet");
  return myIntBuild.PCurve1OnFillet(Index);
}

//=======================================================================
//function : PCurveOnFace2
//purpose  : gives the  PCurve associated to CurveOnFace2(Index)  on the support face
//=======================================================================
const Handle(Geom2d_Curve)& FilletSurf_Builder::PCurveOnFace2(const Standard_Integer Index) const 
{
  if ( (Index<1)||(Index>NbSurface())) 
    Standard_OutOfRange::Raise("FilletSurf_Builder::PCurveOnFace2");
  return myIntBuild.PCurveOnFace2(Index);
}

//=======================================================================
//function : PCurve2OnFillet
//purpose  : gives the PCurve associated to CurveOnFace2(Index) on the Fillet
//=======================================================================
const Handle(Geom2d_Curve)& FilletSurf_Builder::PCurve2OnFillet(const Standard_Integer Index) const 
{
  if ( (Index<1)||(Index>NbSurface())) 
    Standard_OutOfRange::Raise("FilletSurf_Builder::PCurve2OnFillet");
  return myIntBuild.PCurve2OnFillet(Index);
}

//=======================================================================
//function : FirstParameter 
//purpose  : gives the parameter of the fillet  on the first edge
//=======================================================================
Standard_Real FilletSurf_Builder::FirstParameter() const
{
  if (IsDone()==FilletSurf_IsNotOk) 
    StdFail_NotDone::Raise("FilletSurf_Builder::FirstParameter");
  return myIntBuild.FirstParameter();
}

//=======================================================================
//function : LastParameter
//purpose  :  gives the parameter of the fillet  on the last edge
//=======================================================================
Standard_Real FilletSurf_Builder::LastParameter() const
{
  if (IsDone()==FilletSurf_IsNotOk) 
    StdFail_NotDone::Raise("FilletSurf_Builder::LastParameter");
  return myIntBuild.LastParameter();
}

//=======================================================================
//function : StatusStartSection
//purpose  :  returns: 
//            twoExtremityonEdge: each extremity of  start section of the Fillet is
//                                on the edge of  the corresponding support face.  
//            OneExtremityOnEdge: only one  of  the extremities of  start section  of the  Fillet 
//                                is on the  edge of the corresponding support face.  
//            NoExtremityOnEdge:  any extremity of  the start section  ofthe fillet is  on  
//                                the edge  of   the  corresponding support face.
//=======================================================================
FilletSurf_StatusType  FilletSurf_Builder::StartSectionStatus() const 
{
  if (IsDone()==FilletSurf_IsNotOk)
    StdFail_NotDone::Raise("FilletSurf_Builder::StartSectionStatus" );
  return  myIntBuild.StartSectionStatus();
}

//=======================================================================
//function : StatusEndSection
//purpose  :  returns: 
//       twoExtremityonEdge: each extremity of  end section of the Fillet is
//                        on the edge of  the corresponding support face.  
//       OneExtremityOnEdge:  only one  of  the extremities of  end  section  of the  Fillet 
//                           is on the  edge of the corresponding support face.  
//       NoExtremityOnEdge:  any extremity of  the end  section  of the fillet is  on  
//                           the edge  of   the  corresponding support face. 
//=======================================================================
FilletSurf_StatusType  FilletSurf_Builder::EndSectionStatus() const 
{
  if (IsDone()==FilletSurf_IsNotOk) 
    StdFail_NotDone::Raise("FilletSurf_Builder::StartSectionStatus");
  return  myIntBuild.EndSectionStatus(); 
}

//=======================================================================
//function : Simulate 
//purpose  :  computes only the sections used in the computation of the fillet
//=======================================================================
void FilletSurf_Builder::Simulate()
{
  if (myisdone==FilletSurf_IsOk) {
    myIntBuild.Simulate();
    
    if (myIntBuild.Done()) myisdone=FilletSurf_IsOk;
    else { myisdone=FilletSurf_IsNotOk;
	   myerrorstatus=FilletSurf_PbFilletCompute;}
  }
} 

//=======================================================================
//function : NbSection 
//purpose  :  gives the number of sections relative to SurfaceFillet(IndexSurf) 
//=======================================================================
Standard_Integer FilletSurf_Builder::NbSection(const Standard_Integer IndexSurf) const 
{
  if (IsDone()==FilletSurf_IsNotOk) 
    StdFail_NotDone::Raise("FilletSurf_Builder::NbSection)");
  else if ( (IndexSurf<1)||(IndexSurf>NbSurface())) Standard_OutOfRange::Raise
    ("FilletSurf_Builder::NbSection");
  return myIntBuild.NbSection(IndexSurf);
}

//=======================================================================
//function : Section 
//purpose  :  gives the   arc of circle corresponding    to section number 
// IndexSec  of  SurfaceFillet(IndexSurf)  (The   basis curve  of the 
// trimmed curve is a Geom_Circle)
//=======================================================================
void FilletSurf_Builder::Section(const Standard_Integer IndexSurf,
				 const Standard_Integer IndexSec,
				 Handle(Geom_TrimmedCurve)& Circ) const 
{
  if ((IndexSurf<1)||(IndexSurf>NbSurface())) 
    Standard_OutOfRange::Raise("FilletSurf_Builder::Section NbSurface");

  else if ((IndexSec<1)||(IndexSec>NbSection(IndexSurf))) 
    Standard_OutOfRange::Raise("FilletSurf_Builder::Section NbSection");

  else myIntBuild.Section(IndexSurf, IndexSec,Circ);
}