0024510: Remove unused local variables
[occt.git] / src / TopOpeBRepBuild / TopOpeBRepBuild_makeedges.cxx
1 // Created on: 1996-03-07
2 // Created by: Jean Yves LEBEY
3 // Copyright (c) 1996-1999 Matra Datavision
4 // Copyright (c) 1999-2014 OPEN CASCADE SAS
5 //
6 // This file is part of Open CASCADE Technology software library.
7 //
8 // This library is free software; you can redistribute it and / or modify it
9 // under the terms of the GNU Lesser General Public 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.
13 //
14 // Alternatively, this file may be used under the terms of Open CASCADE
15 // commercial license or contractual agreement.
16
17 #include <TopOpeBRepBuild_Builder.ixx>
18
19 #include <TopExp.hxx>
20 #include <TopoDS.hxx>
21 #include <BRep_Tool.hxx>
22 #include <TopOpeBRepTool_TOOL.hxx>
23 #include <TopOpeBRepDS_EXPORT.hxx>
24 #include <TopOpeBRepBuild_define.hxx>
25
26 #ifdef DEB
27 extern void debfillp(const Standard_Integer i);
28 extern void debedbu(const Standard_Integer i) {cout<<"++ debedbu "<<i<<endl;}
29 #endif
30
31 #ifdef DRAW
32 #include <TopOpeBRepTool_DRAW.hxx>
33 #endif
34
35 //=======================================================================
36 //function : GPVSMakeEdges
37 //purpose  : 
38 //=======================================================================
39 void TopOpeBRepBuild_Builder::GPVSMakeEdges
40 (const TopoDS_Shape& EF,TopOpeBRepBuild_PaveSet& PVS,TopTools_ListOfShape& LOE) const 
41 {
42 #ifdef DEB
43   Standard_Integer iE; Standard_Boolean tSPS = GtraceSPS(EF,iE);
44   if (tSPS) debfillp(iE);
45 #endif
46   
47   TopOpeBRepBuild_PaveClassifier VCL(EF);
48   Standard_Boolean equalpar = PVS.HasEqualParameters();
49   if (equalpar) VCL.SetFirstParameter(PVS.EqualParameters());
50   
51   PVS.InitLoop();
52   Standard_Boolean novertex = ( ! PVS.MoreLoop() );
53 #ifdef DEB
54   if(tSPS&&novertex)cout<<"#--- GPVSMakeEdges : no vertex from edge "<<iE<<endl;
55 #endif
56   if (novertex) return;
57   
58   TopOpeBRepBuild_EdgeBuilder EDBU;
59   Standard_Boolean ForceClass = Standard_False;
60   EDBU.InitEdgeBuilder(PVS,VCL,ForceClass);
61   GEDBUMakeEdges(EF,EDBU,LOE);
62   
63 } // GPVSMakeEdges
64
65 //=======================================================================
66 //function : GEDBUMakeEdges
67 //purpose  : 
68 //=======================================================================
69 void TopOpeBRepBuild_Builder::GEDBUMakeEdges
70 (const TopoDS_Shape& EF,TopOpeBRepBuild_EdgeBuilder& EDBU,TopTools_ListOfShape& LOE) const
71 {
72 #ifdef DEB
73   Standard_Integer iE; Standard_Boolean tSPS = GtraceSPS(EF,iE);
74   if(tSPS){cout<<endl;GdumpSHA(EF, (char *) "#--- GEDBUMakeEdges ");cout<<endl;}
75   if(tSPS){GdumpEDBU(EDBU);}
76   if(tSPS){debedbu(iE);}
77 #endif
78
79   TopoDS_Shape newEdge;
80   for (EDBU.InitEdge(); EDBU.MoreEdge(); EDBU.NextEdge()) {
81     
82     Standard_Integer nloop = 0;
83     Standard_Boolean tosplit = Standard_False;
84     for (EDBU.InitVertex(); EDBU.MoreVertex(); EDBU.NextVertex()) nloop++; 
85     // 0 ou 1 vertex sur edge courante => suppression edge
86     if ( nloop <= 1 ) continue;
87     
88     myBuildTool.CopyEdge(EF,newEdge);
89     
90     Standard_Integer nVF = 0, nVR = 0; // nb vertex FORWARD,REVERSED
91     
92     TopoDS_Shape VF,VR; // gestion du bit Closed
93     VF.Nullify();
94     VR.Nullify();
95     
96     for (EDBU.InitVertex(); EDBU.MoreVertex(); EDBU.NextVertex()) {
97       TopoDS_Shape V = EDBU.Vertex();
98       TopAbs_Orientation Vori = V.Orientation();
99       
100       Standard_Boolean hassd = myDataStructure->HasSameDomain(V);
101       if (hassd) { // on prend le vertex reference de V
102         Standard_Integer iref = myDataStructure->SameDomainReference(V);
103         V = myDataStructure->Shape(iref);
104         V.Orientation(Vori);
105       }
106       
107       TopAbs_Orientation oriV = V.Orientation();
108       if ( oriV == TopAbs_EXTERNAL ) continue;
109       
110       Standard_Boolean equafound = Standard_False;
111       TopExp_Explorer exE(newEdge,TopAbs_VERTEX);
112       for (; exE.More(); exE.Next() ) {
113         const TopoDS_Shape& VE = exE.Current();
114         TopAbs_Orientation oriVE = VE.Orientation();
115
116         if ( V.IsEqual(VE) ) {
117           equafound = Standard_True;
118           break;
119         }
120         else if (oriVE == TopAbs_FORWARD || oriVE == TopAbs_REVERSED) {
121           if (oriV == oriVE) {
122             equafound = Standard_True;
123             break;
124           }
125         }
126         else if (oriVE == TopAbs_INTERNAL || oriVE == TopAbs_EXTERNAL) {
127           Standard_Real parV = EDBU.Parameter();
128           Standard_Real parVE = BRep_Tool::Parameter(TopoDS::Vertex(VE),TopoDS::Edge(newEdge));
129           if ( parV == parVE ) {
130             equafound = Standard_True;
131             break;
132           }
133         }
134       }
135       if ( !equafound  ) {
136         if (Vori == TopAbs_FORWARD)  {
137           nVF++;
138           if (nVF == 1) VF = V;
139         } 
140         if (Vori == TopAbs_REVERSED) {
141           nVR++;
142           if (nVR == 1) VR = V;
143         }
144         if (oriV == TopAbs_INTERNAL) tosplit = Standard_True;
145         Standard_Real parV = EDBU.Parameter();
146         myBuildTool.AddEdgeVertex(newEdge,V);
147         myBuildTool.Parameter(newEdge,V,parV);
148       } // !equafound
149       
150     } // EDBUloop.InitVertex :  on vertices of new edge newEdge
151     
152     Standard_Boolean addedge = (nVF == 1 && nVR == 1);
153     Standard_Boolean bitclosed = Standard_False;
154     if (nVF == 1 && nVR == 1) {
155       bitclosed = VF.IsSame(VR);
156       newEdge.Closed(bitclosed);
157     }
158     if (addedge) {
159       if (tosplit) {
160         TopTools_ListOfShape loe; Standard_Boolean ok = TopOpeBRepTool_TOOL::SplitE(TopoDS::Edge(newEdge),loe);
161         if (!ok) tosplit = Standard_False;
162         else     LOE.Append(loe);
163       }
164       if (!tosplit) LOE.Append(newEdge);
165     }    
166   } // EDBU.InitEdge : loop on EDBU edges
167   
168   
169 #ifdef DRAW
170   if(tSPS) {
171     TCollection_AsciiString str1; str1 = "e";
172     TCollection_AsciiString str2; str2 = iE;
173     FDRAW_DINLOE("",LOE,str1,str2);
174   }
175 #endif
176   
177 } // GEDBUMakeEdges