@@ -469,6 +469,23 @@ namespace
469469 {
470470 return ((int )writeQuads << 2 ) | ((int )writeNormals << 1 ) | ((int )writeTexCoords);
471471 }
472+
473+ void spiltColorMapToTextureAndCoordinates (
474+ const boost::optional<boost::shared_ptr<ColorMap>>& colorMap,
475+ ColorMapHandle& textureMap, ColorMapHandle& coordinateMap)
476+ {
477+ ColorMapHandle realColorMap = nullptr ;
478+
479+ if (colorMap) realColorMap = colorMap.get ();
480+ else realColorMap = StandardColorMapFactory::create ();
481+
482+ textureMap = StandardColorMapFactory::create (realColorMap->getColorMapName (),
483+ realColorMap->getColorMapResolution (), realColorMap->getColorMapShift (),
484+ realColorMap->getColorMapInvert ());
485+
486+ coordinateMap = StandardColorMapFactory::create (" Grayscale" , 256 , 0 , false ,
487+ realColorMap->getColorMapRescaleScale (), realColorMap->getColorMapRescaleShift ());
488+ }
472489}
473490
474491
@@ -522,12 +539,9 @@ void GeometryBuilder::renderFacesLinear(
522539
523540 ColorScheme colorScheme = ColorScheme::COLOR_UNIFORM;
524541
525- ColorMapHandle realColorMap;
526- if (colorMap) realColorMap = colorMap.get ();
527- if (!realColorMap) realColorMap = StandardColorMapFactory::create ();
528542
529- auto coordinateMap = StandardColorMapFactory::create ( " Grayscale " , 256 , 0 , false ,
530- realColorMap-> getColorMapRescaleScale (), realColorMap-> getColorMapRescaleShift () );
543+ ColorMapHandle textureMap, coordinateMap;
544+ spiltColorMapToTextureAndCoordinates (colorMap, textureMap, coordinateMap );
531545
532546 if (useColorMap)
533547 {
@@ -773,18 +787,14 @@ void GeometryBuilder::renderFacesLinear(
773787 shader += " _ColorMap" ;
774788 attribs.push_back (SpireVBO::AttributeData (" aTexCoords" , 2 * sizeof (float )));
775789
776- auto map = StandardColorMapFactory::create (realColorMap->getColorMapName (),
777- realColorMap->getColorMapResolution (), realColorMap->getColorMapShift (),
778- realColorMap->getColorMapInvert ());
779-
780790 const static int colorMapResolution = 256 ;
781791 for (int i = 0 ; i < colorMapResolution; ++i)
782792 {
783- ColorRGB color = map ->valueToColor (static_cast <float >(i)/colorMapResolution * 2.0 - 1.0 );
784- texture.bitmap .push_back (color.r ()*255 );
785- texture.bitmap .push_back (color.g ()*255 );
786- texture.bitmap .push_back (color.b ()*255 );
787- texture.bitmap .push_back (255 );
793+ ColorRGB color = textureMap ->valueToColor (static_cast <float >(i)/colorMapResolution * 2.0 - 1.0 );
794+ texture.bitmap .push_back (color.r ()*255 . 99f );
795+ texture.bitmap .push_back (color.g ()*255 . 99f );
796+ texture.bitmap .push_back (color.b ()*255 . 99f );
797+ texture.bitmap .push_back (color. a ()* 255 . 99f );
788798 }
789799 texture.name = " ColorMap" ;
790800 texture.height = 1 ;
@@ -908,6 +918,7 @@ void GeometryBuilder::renderNodes(
908918}
909919
910920
921+
911922void GeometryBuilder::renderEdges (
912923 FieldHandle field,
913924 boost::optional<boost::shared_ptr<ColorMap>> colorMap,
@@ -926,12 +937,8 @@ void GeometryBuilder::renderEdges(
926937 ColorScheme colorScheme;
927938 ColorRGB edge_colors[2 ];
928939
929- ColorMapHandle realColorMap = nullptr ;
930- if (colorMap) realColorMap = colorMap.get ();
931- if (!realColorMap) realColorMap = StandardColorMapFactory::create ();
932-
933- auto coordinateMap = StandardColorMapFactory::create (" Grayscale" , 256 , 0 , false ,
934- realColorMap->getColorMapRescaleScale (), realColorMap->getColorMapRescaleShift ());
940+ ColorMapHandle textureMap, coordinateMap;
941+ spiltColorMapToTextureAndCoordinates (colorMap, textureMap, coordinateMap);
935942
936943 if (fld->basis_order () < 0 ||
937944 (fld->basis_order () == 0 && mesh->dimensionality () != 0 ) ||
@@ -1046,16 +1053,8 @@ void GeometryBuilder::renderEdges(
10461053 ++eiter;
10471054 }
10481055
1049- ColorMapHandle map = nullptr ;
1050- if (realColorMap)
1051- {
1052- map = StandardColorMapFactory::create (realColorMap->getColorMapName (),
1053- realColorMap->getColorMapResolution (), realColorMap->getColorMapShift (),
1054- realColorMap->getColorMapInvert ());
1055- }
1056-
10571056 glyphs.buildObject (*geom, uniqueNodeID, state.get (RenderState::USE_TRANSPARENT_EDGES), edgeTransparencyValue_,
1058- colorScheme, state, primIn, mesh->get_bounding_box (), true , map );
1057+ colorScheme, state, primIn, mesh->get_bounding_box (), true , textureMap );
10591058}
10601059
10611060void ShowField::updateAvailableRenderOptions (FieldHandle field)
0 commit comments