0023301: Comparing variable to itself in ShapeUpgrade_WireDivide.cxx
[occt.git] / src / ShapeUpgrade / ShapeUpgrade_EdgeDivide.cxx
1 // Created on: 2000-05-24
2 // Created by: data exchange team
3 // Copyright (c) 2000-2012 OPEN CASCADE SAS
4 //
5 // The content of this file is subject to the Open CASCADE Technology Public
6 // License Version 6.5 (the "License"). You may not use the content of this file
7 // except in compliance with the License. Please obtain a copy of the License
8 // at http://www.opencascade.org and read it completely before using this file.
9 //
10 // The Initial Developer of the Original Code is Open CASCADE S.A.S., having its
11 // main offices at: 1, place des Freres Montgolfier, 78280 Guyancourt, France.
12 //
13 // The Original Code and all software distributed under the License is
14 // distributed on an "AS IS" basis, without warranty of any kind, and the
15 // Initial Developer hereby disclaims all such warranties, including without
16 // limitation, any warranties of merchantability, fitness for a particular
17 // purpose or non-infringement. Please see the License for the specific terms
18 // and conditions governing the rights and limitations under the License.
19
20
21
22 #include <ShapeUpgrade_EdgeDivide.ixx>
23 #include <BRep_Tool.hxx>
24 #include <ShapeAnalysis_Edge.hxx>
25
26 //=======================================================================
27 //function : ShapeUpgrade_EdgeDivide
28 //purpose  : 
29 //=======================================================================
30
31 ShapeUpgrade_EdgeDivide::ShapeUpgrade_EdgeDivide():
32       ShapeUpgrade_Tool()
33 {
34   mySplitCurve3dTool = new ShapeUpgrade_SplitCurve3d;
35   mySplitCurve2dTool = new ShapeUpgrade_SplitCurve2d;
36 }
37
38
39 //=======================================================================
40 //function : Clear
41 //purpose  : 
42 //=======================================================================
43
44 void ShapeUpgrade_EdgeDivide::Clear()
45 {
46   myKnots3d.Nullify();
47   myKnots2d.Nullify();
48   myHasCurve3d = Standard_False;
49   myHasCurve2d = Standard_False;
50 }
51
52 //=======================================================================
53 //function : Compute
54 //purpose  : 
55 //=======================================================================
56
57 Standard_Boolean ShapeUpgrade_EdgeDivide::Compute(const TopoDS_Edge& anEdge)
58 {
59   Clear();
60   
61   Standard_Real f, l;
62   Handle(Geom_Curve) curve3d = BRep_Tool::Curve (anEdge, f, l);
63   myHasCurve3d = !curve3d.IsNull();
64   
65   Handle(ShapeUpgrade_SplitCurve3d) theSplit3dTool = GetSplitCurve3dTool();
66   if ( myHasCurve3d ) {
67     theSplit3dTool->Init (curve3d, f, l);
68     theSplit3dTool->Compute();
69     myKnots3d = theSplit3dTool->SplitValues();
70   }
71   
72   // on pcurve(s): all knots
73   // assume that if seam-edge, its pcurve1 and pcurve2 has the same split knots !!!
74   Standard_Real f2d, l2d;
75   Handle(Geom2d_Curve) pcurve1;
76   if ( ! myFace.IsNull() ) { // process free edges
77     ShapeAnalysis_Edge sae;
78     sae.PCurve (anEdge, myFace, pcurve1, f2d, l2d, Standard_False);
79   }
80   myHasCurve2d = !pcurve1.IsNull();
81   
82   Handle(ShapeUpgrade_SplitCurve2d) theSplit2dTool = GetSplitCurve2dTool();
83   if ( myHasCurve2d ) {
84     theSplit2dTool->Init (pcurve1, f2d, l2d);
85     theSplit2dTool->Compute();
86     myKnots2d = theSplit2dTool->SplitValues();
87   }
88   
89   if ( theSplit3dTool->Status ( ShapeExtend_DONE ) || 
90       theSplit2dTool->Status ( ShapeExtend_DONE ) ) 
91     return Standard_True;
92   else
93     return Standard_False;
94 }
95
96 //=======================================================================
97 //function : SetSplitCurve2dTool
98 //purpose  : 
99 //=======================================================================
100
101 void ShapeUpgrade_EdgeDivide::SetSplitCurve2dTool(const Handle(ShapeUpgrade_SplitCurve2d)& splitCurve2dTool)
102 {
103   mySplitCurve2dTool = splitCurve2dTool;
104 }
105
106 //=======================================================================
107 //function : SetSplitCurve3dTool
108 //purpose  : 
109 //=======================================================================
110
111 void ShapeUpgrade_EdgeDivide::SetSplitCurve3dTool(const Handle(ShapeUpgrade_SplitCurve3d)& splitCurve3dTool)
112 {
113   mySplitCurve3dTool = splitCurve3dTool;
114 }
115
116 //=======================================================================
117 //function : GetSplitCurve2dTool
118 //purpose  : 
119 //=======================================================================
120
121 Handle(ShapeUpgrade_SplitCurve2d) ShapeUpgrade_EdgeDivide::GetSplitCurve2dTool() const
122
123   return mySplitCurve2dTool;
124 }
125
126 Handle(ShapeUpgrade_SplitCurve3d) ShapeUpgrade_EdgeDivide::GetSplitCurve3dTool() const
127
128   return mySplitCurve3dTool;
129 }