summaryrefslogtreecommitdiff
path: root/inc/TopOpeBRepBuild_SplitEdge.hxx
blob: e41ec61a2a6242a9d90f643b322d364dab2b7edf (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
// File:	TopOpeBRepBuild_SplitEdge.hxx
// Created:	Tue Sep 12 14:32:37 1995
// Author:	Jean Yves LEBEY
//		<jyl@meteox>

#ifndef _TopOpeBRepBuild_SplitEdge_HeaderFile
#define _TopOpeBRepBuild_SplitEdge_HeaderFile

//=======================================================================
//function : SplitEdge
//purpose  : 
//=======================================================================

void TopOpeBRepBuild_Builder::SplitEdge(const TopoDS_Shape& E,
					const TopAbs_State ToBuild1,
					const TopAbs_State ToBuild2)
{
#ifdef DEB
  if ( TopOpeBRepBuild_GetcontextSF2() ) {
    SplitEdge2(E,ToBuild1,ToBuild2);
    return;
  }
#endif
  SplitEdge1(E,ToBuild1,ToBuild2);
  return;
}

//=======================================================================
//function : SplitEdge1
//purpose  : 
//=======================================================================

void TopOpeBRepBuild_Builder::SplitEdge1(const TopoDS_Shape& Eoriented,
					 const TopAbs_State ToBuild1,
					 const TopAbs_State ToBuild2)
{
  // work on a FORWARD edge <Eforward>

  TopoDS_Shape Eforward = Eoriented; 
  Eforward.Orientation(TopAbs_FORWARD);

  Standard_Boolean tosplit = ToSplit(Eoriented,ToBuild1);

#ifdef DEB
  Standard_Integer iEdge; Standard_Boolean tSPS = GtraceSPS(Eoriented,iEdge);
  if(tSPS){
    cout<<endl;
    GdumpSHASTA(Eoriented,ToBuild1,"--- SplitEdge ");
    cout<<endl;
  }
#endif
  
  if ( ! tosplit ) return;

  Reverse(ToBuild1,ToBuild2);
  Reverse(ToBuild2,ToBuild1);
  Standard_Boolean ConnectTo1 = Standard_True;
  Standard_Boolean ConnectTo2 = Standard_False;
  
  // build the list of edges to split : LE1, LE2
  TopTools_ListOfShape LE1,LE2;
  LE1.Append(Eforward);
  FindSameDomain(LE1,LE2);

#ifdef DEB
  if(tSPS){GdumpSAMDOM(LE1, (char *) "1 : ");}
  if(tSPS){GdumpSAMDOM(LE2, (char *) "2 : ");}
  if(tSPS){cout<<endl;}
  if(tSPS){cout<<"V of edge ";TopAbs::Print(Eforward.Orientation(),cout);}
  if(tSPS){cout<<endl;}
  if(tSPS){GdumpEDG(Eforward);}
#endif
  
  // SplitEdge on a edge having other same domained edges on the
  // other shape : do not reverse orientation of edges in FillEdge
    
  // Make a PaveSet <PVS> on edge <Eforward>
  TopOpeBRepBuild_PaveSet PVS(Eforward);

  // Add the points/vertices found on edge <Eforward> in <PVS>
  TopOpeBRepDS_PointIterator EPIT(myDataStructure->EdgePoints(Eforward));
  FillVertexSet(EPIT,ToBuild1,PVS);
  
  TopOpeBRepBuild_PaveClassifier VCL(Eforward);
  Standard_Boolean equalpar = PVS.HasEqualParameters();
  if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());

  // ------------------------------------------
  // before return if PVS has no vertices, 
  // mark <Eforward> as split <ToBuild1>
  // ------------------------------------------
  MarkSplit(Eforward,ToBuild1);
  
  PVS.InitLoop();
  if ( !PVS.MoreLoop() ) {
#ifdef DEB
    if(tSPS) {
      cout<<"NO VERTEX split "; TopAbs::Print(ToBuild1,cout);cout<<endl;
    }
#endif
    return;
  }
  
  // build the new edges
  TopOpeBRepBuild_EdgeBuilder EBU(PVS,VCL);
  
  // Build the new edges
  // -------------------
  TopTools_ListOfShape& EdgeList = ChangeMerged(Eforward,ToBuild1);
  MakeEdges(Eforward,EBU,EdgeList);

  TopTools_ListIteratorOfListOfShape itLE1,itLE2;

  // connect new edges as edges built <ToBuild1> on LE1 edge
  // --------------------------------------------------------
  for (itLE1.Initialize(LE1); itLE1.More(); itLE1.Next()) {
    TopoDS_Shape Ecur = itLE1.Value();
    MarkSplit(Ecur,ToBuild1);
    TopTools_ListOfShape& EL = ChangeSplit(Ecur,ToBuild1);
    if ( ConnectTo1 ) EL = EdgeList;
  }
  
  // connect new edges as edges built <ToBuild2> on LE2 edges
  // --------------------------------------------------------
  for (itLE2.Initialize(LE2); itLE2.More(); itLE2.Next()) {
    TopoDS_Shape Ecur = itLE2.Value();
    MarkSplit(Ecur,ToBuild2);
    TopTools_ListOfShape& EL = ChangeSplit(Ecur,ToBuild2);
    if ( ConnectTo2 ) EL = EdgeList;
  }

} // SplitEdge1

//=======================================================================
//function : SplitEdge2
//purpose  : 
//=======================================================================

void TopOpeBRepBuild_Builder::SplitEdge2(const TopoDS_Shape& Eoriented,
					 const TopAbs_State ToBuild1,
					 const TopAbs_State /*ToBuild2*/)
{
  Standard_Boolean tosplit = ToSplit(Eoriented,ToBuild1);
  if ( ! tosplit ) return;
  
  // work on a FORWARD edge <Eforward>
  TopoDS_Shape Eforward = Eoriented;
  myBuildTool.Orientation(Eforward,TopAbs_FORWARD);

#ifdef DEB
  Standard_Integer iEdge; Standard_Boolean tSPS = GtraceSPS(Eoriented,iEdge);
  if(tSPS){cout<<endl;}
  if(tSPS){GdumpSHASTA(Eoriented,ToBuild1,"--- SplitEdge2 ");}
#endif
  
  // Make a PaveSet <PVS> on edge <Eforward>
  // Add the points/vertices found on edge <Eforward> in <PVS>
  TopOpeBRepBuild_PaveSet PVS(Eforward);

  TopOpeBRepDS_PointIterator EPIT(myDataStructure->EdgePoints(Eforward));
  FillVertexSet(EPIT,ToBuild1,PVS);
  
  TopOpeBRepBuild_PaveClassifier VCL(Eforward);
  Standard_Boolean equalpar = PVS.HasEqualParameters();
  if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());

  // ------------------------------------------
  // before return if PVS has no vertices, 
  // mark <Eforward> as split <ToBuild1>
  // ------------------------------------------
  MarkSplit(Eforward,ToBuild1);
  
  PVS.InitLoop();
  if ( !PVS.MoreLoop() ) {
#ifdef DEB
    if(tSPS) {cout<<"NO VERTEX split ";TopAbs::Print(ToBuild1,cout);cout<<endl;}
#endif
    return;
  }
  
  // build the new edges
  TopOpeBRepBuild_EdgeBuilder EBU(PVS,VCL);
  
  // connect the new edges as split parts <ToBuild1> built on <Eforward>
  TopTools_ListOfShape& EL = ChangeSplit(Eforward,ToBuild1);
  MakeEdges(Eforward,EBU,EL);
  
} // SplitEdge2

//#ifndef _TopOpeBRepBuild_SplitEdge_HeaderFile
#endif