Bentley Communities
Bentley Communities
  • Site
  • User
  • Site
  • Search
  • User
  • Welcome
  • Products
  • Support
  • About
  • More
  • Cancel
MicroStation
  • Product Communities
  • More
MicroStation
MicroStation Wiki [V8i C++] PointCloud IPointCloudChannelDisplayHandler
    • Sign in

    • +MicroStation Wiki
    • +Administration Wiki
    • +Annotations Wiki
    • +Bentley View Wiki
    • +MicroStation PowerDraft
    • -Programming Wiki
      • A class to help create and modify text element
      • A Complete Example
      • A MicroStation VBA Example With Bentley ProjectWise
      • AddIn Development Using VB.NET
      • C# .NET Template with IPrimitiveCommandEvents Class
      • Capturing Graphics in Dynamic Views
      • Compiling MDL Applications
      • Database Manipulation
      • Debugging Native Code MDL Applications
      • Developing Code in VBA
      • Developing MicroStation Applications For DWG Files
      • Drag and Drop in MicroStation
      • Error: "Cannot save changes to VBA project 'Support' because it is read-only"
      • Getting And Setting Elements Using Graphic Groups In VBA [CS]
      • Getting Started with Visual Basic
      • How To Write A Recursive Routine In MicroStation VBA [CS]
      • Introducing Segment3D Methods In MicroStation V8 2004 Edition
      • Known issues in MDL and MicroStationAPI
      • Launching VBA Applications As Initapps Or Dgnapps [CS]
      • Learning MicroStation Addins Step by Step
      • MDL - Getting Started With XAttributes In MicroStation V8 XM Edition
      • MDL - Native Code Application Development
      • MDL Or MicroStation BASIC Choosing The Right Tool [TN]
      • MFC Dialog And Native Window Support
      • Microsoft Office VBA Patch Utility
      • MicroStation BASIC FAQ
      • MicroStation BASIC Limits [FAQ]
      • MicroStation Developer Documentation and Example Code
      • MicroStation Programming Advice
      • MicroStation SDK
      • MicroStation V8 Programming Tools Readme
      • MicroStation V8 VBA Programming Resources [CS]
      • MicroStation V8 XM Edition View Code Updates
      • MicroStation VBA Resources Revisited [CS]
      • Migrating Dimension Code To MicroStation V8
      • Migrating MDL Applications To Native Code
      • Mouse Wheel Events And The Visual Basic 6.0 IDE
      • Porting MDL Applications To MicroStation V8
      • Reading Elements From A Microsoft Access Database With VBA [CS]
      • Running MDL Applications
      • Scanning For MicroStation V8 Elements In VBA [CS]
      • Unleash A Workspace Wizard Automating Workspace Creation With MicroStation V8 And VBA [CS]
      • Using VBA To Detect The Current Or Last Used Command
      • Using VBA To Programmatically Export A VBA Project [CS]
      • Using VBA To Programmatically Import A VBA Projects Components And References [CS]
      • VBA -- Creating A Complex Application
      • VBA Interface Error: failed creating the comp manager - 0x80040583
      • VBA interface error: unable to get IDE
      • vba recording
      • Working With Levels In MicroStation VBA [CS]
      • Writing An MDL Application To Output Custom Placemarks To Google Earth
      • [V8i C++] PointCloud IPointCloudChannelDisplayHandler
    • +Visualization Wiki

     
     Questions about this article, topic, or product? Click here. 

    [V8i C++] PointCloud IPointCloudChannelDisplayHandler

    Q: [v8i C++] PointCloud IPointCloudChannelDisplayHandler by Maury

    Any there any examples of using this for making your own display style?


    A: Re: [v8i C++] PointCloud IPointCloudChannelDisplayHandler by Simon Normand

    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);


     

    • pointcloud
    • MicroStation C++ API Example
    • IPointCloud
    • Share
    • History
    • More
    • Cancel
    • Dan Koval Created by Bentley Colleague Dan Koval
    • When: Thu, Sep 5 2013 3:52 PM
    • Revisions: 1
    • Comments: 0
    Recommended
    Related
    Communities
    • Home
    • Getting Started
    • Community Central
    • Products
    • Support
    • Secure File Upload
    • Feedback
    Support and Services
    • Home
    • Product Support
    • Downloads
    • Subscription Services Portal
    Training and Learning
    • Home
    • About Bentley Institute
    • My Learning History
    • Reference Books
    Social Media
    •    LinkedIn
    •    Facebook
    •    Twitter
    •    YouTube
    •    RSS Feed
    •    Email

    © 2021 Bentley Systems, Incorporated  |  Contact Us  |  Privacy |  Terms of Use  |  Cookies