Volumetric visualization
-
Hello Experts!
for study purposes I need to create a SketchUp Ruby script for volumetric visualization of radiation dose. Dose volume must be divided into voxels where each voxel have x;y;z coordinates and value V which represents dose intensity, besides the voxels must be colored in different colors regarding to value V. For example, if 5>V>3, then color = blue, but if 10>V>5, then color = green et cetera.
Can someone suggest a script to modify for my needs or help solve this problem?P.S. I am not an IT professional, my field of study is physics, so scripting is not an ordinary activity for me

Thanks in advance,
Martins
-
How is the data input into SketchUp ?
I imagine you don't want to type x,y,z,v in for every one !
If it is the form of Comma Separated Values in a CSV file - read/writable in Excel - then as the data is plain text you can read in the lines as individual voxels.
I recommend that 1 unit in the file is represented by 1" in SketchUp [makes the number crunching easier].
So then we have an array called 'voxels' containing several array of [x,y,z,v] data.
Your tool needs to start by making a 'voxel' component - I suggest a 1x1x1 cube - easily done by making a definition and adding a 1x1 face from 4 points and pushpulling it by 1.
Next you need to set up some colored materials to use later [suggest material.alpha= opacity at ~0.4] - you can specify by name - e.g. 'red' or create your own colors etc.
Now make add a group in the model.entities to contain the voxel 'instances'.
Now iterate the vowels and to the group.entities add an instance of the voxel definition.
Read that voxel's array x,y,z,v values - use .to_f to convert the imported strings into numbers
Make a point3d based on these x,y,z values.
Use that point3d in a new Transformation.
instance = group.entities.add_instance(voxel, transformation)
The new instance of a voxel is added at x,y,z, it uses the default material.
Now use a series of 'case' or 'if' tests to decide on the 'instance.material=' you use for that instance.
You can also set the instance.name=v.to_s so the Entity Info can tell you the exact value of a selected voxel.
After all of the voxels are processed you now have a stack of cubes colored by their 'v'.
If the color has transparency then you can see through them, or Xray view-mode ?There are several plugin/code examples on SCF for the reading of CSV data, use of .to_f, making materials/colors, making components, adding instances with transformations, making tests assigning materials and so on
-
Your best bet is to extract the iso-surface from your data using marching-cubes rather than generate zillions of cubes.
It would mean you could create N colored surfaces representing each of your threshold values for V.
If you're asking whether its a trivial 10 minute script. The answer is unfortunately, No.

Adam
-
Thank's to all, problem solved!
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement