| 579 | } |
| 580 | |
| 581 | void mitk::PointSet::ExecuteOperation(Operation *operation) |
| 582 | { |
| 583 | int timeStep = -1; |
| 584 | |
| 585 | mitkCheckOperationTypeMacro(PointOperation, operation, pointOp); |
| 586 | |
| 587 | if (pointOp) |
| 588 | { |
| 589 | timeStep = this->GetTimeGeometry()->TimePointToTimeStep(pointOp->GetTimeInMS()); |
| 590 | } |
| 591 | |
| 592 | if (timeStep < 0) |
| 593 | { |
| 594 | MITK_ERROR << "Time step (" << timeStep << ") outside of PointSet time bounds" << std::endl; |
| 595 | return; |
| 596 | } |
| 597 | |
| 598 | switch (operation->GetOperationType()) |
| 599 | { |
| 600 | case OpNOTHING: |
| 601 | break; |
| 602 | |
| 603 | case OpINSERT: // inserts the point at the given position and selects it. |
| 604 | { |
| 605 | int position = pointOp->GetIndex(); |
| 606 | |
| 607 | PointType pt; |
| 608 | pt.CastFrom(pointOp->GetPoint()); |
| 609 | |
| 610 | if (timeStep >= (int)this->GetTimeSteps()) |
| 611 | this->Expand(timeStep + 1); |
| 612 | |
| 613 | // transfer from world to index coordinates |
| 614 | mitk::BaseGeometry *geometry = this->GetGeometry(timeStep); |
| 615 | if (geometry == nullptr) |
| 616 | { |
| 617 | MITK_INFO << "GetGeometry returned nullptr!\n"; |
| 618 | return; |
| 619 | } |
| 620 | geometry->WorldToIndex(pt, pt); |
| 621 | |
| 622 | m_PointSetSeries[timeStep]->GetPoints()->InsertElement(position, pt); |
| 623 | |
| 624 | PointDataType pointData = { |
| 625 | static_cast<unsigned int>(pointOp->GetIndex()), pointOp->GetSelected(), pointOp->GetPointType()}; |
| 626 | |
| 627 | m_PointSetSeries[timeStep]->GetPointData()->InsertElement(position, pointData); |
| 628 | |
| 629 | this->Modified(); |
| 630 | |
| 631 | // boundingbox has to be computed |
| 632 | m_CalculateBoundingBox = true; |
| 633 | |
| 634 | this->InvokeEvent(PointSetAddEvent()); |
| 635 | this->OnPointSetChange(); |
| 636 | } |
| 637 | break; |
| 638 |
no test coverage detected