------------------------------------------------------------------------------
| 2160 | |
| 2161 | //------------------------------------------------------------------------------ |
| 2162 | void vtkReebGraph::Implementation::FindLoops() |
| 2163 | { |
| 2164 | |
| 2165 | if (this->ArcLoopTable) |
| 2166 | { |
| 2167 | free(this->ArcLoopTable); |
| 2168 | this->ArcLoopTable = nullptr; |
| 2169 | this->LoopNumber = 0; |
| 2170 | } |
| 2171 | |
| 2172 | this->ConnectedComponentNumber = 0; |
| 2173 | |
| 2174 | int nstack = 0, mstack = 0; |
| 2175 | int* stack = nullptr; |
| 2176 | |
| 2177 | char* Ntouch = (char*)malloc(sizeof(char) * this->MainNodeTable.Size); |
| 2178 | char* Atouch = (char*)malloc(sizeof(char) * this->MainArcTable.Size); |
| 2179 | |
| 2180 | memset(Ntouch, 0, sizeof(char) * this->MainNodeTable.Size); |
| 2181 | |
| 2182 | for (int Node = 1; Node < this->MainNodeTable.Size; Node++) |
| 2183 | { |
| 2184 | // check that the node is clear |
| 2185 | if (this->GetNode(Node)->ArcUpId == -2) |
| 2186 | continue; |
| 2187 | |
| 2188 | if (!Ntouch[Node]) |
| 2189 | { |
| 2190 | ++(this->ConnectedComponentNumber); |
| 2191 | |
| 2192 | memset(Atouch, 0, sizeof(bool) * this->MainArcTable.Size); |
| 2193 | |
| 2194 | Ntouch[Node] = 1; |
| 2195 | nstack = 0; |
| 2196 | vtkReebGraphStackPush(Node); |
| 2197 | |
| 2198 | while (vtkReebGraphStackSize()) |
| 2199 | { |
| 2200 | |
| 2201 | int N = vtkReebGraphStackTop(); |
| 2202 | vtkReebGraphStackPop(); |
| 2203 | |
| 2204 | for (int dir = 0; dir <= 1; dir++) |
| 2205 | { |
| 2206 | for (vtkIdType A = (!dir) ? (this->GetNode(N)->ArcDownId) : (this->GetNode(N)->ArcUpId); |
| 2207 | A; A = (!dir) ? (this->GetArc(A)->ArcDwId1) : (this->GetArc(A)->ArcDwId0)) |
| 2208 | { |
| 2209 | int M = (!dir) ? (this->GetArc(A)->NodeId0) : (this->GetArc(A)->NodeId1); |
| 2210 | |
| 2211 | if (Atouch[A]) |
| 2212 | continue; |
| 2213 | |
| 2214 | if (!Ntouch[M]) |
| 2215 | { |
| 2216 | vtkReebGraphStackPush(M); |
| 2217 | } |
| 2218 | else |
| 2219 | { |
no test coverage detected