- Timestamp:
- Aug 2, 2014, 12:55:11 AM (10 years ago)
- Location:
- vtkvis/branches/1.7
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
vtkvis/branches/1.7
- Property svn:mergeinfo changed
/trunk/packages/vizservers/vtkvis merged: 4243
- Property svn:mergeinfo changed
-
vtkvis/branches/1.7/Volume.cpp
r3980 r4608 11 11 #include <vtkPointData.h> 12 12 #include <vtkImageData.h> 13 #include <vtkProbeFilter.h> 13 14 #include <vtkVolumeProperty.h> 14 15 #include <vtkGPUVolumeRayCastMapper.h> … … 32 33 Volume::Volume() : 33 34 GraphicsObject(), 35 _useUgridMapper(false), 34 36 _colorMap(NULL) 35 37 { … … 105 107 } 106 108 109 if (ds->GetPointData() == NULL || 110 ds->GetPointData()->GetScalars() == NULL) { 111 WARN("No scalar point data in dataset %s", _dataSet->getName().c_str()); 112 } 113 107 114 if (vtkImageData::SafeDownCast(ds) != NULL) { 108 115 // Image data required for these mappers … … 123 130 #endif 124 131 vtkVolumeMapper::SafeDownCast(_volumeMapper)->SetBlendModeToComposite(); 125 } else if (_dataSet->isCloud() || 126 vtkUnstructuredGrid::SafeDownCast(ds) == NULL) { 127 // DataSet is a 3D point cloud, rectilinear grid or structured grid 132 } else if (_dataSet->isCloud()) { 133 // DataSet is a 3D point cloud 128 134 vtkSmartPointer<vtkGaussianSplatter> splatter = vtkSmartPointer<vtkGaussianSplatter>::New(); 129 135 #ifdef USE_VTK6 … … 151 157 #endif 152 158 _volumeMapper->SetInputConnection(splatter->GetOutputPort()); 159 vtkVolumeMapper::SafeDownCast(_volumeMapper)->SetBlendModeToComposite(); 160 } else if (vtkUnstructuredGrid::SafeDownCast(ds) == NULL || !_useUgridMapper) { 161 // (Slow) Resample using ProbeFilter 162 double bounds[6]; 163 ds->GetBounds(bounds); 164 double xLen = bounds[1] - bounds[0]; 165 double yLen = bounds[3] - bounds[2]; 166 double zLen = bounds[5] - bounds[4]; 167 168 int dims[3]; 169 dims[0] = dims[1] = dims[2] = 64; 170 if (xLen == 0.0) dims[0] = 1; 171 if (yLen == 0.0) dims[1] = 1; 172 if (zLen == 0.0) dims[2] = 1; 173 if (vtkStructuredGrid::SafeDownCast(ds) != NULL) { 174 vtkStructuredGrid::SafeDownCast(ds)->GetDimensions(dims); 175 } else if (vtkRectilinearGrid::SafeDownCast(ds) != NULL) { 176 vtkRectilinearGrid::SafeDownCast(ds)->GetDimensions(dims); 177 } 178 TRACE("Generating volume with dims (%d,%d,%d) from %d points", 179 dims[0], dims[1], dims[2], ds->GetNumberOfPoints()); 180 181 double xSpacing = (dims[0] == 1 ? 0.0 : xLen/((double)(dims[0]-1))); 182 double ySpacing = (dims[1] == 1 ? 0.0 : yLen/((double)(dims[1]-1))); 183 double zSpacing = (dims[2] == 1 ? 0.0 : zLen/((double)(dims[2]-1))); 184 185 vtkSmartPointer<vtkImageData> imageData = vtkSmartPointer<vtkImageData>::New(); 186 imageData->SetDimensions(dims[0], dims[1], dims[2]); 187 imageData->SetOrigin(bounds[0], bounds[2], bounds[4]); 188 imageData->SetSpacing(xSpacing, ySpacing, zSpacing); 189 190 vtkSmartPointer<vtkProbeFilter> probe = vtkSmartPointer<vtkProbeFilter>::New(); 191 probe->SetInputData(imageData); 192 probe->SetSourceData(ds); 193 probe->Update(); 194 195 TRACE("Done generating volume"); 196 197 #ifdef USE_GPU_RAYCAST_MAPPER 198 _volumeMapper = vtkSmartPointer<vtkGPUVolumeRayCastMapper>::New(); 199 vtkGPUVolumeRayCastMapper::SafeDownCast(_volumeMapper)->AutoAdjustSampleDistancesOff(); 200 #else 201 _volumeMapper = vtkSmartPointer<vtkVolumeTextureMapper3D>::New(); 202 #endif 203 _volumeMapper->SetInputConnection(probe->GetOutputPort()); 153 204 vtkVolumeMapper::SafeDownCast(_volumeMapper)->SetBlendModeToComposite(); 154 205 } else { … … 191 242 192 243 initProp(); 193 194 if (ds->GetPointData() == NULL ||195 ds->GetPointData()->GetScalars() == NULL) {196 WARN("No scalar point data in dataset %s", _dataSet->getName().c_str());197 }198 244 199 245 if (_colorMap == NULL) { -
vtkvis/branches/1.7/Volume.h
r3961 r4608 67 67 virtual void update(); 68 68 69 bool _useUgridMapper; 70 69 71 ColorMap *_colorMap; 70 72 vtkSmartPointer<vtkAbstractVolumeMapper> _volumeMapper;
Note: See TracChangeset
for help on using the changeset viewer.