Attach cube on segmented surface

Is there any editing tools like “Fill between slices”

I want to attach cube(below pupple colored cube) on the surface(it means segmented region on the slice)

There is an effect called “Fill between slices” in Segment Editor module.

Would you like to 3D print a template that fits on the segmented surface? You can do that by the following steps:

  • Add a new segment
  • Select Scissors effect, set “Operation” to “Fill inside”, “Shape” to “Rectangle”, and “Editable area” to “Outside all segments”, then draw the rectangle in 3D view
  • You can use Islands effect’s “Keep selected island” method to keep only that part of the cube that sits on the surface
1 Like

Thank you. i will do that :slight_smile:
i think 3d slicer is very powerful tool as i think.
3d image processing is very interesting for me
i m in flow in that field. i love it. i am enthusiast!

1 Like

So, I am now automate below behavior using python script.
but, python scrip for effect of hollow and scissors by fiducial was not found

behavior

after generating mesh,

  1. new segment <== it is ok
  2. threshold-smooth <== ok
  3. markup by fiducial <== ok
    4. hollow effect <== not found
    5. scissors effect using markup <== c++ code founded but python not found



Scissors effect is developed for interactive use. If you want to place a box on a surface from a script then it is probably much easier to create a box-shaped model node from output of a vtkCurbeSource, then set its pose using a transform node (set translation based on a markups fiducial point position, set orientation by getting the surface normal at the fiducial point), then import the model into a segment in the segmentation node (using segmentationNode.AddSegmentFromClosedSurfaceRepresentation).

1 Like

From your advise, i did 1 box but now extend 9 boxes.
If python script is completed well, let it share this page.


Excepting normal from 3 fiducial points, attching cylinder pad on the surface of head ( I will update complete version including normal soon)

# Markup and Patching Circluar Pad On Surface of Head
f = getNode('F')
pos=[0,0,0]
f.GetNthFiducialPosition(0,pos)
markups = getNode('F')

# Get 3 point positions as numpy array for computing surface normal,position
# (Extend to 9 for computing surface normal,position,further release) )

import numpy as np

nOfFiduciallPoints = markups.GetNumberOfFiducials()
if nOfFiduciallPoints < 3:
    return  # not enough points

points = np.zeros([3,nOfFiduciallPoints])
for i in range(0, nOfFiduciallPoints):
    markups.GetNthFiducialPosition(i, points[:,i])

# Compute plane position and normal
planePosition = points.mean(axis=1)
planeNormal = np.cross(points[:,1] - points[:,0], points[:,2] - points[:,0])

# Apply to cylinder pad 
    cyl = vtk.vtkCylinderSource()
    cyl.SetRadius(10)
    cyl.SetResolution(50)
    cyl.SetHeight(10)
    #cyl.SetCenter(slicePosition)
    cyl.Update()
   segmentationNode.AddSegmentFromClosedSurfaceRepresentation(cyl.GetOutput(), "Pad", [1.0,0.0,0.0])

    transformMatrix.setSegmentationNode()

Scissors effect is developed for interactive use. If you want to place a box on a surface from a script then it is probably much easier to create a box-shaped model node from output of a vtkCurbeSource, then set its pose using a transform node (set translation based on a markups fiducial point position, set orientation by getting the surface normal at the fiducial point), then import the model into a segment in the segmentation node (using segmentationNode.AddSegmentFromClosedSurfaceRepresentation ).

then set its pose using a transform node (set translation based on a markups fiducial point position, set orientation by getting the surface normal at the fiducial point
==> so , Do you Know How to Set UI Value, Translation, Rotation, Apply transform

  1. Set the Transform Matrix for Rotation,Translation

image

  1. Apply transform,
    but i don t know the python script code for below picture :slight_smile:

image

You can apply a transform by setting the parent transform node (SetAndObserveTransformNodeID). See in example in Transforms module documentation.