Opencascade color scale
[Email protected]
Abstract.The color scale is a specialized label object that displays a color map and an accompanying numerical scale for color mapped or contour data plots. as the geometry modeling kernel of Salome, opencascade provides the color scale function. the paper focus on the usage of color scale in opencascade.
Key words.Opencascade, color scale, stress cloud map, color ing table
1. Introduction
Stress cloud maps are widely used scalar field visualization methods and are often used to express a component of vector or tensor fields. A cloud map establishes a certain ing relationship between the color and the scalar data, and draws a color discrete change image on the computer screen to display the scientific computing results. A cloud map the data values in the definition field of a scalar field to different colors to reflect the changing rules of data in the data field through color changes.
The cloud map function is available for the post-processing results of many numerical analysis software. Shows the Cloud Maps generated by the ABAQUS software:
Figure 1.1 A colored stress patterns by ABAQUS
Opencascade, as the geometric modeling kernel of Salome open-source numerical analysis software, also provides the cloud map visualization function. This article describes how to use opencascade to display the color scale ing table (color scale) in the stress cloud of a model ).
2. Color Scale
Cloud Maps depend on the one-to-one ing between the color set and the scalar field value set, that is, the color scale ing table (color scale ). The color ing table establishes a ing relationship between values and colors when filling areas. As shown in:
Figure 2.1 color scale
As a reference for analysis and comparison, you can determine the numerical distribution of a region based on the numerical range corresponding to the color linear table. Color linear tables are not only used for cloud maps, but also for other computing visualization algorithms.
A color linear table can be defined in different forms. In contrast, a distinctive color is used as the color of a linear table segment, and a transitional color is used between two contrasting colors.
In opencascade, the color ing table is drawn by the viewer. The TCL command is vcolorscale, as shown below:
Figure 2.2 color scale TCL command: vcolorscale
Shows the Display Effect of the default color ing table:
Figure 2.3 color scale in draw test harness
3. TCL Test
Opencascade's draw test harness Environment Based on Tcl/tk makes it easy to test some ideas. Now a complete cloud map is displayed in draw test harness, as shown in:
Figure 3.1 color scale in draw test harness
The TCL script code is as follows:
## Copyright (c) 2014 eryar All Rights Reserved.## File : colorscale.tcl# Author : [email protected]# Date : 2014-09-20 18:10# Version : 1.0v## Description : Demonstrate the usage of OpenCASCADE color scale.#pload ALLmeshfromstl m data/stl/head.stlmeshcolors m nodaltex 0# show the color sacle.vcolorscalevfit
First load all the required modules, and then load the grid model from head. STL. After the mesh vertex color is set, use the vcolorscale command to develop a color ing table.
4. Code Analysis
Find the corresponding C ++ implementation code based on the Tcl command:
//=============================================================================//function : VColorScale//purpose : representation color scale//=============================================================================#include <V3d_ColorScale.hxx>static int VColorScale (Draw_Interpretor& di, Standard_Integer argc, const char ** argv){ if ( argc != 1 && argc != 4 && argc != 5 && argc != 6 && argc != 8 ) { di << "Usage : " << argv[0] << " [RangeMin = 0 RangeMax = 100 Intervals = 10 HeightFont = 16 Position = Right X = 0 Y = 0] " << "\n"; return 1; } Handle(AIS_InteractiveContext) aContext = ViewerTest::GetAISContext(); if(aContext.IsNull()) { di << argv[0] << " ERROR : use ‘vinit‘ command before " << "\n"; return -1; } Standard_Real minRange = 0. , maxRange = 100. ; Standard_Integer numIntervals = 10 ; Standard_Integer textHeight = 16; Aspect_TypeOfColorScalePosition position = Aspect_TOCSP_RIGHT; Standard_Real X = 0., Y = 0. ; if ( argc < 9 ) { if( argc > 3 ) { minRange = Draw::Atof( argv[1] ); maxRange = Draw::Atof( argv[2] ); numIntervals = Draw::Atoi( argv[3] ); } if ( argc > 4 ) textHeight = Draw::Atoi( argv[4] ); if ( argc > 5 ) position = (Aspect_TypeOfColorScalePosition)Draw::Atoi( argv[5] ); if ( argc > 7 ) { X = Draw::Atof( argv[6] ); Y = Draw::Atof( argv[7] ); } } Handle(V3d_View) curView = ViewerTest::CurrentView( ); if ( curView.IsNull( ) ) return 1; Handle(Aspect_ColorScale) aCSV = curView->ColorScale( ); Handle(V3d_ColorScale) aCS = ( Handle( V3d_ColorScale )::DownCast( aCSV ) ); if( ! aCS.IsNull( ) ) { aCS->SetPosition( X , Y ); aCS->SetHeight( 0.95) ; aCS->SetTextHeight( textHeight ); aCS->SetRange( minRange , maxRange ); aCS->SetNumberOfIntervals( numIntervals ); aCS->SetLabelPosition( position ); if( !curView->ColorScaleIsDisplayed() ) curView->ColorScaleDisplay( ); } return 0;}
The above Code shows that the color ing table mainly sets the aspect_colorscale in the current view. The display color ing table is mainly implemented by the v3d_colorscale class. After obtaining the color table object of the current view, you can call colorscaledisplay () of the view to display it by setting relevant parameters.
Based on the implementation code in the above draw test harness, you can easily implement related functions in your own program.
5. Conclusion
The opencascade view also provides the display color ing table function. By setting v3d_colorscale parameters of the view, you can display the color ing table.
6. References
1. Wang chengen. grid division and Visualization Technology for scientific computing. Science Press. 2011
Pdf version and Tcl Script: opencascade color scale
Opencascade color scale