Hello!
Just as it is possible to add a series of vertex / edges using AddVertex / AddEdges, it is also possible to delete / remove this kind of them from a Graphic3d_ArrayOfPrimitives array?
Thank you!
gkv311 n Thu, 02/02/2023 - 18:35
Graphic3d_ArrayOfPrimitives creates simple arrays of predefined length, and then 'adds' elements to the 'end' while it has capacity to.
Removing already added elements would require a massive copy of entire tail of array starting at element to be removed. This would be expensive operation that goes beyond the purpose of Graphic3d_ArrayOfPrimitives tool.
So, of you need such operations, then you might consider using other collections that allow removing elements more efficiently (at other costs) and then recreate Graphic3d_ArrayOfPrimitives from it.
Thank you very much for your time to respond to my question!
I intend to create a toolpath simulation and I'm trying to find an efficient solution to display large segments array (using AddEdges for Next and something opposite / deleting for Back step simulation). Also I'm not sure yet how to combine a Graphic3d_ArrayOfPrimitives with OCCT Animation class. I appreciate any ideas to move forward.
To implement fast back-step / forward-step elements, I would split a large array into smaller chunks (multiple Graphic3d_ArrayOfPrimitives). So that when moving back a little - you will reused most of the chunks and recreate only altered one(s).
One large Graphic3d_ArrayOfPrimitives is faster for rendering, many small arrays - faster for modification. So you need to find a balance for choosing an optimal chunk size in your case.
There is still a possibility not to delete but to hide an element from an array of Graphic3d_ArrayOfPrimitives? Or to set up an "invisible" color on the vertex? This would make development much easier!!
Sure, you may mark invisibility via vertex color attribute (4 extra bytes per vertex) + alpha masking Graphic3d_AlphaMode_Mask. There is no per-element attributes, so that you will need separating vertices of elements to be hidden in advance (this means duplicating vertices - which might be a plenty of memory overhead in case if you would want making an arbitrary element invisible). Graphic3d_ArrayFlags_AttribsDeinterleaved + Graphic3d_ArrayFlags_AttribsMutable flags would allow locally patching of existing VBO without re-uploading entire buffer of vertex attributes.
Or you may re-upload triangle indices and keep vertex attributes unaffected with help of Graphic3d_ArrayFlags_IndexesMutable flag. This might be more efficiently than dealing with per-vertex colors.
Or go into even lower-level stuff and implement a custom Geometry Shader reading information from some TBO.
Crazy stuff!!! :-)
It sounds more reasonable in terms of complexity to use Graphic3d_ArrayFlags_IndexesMutable flag.
Can you indicate just a simple example of how to use this flag in a simple 3D lines array to have a starting point?
As an example, The Graphic3d_ArrayOfPrimitives could display just a simple 2D rectangle. When I press Back I like to make the last segment array invisible, and when press Next to re-display it on the screen.
This could be a great example for this community also as there is absolute no example / documentation how to use this advanced flag!!!
Thank you very much!!
MyPArrayObject within src/ViewerTest/ViewerTest_ObjectCommands.cxx implementing command vdrawparray and test script tests/v3d/bugs/bug30076 might be helpful to figure out how this API is supposed to be used.
Thank you very much!!! At least I have a starting point! Just one more essential question: is this approach (using Graphic3d_ArrayFlags_IndexesMutable flag) an optimal one for using large amount of segments inside a Graphic3d_ArrayOfPrimitives? I'm pretty new user of OCCT technology and try to find the best approach for a toolpath simulation. In some cases there can be millions of segments inside a Graphic3d_ArrayOfPrimitives, and imagine I'm in my actual simulation I'm already almost at the end of it and want to go back a step, to the previous segment. I'm just trying to find the best solution for displaying these segments during the simulation.
I'm afraid there is no answer to question 'would it be fast or not'. You need trying approaches at hand, collect numbers for your use cases, use performance profilers to detect hotspots and decide further improvements upon results.
Hello!
Digging deep into the problem, new questions related to the current topic emerged:
1. How the Graphic3d_MutableIndexBuffer class can be used? Is there some samples / examples / scripts which help to understand how it can actually be used? I could not find any example for using it.
2. How can you use Graphic3d_MutableIndexBuffer with Graphic3d_ArrayOfPrimitives? How they can relate to each other if make sense?
3. If Graphic3d_MutableIndexBuffer can be used, what does InvalidateRange() do?
I appreciate any response as I am completely blocked in this problem!
Thank you!!
How can you use Graphic3d_MutableIndexBuffer with Graphic3d_ArrayOfPrimitives? How they can relate to each other if make sense?
Graphic3d_ArrayOfPrimitives is just a convenient interface for filling buffers. You may go ahead and create buffers on your own or use ArrayOfPrimitives to create them and then modify created buffers.
If Graphic3d_MutableIndexBuffer can be used, what does InvalidateRange() do?
Buffers are uploaded to GPU memory for efficient rendering. Reuploading buffers on each frame would be slow and doesn't make sense. Without calling InvalidateRange driver will keep drawing an old copy of buffer last uploaded to GPU memory.
Thu, 02/02/2023 - 18:35
Graphic3d_ArrayOfPrimitives
creates simple arrays of predefined length, and then 'adds' elements to the 'end' while it has capacity to.Removing already added elements would require a massive copy of entire tail of array starting at element to be removed. This would be expensive operation that goes beyond the purpose of
Graphic3d_ArrayOfPrimitives
tool.So, of you need such operations, then you might consider using other collections that allow removing elements more efficiently (at other costs) and then recreate
Graphic3d_ArrayOfPrimitives
from it.Thu, 02/02/2023 - 19:46
Thank you very much for your time to respond to my question!
I intend to create a toolpath simulation and I'm trying to find an efficient solution to display large segments array (using AddEdges for Next and something opposite / deleting for Back step simulation). Also I'm not sure yet how to combine a Graphic3d_ArrayOfPrimitives with OCCT Animation class. I appreciate any ideas to move forward.
Thu, 02/02/2023 - 21:09
To implement fast back-step / forward-step elements, I would split a large array into smaller chunks (multiple
Graphic3d_ArrayOfPrimitives
). So that when moving back a little - you will reused most of the chunks and recreate only altered one(s).One large
Graphic3d_ArrayOfPrimitives
is faster for rendering, many small arrays - faster for modification. So you need to find a balance for choosing an optimal chunk size in your case.Thu, 02/02/2023 - 21:45
Excellent!!!
Thank you very much for your thoughts, I appreciate your generosity!
Sun, 02/05/2023 - 12:18
There is still a possibility not to delete but to hide an element from an array of Graphic3d_ArrayOfPrimitives? Or to set up an "invisible" color on the vertex? This would make development much easier!!
Sun, 02/05/2023 - 13:35
Sure, you may mark invisibility via vertex color attribute (4 extra bytes per vertex) + alpha masking
Graphic3d_AlphaMode_Mask
. There is no per-element attributes, so that you will need separating vertices of elements to be hidden in advance (this means duplicating vertices - which might be a plenty of memory overhead in case if you would want making an arbitrary element invisible).Graphic3d_ArrayFlags_AttribsDeinterleaved
+Graphic3d_ArrayFlags_AttribsMutable
flags would allow locally patching of existing VBO without re-uploading entire buffer of vertex attributes.Or you may re-upload triangle indices and keep vertex attributes unaffected with help of
Graphic3d_ArrayFlags_IndexesMutable
flag. This might be more efficiently than dealing with per-vertex colors.Or go into even lower-level stuff and implement a custom Geometry Shader reading information from some TBO.
Sun, 02/05/2023 - 15:04
Crazy stuff!!! :-)
It sounds more reasonable in terms of complexity to use Graphic3d_ArrayFlags_IndexesMutable flag.
Can you indicate just a simple example of how to use this flag in a simple 3D lines array to have a starting point?
As an example, The Graphic3d_ArrayOfPrimitives could display just a simple 2D rectangle. When I press Back I like to make the last segment array invisible, and when press Next to re-display it on the screen.
This could be a great example for this community also as there is absolute no example / documentation how to use this advanced flag!!!
Thank you very much!!
Tue, 02/07/2023 - 12:50
MyPArrayObject
withinsrc/ViewerTest/ViewerTest_ObjectCommands.cxx
implementing commandvdrawparray
and test scripttests/v3d/bugs/bug30076
might be helpful to figure out how this API is supposed to be used.Tue, 02/07/2023 - 15:17
Thank you very much!!! At least I have a starting point! Just one more essential question: is this approach (using Graphic3d_ArrayFlags_IndexesMutable flag) an optimal one for using large amount of segments inside a Graphic3d_ArrayOfPrimitives? I'm pretty new user of OCCT technology and try to find the best approach for a toolpath simulation. In some cases there can be millions of segments inside a Graphic3d_ArrayOfPrimitives, and imagine I'm in my actual simulation I'm already almost at the end of it and want to go back a step, to the previous segment. I'm just trying to find the best solution for displaying these segments during the simulation.
Tue, 02/07/2023 - 15:53
I'm afraid there is no answer to question 'would it be fast or not'. You need trying approaches at hand, collect numbers for your use cases, use performance profilers to detect hotspots and decide further improvements upon results.
Sun, 02/12/2023 - 21:18
Hello!
Digging deep into the problem, new questions related to the current topic emerged:
1. How the Graphic3d_MutableIndexBuffer class can be used? Is there some samples / examples / scripts which help to understand how it can actually be used? I could not find any example for using it.
2. How can you use Graphic3d_MutableIndexBuffer with Graphic3d_ArrayOfPrimitives? How they can relate to each other if make sense?
3. If Graphic3d_MutableIndexBuffer can be used, what does InvalidateRange() do?
I appreciate any response as I am completely blocked in this problem!
Thank you!!
Sun, 02/12/2023 - 22:15
Graphic3d_ArrayOfPrimitives
is just a convenient interface for filling buffers. You may go ahead and create buffers on your own or use ArrayOfPrimitives to create them and then modify created buffers.Buffers are uploaded to GPU memory for efficient rendering. Reuploading buffers on each frame would be slow and doesn't make sense. Without calling
InvalidateRange
driver will keep drawing an old copy of buffer last uploaded to GPU memory.