export discrete deformation field

49 views
Skip to first unread message

Chi Zhang

unread,
May 28, 2021, 8:45:02 PM5/28/21
to scalismo
Hi ,
In Tutorial 3,  how to export(write) the discrete deformation field (or EuclideanVector)  to the a txt file? Since I am trying to plot a heatmap on a human face mesh to illustrate the protrusion/retrusion of the mouth/lips. 
Cheers,
Chi

Marcel Luethi

unread,
May 29, 2021, 8:32:15 AM5/29/21
to Chi Zhang, scalismo
Hi Chi

We do not currently have a dedicated method for writing out such fields. But you can just loop through the points, vectors as follows:
val faceWithVectors : DiscreteField[_3D, TriangleMesh, EuclideanVector[_3D]] = ???
for ((point, vec) <- faceWithVectors.pointsWithValues) {
// write it here, e.g.
print(point)
print(vec)
}
Best regards,
Marcel

--
You received this message because you are subscribed to the Google Groups "scalismo" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scalismo+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/scalismo/61fe3b57-15fa-4a77-9673-94c857b8f6c0n%40googlegroups.com.

Chi Zhang

unread,
May 30, 2021, 4:39:18 AM5/30/21
to scalismo
Hi Marcel, 
Thanks a lot. I have successfully written it out using the code below. 

```scala

//export deformation filed

val deformationField: DiscreteField[_3D, TriangleMesh, EuclideanVector[_3D]] = DiscreteField3D(referenceMesh, deformations)

val vecpw = new PrintWriter(new File("vec.txt" ))
val pointpw = new PrintWriter(new File("point.txt" ))

for ((point, vec) <- deformationField.pointsWithValues) {
vecpw.write(vec.toString+System.getProperty("line.separator"))
pointpw.write(point.toString+System.getProperty("line.separator"))
}

vecpw.close
pointpw.close
```
Cheers,

Chi


Reply all
Reply to author
Forward
0 new messages