[vtkusers] Create a custom valueType vtkArray

Ruben Di Battista rubendibattista at gmail.com
Sun Sep 30 05:12:25 EDT 2018


Hello, 

At the moment I have some code that reads like this:

        m_H->SetNumberOfValues(nPoints);
        m_G->SetNumberOfValues(nPoints);
        m_C->SetNumberOfValues(nPoints);
        m_SI->SetNumberOfValues(nPoints);

        for ( auto p : this->IterateOver<Point>() ) {
                auto curvatures = p.HG();
                m_H->SetValue(p.Id(), curvatures.H);
                m_G->SetValue(p.Id(), curvatures.G);
                m_C->SetValue(p.Id(), curvatures.C);
                m_SI->SetValue(p.Id(), curvatures.SI);
       }

        m_polyPtr->GetPointData()->AddArray(m_H);
        m_polyPtr->GetPointData()->AddArray(m_G);
        m_polyPtr->GetPointData()->AddArray(m_C);
        m_polyPtr->GetPointData()->AddArray(m_SI);

Where m_polyPtr is a vtkPolyData* and the return type of p.HG() is:
    
     struct Curvatures
    {
        double G; /**< Gauss Curvature */
        double H; /**< Mean Curvature */
        double C; /**< Curvedness */
        double SI; /**< Shape Index */
    };

Now I’m facing a problem where I need to add fields to the structure “Curvatures” and so I need to change code in three different classes. 
Is there a way to create a vtkArray whose (templated?) valueType is `Curvatures` such that I can just modify that struct to allow more fields to be stored and set in a “more abstract way” and that can be appended to the `PointData` of the vtkPolyData in a transparent way?

Any suggestion is appreciated! 

:)


          _   
-.     .´  |∞∞∞∞
  ',  ;    |∞∞∞∞∞∞
    ˜˜     |∞∞∞∞∞∞∞∞∞ RdB
    ,.,    |∞∞∞∞∞∞
  .'   '.  |∞∞∞∞
-'       `’

https://rdb.is
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180930/c08b5111/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: Message signed with OpenPGP using AMPGpg
URL: <https://public.kitware.com/pipermail/vtkusers/attachments/20180930/c08b5111/attachment.sig>


More information about the vtkusers mailing list