Invalidation doesn't mean hiding anything, it marks a range in a buffer that should be reuploaded from CPU to GPU (OpenGL) memory for rendering. If buffer hadn't actually changed - there will be no visual result.
Archived discussion
Invalidate AIS_PointCloud elements
Hello!
I have an AIS_PointCloud data and try to hide some of its elements by re-uploading modified portion of Graphic3d_ArrayOfPrimitives without recomputing entire presentation using Graphic3d_Buffer::InvalidatedRange() mechanism. I indicate below the code used for this:
// define the points array for filling up the pointCloud data
Handle(Graphic3d_ArrayOfPoints _pointsArray = new Graphic3d_ArrayOfPoints(11);
Handle(Graphic3d_ArrayOfPrimitives) primitiveArray = _pointsArray;
const Handle(NCollection_BaseAllocator)& anAlloc = Graphic3d_Buffer::DefaultAllocator();
mutable Handle(Graphic3d_AttribBuffer) _pointsArrayAttribs = new Graphic3d_AttribBuffer(anAlloc);
_pointsArrayAttribs->Init(primitiveArray->Attributes()->NbElements, primitiveArray->Attributes()->AttributesArray(), primitiveArray->Attributes()->NbAttributes);
_pointsArrayAttribs->SetMutable(true);
//filling my pointCloud with _pointsArray elements
pointCloud->SetPoints(_pointsArray);
//...
//invoking _pointsArrayAttribs to hide some range of points
_pointsArrayAttribs->Invalidate(0, 6);
GetContext()->Redisplay(pointCloud, true, true);
GetContext()->UpdateCurrentViewer();
Although _pointsArrayAttribs seems to contain the correct data, the points in the range 0-6 are not hidden. What is wrong?
Thank you!
Discussion
4 archived replies
Posts are displayed in their archived order.
Hello!
Thank you very much for your response!
I want to use this mechanism by re-uploading modified portion of Graphic3d_ArrayOfPrimitives without recomputing the entire presentation.
Can you indicate what are the necessary steps to use this mechanism?
Unfortunately, there is no documentation or a simple example that can be followed.
Conceptually something like this:
Handle(Graphic3d_ArrayOfPoints) aPnts = new Graphic3d_ArrayOfPoints(11, Graphic3d_ArrayFlags_AttribsMutable);
for (int i = 0; i < 11; ++i) { aPnts->SetVertice(i + 1, i*4, i%4, i%3); }
Handle(AIS_PointCloud) aPrs = new AIS_PointCloud();
aCloud->SetPoints(aPnts);
theCtx->Display(aPrs, true);
...
// change (hide) 10th point
aPnts->SetVertice(10+1, std::numeric_limits<float>::quiet_NaN(), 0, 0);
Graphic3d_AttribBuffer* aPntBuff = dynamic_cast<Graphic3d_AttribBuffer*>(aPnts->Attributes().get());
aPntBuf->Invalidate(10, 10);
Don't know if using NaN is a good idea for hiding anything.
Thank you very much!!!
What are the recommended values for hiding a point?
If I use the suggested values: std::numeric_limits<float>::quiet_NaN(), 0, 0 - the hiding and later redisplaying of the points works correctly, but at some point during this process, the following error is triggered:
*** ERROR: ASSERT in file '.../SelectMgr/SelectMgr_Frustum.lxx': Error! Failed to project box (aMaxB >= aMinB)
The error occurs after a series of point displays/hides using the procedure and the value indicated for setting a vertice, right after selecting a point in the workspace using pick point!
I would appreciate any guidance on how to address this issue or where to seek potential solutions.