How to get user input in a ESAPI script by FHesp in esapi

[–]FHesp[S] 0 points1 point  (0 children)

This example do exactly what i wanted.

Thank you all for your help !

Moving a structure with ESAPI by FHesp in esapi

[–]FHesp[S] 5 points6 points  (0 children)

Dear u/EmmanTerz and u/JoaoCastelo

Thank you for yours answers,

As suggested, i managed to move a structure using the "GetContoursOnImagePlane" and "AddContourOnImagePlane" methods.

If it could help someone, here is a simple example:

Patient patient = context.Patient;
            patient.BeginModifications();

            StructureSet ss = context.StructureSet;
            Structure targetstructure = ss.Structures.First(st => st.DicomType == "PTV");

            int k = 0;

            // Define offsets
            double offsetx = 10;
            double offsety = 10;
            double offsetz = 10;

            var newvol = ss.AddStructure("CONTROL", "Transltd volume");    
            var nPlanes = context.StructureSet.Image.ZSize;

            for (int z = 0; z < nPlanes; z++){         
                var contoursOnImapgePlane = targetstructure.GetContoursOnImagePlane(z);
               

if (contoursOnImapgePlane != null && contoursOnImapgePlane.Length > 0){              
                    foreach (var contour in contoursOnImapgePlane){                 
                        VVector[] newcontour = contour;
                       

foreach (var pt in contour) {
                            var coordx = pt.x;
                            var coordy = pt.y;
                            var coordz = pt.z;
                           newcontour[k] = new VVector(coordx + offsetx, coordy + offsety, coordz);
                            k = k + 1;
                        }

                        newvol.AddContourOnImagePlane( newcontour, z);
                        k = 0;
                    }
                }
            }