| 349 | } |
| 350 | |
| 351 | class DebugWriter { |
| 352 | public: |
| 353 | DebugWriter() : enabled_(false) {} |
| 354 | |
| 355 | DebugWriter(bool enabled, const std::string& filename_prefix) |
| 356 | : enabled_(enabled) { |
| 357 | if (enabled_) { |
| 358 | obj.open(filename_prefix + ".obj"); |
| 359 | vi = 1; |
| 360 | svg.open(filename_prefix + ".svg"); |
| 361 | svg << "<svg xmlns=\"http://www.w3.org/2000/svg\" version=\"1.1\" viewBox=\"-10 -10 200 200\">\n"; |
| 362 | } |
| 363 | } |
| 364 | ~DebugWriter() { |
| 365 | if (enabled_) { |
| 366 | svg << "</svg>\n"; |
| 367 | obj << std::flush; |
| 368 | obj.close(); |
| 369 | svg.close(); |
| 370 | } |
| 371 | } |
| 372 | |
| 373 | DebugWriter(const DebugWriter&) = delete; |
| 374 | |
| 375 | DebugWriter(DebugWriter&& other) noexcept |
| 376 | : obj(std::move(other.obj)), vi(other.vi), svg(std::move(other.svg)), enabled_(other.enabled_), last_segment_name_(std::move(other.last_segment_name_)) |
| 377 | { |
| 378 | other.enabled_ = false; |
| 379 | other.vi = 1; |
| 380 | other.last_segment_name_.clear(); |
| 381 | } |
| 382 | |
| 383 | DebugWriter& operator=(const DebugWriter&) = delete; |
| 384 | |
| 385 | DebugWriter& operator=(DebugWriter&& other) noexcept { |
| 386 | if (this == &other) { |
| 387 | return *this; |
| 388 | } |
| 389 | |
| 390 | if (enabled_) { |
| 391 | svg << "</svg>\n"; |
| 392 | obj << std::flush; |
| 393 | obj.close(); |
| 394 | svg.close(); |
| 395 | } |
| 396 | |
| 397 | obj = std::move(other.obj); |
| 398 | svg = std::move(other.svg); |
| 399 | vi = other.vi; |
| 400 | enabled_ = other.enabled_; |
| 401 | last_segment_name_ = std::move(other.last_segment_name_); |
| 402 | |
| 403 | other.enabled_ = false; |
| 404 | other.vi = 1; |
| 405 | other.last_segment_name_.clear(); |
| 406 | |
| 407 | return *this; |
| 408 | } |
no test coverage detected