Set and observe transform node to markups curve node: bug or feature?

Greeting,

Transformation of vtkMRMLMarkupsClosedCurveNode looks like a little bit buggy. Points of the curve are transformed correctly, but not the curve itself.

There is no such problem with markups line node, where both line and points are transformed correctly.

Code closedCurveNode->SetAndObserveTransformNodeID(transformNode->GetID());

gives such results

Thanks for reporting this, I’ll take a look at it.

1 Like

@mik Can you reproduce the problem with the latest Slicer Preview Release?

Build from the source, the problem remains.

Slicer 4.11.0-2020-05-14 r29057 / 0bc7cb1

curve node without transformation

curve node with transformation (points and curve are separated)

I’ve made a fix, could you try the latest version of Slicer?

1 Like

The fix will be included in Slicer Preview Release that you download tomorrow or later.

Thank you, the major problem has been fixed.

I have one more minor issue with markups node. How to update markups data in loadable module correctly?

I have markups node with four points (rectangle). When i update markups control point position the code the point change it position, but not the curve.

The have found the solution by removing node and creating it with a new positions.

Can you send a link to the code lines where you set the control point positions?

Here is a method, which creates a curve node, other curve nodes use the same technique.

I made the following snippet based on the code from the CreateImagerBoundary function, but it doesn’t seem to cause the issue:

c = slicer.vtkMRMLMarkupsClosedCurveNode()
slicer.mrmlScene.AddNode(c)
c.SetCurveTypeToLinear()
c.SetHideFromEditors(1)
c.AddControlPoint(vtk.vtkVector3d(0.0, 0.0, 0.0))
c.AddControlPoint(vtk.vtkVector3d(1.0, 0.0, 0.0))
c.AddControlPoint(vtk.vtkVector3d(1.0, 1.0, 0.0))
c.AddControlPoint(vtk.vtkVector3d(0.0, 1.0, 0.0))

What would happen if you modify a z coordinate of each point and try to update a curve node? Will the curve change it position as well, not just control points?

Static curve is not a problem anymore, thanks to your fix, but in GUI i have a slider which change z coordinates of the curve and only control points move.

Updating a control point position updates the curve correctly. For example, this code updates first point of curve “C” correctly (point and curve are both updated):

c = getNode('C')
p = [0,0,0]
c.GetNthControlPointPosition(0, p)
p[2] = p[2] + 10
c.SetNthControlPointPosition(0, *p)

Thank you!

After some trials and errors, i have found the code

double p[3];
imagerMarkupsNode->GetNthControlPointPosition( 0, p);
p[2] = value
imagerMarkupsNode->Modified()

didn’t work, but code

double p[3];
imagerMarkupsNode->GetNthControlPointPosition( 0, p);
p[2] = value
imagerMarkupsNode->SetNthControlPointPosition( 0, p[0], p[1], p[2]);

works as it should.

The topic is closed.

1 Like

Would you recommend to make any changes to the documentation to clarify that no permanent synchronization mechanism is created between the input Python array and a markups node when you call GetNthControlPointPosition?

It will good to have a some kind of warning about such feature, and something like:

Warning: In order to update position of markups as well as a curve, one always must use SetNthControlPointPosition method.