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!

gkv311 n's picture

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.

bioan m's picture

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.

gkv311 n's picture

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.

bioan m's picture

Thank you very much!!!