------------------------------------------------------------------------------
| 818 | |
| 819 | //------------------------------------------------------------------------------ |
| 820 | void vtkOSPRayPolyDataMapperNode::ORenderPoly(void* renderer, vtkOSPRayActorNode* aNode, |
| 821 | vtkPolyData* poly, double* ambientColor, double* diffuseColor, double opacity, |
| 822 | std::string materialName) |
| 823 | { |
| 824 | vtkOSPRayRendererNode* orn = |
| 825 | static_cast<vtkOSPRayRendererNode*>(this->GetFirstAncestorOfType("vtkOSPRayRendererNode")); |
| 826 | RTW::Backend* backend = orn->GetBackend(); |
| 827 | if (backend == nullptr) |
| 828 | return; |
| 829 | |
| 830 | OSPRenderer oRenderer = static_cast<OSPRenderer>(renderer); |
| 831 | vtkActor* act = vtkActor::SafeDownCast(aNode->GetRenderable()); |
| 832 | vtkProperty* property = act->GetProperty(); |
| 833 | |
| 834 | // get texture transform |
| 835 | osp::vec4f texTransform{ 1.f, 0.f, 0.f, 1.f }; |
| 836 | vtkInformation* info = act->GetPropertyKeys(); |
| 837 | if (info && info->Has(vtkProp::GENERAL_TEXTURE_TRANSFORM())) |
| 838 | { |
| 839 | double* mat = info->Get(vtkProp::GENERAL_TEXTURE_TRANSFORM()); |
| 840 | texTransform.x = mat[0]; |
| 841 | texTransform.y = mat[1]; |
| 842 | texTransform.z = mat[4]; |
| 843 | texTransform.w = mat[5]; |
| 844 | } |
| 845 | |
| 846 | // make geometry |
| 847 | std::vector<double> _vertices; |
| 848 | vtkPolyDataMapperNode::TransformPoints(act, poly, _vertices); |
| 849 | size_t numPositions = _vertices.size() / 3; |
| 850 | if (numPositions == 0) |
| 851 | { |
| 852 | return; |
| 853 | } |
| 854 | std::vector<osp::vec3f> vertices(numPositions); |
| 855 | for (size_t i = 0; i < numPositions; i++) |
| 856 | { |
| 857 | vertices[i] = osp::vec3f{ static_cast<float>(_vertices[i * 3 + 0]), |
| 858 | static_cast<float>(_vertices[i * 3 + 1]), static_cast<float>(_vertices[i * 3 + 2]) }; |
| 859 | } |
| 860 | OSPData position = ospNewCopyData1D(&vertices[0], OSP_VEC3F, numPositions); |
| 861 | ospCommit(position); |
| 862 | _vertices.clear(); |
| 863 | |
| 864 | // make connectivity |
| 865 | vtkPolyDataMapperNode::vtkPDConnectivity conn; |
| 866 | vtkPolyDataMapperNode::MakeConnectivity(poly, property->GetRepresentation(), conn); |
| 867 | |
| 868 | // choosing sphere and cylinder radii (for points and lines) that |
| 869 | // approximate pointsize and linewidth |
| 870 | vtkMapper* mapper = act->GetMapper(); |
| 871 | double length = 1.0; |
| 872 | if (mapper) |
| 873 | { |
| 874 | length = mapper->GetLength(); |
| 875 | } |
| 876 | int scalingMode = vtkOSPRayActorNode::GetEnableScaling(act); |
| 877 | double pointSize = length / 1000.0 * property->GetPointSize(); |
no test coverage detected