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