Changeset 2270 for trunk/packages
- Timestamp:
- Jun 5, 2011, 1:26:07 PM (13 years ago)
- Location:
- trunk/packages/vizservers/vtkvis
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/RpContour2D.cpp
r2269 r2270 114 114 _contourFilter = vtkSmartPointer<vtkContourFilter>::New(); 115 115 } 116 117 vtkSmartPointer<vtkCellDataToPointData> cellToPtData;118 116 119 117 if (ds->GetPointData() == NULL || 120 118 ds->GetPointData()->GetScalars() == NULL) { 121 ERROR("No scalar point data in dataset %s", _dataSet->getName().c_str());119 WARN("No scalar point data in dataset %s", _dataSet->getName().c_str()); 122 120 if (ds->GetCellData() != NULL && 123 121 ds->GetCellData()->GetScalars() != NULL) { 122 vtkSmartPointer<vtkCellDataToPointData> cellToPtData; 124 123 cellToPtData = 125 124 vtkSmartPointer<vtkCellDataToPointData>::New(); 126 125 cellToPtData->SetInput(ds); 126 //cellToPtData->PassCellDataOn(); 127 cellToPtData->Update(); 127 128 ds = cellToPtData->GetOutput(); 128 129 } else { … … 141 142 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 142 143 mesher->SetInput(pd); 143 pd = mesher->GetOutput(); 144 assert(pd); 145 _contourFilter->SetInput(pd); 144 _contourFilter->SetInputConnection(mesher->GetOutputPort()); 146 145 } else { 147 146 vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New(); 148 147 mesher->SetInput(pd); 149 148 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 150 gf->SetInput(mesher->GetOutput()); 151 gf->Update(); 152 pd = gf->GetOutput(); 153 assert(pd); 154 _contourFilter->SetInput(pd); 155 } 149 gf->SetInputConnection(mesher->GetOutputPort()); 150 _contourFilter->SetInputConnection(gf->GetOutputPort()); 151 } 156 152 } else { 157 153 // DataSet is a vtkPolyData with lines and/or polygons … … 163 159 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 164 160 gf->SetInput(ds); 165 gf->Update(); 166 pd = gf->GetOutput(); 167 assert(pd); 168 _contourFilter->SetInput(pd); 161 _contourFilter->SetInputConnection(gf->GetOutputPort()); 169 162 } 170 163 … … 193 186 _contourMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 194 187 _contourMapper->SetResolveCoincidentTopologyToPolygonOffset(); 195 _contourMapper->SetInput (_contourFilter->GetOutput());188 _contourMapper->SetInputConnection(_contourFilter->GetOutputPort()); 196 189 _contourActor->SetMapper(_contourMapper); 197 190 } 191 192 _contourMapper->Update(); 198 193 } 199 194 -
trunk/packages/vizservers/vtkvis/RpGlyphs.cpp
r2269 r2270 147 147 setGlyphShape(_glyphShape); 148 148 149 vtkSmartPointer<vtkCellDataToPointData> cellToPtData;150 151 149 if (ds->GetPointData() == NULL || 152 150 ds->GetPointData()->GetScalars() == NULL) { 153 ERROR("No scalar point data in dataset %s", _dataSet->getName().c_str());151 WARN("No scalar point data in dataset %s", _dataSet->getName().c_str()); 154 152 if (ds->GetCellData() != NULL && 155 153 ds->GetCellData()->GetScalars() != NULL) { 154 vtkSmartPointer<vtkCellDataToPointData> cellToPtData; 156 155 cellToPtData = 157 156 vtkSmartPointer<vtkCellDataToPointData>::New(); 158 157 cellToPtData->SetInput(ds); 158 //cellToPtData->PassCellDataOn(); 159 cellToPtData->Update(); 159 160 ds = cellToPtData->GetOutput(); 160 161 } else { … … 183 184 } 184 185 185 _pdMapper->SetInput (_glyphGenerator->GetOutput());186 _pdMapper->SetInputConnection(_glyphGenerator->GetOutputPort()); 186 187 187 188 if (ds->GetPointData() == NULL || … … 209 210 210 211 _prop->SetMapper(_pdMapper); 212 _pdMapper->Update(); 211 213 } 212 214 -
trunk/packages/vizservers/vtkvis/RpHeightMap.cpp
r2269 r2270 40 40 _contourEdgeWidth(1.0), 41 41 _opacity(1.0), 42 _warpScale(1.0) 42 _warpScale(1.0), 43 _pipelineInitialized(false) 43 44 { 44 45 _dataRange[0] = 0.0; … … 113 114 } 114 115 115 if (_transformedData == NULL) { 116 vtkSmartPointer<vtkCellDataToPointData> cellToPtData; 117 116 if (!_pipelineInitialized) { 118 117 if (ds->GetPointData() == NULL || 119 118 ds->GetPointData()->GetScalars() == NULL) { 120 ERROR("No scalar point data in dataset %s", _dataSet->getName().c_str());119 WARN("No scalar point data in dataset %s", _dataSet->getName().c_str()); 121 120 if (ds->GetCellData() != NULL && 122 121 ds->GetCellData()->GetScalars() != NULL) { 122 vtkSmartPointer<vtkCellDataToPointData> cellToPtData; 123 123 cellToPtData = 124 124 vtkSmartPointer<vtkCellDataToPointData>::New(); 125 125 cellToPtData->SetInput(ds); 126 //cellToPtData->PassCellDataOn(); 127 cellToPtData->Update(); 126 128 ds = cellToPtData->GetOutput(); 127 129 } else { 128 130 ERROR("No scalar cell data in dataset %s", _dataSet->getName().c_str()); 131 return; 129 132 } 130 133 } … … 141 144 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 142 145 mesher->SetInput(pd); 143 pd = mesher->GetOutput(); 144 assert(pd); 146 vtkAlgorithmOutput *warpOutput = initWarp(mesher->GetOutputPort()); 147 _dsMapper->SetInputConnection(warpOutput); 148 _contourFilter->SetInputConnection(warpOutput); 145 149 #else 146 150 if (_pointSplatter == NULL) … … 161 165 if (_volumeSlicer == NULL) 162 166 _volumeSlicer = vtkSmartPointer<vtkExtractVOI>::New(); 163 _volumeSlicer->SetInput (_pointSplatter->GetOutput());167 _volumeSlicer->SetInputConnection(_pointSplatter->GetOutputPort()); 164 168 _volumeSlicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, 1, 1); 165 169 _volumeSlicer->SetSampleRate(1, 1, 1); 166 170 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 167 gf->SetInput(_volumeSlicer->GetOutput()); 168 gf->Update(); 169 pd = gf->GetOutput(); 171 gf->SetInputConnection(_volumeSlicer->GetOutputPort()); 172 vtkAlgorithmOutput *warpOutput = initWarp(gf->GetOutputPort()); 173 _dsMapper->SetInputConnection(warpOutput); 174 _contourFilter->SetInputConnection(warpOutput); 170 175 #endif 171 pd = initWarp(pd);172 assert(pd);173 _transformedData = pd;174 176 } else { 175 177 #ifdef MESH_POINTS … … 177 179 mesher->SetInput(pd); 178 180 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 179 gf->SetInput (mesher->GetOutput());181 gf->SetInputConnection(mesher->GetOutputPort()); 180 182 #else 181 183 if (_pointSplatter == NULL) … … 196 198 if (_volumeSlicer == NULL) 197 199 _volumeSlicer = vtkSmartPointer<vtkExtractVOI>::New(); 198 _volumeSlicer->SetInput (_pointSplatter->GetOutput());200 _volumeSlicer->SetInputConnection(_pointSplatter->GetOutputPort()); 199 201 _volumeSlicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, 1, 1); 200 202 _volumeSlicer->SetSampleRate(1, 1, 1); 201 203 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 202 gf->SetInput (_volumeSlicer->GetOutput());204 gf->SetInputConnection(_volumeSlicer->GetOutputPort()); 203 205 #endif 204 gf->Update(); 205 pd = gf->GetOutput(); 206 assert(pd); 207 pd = initWarp(pd); 208 assert(pd); 209 _transformedData = pd; 206 vtkAlgorithmOutput *warpOutput = initWarp(gf->GetOutputPort()); 207 _dsMapper->SetInputConnection(warpOutput); 208 _contourFilter->SetInputConnection(warpOutput); 210 209 } 211 210 } else { 212 211 // DataSet is a vtkPolyData with lines and/or polygons 213 pd = initWarp(pd); 214 assert(pd); 215 _transformedData = pd; 212 vtkAlgorithmOutput *warpOutput = initWarp(pd); 213 if (warpOutput != NULL) { 214 _dsMapper->SetInputConnection(warpOutput); 215 _contourFilter->SetInputConnection(warpOutput); 216 } else { 217 _dsMapper->SetInput(pd); 218 _contourFilter->SetInput(pd); 219 } 216 220 } 217 221 } else { … … 230 234 _volumeSlicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, (dims[2]-1)/2, (dims[2]-1)/2); 231 235 _volumeSlicer->SetSampleRate(1, 1, 1); 232 gf->SetInput (_volumeSlicer->GetOutput());236 gf->SetInputConnection(_volumeSlicer->GetOutputPort()); 233 237 } else { 234 238 // 2D image data, structured grid, unstructured grid, or rectilinear grid 235 239 gf->SetInput(ds); 236 240 } 237 gf->Update(); 238 pd = gf->GetOutput(); 239 assert(pd); 240 pd = initWarp(pd); 241 assert(pd); 242 _transformedData = pd; 241 vtkAlgorithmOutput *warpOutput = initWarp(gf->GetOutputPort()); 242 _dsMapper->SetInputConnection(warpOutput); 243 _contourFilter->SetInputConnection(warpOutput); 243 244 } 244 245 } 245 246 246 _dsMapper->SetInput(_transformedData); 247 _contourFilter->SetInput(_transformedData); 248 249 _dsMapper->StaticOn(); 247 _pipelineInitialized = true; 250 248 251 249 if (ds->GetPointData() == NULL || … … 299 297 _contourMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 300 298 _contourMapper->SetResolveCoincidentTopologyToPolygonOffset(); 301 _contourMapper->SetInput (_contourFilter->GetOutput());299 _contourMapper->SetInputConnection(_contourFilter->GetOutputPort()); 302 300 _contourActor->SetMapper(_contourMapper); 303 301 } … … 310 308 _props->AddPart(_contourActor); 311 309 } 310 311 _dsMapper->Update(); 312 _contourMapper->Update(); 313 } 314 315 vtkAlgorithmOutput *HeightMap::initWarp(vtkAlgorithmOutput *input) 316 { 317 TRACE("Warp scale: %g", _warpScale); 318 if (_warpScale == 0.0) { 319 _warp = NULL; 320 return input; 321 } else if (input == NULL) { 322 ERROR("NULL input"); 323 return input; 324 } else { 325 if (_warp == NULL) 326 _warp = vtkSmartPointer<vtkWarpScalar>::New(); 327 _warp->SetNormal(0, 0, 1); 328 _warp->UseNormalOn(); 329 _warp->SetScaleFactor(_warpScale); 330 _warp->SetInputConnection(input); 331 return _warp->GetOutputPort(); 332 } 333 } 334 335 vtkAlgorithmOutput *HeightMap::initWarp(vtkPolyData *pdInput) 336 { 337 TRACE("Warp scale: %g", _warpScale); 338 if (_warpScale == 0.0) { 339 _warp = NULL; 340 return NULL; 341 } else if (pdInput == NULL) { 342 ERROR("NULL input"); 343 return NULL; 344 } else { 345 if (_warp == NULL) 346 _warp = vtkSmartPointer<vtkWarpScalar>::New(); 347 _warp->SetNormal(0, 0, 1); 348 _warp->UseNormalOn(); 349 _warp->SetScaleFactor(_warpScale); 350 _warp->SetInput(pdInput); 351 return _warp->GetOutputPort(); 352 } 312 353 } 313 354 314 355 void HeightMap::setHeightScale(double scale) 315 356 { 357 if (_warpScale == scale) 358 return; 359 316 360 _warpScale = scale; 317 if (_warp != NULL) { 318 _warp->SetScaleFactor(scale); 319 _warp->Update(); 320 } 361 if (_warp == NULL) { 362 vtkAlgorithmOutput *warpOutput = initWarp(_dsMapper->GetInputConnection(0, 0)); 363 _dsMapper->SetInputConnection(warpOutput); 364 _contourFilter->SetInputConnection(warpOutput); 365 } else if (scale == 0.0) { 366 vtkAlgorithmOutput *warpInput = _warp->GetInputConnection(0, 0); 367 _dsMapper->SetInputConnection(warpInput); 368 _contourFilter->SetInputConnection(warpInput); 369 _warp = NULL; 370 } else { 371 _warp->SetScaleFactor(_warpScale); 372 } 373 374 if (_dsMapper != NULL) 375 _dsMapper->Update(); 376 if (_contourMapper != NULL) 377 _contourMapper->Update(); 321 378 } 322 379 … … 379 436 380 437 _volumeSlicer->SetVOI(voi[0], voi[1], voi[2], voi[3], voi[4], voi[5]); 381 _warp->Update(); 382 } 383 384 vtkPolyData *HeightMap::initWarp(vtkPolyData *input) 385 { 386 TRACE("Warp scale: %g", _warpScale); 387 if (_warpScale == 0.0) { 388 _warp = NULL; 389 return input; 390 } else if (input == NULL) { 391 ERROR("NULL input"); 392 return input; 393 } else if (input->GetPointData() != NULL && 394 input->GetPointData()->GetScalars() != NULL) { 395 if (_warp == NULL) 396 _warp = vtkSmartPointer<vtkWarpScalar>::New(); 397 _warp->SetNormal(0, 0, 1); 398 _warp->UseNormalOn(); 399 _warp->SetScaleFactor(_warpScale); 400 _warp->SetInput(input); 401 _warp->Update(); 402 return _warp->GetPolyDataOutput(); 403 } else { 404 ERROR("No scalar data for input"); 405 return input; 406 } 438 if (_dsMapper != NULL) 439 _dsMapper->Update(); 440 if (_contourMapper != NULL) 441 _contourMapper->Update(); 407 442 } 408 443 … … 651 686 void HeightMap::setClippingPlanes(vtkPlaneCollection *planes) 652 687 { 653 TRACE("planes: %p", planes);654 688 if (_dsMapper != NULL) { 655 689 _dsMapper->SetClippingPlanes(planes); -
trunk/packages/vizservers/vtkvis/RpHeightMap.h
r2261 r2270 10 10 11 11 #include <vtkSmartPointer.h> 12 #include <vtkAlgorithmOutput.h> 12 13 #include <vtkContourFilter.h> 13 14 #include <vtkLookupTable.h> … … 89 90 90 91 private: 91 vtkPolyData *initWarp(vtkPolyData *input); 92 vtkAlgorithmOutput *initWarp(vtkAlgorithmOutput *input); 93 vtkAlgorithmOutput *initWarp(vtkPolyData *input); 92 94 void initProp(); 93 95 void update(); … … 105 107 double _opacity; 106 108 double _warpScale; 109 bool _pipelineInitialized; 107 110 108 vtkSmartPointer<vtkPolyData> _transformedData;109 111 vtkSmartPointer<vtkLookupTable> _lut; 110 112 vtkSmartPointer<vtkDataSetMapper> _dsMapper; -
trunk/packages/vizservers/vtkvis/RpPolyData.cpp
r2264 r2270 107 107 _pdMapper->ScalarVisibilityOff(); 108 108 } 109 110 initProp();111 _pdActor->SetMapper(_pdMapper);112 109 113 110 vtkDataSet *ds = _dataSet->getVtkDataSet(); … … 127 124 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 128 125 mesher->SetInput(pd); 129 _pdMapper->SetInput(mesher->GetOutput()); 126 #if defined(DEBUG) && defined(WANT_TRACE) 127 mesher->Update(); 128 vtkPolyData *outpd = mesher->GetOutput(); 129 TRACE("Delaunay2D Verts: %d Lines: %d Polys: %d Strips: %d", 130 outpd->GetNumberOfVerts(), 131 outpd->GetNumberOfLines(), 132 outpd->GetNumberOfPolys(), 133 outpd->GetNumberOfStrips()); 134 #endif 135 _pdMapper->SetInputConnection(mesher->GetOutputPort()); 130 136 } else { 131 137 vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New(); … … 134 140 // to get the grid boundary as a PolyData 135 141 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 136 gf->SetInput(mesher->GetOutput()); 137 gf->Update(); 138 pd = gf->GetOutput(); 139 assert(pd); 140 _pdMapper->SetInput(pd); 142 gf->SetInputConnection(mesher->GetOutputPort()); 143 _pdMapper->SetInputConnection(gf->GetOutputPort()); 141 144 } 142 145 } else { 143 146 // DataSet is a vtkPolyData with lines and/or polygons 144 147 _pdMapper->SetInput(pd); 145 _pdMapper->StaticOn();146 148 } 147 149 } else { … … 150 152 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 151 153 gf->SetInput(ds); 152 gf->Update(); 153 pd = gf->GetOutput(); 154 assert(pd); 155 _pdMapper->SetInput(pd); 156 } 154 _pdMapper->SetInputConnection(gf->GetOutputPort()); 155 } 156 157 initProp(); 158 _pdActor->SetMapper(_pdMapper); 159 _pdMapper->Update(); 157 160 } 158 161 -
trunk/packages/vizservers/vtkvis/RpPseudoColor.cpp
r2269 r2270 96 96 vtkSmartPointer<vtkDelaunay2D> mesher = vtkSmartPointer<vtkDelaunay2D>::New(); 97 97 mesher->SetInput(pd); 98 pd = mesher->GetOutput();98 _dsMapper->SetInputConnection(mesher->GetOutputPort()); 99 99 #else 100 100 vtkSmartPointer<vtkGaussianSplatter> splatter = vtkSmartPointer<vtkGaussianSplatter>::New(); … … 113 113 bounds[4], bounds[5]); 114 114 vtkSmartPointer<vtkExtractVOI> slicer = vtkSmartPointer<vtkExtractVOI>::New(); 115 slicer->SetInput (splatter->GetOutput());115 slicer->SetInputConnection(splatter->GetOutputPort()); 116 116 slicer->SetVOI(0, dims[0]-1, 0, dims[1]-1, 1, 1); 117 117 slicer->SetSampleRate(1, 1, 1); 118 118 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 119 gf->SetInput(slicer->GetOutput()); 120 gf->Update(); 121 pd = gf->GetOutput(); 119 gf->SetInputConnection(slicer->GetOutputPort()); 120 _dsMapper->SetInputConnection(gf->GetOutputPort()); 122 121 #endif 123 assert(pd);124 _dsMapper->SetInput(pd);125 122 } else { 126 123 vtkSmartPointer<vtkDelaunay3D> mesher = vtkSmartPointer<vtkDelaunay3D>::New(); 127 124 mesher->SetInput(pd); 128 125 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 129 gf->SetInput(mesher->GetOutput()); 130 gf->Update(); 131 pd = gf->GetOutput(); 132 assert(pd); 133 _dsMapper->SetInput(pd); 126 gf->SetInputConnection(mesher->GetOutputPort()); 127 _dsMapper->SetInputConnection(gf->GetOutputPort()); 134 128 } 135 129 } else { … … 142 136 vtkSmartPointer<vtkDataSetSurfaceFilter> gf = vtkSmartPointer<vtkDataSetSurfaceFilter>::New(); 143 137 gf->SetInput(ds); 144 gf->Update(); 145 pd = gf->GetOutput(); 146 assert(pd); 147 _dsMapper->SetInput(pd); 148 } 149 150 //_dsMapper->StaticOn(); 138 _dsMapper->SetInputConnection(gf->GetOutputPort()); 139 } 151 140 152 141 if (ds->GetPointData() == NULL || … … 175 164 initProp(); 176 165 _dsActor->SetMapper(_dsMapper); 166 _dsMapper->Update(); 177 167 } 178 168 -
trunk/packages/vizservers/vtkvis/RpVolume.cpp
r2261 r2270 106 106 filter->SetInput(ugrid); 107 107 filter->TetrahedraOnlyOn(); 108 filter->Update(); 109 _volumeMapper->SetInput(filter->GetOutput()); 108 _volumeMapper->SetInputConnection(filter->GetOutputPort()); 110 109 } 111 110 112 111 vtkUnstructuredGridVolumeMapper::SafeDownCast(_volumeMapper)-> 113 112 SetBlendModeToComposite(); … … 134 133 135 134 _volumeProp->SetMapper(_volumeMapper); 135 _volumeMapper->Update(); 136 136 } 137 137 -
trunk/packages/vizservers/vtkvis/RpVtkDataSet.cpp
r2263 r2270 8 8 #include <vtkCharArray.h> 9 9 #include <vtkDataSetReader.h> 10 #include <vtkDataSetMapper.h> 10 #include <vtkPolyData.h> 11 #include <vtkStructuredPoints.h> 12 #include <vtkStructuredGrid.h> 13 #include <vtkRectilinearGrid.h> 14 #include <vtkUnstructuredGrid.h> 11 15 #include <vtkProperty.h> 12 16 #include <vtkPointData.h> … … 61 65 { 62 66 vtkSmartPointer<vtkDataSetReader> reader = vtkSmartPointer<vtkDataSetReader>::New(); 67 68 #if defined(WANT_TRACE) && defined(DEBUG) 69 reader->DebugOn(); 70 #endif 71 63 72 reader->SetFileName(filename); 73 reader->ReadAllScalarsOn(); 74 reader->ReadAllVectorsOn(); 64 75 return setData(reader); 65 76 } … … 70 81 bool DataSet::setData(char *data, int nbytes) 71 82 { 83 TRACE("Entering"); 84 72 85 vtkSmartPointer<vtkDataSetReader> reader = vtkSmartPointer<vtkDataSetReader>::New(); 73 86 vtkSmartPointer<vtkCharArray> dataSetString = vtkSmartPointer<vtkCharArray>::New(); 87 88 #if defined(WANT_TRACE) && defined(DEBUG) 89 reader->DebugOn(); 90 dataSetString->DebugOn(); 91 #endif 74 92 75 93 dataSetString->SetArray(data, nbytes, 1); 76 94 reader->SetInputArray(dataSetString); 77 95 reader->ReadFromInputStringOn(); 78 return setData(reader); 96 reader->ReadAllScalarsOn(); 97 reader->ReadAllVectorsOn(); 98 99 bool status = setData(reader); 100 101 TRACE("Leaving"); 102 return status; 79 103 } 80 104 81 105 /** 82 106 * \brief Read dataset using supplied reader 107 * 108 * Pipeline information is removed from the resulting 109 * vtkDataSet, so that the reader and its data can be 110 * released 83 111 */ 84 112 bool DataSet::setData(vtkDataSetReader *reader) … … 86 114 // Force reading data set 87 115 reader->SetLookupTableName(""); 116 reader->Update(); 117 88 118 _dataSet = reader->GetOutput(); 89 _dataSet->Update(); 119 _dataSet->SetPipelineInformation(NULL); 120 90 121 _dataSet->GetScalarRange(_dataRange); 91 122 _dataSet->GetBounds(_bounds); … … 97 128 98 129 /** 99 * \brief Set dataset from existing vtkDataSet object 130 * \brief Set DataSet from existing vtkDataSet object 131 * 132 * Pipeline information is removed from the supplied vtkDataSet 100 133 */ 101 134 bool DataSet::setData(vtkDataSet *ds) 102 135 { 103 136 _dataSet = ds; 104 _dataSet-> Update();137 _dataSet->SetPipelineInformation(NULL); 105 138 _dataSet->GetScalarRange(_dataRange); 106 139 _dataSet->GetBounds(_bounds); … … 109 142 TRACE("Scalar Range: %.12e, %.12e", _dataRange[0], _dataRange[1]); 110 143 return true; 144 } 145 146 /** 147 * \brief Copy an existing vtkDataSet object 148 * 149 * Pipeline information is not copied from the supplied vtkDataSet 150 * into this DataSet, but pipeline information in the supplied 151 * vtkDataSet is not removed 152 */ 153 vtkDataSet *DataSet::copyData(vtkDataSet *ds) 154 { 155 if (vtkPolyData::SafeDownCast(ds) != NULL) { 156 _dataSet = vtkSmartPointer<vtkPolyData>::New(); 157 _dataSet->DeepCopy(vtkPolyData::SafeDownCast(ds)); 158 } else if (vtkStructuredPoints::SafeDownCast(ds) != NULL) { 159 _dataSet = vtkSmartPointer<vtkStructuredPoints>::New(); 160 _dataSet->DeepCopy(vtkStructuredPoints::SafeDownCast(ds)); 161 } else if (vtkStructuredGrid::SafeDownCast(ds) != NULL) { 162 _dataSet = vtkSmartPointer<vtkStructuredGrid>::New(); 163 _dataSet->DeepCopy(vtkStructuredGrid::SafeDownCast(ds)); 164 } else if (vtkRectilinearGrid::SafeDownCast(ds) != NULL) { 165 _dataSet = vtkSmartPointer<vtkRectilinearGrid>::New(); 166 _dataSet->DeepCopy(vtkRectilinearGrid::SafeDownCast(ds)); 167 } else if (vtkUnstructuredGrid::SafeDownCast(ds) != NULL) { 168 _dataSet = vtkSmartPointer<vtkUnstructuredGrid>::New(); 169 _dataSet->DeepCopy(vtkUnstructuredGrid::SafeDownCast(ds)); 170 } else { 171 ERROR("Unknown data type"); 172 return NULL; 173 } 174 _dataSet->GetScalarRange(_dataRange); 175 _dataSet->GetBounds(_bounds); 176 177 TRACE("DataSet class: %s", _dataSet->GetClassName()); 178 TRACE("Scalar Range: %.12e, %.12e", _dataRange[0], _dataRange[1]); 179 return _dataSet; 111 180 } 112 181 -
trunk/packages/vizservers/vtkvis/RpVtkDataSet.h
r2260 r2270 27 27 virtual ~DataSet(); 28 28 29 bool setDataFile(const char *filename); 30 29 31 bool setData(char *data, int nbytes); 32 33 bool setData(vtkDataSetReader *reader); 30 34 31 35 bool setData(vtkDataSet *ds); 32 36 33 bool setData(vtkDataSetReader *reader); 34 35 bool setDataFile(const char *filename); 37 vtkDataSet *copyData(vtkDataSet *ds); 36 38 37 39 bool is2D() const; -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r2269 r2270 66 66 _cumulativeDataRange[1] = 1.0; 67 67 // clipping planes to prevent overdrawing axes 68 _ clippingPlanes = vtkSmartPointer<vtkPlaneCollection>::New();68 _activeClipPlanes = vtkSmartPointer<vtkPlaneCollection>::New(); 69 69 // bottom 70 vtkSmartPointer<vtkPlane> plane0 = vtkSmartPointer<vtkPlane>::New(); 71 plane0->SetNormal(0, 1, 0); 72 plane0->SetOrigin(0, 0, 0); 73 _clippingPlanes->AddItem(plane0); 70 _clipPlanes[0] = vtkSmartPointer<vtkPlane>::New(); 71 _clipPlanes[0]->SetNormal(0, 1, 0); 72 _clipPlanes[0]->SetOrigin(0, 0, 0); 73 if (_cameraMode == IMAGE) 74 _activeClipPlanes->AddItem(_clipPlanes[0]); 74 75 // left 75 vtkSmartPointer<vtkPlane> plane1 = vtkSmartPointer<vtkPlane>::New(); 76 plane1->SetNormal(1, 0, 0); 77 plane1->SetOrigin(0, 0, 0); 78 _clippingPlanes->AddItem(plane1); 79 // top 80 vtkSmartPointer<vtkPlane> plane2 = vtkSmartPointer<vtkPlane>::New(); 81 plane2->SetNormal(0, -1, 0); 82 plane2->SetOrigin(0, 1, 0); 83 _clippingPlanes->AddItem(plane2); 76 _clipPlanes[1] = vtkSmartPointer<vtkPlane>::New(); 77 _clipPlanes[1]->SetNormal(1, 0, 0); 78 _clipPlanes[1]->SetOrigin(0, 0, 0); 79 if (_cameraMode == IMAGE) 80 _activeClipPlanes->AddItem(_clipPlanes[1]); 81 // top 82 _clipPlanes[2] = vtkSmartPointer<vtkPlane>::New(); 83 _clipPlanes[2]->SetNormal(0, -1, 0); 84 _clipPlanes[2]->SetOrigin(0, 1, 0); 85 if (_cameraMode == IMAGE) 86 _activeClipPlanes->AddItem(_clipPlanes[2]); 84 87 // right 85 vtkSmartPointer<vtkPlane> plane3 = vtkSmartPointer<vtkPlane>::New(); 86 plane3->SetNormal(-1, 0, 0); 87 plane3->SetOrigin(1, 0, 0); 88 _clippingPlanes->AddItem(plane3); 88 _clipPlanes[3] = vtkSmartPointer<vtkPlane>::New(); 89 _clipPlanes[3]->SetNormal(-1, 0, 0); 90 _clipPlanes[3]->SetOrigin(1, 0, 0); 91 if (_cameraMode == IMAGE) 92 _activeClipPlanes->AddItem(_clipPlanes[3]); 89 93 _renderer = vtkSmartPointer<vtkRenderer>::New(); 90 94 _renderer->LightFollowCameraOn(); … … 107 111 Renderer::~Renderer() 108 112 { 113 TRACE("Enter"); 114 TRACE("Deleting Contours"); 109 115 for (Contour2DHashmap::iterator itr = _contours.begin(); 110 116 itr != _contours.end(); ++itr) { … … 112 118 } 113 119 _contours.clear(); 120 TRACE("Deleting Glyphs"); 114 121 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 115 122 itr != _glyphs.end(); ++itr) { … … 117 124 } 118 125 _glyphs.clear(); 126 TRACE("Deleting HeightMaps"); 119 127 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 120 128 itr != _heightMaps.end(); ++itr) { … … 122 130 } 123 131 _heightMaps.clear(); 132 TRACE("Deleting PolyDatas"); 124 133 for (PolyDataHashmap::iterator itr = _polyDatas.begin(); 125 134 itr != _polyDatas.end(); ++itr) { … … 127 136 } 128 137 _polyDatas.clear(); 138 TRACE("Deleting PseudoColors"); 129 139 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 130 140 itr != _pseudoColors.end(); ++itr) { … … 132 142 } 133 143 _pseudoColors.clear(); 144 TRACE("Deleting Volumes"); 134 145 for (VolumeHashmap::iterator itr = _volumes.begin(); 135 146 itr != _volumes.end(); ++itr) { … … 137 148 } 138 149 _volumes.clear(); 150 TRACE("Deleting ColorMaps"); 139 151 // Delete color maps and data sets last in case references still 140 152 // exist … … 144 156 } 145 157 _colorMaps.clear(); 158 TRACE("Deleting DataSets"); 146 159 for (DataSetHashmap::iterator itr = _dataSets.begin(); 147 160 itr != _dataSets.end(); ++itr) { … … 149 162 } 150 163 _dataSets.clear(); 164 TRACE("Leave"); 151 165 } 152 166 … … 1238 1252 } while (doAll && ++itr != _dataSets.end()); 1239 1253 1254 if (_cameraMode == IMAGE) 1255 setCameraMode(PERSPECTIVE); 1240 1256 initCamera(); 1241 1257 … … 1496 1512 } while (doAll && ++itr != _dataSets.end()); 1497 1513 1514 if (_cameraMode == IMAGE) 1515 setCameraMode(PERSPECTIVE); 1498 1516 initCamera(); 1499 1517 … … 2810 2828 camera->ParallelProjectionOn(); 2811 2829 if (origMode == IMAGE) { 2812 resetCamera( false);2830 resetCamera(true); 2813 2831 } 2814 2832 break; … … 2818 2836 camera->ParallelProjectionOff(); 2819 2837 if (origMode == IMAGE) { 2820 resetCamera( false);2838 resetCamera(true); 2821 2839 } 2822 2840 break; … … 2833 2851 } 2834 2852 resetAxes(); 2853 2835 2854 _needsRedraw = true; 2836 2855 } … … 3214 3233 3215 3234 // bottom 3216 _clip pingPlanes->GetItem(0)->SetOrigin(0, _imgWorldOrigin[1], 0);3235 _clipPlanes[0]->SetOrigin(0, _imgWorldOrigin[1], 0); 3217 3236 // left 3218 _clip pingPlanes->GetItem(1)->SetOrigin(_imgWorldOrigin[0], 0, 0);3237 _clipPlanes[1]->SetOrigin(_imgWorldOrigin[0], 0, 0); 3219 3238 // top 3220 _clip pingPlanes->GetItem(2)->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0);3239 _clipPlanes[2]->SetOrigin(0, _imgWorldOrigin[1] + _imgWorldDims[1], 0); 3221 3240 // right 3222 _clip pingPlanes->GetItem(3)->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0);3241 _clipPlanes[3]->SetOrigin(_imgWorldOrigin[0] + _imgWorldDims[0], 0, 0); 3223 3242 3224 3243 _cubeAxesActor2D->SetBounds(_imgWorldOrigin[0], _imgWorldOrigin[0] + _imgWorldDims[0], … … 3689 3708 3690 3709 /** 3710 * \brief Set up clipping planes for image camera mode if needed 3711 */ 3712 void Renderer::setCameraClippingPlanes() 3713 { 3714 /* XXX: Note that there appears to be a bug with setting the 3715 * clipping plane collection to NULL in the VTK Mappers -- 3716 * the old clip planes are still applied. The workaround here 3717 * is to keep the PlaneCollection and add/remove the planes 3718 * to/from the PlaneCollection as needed. 3719 */ 3720 if (_cameraMode == IMAGE) { 3721 if (_activeClipPlanes->GetNumberOfItems() == 0) { 3722 for (int i = 0; i < 4; i++) 3723 _activeClipPlanes->AddItem(_clipPlanes[i]); 3724 } 3725 } else { 3726 if (_activeClipPlanes->GetNumberOfItems() > 0) 3727 _activeClipPlanes->RemoveAllItems(); 3728 } 3729 3730 /* Ensure all Mappers are using the PlaneCollection 3731 * This will not change the state or timestamp of 3732 * Mappers already using the PlaneCollection 3733 */ 3734 for (Contour2DHashmap::iterator itr = _contours.begin(); 3735 itr != _contours.end(); ++itr) { 3736 itr->second->setClippingPlanes(_activeClipPlanes); 3737 } 3738 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 3739 itr != _glyphs.end(); ++itr) { 3740 itr->second->setClippingPlanes(_activeClipPlanes); 3741 } 3742 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 3743 itr != _heightMaps.end(); ++itr) { 3744 itr->second->setClippingPlanes(_activeClipPlanes); 3745 } 3746 for (PolyDataHashmap::iterator itr = _polyDatas.begin(); 3747 itr != _polyDatas.end(); ++itr) { 3748 itr->second->setClippingPlanes(_activeClipPlanes); 3749 } 3750 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 3751 itr != _pseudoColors.end(); ++itr) { 3752 itr->second->setClippingPlanes(_activeClipPlanes); 3753 } 3754 for (VolumeHashmap::iterator itr = _volumes.begin(); 3755 itr != _volumes.end(); ++itr) { 3756 itr->second->setClippingPlanes(_activeClipPlanes); 3757 } 3758 } 3759 3760 /** 3691 3761 * \brief Cause the rendering to render a new image if needed 3692 3762 * … … 3697 3767 { 3698 3768 if (_needsRedraw) { 3699 if (_cameraMode == IMAGE) { 3700 for (Contour2DHashmap::iterator itr = _contours.begin(); 3701 itr != _contours.end(); ++itr) { 3702 itr->second->setClippingPlanes(_clippingPlanes); 3703 } 3704 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 3705 itr != _glyphs.end(); ++itr) { 3706 itr->second->setClippingPlanes(_clippingPlanes); 3707 } 3708 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 3709 itr != _heightMaps.end(); ++itr) { 3710 itr->second->setClippingPlanes(_clippingPlanes); 3711 } 3712 for (PolyDataHashmap::iterator itr = _polyDatas.begin(); 3713 itr != _polyDatas.end(); ++itr) { 3714 itr->second->setClippingPlanes(_clippingPlanes); 3715 } 3716 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 3717 itr != _pseudoColors.end(); ++itr) { 3718 itr->second->setClippingPlanes(_clippingPlanes); 3719 } 3720 for (VolumeHashmap::iterator itr = _volumes.begin(); 3721 itr != _volumes.end(); ++itr) { 3722 itr->second->setClippingPlanes(_clippingPlanes); 3723 } 3724 } else { 3725 for (Contour2DHashmap::iterator itr = _contours.begin(); 3726 itr != _contours.end(); ++itr) { 3727 itr->second->setClippingPlanes(NULL); 3728 } 3729 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 3730 itr != _glyphs.end(); ++itr) { 3731 itr->second->setClippingPlanes(NULL); 3732 } 3733 for (HeightMapHashmap::iterator itr = _heightMaps.begin(); 3734 itr != _heightMaps.end(); ++itr) { 3735 itr->second->setClippingPlanes(NULL); 3736 } 3737 for (PolyDataHashmap::iterator itr = _polyDatas.begin(); 3738 itr != _polyDatas.end(); ++itr) { 3739 itr->second->setClippingPlanes(NULL); 3740 } 3741 for (PseudoColorHashmap::iterator itr = _pseudoColors.begin(); 3742 itr != _pseudoColors.end(); ++itr) { 3743 itr->second->setClippingPlanes(NULL); 3744 } 3745 for (VolumeHashmap::iterator itr = _volumes.begin(); 3746 itr != _volumes.end(); ++itr) { 3747 itr->second->setClippingPlanes(NULL); 3748 } 3749 } 3769 setCameraClippingPlanes(); 3750 3770 _renderWindow->Render(); 3751 3771 _needsRedraw = false; -
trunk/packages/vizservers/vtkvis/RpVtkRenderer.h
r2269 r2270 357 357 void initAxes(); 358 358 void resetAxes(); 359 void setCameraClippingPlanes(); 359 360 360 361 bool _needsRedraw; … … 384 385 CameraMode _cameraMode; 385 386 386 vtkSmartPointer<vtkPlaneCollection> _clippingPlanes; 387 vtkSmartPointer<vtkPlane> _clipPlanes[4]; 388 vtkSmartPointer<vtkPlaneCollection> _activeClipPlanes; 387 389 vtkSmartPointer<vtkCubeAxesActor> _cubeAxesActor; // For 3D view 388 390 #ifdef USE_CUSTOM_AXES
Note: See TracChangeset
for help on using the changeset viewer.