[v8i C++] PointCloud IPointCloudChannelDisplayHandler

I am assuming this can be used for making your own display style.. Any examples? The documentation is very poor.

Thanks!

  • Hi,

    First, you cannot create custom display styles and have them listed in the View Attributes dialog.

    The IPointCloudChannelDisplayHandler interface allows you to change the display of points for your custom point channel. If you are not familiar with the IPointCloudChannel interface, it allows you to store arbitrary per point data.

    Here's an example of use of both interfaces:

    I want to color the points that are within a certain distance of another MS element and display them in a different color.

    The first I would create a point channel that stores a single integer value per point

    int defaultValue = -1;
    Bentley::WString infoStr (L"Storing distances to element");
    PointCloudChannelPtr pMyChannel = PointCloudChannelManager::GetManager().CreateChannel (Bentley::WString(L"DistanceChannel"), &infoStr, sizeof(int), 1, &defaultValue, false);

    Then I would run a query on points and calculate the distance for each point

                PointCloudDataQueryPtr query = IPointCloudDataQuery::CreateBoundingBoxQuery(elHandle, origin, corner);
               
                int             maxPoints = 50000;
                DPoint3d*       pointsBuffer =  new DPoint3d[maxPoints];
                int             pointsRead = 0;
                
                // alloc buffer for our channel
                int*          channelBuffer = new int[maxPoints];
                PointChannelQueryBufferVector channelQueries;
                channelQueries.push_back (PointChannelQueryBuffer (pMyChannel, channelBuffer));
                //  Perform the query for points
                do
                    {
                    pointsRead = query->GetDetailedPoints (maxPoints, pointsBuffer, NULL, NULL, NULL, NULL, NULL, &channelQueries);
                    if (pointsRead)
                        {
                        // loop on each point, set its distance in channelBuffer[]

    ...

                        query->SubmitUpdate (pMyChannel);
                        }
                    }
                    while (pointsRead > 0);

                delete [] pointsBuffer;
                delete [] channelBuffer;

    Now that I have setup my own point channel. I can create its display handler.

    class DistanceChannelDisplayHandler : public IPointCloudChannelDisplayHandler,  public PointCloudChannelHandler
        {
        protected:
            virtual bool _CanHandle (ElemHandleCR eh) const override {return true};
            virtual UInt _OnDisplay (IViewContextP viewContext, ElemHandleCR eh, UInt bufferSize,
                DPoint3dP geomBuffer, RGBColorDef* rgbBuffer, UChar* selectionBuffer,
                UChar* classificationBuffer, void* channelBuffer)
                {
            // loop on each point, retrieve value from channel buffer, change the color in rgbBuffer
            ...
                return bufferSize;
                }

        };

    Create an instance of DistanceDisplayChannelHandler and set it as the handler for my custom point channel.

    pMyChannel->SetHandler (&myDistanceDisplayHandler);

    I hope this example helps

    Simon

    Answer Verified By: Phil Chouinard 

  • Thanks Simon! That clears up a lot.

    One question.. If you are storing a double value Distance as the channel, why did you create it as an integer?

    int defaultValue = -1;

    Bentley::WString infoStr (L"Storing distances to element");

    PointCloudChannelPtr pMyChannel = PointCloudChannelManager::GetManager().CreateChannel (Bentley::WString(L"DistanceChannel"), &infoStr, sizeof(int), 1, &defaultValue, false);

  • Hi Maury,

    I have edited my reply, I initially intented to store doubles and forgot to edit the query code.

    int*          channelBuffer = new int[maxPoints];

  • Unknown said:
    Here's an example

    Excellent example — keep them coming!

     
    Regards, Jon Summers
    LA Solutions