1 // Created on: 1995-09-12
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1995-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
6 // This file is part of Open CASCADE Technology software library.
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
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.
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
17 #ifndef _TopOpeBRepBuild_SplitEdge_HeaderFile
18 #define _TopOpeBRepBuild_SplitEdge_HeaderFile
20 //=======================================================================
21 //function : SplitEdge
23 //=======================================================================
25 void TopOpeBRepBuild_Builder::SplitEdge(const TopoDS_Shape& E,
26 const TopAbs_State ToBuild1,
27 const TopAbs_State ToBuild2)
30 if ( TopOpeBRepBuild_GetcontextSF2() ) {
31 SplitEdge2(E,ToBuild1,ToBuild2);
35 SplitEdge1(E,ToBuild1,ToBuild2);
39 //=======================================================================
40 //function : SplitEdge1
42 //=======================================================================
44 void TopOpeBRepBuild_Builder::SplitEdge1(const TopoDS_Shape& Eoriented,
45 const TopAbs_State ToBuild1,
46 const TopAbs_State ToBuild2)
48 // work on a FORWARD edge <Eforward>
50 TopoDS_Shape Eforward = Eoriented;
51 Eforward.Orientation(TopAbs_FORWARD);
53 Standard_Boolean tosplit = ToSplit(Eoriented,ToBuild1);
56 Standard_Integer iEdge; Standard_Boolean tSPS = GtraceSPS(Eoriented,iEdge);
59 GdumpSHASTA(Eoriented,ToBuild1,"--- SplitEdge ");
64 if ( ! tosplit ) return;
66 Reverse(ToBuild1,ToBuild2);
67 Reverse(ToBuild2,ToBuild1);
68 Standard_Boolean ConnectTo1 = Standard_True;
69 Standard_Boolean ConnectTo2 = Standard_False;
71 // build the list of edges to split : LE1, LE2
72 TopTools_ListOfShape LE1,LE2;
74 FindSameDomain(LE1,LE2);
77 if(tSPS){GdumpSAMDOM(LE1, (char *) "1 : ");}
78 if(tSPS){GdumpSAMDOM(LE2, (char *) "2 : ");}
80 if(tSPS){cout<<"V of edge ";TopAbs::Print(Eforward.Orientation(),cout);}
82 if(tSPS){GdumpEDG(Eforward);}
85 // SplitEdge on a edge having other same domained edges on the
86 // other shape : do not reverse orientation of edges in FillEdge
88 // Make a PaveSet <PVS> on edge <Eforward>
89 TopOpeBRepBuild_PaveSet PVS(Eforward);
91 // Add the points/vertices found on edge <Eforward> in <PVS>
92 TopOpeBRepDS_PointIterator EPIT(myDataStructure->EdgePoints(Eforward));
93 FillVertexSet(EPIT,ToBuild1,PVS);
95 TopOpeBRepBuild_PaveClassifier VCL(Eforward);
96 Standard_Boolean equalpar = PVS.HasEqualParameters();
97 if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());
99 // ------------------------------------------
100 // before return if PVS has no vertices,
101 // mark <Eforward> as split <ToBuild1>
102 // ------------------------------------------
103 MarkSplit(Eforward,ToBuild1);
106 if ( !PVS.MoreLoop() ) {
109 cout<<"NO VERTEX split "; TopAbs::Print(ToBuild1,cout);cout<<endl;
115 // build the new edges
116 TopOpeBRepBuild_EdgeBuilder EBU(PVS,VCL);
118 // Build the new edges
119 // -------------------
120 TopTools_ListOfShape& EdgeList = ChangeMerged(Eforward,ToBuild1);
121 MakeEdges(Eforward,EBU,EdgeList);
123 TopTools_ListIteratorOfListOfShape itLE1,itLE2;
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;
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;
145 //=======================================================================
146 //function : SplitEdge2
148 //=======================================================================
150 void TopOpeBRepBuild_Builder::SplitEdge2(const TopoDS_Shape& Eoriented,
151 const TopAbs_State ToBuild1,
152 const TopAbs_State /*ToBuild2*/)
154 Standard_Boolean tosplit = ToSplit(Eoriented,ToBuild1);
155 if ( ! tosplit ) return;
157 // work on a FORWARD edge <Eforward>
158 TopoDS_Shape Eforward = Eoriented;
159 myBuildTool.Orientation(Eforward,TopAbs_FORWARD);
162 Standard_Integer iEdge; Standard_Boolean tSPS = GtraceSPS(Eoriented,iEdge);
163 if(tSPS){cout<<endl;}
164 if(tSPS){GdumpSHASTA(Eoriented,ToBuild1,"--- SplitEdge2 ");}
167 // Make a PaveSet <PVS> on edge <Eforward>
168 // Add the points/vertices found on edge <Eforward> in <PVS>
169 TopOpeBRepBuild_PaveSet PVS(Eforward);
171 TopOpeBRepDS_PointIterator EPIT(myDataStructure->EdgePoints(Eforward));
172 FillVertexSet(EPIT,ToBuild1,PVS);
174 TopOpeBRepBuild_PaveClassifier VCL(Eforward);
175 Standard_Boolean equalpar = PVS.HasEqualParameters();
176 if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());
178 // ------------------------------------------
179 // before return if PVS has no vertices,
180 // mark <Eforward> as split <ToBuild1>
181 // ------------------------------------------
182 MarkSplit(Eforward,ToBuild1);
185 if ( !PVS.MoreLoop() ) {
187 if(tSPS) {cout<<"NO VERTEX split ";TopAbs::Print(ToBuild1,cout);cout<<endl;}
192 // build the new edges
193 TopOpeBRepBuild_EdgeBuilder EBU(PVS,VCL);
195 // connect the new edges as split parts <ToBuild1> built on <Eforward>
196 TopTools_ListOfShape& EL = ChangeSplit(Eforward,ToBuild1);
197 MakeEdges(Eforward,EBU,EL);
201 //#ifndef _TopOpeBRepBuild_SplitEdge_HeaderFile