summaryrefslogtreecommitdiff
path: root/src/DNaming/DNaming_RevolutionDriver.cxx
blob: 52100f64a2e51d7e8c20026f328b498c9ec8e0c0 (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
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
// File:	DNaming_RevolutionDriver.cxx
// Created:	Wed Jun 17 15:37:42 2009
// Author:	Sergey ZARITCHNY
//		<szy@petrox.nnov.matra-dtv.fr>


#include <DNaming_RevolutionDriver.ixx>

#include <gp_Dir.hxx>
#include <gp_Vec.hxx>
#include <gp_Pnt.hxx>
#include <gp_Ax2.hxx>
#include <Geom_Line.hxx>

#include <BRep_Tool.hxx>
#include <BRepGProp.hxx>
#include <BRepCheck_Shell.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <BRepPrimAPI_MakeRevol.hxx>
#include <TopoDS.hxx>
#include <TopoDS_Shape.hxx>
#include <TopoDS_Edge.hxx>
#include <TopoDS_Wire.hxx>
#include <TopLoc_Location.hxx>
#include <TopExp_Explorer.hxx>
#include <GProp_GProps.hxx>
#include <Precision.hxx>
#include <BRepCheck_Wire.hxx>
#include <BRepPrimAPI_MakeCylinder.hxx>
#include <BRepCheck_Analyzer.hxx>
#include <TopLoc_Location.hxx>
#include <TopoDS_Solid.hxx>
#include <Standard_GUID.hxx>
#include <Standard_Real.hxx>
#include <BRepBuilderAPI_MakeFace.hxx>
#include <TopTools_DataMapOfShapeShape.hxx>
#include <TopTools_MapOfShape.hxx>
#include <TopTools_ListIteratorOfListOfShape.hxx>
#include <TopTools_MapIteratorOfMapOfShape.hxx>
#include <TopExp.hxx>
#include <BRepBuilderAPI_MakeWire.hxx>

// OCAF
#include <TDataStd_Integer.hxx>
#include <TDataStd_Real.hxx>
#include <TNaming.hxx>
#include <TNaming_Builder.hxx>
#include <TNaming_NamedShape.hxx>
#include <TFunction_Function.hxx>
#include <TFunction_Logbook.hxx>
#include <TDF_Label.hxx>
#include <TDF_TagSource.hxx>

#include <DNaming.hxx>
#include <ModelDefinitions.hxx>

//=======================================================================
//function : DNaming_RevolutionDriver
//purpose  : Constructor
//=======================================================================
DNaming_RevolutionDriver::DNaming_RevolutionDriver()
{}

//=======================================================================
//function : Validate
//purpose  : Validates labels of a function in <theLog>.
//=======================================================================
void DNaming_RevolutionDriver::Validate(TFunction_Logbook& theLog) const
{}

//=======================================================================
//function : MustExecute
//purpose  : Analyses in <theLog> if the loaded function must be executed
//=======================================================================
Standard_Boolean DNaming_RevolutionDriver::MustExecute(const TFunction_Logbook& theLog) const
{
  return Standard_True;
}

#ifdef OCC_DEB
#include <BRepTools.hxx>
static void Write(const TopoDS_Shape& shape,
		      const Standard_CString filename) 
{
  ofstream save;
  save.open(filename);
  save << "DBRep_DrawableShape" << endl << endl;
  if(!shape.IsNull()) BRepTools::Write(shape, save);
  save.close();
}
#endif
//=======================================================================
//function : Execute
//purpose  : Executes the function 
//=======================================================================
Standard_Integer DNaming_RevolutionDriver::Execute(TFunction_Logbook& theLog) const {
  Handle(TFunction_Function) aFunction;
  Label().FindAttribute(TFunction_Function::GetID(), aFunction);
  if(aFunction.IsNull()) return -1;

  // Save location
  Handle(TNaming_NamedShape) aPrevRevol = DNaming::GetFunctionResult(aFunction);
  TopLoc_Location aLocation;
  if (!aPrevRevol.IsNull() && !aPrevRevol->IsEmpty()) {
    aLocation = aPrevRevol->Get().Location();
  }

  //Basis for Revol
  Handle(TDataStd_UAttribute) aBasObject = DNaming::GetObjectArg(aFunction,REVOL_BASIS);
  Handle(TNaming_NamedShape) aBasisNS = DNaming::GetObjectValue(aBasObject);
  if(aBasisNS.IsNull() || aBasisNS->IsEmpty()) {
    aFunction->SetFailure(WRONG_ARGUMENT);
    return -1;
  }
 
  const TopoDS_Shape& aBasis = aBasisNS->Get(); 
  TopoDS_Shape aBASIS;
  if(aBasis.ShapeType() == TopAbs_WIRE) {
    Handle(BRepCheck_Wire) aCheck = new BRepCheck_Wire(TopoDS::Wire(aBasis));
    if(aCheck->Closed(Standard_True) == BRepCheck_NoError) {
      BRepBuilderAPI_MakeFace aMaker (TopoDS::Wire(aBasis), Standard_True); //Makes planar face
      if(aMaker.IsDone()) 
	aBASIS = aMaker.Face();//aMaker.Face();           
    }
  } else if(aBasis.ShapeType() == TopAbs_FACE)
    aBASIS = aBasis;
  if(aBASIS.IsNull()) {
    aFunction->SetFailure(WRONG_ARGUMENT);
    return -1;
  }


  Handle(TNaming_NamedShape) aContextOfBasis;
  Standard_Boolean anIsAttachment = Standard_False;
  if(DNaming::IsAttachment(aBasObject)) {
    aContextOfBasis = DNaming::GetAttachmentsContext(aBasObject); // a Context of Revolution basis
    if(aContextOfBasis.IsNull() || aContextOfBasis->IsEmpty()) {
      aFunction->SetFailure(WRONG_ARGUMENT);
      return -1;
    }
    anIsAttachment = Standard_True;
  }

// Axis 
  Handle(TDataStd_UAttribute) anAxObject = DNaming::GetObjectArg(aFunction,REVOL_AXIS);
  Handle(TNaming_NamedShape) anAxNS = DNaming::GetObjectValue(anAxObject);
  gp_Ax1 anAXIS;
  TopoDS_Shape aTopoDSAxis;
  if(anAxNS.IsNull() || anAxNS->IsEmpty()) {
    aFunction->SetFailure(WRONG_ARGUMENT);
    return -1;
  } else {
    aTopoDSAxis = anAxNS->Get();
    Standard_Boolean anAxisOK = Standard_False;
    if (!aTopoDSAxis.IsNull()) {
      if(aTopoDSAxis.ShapeType() == TopAbs_EDGE || aTopoDSAxis.ShapeType() == TopAbs_WIRE) {
	if (aTopoDSAxis.ShapeType() == TopAbs_WIRE) {
	  TopExp_Explorer anExplorer(aTopoDSAxis, TopAbs_EDGE);
	  aTopoDSAxis = anExplorer.Current();
	}
	const TopoDS_Edge& anEdge = TopoDS::Edge(aTopoDSAxis);
	Standard_Real aFirst, aLast;
	Handle(Geom_Curve) aCurve = BRep_Tool::Curve(anEdge,aFirst,aLast) ;
        if (aCurve->IsKind (STANDARD_TYPE(Geom_Line)) ) {
	  Handle(Geom_Line) aLine = Handle(Geom_Line)::DownCast(aCurve) ;
	  if(!aLine.IsNull()) {
	    anAXIS  = aLine->Position() ;
	    anAxisOK = Standard_True;
	  }
        }
      }
    }
    if(!anAxisOK) {
#ifdef OCC_DEB
      cout<<"RevolutionDriver:: Axis is not correct"<<endl;
#endif
      aFunction->SetFailure(WRONG_ARGUMENT);
      return -1;
    }
  }
  
  if(aFunction->GetDriverGUID() == FULREVOL_GUID) {
    BRepPrimAPI_MakeRevol aMakeRevol(aBASIS, anAXIS, Standard_True);
    aMakeRevol.Build();
    if (!aMakeRevol.IsDone()) {
      aFunction->SetFailure(ALGO_FAILED);
      return -1;
    }
    const TopoDS_Shape aResult = aMakeRevol.Shape();
    BRepCheck_Analyzer aCheck(aResult);
    if (!aCheck.IsValid(aResult)) {
      aFunction->SetFailure(RESULT_NOT_VALID);
      return -1;
    }
    Standard_Boolean aVol = Standard_False;
    if(aResult.ShapeType() == TopAbs_SOLID) aVol = Standard_True;
    else if(aResult.ShapeType() == TopAbs_SHELL) {
      Handle(BRepCheck_Shell) aCheck = new BRepCheck_Shell(TopoDS::Shell(aResult));
      if(aCheck->Closed() == BRepCheck_NoError) 
	aVol = Standard_True;
    }
    if(aVol) {
      GProp_GProps aGProp;
      BRepGProp::VolumeProperties(aResult, aGProp);
      if(aGProp.Mass() <= Precision::Confusion()) {
	aFunction->SetFailure(RESULT_NOT_VALID);
	return -1;
      }
    }
      // Naming  
    if(anIsAttachment)
      LoadNamingDS(RESPOSITION(aFunction), aMakeRevol, aBASIS, aContextOfBasis->Get());
    else
      LoadNamingDS(RESPOSITION(aFunction), aMakeRevol, aBASIS, aBASIS);
    
  } else if(aFunction->GetDriverGUID() == SECREVOL_GUID) {
    Standard_Real anANGLE = DNaming::GetReal(aFunction,REVOL_ANGLE)->Get();
    if(anANGLE <= Precision::Confusion()) {
      aFunction->SetFailure(WRONG_ARGUMENT);
      return -1;
    }
    // Reverse
    Standard_Integer aRev = DNaming::GetInteger(aFunction,REVOL_REV)->Get();
    if(aRev) anAXIS.Reverse();

    BRepPrimAPI_MakeRevol aMakeRevol(aBASIS, anAXIS, anANGLE, Standard_True);
    aMakeRevol.Build();
    if (!aMakeRevol.IsDone()) {
      aFunction->SetFailure(ALGO_FAILED);
      return -1;
    }
    const TopoDS_Shape aResult = aMakeRevol.Shape();
    BRepCheck_Analyzer aCheck(aResult);
    if (!aCheck.IsValid(aResult)) { 
      aFunction->SetFailure(RESULT_NOT_VALID);
      return -1;
    }
    Standard_Boolean aVol = Standard_False;
    if(aResult.ShapeType() == TopAbs_SOLID) aVol = Standard_True;
    else if(aResult.ShapeType() == TopAbs_SHELL) {
      Handle(BRepCheck_Shell) aCheck = new BRepCheck_Shell(TopoDS::Shell(aResult));
      if(aCheck->Closed() == BRepCheck_NoError) 
	aVol = Standard_True;
    }
    if(aVol) {
      GProp_GProps aGProp;
      BRepGProp::VolumeProperties(aResult, aGProp);
      if(aGProp.Mass() <= Precision::Confusion()) {
	aFunction->SetFailure(RESULT_NOT_VALID);
	return -1;
      }
    }

    // Naming  
    if(anIsAttachment)
      LoadNamingDS(RESPOSITION(aFunction), aMakeRevol, aBASIS, aContextOfBasis->Get());
    else
      LoadNamingDS(RESPOSITION(aFunction), aMakeRevol, aBASIS, aBASIS); 
    
  } else {
    aFunction->SetFailure(UNSUPPORTED_FUNCTION);
    return -1;
  }
    
  // restore location
  if(!aLocation.IsIdentity()) 
    TNaming::Displace(RESPOSITION(aFunction), aLocation, Standard_True);
  
  theLog.SetValid(RESPOSITION(aFunction),Standard_True);  
  aFunction->SetFailure(DONE);
  return 0;
}

//=======================================================================
static void LoadSeamEdge (BRepPrimAPI_MakeRevol&        mkRevol,
			  const TDF_Label&              ResultLabel,
			  const TopoDS_Shape&           ShapeIn) 

{
  TopTools_MapOfShape View;
  TopExp_Explorer ShapeExplorer (ShapeIn, TopAbs_EDGE);
  Standard_Boolean isFound(Standard_False);
  for (; ShapeExplorer.More(); ShapeExplorer.Next ()) {
    const TopoDS_Shape& Root = ShapeExplorer.Current ();
    if (!View.Add(Root)) continue;
    const TopTools_ListOfShape& Shapes = mkRevol.Generated (Root);
    TopTools_ListIteratorOfListOfShape ShapesIterator (Shapes);
    for (;ShapesIterator.More (); ShapesIterator.Next ()) {
      TopoDS_Shape newShape = ShapesIterator.Value ();
      if(newShape.ShapeType() != TopAbs_FACE)
	continue;
      if (!Root.IsSame (newShape)) {	
	TopExp_Explorer exp(newShape, TopAbs_EDGE);
	for (;exp.More();exp.Next()) {
	  if(BRep_Tool::IsClosed (TopoDS::Edge(exp.Current()), TopoDS::Face(newShape))) {
	    TNaming_Builder Builder(ResultLabel.NewChild());
	    Builder.Generated (exp.Current());
	    isFound = Standard_True;
	    break;
	  }
	}
	if(isFound) {isFound = Standard_False;break;}
      }
    }
  }
}

//=======================================================================
static Standard_Boolean HasDangle(const TopoDS_Shape& ShapeIn)
{
  if (ShapeIn.ShapeType() == TopAbs_SOLID)
    return Standard_False;
  else if (ShapeIn.ShapeType() == TopAbs_SHELL) {
    Handle(BRepCheck_Shell) aCheck = new BRepCheck_Shell(TopoDS::Shell(ShapeIn));
    if(aCheck->Closed() == BRepCheck_NoError)
      return Standard_False;
    else
      return Standard_True;
  } else if (ShapeIn.ShapeType() == TopAbs_FACE ||
             ShapeIn.ShapeType() == TopAbs_WIRE ||
             ShapeIn.ShapeType() == TopAbs_EDGE ||
             ShapeIn.ShapeType() == TopAbs_VERTEX)
    return Standard_True;
  return Standard_False;
}
//=======================================================================
static void BuildAtomicMap(const TopoDS_Shape& S, TopTools_MapOfShape& M)
{
  if(S.ShapeType() == TopAbs_COMPOUND || S.ShapeType() == TopAbs_COMPSOLID) {
    TopoDS_Iterator it(S);
    for(;it.More();it.Next()) {
      if(it.Value().ShapeType() > TopAbs_COMPSOLID)
        M.Add(it.Value());
      else
        BuildAtomicMap(it.Value(), M);
    }
  } else
    M.Add(S);
}
//=======================================================================
//function : HasDangleShapes
//purpose  :
//=======================================================================

Standard_Boolean HasDangleShapes(const TopoDS_Shape& ShapeIn) {
  if (ShapeIn.ShapeType() == TopAbs_COMPOUND || ShapeIn.ShapeType() == TopAbs_COMPSOLID) {
    TopTools_MapOfShape M;
    BuildAtomicMap(ShapeIn, M);
    TopTools_MapIteratorOfMapOfShape it(M);
    for (; it.More(); it.Next())
      if (HasDangle(it.Key())) return Standard_True;
  } else
    return HasDangle(ShapeIn);
  return Standard_False;
}
//=======================================================================
//function : LoadAndName
//purpose  : 
//=======================================================================
void DNaming_RevolutionDriver::LoadNamingDS (const TDF_Label& theResultLabel, 
					BRepPrimAPI_MakeRevol& MS,
					const TopoDS_Shape& Basis,
					const TopoDS_Shape& Context
					) const 
{

  TopTools_DataMapOfShapeShape SubShapes;
  for (TopExp_Explorer Exp(MS.Shape(),TopAbs_FACE); Exp.More(); Exp.Next()) {
    SubShapes.Bind(Exp.Current(),Exp.Current());
  }
  
  Handle(TDF_TagSource) Tagger = TDF_TagSource::Set(theResultLabel);
  if (Tagger.IsNull()) return;
  Tagger->Set(0);

  TNaming_Builder Builder (theResultLabel);
  if(Basis.IsEqual(Context))
    Builder.Generated(MS.Shape());
  else
    Builder.Generated(Context, MS.Shape());
 
  //Insert lateral face : Face from Edge
  TNaming_Builder  LateralFaceBuilder(theResultLabel.NewChild());   
  DNaming::LoadAndOrientGeneratedShapes(MS, Basis, TopAbs_EDGE, LateralFaceBuilder, SubShapes);

 // is full
  TopoDS_Shape StartShape = MS.FirstShape();
  TopoDS_Shape EndShape = MS.LastShape();
  Standard_Boolean isFull(Standard_False);
  if (!StartShape.IsNull() && !EndShape.IsNull()) 
    isFull = StartShape.IsEqual(EndShape);
  
  Standard_Boolean hasDangle = HasDangleShapes(MS.Shape());
  Standard_Boolean isBasisClosed(Standard_True);
  TopoDS_Vertex Vfirst, Vlast;
  if(Basis.ShapeType() == TopAbs_WIRE) {
    Handle(BRepCheck_Wire) aCheck = new BRepCheck_Wire(TopoDS::Wire(Basis));
    if(aCheck->Closed() != BRepCheck_NoError) {
      isBasisClosed = Standard_False; //open
      TopExp::Vertices(TopoDS::Wire(Basis), Vfirst, Vlast);
    }
  } else if(Basis.ShapeType() == TopAbs_EDGE) {
    BRepBuilderAPI_MakeWire aMakeWire;
    aMakeWire.Add(TopoDS::Edge(Basis));
    if(aMakeWire.IsDone()) {
      Handle(BRepCheck_Wire) aCheck = new BRepCheck_Wire(aMakeWire.Wire());
      if(aCheck->Closed() != BRepCheck_NoError) {//check for circle case
	isBasisClosed = Standard_False; //open 
	TopExp::Vertices(TopoDS::Edge(Basis), Vfirst, Vlast);
      }
    }
  }
  if(isFull) {
    //seam edge
    LoadSeamEdge(MS, theResultLabel, Basis);

    if(hasDangle) {
      if(!isBasisClosed) {
      //dangle edges
	const TopTools_ListOfShape& Shapes = MS.Generated (Vfirst);	
	TopTools_ListIteratorOfListOfShape it (Shapes);
	for (;it.More (); it.Next ()) {
	  if(!BRep_Tool::Degenerated(TopoDS::Edge(it.Value()))) {
	    TNaming_Builder aBuilder(theResultLabel.NewChild());
	    aBuilder.Generated (Vfirst, it.Value());
	  }
#ifdef OCC_DEB
	  else {
	    if(MS.HasDegenerated()) 
	      cout <<"mkRevol has degenerated" <<endl;
	    cout << "BRep_Tool found degenerated edge (from Vfirst) TS = " << it.Value().TShape() <<endl;
	  }
#endif
	}


	const TopTools_ListOfShape& Shapes2 = MS.Generated (Vlast);
	it.Initialize(Shapes2);
	for (;it.More (); it.Next ()) {
	  if(!BRep_Tool::Degenerated(TopoDS::Edge(it.Value()))) {
	    TNaming_Builder aBuilder(theResultLabel.NewChild());
	    aBuilder.Generated (Vlast, it.Value());		      
	  } 
#ifdef OCC_DEB
	  else {
	    if(MS.HasDegenerated()) 
	      cout <<"mkRevol has degenerated" <<endl;
	    cout << "BRep_Tool found degenerated edge (from Vlast) TS = " << it.Value().TShape() <<endl;
	  }
#endif
	}
      }
    }
  } else {//if(!isFull)    
    //Insert start shape 
    if (!StartShape.IsNull()) {
      if (StartShape.ShapeType() != TopAbs_COMPOUND) {
	TNaming_Builder StartBuilder(theResultLabel.NewChild());  
	if (SubShapes.IsBound(StartShape)) {
	  StartShape = SubShapes(StartShape);	  
	}
	StartBuilder.Generated(StartShape);
	if(StartShape.ShapeType() != TopAbs_FACE) {
	  TopoDS_Iterator it(StartShape);
	  for (; it.More(); it.Next()) {
	    TNaming_Builder Builder(theResultLabel.NewChild()); 
	    Builder.Generated(it.Value());
	  }
	}
      } else {
	TopoDS_Iterator itr(StartShape);
	for (; itr.More(); itr.Next()) {
	  TNaming_Builder StartBuilder(theResultLabel.NewChild());  
	  StartBuilder.Generated(itr.Value());
	}
      }
    }


  //Insert end shape
    if (!EndShape.IsNull()) {
      if (EndShape.ShapeType() != TopAbs_COMPOUND) {
	TNaming_Builder EndBuilder(theResultLabel.NewChild());
	if (SubShapes.IsBound(EndShape)) {
	  EndShape = SubShapes(EndShape);
	}
	EndBuilder.Generated(EndShape);
	if(EndShape.ShapeType() != TopAbs_FACE) {
	  TopoDS_Iterator it(EndShape);
	  for (; it.More(); it.Next()) {
	    TNaming_Builder Builder(theResultLabel.NewChild()); 
	    Builder.Generated(it.Value());
	  }
	}
      } else {
	TopoDS_Iterator itr(EndShape);
	for (; itr.More(); itr.Next()) {
	  TNaming_Builder EndBuilder(theResultLabel.NewChild());  
	  EndBuilder.Generated(itr.Value());
	}
      }
    }
    if(hasDangle) {
      if(!isBasisClosed) {
      //dangle edges
	const TopTools_ListOfShape& Shapes = MS.Generated (Vfirst);	
	TopTools_ListIteratorOfListOfShape it (Shapes);
	for (;it.More (); it.Next ()) {
	  if(!BRep_Tool::Degenerated(TopoDS::Edge(it.Value()))) {
	    TNaming_Builder aBuilder(theResultLabel.NewChild());
	    aBuilder.Generated (Vfirst, it.Value());
	  }
#ifdef OCC_DEB
	  else {
	    if(MS.HasDegenerated()) 
	      cout <<"mkRevol has degenerated" <<endl;
	    cout << "BRep_Tool found degenerated edge (from Vfirst) TS = " << it.Value().TShape() <<endl;
	  }
#endif
	}
	
	const TopTools_ListOfShape& Shapes2 = MS.Generated (Vlast);
	it.Initialize(Shapes2);
	for (;it.More (); it.Next ()) {
	  if(!BRep_Tool::Degenerated(TopoDS::Edge(it.Value()))) {
	    TNaming_Builder aBuilder(theResultLabel.NewChild());
	    aBuilder.Generated (Vlast, it.Value());
	  }
#ifdef OCC_DEB
	  else {
	    if(MS.HasDegenerated()) 
	      cout <<"mkRevol has degenerated" <<endl;
	    cout << "BRep_Tool found degenerated edge (from Vlast) TS = " << it.Value().TShape() <<endl;
	  }
#endif
	}
      }
    }
  }   
}