Commit | Line | Data |
---|---|---|
b311480e | 1 | // Created on: 1995-09-12 |
2 | // Created by: Jean Yves LEBEY | |
3 | // Copyright (c) 1995-1999 Matra Datavision | |
973c2be1 | 4 | // Copyright (c) 1999-2014 OPEN CASCADE SAS |
b311480e | 5 | // |
973c2be1 | 6 | // This file is part of Open CASCADE Technology software library. |
b311480e | 7 | // |
d5f74e42 | 8 | // This library is free software; you can redistribute it and/or modify it under |
9 | // the terms of the GNU Lesser General Public License version 2.1 as published | |
973c2be1 | 10 | // by the Free Software Foundation, with special exception defined in the file |
11 | // OCCT_LGPL_EXCEPTION.txt. Consult the file LICENSE_LGPL_21.txt included in OCCT | |
12 | // distribution for complete text of the license and disclaimer of any warranty. | |
b311480e | 13 | // |
973c2be1 | 14 | // Alternatively, this file may be used under the terms of Open CASCADE |
15 | // commercial license or contractual agreement. | |
7fd59977 | 16 | |
17 | #ifndef _TopOpeBRepBuild_SplitEdge_HeaderFile | |
18 | #define _TopOpeBRepBuild_SplitEdge_HeaderFile | |
19 | ||
20 | //======================================================================= | |
21 | //function : SplitEdge | |
22 | //purpose : | |
23 | //======================================================================= | |
24 | ||
25 | void TopOpeBRepBuild_Builder::SplitEdge(const TopoDS_Shape& E, | |
26 | const TopAbs_State ToBuild1, | |
27 | const TopAbs_State ToBuild2) | |
28 | { | |
0797d9d3 | 29 | #ifdef OCCT_DEBUG |
7fd59977 | 30 | if ( TopOpeBRepBuild_GetcontextSF2() ) { |
31 | SplitEdge2(E,ToBuild1,ToBuild2); | |
32 | return; | |
33 | } | |
34 | #endif | |
35 | SplitEdge1(E,ToBuild1,ToBuild2); | |
36 | return; | |
37 | } | |
38 | ||
39 | //======================================================================= | |
40 | //function : SplitEdge1 | |
41 | //purpose : | |
42 | //======================================================================= | |
43 | ||
44 | void TopOpeBRepBuild_Builder::SplitEdge1(const TopoDS_Shape& Eoriented, | |
45 | const TopAbs_State ToBuild1, | |
46 | const TopAbs_State ToBuild2) | |
47 | { | |
48 | // work on a FORWARD edge <Eforward> | |
49 | ||
7fd59977 | 50 | TopoDS_Shape Eforward = Eoriented; |
51 | Eforward.Orientation(TopAbs_FORWARD); | |
52 | ||
53 | Standard_Boolean tosplit = ToSplit(Eoriented,ToBuild1); | |
54 | ||
0797d9d3 | 55 | #ifdef OCCT_DEBUG |
7fd59977 | 56 | Standard_Integer iEdge; Standard_Boolean tSPS = GtraceSPS(Eoriented,iEdge); |
57 | if(tSPS){ | |
58 | cout<<endl; | |
59 | GdumpSHASTA(Eoriented,ToBuild1,"--- SplitEdge "); | |
60 | cout<<endl; | |
61 | } | |
62 | #endif | |
63 | ||
64 | if ( ! tosplit ) return; | |
65 | ||
96a95605 DB |
66 | Reverse(ToBuild1,ToBuild2); |
67 | Reverse(ToBuild2,ToBuild1); | |
7fd59977 | 68 | Standard_Boolean ConnectTo1 = Standard_True; |
69 | Standard_Boolean ConnectTo2 = Standard_False; | |
70 | ||
71 | // build the list of edges to split : LE1, LE2 | |
72 | TopTools_ListOfShape LE1,LE2; | |
73 | LE1.Append(Eforward); | |
74 | FindSameDomain(LE1,LE2); | |
7fd59977 | 75 | |
0797d9d3 | 76 | #ifdef OCCT_DEBUG |
7fd59977 | 77 | if(tSPS){GdumpSAMDOM(LE1, (char *) "1 : ");} |
78 | if(tSPS){GdumpSAMDOM(LE2, (char *) "2 : ");} | |
79 | if(tSPS){cout<<endl;} | |
80 | if(tSPS){cout<<"V of edge ";TopAbs::Print(Eforward.Orientation(),cout);} | |
81 | if(tSPS){cout<<endl;} | |
82 | if(tSPS){GdumpEDG(Eforward);} | |
83 | #endif | |
84 | ||
85 | // SplitEdge on a edge having other same domained edges on the | |
86 | // other shape : do not reverse orientation of edges in FillEdge | |
7fd59977 | 87 | |
88 | // Make a PaveSet <PVS> on edge <Eforward> | |
89 | TopOpeBRepBuild_PaveSet PVS(Eforward); | |
90 | ||
91 | // Add the points/vertices found on edge <Eforward> in <PVS> | |
92 | TopOpeBRepDS_PointIterator EPIT(myDataStructure->EdgePoints(Eforward)); | |
93 | FillVertexSet(EPIT,ToBuild1,PVS); | |
94 | ||
95 | TopOpeBRepBuild_PaveClassifier VCL(Eforward); | |
96 | Standard_Boolean equalpar = PVS.HasEqualParameters(); | |
97 | if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters()); | |
98 | ||
99 | // ------------------------------------------ | |
100 | // before return if PVS has no vertices, | |
101 | // mark <Eforward> as split <ToBuild1> | |
102 | // ------------------------------------------ | |
103 | MarkSplit(Eforward,ToBuild1); | |
104 | ||
105 | PVS.InitLoop(); | |
106 | if ( !PVS.MoreLoop() ) { | |
0797d9d3 | 107 | #ifdef OCCT_DEBUG |
7fd59977 | 108 | if(tSPS) { |
109 | cout<<"NO VERTEX split "; TopAbs::Print(ToBuild1,cout);cout<<endl; | |
110 | } | |
111 | #endif | |
112 | return; | |
113 | } | |
114 | ||
115 | // build the new edges | |
116 | TopOpeBRepBuild_EdgeBuilder EBU(PVS,VCL); | |
117 | ||
118 | // Build the new edges | |
119 | // ------------------- | |
120 | TopTools_ListOfShape& EdgeList = ChangeMerged(Eforward,ToBuild1); | |
121 | MakeEdges(Eforward,EBU,EdgeList); | |
122 | ||
123 | TopTools_ListIteratorOfListOfShape itLE1,itLE2; | |
124 | ||
125 | // connect new edges as edges built <ToBuild1> on LE1 edge | |
126 | // -------------------------------------------------------- | |
127 | for (itLE1.Initialize(LE1); itLE1.More(); itLE1.Next()) { | |
128 | TopoDS_Shape Ecur = itLE1.Value(); | |
129 | MarkSplit(Ecur,ToBuild1); | |
130 | TopTools_ListOfShape& EL = ChangeSplit(Ecur,ToBuild1); | |
131 | if ( ConnectTo1 ) EL = EdgeList; | |
132 | } | |
133 | ||
134 | // connect new edges as edges built <ToBuild2> on LE2 edges | |
135 | // -------------------------------------------------------- | |
136 | for (itLE2.Initialize(LE2); itLE2.More(); itLE2.Next()) { | |
137 | TopoDS_Shape Ecur = itLE2.Value(); | |
138 | MarkSplit(Ecur,ToBuild2); | |
139 | TopTools_ListOfShape& EL = ChangeSplit(Ecur,ToBuild2); | |
140 | if ( ConnectTo2 ) EL = EdgeList; | |
141 | } | |
142 | ||
143 | } // SplitEdge1 | |
144 | ||
145 | //======================================================================= | |
146 | //function : SplitEdge2 | |
147 | //purpose : | |
148 | //======================================================================= | |
149 | ||
150 | void TopOpeBRepBuild_Builder::SplitEdge2(const TopoDS_Shape& Eoriented, | |
151 | const TopAbs_State ToBuild1, | |
152 | const TopAbs_State /*ToBuild2*/) | |
153 | { | |
154 | Standard_Boolean tosplit = ToSplit(Eoriented,ToBuild1); | |
155 | if ( ! tosplit ) return; | |
156 | ||
157 | // work on a FORWARD edge <Eforward> | |
158 | TopoDS_Shape Eforward = Eoriented; | |
159 | myBuildTool.Orientation(Eforward,TopAbs_FORWARD); | |
160 | ||
0797d9d3 | 161 | #ifdef OCCT_DEBUG |
7fd59977 | 162 | Standard_Integer iEdge; Standard_Boolean tSPS = GtraceSPS(Eoriented,iEdge); |
163 | if(tSPS){cout<<endl;} | |
164 | if(tSPS){GdumpSHASTA(Eoriented,ToBuild1,"--- SplitEdge2 ");} | |
165 | #endif | |
166 | ||
167 | // Make a PaveSet <PVS> on edge <Eforward> | |
168 | // Add the points/vertices found on edge <Eforward> in <PVS> | |
169 | TopOpeBRepBuild_PaveSet PVS(Eforward); | |
170 | ||
171 | TopOpeBRepDS_PointIterator EPIT(myDataStructure->EdgePoints(Eforward)); | |
172 | FillVertexSet(EPIT,ToBuild1,PVS); | |
173 | ||
174 | TopOpeBRepBuild_PaveClassifier VCL(Eforward); | |
175 | Standard_Boolean equalpar = PVS.HasEqualParameters(); | |
176 | if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters()); | |
177 | ||
178 | // ------------------------------------------ | |
179 | // before return if PVS has no vertices, | |
180 | // mark <Eforward> as split <ToBuild1> | |
181 | // ------------------------------------------ | |
182 | MarkSplit(Eforward,ToBuild1); | |
183 | ||
184 | PVS.InitLoop(); | |
185 | if ( !PVS.MoreLoop() ) { | |
0797d9d3 | 186 | #ifdef OCCT_DEBUG |
7fd59977 | 187 | if(tSPS) {cout<<"NO VERTEX split ";TopAbs::Print(ToBuild1,cout);cout<<endl;} |
188 | #endif | |
189 | return; | |
190 | } | |
191 | ||
192 | // build the new edges | |
193 | TopOpeBRepBuild_EdgeBuilder EBU(PVS,VCL); | |
194 | ||
195 | // connect the new edges as split parts <ToBuild1> built on <Eforward> | |
196 | TopTools_ListOfShape& EL = ChangeSplit(Eforward,ToBuild1); | |
197 | MakeEdges(Eforward,EBU,EL); | |
198 | ||
199 | } // SplitEdge2 | |
200 | ||
201 | //#ifndef _TopOpeBRepBuild_SplitEdge_HeaderFile | |
202 | #endif |