Visualizing heatmaps in the surface of 3D models

Hello,

I'm trying to visualize heatmaps in the surface of 3D models in OpenCascade 7.3.0. Unfortunately, I've been unable to properly color a model since AIS_TexturedShape, aparently, only allows to give a texture to each face and I will have a map of the whole model.

I have been also testing with MeshVS_Mesh but the result is not as I expected. Here is the piece of code I have used to color the mesh:

void MainWindow::makeMesh(Standard_CString file_model_path)
{
    Handle_Poly_Triangulation aPolyTriang = RWStl::ReadFile ("Cylinder.stl");
    Handle_XSDRAWSTLVRML_DataSource aDataSource = new XSDRAWSTLVRML_DataSource (aPolyTriang);

    // create mesh
    Handle_MeshVS_Mesh aMesh = new MeshVS_Mesh();
    aMesh->SetDataSource  (aDataSource);


    Handle_MeshVS_NodalColorPrsBuilder aBuilder = new MeshVS_NodalColorPrsBuilder(aMesh,MeshVS_DMF_NodalColorDataPrs | MeshVS_DMF_OCCMask);
    aMesh->AddBuilder (aBuilder, Standard_True);

    // prepare color map
    Aspect_SequenceOfColor  aColorMap;
                            aColorMap.Append  (Quantity_NOC_RED);
                            aColorMap.Append(Quantity_NOC_GOLD1);
                            aColorMap.Append  (Quantity_NOC_BLUE1);
                            aColorMap.Append  (Quantity_NOC_VIOLET);

    TColStd_DataMapOfIntegerReal  aScaleMap;
    int anId=0; double aValue=0;

    
    // iterating through the nodes
    const TColgp_Array1OfPnt& mNodes=aPolyTriang->Nodes();
    for(auto point:mNodes)
    {
       anId++;

       //Giving one color to nodes with high Z and another to the low ones
       if (aPolyTriang->Node(anId).Z()>100)
          aValue=0.9;
       else
          aValue=0.1;

       aScaleMap.Bind  (anId, aValue);

    }
    
    // pass color map and color scale values to the builder
    aBuilder->SetTextureCoords(aScaleMap);
    aBuilder->SetColorMap  (aColorMap);
    aBuilder->UseTexture(true);
    aBuilder->SetInvalidColor(Quantity_NOC_PINK);


    aMesh->AddBuilder  (aBuilder, Standard_True);
    aMesh->UnsetMaterial();

    mContext->Activate(aMesh); //Activating the AIS_interactiveContext

    mContext->Display(aMesh, 3, TopAbs_SHAPE, true); //Displaying the mesh
    

}

As you can see in the attached image, I get the colored mesh but i think the lines of the triangulation are also represented in yellow and i can't get rid of them.

Does anyone know who to load a shape and color its surface with a color map? As I say, I'm open to use the raw data of the map and insert it in a mesh and to load the map with an image file and apply it to the whole shape.

 

Thanks in advance!

Álvaro

 

Attachments: 
Kirill Gavrilov's picture

MeshVS defines its own set of presentation parameters via MeshVS_Drawer class and MeshVS_DrawerAttribute enumeration.
MeshVS_DA_ShowEdges is enabled by default, but can be disabled.

Alvaro Fernandez's picture

Yes, it works fine with this new line.

aMesh->GetDrawer()->SetBoolean(MeshVS_DA_ShowEdges, false);

Thank you very much!