- Timestamp:
- Sep 21, 2011, 2:27:44 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/blt4/packages/vizservers/vtkvis/RpStreamlines.cpp
r2409 r2542 36 36 _lineType(LINES), 37 37 _colorMode(COLOR_BY_VECTOR_MAGNITUDE), 38 _seedVisible(true) 38 _colorMap(NULL), 39 _seedVisible(true), 40 _dataScale(1) 39 41 { 40 42 _faceCulling = true; … … 51 53 Streamlines::~Streamlines() 52 54 { 55 } 56 57 void Streamlines::setDataSet(DataSet *dataSet, 58 bool useCumulative, 59 double scalarRange[2], 60 double vectorMagnitudeRange[2], 61 double vectorComponentRange[3][2]) 62 { 63 if (_dataSet != dataSet) { 64 _dataSet = dataSet; 65 66 if (useCumulative) { 67 _dataRange[0] = scalarRange[0]; 68 _dataRange[1] = scalarRange[1]; 69 _vectorMagnitudeRange[0] = vectorMagnitudeRange[0]; 70 _vectorMagnitudeRange[1] = vectorMagnitudeRange[1]; 71 for (int i = 0; i < 3; i++) { 72 _vectorComponentRange[i][0] = vectorComponentRange[i][0]; 73 _vectorComponentRange[i][1] = vectorComponentRange[i][1]; 74 } 75 } else { 76 _dataSet->getScalarRange(_dataRange); 77 _dataSet->getVectorRange(_vectorMagnitudeRange); 78 for (int i = 0; i < 3; i++) { 79 _dataSet->getVectorRange(_vectorComponentRange[i], i); 80 } 81 } 82 83 update(); 84 } 53 85 } 54 86 … … 96 128 _seedActor->GetProperty()->SetRepresentationToWireframe(); 97 129 _seedActor->GetProperty()->LightingOff(); 130 setSeedVisibility(_seedVisible); 98 131 } 99 132 if (_prop == NULL) { … … 201 234 202 235 vtkDataSet *ds = _dataSet->getVtkDataSet(); 203 double dataRange[2]; 204 _dataSet->getVectorMagnitudeRange(dataRange); 236 205 237 double bounds[6]; 206 238 _dataSet->getBounds(bounds); … … 215 247 maxBound = bounds[5] - bounds[4]; 216 248 } 249 250 double cellSizeRange[2]; 251 double avgSize; 252 _dataSet->getCellSizeRange(cellSizeRange, &avgSize); 253 _dataScale = avgSize / 8.; 217 254 218 255 vtkSmartPointer<vtkCellDataToPointData> cellToPtData; … … 294 331 _seedActor->SetMapper(_seedMapper); 295 332 296 _lut = vtkSmartPointer<vtkLookupTable>::New(); 297 _lut->SetRange(dataRange); 298 _lut->SetVectorModeToMagnitude(); 299 300 _pdMapper->SetScalarModeToUsePointFieldData(); 301 if (ds->GetPointData() != NULL && 302 ds->GetPointData()->GetVectors() != NULL) { 303 TRACE("Vector name: '%s'", ds->GetPointData()->GetVectors()->GetName()); 304 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 305 } 306 _pdMapper->SetColorModeToMapScalars(); 307 _pdMapper->UseLookupTableScalarRangeOn(); 308 _pdMapper->SetLookupTable(_lut); 333 if (_lut == NULL) { 334 setColorMap(ColorMap::getDefault()); 335 } 336 337 setColorMode(_colorMode); 309 338 310 339 _linesActor->SetMapper(_pdMapper); … … 724 753 numSides = 3; 725 754 tubeFilter->SetNumberOfSides(numSides); 726 tubeFilter->SetRadius( radius);755 tubeFilter->SetRadius(_dataScale * radius); 727 756 _pdMapper->SetInputConnection(_lineFilter->GetOutputPort()); 728 757 if (_faceCulling && _opacity == 1.0) … … 749 778 } 750 779 vtkRibbonFilter *ribbonFilter = vtkRibbonFilter::SafeDownCast(_lineFilter); 751 ribbonFilter->SetWidth( width);780 ribbonFilter->SetWidth(_dataScale * width); 752 781 ribbonFilter->SetAngle(angle); 753 782 ribbonFilter->UseDefaultNormalOn(); … … 759 788 } 760 789 790 void Streamlines::updateRanges(bool useCumulative, 791 double scalarRange[2], 792 double vectorMagnitudeRange[2], 793 double vectorComponentRange[3][2]) 794 { 795 if (useCumulative) { 796 _dataRange[0] = scalarRange[0]; 797 _dataRange[1] = scalarRange[1]; 798 _vectorMagnitudeRange[0] = vectorMagnitudeRange[0]; 799 _vectorMagnitudeRange[1] = vectorMagnitudeRange[1]; 800 for (int i = 0; i < 3; i++) { 801 _vectorComponentRange[i][0] = vectorComponentRange[i][0]; 802 _vectorComponentRange[i][1] = vectorComponentRange[i][1]; 803 } 804 } else { 805 _dataSet->getScalarRange(_dataRange); 806 _dataSet->getVectorRange(_vectorMagnitudeRange); 807 for (int i = 0; i < 3; i++) { 808 _dataSet->getVectorRange(_vectorComponentRange[i], i); 809 } 810 } 811 812 // Need to update color map ranges and/or active vector field 813 setColorMode(_colorMode); 814 } 815 761 816 void Streamlines::setColorMode(ColorMode mode) 762 817 { … … 772 827 _pdMapper->SetScalarModeToDefault(); 773 828 if (_lut != NULL) { 774 double dataRange[2]; 775 _dataSet->getDataRange(dataRange); 776 _lut->SetRange(dataRange); 829 _lut->SetRange(_dataRange); 777 830 } 778 831 } … … 786 839 } 787 840 if (_lut != NULL) { 788 double dataRange[2]; 789 _dataSet->getVectorMagnitudeRange(dataRange); 790 TRACE("vmag range: %g %g", dataRange[0], dataRange[1]); 791 _lut->SetRange(dataRange); 841 _lut->SetRange(_vectorMagnitudeRange); 792 842 _lut->SetVectorModeToMagnitude(); 793 843 } … … 802 852 } 803 853 if (_lut != NULL) { 804 double dataRange[2]; 805 _dataSet->getVectorComponentRange(dataRange, 0); 806 _lut->SetRange(dataRange); 854 _lut->SetRange(_vectorComponentRange[0]); 807 855 _lut->SetVectorModeToComponent(); 808 856 _lut->SetVectorComponent(0); … … 817 865 } 818 866 if (_lut != NULL) { 819 double dataRange[2]; 820 _dataSet->getVectorComponentRange(dataRange, 1); 821 _lut->SetRange(dataRange); 867 _lut->SetRange(_vectorComponentRange[1]); 822 868 _lut->SetVectorModeToComponent(); 823 869 _lut->SetVectorComponent(1); … … 832 878 } 833 879 if (_lut != NULL) { 834 double dataRange[2]; 835 _dataSet->getVectorComponentRange(dataRange, 2); 836 TRACE("vz range: %g %g", dataRange[0], dataRange[1]); 837 _lut->SetRange(dataRange); 880 _lut->SetRange(_vectorComponentRange[2]); 838 881 _lut->SetVectorModeToComponent(); 839 882 _lut->SetVectorComponent(2); … … 848 891 849 892 /** 850 * \brief Get the VTK colormap lookup table in use851 */ 852 v tkLookupTable *Streamlines::getLookupTable()853 { 854 return _lut;893 * \brief Called when the color map has been edited 894 */ 895 void Streamlines::updateColorMap() 896 { 897 setColorMap(_colorMap); 855 898 } 856 899 … … 858 901 * \brief Associate a colormap lookup table with the DataSet 859 902 */ 860 void Streamlines::setLookupTable(vtkLookupTable *lut) 861 { 862 if (lut == NULL) { 903 void Streamlines::setColorMap(ColorMap *cmap) 904 { 905 if (cmap == NULL) 906 return; 907 908 _colorMap = cmap; 909 910 if (_lut == NULL) { 863 911 _lut = vtkSmartPointer<vtkLookupTable>::New(); 864 } else { 865 _lut = lut; 866 } 912 if (_pdMapper != NULL) { 913 _pdMapper->UseLookupTableScalarRangeOn(); 914 _pdMapper->SetLookupTable(_lut); 915 } 916 } 917 918 _lut->DeepCopy(cmap->getLookupTable()); 867 919 868 920 switch (_colorMode) { 869 case COLOR_BY_VECTOR_MAGNITUDE: { 870 double dataRange[2]; 871 _dataSet->getVectorMagnitudeRange(dataRange); 921 case COLOR_CONSTANT: 922 case COLOR_BY_SCALAR: 923 _lut->SetRange(_dataRange); 924 break; 925 case COLOR_BY_VECTOR_MAGNITUDE: 872 926 _lut->SetVectorModeToMagnitude(); 873 _lut->SetRange(dataRange); 874 } 875 break; 876 case COLOR_BY_VECTOR_X: { 877 double dataRange[2]; 878 _dataSet->getVectorComponentRange(dataRange, 0); 927 _lut->SetRange(_vectorMagnitudeRange); 928 break; 929 case COLOR_BY_VECTOR_X: 879 930 _lut->SetVectorModeToComponent(); 880 931 _lut->SetVectorComponent(0); 881 _lut->SetRange(dataRange); 882 } 883 break; 884 case COLOR_BY_VECTOR_Y: { 885 double dataRange[2]; 886 _dataSet->getVectorComponentRange(dataRange, 1); 932 _lut->SetRange(_vectorComponentRange[0]); 933 break; 934 case COLOR_BY_VECTOR_Y: 887 935 _lut->SetVectorModeToComponent(); 888 936 _lut->SetVectorComponent(1); 889 _lut->SetRange(dataRange); 890 } 891 break; 892 case COLOR_BY_VECTOR_Z: { 893 double dataRange[2]; 894 _dataSet->getVectorComponentRange(dataRange, 2); 937 _lut->SetRange(_vectorComponentRange[1]); 938 break; 939 case COLOR_BY_VECTOR_Z: 895 940 _lut->SetVectorModeToComponent(); 896 941 _lut->SetVectorComponent(2); 897 _lut->SetRange(dataRange); 898 } 942 _lut->SetRange(_vectorComponentRange[2]); 899 943 break; 900 944 default: 901 945 break; 902 }903 904 if (_pdMapper != NULL) {905 _pdMapper->SetLookupTable(_lut);906 946 } 907 947 }
Note: See TracChangeset
for help on using the changeset viewer.