summaryrefslogtreecommitdiff
path: root/src/ShapeUpgrade/ShapeUpgrade_EdgeDivide.cxx
blob: 9e86feb56763fe2bec2bd7832f8612bee8f05c21 (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
// File:	ShapeUpgrade_EdgeDivide.cxx
// Created:	Wed May 24 17:13:15 2000
// Author:	data exchange team
//		<det@friendox>


#include <ShapeUpgrade_EdgeDivide.ixx>
#include <BRep_Tool.hxx>
#include <ShapeAnalysis_Edge.hxx>

//=======================================================================
//function : ShapeUpgrade_EdgeDivide
//purpose  : 
//=======================================================================

ShapeUpgrade_EdgeDivide::ShapeUpgrade_EdgeDivide():
      ShapeUpgrade_Tool()
{
  mySplitCurve3dTool = new ShapeUpgrade_SplitCurve3d;
  mySplitCurve2dTool = new ShapeUpgrade_SplitCurve2d;
}


//=======================================================================
//function : Clear
//purpose  : 
//=======================================================================

void ShapeUpgrade_EdgeDivide::Clear()
{
  myKnots3d.Nullify();
  myKnots2d.Nullify();
  myHasCurve3d = Standard_False;
  myHasCurve2d = Standard_False;
}

//=======================================================================
//function : Compute
//purpose  : 
//=======================================================================

Standard_Boolean ShapeUpgrade_EdgeDivide::Compute(const TopoDS_Edge& anEdge)
{
  Clear();
  
  Standard_Real f, l;
  Handle(Geom_Curve) curve3d = BRep_Tool::Curve (anEdge, f, l);
  myHasCurve3d = !curve3d.IsNull();
  
  Handle(ShapeUpgrade_SplitCurve3d) theSplit3dTool = GetSplitCurve3dTool();
  if ( myHasCurve3d ) {
    theSplit3dTool->Init (curve3d, f, l);
    theSplit3dTool->Compute();
    myKnots3d = theSplit3dTool->SplitValues();
  }
  
  // on pcurve(s): all knots
  // assume that if seam-edge, its pcurve1 and pcurve2 has the same split knots !!!
  Standard_Real f2d = 0.0, l2d = 0.0;
  Handle(Geom2d_Curve) pcurve1;
  if ( ! myFace.IsNull() ) { // process free edges
    ShapeAnalysis_Edge sae;
    sae.PCurve (anEdge, myFace, pcurve1, f2d, l2d, Standard_False);
  }
  myHasCurve2d = !pcurve1.IsNull();
  
  Handle(ShapeUpgrade_SplitCurve2d) theSplit2dTool = GetSplitCurve2dTool();
  if ( myHasCurve2d ) {
    theSplit2dTool->Init (pcurve1, f2d, l2d);
    theSplit2dTool->Compute();
    myKnots2d = theSplit2dTool->SplitValues();
  }
  
  if ( theSplit3dTool->Status ( ShapeExtend_DONE ) || 
      theSplit2dTool->Status ( ShapeExtend_DONE ) ) 
    return Standard_True;
  else
    return Standard_False;
}

//=======================================================================
//function : SetSplitCurve2dTool
//purpose  : 
//=======================================================================

void ShapeUpgrade_EdgeDivide::SetSplitCurve2dTool(const Handle(ShapeUpgrade_SplitCurve2d)& splitCurve2dTool)
{
  mySplitCurve2dTool = splitCurve2dTool;
}

//=======================================================================
//function : SetSplitCurve3dTool
//purpose  : 
//=======================================================================

void ShapeUpgrade_EdgeDivide::SetSplitCurve3dTool(const Handle(ShapeUpgrade_SplitCurve3d)& splitCurve3dTool)
{
  mySplitCurve3dTool = splitCurve3dTool;
}

//=======================================================================
//function : GetSplitCurve2dTool
//purpose  : 
//=======================================================================

Handle(ShapeUpgrade_SplitCurve2d) ShapeUpgrade_EdgeDivide::GetSplitCurve2dTool() const
{ 
  return mySplitCurve2dTool;
}

Handle(ShapeUpgrade_SplitCurve3d) ShapeUpgrade_EdgeDivide::GetSplitCurve3dTool() const
{ 
  return mySplitCurve3dTool;
}