Home › Forum › SOFA › Using SOFA › [SOLVED] Bounding Boxes in SOFA
Tagged: 64_bits, bounding box grid regular, Linux_ubuntu, SOFA_1512
- This topic has 7 replies, 4 voices, and was last updated 8 years, 5 months ago by Hugo.
-
AuthorPosts
-
16 April 2016 at 13:04 #6540jjcasmarBlocked
Hello,
I would like to know if there is a way to access to the bounding box of an object in the XML file.
Im trying to generate a grid that contains a mesh. I am using the RegularGridTopology component. In the XML I have this
<RegularGrid name="Grid" nx="4" ny="4" nz="4" xmin="-5.25" xmax="2.25" ymin="0.25" ymax="5.25" zmin="-2" zmax="3"/>
The values xmin…zmax are the boundingbox of the grid I will generate.
I want to know if its possible to get this values from a topology or from a MechanicalObject.
Thanks!
18 April 2016 at 07:38 #6541Alex BilgerBlockedI don’t know if there is such a component, but you may want to use SparseGridTopology instead of RegularGrid. The former is made to contain a mesh, but it creates only cells inside and on the boundary of the mesh.
If you really want to use RegularGrid and you know C++, it should be really simple to create one engine that computes the bounding box that you can provide to the regular grid.Hope this helps,
Alex
18 April 2016 at 10:24 #6542jjcasmarBlockedThanks Alex,
I didnt know about the SparseGridTopology. Anyway, I must upload the displacement data of an underlying tetrahedral mesh to a 3DTexture in OpenGL. That’s why I am using the RegularGrid. What I’m doing is using the BarycentricMapping between the Tetrahedral object and the grid. In a second step, I just check if the point is inside a tetrahedron (possible using the mapping data) and if it’s not, just set the displacement to 0.
I know I can do a DataEngine to compute the bounding boxes, but it’s such a common task in graphics to ask information about BBoxes (even sofa uses BBoxes to check collisions) that there should be a way to access this BBox info from the XML to link it for example for computing grids…
18 April 2016 at 11:12 #6544Alex BilgerBlockedI understand your goal. Do you think you can do it with a SparseGridTopology. I saw that it internally creates a RegularGrid adapted to your object. Maybe you can use it.
I guess all the bounding box calculations are always done internally. I agree a simple component providing the bounding box of an object would be useful. Maybe it exists but I’m not aware of any.
For your project, have you had a look on the plugin image? Maybe there is all you need.
18 April 2016 at 11:22 #6545jjcasmarBlockedI know the image plugin. My first try was to use it, but then I realized that I need to check in which tetrahedron each sample point was to compute the interpolated displacement, and thinking about that problem I realized that it was already solved if I used a grid topology and a barycentric mapping.
I will check the SparseGridTopology. If it’s possible to access the full regular grid voxels, it will be sufficient.
Thanks Alex!
20 April 2016 at 09:35 #6548jjcasmarBlockedI was able to do what I was trying to do using a SparseGridTopology.
Anyway, the question is still open, is there any possibility to access the BBox from the XML file and link it to other data of other components?
20 April 2016 at 10:02 #6550FroyKeymasterIt is possible to fetch BBox informations from the Camera, if you are using it (it is instanced by default if using standard GUI).
If you want to use links, you need to set it explicitly in the scene
(just add
<interactivecamera name="camera"></interactivecamera>
)
and link the bbox data to your component:<yourcomponent minBBox="@camera.minBBox" minBBox="@camera.maxBBox"></yourcomponent>
6 June 2016 at 14:56 #7033HugoKeymasterI guess the Fred’s answer solved your problem, right JuanJo ?
If you need anything, re-open the thread.
Cheers,Hugo
-
AuthorPosts
- You must be logged in to reply to this topic.