| 419 | } |
| 420 | |
| 421 | bool ShadingControl_Impl::addSubSurface(const SubSurface& subSurface) { |
| 422 | // Check if subSurface already exists |
| 423 | boost::optional<unsigned> _existingIndex = subSurfaceIndex(subSurface); |
| 424 | if (_existingIndex) { |
| 425 | LOG(Warn, "For " << briefDescription() << ", SubSurface already exists."); |
| 426 | return true; |
| 427 | } |
| 428 | |
| 429 | bool result; |
| 430 | |
| 431 | auto eg = getObject<ModelObject>().pushExtensibleGroup().cast<WorkspaceExtensibleGroup>(); |
| 432 | bool subsurface = eg.setPointer(OS_ShadingControlExtensibleFields::SubSurfaceName, subSurface.handle()); |
| 433 | if (subsurface) { |
| 434 | result = true; |
| 435 | } else { |
| 436 | // Something went wrong |
| 437 | // So erase the new extensible group |
| 438 | getObject<ModelObject>().eraseExtensibleGroup(eg.groupIndex()); |
| 439 | result = false; |
| 440 | } |
| 441 | return result; |
| 442 | } |
| 443 | |
| 444 | bool ShadingControl_Impl::setSubSurfaceIndex(const SubSurface& subSurface, unsigned index) { |
| 445 | boost::optional<unsigned> idx = subSurfaceIndex(subSurface); |