------------------------------------------------------------------------------ create the cell scalar array adjusted for ogl Cells
| 3797 | //------------------------------------------------------------------------------ |
| 3798 | // create the cell scalar array adjusted for ogl Cells |
| 3799 | void vtkOpenGLPolyDataMapper::AppendCellTextures(vtkRenderer* /*ren*/, vtkActor*, |
| 3800 | vtkCellArray* prims[4], int representation, std::vector<unsigned char>& newColors, |
| 3801 | std::vector<float>& newNorms, vtkPolyData* poly, vtkOpenGLCellToVTKCellMap* ccmap) |
| 3802 | { |
| 3803 | vtkPoints* points = poly->GetPoints(); |
| 3804 | |
| 3805 | if (this->HaveCellScalars || this->HaveCellNormals) |
| 3806 | { |
| 3807 | ccmap->Update(prims, representation, points); |
| 3808 | |
| 3809 | if (this->HaveCellScalars) |
| 3810 | { |
| 3811 | int numComp = this->Colors->GetNumberOfComponents(); |
| 3812 | unsigned char* colorPtr = this->Colors->GetPointer(0); |
| 3813 | assert(numComp == 4); |
| 3814 | newColors.reserve(numComp * ccmap->GetSize()); |
| 3815 | // use a single color value? |
| 3816 | if (this->FieldDataTupleId > -1 && this->ScalarMode == VTK_SCALAR_MODE_USE_FIELD_DATA) |
| 3817 | { |
| 3818 | for (size_t i = 0; i < ccmap->GetSize(); i++) |
| 3819 | { |
| 3820 | for (int j = 0; j < numComp; j++) |
| 3821 | { |
| 3822 | newColors.push_back(colorPtr[this->FieldDataTupleId * numComp + j]); |
| 3823 | } |
| 3824 | } |
| 3825 | } |
| 3826 | else |
| 3827 | { |
| 3828 | for (size_t i = 0; i < ccmap->GetSize(); i++) |
| 3829 | { |
| 3830 | for (int j = 0; j < numComp; j++) |
| 3831 | { |
| 3832 | newColors.push_back(colorPtr[ccmap->GetValue(i) * numComp + j]); |
| 3833 | } |
| 3834 | } |
| 3835 | } |
| 3836 | } |
| 3837 | |
| 3838 | if (this->HaveCellNormals) |
| 3839 | { |
| 3840 | // create the cell scalar array adjusted for ogl Cells |
| 3841 | vtkDataArray* n = poly->GetCellData()->GetNormals(); |
| 3842 | // Allocate memory to allow for faster direct access methods instead of using push_back to |
| 3843 | // populate the array. |
| 3844 | size_t nnSize = newNorms.size(); // Composite mappers can already have values in the array |
| 3845 | newNorms.resize(nnSize + 4 * ccmap->GetSize(), 0.0f); |
| 3846 | for (size_t i = 0; i < ccmap->GetSize(); i++) |
| 3847 | { |
| 3848 | // RGB32F requires a later version of OpenGL than 3.2 |
| 3849 | // with 3.2 we know we have RGBA32F hence the extra value |
| 3850 | double* norms = n->GetTuple(ccmap->GetValue(i)); |
| 3851 | newNorms[nnSize + i * 4 + 0] = (norms[0]); |
| 3852 | newNorms[nnSize + i * 4 + 1] = (norms[1]); |
| 3853 | newNorms[nnSize + i * 4 + 2] = (norms[2]); |
| 3854 | /* newNorms[nnSize + i * 4 + 3] = (0); */ |
| 3855 | // Don't set the final value because it is already set faster by the vector resize above. |
| 3856 | } |
no test coverage detected