X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;f=vv%2FvvLandmarks.cxx;h=dc38cd228f69b27981960e24b220bf3fafa5c4eb;hb=2b4f24763b17fe431e37952269c8efb83b9fb06b;hp=d0f2c916daa2fcc6224f248740e26e3436631cfb;hpb=d6a6a206c0a533a60519e9b3e82fba48d1240c3e;p=clitk.git diff --git a/vv/vvLandmarks.cxx b/vv/vvLandmarks.cxx index d0f2c91..dc38cd2 100644 --- a/vv/vvLandmarks.cxx +++ b/vv/vvLandmarks.cxx @@ -118,6 +118,41 @@ void vvLandmarks::RemoveLastLandmark() //-------------------------------------------------------------------- +//-------------------------------------------------------------------- +void vvLandmarks::RemoveLandmarkWithLabel(vtkStdString label, int time) +{ + if (label != "P1" && label != "P2") + return; + // erase a vtkPoint by shifiting the array . + // not a problem here because there are no + // pologyons linking the points + int t = time;//mLandmarks[index].coordinates[3]; + int npoints = mPoints[t]->GetNumberOfPoints(); + + //search of the index corresponding to the label + int index(0); + while (mLabels[t]->GetValue(index) != label) + ++index; + + for (int i = index; i < npoints - 1; i++) { + mPoints[t]->InsertPoint(i, mPoints[t]->GetPoint(i+1)); + std::string str_i; // string which will contain the result + std::ostringstream convert; // stream used for the conversion + convert << i; // insert the textual representation of 'i' in the characters in the stream + str_i = convert.str(); // set 'str_i' to the contents of the stream + mLabels[t]->SetValue(i,mLabels[t]->GetValue(i+1)); + } + mPoints[t]->SetNumberOfPoints(npoints-1); + mLabels[t]->SetNumberOfValues(npoints-1); + mLabels[t]->Modified(); + mPolyData->Modified(); + + mLandmarks[t].erase(mLandmarks[t].begin() + index); + mIds[t]->RemoveLastTuple(); +} +//-------------------------------------------------------------------- + + //-------------------------------------------------------------------- void vvLandmarks::RemoveLandmark(int index) {