0025266: Debug statements in the source are getting flushed on to the console
[occt.git] / src / ShapeUpgrade / ShapeUpgrade_EdgeDivide.cxx
1 // Created on: 2000-05-24
2 // Created by: data exchange team
3 // Copyright (c) 2000-2014 OPEN CASCADE SAS
4 //
5 // This file is part of Open CASCADE Technology software library.
6 //
7 // This library is free software; you can redistribute it and/or modify it under
8 // the terms of the GNU Lesser General Public License version 2.1 as published
9 // by the Free Software Foundation, with special exception defined in the file
10 // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT
11 // distribution for complete text of the license and disclaimer of any warranty.
12 //
13 // Alternatively, this file may be used under the terms of Open CASCADE
14 // commercial license or contractual agreement.
15
16 #include <ShapeUpgrade_EdgeDivide.ixx>
17 #include <BRep_Tool.hxx>
18 #include <ShapeAnalysis_Edge.hxx>
19
20 //=======================================================================
21 //function : ShapeUpgrade_EdgeDivide
22 //purpose  : 
23 //=======================================================================
24
25 ShapeUpgrade_EdgeDivide::ShapeUpgrade_EdgeDivide():
26       ShapeUpgrade_Tool()
27 {
28   mySplitCurve3dTool = new ShapeUpgrade_SplitCurve3d;
29   mySplitCurve2dTool = new ShapeUpgrade_SplitCurve2d;
30 }
31
32
33 //=======================================================================
34 //function : Clear
35 //purpose  : 
36 //=======================================================================
37
38 void ShapeUpgrade_EdgeDivide::Clear()
39 {
40   myKnots3d.Nullify();
41   myKnots2d.Nullify();
42   myHasCurve3d = Standard_False;
43   myHasCurve2d = Standard_False;
44 }
45
46 //=======================================================================
47 //function : Compute
48 //purpose  : 
49 //=======================================================================
50
51 Standard_Boolean ShapeUpgrade_EdgeDivide::Compute(const TopoDS_Edge& anEdge)
52 {
53   Clear();
54   
55   Standard_Real f, l;
56   Handle(Geom_Curve) curve3d = BRep_Tool::Curve (anEdge, f, l);
57   myHasCurve3d = !curve3d.IsNull();
58   
59   Handle(ShapeUpgrade_SplitCurve3d) theSplit3dTool = GetSplitCurve3dTool();
60   if ( myHasCurve3d ) {
61     theSplit3dTool->Init (curve3d, f, l);
62     theSplit3dTool->Compute();
63     myKnots3d = theSplit3dTool->SplitValues();
64   }
65   
66   // on pcurve(s): all knots
67   // assume that if seam-edge, its pcurve1 and pcurve2 has the same split knots !!!
68   Standard_Real f2d = 0., l2d = 0.;
69   Handle(Geom2d_Curve) pcurve1;
70   if ( ! myFace.IsNull() ) { // process free edges
71     ShapeAnalysis_Edge sae;
72     sae.PCurve (anEdge, myFace, pcurve1, f2d, l2d, Standard_False);
73   }
74   myHasCurve2d = !pcurve1.IsNull();
75   
76   Handle(ShapeUpgrade_SplitCurve2d) theSplit2dTool = GetSplitCurve2dTool();
77   if ( myHasCurve2d ) {
78     theSplit2dTool->Init (pcurve1, f2d, l2d);
79     theSplit2dTool->Compute();
80     myKnots2d = theSplit2dTool->SplitValues();
81   }
82   
83   if ( theSplit3dTool->Status ( ShapeExtend_DONE ) || 
84       theSplit2dTool->Status ( ShapeExtend_DONE ) ) 
85     return Standard_True;
86   else
87     return Standard_False;
88 }
89
90 //=======================================================================
91 //function : SetSplitCurve2dTool
92 //purpose  : 
93 //=======================================================================
94
95 void ShapeUpgrade_EdgeDivide::SetSplitCurve2dTool(const Handle(ShapeUpgrade_SplitCurve2d)& splitCurve2dTool)
96 {
97   mySplitCurve2dTool = splitCurve2dTool;
98 }
99
100 //=======================================================================
101 //function : SetSplitCurve3dTool
102 //purpose  : 
103 //=======================================================================
104
105 void ShapeUpgrade_EdgeDivide::SetSplitCurve3dTool(const Handle(ShapeUpgrade_SplitCurve3d)& splitCurve3dTool)
106 {
107   mySplitCurve3dTool = splitCurve3dTool;
108 }
109
110 //=======================================================================
111 //function : GetSplitCurve2dTool
112 //purpose  : 
113 //=======================================================================
114
115 Handle(ShapeUpgrade_SplitCurve2d) ShapeUpgrade_EdgeDivide::GetSplitCurve2dTool() const
116
117   return mySplitCurve2dTool;
118 }
119
120 Handle(ShapeUpgrade_SplitCurve3d) ShapeUpgrade_EdgeDivide::GetSplitCurve3dTool() const
121
122   return mySplitCurve3dTool;
123 }