0031682: Visualization - Prs3d_ShadingAspect::SetTransparency() has no effect with...
[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
17 #include <BRep_Tool.hxx>
18 #include <ShapeAnalysis_Edge.hxx>
19 #include <ShapeUpgrade_EdgeDivide.hxx>
20 #include <ShapeUpgrade_SplitCurve2d.hxx>
21 #include <ShapeUpgrade_SplitCurve3d.hxx>
22 #include <Standard_Type.hxx>
23 #include <TopoDS_Edge.hxx>
24 #include <TopoDS_Face.hxx>
25
26 IMPLEMENT_STANDARD_RTTIEXT(ShapeUpgrade_EdgeDivide,ShapeUpgrade_Tool)
27
28 //=======================================================================
29 //function : ShapeUpgrade_EdgeDivide
30 //purpose  : 
31 //=======================================================================
32 ShapeUpgrade_EdgeDivide::ShapeUpgrade_EdgeDivide():
33       ShapeUpgrade_Tool()
34 {
35   mySplitCurve3dTool = new ShapeUpgrade_SplitCurve3d;
36   mySplitCurve2dTool = new ShapeUpgrade_SplitCurve2d;
37 }
38
39
40 //=======================================================================
41 //function : Clear
42 //purpose  : 
43 //=======================================================================
44
45 void ShapeUpgrade_EdgeDivide::Clear()
46 {
47   myKnots3d.Nullify();
48   myKnots2d.Nullify();
49   myHasCurve3d = Standard_False;
50   myHasCurve2d = Standard_False;
51 }
52
53 //=======================================================================
54 //function : Compute
55 //purpose  : 
56 //=======================================================================
57
58 Standard_Boolean ShapeUpgrade_EdgeDivide::Compute(const TopoDS_Edge& anEdge)
59 {
60   Clear();
61   
62   Standard_Real f, l;
63   Handle(Geom_Curve) curve3d = BRep_Tool::Curve (anEdge, f, l);
64   myHasCurve3d = !curve3d.IsNull();
65   
66   Handle(ShapeUpgrade_SplitCurve3d) theSplit3dTool = GetSplitCurve3dTool();
67   if ( myHasCurve3d ) {
68     theSplit3dTool->Init (curve3d, f, l);
69     theSplit3dTool->Compute();
70     myKnots3d = theSplit3dTool->SplitValues();
71   }
72   
73   // on pcurve(s): all knots
74   // assume that if seam-edge, its pcurve1 and pcurve2 has the same split knots !!!
75   Standard_Real f2d = 0., l2d = 0.;
76   Handle(Geom2d_Curve) pcurve1;
77   if ( ! myFace.IsNull() ) { // process free edges
78     ShapeAnalysis_Edge sae;
79     sae.PCurve (anEdge, myFace, pcurve1, f2d, l2d, Standard_False);
80   }
81   myHasCurve2d = !pcurve1.IsNull();
82   
83   Handle(ShapeUpgrade_SplitCurve2d) theSplit2dTool = GetSplitCurve2dTool();
84   if ( myHasCurve2d ) {
85     theSplit2dTool->Init (pcurve1, f2d, l2d);
86     theSplit2dTool->Compute();
87     myKnots2d = theSplit2dTool->SplitValues();
88   }
89   
90   if ( theSplit3dTool->Status ( ShapeExtend_DONE ) || 
91       theSplit2dTool->Status ( ShapeExtend_DONE ) ) 
92     return Standard_True;
93   else
94     return Standard_False;
95 }
96
97 //=======================================================================
98 //function : SetSplitCurve2dTool
99 //purpose  : 
100 //=======================================================================
101
102 void ShapeUpgrade_EdgeDivide::SetSplitCurve2dTool(const Handle(ShapeUpgrade_SplitCurve2d)& splitCurve2dTool)
103 {
104   mySplitCurve2dTool = splitCurve2dTool;
105 }
106
107 //=======================================================================
108 //function : SetSplitCurve3dTool
109 //purpose  : 
110 //=======================================================================
111
112 void ShapeUpgrade_EdgeDivide::SetSplitCurve3dTool(const Handle(ShapeUpgrade_SplitCurve3d)& splitCurve3dTool)
113 {
114   mySplitCurve3dTool = splitCurve3dTool;
115 }
116
117 //=======================================================================
118 //function : GetSplitCurve2dTool
119 //purpose  : 
120 //=======================================================================
121
122 Handle(ShapeUpgrade_SplitCurve2d) ShapeUpgrade_EdgeDivide::GetSplitCurve2dTool() const
123
124   return mySplitCurve2dTool;
125 }
126
127 Handle(ShapeUpgrade_SplitCurve3d) ShapeUpgrade_EdgeDivide::GetSplitCurve3dTool() const
128
129   return mySplitCurve3dTool;
130 }