----------------------------------------------------------------------------
| 916 | |
| 917 | //---------------------------------------------------------------------------- |
| 918 | void vtkFastLabeledDataMapper::MakeShaderArrays(int numCurLabels, |
| 919 | const std::vector<std::string>& stringlist, vtkIntArray* typeArr, vtkFloatArray* fcolArr) |
| 920 | { |
| 921 | // make up arrays from to help place each character in each word |
| 922 | int pntcnt = 0; |
| 923 | for (int i = 0; i < numCurLabels; i++) // each word |
| 924 | { |
| 925 | const auto& wordString = stringlist[i]; |
| 926 | int wordsPropId = 0; |
| 927 | if (typeArr) |
| 928 | { |
| 929 | // todo assumes types are 0,1,2,... this isn't necessarily true |
| 930 | wordsPropId = typeArr->GetValue(i); |
| 931 | } |
| 932 | double fcolors[3] = { 0.0, 0.0, 0.0 }; |
| 933 | if (fcolArr) |
| 934 | { |
| 935 | // frame colors from point aligned array |
| 936 | fcolArr->GetTuple(i, fcolors); |
| 937 | } |
| 938 | else |
| 939 | { |
| 940 | // frame colors from TextProperty |
| 941 | this->Implementation->TextProperties[wordsPropId]->GetFrameColor(fcolors); |
| 942 | } |
| 943 | vtkTextProperty* prop = this->GetLabelTextProperty(wordsPropId); |
| 944 | if (!prop) |
| 945 | { |
| 946 | vtkErrorMacro("No text property available for type array entry '" << wordsPropId << "'."); |
| 947 | continue; |
| 948 | } |
| 949 | |
| 950 | double coffset = 0.0; |
| 951 | vtkIdType startpt = pntcnt; |
| 952 | for (std::size_t cidx = 0; cidx < wordString.size(); cidx++) // each char |
| 953 | { |
| 954 | std::string c = wordString.substr(cidx, 1); |
| 955 | WordRecord wrec = |
| 956 | this->Implementation->AllStrings.find(std::make_pair(c, wordsPropId))->second; |
| 957 | vtkImageData* wr = wrec.Texture; |
| 958 | int wordsextents[6]; |
| 959 | wr->GetExtent(wordsextents); |
| 960 | vtkIdType ptlist = pntcnt; |
| 961 | pntcnt++; |
| 962 | this->Implementation->InputPlusArrays->InsertNextCell(VTK_VERTEX, 1, &ptlist); |
| 963 | this->Implementation->PId->InsertNextValue(i); |
| 964 | this->Implementation->GlyphExtents->InsertNextTypedTuple(wordsextents); |
| 965 | this->Implementation->Coff->InsertNextValue(coffset); |
| 966 | float width = wordsextents[1] - wordsextents[0] + 1 - (2 * PADSZ); |
| 967 | coffset += width; |
| 968 | this->Implementation->PropId->InsertNextValue(wrec.PropId); |
| 969 | this->Implementation->Framecolors->InsertNextTuple3(fcolors[0], fcolors[1], fcolors[2]); |
| 970 | } |
| 971 | // align glyphs |
| 972 | if (this->TextAnchor == LowerLeft || this->TextAnchor == UpperLeft || |
| 973 | this->TextAnchor == LeftEdge) |
| 974 | { |
| 975 | coffset = 0.0; |
no test coverage detected