16 April 2016 at 13 h 04 min #6540
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 7 h 38 min #6541AlexParticipant
I 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,
Alex18 April 2016 at 10 h 24 min #6542
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 h 12 min #6544AlexParticipant
I 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 h 22 min #6545
I 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 9 h 35 min #6548
I 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 h 02 min #6550FroyParticipant
- SOFA Consortium
It 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
and link the bbox data to your component:
<yourcomponent minBBox="@camera.minBBox" minBBox="@camera.maxBBox"></yourcomponent>6 June 2016 at 14 h 56 min #7033HugoKeymaster
- SOFA Consortium
I guess the Fred’s answer solved your problem, right JuanJo ?
If you need anything, re-open the thread.
- You must be logged in to reply to this topic.