Changeset 2550
- Timestamp:
- Sep 21, 2011, 2:33:59 PM (13 years ago)
- Location:
- branches/blt4/packages/vizservers/vtkvis
- Files:
-
- 2 added
- 26 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/blt4/packages/vizservers/vtkvis/CmdProc.cpp
r2542 r2550 10 10 11 11 #include "CmdProc.h" 12 13 using namespace Rappture;14 12 15 13 /** … … 24 22 */ 25 23 static int 26 BinaryOpSearch( CmdSpec *specs,24 BinaryOpSearch(Rappture::CmdSpec *specs, 27 25 int nSpecs, 28 26 char *string) /* Name of minor operation to search for */ … … 37 35 length = strlen(string); 38 36 while (low <= high) { 39 CmdSpec *specPtr;37 Rappture::CmdSpec *specPtr; 40 38 int compare; 41 39 int median; … … 78 76 */ 79 77 static int 80 LinearOpSearch( CmdSpec *specs,78 LinearOpSearch(Rappture::CmdSpec *specs, 81 79 int nSpecs, 82 80 char *string) /* Name of minor operation to search for */ 83 81 { 84 CmdSpec *specPtr;82 Rappture::CmdSpec *specPtr; 85 83 char c; 86 84 size_t length; … … 122 120 */ 123 121 Tcl_ObjCmdProc * 124 Rappture::GetOpFromObj(Tcl_Interp *interp, /* Interpreter to report errors to */125 int nSpecs, /* Number of specifications in array */126 CmdSpec *specs,/* Op specification array */127 int operPos, /* Position of operation in argument128 * list. */129 int objc, /* Number of arguments in the argument130 * vector. This includes any prefixed131 * arguments */132 Tcl_Obj *const *objv, /* Argument vector */122 Rappture::GetOpFromObj(Tcl_Interp *interp, /* Interpreter to report errors to */ 123 int nSpecs, /* Number of specifications in array */ 124 Rappture::CmdSpec *specs, /* Op specification array */ 125 int operPos, /* Position of operation in argument 126 * list. */ 127 int objc, /* Number of arguments in the argument 128 * vector. This includes any prefixed 129 * arguments */ 130 Tcl_Obj *const *objv, /* Argument vector */ 133 131 int flags) 134 132 { -
branches/blt4/packages/vizservers/vtkvis/CmdProc.h
r2542 r2550 19 19 * for a function pointer associated with the operation name. 20 20 */ 21 struct CmdSpec{21 typedef struct { 22 22 const char *name; /**< Name of operation */ 23 23 int minChars; /**< Minimum # characters to disambiguate */ … … 26 26 int maxArgs; /**< Maximum # args required */ 27 27 const char *usage; /**< Usage message */ 28 } ;28 } CmdSpec; 29 29 30 enum CmdSpecIndex{30 typedef enum { 31 31 CMDSPEC_ARG0, /**< Op is the first argument. */ 32 32 CMDSPEC_ARG1, /**< Op is the second argument. */ … … 34 34 CMDSPEC_ARG3, /**< Op is the fourth argument. */ 35 35 CMDSPEC_ARG4 /**< Op is the fifth argument. */ 36 } ;36 } CmdSpecIndex; 37 37 38 38 #define CMDSPEC_LINEAR_SEARCH 1 -
branches/blt4/packages/vizservers/vtkvis/Makefile.in
r2542 r2550 47 47 DEBUG = #yes 48 48 TRACE = #yes 49 USE_CUSTOM_AXES = yes 50 USE_GPU_RAYCASTING = yes 51 USE_OFFSCREEN_RENDERING = yes 52 USE_THREADS = yes 49 USE_CUSTOM_AXES = yes 50 USE_GPU_RAYCASTING = yes 51 USE_OFFSCREEN_RENDERING = yes 53 52 54 53 #vtk uses deprecated strstream header (instead of sstream) … … 71 70 DEFINES += -DUSE_GPU_RAYCAST_MAPPER 72 71 endif 73 ifdef USE_THREADS74 DEFINES += -DUSE_THREADS75 endif76 72 CXX_SWITCHES = $(CXXFLAGS) $(EXTRA_CFLAGS) $(DEFINES) $(INCLUDES) 77 73 … … 82 78 RpContour2D.cpp \ 83 79 RpContour3D.cpp \ 80 RpCutplane.cpp \ 84 81 RpGlyphs.cpp \ 85 82 RpHeightMap.cpp \ … … 99 96 ifdef USE_CUSTOM_AXES 100 97 SERVER_SRCS+=vtkRpCubeAxesActor2D.cpp 101 endif102 ifdef USE_THREADS103 SERVER_SRCS+=ResponseQueue.cpp104 98 endif 105 99 … … 136 130 CmdProc.o: CmdProc.h 137 131 ColorMap.o: ColorMap.h RpMolecule.h Trace.h 138 PPMWriter.o: PPMWriter.h ResponseQueue.h Trace.h 139 ResponseQueue.o: ResponseQueue.h Trace.h 132 PPMWriter.o: PPMWriter.h Trace.h 140 133 RpContour2D.o: RpContour2D.h RpVtkGraphicsObject.h RpVtkDataSet.h Trace.h 141 134 RpContour3D.o: RpContour3D.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 135 RpCutplane.o: RpCutplane.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 142 136 RpGlyphs.o: RpGlyphs.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 143 137 RpHeightMap.o: RpHeightMap.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h … … 149 143 RpVolume.o: RpVolume.h RpVtkGraphicsObject.h RpVtkDataSet.h ColorMap.h Trace.h 150 144 RpVtkDataSet.o: RpVtkDataSet.h Trace.h 151 RpVtkRenderer.o: RpVtkRenderer.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h152 RpVtkRendererCmd.o: RpVtkRenderer.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h ResponseQueue.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h153 RpVtkRenderServer.o: RpVtkRenderServer.h RpVtkRendererCmd.h RpVtkRenderer.h ResponseQueue.h Trace.h PPMWriter.h TGAWriter.h145 RpVtkRenderer.o: RpVtkRenderer.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h 146 RpVtkRendererCmd.o: RpVtkRenderer.h vtkRpCubeAxesActor2D.h RpVtkDataSet.h RpContour2D.h RpContour3D.h RpGlyphs.h RpHeightMap.h RpLIC.h RpMolecule.h RpPolyData.h RpPseudoColor.h RpStreamlines.h RpVolume.h ColorMap.h Trace.h CmdProc.h PPMWriter.h TGAWriter.h 147 RpVtkRenderServer.o: RpVtkRenderServer.h RpVtkRendererCmd.h RpVtkRenderer.h vtkRpCubeAxesActor2D.h Trace.h PPMWriter.h TGAWriter.h 154 148 Trace.o: Trace.h 155 TGAWriter.o: TGAWriter.h ResponseQueue.hTrace.h149 TGAWriter.o: TGAWriter.h Trace.h 156 150 vtkRpCubeAxesActor2D.o: vtkRpCubeAxesActor2D.h -
branches/blt4/packages/vizservers/vtkvis/PPMWriter.cpp
r2542 r2550 12 12 #include <sys/uio.h> 13 13 14 #include "PPMWriter.h" 14 15 #include "Trace.h" 15 #include "PPMWriter.h"16 #ifdef USE_THREADS17 #include "ResponseQueue.h"18 #endif19 16 20 17 using namespace Rappture::VtkVis; 21 22 #ifdef USE_THREADS23 24 /**25 * \brief Writes image data as PPM binary data to the client.26 *27 * The PPM binary format is very simple.28 *29 * P6 w h 255\n30 * 3-byte RGB pixel data.31 *32 * The client (using the TkImg library) will do less work to unpack this33 * format, as opposed to BMP or PNG.34 *35 * Note that currently the image data has bottom to top scanlines. This36 * routine could be made even simpler (faster) if the image data had top37 * to bottom scanlines.38 *39 * \param[in] queue Pointer to ResponseQueue to write to40 * \param[in] cmdName Command name to send (byte length will be appended)41 * \param[in] data Image data42 * \param[in] width Width of image in pixels43 * \param[in] height Height of image in pixels44 */45 void46 Rappture::VtkVis::queuePPM(ResponseQueue *queue, const char *cmdName,47 const unsigned char *data, int width, int height)48 {49 #define PPM_MAXVAL 25550 char header[200];51 52 TRACE("Entering (%dx%d)\n", width, height);53 // Generate the PPM binary file header54 snprintf(header, sizeof(header), "P6 %d %d %d\n", width, height,55 PPM_MAXVAL);56 57 size_t headerLength = strlen(header);58 size_t dataLength = width * height * 3;59 60 char command[200];61 snprintf(command, sizeof(command), "%s %lu\n", cmdName,62 (unsigned long)headerLength + dataLength);63 64 size_t cmdLength;65 cmdLength = strlen(command);66 67 size_t length;68 unsigned char *mesg;69 70 length = headerLength + dataLength + cmdLength;71 mesg = (unsigned char *)malloc(length);72 if (mesg == NULL) {73 ERROR("can't allocate %ld bytes for the image message", length);74 return;75 }76 memcpy(mesg, command, cmdLength);77 memcpy(mesg + cmdLength, header, headerLength);78 79 size_t bytesPerRow = width * 3;80 unsigned char *destRowPtr = mesg + length - bytesPerRow;81 int y;82 unsigned char *srcRowPtr = const_cast<unsigned char *>(data);83 for (y = 0; y < height; y++) {84 memcpy(destRowPtr, srcRowPtr, bytesPerRow);85 srcRowPtr += bytesPerRow;86 destRowPtr -= bytesPerRow;87 }88 89 Response *response;90 if (strncmp(cmdName, "nv>legend", 9) == 0) {91 response = new Response(Response::LEGEND);92 } else {93 response = new Response(Response::IMAGE);94 }95 response->setMessage(mesg, length, Response::DYNAMIC);96 queue->enqueue(response);97 TRACE("Leaving (%dx%d)\n", width, height);98 }99 #else100 18 101 19 /** … … 121 39 */ 122 40 void 123 Rappture::VtkVis::writePPM(int fd, const char *cmdName, 124 const unsigned char *data,int width, int height)41 Rappture::VtkVis::writePPM(int fd, const char *cmdName, const unsigned char *data, 42 int width, int height) 125 43 { 126 44 #define PPM_MAXVAL 255 … … 129 47 TRACE("Entering (%dx%d)\n", width, height); 130 48 // Generate the PPM binary file header 131 snprintf(header, sizeof(header), "P6 %d %d %d\n", width, height, 132 PPM_MAXVAL); 49 snprintf(header, sizeof(header), "P6 %d %d %d\n", width, height, PPM_MAXVAL); 133 50 134 51 size_t headerLength = strlen(header); … … 162 79 } 163 80 if (writev(fd, iov, nRecs) < 0) { 164 81 ERROR("write failed: %s\n", strerror(errno)); 165 82 } 166 83 free(iov); … … 168 85 TRACE("Leaving (%dx%d)\n", width, height); 169 86 } 170 171 #endif /*USE_THREADS*/ -
branches/blt4/packages/vizservers/vtkvis/PPMWriter.h
r2542 r2550 9 9 #define __RAPPTURE_VTKVIS_PPMWRITER_H__ 10 10 11 #ifdef USE_THREADS12 #include "ResponseQueue.h"13 #endif14 15 11 namespace Rappture { 16 12 namespace VtkVis { 17 #ifdef USE_THREADS 13 18 14 extern 19 void queuePPM(ResponseQueue *queue, const char *cmdName, 20 const unsigned char *data, int width, int height); 21 #else 22 extern 23 void writePPM(int fd, const char *cmdName, 24 const unsigned char *data, int width, int height); 25 #endif 15 void writePPM(int fd, const char *cmdName, const unsigned char *data, int width, int height); 16 26 17 } 27 18 } 19 28 20 #endif -
branches/blt4/packages/vizservers/vtkvis/RpContour3D.cpp
r2542 r2550 172 172 _contourMapper->SetResolveCoincidentTopologyToPolygonOffset(); 173 173 _contourMapper->SetInputConnection(_contourFilter->GetOutputPort()); 174 _contourMapper->SetColorModeToMapScalars(); 174 175 getActor()->SetMapper(_contourMapper); 175 176 } -
branches/blt4/packages/vizservers/vtkvis/RpGlyphs.h
r2542 r2550 14 14 #include <vtkProp.h> 15 15 #include <vtkActor.h> 16 #ifdef HAVE_GLYPH3D_MAPPER 16 #include <vtkVersion.h> 17 #if ((VTK_MAJOR_VERSION > 5) || (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION >= 8)) 18 #define HAVE_GLYPH3D_MAPPER 17 19 #include <vtkGlyph3DMapper.h> 18 20 #else -
branches/blt4/packages/vizservers/vtkvis/RpHeightMap.cpp
r2542 r2550 91 91 _dataRange[1] = scalarRange[1]; 92 92 } else { 93 dataSet->getScalarRange(_dataRange);93 _dataSet->getScalarRange(_dataRange); 94 94 } 95 95 -
branches/blt4/packages/vizservers/vtkvis/RpHeightMap.h
r2542 r2550 73 73 void setHeightScale(double scale); 74 74 75 double getHeightScale() 76 { 77 return _warpScale; 78 } 79 75 80 void setNumContours(int numContours); 76 81 -
branches/blt4/packages/vizservers/vtkvis/RpLIC.cpp
r2542 r2550 24 24 #include "RpLIC.h" 25 25 #include "Trace.h" 26 #include "RpVtkRenderServer.h"27 26 28 27 using namespace Rappture::VtkVis; -
branches/blt4/packages/vizservers/vtkvis/RpPseudoColor.cpp
r2542 r2550 10 10 #include <vtkDataSet.h> 11 11 #include <vtkPointData.h> 12 #include <vtkCellData.h> 12 13 #include <vtkDataSetMapper.h> 13 14 #include <vtkUnstructuredGrid.h> … … 235 236 case COLOR_BY_VECTOR_MAGNITUDE: { 236 237 _dsMapper->ScalarVisibilityOn(); 237 _dsMapper->SetScalarModeToUsePointFieldData();238 238 if (ds->GetPointData() != NULL && 239 239 ds->GetPointData()->GetVectors() != NULL) { 240 _dsMapper->SetScalarModeToUsePointFieldData(); 240 241 _dsMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 242 } else if (ds->GetCellData() != NULL && 243 ds->GetCellData()->GetVectors() != NULL) { 244 _dsMapper->SetScalarModeToUseCellFieldData(); 245 _dsMapper->SelectColorArray(ds->GetCellData()->GetVectors()->GetName()); 241 246 } 242 247 if (_lut != NULL) { … … 248 253 case COLOR_BY_VECTOR_X: 249 254 _dsMapper->ScalarVisibilityOn(); 250 _dsMapper->SetScalarModeToUsePointFieldData();251 255 if (ds->GetPointData() != NULL && 252 256 ds->GetPointData()->GetVectors() != NULL) { 257 _dsMapper->SetScalarModeToUsePointFieldData(); 253 258 _dsMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 259 } else if (ds->GetCellData() != NULL && 260 ds->GetCellData()->GetVectors() != NULL) { 261 _dsMapper->SetScalarModeToUseCellFieldData(); 262 _dsMapper->SelectColorArray(ds->GetCellData()->GetVectors()->GetName()); 254 263 } 255 264 if (_lut != NULL) { … … 261 270 case COLOR_BY_VECTOR_Y: 262 271 _dsMapper->ScalarVisibilityOn(); 263 _dsMapper->SetScalarModeToUsePointFieldData();264 272 if (ds->GetPointData() != NULL && 265 273 ds->GetPointData()->GetVectors() != NULL) { 274 _dsMapper->SetScalarModeToUsePointFieldData(); 266 275 _dsMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 276 } else if (ds->GetCellData() != NULL && 277 ds->GetCellData()->GetVectors() != NULL) { 278 _dsMapper->SetScalarModeToUseCellFieldData(); 279 _dsMapper->SelectColorArray(ds->GetCellData()->GetVectors()->GetName()); 267 280 } 268 281 if (_lut != NULL) { … … 274 287 case COLOR_BY_VECTOR_Z: 275 288 _dsMapper->ScalarVisibilityOn(); 276 _dsMapper->SetScalarModeToUsePointFieldData();277 289 if (ds->GetPointData() != NULL && 278 290 ds->GetPointData()->GetVectors() != NULL) { 291 _dsMapper->SetScalarModeToUsePointFieldData(); 279 292 _dsMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 293 } else if (ds->GetCellData() != NULL && 294 ds->GetCellData()->GetVectors() != NULL) { 295 _dsMapper->SetScalarModeToUseCellFieldData(); 296 _dsMapper->SelectColorArray(ds->GetCellData()->GetVectors()->GetName()); 280 297 } 281 298 if (_lut != NULL) { -
branches/blt4/packages/vizservers/vtkvis/RpStreamlines.cpp
r2542 r2550 21 21 #include <vtkCellData.h> 22 22 #include <vtkCellDataToPointData.h> 23 #include <vtkPolygon.h> 23 24 #include <vtkPolyData.h> 24 25 #include <vtkTubeFilter.h> … … 26 27 #include <vtkTransform.h> 27 28 #include <vtkTransformPolyDataFilter.h> 29 #include <vtkVertexGlyphFilter.h> 28 30 29 31 #include "RpStreamlines.h" … … 123 125 _seedActor = vtkSmartPointer<vtkActor>::New(); 124 126 _seedActor->GetProperty()->SetColor(_seedColor[0], _seedColor[1], _seedColor[2]); 127 _seedActor->GetProperty()->SetEdgeColor(_seedColor[0], _seedColor[1], _seedColor[2]); 125 128 _seedActor->GetProperty()->SetLineWidth(1); 126 129 _seedActor->GetProperty()->SetPointSize(2); … … 172 175 */ 173 176 void Streamlines::getRandomPointInTriangle(double pt[3], 177 const double v0[3], 174 178 const double v1[3], 175 const double v2[3], 176 const double v3[3]) 179 const double v2[3]) 177 180 { 178 181 // Choose random barycentric coordinates … … 189 192 // Convert to cartesian coords 190 193 for (int i = 0; i < 3; i++) { 191 pt[i] = v1[i] * bary[0] + v2[i] * bary[1] + v3[i] * bary[2]; 194 pt[i] = v0[i] * bary[0] + v1[i] * bary[1] + v2[i] * bary[2]; 195 } 196 } 197 198 void Streamlines::getRandomPointInTetrahedron(double pt[3], 199 const double v0[3], 200 const double v1[3], 201 const double v2[3], 202 const double v3[3]) 203 { 204 // Choose random barycentric coordinates 205 double bary[4]; 206 bary[0] = getRandomNum(0, 1); 207 bary[1] = getRandomNum(0, 1); 208 bary[2] = getRandomNum(0, 1); 209 if (bary[0] + bary[1] > 1.0) { 210 bary[0] = 1.0 - bary[0]; 211 bary[1] = 1.0 - bary[1]; 212 } 213 if (bary[1] + bary[2] > 1.0) { 214 double tmp = bary[2]; 215 bary[2] = 1.0 - bary[0] - bary[1]; 216 bary[1] = 1.0 - tmp; 217 } else if (bary[0] + bary[1] + bary[2] > 1.0) { 218 double tmp = bary[2]; 219 bary[2] = bary[0] + bary[1] + bary[2] - 1.0; 220 bary[0] = 1.0 - bary[1] - tmp; 221 } 222 bary[3] = 1.0 - bary[0] - bary[1] - bary[2]; 223 TRACE("bary %g %g %g %g", bary[0], bary[1], bary[2], bary[3]); 224 // Convert to cartesian coords 225 for (int i = 0; i < 3; i++) { 226 #if 0 227 pt[i] = (v0[i] - v3[i]) * bary[0] + 228 (v1[i] - v3[i]) * bary[1] + 229 (v2[i] - v3[i]) * bary[2] + v3[i]; 230 #else 231 pt[i] = v0[i] * bary[0] + v1[i] * bary[1] + 232 v2[i] * bary[2] + v3[i] * bary[3]; 233 #endif 192 234 } 193 235 } … … 209 251 * \brief Get a random point within a vtkDataSet's mesh 210 252 * 211 * Note: This currently doesn't give a uniform distribution of 212 * points in space and can generate points outside the mesh 253 * Note: This currently doesn't always give a uniform distribution 254 * of points in space and can generate points outside the mesh for 255 * unusual cell types 213 256 */ 214 257 void Streamlines::getRandomCellPt(double pt[3], vtkDataSet *ds) … … 218 261 // all cells are equal area/volume) 219 262 int cell = rand() % numCells; 220 double bounds[6]; 221 ds->GetCellBounds(cell, bounds); 222 // Note: point is inside AABB of cell, but may be outside the cell 223 getRandomPoint(pt, bounds); 263 int type = ds->GetCellType(cell); 264 switch (type) { 265 case VTK_VERTEX: { 266 vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); 267 ds->GetCellPoints(cell, ptIds); 268 assert(ptIds->GetNumberOfIds() == 1); 269 ds->GetPoint(ptIds->GetId(0), pt); 270 } 271 break; 272 case VTK_POLY_VERTEX: { 273 vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); 274 ds->GetCellPoints(cell, ptIds); 275 assert(ptIds->GetNumberOfIds() >= 1); 276 int id = rand() % ptIds->GetNumberOfIds(); 277 ds->GetPoint(ptIds->GetId(id), pt); 278 } 279 break; 280 case VTK_LINE: { 281 double v[2][3]; 282 vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); 283 ds->GetCellPoints(cell, ptIds); 284 assert(ptIds->GetNumberOfIds() == 2); 285 for (int i = 0; i < 2; i++) { 286 ds->GetPoint(ptIds->GetId(i), v[i]); 287 } 288 getRandomPointOnLineSegment(pt, v[0], v[1]); 289 } 290 break; 291 case VTK_POLY_LINE: { 292 double v[2][3]; 293 vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); 294 ds->GetCellPoints(cell, ptIds); 295 assert(ptIds->GetNumberOfIds() >= 2); 296 int id = rand() % (ptIds->GetNumberOfIds()-1); 297 for (int i = 0; i < 2; i++) { 298 ds->GetPoint(ptIds->GetId(id+i), v[i]); 299 } 300 getRandomPointOnLineSegment(pt, v[0], v[1]); 301 } 302 break; 303 case VTK_TRIANGLE: { 304 double v[3][3]; 305 vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); 306 ds->GetCellPoints(cell, ptIds); 307 assert(ptIds->GetNumberOfIds() == 3); 308 for (int i = 0; i < 3; i++) { 309 ds->GetPoint(ptIds->GetId(i), v[i]); 310 } 311 getRandomPointInTriangle(pt, v[0], v[1], v[2]); 312 } 313 break; 314 case VTK_TRIANGLE_STRIP: { 315 double v[3][3]; 316 vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); 317 ds->GetCellPoints(cell, ptIds); 318 assert(ptIds->GetNumberOfIds() >= 3); 319 int id = rand() % (ptIds->GetNumberOfIds()-2); 320 for (int i = 0; i < 3; i++) { 321 ds->GetPoint(ptIds->GetId(id+i), v[i]); 322 } 323 getRandomPointInTriangle(pt, v[0], v[1], v[2]); 324 } 325 break; 326 case VTK_POLYGON: { 327 vtkPolygon *poly = vtkPolygon::SafeDownCast(ds->GetCell(cell)); 328 assert (poly != NULL); 329 vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); 330 poly->Triangulate(ptIds); 331 assert(ptIds->GetNumberOfIds() >= 3 && ptIds->GetNumberOfIds() % 3 == 0); 332 int tri = rand() % (ptIds->GetNumberOfIds()/3); 333 double v[3][3]; 334 for (int i = 0; i < 3; i++) { 335 ds->GetPoint(ptIds->GetId(i + tri * 3), v[i]); 336 } 337 getRandomPointInTriangle(pt, v[0], v[1], v[2]); 338 } 339 break; 340 case VTK_QUAD: { 341 double v[4][3]; 342 vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); 343 ds->GetCellPoints(cell, ptIds); 344 assert(ptIds->GetNumberOfIds() == 4); 345 for (int i = 0; i < 4; i++) { 346 ds->GetPoint(ptIds->GetId(i), v[i]); 347 } 348 int tri = rand() & 0x1; 349 if (tri) { 350 getRandomPointInTriangle(pt, v[0], v[1], v[2]); 351 } else { 352 getRandomPointInTriangle(pt, v[0], v[2], v[3]); 353 } 354 } 355 break; 356 case VTK_TETRA: { 357 double v[4][3]; 358 vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); 359 ds->GetCellPoints(cell, ptIds); 360 assert(ptIds->GetNumberOfIds() == 4); 361 for (int i = 0; i < 4; i++) { 362 ds->GetPoint(ptIds->GetId(i), v[i]); 363 } 364 getRandomPointInTetrahedron(pt, v[0], v[1], v[2], v[3]); 365 } 366 break; 367 case VTK_WEDGE: { 368 double v[6][3]; 369 vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); 370 ds->GetCellPoints(cell, ptIds); 371 assert(ptIds->GetNumberOfIds() == 6); 372 for (int i = 0; i < 6; i++) { 373 ds->GetPoint(ptIds->GetId(i), v[i]); 374 } 375 double vv[3][3]; 376 getRandomPointOnLineSegment(vv[0], v[0], v[3]); 377 getRandomPointOnLineSegment(vv[1], v[1], v[4]); 378 getRandomPointOnLineSegment(vv[2], v[2], v[5]); 379 getRandomPointInTriangle(pt, vv[0], vv[1], vv[2]); 380 } 381 break; 382 case VTK_PYRAMID: { 383 double v[5][3]; 384 vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); 385 ds->GetCellPoints(cell, ptIds); 386 assert(ptIds->GetNumberOfIds() == 5); 387 for (int i = 0; i < 5; i++) { 388 ds->GetPoint(ptIds->GetId(i), v[i]); 389 } 390 int tetra = rand() & 0x1; 391 if (tetra) { 392 getRandomPointInTetrahedron(pt, v[0], v[1], v[2], v[4]); 393 } else { 394 getRandomPointInTetrahedron(pt, v[0], v[2], v[3], v[4]); 395 } 396 } 397 break; 398 case VTK_PIXEL: 399 case VTK_VOXEL: { 400 double bounds[6]; 401 ds->GetCellBounds(cell, bounds); 402 getRandomPoint(pt, bounds); 403 } 404 break; 405 default: { 406 vtkSmartPointer<vtkIdList> ptIds = vtkSmartPointer<vtkIdList>::New(); 407 vtkSmartPointer<vtkPoints> pts = vtkSmartPointer<vtkPoints>::New(); 408 ds->GetCell(cell)->Triangulate(0, ptIds, pts); 409 if (ptIds->GetNumberOfIds() % 4 == 0) { 410 int tetra = rand() % (ptIds->GetNumberOfIds()/4); 411 double v[4][3]; 412 for (int i = 0; i < 4; i++) { 413 ds->GetPoint(ptIds->GetId(i + tetra * 4), v[i]); 414 } 415 getRandomPointInTetrahedron(pt, v[0], v[1], v[2], v[4]); 416 } else { 417 assert(ptIds->GetNumberOfIds() % 3 == 0); 418 int tri = rand() % (ptIds->GetNumberOfIds()/3); 419 double v[3][3]; 420 for (int i = 0; i < 3; i++) { 421 ds->GetPoint(ptIds->GetId(i + tri * 3), v[i]); 422 } 423 getRandomPointInTriangle(pt, v[0], v[1], v[2]); 424 } 425 } 426 } 224 427 } 225 428 … … 237 440 double bounds[6]; 238 441 _dataSet->getBounds(bounds); 442 double xLen = bounds[1] - bounds[0]; 443 double yLen = bounds[3] - bounds[2]; 444 double zLen = bounds[5] - bounds[4]; 239 445 double maxBound = 0.0; 240 if ( bounds[1] - bounds[0]> maxBound) {241 maxBound = bounds[1] - bounds[0];242 } 243 if ( bounds[3] - bounds[2]> maxBound) {244 maxBound = bounds[3] - bounds[2];245 } 246 if ( bounds[5] - bounds[4]> maxBound) {247 maxBound = bounds[5] - bounds[4];446 if (xLen > maxBound) { 447 maxBound = xLen; 448 } 449 if (yLen > maxBound) { 450 maxBound = yLen; 451 } 452 if (zLen > maxBound) { 453 maxBound = zLen; 248 454 } 249 455 … … 276 482 277 483 _streamTracer->SetInput(ds); 278 _streamTracer->SetMaximumPropagation(maxBound); 484 _streamTracer->SetMaximumPropagation(xLen + yLen + zLen); 485 _streamTracer->SetIntegratorTypeToRungeKutta45(); 486 487 TRACE("Setting streamlines max length to %g", 488 _streamTracer->GetMaximumPropagation()); 279 489 280 490 if (_pdMapper == NULL) { … … 286 496 _seedMapper = vtkSmartPointer<vtkPolyDataMapper>::New(); 287 497 _seedMapper->SetResolveCoincidentTopologyToPolygonOffset(); 498 _seedMapper->ScalarVisibilityOff(); 288 499 } 289 500 290 501 // Set up seed source object 291 setSeedTo RandomPoints(200);502 setSeedToFilledMesh(200); 292 503 293 504 switch (_lineType) { … … 343 554 344 555 /** 345 * \brief Use randomly distributed seed points 556 * \brief Use points of the DataSet associated with this 557 * Streamlines as seeds 558 */ 559 void Streamlines::setSeedToMeshPoints() 560 { 561 setSeedToMeshPoints(_dataSet->getVtkDataSet()); 562 } 563 564 /** 565 * \brief Use seed points randomly distributed within the cells 566 * of the DataSet associated with this Streamlines 346 567 * 347 568 * Note: The current implementation doesn't give a uniform … … 351 572 * \param[in] numPoints Number of random seed points to generate 352 573 */ 353 void Streamlines::setSeedToRandomPoints(int numPoints) 574 void Streamlines::setSeedToFilledMesh(int numPoints) 575 { 576 setSeedToFilledMesh(_dataSet->getVtkDataSet(), numPoints); 577 } 578 579 /** 580 * \brief Use points of a supplied vtkDataSet as seeds 581 * 582 * \param[in] seed vtkDataSet with points to use as seeds 583 */ 584 void Streamlines::setSeedToMeshPoints(vtkDataSet *seed) 585 { 586 if (_streamTracer != NULL) { 587 TRACE("Seed points: %d", seed->GetNumberOfPoints()); 588 vtkSmartPointer<vtkDataSet> oldSeed; 589 if (_streamTracer->GetSource() != NULL) { 590 oldSeed = _streamTracer->GetSource(); 591 } 592 593 _streamTracer->SetSource(seed); 594 if (oldSeed != NULL) { 595 oldSeed->SetPipelineInformation(NULL); 596 } 597 598 if (vtkPolyData::SafeDownCast(seed) != NULL) { 599 _seedMapper->SetInput(vtkPolyData::SafeDownCast(seed)); 600 } else { 601 vtkSmartPointer<vtkVertexGlyphFilter> vertFilter = vtkSmartPointer<vtkVertexGlyphFilter>::New(); 602 vertFilter->SetInput(seed); 603 _seedMapper->SetInputConnection(vertFilter->GetOutputPort()); 604 } 605 } 606 } 607 608 /** 609 * \brief Use seed points randomly distributed within the cells 610 * of a supplied vtkDataSet 611 * 612 * Note: The current implementation doesn't give a uniform 613 * distribution of points, and points outside the mesh bounds 614 * may be generated 615 * 616 * \param[in] ds vtkDataSet containing cells 617 * \param[in] numPoints Number of random seed points to generate 618 */ 619 void Streamlines::setSeedToFilledMesh(vtkDataSet *ds, int numPoints) 354 620 { 355 621 if (_streamTracer != NULL) { … … 359 625 vtkSmartPointer<vtkCellArray> cells = vtkSmartPointer<vtkCellArray>::New(); 360 626 627 if (ds->GetNumberOfCells() < 1) { 628 ERROR("No cells in mesh"); 629 } 630 361 631 for (int i = 0; i < numPoints; i++) { 362 632 double pt[3]; 363 getRandomCellPt(pt, _dataSet->getVtkDataSet());364 TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]);633 getRandomCellPt(pt, ds); 634 //TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]); 365 635 pts->InsertNextPoint(pt); 366 636 cells->InsertNextCell(1); … … 415 685 pt[ii] = start[ii] + dir[ii] * ((double)i / (numPoints-1)); 416 686 } 417 TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]);687 //TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]); 418 688 pts->InsertNextPoint(pt); 419 689 polyline->GetPointIds()->SetId(i, i); … … 507 777 pt[i] = center[i] + r * (px[i] * cos(angle) + py[i] * sin(angle)); 508 778 } 509 TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]);779 //TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]); 510 780 pts->InsertNextPoint(pt); 511 781 cells->InsertNextCell(1); … … 662 932 py[i] * sin(theta)); 663 933 } 664 TRACE("Vert %d: %g %g %g", j, verts[j][0], verts[j][1], verts[j][2]);934 //TRACE("Vert %d: %g %g %g", j, verts[j][0], verts[j][1], verts[j][2]); 665 935 } 666 936 … … 671 941 double pt[3]; 672 942 getRandomPointInTriangle(pt, verts[0], verts[1], verts[2]); 673 TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]);943 //TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]); 674 944 pts->InsertNextPoint(pt); 675 945 cells->InsertNextCell(1); … … 682 952 double pt[3]; 683 953 getRandomPointInTriangle(pt, center, verts[tri], verts[(tri+1) % numSides]); 684 TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]);954 //TRACE("Seed pt: %g %g %g", pt[0], pt[1], pt[2]); 685 955 pts->InsertNextPoint(pt); 686 956 cells->InsertNextCell(1); … … 708 978 709 979 /** 710 * \brief Set maximum length of stream lines in world coordinates 980 * \brief Set the integration method used 981 */ 982 void Streamlines::setIntegrator(IntegratorType integrator) 983 { 984 if (_streamTracer != NULL) { 985 switch (integrator) { 986 case RUNGE_KUTTA2: 987 _streamTracer->SetIntegratorTypeToRungeKutta2(); 988 break; 989 case RUNGE_KUTTA4: 990 _streamTracer->SetIntegratorTypeToRungeKutta4(); 991 break; 992 case RUNGE_KUTTA45: 993 _streamTracer->SetIntegratorTypeToRungeKutta45(); 994 break; 995 default: 996 ; 997 } 998 } 999 } 1000 1001 /** 1002 * \brief Set the direction of integration 1003 */ 1004 void Streamlines::setIntegrationDirection(IntegrationDirection dir) 1005 { 1006 if (_streamTracer != NULL) { 1007 switch (dir) { 1008 case FORWARD: 1009 _streamTracer->SetIntegrationDirectionToForward(); 1010 break; 1011 case BACKWARD: 1012 _streamTracer->SetIntegrationDirectionToBackward(); 1013 break; 1014 case BOTH: 1015 _streamTracer->SetIntegrationDirectionToBoth(); 1016 break; 1017 default: 1018 ; 1019 } 1020 } 1021 } 1022 1023 /** 1024 * \brief Set the step size units. Length units are world 1025 * coordinates, and cell units means steps are from cell to 1026 * cell. Default is cell units. 1027 * 1028 * Note: calling this function will not convert existing 1029 * initial, minimum or maximum step value settings to the 1030 * new units, so this function should be called before 1031 * setting step values. 1032 */ 1033 void Streamlines::setIntegrationStepUnit(StepUnit unit) 1034 { 1035 if (_streamTracer != NULL) { 1036 switch (unit) { 1037 case LENGTH_UNIT: 1038 _streamTracer->SetIntegrationStepUnit(vtkStreamTracer::LENGTH_UNIT); 1039 break; 1040 case CELL_LENGTH_UNIT: 1041 _streamTracer->SetIntegrationStepUnit(vtkStreamTracer::CELL_LENGTH_UNIT); 1042 break; 1043 default: 1044 ; 1045 } 1046 } 1047 } 1048 1049 /** 1050 * \brief Set initial step size for adaptive step integrator in 1051 * step units (see setIntegrationStepUnit). For non-adaptive 1052 * integrators, this is the fixed step size. 1053 */ 1054 void Streamlines::setInitialIntegrationStep(double step) 1055 { 1056 if (_streamTracer != NULL) { 1057 _streamTracer->SetInitialIntegrationStep(step); 1058 } 1059 } 1060 1061 /** 1062 * \brief Set minimum step for adaptive step integrator in 1063 * step units (see setIntegrationStepUnit) 1064 */ 1065 void Streamlines::setMinimumIntegrationStep(double step) 1066 { 1067 if (_streamTracer != NULL) { 1068 _streamTracer->SetMinimumIntegrationStep(step); 1069 } 1070 } 1071 1072 /** 1073 * \brief Set maximum step for adaptive step integrator in 1074 * step units (see setIntegrationStepUnit) 1075 */ 1076 void Streamlines::setMaximumIntegrationStep(double step) 1077 { 1078 if (_streamTracer != NULL) { 1079 _streamTracer->SetMaximumIntegrationStep(step); 1080 } 1081 } 1082 1083 /** 1084 * \brief Set maximum error tolerance 1085 */ 1086 void Streamlines::setMaximumError(double error) 1087 { 1088 if (_streamTracer != NULL) { 1089 _streamTracer->SetMaximumError(error); 1090 } 1091 } 1092 1093 /** 1094 * \brief Set maximum length of stream lines in world 1095 * coordinates 711 1096 */ 712 1097 void Streamlines::setMaxPropagation(double length) … … 714 1099 if (_streamTracer != NULL) { 715 1100 _streamTracer->SetMaximumPropagation(length); 1101 } 1102 } 1103 1104 /** 1105 * \brief Set maximum number of integration steps 1106 */ 1107 void Streamlines::setMaxNumberOfSteps(int steps) 1108 { 1109 if (_streamTracer != NULL) { 1110 _streamTracer->SetMaximumNumberOfSteps(steps); 1111 } 1112 } 1113 1114 /** 1115 * \brief Set the minimum speed before integration stops 1116 */ 1117 void Streamlines::setTerminalSpeed(double speed) 1118 { 1119 if (_streamTracer != NULL) { 1120 _streamTracer->SetTerminalSpeed(speed); 716 1121 } 717 1122 } … … 820 1225 return; 821 1226 822 vtkDataSet *ds = _dataSet->getVtkDataSet();823 824 1227 switch (mode) { 825 1228 case COLOR_BY_SCALAR: { … … 834 1237 _pdMapper->ScalarVisibilityOn(); 835 1238 _pdMapper->SetScalarModeToUsePointFieldData(); 836 if (ds->GetPointData() != NULL && 837 ds->GetPointData()->GetVectors() != NULL) { 838 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 839 } 1239 _pdMapper->SelectColorArray(_dataSet->getActiveVectorsName()); 840 1240 if (_lut != NULL) { 841 1241 _lut->SetRange(_vectorMagnitudeRange); … … 847 1247 _pdMapper->ScalarVisibilityOn(); 848 1248 _pdMapper->SetScalarModeToUsePointFieldData(); 849 if (ds->GetPointData() != NULL && 850 ds->GetPointData()->GetVectors() != NULL) { 851 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 852 } 1249 _pdMapper->SelectColorArray(_dataSet->getActiveVectorsName()); 853 1250 if (_lut != NULL) { 854 1251 _lut->SetRange(_vectorComponentRange[0]); … … 860 1257 _pdMapper->ScalarVisibilityOn(); 861 1258 _pdMapper->SetScalarModeToUsePointFieldData(); 862 if (ds->GetPointData() != NULL && 863 ds->GetPointData()->GetVectors() != NULL) { 864 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 865 } 1259 _pdMapper->SelectColorArray(_dataSet->getActiveVectorsName()); 866 1260 if (_lut != NULL) { 867 1261 _lut->SetRange(_vectorComponentRange[1]); … … 873 1267 _pdMapper->ScalarVisibilityOn(); 874 1268 _pdMapper->SetScalarModeToUsePointFieldData(); 875 if (ds->GetPointData() != NULL && 876 ds->GetPointData()->GetVectors() != NULL) { 877 _pdMapper->SelectColorArray(ds->GetPointData()->GetVectors()->GetName()); 878 } 1269 _pdMapper->SelectColorArray(_dataSet->getActiveVectorsName()); 879 1270 if (_lut != NULL) { 880 1271 _lut->SetRange(_vectorComponentRange[2]); … … 1058 1449 _seedColor[1] = color[1]; 1059 1450 _seedColor[2] = color[2]; 1060 if (_seedActor != NULL) 1451 if (_seedActor != NULL) { 1061 1452 _seedActor->GetProperty()->SetColor(_seedColor[0], _seedColor[1], _seedColor[2]); 1453 _seedActor->GetProperty()->SetEdgeColor(_seedColor[0], _seedColor[1], _seedColor[2]); 1454 } 1062 1455 } 1063 1456 -
branches/blt4/packages/vizservers/vtkvis/RpStreamlines.h
r2542 r2550 44 44 COLOR_CONSTANT 45 45 }; 46 enum StepUnit { 47 LENGTH_UNIT, 48 CELL_LENGTH_UNIT 49 }; 50 enum IntegratorType { 51 RUNGE_KUTTA2, 52 RUNGE_KUTTA4, 53 RUNGE_KUTTA45 54 }; 55 enum IntegrationDirection { 56 FORWARD, 57 BACKWARD, 58 BOTH 59 }; 46 60 47 61 Streamlines(); … … 77 91 virtual void setClippingPlanes(vtkPlaneCollection *planes); 78 92 79 void setSeedToRandomPoints(int numPoints); 93 void setSeedToMeshPoints(); 94 95 void setSeedToFilledMesh(int numPoints); 96 97 void setSeedToMeshPoints(vtkDataSet *ds); 98 99 void setSeedToFilledMesh(vtkDataSet *ds, int numPoints); 80 100 81 101 void setSeedToRake(double start[3], double end[3], int numPoints); … … 92 112 int numSides, int numPoints); 93 113 114 void setIntegrator(IntegratorType integrator); 115 116 void setIntegrationDirection(IntegrationDirection dir); 117 118 void setIntegrationStepUnit(StepUnit unit); 119 120 void setInitialIntegrationStep(double step); 121 122 void setMinimumIntegrationStep(double step); 123 124 void setMaximumIntegrationStep(double step); 125 126 void setMaximumError(double error); 127 94 128 void setMaxPropagation(double length); 129 130 void setMaxNumberOfSteps(int steps); 131 132 void setTerminalSpeed(double speed); 95 133 96 134 void setLineTypeToLines(); … … 130 168 static void getRandomPoint(double pt[3], const double bounds[6]); 131 169 static void getRandomPointInTriangle(double pt[3], 170 const double v0[3], 132 171 const double v1[3], 133 const double v2[3], 134 const double v3[3]); 172 const double v2[3]); 135 173 static void getRandomPointOnLineSegment(double pt[3], 136 174 const double endpt[3], 137 175 const double endpt2[3]); 176 static void getRandomPointInTetrahedron(double pt[3], 177 const double v0[3], 178 const double v1[3], 179 const double v2[3], 180 const double v3[3]); 138 181 static void getRandomCellPt(double pt[3], vtkDataSet *ds); 139 182 -
branches/blt4/packages/vizservers/vtkvis/RpVtkRenderServer.cpp
r2542 r2550 1 2 1 /* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */ 3 2 /* … … 10 9 #include <cstring> 11 10 #include <cstdlib> 12 #include <cerrno> 11 #include <string> 12 #include <sstream> 13 13 #include <unistd.h> 14 14 #include <signal.h> … … 17 17 #include <sys/time.h> 18 18 #endif 19 20 #include <string>21 #include <sstream>22 19 23 20 #include "Trace.h" … … 27 24 #include "PPMWriter.h" 28 25 #include "TGAWriter.h" 29 #ifdef USE_THREADS30 #include <pthread.h>31 #include "ResponseQueue.h"32 #endif33 26 34 27 using namespace Rappture::VtkVis; … … 45 38 (((t2).tv_sec - (t1).tv_sec))*1.0e+3f + (float)((t2).tv_usec - (t1).tv_usec)/1.0e+3f) 46 39 47 #ifdef USE_THREADS48 40 static void 49 queueFrame(ResponseQueue *queue, vtkUnsignedCharArray *imgData)41 writeFrame(int fd, vtkUnsignedCharArray *imgData) 50 42 { 51 43 #ifdef DEBUG … … 73 65 TARGA_BYTES_PER_PIXEL, 74 66 true); 75 #endif /*RENDER_TARGA*/67 #endif 76 68 77 69 #else … … 90 82 91 83 #ifdef RENDER_TARGA 92 queueTGA(queue, oss.str().c_str(),84 writeTGA(fd, oss.str().c_str(), 93 85 imgData->GetPointer(0), 94 86 g_renderer->getWindowWidth(), … … 96 88 TARGA_BYTES_PER_PIXEL); 97 89 #else 98 queuePPM(queue, oss.str().c_str(),90 writePPM(fd, oss.str().c_str(), 99 91 imgData->GetPointer(0), 100 92 g_renderer->getWindowWidth(), 101 93 g_renderer->getWindowHeight()); 102 #endif /*RENDER_TARGA*/ 103 } else { 104 #ifdef RENDER_TARGA 105 queueTGA(queue, "nv>image -type image -bytes", 106 imgData->GetPointer(0), 107 g_renderer->getWindowWidth(), 108 g_renderer->getWindowHeight(), 109 TARGA_BYTES_PER_PIXEL); 110 #else 111 queuePPM(queue, "nv>image -type image -bytes", 112 imgData->GetPointer(0), 113 g_renderer->getWindowWidth(), 114 g_renderer->getWindowHeight()); 115 #endif /*RENDER_TARGA*/ 116 } 117 #endif /*DEBUG*/ 118 } 119 120 #else 121 122 static void 123 writeFrame(int fd, vtkUnsignedCharArray *imgData) 124 { 125 #ifdef DEBUG 126 if (g_renderer->getCameraMode() == Renderer::IMAGE) { 127 double xywh[4]; 128 g_renderer->getScreenWorldCoords(xywh); 129 TRACE("Image bbox: %g %g %g %g", 130 xywh[0], 131 (xywh[1] + xywh[3]), 132 (xywh[0] + xywh[2]), 133 xywh[1]); 134 } 135 136 #ifdef RENDER_TARGA 137 writeTGAFile("/tmp/frame.tga", 138 imgData->GetPointer(0), 139 g_renderer->getWindowWidth(), 140 g_renderer->getWindowHeight(), 141 TARGA_BYTES_PER_PIXEL); 142 #else 143 writeTGAFile("/tmp/frame.tga", 144 imgData->GetPointer(0), 145 g_renderer->getWindowWidth(), 146 g_renderer->getWindowHeight(), 147 TARGA_BYTES_PER_PIXEL, 148 true); 149 #endif /*RENDER_TARGA*/ 150 151 #else 152 if (g_renderer->getCameraMode() == Renderer::IMAGE) { 153 double xywh[4]; 154 g_renderer->getCameraZoomRegion(xywh); 155 std::ostringstream oss; 156 oss.precision(12); 157 // Send upper left and lower right corners as bbox 158 oss << "nv>image -type image -bbox {" 159 << std::scientific 160 << xywh[0] << " " 161 << xywh[1] << " " 162 << xywh[2] << " " 163 << xywh[3] << "} -bytes"; 164 165 #ifdef RENDER_TARGA 166 writeTGA(fd, oss.str().c_str(), 167 imgData->GetPointer(0), 168 g_renderer->getWindowWidth(), 169 g_renderer->getWindowHeight(), 170 TARGA_BYTES_PER_PIXEL); 171 #else 172 writePPM(fd, oss.str().c_str(), 173 imgData->GetPointer(0), 174 g_renderer->getWindowWidth(), 175 g_renderer->getWindowHeight()); 176 #endif /*RENDER_TARGA*/ 94 #endif 177 95 } else { 178 96 #ifdef RENDER_TARGA … … 187 105 g_renderer->getWindowWidth(), 188 106 g_renderer->getWindowHeight()); 189 #endif /*RENDER_TARGA*/ 190 } 191 #endif /*DEBUG*/ 192 } 193 #endif /*USE_THREADS*/ 107 #endif 108 } 109 #endif 110 } 194 111 195 112 static void … … 236 153 } 237 154 238 #ifdef USE_THREADS239 static void *240 readerThread(void *clientData)241 {242 ResponseQueue *queue = (ResponseQueue *)clientData;243 Tcl_Interp *interp;244 245 TRACE("starting reader thread");246 interp = (Tcl_Interp *)queue->clientData();247 vtkSmartPointer<vtkUnsignedCharArray> imgData =248 vtkSmartPointer<vtkUnsignedCharArray>::New();249 for (;;) {250 int ret;251 252 ret = processCommands(interp, g_fIn, g_fOut);253 if (ret < 0)254 break;255 if (g_renderer->render()) {256 TRACE("Rendering new frame");257 g_renderer->getRenderedFrame(imgData);258 queueFrame(queue, imgData);259 } else {260 TRACE("No render required");261 }262 if (feof(g_fIn))263 break;264 }265 return NULL;266 }267 268 static void *269 writerThread(void *clientData)270 {271 ResponseQueue *queue = (ResponseQueue *)clientData;272 273 TRACE("starting writer thread");274 for (;;) {275 Response *response;276 277 response = queue->dequeue();278 if (fwrite(response->message(), sizeof(char), response->length(),279 g_fOut) != response->length()) {280 ERROR("short write while trying to write %ld bytes",281 response->length());282 }283 fflush(g_fOut);284 delete response;285 if (feof(g_fOut))286 break;287 }288 return NULL;289 }290 291 #endif /*USE_THREADS*/292 293 155 int 294 156 main(int argc, char *argv[]) … … 297 159 signal(SIGPIPE, SIG_IGN); 298 160 initService(); 299 initLog();161 InitLog(); 300 162 301 163 TRACE("Starting VTKVis Server"); … … 314 176 315 177 g_renderer = new Renderer(); 316 317 Tcl_Interp *interp = Tcl_CreateInterp();318 319 #ifdef USE_THREADS320 ResponseQueue queue((void *)interp);321 initTcl(interp, (ClientData)&queue);322 323 pthread_t readerThreadId, writerThreadId;324 if (pthread_create(&readerThreadId, NULL, &readerThread, &queue) < 0) {325 ERROR("can't create reader thread: %s", strerror(errno));326 }327 if (pthread_create(&writerThreadId, NULL, &writerThread, &queue) < 0) {328 ERROR("can't create writer thread: %s", strerror(errno));329 }330 if (pthread_join(readerThreadId, NULL) < 0) {331 ERROR("can't join reader thread: %s", strerror(errno));332 }333 if (pthread_join(writerThreadId, NULL) < 0) {334 ERROR("can't join writer thread: %s", strerror(errno));335 }336 #else337 initTcl(interp, (ClientData)NULL);338 int ret = 0;339 340 178 vtkSmartPointer<vtkUnsignedCharArray> imgData = 341 179 vtkSmartPointer<vtkUnsignedCharArray>::New(); 180 181 Tcl_Interp *interp = initTcl(); 182 183 int ret = 0; 184 342 185 while (1) { 343 186 ret = processCommands(interp, g_fIn, g_fOut); … … 356 199 break; 357 200 } 358 #endif 359 INFO("exiting vtkvis"); 201 360 202 exitTcl(interp); 361 203 interp = NULL; … … 366 208 TRACE("Exiting VTKVis Server"); 367 209 368 closeLog();210 CloseLog(); 369 211 exitService(); 370 212 371 return 0;372 } 373 213 return ret; 214 } 215 -
branches/blt4/packages/vizservers/vtkvis/RpVtkRenderServer.h
r2120 r2550 9 9 #define __RAPPTURE_VTKVIS_RENDERSERVER_H__ 10 10 11 #include "RpVtkRenderer.h"12 13 11 namespace Rappture { 14 12 namespace VtkVis { 13 14 class Renderer; 15 15 16 16 extern int g_fdIn; -
branches/blt4/packages/vizservers/vtkvis/RpVtkRenderer.cpp
r2542 r2550 40 40 #include <vtkTextProperty.h> 41 41 #include <vtkOpenGLRenderWindow.h> 42 #include <vtkVersion.h> 42 43 43 44 #include "RpVtkRenderer.h" … … 158 159 } 159 160 _contour3Ds.clear(); 161 TRACE("Deleting Cutplanes"); 162 for (CutplaneHashmap::iterator itr = _cutplanes.begin(); 163 itr != _cutplanes.end(); ++itr) { 164 delete itr->second; 165 } 166 _cutplanes.clear(); 160 167 TRACE("Deleting Glyphs"); 161 168 for (GlyphsHashmap::iterator itr = _glyphs.begin(); … … 314 321 315 322 /** 323 * \brief Remove the Cutplane for the specified DataSet 324 * 325 * The underlying Cutplane is deleted, freeing its memory 326 */ 327 void Renderer::deleteCutplane(const DataSetId& id) 328 { 329 CutplaneHashmap::iterator itr; 330 331 bool doAll = false; 332 333 if (id.compare("all") == 0) { 334 itr = _cutplanes.begin(); 335 doAll = true; 336 } else { 337 itr = _cutplanes.find(id); 338 } 339 if (itr == _cutplanes.end()) { 340 ERROR("Cutplane not found: %s", id.c_str()); 341 return; 342 } 343 344 TRACE("Deleting Cutplanes for %s", id.c_str()); 345 346 do { 347 Cutplane *cutplane = itr->second; 348 if (cutplane->getProp()) 349 _renderer->RemoveViewProp(cutplane->getProp()); 350 delete cutplane; 351 352 itr = _cutplanes.erase(itr); 353 } while (doAll && itr != _cutplanes.end()); 354 355 _renderer->ResetCameraClippingRange(); 356 _needsRedraw = true; 357 } 358 359 /** 316 360 * \brief Remove the Glyphs for the specified DataSet 317 361 * … … 637 681 deleteContour2D(itr->second->getName()); 638 682 deleteContour3D(itr->second->getName()); 683 deleteCutplane(itr->second->getName()); 639 684 deleteGlyphs(itr->second->getName()); 640 685 deleteHeightMap(itr->second->getName()); … … 825 870 double newBounds[6]; 826 871 collectBounds(newBounds, false); 872 #if ((VTK_MAJOR_VERSION > 5) || (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION >= 8)) 873 _cubeAxesActor->SetXAxisRange(newBounds[0], newBounds[1]); 874 _cubeAxesActor->SetYAxisRange(newBounds[2], newBounds[3]); 875 _cubeAxesActor->SetZAxisRange(newBounds[4], newBounds[5]); 876 #endif 827 877 _cubeAxesActor->SetBounds(newBounds); 828 878 TRACE("Bounds (computed): %g %g %g %g %g %g", … … 834 884 newBounds[5]); 835 885 } else { 886 #if ((VTK_MAJOR_VERSION > 5) || (VTK_MAJOR_VERSION == 5 && VTK_MINOR_VERSION >= 8)) 887 _cubeAxesActor->SetXAxisRange(bounds[0], bounds[1]); 888 _cubeAxesActor->SetYAxisRange(bounds[2], bounds[3]); 889 _cubeAxesActor->SetZAxisRange(bounds[4], bounds[5]); 890 #endif 836 891 _cubeAxesActor->SetBounds(bounds); 837 892 TRACE("Bounds (supplied): %g %g %g %g %g %g", … … 858 913 // Don't offset labels at origin 859 914 _cubeAxesActor->SetCornerOffset(0); 860 _cubeAxesActor->SetFlyModeTo ClosestTriad();915 _cubeAxesActor->SetFlyModeToStaticTriad(); 861 916 862 917 #ifdef USE_CUSTOM_AXES … … 1213 1268 } 1214 1269 } 1270 for (CutplaneHashmap::iterator itr = _cutplanes.begin(); 1271 itr != _cutplanes.end(); ++itr) { 1272 if (itr->second->getColorMap() == cmap) { 1273 itr->second->updateColorMap(); 1274 _needsRedraw = true; 1275 } 1276 } 1215 1277 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 1216 1278 itr != _glyphs.end(); ++itr) { … … 1271 1333 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 1272 1334 itr != _contour3Ds.end(); ++itr) { 1335 if (itr->second->getColorMap() == cmap) 1336 return true; 1337 } 1338 for (CutplaneHashmap::iterator itr = _cutplanes.begin(); 1339 itr != _cutplanes.end(); ++itr) { 1273 1340 if (itr->second->getColorMap() == cmap) 1274 1341 return true; … … 2197 2264 } while (doAll && ++itr != _dataSets.end()); 2198 2265 2199 if (_cameraMode == IMAGE)2200 setCameraMode(PERSPECTIVE);2201 2266 initCamera(); 2202 2267 _needsRedraw = true; … … 2672 2737 2673 2738 /** 2739 * \brief Create a new Cutplane and associate it with the named DataSet 2740 */ 2741 bool Renderer::addCutplane(const DataSetId& id) 2742 { 2743 DataSetHashmap::iterator itr; 2744 2745 bool doAll = false; 2746 2747 if (id.compare("all") == 0) { 2748 itr = _dataSets.begin(); 2749 } else { 2750 itr = _dataSets.find(id); 2751 } 2752 if (itr == _dataSets.end()) { 2753 ERROR("Unknown dataset %s", id.c_str()); 2754 return false; 2755 } 2756 2757 do { 2758 DataSet *ds = itr->second; 2759 const DataSetId& dsID = ds->getName(); 2760 2761 if (getCutplane(dsID)) { 2762 WARN("Replacing existing Cutplane %s", dsID.c_str()); 2763 deleteCutplane(dsID); 2764 } 2765 2766 Cutplane *cutplane = new Cutplane(); 2767 _cutplanes[dsID] = cutplane; 2768 2769 cutplane->setDataSet(ds, 2770 _useCumulativeRange, 2771 _cumulativeScalarRange, 2772 _cumulativeVectorMagnitudeRange, 2773 _cumulativeVectorComponentRange); 2774 2775 _renderer->AddViewProp(cutplane->getProp()); 2776 } while (doAll && ++itr != _dataSets.end()); 2777 2778 _needsRedraw = true; 2779 return true; 2780 } 2781 2782 /** 2783 * \brief Get the Cutplane associated with a named DataSet 2784 */ 2785 Cutplane *Renderer::getCutplane(const DataSetId& id) 2786 { 2787 CutplaneHashmap::iterator itr = _cutplanes.find(id); 2788 2789 if (itr == _cutplanes.end()) { 2790 #ifdef DEBUG 2791 TRACE("Cutplane not found: %s", id.c_str()); 2792 #endif 2793 return NULL; 2794 } else 2795 return itr->second; 2796 } 2797 2798 /** 2799 * \brief Set an additional transform on the prop 2800 */ 2801 void Renderer::setCutplaneTransform(const DataSetId& id, vtkMatrix4x4 *trans) 2802 { 2803 CutplaneHashmap::iterator itr; 2804 2805 bool doAll = false; 2806 2807 if (id.compare("all") == 0) { 2808 itr = _cutplanes.begin(); 2809 doAll = true; 2810 } else { 2811 itr = _cutplanes.find(id); 2812 } 2813 if (itr == _cutplanes.end()) { 2814 ERROR("Cutplane not found: %s", id.c_str()); 2815 return; 2816 } 2817 2818 do { 2819 itr->second->setTransform(trans); 2820 } while (doAll && ++itr != _cutplanes.end()); 2821 2822 resetAxes(); 2823 _needsRedraw = true; 2824 } 2825 2826 /** 2827 * \brief Set the prop orientation with a quaternion 2828 */ 2829 void Renderer::setCutplaneOrientation(const DataSetId& id, double quat[4]) 2830 { 2831 CutplaneHashmap::iterator itr; 2832 2833 bool doAll = false; 2834 2835 if (id.compare("all") == 0) { 2836 itr = _cutplanes.begin(); 2837 doAll = true; 2838 } else { 2839 itr = _cutplanes.find(id); 2840 } 2841 if (itr == _cutplanes.end()) { 2842 ERROR("Cutplane not found: %s", id.c_str()); 2843 return; 2844 } 2845 2846 do { 2847 itr->second->setOrientation(quat); 2848 } while (doAll && ++itr != _cutplanes.end()); 2849 2850 resetAxes(); 2851 _needsRedraw = true; 2852 } 2853 2854 /** 2855 * \brief Set the prop orientation with a rotation about an axis 2856 */ 2857 void Renderer::setCutplaneOrientation(const DataSetId& id, double angle, double axis[3]) 2858 { 2859 CutplaneHashmap::iterator itr; 2860 2861 bool doAll = false; 2862 2863 if (id.compare("all") == 0) { 2864 itr = _cutplanes.begin(); 2865 doAll = true; 2866 } else { 2867 itr = _cutplanes.find(id); 2868 } 2869 if (itr == _cutplanes.end()) { 2870 ERROR("Cutplane not found: %s", id.c_str()); 2871 return; 2872 } 2873 2874 do { 2875 itr->second->setOrientation(angle, axis); 2876 } while (doAll && ++itr != _cutplanes.end()); 2877 2878 resetAxes(); 2879 _needsRedraw = true; 2880 } 2881 2882 /** 2883 * \brief Set the prop position in world coords 2884 */ 2885 void Renderer::setCutplanePosition(const DataSetId& id, double pos[3]) 2886 { 2887 CutplaneHashmap::iterator itr; 2888 2889 bool doAll = false; 2890 2891 if (id.compare("all") == 0) { 2892 itr = _cutplanes.begin(); 2893 doAll = true; 2894 } else { 2895 itr = _cutplanes.find(id); 2896 } 2897 if (itr == _cutplanes.end()) { 2898 ERROR("Cutplane not found: %s", id.c_str()); 2899 return; 2900 } 2901 2902 do { 2903 itr->second->setPosition(pos); 2904 } while (doAll && ++itr != _cutplanes.end()); 2905 2906 resetAxes(); 2907 _needsRedraw = true; 2908 } 2909 2910 /** 2911 * \brief Set the prop scaling 2912 */ 2913 void Renderer::setCutplaneScale(const DataSetId& id, double scale[3]) 2914 { 2915 CutplaneHashmap::iterator itr; 2916 2917 bool doAll = false; 2918 2919 if (id.compare("all") == 0) { 2920 itr = _cutplanes.begin(); 2921 doAll = true; 2922 } else { 2923 itr = _cutplanes.find(id); 2924 } 2925 if (itr == _cutplanes.end()) { 2926 ERROR("Cutplane not found: %s", id.c_str()); 2927 return; 2928 } 2929 2930 do { 2931 itr->second->setScale(scale); 2932 } while (doAll && ++itr != _cutplanes.end()); 2933 2934 resetAxes(); 2935 _needsRedraw = true; 2936 } 2937 2938 /** 2939 * \brief Set the volume slice used for mapping volumetric data 2940 */ 2941 void Renderer::setCutplaneVolumeSlice(const DataSetId& id, Cutplane::Axis axis, double ratio) 2942 { 2943 CutplaneHashmap::iterator itr; 2944 2945 bool doAll = false; 2946 2947 if (id.compare("all") == 0) { 2948 itr = _cutplanes.begin(); 2949 doAll = true; 2950 } else { 2951 itr = _cutplanes.find(id); 2952 } 2953 2954 if (itr == _cutplanes.end()) { 2955 ERROR("Cutplane not found: %s", id.c_str()); 2956 return; 2957 } 2958 2959 do { 2960 itr->second->selectVolumeSlice(axis, ratio); 2961 } while (doAll && ++itr != _cutplanes.end()); 2962 2963 _renderer->ResetCameraClippingRange(); 2964 _needsRedraw = true; 2965 } 2966 2967 /** 2968 * \brief Associate an existing named color map with a Cutplane for the given DataSet 2969 */ 2970 void Renderer::setCutplaneColorMap(const DataSetId& id, const ColorMapId& colorMapId) 2971 { 2972 CutplaneHashmap::iterator itr; 2973 2974 bool doAll = false; 2975 2976 if (id.compare("all") == 0) { 2977 itr = _cutplanes.begin(); 2978 doAll = true; 2979 } else { 2980 itr = _cutplanes.find(id); 2981 } 2982 2983 if (itr == _cutplanes.end()) { 2984 ERROR("Cutplane not found: %s", id.c_str()); 2985 return; 2986 } 2987 2988 ColorMap *cmap = getColorMap(colorMapId); 2989 if (cmap == NULL) { 2990 ERROR("Unknown colormap: %s", colorMapId.c_str()); 2991 return; 2992 } 2993 2994 do { 2995 TRACE("Set Cutplane color map: %s for dataset %s", colorMapId.c_str(), 2996 itr->second->getDataSet()->getName().c_str()); 2997 2998 itr->second->setColorMap(cmap); 2999 } while (doAll && ++itr != _cutplanes.end()); 3000 3001 _needsRedraw = true; 3002 } 3003 3004 /** 3005 * \brief Set the color mode for the specified DataSet 3006 */ 3007 void Renderer::setCutplaneColorMode(const DataSetId& id, Cutplane::ColorMode mode) 3008 { 3009 CutplaneHashmap::iterator itr; 3010 3011 bool doAll = false; 3012 3013 if (id.compare("all") == 0) { 3014 itr = _cutplanes.begin(); 3015 doAll = true; 3016 } else { 3017 itr = _cutplanes.find(id); 3018 } 3019 if (itr == _cutplanes.end()) { 3020 ERROR("Cutplane not found: %s", id.c_str()); 3021 return; 3022 } 3023 3024 do { 3025 itr->second->setColorMode(mode); 3026 } while (doAll && ++itr != _cutplanes.end()); 3027 3028 _needsRedraw = true; 3029 } 3030 3031 /** 3032 * \brief Set opacity of height map for the given DataSet 3033 */ 3034 void Renderer::setCutplaneOpacity(const DataSetId& id, double opacity) 3035 { 3036 CutplaneHashmap::iterator itr; 3037 3038 bool doAll = false; 3039 3040 if (id.compare("all") == 0) { 3041 itr = _cutplanes.begin(); 3042 doAll = true; 3043 } else { 3044 itr = _cutplanes.find(id); 3045 } 3046 if (itr == _cutplanes.end()) { 3047 ERROR("Cutplane not found: %s", id.c_str()); 3048 return; 3049 } 3050 3051 do { 3052 itr->second->setOpacity(opacity); 3053 } while (doAll && ++itr != _cutplanes.end()); 3054 3055 _needsRedraw = true; 3056 } 3057 3058 /** 3059 * \brief Turn on/off rendering height map for the given DataSet 3060 */ 3061 void Renderer::setCutplaneVisibility(const DataSetId& id, bool state) 3062 { 3063 CutplaneHashmap::iterator itr; 3064 3065 bool doAll = false; 3066 3067 if (id.compare("all") == 0) { 3068 itr = _cutplanes.begin(); 3069 doAll = true; 3070 } else { 3071 itr = _cutplanes.find(id); 3072 } 3073 if (itr == _cutplanes.end()) { 3074 ERROR("Cutplane not found: %s", id.c_str()); 3075 return; 3076 } 3077 3078 do { 3079 itr->second->setVisibility(state); 3080 } while (doAll && ++itr != _cutplanes.end()); 3081 3082 _needsRedraw = true; 3083 } 3084 3085 /** 3086 * \brief Set wireframe rendering for the specified DataSet 3087 */ 3088 void Renderer::setCutplaneWireframe(const DataSetId& id, bool state) 3089 { 3090 CutplaneHashmap::iterator itr; 3091 3092 bool doAll = false; 3093 3094 if (id.compare("all") == 0) { 3095 itr = _cutplanes.begin(); 3096 doAll = true; 3097 } else { 3098 itr = _cutplanes.find(id); 3099 } 3100 if (itr == _cutplanes.end()) { 3101 ERROR("Cutplane not found: %s", id.c_str()); 3102 return; 3103 } 3104 3105 do { 3106 itr->second->setWireframe(state); 3107 } while (doAll && ++itr != _cutplanes.end()); 3108 3109 _needsRedraw = true; 3110 } 3111 3112 /** 3113 * \brief Turn on/off rendering height map mesh edges for the given DataSet 3114 */ 3115 void Renderer::setCutplaneEdgeVisibility(const DataSetId& id, bool state) 3116 { 3117 CutplaneHashmap::iterator itr; 3118 3119 bool doAll = false; 3120 3121 if (id.compare("all") == 0) { 3122 itr = _cutplanes.begin(); 3123 doAll = true; 3124 } else { 3125 itr = _cutplanes.find(id); 3126 } 3127 if (itr == _cutplanes.end()) { 3128 ERROR("Cutplane not found: %s", id.c_str()); 3129 return; 3130 } 3131 3132 do { 3133 itr->second->setEdgeVisibility(state); 3134 } while (doAll && ++itr != _cutplanes.end()); 3135 3136 _needsRedraw = true; 3137 } 3138 3139 /** 3140 * \brief Set the RGB height map mesh edge color for the specified DataSet 3141 */ 3142 void Renderer::setCutplaneEdgeColor(const DataSetId& id, float color[3]) 3143 { 3144 CutplaneHashmap::iterator itr; 3145 3146 bool doAll = false; 3147 3148 if (id.compare("all") == 0) { 3149 itr = _cutplanes.begin(); 3150 doAll = true; 3151 } else { 3152 itr = _cutplanes.find(id); 3153 } 3154 if (itr == _cutplanes.end()) { 3155 ERROR("Cutplane not found: %s", id.c_str()); 3156 return; 3157 } 3158 3159 do { 3160 itr->second->setEdgeColor(color); 3161 } while (doAll && ++itr != _cutplanes.end()); 3162 3163 _needsRedraw = true; 3164 } 3165 3166 /** 3167 * \brief Set the height map mesh edge width for the specified DataSet (may be a no-op) 3168 * 3169 * If the OpenGL implementation/hardware does not support wide lines, 3170 * this function may not have an effect. 3171 */ 3172 void Renderer::setCutplaneEdgeWidth(const DataSetId& id, float edgeWidth) 3173 { 3174 CutplaneHashmap::iterator itr; 3175 3176 bool doAll = false; 3177 3178 if (id.compare("all") == 0) { 3179 itr = _cutplanes.begin(); 3180 doAll = true; 3181 } else { 3182 itr = _cutplanes.find(id); 3183 } 3184 if (itr == _cutplanes.end()) { 3185 ERROR("Cutplane not found: %s", id.c_str()); 3186 return; 3187 } 3188 3189 do { 3190 itr->second->setEdgeWidth(edgeWidth); 3191 } while (doAll && ++itr != _cutplanes.end()); 3192 3193 _needsRedraw = true; 3194 } 3195 3196 /** 3197 * \brief Turn height map lighting on/off for the specified DataSet 3198 */ 3199 void Renderer::setCutplaneLighting(const DataSetId& id, bool state) 3200 { 3201 CutplaneHashmap::iterator itr; 3202 3203 bool doAll = false; 3204 3205 if (id.compare("all") == 0) { 3206 itr = _cutplanes.begin(); 3207 doAll = true; 3208 } else { 3209 itr = _cutplanes.find(id); 3210 } 3211 if (itr == _cutplanes.end()) { 3212 ERROR("Cutplane not found: %s", id.c_str()); 3213 return; 3214 } 3215 3216 do { 3217 itr->second->setLighting(state); 3218 } while (doAll && ++itr != _cutplanes.end()); 3219 _needsRedraw = true; 3220 } 3221 3222 /** 2674 3223 * \brief Create a new Glyphs and associate it with the named DataSet 2675 3224 */ … … 2717 3266 } while (doAll && ++itr != _dataSets.end()); 2718 3267 2719 if (_cameraMode == IMAGE)2720 setCameraMode(PERSPECTIVE);2721 3268 initCamera(); 2722 3269 … … 3322 3869 } while (doAll && ++itr != _dataSets.end()); 3323 3870 3324 if (_cameraMode == IMAGE)3325 setCameraMode(PERSPECTIVE);3326 3871 initCamera(); 3327 3872 … … 3376 3921 } while (doAll && ++itr != _dataSets.end()); 3377 3922 3378 if (_cameraMode == IMAGE)3379 setCameraMode(PERSPECTIVE);3380 3923 initCamera(); 3381 3924 … … 3561 4104 } 3562 4105 4106 bool initCam = false; 3563 4107 do { 3564 4108 itr->second->selectVolumeSlice(axis, ratio); 4109 if (itr->second->getHeightScale() > 0.0) 4110 initCam = true; 3565 4111 } while (doAll && ++itr != _heightMaps.end()); 3566 4112 3567 initCamera(); 4113 if (initCam) 4114 initCamera(); 4115 else 4116 _renderer->ResetCameraClippingRange(); 3568 4117 _needsRedraw = true; 3569 4118 } … … 4032 4581 } while (doAll && ++itr != _dataSets.end()); 4033 4582 4034 if (_cameraMode == IMAGE)4035 setCameraMode(PERSPECTIVE);4036 4583 initCamera(); 4037 4584 _needsRedraw = true; … … 4220 4767 } while (doAll && ++itr != _lics.end()); 4221 4768 4222 initCamera();4769 _renderer->ResetCameraClippingRange(); 4223 4770 _needsRedraw = true; 4224 4771 } … … 4462 5009 } while (doAll && ++itr != _dataSets.end()); 4463 5010 4464 if (_cameraMode == IMAGE)4465 setCameraMode(PERSPECTIVE);4466 5011 initCamera(); 4467 5012 _needsRedraw = true; … … 4971 5516 } while (doAll && ++itr != _dataSets.end()); 4972 5517 4973 if (_cameraMode == IMAGE)4974 setCameraMode(PERSPECTIVE);4975 5518 initCamera(); 4976 5519 _needsRedraw = true; … … 6073 6616 6074 6617 /** 6618 * \brief Set the streamlines seed to points of the streamlines DataSet 6619 */ 6620 void Renderer::setStreamlinesSeedToMeshPoints(const DataSetId& id) 6621 { 6622 StreamlinesHashmap::iterator itr; 6623 6624 bool doAll = false; 6625 6626 if (id.compare("all") == 0) { 6627 itr = _streamlines.begin(); 6628 doAll = true; 6629 } else { 6630 itr = _streamlines.find(id); 6631 } 6632 if (itr == _streamlines.end()) { 6633 ERROR("Streamlines not found: %s", id.c_str()); 6634 return; 6635 } 6636 6637 do { 6638 itr->second->setSeedToMeshPoints(); 6639 } while (doAll && ++itr != _streamlines.end()); 6640 6641 _needsRedraw = true; 6642 } 6643 6644 /** 6645 * \brief Set the streamlines seed to points distributed randomly inside 6646 * cells of the streamlines DataSet 6647 */ 6648 void Renderer::setStreamlinesSeedToFilledMesh(const DataSetId& id, int numPoints) 6649 { 6650 StreamlinesHashmap::iterator itr; 6651 6652 bool doAll = false; 6653 6654 if (id.compare("all") == 0) { 6655 itr = _streamlines.begin(); 6656 doAll = true; 6657 } else { 6658 itr = _streamlines.find(id); 6659 } 6660 if (itr == _streamlines.end()) { 6661 ERROR("Streamlines not found: %s", id.c_str()); 6662 return; 6663 } 6664 6665 do { 6666 itr->second->setSeedToFilledMesh(numPoints); 6667 } while (doAll && ++itr != _streamlines.end()); 6668 6669 _needsRedraw = true; 6670 } 6671 6672 /** 6673 * \brief Set the streamlines seed to points of a DataSet 6674 * 6675 * \param[in] id DataSet identifier 6676 * \param[in] data Bytes of VTK DataSet file 6677 * \param[in] nbytes Length of data array 6678 * 6679 * \return boolean indicating success or failure 6680 */ 6681 bool Renderer::setStreamlinesSeedToMeshPoints(const DataSetId& id, 6682 char *data, size_t nbytes) 6683 { 6684 vtkSmartPointer<vtkDataSetReader> reader = vtkSmartPointer<vtkDataSetReader>::New(); 6685 vtkSmartPointer<vtkCharArray> dataSetString = vtkSmartPointer<vtkCharArray>::New(); 6686 6687 dataSetString->SetArray(data, nbytes, 1); 6688 reader->SetInputArray(dataSetString); 6689 reader->ReadFromInputStringOn(); 6690 reader->Update(); 6691 6692 vtkSmartPointer<vtkDataSet> dataSet = reader->GetOutput(); 6693 if (dataSet == NULL) { 6694 return false; 6695 } 6696 dataSet->SetPipelineInformation(NULL); 6697 6698 StreamlinesHashmap::iterator itr; 6699 6700 bool doAll = false; 6701 6702 if (id.compare("all") == 0) { 6703 itr = _streamlines.begin(); 6704 doAll = true; 6705 } else { 6706 itr = _streamlines.find(id); 6707 } 6708 if (itr == _streamlines.end()) { 6709 ERROR("Streamlines not found: %s", id.c_str()); 6710 return false; 6711 } 6712 6713 do { 6714 itr->second->setSeedToMeshPoints(dataSet); 6715 } while (doAll && ++itr != _streamlines.end()); 6716 6717 _needsRedraw = true; 6718 return true; 6719 } 6720 6721 /** 6075 6722 * \brief Set the streamlines seed to points distributed randomly inside 6076 6723 * cells of DataSet 6077 */ 6078 void Renderer::setStreamlinesSeedToRandomPoints(const DataSetId& id, int numPoints) 6079 { 6724 * 6725 * \param[in] id DataSet identifier 6726 * \param[in] data Bytes of VTK DataSet file 6727 * \param[in] nbytes Length of data array 6728 * \param[in] numPoints Number of random seed points to generate 6729 * 6730 * \return boolean indicating success or failure 6731 */ 6732 bool Renderer::setStreamlinesSeedToFilledMesh(const DataSetId& id, 6733 char *data, size_t nbytes, 6734 int numPoints) 6735 { 6736 vtkSmartPointer<vtkDataSetReader> reader = vtkSmartPointer<vtkDataSetReader>::New(); 6737 vtkSmartPointer<vtkCharArray> dataSetString = vtkSmartPointer<vtkCharArray>::New(); 6738 6739 dataSetString->SetArray(data, nbytes, 1); 6740 reader->SetInputArray(dataSetString); 6741 reader->ReadFromInputStringOn(); 6742 reader->Update(); 6743 6744 vtkSmartPointer<vtkDataSet> dataSet = reader->GetOutput(); 6745 if (dataSet == NULL) { 6746 return false; 6747 } 6748 dataSet->SetPipelineInformation(NULL); 6749 6080 6750 StreamlinesHashmap::iterator itr; 6081 6751 … … 6090 6760 if (itr == _streamlines.end()) { 6091 6761 ERROR("Streamlines not found: %s", id.c_str()); 6092 return ;6093 } 6094 6095 do { 6096 itr->second->setSeedTo RandomPoints(numPoints);6762 return false; 6763 } 6764 6765 do { 6766 itr->second->setSeedToFilledMesh(dataSet, numPoints); 6097 6767 } while (doAll && ++itr != _streamlines.end()); 6098 6768 6099 6769 _needsRedraw = true; 6770 return true; 6100 6771 } 6101 6772 … … 6681 7352 } while (doAll && ++itr != _dataSets.end()); 6682 7353 6683 if (_cameraMode == IMAGE)6684 setCameraMode(PERSPECTIVE);6685 7354 initCamera(); 6686 7355 _needsRedraw = true; … … 7416 8085 _cameraOrientation[3] = 0.0; 7417 8086 } 7418 setViewAngle(_windowHeight);8087 //setViewAngle(_windowHeight); 7419 8088 double bounds[6]; 7420 8089 collectBounds(bounds, false); … … 7952 8621 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 7953 8622 } 8623 for (CutplaneHashmap::iterator itr = _cutplanes.begin(); 8624 itr != _cutplanes.end(); ++itr) { 8625 if ((!onlyVisible || itr->second->getVisibility()) && 8626 itr->second->getProp() != NULL) 8627 mergeBounds(bounds, bounds, itr->second->getProp()->GetBounds()); 8628 } 7954 8629 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 7955 8630 itr != _glyphs.end(); ++itr) { … … 8048 8723 for (Contour3DHashmap::iterator itr = _contour3Ds.begin(); 8049 8724 itr != _contour3Ds.end(); ++itr) { 8725 itr->second->updateRanges(_useCumulativeRange, 8726 _cumulativeScalarRange, 8727 _cumulativeVectorMagnitudeRange, 8728 _cumulativeVectorComponentRange); 8729 } 8730 for (CutplaneHashmap::iterator itr = _cutplanes.begin(); 8731 itr != _cutplanes.end(); ++itr) { 8050 8732 itr->second->updateRanges(_useCumulativeRange, 8051 8733 _cumulativeScalarRange, … … 8383 9065 if (id.compare("all") == 0 || getContour3D(id) != NULL) 8384 9066 setContour3DOpacity(id, opacity); 9067 if (id.compare("all") == 0 || getCutplane(id) != NULL) 9068 setCutplaneOpacity(id, opacity); 8385 9069 if (id.compare("all") == 0 || getGlyphs(id) != NULL) 8386 9070 setGlyphsOpacity(id, opacity); … … 8431 9115 if (id.compare("all") == 0 || getContour3D(id) != NULL) 8432 9116 setContour3DVisibility(id, state); 9117 if (id.compare("all") == 0 || getCutplane(id) != NULL) 9118 setCutplaneVisibility(id, state); 8433 9119 if (id.compare("all") == 0 || getGlyphs(id) != NULL) 8434 9120 setGlyphsVisibility(id, state); … … 8537 9223 } 8538 9224 } else { 8539 if (ratio > 0.0) {9225 if (ratio < 1.0) { 8540 9226 if (_userClipPlanes[1] == NULL) { 8541 9227 _userClipPlanes[1] = vtkSmartPointer<vtkPlane>::New(); … … 8560 9246 } 8561 9247 } else { 8562 if (ratio > 0.0) {9248 if (ratio < 1.0) { 8563 9249 if (_userClipPlanes[3] == NULL) { 8564 9250 _userClipPlanes[3] = vtkSmartPointer<vtkPlane>::New(); … … 8583 9269 } 8584 9270 } else { 8585 if (ratio > 0.0) {9271 if (ratio < 1.0) { 8586 9272 if (_userClipPlanes[5] == NULL) { 8587 9273 _userClipPlanes[5] = vtkSmartPointer<vtkPlane>::New(); … … 8639 9325 itr->second->setClippingPlanes(_activeClipPlanes); 8640 9326 } 9327 for (CutplaneHashmap::iterator itr = _cutplanes.begin(); 9328 itr != _cutplanes.end(); ++itr) { 9329 itr->second->setClippingPlanes(_activeClipPlanes); 9330 } 8641 9331 for (GlyphsHashmap::iterator itr = _glyphs.begin(); 8642 9332 itr != _glyphs.end(); ++itr) { -
branches/blt4/packages/vizservers/vtkvis/RpVtkRenderer.h
r2542 r2550 29 29 #include "RpContour2D.h" 30 30 #include "RpContour3D.h" 31 #include "RpCutplane.h" 31 32 #include "RpGlyphs.h" 32 33 #include "RpHeightMap.h" … … 101 102 typedef std::tr1::unordered_map<DataSetId, Contour2D *> Contour2DHashmap; 102 103 typedef std::tr1::unordered_map<DataSetId, Contour3D *> Contour3DHashmap; 104 typedef std::tr1::unordered_map<DataSetId, Cutplane *> CutplaneHashmap; 103 105 typedef std::tr1::unordered_map<DataSetId, Glyphs *> GlyphsHashmap; 104 106 typedef std::tr1::unordered_map<DataSetId, HeightMap *> HeightMapHashmap; … … 164 166 void setViewAngle(int height); 165 167 168 vtkCamera *getVtkCamera() 169 { 170 if (_renderer != NULL) 171 return _renderer->GetActiveCamera(); 172 else 173 return NULL; 174 } 175 166 176 void setCameraMode(CameraMode mode); 167 177 … … 333 343 void setContour3DColorMap(const DataSetId& id, const ColorMapId& colorMapId); 334 344 345 // Cutplanes 346 347 bool addCutplane(const DataSetId& id); 348 349 void deleteCutplane(const DataSetId& id); 350 351 Cutplane *getCutplane(const DataSetId& id); 352 353 void setCutplaneTransform(const DataSetId& id, vtkMatrix4x4 *trans); 354 355 void setCutplaneOrientation(const DataSetId& id, double quat[4]); 356 357 void setCutplaneOrientation(const DataSetId& id, double angle, double axis[3]); 358 359 void setCutplanePosition(const DataSetId& id, double pos[3]); 360 361 void setCutplaneScale(const DataSetId& id, double scale[3]); 362 363 void setCutplaneEdgeVisibility(const DataSetId& id, bool state); 364 365 void setCutplaneEdgeColor(const DataSetId& id, float color[3]); 366 367 void setCutplaneEdgeWidth(const DataSetId& id, float edgeWidth); 368 369 void setCutplaneLighting(const DataSetId& id, bool state); 370 371 void setCutplaneOpacity(const DataSetId& id, double opacity); 372 373 void setCutplaneVisibility(const DataSetId& id, bool state); 374 375 void setCutplaneWireframe(const DataSetId& id, bool state); 376 377 void setCutplaneVolumeSlice(const DataSetId& id, Cutplane::Axis axis, double ratio); 378 379 void setCutplaneColorMap(const DataSetId& id, const ColorMapId& colorMapId); 380 381 void setCutplaneColorMode(const DataSetId& id, Cutplane::ColorMode mode); 382 335 383 // Glyphs 336 384 … … 611 659 void setStreamlinesVisibility(const DataSetId& id, bool state); 612 660 613 void setStreamlinesSeedToRandomPoints(const DataSetId& id, int numPoints); 661 void setStreamlinesSeedToMeshPoints(const DataSetId& id); 662 663 void setStreamlinesSeedToFilledMesh(const DataSetId& id, int numPoints); 664 665 bool setStreamlinesSeedToMeshPoints(const DataSetId& id, 666 char *data, size_t nbytes); 667 668 bool setStreamlinesSeedToFilledMesh(const DataSetId& id, 669 char *data, size_t nbytes, 670 int numPoints); 614 671 615 672 void setStreamlinesSeedToRake(const DataSetId& id, … … 745 802 Contour2DHashmap _contour2Ds; 746 803 Contour3DHashmap _contour3Ds; 804 CutplaneHashmap _cutplanes; 747 805 GlyphsHashmap _glyphs; 748 806 HeightMapHashmap _heightMaps; -
branches/blt4/packages/vizservers/vtkvis/RpVtkRendererCmd.cpp
r2542 r2550 21 21 #include "RpVtkRendererCmd.h" 22 22 #include "RpVtkRenderServer.h" 23 #include "RpVtkRenderer.h" 23 24 #include "PPMWriter.h" 24 25 #include "TGAWriter.h" 25 #ifdef USE_THREADS26 #include "ResponseQueue.h"27 #endif28 26 29 27 using namespace Rappture::VtkVis; 30 31 static int lastCmdStatus;32 33 #ifdef USE_THREADS34 static void35 QueueResponse(ClientData clientData, const void *bytes, size_t len,36 Response::AllocationType allocType)37 {38 ResponseQueue *queue = (ResponseQueue *)clientData;39 40 Response *response;41 42 response = new Response(Response::DATA);43 response->setMessage((unsigned char *)bytes, len, allocType);44 queue->enqueue(response);45 }46 #else47 28 48 29 static ssize_t … … 62 43 } 63 44 64 #endif /*USE_THREADS*/ 45 static size_t 46 SocketRead(void *bytes, size_t len) 47 { 48 #ifdef notdef 49 size_t ofs = 0; 50 ssize_t bytesRead = 0; 51 while ((bytesRead = read(g_fdIn, bytes + ofs, len - ofs)) > 0) { 52 ofs += bytesRead; 53 if (ofs == len) 54 break; 55 } 56 TRACE("bytesRead: %lu", ofs); 57 return ofs; 58 #else 59 size_t bytesRead = fread(bytes, 1, len, g_fIn); 60 TRACE("bytesRead: %lu", bytesRead); 61 return bytesRead; 62 #endif 63 } 65 64 66 65 static int … … 69 68 int result; 70 69 71 TRACE("command: '%s'", Tcl_DStringValue(dsPtr)); 72 lastCmdStatus = TCL_OK; 73 result = Tcl_EvalEx(interp, Tcl_DStringValue(dsPtr), 74 Tcl_DStringLength(dsPtr), 75 TCL_EVAL_DIRECT | TCL_EVAL_GLOBAL); 70 result = Tcl_Eval(interp, Tcl_DStringValue(dsPtr)); 76 71 Tcl_DStringSetLength(dsPtr, 0); 77 if (lastCmdStatus == TCL_BREAK) { 78 return TCL_BREAK; 79 } 80 lastCmdStatus = result; 72 81 73 return result; 82 74 } … … 203 195 { 204 196 const char *title = Tcl_GetString(objv[3]); 197 if (strlen(title) > 30) { 198 Tcl_AppendResult(interp, "axis name \"", title, 199 "\" is too long", (char*)NULL); 200 return TCL_ERROR; 201 } 205 202 const char *string = Tcl_GetString(objv[2]); 206 203 char c = string[0]; … … 270 267 { 271 268 const char *units = Tcl_GetString(objv[3]); 269 if (strlen(units) > 10) { 270 Tcl_AppendResult(interp, "axis units name \"", units, 271 "\" is too long", (char*)NULL); 272 return TCL_ERROR; 273 } 272 274 const char *string = Tcl_GetString(objv[2]); 273 275 char c = string[0]; … … 277 279 g_renderer->setAxisUnits(Renderer::Y_AXIS, units); 278 280 } else if ((c == 'z') && (strcmp(string, "z") == 0)) { 281 g_renderer->setAxisUnits(Renderer::Z_AXIS, units); 282 } else if ((c == 'a') && (strcmp(string, "all") == 0)) { 283 g_renderer->setAxisUnits(Renderer::X_AXIS, units); 284 g_renderer->setAxisUnits(Renderer::Y_AXIS, units); 279 285 g_renderer->setAxisUnits(Renderer::Z_AXIS, units); 280 286 } else { … … 374 380 pos[0], pos[1], pos[2], focalPt[0], focalPt[1], focalPt[2], viewUp[0], viewUp[1], viewUp[2]); 375 381 376 #ifdef USE_THREADS377 QueueResponse(clientData, buf, strlen(buf), Response::VOLATILE);378 #else379 382 ssize_t bytesWritten = SocketWrite(buf, strlen(buf)); 383 380 384 if (bytesWritten < 0) { 381 385 return TCL_ERROR; 382 386 } 383 #endif384 387 return TCL_OK; 385 388 } … … 1266 1269 1267 1270 static int 1271 CutplaneAddOp(ClientData clientData, Tcl_Interp *interp, int objc, 1272 Tcl_Obj *const *objv) 1273 { 1274 if (objc == 3) { 1275 const char *name = Tcl_GetString(objv[2]); 1276 if (!g_renderer->addCutplane(name)) { 1277 Tcl_AppendResult(interp, "Failed to create cutplane", (char*)NULL); 1278 return TCL_ERROR; 1279 } 1280 } else { 1281 if (!g_renderer->addCutplane("all")) { 1282 Tcl_AppendResult(interp, "Failed to create cutplane for one or more data sets", (char*)NULL); 1283 return TCL_ERROR; 1284 } 1285 } 1286 return TCL_OK; 1287 } 1288 1289 static int 1290 CutplaneColorMapOp(ClientData clientData, Tcl_Interp *interp, int objc, 1291 Tcl_Obj *const *objv) 1292 { 1293 const char *colorMapName = Tcl_GetString(objv[2]); 1294 if (objc == 4) { 1295 const char *dataSetName = Tcl_GetString(objv[3]); 1296 g_renderer->setCutplaneColorMap(dataSetName, colorMapName); 1297 } else { 1298 g_renderer->setCutplaneColorMap("all", colorMapName); 1299 } 1300 return TCL_OK; 1301 } 1302 1303 static int 1304 CutplaneColorModeOp(ClientData clientData, Tcl_Interp *interp, int objc, 1305 Tcl_Obj *const *objv) 1306 { 1307 Cutplane::ColorMode mode; 1308 const char *str = Tcl_GetString(objv[2]); 1309 if (str[0] == 's' && strcmp(str, "scalar") == 0) { 1310 mode = Cutplane::COLOR_BY_SCALAR; 1311 } else if (str[0] == 'v' && strcmp(str, "vmag") == 0) { 1312 mode = Cutplane::COLOR_BY_VECTOR_MAGNITUDE; 1313 } else if (str[0] == 'v' && strcmp(str, "vx") == 0) { 1314 mode = Cutplane::COLOR_BY_VECTOR_X; 1315 } else if (str[0] == 'v' && strcmp(str, "vy") == 0) { 1316 mode = Cutplane::COLOR_BY_VECTOR_Y; 1317 } else if (str[0] == 'v' && strcmp(str, "vz") == 0) { 1318 mode = Cutplane::COLOR_BY_VECTOR_Z; 1319 } else { 1320 Tcl_AppendResult(interp, "bad color mode option \"", str, 1321 "\": should be one of: 'scalar', 'vmag', 'vx', 'vy', 'vz'", (char*)NULL); 1322 return TCL_ERROR; 1323 } 1324 if (objc == 4) { 1325 const char *name = Tcl_GetString(objv[3]); 1326 g_renderer->setCutplaneColorMode(name, mode); 1327 } else { 1328 g_renderer->setCutplaneColorMode("all", mode); 1329 } 1330 return TCL_OK; 1331 } 1332 1333 static int 1334 CutplaneDeleteOp(ClientData clientData, Tcl_Interp *interp, int objc, 1335 Tcl_Obj *const *objv) 1336 { 1337 if (objc == 3) { 1338 const char *name = Tcl_GetString(objv[2]); 1339 g_renderer->deleteCutplane(name); 1340 } else { 1341 g_renderer->deleteCutplane("all"); 1342 } 1343 return TCL_OK; 1344 } 1345 1346 static int 1347 CutplaneEdgeVisibilityOp(ClientData clientData, Tcl_Interp *interp, int objc, 1348 Tcl_Obj *const *objv) 1349 { 1350 bool state; 1351 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1352 return TCL_ERROR; 1353 } 1354 if (objc == 4) { 1355 const char *name = Tcl_GetString(objv[3]); 1356 g_renderer->setCutplaneEdgeVisibility(name, state); 1357 } else { 1358 g_renderer->setCutplaneEdgeVisibility("all", state); 1359 } 1360 return TCL_OK; 1361 } 1362 1363 static int 1364 CutplaneLightingOp(ClientData clientData, Tcl_Interp *interp, int objc, 1365 Tcl_Obj *const *objv) 1366 { 1367 bool state; 1368 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1369 return TCL_ERROR; 1370 } 1371 if (objc == 4) { 1372 const char *name = Tcl_GetString(objv[3]); 1373 g_renderer->setCutplaneLighting(name, state); 1374 } else { 1375 g_renderer->setCutplaneLighting("all", state); 1376 } 1377 return TCL_OK; 1378 } 1379 1380 static int 1381 CutplaneLineColorOp(ClientData clientData, Tcl_Interp *interp, int objc, 1382 Tcl_Obj *const *objv) 1383 { 1384 float color[3]; 1385 if (GetFloatFromObj(interp, objv[2], &color[0]) != TCL_OK || 1386 GetFloatFromObj(interp, objv[3], &color[1]) != TCL_OK || 1387 GetFloatFromObj(interp, objv[4], &color[2]) != TCL_OK) { 1388 return TCL_ERROR; 1389 } 1390 if (objc == 6) { 1391 const char *name = Tcl_GetString(objv[5]); 1392 g_renderer->setCutplaneEdgeColor(name, color); 1393 } else { 1394 g_renderer->setCutplaneEdgeColor("all", color); 1395 } 1396 return TCL_OK; 1397 } 1398 1399 static int 1400 CutplaneLineWidthOp(ClientData clientData, Tcl_Interp *interp, int objc, 1401 Tcl_Obj *const *objv) 1402 { 1403 float width; 1404 if (GetFloatFromObj(interp, objv[2], &width) != TCL_OK) { 1405 return TCL_ERROR; 1406 } 1407 if (objc == 4) { 1408 const char *name = Tcl_GetString(objv[3]); 1409 g_renderer->setCutplaneEdgeWidth(name, width); 1410 } else { 1411 g_renderer->setCutplaneEdgeWidth("all", width); 1412 } 1413 return TCL_OK; 1414 } 1415 1416 static int 1417 CutplaneOpacityOp(ClientData clientData, Tcl_Interp *interp, int objc, 1418 Tcl_Obj *const *objv) 1419 { 1420 double opacity; 1421 if (Tcl_GetDoubleFromObj(interp, objv[2], &opacity) != TCL_OK) { 1422 return TCL_ERROR; 1423 } 1424 if (objc == 4) { 1425 const char *name = Tcl_GetString(objv[3]); 1426 g_renderer->setCutplaneOpacity(name, opacity); 1427 } else { 1428 g_renderer->setCutplaneOpacity("all", opacity); 1429 } 1430 return TCL_OK; 1431 } 1432 1433 static int 1434 CutplaneOrientOp(ClientData clientData, Tcl_Interp *interp, int objc, 1435 Tcl_Obj *const *objv) 1436 { 1437 double quat[4]; 1438 if (Tcl_GetDoubleFromObj(interp, objv[2], &quat[0]) != TCL_OK || 1439 Tcl_GetDoubleFromObj(interp, objv[3], &quat[1]) != TCL_OK || 1440 Tcl_GetDoubleFromObj(interp, objv[4], &quat[2]) != TCL_OK || 1441 Tcl_GetDoubleFromObj(interp, objv[5], &quat[3]) != TCL_OK) { 1442 return TCL_ERROR; 1443 } 1444 if (objc == 7) { 1445 const char *name = Tcl_GetString(objv[6]); 1446 g_renderer->setCutplaneOrientation(name, quat); 1447 } else { 1448 g_renderer->setCutplaneOrientation("all", quat); 1449 } 1450 return TCL_OK; 1451 } 1452 1453 static int 1454 CutplanePositionOp(ClientData clientData, Tcl_Interp *interp, int objc, 1455 Tcl_Obj *const *objv) 1456 { 1457 double pos[3]; 1458 if (Tcl_GetDoubleFromObj(interp, objv[2], &pos[0]) != TCL_OK || 1459 Tcl_GetDoubleFromObj(interp, objv[3], &pos[1]) != TCL_OK || 1460 Tcl_GetDoubleFromObj(interp, objv[4], &pos[2]) != TCL_OK) { 1461 return TCL_ERROR; 1462 } 1463 if (objc == 6) { 1464 const char *name = Tcl_GetString(objv[5]); 1465 g_renderer->setCutplanePosition(name, pos); 1466 } else { 1467 g_renderer->setCutplanePosition("all", pos); 1468 } 1469 return TCL_OK; 1470 } 1471 1472 static int 1473 CutplaneScaleOp(ClientData clientData, Tcl_Interp *interp, int objc, 1474 Tcl_Obj *const *objv) 1475 { 1476 double scale[3]; 1477 if (Tcl_GetDoubleFromObj(interp, objv[2], &scale[0]) != TCL_OK || 1478 Tcl_GetDoubleFromObj(interp, objv[3], &scale[1]) != TCL_OK || 1479 Tcl_GetDoubleFromObj(interp, objv[4], &scale[2]) != TCL_OK) { 1480 return TCL_ERROR; 1481 } 1482 if (objc == 6) { 1483 const char *name = Tcl_GetString(objv[5]); 1484 g_renderer->setCutplaneScale(name, scale); 1485 } else { 1486 g_renderer->setCutplaneScale("all", scale); 1487 } 1488 return TCL_OK; 1489 } 1490 1491 static int 1492 CutplaneVisibleOp(ClientData clientData, Tcl_Interp *interp, int objc, 1493 Tcl_Obj *const *objv) 1494 { 1495 bool state; 1496 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1497 return TCL_ERROR; 1498 } 1499 if (objc == 4) { 1500 const char *name = Tcl_GetString(objv[3]); 1501 g_renderer->setCutplaneVisibility(name, state); 1502 } else { 1503 g_renderer->setCutplaneVisibility("all", state); 1504 } 1505 return TCL_OK; 1506 } 1507 1508 static int 1509 CutplaneVolumeSliceOp(ClientData clientData, Tcl_Interp *interp, int objc, 1510 Tcl_Obj *const *objv) 1511 { 1512 double ratio; 1513 if (Tcl_GetDoubleFromObj(interp, objv[3], &ratio) != TCL_OK) { 1514 return TCL_ERROR; 1515 } 1516 const char *string = Tcl_GetString(objv[2]); 1517 char c = string[0]; 1518 Cutplane::Axis axis; 1519 if ((c == 'x') && (strcmp(string, "x") == 0)) { 1520 axis = Cutplane::X_AXIS; 1521 } else if ((c == 'y') && (strcmp(string, "y") == 0)) { 1522 axis = Cutplane::Y_AXIS; 1523 } else if ((c == 'z') && (strcmp(string, "z") == 0)) { 1524 axis = Cutplane::Z_AXIS; 1525 } else { 1526 Tcl_AppendResult(interp, "bad axis option \"", string, 1527 "\": should be axisName ratio", (char*)NULL); 1528 return TCL_ERROR; 1529 } 1530 if (objc == 5) { 1531 const char *name = Tcl_GetString(objv[4]); 1532 g_renderer->setCutplaneVolumeSlice(name, axis, ratio); 1533 } else { 1534 g_renderer->setCutplaneVolumeSlice("all", axis, ratio); 1535 } 1536 return TCL_OK; 1537 } 1538 1539 static int 1540 CutplaneWireframeOp(ClientData clientData, Tcl_Interp *interp, int objc, 1541 Tcl_Obj *const *objv) 1542 { 1543 bool state; 1544 if (GetBooleanFromObj(interp, objv[2], &state) != TCL_OK) { 1545 return TCL_ERROR; 1546 } 1547 if (objc == 4) { 1548 const char *name = Tcl_GetString(objv[3]); 1549 g_renderer->setCutplaneWireframe(name, state); 1550 } else { 1551 g_renderer->setCutplaneWireframe("all", state); 1552 } 1553 return TCL_OK; 1554 } 1555 1556 static Rappture::CmdSpec cutplaneOps[] = { 1557 {"add", 1, CutplaneAddOp, 2, 3, "oper value ?dataSetName?"}, 1558 {"colormap", 7, CutplaneColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 1559 {"colormode", 7, CutplaneColorModeOp, 3, 4, "mode ?dataSetNme?"}, 1560 {"delete", 1, CutplaneDeleteOp, 2, 3, "?dataSetName?"}, 1561 {"edges", 1, CutplaneEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"}, 1562 {"lighting", 3, CutplaneLightingOp, 3, 4, "bool ?dataSetName?"}, 1563 {"linecolor", 5, CutplaneLineColorOp, 5, 6, "r g b ?dataSetName?"}, 1564 {"linewidth", 5, CutplaneLineWidthOp, 3, 4, "width ?dataSetName?"}, 1565 {"opacity", 2, CutplaneOpacityOp, 3, 4, "value ?dataSetName?"}, 1566 {"orient", 2, CutplaneOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 1567 {"pos", 1, CutplanePositionOp, 5, 6, "x y z ?dataSetName?"}, 1568 {"scale", 2, CutplaneScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 1569 {"slice", 2, CutplaneVolumeSliceOp, 4, 5, "axis ratio ?dataSetName?"}, 1570 {"visible", 1, CutplaneVisibleOp, 3, 4, "bool ?dataSetName?"}, 1571 {"wireframe", 1, CutplaneWireframeOp, 3, 4, "bool ?dataSetName?"} 1572 }; 1573 static int nCutplaneOps = NumCmdSpecs(cutplaneOps); 1574 1575 static int 1576 CutplaneCmd(ClientData clientData, Tcl_Interp *interp, int objc, 1577 Tcl_Obj *const *objv) 1578 { 1579 Tcl_ObjCmdProc *proc; 1580 1581 proc = Rappture::GetOpFromObj(interp, nCutplaneOps, cutplaneOps, 1582 Rappture::CMDSPEC_ARG1, objc, objv, 0); 1583 if (proc == NULL) { 1584 return TCL_ERROR; 1585 } 1586 return (*proc) (clientData, interp, objc, objv); 1587 } 1588 1589 static int 1268 1590 DataSetActiveScalarsOp(ClientData clientData, Tcl_Interp *interp, int objc, 1269 1591 Tcl_Obj *const *objv) … … 1334 1656 } 1335 1657 char *data = (char *)malloc(nbytes); 1336 size_t bytesRead = fread(data, 1, nbytes, g_fIn); 1337 TRACE("bytesRead: %d", bytesRead); 1338 if (bytesRead < (size_t)nbytes) { 1658 size_t bytesRead = SocketRead(data, nbytes); 1659 if (bytesRead < 0) { 1339 1660 free(data); 1340 1661 return TCL_ERROR; … … 1377 1698 1378 1699 char buf[256]; 1379 int length; 1380 1381 length = snprintf(buf, sizeof(buf), "nv>dataset scalar pixel %d %d %g %s\n", 1382 x, y, value, name); 1383 1384 #ifdef USE_THREADS 1385 QueueResponse(clientData, buf, length, Response::VOLATILE); 1386 #else 1387 ssize_t bytesWritten = SocketWrite(buf, length); 1700 snprintf(buf, sizeof(buf), "nv>dataset scalar pixel %d %d %g %s\n", x, y, value, name); 1701 1702 ssize_t bytesWritten = SocketWrite(buf, strlen(buf)); 1388 1703 1389 1704 if (bytesWritten < 0) { 1390 1705 return TCL_ERROR; 1391 1706 } 1392 #endif1393 1707 return TCL_OK; 1394 1708 } … … 1412 1726 1413 1727 char buf[256]; 1414 int length; 1415 1416 length = snprintf(buf, sizeof(buf), 1417 "nv>dataset scalar world %g %g %g %g %s\n", x, y, z, value, name); 1418 1419 #ifdef USE_THREADS 1420 QueueResponse(clientData, buf, length, Response::VOLATILE); 1421 #else 1422 ssize_t bytesWritten = SocketWrite(buf, length); 1728 snprintf(buf, sizeof(buf), "nv>dataset scalar world %g %g %g %g %s\n", x, y, z, value, name); 1729 1730 ssize_t bytesWritten = SocketWrite(buf, strlen(buf)); 1731 1423 1732 if (bytesWritten < 0) { 1424 1733 return TCL_ERROR; 1425 1734 } 1426 #endif1427 1735 return TCL_OK; 1428 1736 } … … 1465 1773 1466 1774 char buf[256]; 1467 int length; 1468 length = snprintf(buf, sizeof(buf), 1469 "nv>dataset vector pixel %d %d %g %g %g %s\n", x, y, value[0], 1470 value[1], value[2], name); 1471 1472 #ifdef USE_THREADS 1473 QueueResponse(clientData, buf, length, Response::VOLATILE); 1474 #else 1475 ssize_t bytesWritten = SocketWrite(buf, length); 1775 snprintf(buf, sizeof(buf), "nv>dataset vector pixel %d %d %g %g %g %s\n", x, y, 1776 value[0], value[1], value[2], name); 1777 1778 ssize_t bytesWritten = SocketWrite(buf, strlen(buf)); 1476 1779 1477 1780 if (bytesWritten < 0) { 1478 1781 return TCL_ERROR; 1479 1782 } 1480 #endif /*USE_THREADS*/1481 1783 return TCL_OK; 1482 1784 } … … 1500 1802 1501 1803 char buf[256]; 1502 int length; 1503 length = snprintf(buf, sizeof(buf), 1504 "nv>dataset vector world %g %g %g %g %g %g %s\n", x, y, z, 1505 value[0], value[1], value[2], name); 1506 #ifdef USE_THREADS 1507 QueueResponse(clientData, buf, length, Response::VOLATILE); 1508 #else 1509 ssize_t bytesWritten = SocketWrite(buf, length); 1804 snprintf(buf, sizeof(buf), "nv>dataset vector world %g %g %g %g %g %g %s\n", x, y, z, 1805 value[0], value[1], value[2], name); 1806 1807 ssize_t bytesWritten = SocketWrite(buf, strlen(buf)); 1510 1808 1511 1809 if (bytesWritten < 0) { 1512 1810 return TCL_ERROR; 1513 1811 } 1514 #endif /*USE_THREADS*/1515 1812 return TCL_OK; 1516 1813 } … … 1575 1872 oss << "}\n"; 1576 1873 len += 2; 1577 #ifdef USE_THREADS 1578 QueueResponse(clientData, oss.str().c_str(), len, Response::VOLATILE); 1579 #else 1580 ssize_t bytesWritten = SocketWrite(oss.str().c_str(), len); 1874 1875 size_t bytesWritten = SocketWrite(oss.str().c_str(), len); 1581 1876 1582 1877 if (bytesWritten < 0) { 1583 1878 return TCL_ERROR; 1584 1879 } 1585 #endif /*USE_THREADS*/1586 1880 return TCL_OK; 1587 1881 } … … 2589 2883 static Rappture::CmdSpec heightmapOps[] = { 2590 2884 {"add", 1, HeightMapAddOp, 5, 6, "oper value ?dataSetName?"}, 2591 {"colormap", 2, HeightMapColorMapOp, 3, 4, "colorMapName ?dataSetName?"},2592 {"contourlist", 2, HeightMapContourListOp, 3, 4, "contourList ?dataSetName?"},2885 {"colormap", 3, HeightMapColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 2886 {"contourlist", 3, HeightMapContourListOp, 3, 4, "contourList ?dataSetName?"}, 2593 2887 {"delete", 1, HeightMapDeleteOp, 2, 3, "?dataSetName?"}, 2594 2888 {"edges", 1, HeightMapEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"}, … … 2604 2898 {"orient", 2, HeightMapOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 2605 2899 {"pos", 1, HeightMapPositionOp, 5, 6, "x y z ?dataSetName?"}, 2606 {"scale", 1, HeightMapScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 2900 {"scale", 2, HeightMapScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 2901 {"slice", 2, HeightMapVolumeSliceOp, 4, 5, "axis ratio ?dataSetName?"}, 2607 2902 {"surface", 2, HeightMapContourSurfaceVisibleOp, 3, 4, "bool ?dataSetName?"}, 2608 {"visible", 2, HeightMapVisibleOp, 3, 4, "bool ?dataSetName?"}, 2609 {"volumeslice", 2, HeightMapVolumeSliceOp, 4, 5, "axis ratio ?dataSetName?"}, 2903 {"visible", 1, HeightMapVisibleOp, 3, 4, "bool ?dataSetName?"}, 2610 2904 {"wireframe", 1, HeightMapWireframeOp, 3, 4, "bool ?dataSetName?"} 2611 2905 }; … … 2624 2918 } 2625 2919 return (*proc) (clientData, interp, objc, objv); 2626 }2627 2628 static int2629 ImageFlushCmd(ClientData clientData, Tcl_Interp *interp, int objc,2630 Tcl_Obj *const *objv)2631 {2632 lastCmdStatus = TCL_BREAK;2633 return TCL_OK;2634 2920 } 2635 2921 … … 2695 2981 2696 2982 #ifdef DEBUG 2697 # ifdef RENDER_TARGA2698 2983 writeTGAFile("/tmp/legend.tga", imgData->GetPointer(0), width, height, 2699 2984 TARGA_BYTES_PER_PIXEL); 2700 # else2701 writeTGAFile("/tmp/legend.tga", imgData->GetPointer(0), width, height,2702 TARGA_BYTES_PER_PIXEL, true);2703 # endif2704 2985 #else 2705 2986 char cmd[256]; 2706 2987 snprintf(cmd, sizeof(cmd), "nv>legend {%s} {%s} %g %g", 2707 2988 colorMapName, title.c_str(), range[0], range[1]); 2708 2709 # ifdef USE_THREADS 2710 # ifdef RENDER_TARGA 2711 ResponseQueue *queue = (ResponseQueue *)clientData; 2712 queueTGA(queue, cmd, imgData->GetPointer(0), width, height, 2713 TARGA_BYTES_PER_PIXEL); 2714 # else 2715 ResponseQueue *queue = (ResponseQueue *)clientData; 2716 queuePPM(queue, cmd, imgData->GetPointer(0), width, height); 2717 # endif 2718 # else 2719 # ifdef RENDER_TARGA 2989 #ifdef RENDER_TARGA 2720 2990 writeTGA(g_fdOut, cmd, imgData->GetPointer(0), width, height, 2721 TARGA_BYTES_PER_PIXEL);2722 # 2991 TARGA_BYTES_PER_PIXEL); 2992 #else 2723 2993 writePPM(g_fdOut, cmd, imgData->GetPointer(0), width, height); 2724 # 2725 # endif // USE_THREADS2726 #endif // DEBUG 2994 #endif 2995 #endif 2996 2727 2997 return TCL_OK; 2728 2998 } … … 2978 3248 {"orient", 2, LICOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 2979 3249 {"pos", 1, LICPositionOp, 5, 6, "x y z ?dataSetName?"}, 2980 {"scale", 1, LICScaleOp, 5, 6, "sx sy sz ?dataSetName?"},2981 {" visible", 2, LICVisibleOp, 3, 4, "bool?dataSetName?"},2982 {"v olumeslice", 2, LICVolumeSliceOp, 4, 5, "axis ratio?dataSetName?"}3250 {"scale", 2, LICScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 3251 {"slice", 2, LICVolumeSliceOp, 4, 5, "axis ratio ?dataSetName?"}, 3252 {"visible", 1, LICVisibleOp, 3, 4, "bool ?dataSetName?"} 2983 3253 }; 2984 3254 static int nLICOps = NumCmdSpecs(licOps); … … 4386 4656 4387 4657 static int 4658 StreamlinesSeedFilledMeshOp(ClientData clientData, Tcl_Interp *interp, 4659 int objc, Tcl_Obj *const *objv) 4660 { 4661 int numPoints = 0; 4662 if (Tcl_GetIntFromObj(interp, objv[3], &numPoints) != TCL_OK || 4663 numPoints < 1) { 4664 return TCL_ERROR; 4665 } 4666 const char *string = Tcl_GetString(objv[4]); 4667 char c = string[0]; 4668 if ((c != 'd') || (strcmp(string, "data") != 0)) { 4669 Tcl_AppendResult(interp, "bad streamlines seed fmesh option \"", 4670 string, "\": should be data", (char*)NULL); 4671 return TCL_ERROR; 4672 } 4673 string = Tcl_GetString(objv[5]); 4674 c = string[0]; 4675 if ((c != 'f') || (strcmp(string, "follows") != 0)) { 4676 Tcl_AppendResult(interp, "bad streamlines seed fmesh option \"", 4677 string, "\": should be follows", (char*)NULL); 4678 return TCL_ERROR; 4679 } 4680 int nbytes = 0; 4681 if (Tcl_GetIntFromObj(interp, objv[6], &nbytes) != TCL_OK || 4682 nbytes < 0) { 4683 return TCL_ERROR; 4684 } 4685 char *data = (char *)malloc(nbytes); 4686 size_t bytesRead = SocketRead(data, nbytes); 4687 if (bytesRead < 0) { 4688 free(data); 4689 return TCL_ERROR; 4690 } 4691 if (objc == 8) { 4692 const char *name = Tcl_GetString(objv[7]); 4693 if (!g_renderer->setStreamlinesSeedToFilledMesh(name, data, nbytes, 4694 numPoints)) { 4695 free(data); 4696 Tcl_AppendResult(interp, "Couldn't read mesh data or streamlines not found", (char*)NULL); 4697 return TCL_ERROR; 4698 } 4699 } else { 4700 if (!g_renderer->setStreamlinesSeedToFilledMesh("all", data, nbytes, 4701 numPoints)) { 4702 free(data); 4703 Tcl_AppendResult(interp, "Couldn't read mesh data or streamlines not found", (char*)NULL); 4704 return TCL_ERROR; 4705 } 4706 } 4707 free(data); 4708 return TCL_OK; 4709 } 4710 4711 static int 4712 StreamlinesSeedMeshPointsOp(ClientData clientData, Tcl_Interp *interp, 4713 int objc, Tcl_Obj *const *objv) 4714 { 4715 const char *string = Tcl_GetString(objv[3]); 4716 char c = string[0]; 4717 if ((c != 'd') || (strcmp(string, "data") != 0)) { 4718 Tcl_AppendResult(interp, "bad streamlines seed fmesh option \"", 4719 string, "\": should be data", (char*)NULL); 4720 return TCL_ERROR; 4721 } 4722 string = Tcl_GetString(objv[4]); 4723 c = string[0]; 4724 if ((c != 'f') || (strcmp(string, "follows") != 0)) { 4725 Tcl_AppendResult(interp, "bad streamlines seed fmesh option \"", 4726 string, "\": should be follows", (char*)NULL); 4727 return TCL_ERROR; 4728 } 4729 int nbytes = 0; 4730 if (Tcl_GetIntFromObj(interp, objv[5], &nbytes) != TCL_OK || 4731 nbytes < 0) { 4732 return TCL_ERROR; 4733 } 4734 char *data = (char *)malloc(nbytes); 4735 size_t bytesRead = SocketRead(data, nbytes); 4736 if (bytesRead < 0) { 4737 free(data); 4738 return TCL_ERROR; 4739 } 4740 if (objc == 7) { 4741 const char *name = Tcl_GetString(objv[6]); 4742 if (!g_renderer->setStreamlinesSeedToMeshPoints(name, data, nbytes)) { 4743 free(data); 4744 Tcl_AppendResult(interp, "Couldn't read mesh data or streamlines not found", (char*)NULL); 4745 return TCL_ERROR; 4746 } 4747 } else { 4748 if (!g_renderer->setStreamlinesSeedToMeshPoints("all", data, nbytes)) { 4749 free(data); 4750 Tcl_AppendResult(interp, "Couldn't read mesh data or streamlines not found", (char*)NULL); 4751 return TCL_ERROR; 4752 } 4753 } 4754 free(data); 4755 return TCL_OK; 4756 } 4757 4758 static int 4759 StreamlinesSeedPointsOp(ClientData clientData, Tcl_Interp *interp, int objc, 4760 Tcl_Obj *const *objv) 4761 { 4762 if (objc == 4) { 4763 const char *name = Tcl_GetString(objv[3]); 4764 g_renderer->setStreamlinesSeedToMeshPoints(name); 4765 } else { 4766 g_renderer->setStreamlinesSeedToMeshPoints("all"); 4767 } 4768 return TCL_OK; 4769 } 4770 4771 static int 4388 4772 StreamlinesSeedPolygonOp(ClientData clientData, Tcl_Interp *interp, int objc, 4389 4773 Tcl_Obj *const *objv) … … 4498 4882 if (objc == 5) { 4499 4883 const char *name = Tcl_GetString(objv[4]); 4500 g_renderer->setStreamlinesSeedTo RandomPoints(name, numPoints);4501 } else { 4502 g_renderer->setStreamlinesSeedTo RandomPoints("all", numPoints);4884 g_renderer->setStreamlinesSeedToFilledMesh(name, numPoints); 4885 } else { 4886 g_renderer->setStreamlinesSeedToFilledMesh("all", numPoints); 4503 4887 } 4504 4888 return TCL_OK; … … 4525 4909 {"color", 1, StreamlinesSeedColorOp, 6, 7, "r g b ?dataSetName?"}, 4526 4910 {"disk", 1, StreamlinesSeedDiskOp, 12, 13, "centerX centerY centerZ normalX normalY normalZ radius innerRadius numPoints ?dataSetName?"}, 4527 {"fpoly", 1, StreamlinesSeedFilledPolygonOp, 13, 14, "centerX centerY centerZ normalX normalY normalZ angle radius numSides numPoints ?dataSetName?"}, 4528 {"polygon", 1, StreamlinesSeedPolygonOp, 12, 13, "centerX centerY centerZ normalX normalY normalZ angle radius numSides ?dataSetName?"}, 4911 {"fmesh", 2, StreamlinesSeedFilledMeshOp, 7, 8, "numPoints data follows nbytes ?dataSetName?"}, 4912 {"fpoly", 2, StreamlinesSeedFilledPolygonOp, 13, 14, "centerX centerY centerZ normalX normalY normalZ angle radius numSides numPoints ?dataSetName?"}, 4913 {"mesh", 1, StreamlinesSeedMeshPointsOp, 6, 7, "data follows nbytes ?dataSetName?"}, 4914 {"points", 3, StreamlinesSeedPointsOp, 3, 4, "?dataSetName?"}, 4915 {"polygon", 3, StreamlinesSeedPolygonOp, 12, 13, "centerX centerY centerZ normalX normalY normalZ angle radius numSides ?dataSetName?"}, 4529 4916 {"rake", 3, StreamlinesSeedRakeOp, 10, 11, "startX startY startZ endX endY endZ numPoints ?dataSetName?"}, 4530 4917 {"random", 3, StreamlinesSeedRandomOp, 4, 5, "numPoints ?dataSetName?"}, … … 4586 4973 4587 4974 static Rappture::CmdSpec streamlinesOps[] = { 4588 {"add", 1, StreamlinesAddOp, 4589 {"ccolor", 1, StreamlinesColorOp, 4590 {"colormap", 7, StreamlinesColorMapOp, 4975 {"add", 1, StreamlinesAddOp, 2, 3, "?dataSetName?"}, 4976 {"ccolor", 1, StreamlinesColorOp, 5, 6, "r g b ?dataSetName?"}, 4977 {"colormap", 7, StreamlinesColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 4591 4978 {"colormode", 7, StreamlinesColorModeOp, 3, 4, "mode ?dataSetNme?"}, 4592 {"delete", 1, StreamlinesDeleteOp, 4979 {"delete", 1, StreamlinesDeleteOp, 2, 3, "?dataSetName?"}, 4593 4980 {"edges", 1, StreamlinesEdgeVisibilityOp, 3, 4, "bool ?dataSetName?"}, 4594 {"length", 2, StreamlinesLengthOp, 4595 {"lighting", 3, StreamlinesLightingOp, 4981 {"length", 2, StreamlinesLengthOp, 3, 4, "length ?dataSetName?"}, 4982 {"lighting", 3, StreamlinesLightingOp, 3, 4, "bool ?dataSetName?"}, 4596 4983 {"linecolor", 5, StreamlinesLineColorOp, 5, 6, "r g b ?dataSetName?"}, 4597 {"lines", 5, StreamlinesLinesOp, 4984 {"lines", 5, StreamlinesLinesOp, 2, 3, "?dataSetName?"}, 4598 4985 {"linewidth", 5, StreamlinesLineWidthOp, 3, 4, "width ?dataSetName?"}, 4599 {"opacity", 2, StreamlinesOpacityOp, 4600 {"orient", 2, StreamlinesOrientOp, 4601 {"pos", 1, StreamlinesPositionOp, 4602 {"ribbons", 1, StreamlinesRibbonsOp, 4603 {"scale", 2, StreamlinesScaleOp, 4604 {"seed", 2, StreamlinesSeedOp, 4, 14, "op params... ?dataSetName?"},4986 {"opacity", 2, StreamlinesOpacityOp, 3, 4, "val ?dataSetName?"}, 4987 {"orient", 2, StreamlinesOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 4988 {"pos", 1, StreamlinesPositionOp, 5, 6, "x y z ?dataSetName?"}, 4989 {"ribbons", 1, StreamlinesRibbonsOp, 4, 5, "width angle ?dataSetName?"}, 4990 {"scale", 2, StreamlinesScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 4991 {"seed", 2, StreamlinesSeedOp, 3, 14, "op params... ?dataSetName?"}, 4605 4992 {"tubes", 1, StreamlinesTubesOp, 4, 5, "numSides radius ?dataSetName?"}, 4606 4993 {"visible", 1, StreamlinesVisibleOp, 3, 4, "bool ?dataSetName?"} … … 4816 5203 4817 5204 static Rappture::CmdSpec volumeShadingOps[] = { 4818 {"ambient", 1, VolumeShadingAmbientOp, 4819 {"diffuse", 1, VolumeShadingDiffuseOp, 5205 {"ambient", 1, VolumeShadingAmbientOp, 4, 5, "coeff ?dataSetName?"}, 5206 {"diffuse", 1, VolumeShadingDiffuseOp, 4, 5, "coeff ?dataSetName?"}, 4820 5207 {"specular", 1, VolumeShadingSpecularOp, 5, 6, "coeff power ?dataSetName?"} 4821 5208 }; … … 4854 5241 4855 5242 static Rappture::CmdSpec volumeOps[] = { 4856 {"add", 1, VolumeAddOp, 5243 {"add", 1, VolumeAddOp, 2, 3, "?dataSetName?"}, 4857 5244 {"colormap", 1, VolumeColorMapOp, 3, 4, "colorMapName ?dataSetName?"}, 4858 {"delete", 1, VolumeDeleteOp, 5245 {"delete", 1, VolumeDeleteOp, 2, 3, "?dataSetName?"}, 4859 5246 {"lighting", 1, VolumeLightingOp, 3, 4, "bool ?dataSetName?"}, 4860 {"opacity", 2, VolumeOpacityOp, 4861 {"orient", 2, VolumeOrientOp, 5247 {"opacity", 2, VolumeOpacityOp, 3, 4, "val ?dataSetName?"}, 5248 {"orient", 2, VolumeOrientOp, 6, 7, "qw qx qy qz ?dataSetName?"}, 4862 5249 {"pos", 1, VolumePositionOp, 5, 6, "x y z ?dataSetName?"}, 4863 {"scale", 2, VolumeScaleOp, 4864 {"shading", 2, VolumeShadingOp, 4865 {"visible", 1, VolumeVisibleOp, 5250 {"scale", 2, VolumeScaleOp, 5, 6, "sx sy sz ?dataSetName?"}, 5251 {"shading", 2, VolumeShadingOp, 4, 6, "oper val ?dataSetName?"}, 5252 {"visible", 1, VolumeVisibleOp, 3, 4, "bool ?dataSetName?"} 4866 5253 }; 4867 5254 static int nVolumeOps = NumCmdSpecs(volumeOps); … … 4883 5270 /** 4884 5271 * \brief Execute commands from client in Tcl interpreter 4885 *4886 * In this threaded model, the select call is for event compression. We4887 * want to execute render server commands as long as they keep coming.4888 * This lets us execute a stream of many commands but render once. This4889 * benefits camera movements, screen resizing, and opacity changes4890 * (using a slider on the client). The down side is you don't render4891 * until there's a lull in the command stream. If the client needs an4892 * image, it can issue an "imgflush" command. That breaks us out of the4893 * read loop.4894 5272 */ 4895 5273 int 4896 5274 Rappture::VtkVis::processCommands(Tcl_Interp *interp, FILE *fin, FILE *fout) 4897 5275 { 5276 Tcl_DString cmdbuffer; 5277 Tcl_DStringInit(&cmdbuffer); 5278 5279 int fdIn = fileno(fin); 5280 int fdOut = fileno(fout); 5281 int flags = fcntl(fdIn, F_GETFL, 0); 5282 fcntl(fdIn, F_SETFL, flags & ~O_NONBLOCK); 5283 4898 5284 int status = TCL_OK; 4899 4900 #define BUFFERSIZE ((1<<16)-1) 4901 char buffer[BUFFERSIZE+1]; 4902 4903 Tcl_DString command; 4904 Tcl_DStringInit(&command); 4905 4906 fd_set readFds; 4907 struct timeval tv, *tvPtr; 4908 4909 FD_ZERO(&readFds); 4910 FD_SET(fileno(fin), &readFds); 4911 tvPtr = NULL; /* Initially there is no timeout. */ 4912 while (select(1, &readFds, NULL, NULL, tvPtr) > 0) { 4913 if (fgets(buffer, BUFFERSIZE, fin) == NULL) { 4914 /* Terminate the server if we can't 4915 * communicate with the client 4916 * anymore. */ 4917 if (feof(fin)) { 4918 INFO("Exiting server on EOF from client"); 4919 exit(0); 4920 } else { 4921 ERROR("Exiting server, failed to read from client: %s", 4922 strerror(errno)); 4923 exit(1); 5285 int nCommands = 0; 5286 bool isComplete = false; 5287 while ((!feof(fin)) && (status == TCL_OK)) { 5288 while (!feof(fin)) { 5289 int c = fgetc(fin); 5290 if (c <= 0) { 5291 if (errno == EWOULDBLOCK) { 5292 break; 5293 } 5294 if (feof(fin)) 5295 return 1; 5296 else 5297 return c; 4924 5298 } 4925 } 4926 buffer[BUFFERSIZE] = '\0'; 4927 Tcl_DStringAppend(&command, buffer, -1); 4928 if (Tcl_CommandComplete(Tcl_DStringValue(&command))) { 4929 status = ExecuteCommand(interp, &command); 4930 if (status == TCL_BREAK) { 4931 return 1; /* This was caused by a "imgflush" 4932 * command. Break out of the read loop 4933 * and allow a new image to be 4934 * rendered. */ 5299 char ch = (char)c; 5300 Tcl_DStringAppend(&cmdbuffer, &ch, 1); 5301 if (ch == '\n') { 5302 isComplete = Tcl_CommandComplete(Tcl_DStringValue(&cmdbuffer)); 5303 if (isComplete) { 5304 break; 5305 } 4935 5306 } 4936 5307 } 4937 tv.tv_sec = tv.tv_usec = 0L; 4938 FD_SET(fileno(fin), &readFds); 4939 tvPtr = &tv; 4940 } 5308 // no command? then we're done for now 5309 if (Tcl_DStringLength(&cmdbuffer) == 0) { 5310 break; 5311 } 5312 if (isComplete) { 5313 // back to original flags during command evaluation... 5314 fcntl(fdIn, F_SETFL, flags & ~O_NONBLOCK); 5315 TRACE("command: '%s'", Tcl_DStringValue(&cmdbuffer)); 5316 status = ExecuteCommand(interp, &cmdbuffer); 5317 // non-blocking for next read -- we might not get anything 5318 fcntl(fdIn, F_SETFL, flags | O_NONBLOCK); 5319 isComplete = false; 5320 nCommands++; 5321 } 5322 } 5323 fcntl(fdIn, F_SETFL, flags); 4941 5324 4942 5325 if (status != TCL_OK) { … … 4946 5329 string = Tcl_GetVar(interp, "errorInfo", TCL_GLOBAL_ONLY); 4947 5330 TRACE("ERROR errorInfo=(%s)", string); 4948 INFO("%s: status=%d ERROR errorInfo=(%s)", Tcl_DStringValue(&command), 4949 status, string); 5331 4950 5332 nBytes = strlen(string); 4951 5333 struct iovec iov[3]; … … 4956 5338 iov[2].iov_base = (char *)"\n"; 4957 5339 iov[2].iov_len = strlen((char *)iov[2].iov_base); 4958 int fdOut = fileno(fout);4959 5340 if (writev(fdOut, iov, 3) < 0) { 4960 5341 ERROR("write failed: %s", strerror(errno)); … … 4971 5352 * \return The initialized Tcl interpreter 4972 5353 */ 4973 void 4974 Rappture::VtkVis::initTcl(Tcl_Interp *interp, ClientData clientData) 4975 { 5354 Tcl_Interp * 5355 Rappture::VtkVis::initTcl() 5356 { 5357 Tcl_Interp *interp; 5358 interp = Tcl_CreateInterp(); 5359 4976 5360 Tcl_MakeSafe(interp); 4977 Tcl_CreateObjCommand(interp, "axis", AxisCmd, clientData, NULL); 4978 Tcl_CreateObjCommand(interp, "camera", CameraCmd, clientData, NULL); 4979 Tcl_CreateObjCommand(interp, "colormap", ColorMapCmd, clientData, NULL); 4980 Tcl_CreateObjCommand(interp, "contour2d", Contour2DCmd, clientData, NULL); 4981 Tcl_CreateObjCommand(interp, "contour3d", Contour3DCmd, clientData, NULL); 4982 Tcl_CreateObjCommand(interp, "dataset", DataSetCmd, clientData, NULL); 4983 Tcl_CreateObjCommand(interp, "glyphs", GlyphsCmd, clientData, NULL); 4984 Tcl_CreateObjCommand(interp, "heightmap", HeightMapCmd, clientData, NULL); 4985 Tcl_CreateObjCommand(interp, "imgflush", ImageFlushCmd, clientData, NULL); 4986 Tcl_CreateObjCommand(interp, "legend", LegendCmd, clientData, NULL); 4987 Tcl_CreateObjCommand(interp, "lic", LICCmd, clientData, NULL); 4988 Tcl_CreateObjCommand(interp, "molecule", MoleculeCmd, clientData, NULL); 4989 Tcl_CreateObjCommand(interp, "polydata", PolyDataCmd, clientData, NULL); 4990 Tcl_CreateObjCommand(interp, "pseudocolor", PseudoColorCmd, clientData, NULL); 4991 Tcl_CreateObjCommand(interp, "renderer", RendererCmd, clientData, NULL); 4992 Tcl_CreateObjCommand(interp, "screen", ScreenCmd, clientData, NULL); 4993 Tcl_CreateObjCommand(interp, "streamlines", StreamlinesCmd, clientData, NULL); 4994 Tcl_CreateObjCommand(interp, "volume", VolumeCmd, clientData, NULL); 5361 5362 Tcl_CreateObjCommand(interp, "axis", AxisCmd, NULL, NULL); 5363 Tcl_CreateObjCommand(interp, "camera", CameraCmd, NULL, NULL); 5364 Tcl_CreateObjCommand(interp, "colormap", ColorMapCmd, NULL, NULL); 5365 Tcl_CreateObjCommand(interp, "contour2d", Contour2DCmd, NULL, NULL); 5366 Tcl_CreateObjCommand(interp, "contour3d", Contour3DCmd, NULL, NULL); 5367 Tcl_CreateObjCommand(interp, "cutplane", CutplaneCmd, NULL, NULL); 5368 Tcl_CreateObjCommand(interp, "dataset", DataSetCmd, NULL, NULL); 5369 Tcl_CreateObjCommand(interp, "glyphs", GlyphsCmd, NULL, NULL); 5370 Tcl_CreateObjCommand(interp, "heightmap", HeightMapCmd, NULL, NULL); 5371 Tcl_CreateObjCommand(interp, "legend", LegendCmd, NULL, NULL); 5372 Tcl_CreateObjCommand(interp, "lic", LICCmd, NULL, NULL); 5373 Tcl_CreateObjCommand(interp, "molecule", MoleculeCmd, NULL, NULL); 5374 Tcl_CreateObjCommand(interp, "polydata", PolyDataCmd, NULL, NULL); 5375 Tcl_CreateObjCommand(interp, "pseudocolor", PseudoColorCmd, NULL, NULL); 5376 Tcl_CreateObjCommand(interp, "renderer", RendererCmd, NULL, NULL); 5377 Tcl_CreateObjCommand(interp, "screen", ScreenCmd, NULL, NULL); 5378 Tcl_CreateObjCommand(interp, "streamlines", StreamlinesCmd, NULL, NULL); 5379 Tcl_CreateObjCommand(interp, "volume", VolumeCmd, NULL, NULL); 5380 return interp; 4995 5381 } 4996 5382 4997 5383 /** 4998 5384 * \brief Delete Tcl commands and interpreter 5385 * 4999 5386 */ 5000 5387 void Rappture::VtkVis::exitTcl(Tcl_Interp *interp) … … 5006 5393 Tcl_DeleteCommand(interp, "contour2d"); 5007 5394 Tcl_DeleteCommand(interp, "contour3d"); 5395 Tcl_DeleteCommand(interp, "cutplane"); 5008 5396 Tcl_DeleteCommand(interp, "dataset"); 5009 5397 Tcl_DeleteCommand(interp, "glyphs"); 5010 5398 Tcl_DeleteCommand(interp, "heightmap"); 5011 Tcl_DeleteCommand(interp, "imgflush");5012 5399 Tcl_DeleteCommand(interp, "legend"); 5013 5400 Tcl_DeleteCommand(interp, "lic"); -
branches/blt4/packages/vizservers/vtkvis/RpVtkRendererCmd.h
r2542 r2550 16 16 17 17 extern int processCommands(Tcl_Interp *interp, FILE *fin, FILE *fout); 18 extern void initTcl(Tcl_Interp *interp, ClientData clientData);18 extern Tcl_Interp *initTcl(); 19 19 extern void exitTcl(Tcl_Interp *interp); 20 20 -
branches/blt4/packages/vizservers/vtkvis/TGAWriter.cpp
r2542 r2550 17 17 #include "TGAWriter.h" 18 18 #include "Trace.h" 19 #ifdef USE_THREADS20 #include "ResponseQueue.h"21 #endif22 23 #ifdef USE_THREADS24 25 /**26 * \brief Writes image command + data to supplied file descriptor.27 *28 * The image data must be supplied in BGR(A) order with bottom to29 * top scanline ordering.30 *31 * \param[in] queue Pointer to ResponseQueue to write to32 * \param[in] cmdName Command name to send (byte length will be appended)33 * \param[in] data Image data34 * \param[in] width Width of image in pixels35 * \param[in] height Height of image in pixels36 * \param[in] bytesPerPixel Should be 3 or 4, depending on alpha37 */38 void39 Rappture::VtkVis::queueTGA(ResponseQueue *queue, const char *cmdName,40 const unsigned char *data,41 int width, int height,42 int bytesPerPixel)43 {44 TRACE("(%dx%d)\n", width, height);45 46 size_t headerLength = 18;47 48 char header[headerLength];49 memset(header, 0, headerLength);50 header[2] = (char)2; // image type (2 = uncompressed true-color)51 header[12] = (char)width;52 header[13] = (char)(width >> 8);53 header[14] = (char)height;54 header[15] = (char)(height >> 8);55 header[16] = (char)(bytesPerPixel*8); // bits per pixel56 57 size_t dataLength = width * height * bytesPerPixel;58 size_t cmdLength;59 60 char command[200];61 cmdLength = snprintf(command, sizeof(command), "%s %lu\n", cmdName,62 (unsigned long)headerLength + dataLength);63 64 size_t length;65 unsigned char *mesg = NULL;66 67 length = headerLength + dataLength + cmdLength;68 mesg = (unsigned char *)malloc(length);69 if (mesg == NULL) {70 ERROR("can't allocate %ld bytes for the image message", length);71 return;72 }73 memcpy(mesg, command, cmdLength);74 memcpy(mesg + cmdLength, header, headerLength);75 memcpy(mesg + cmdLength + headerLength,76 const_cast<unsigned char *>(data), dataLength);77 78 Response *response = NULL;79 if (strncmp(cmdName, "nv>legend", 9) == 0) {80 response = new Response(Response::LEGEND);81 } else {82 response = new Response(Response::IMAGE);83 }84 response->setMessage(mesg, length, Response::DYNAMIC);85 queue->enqueue(response);86 TRACE("Leaving (%dx%d)\n", width, height);87 }88 #else89 19 90 20 /** … … 149 79 TRACE("Leaving (%dx%d)\n", width, height); 150 80 } 151 #endif /*USE_THREADS*/152 81 153 82 /** -
branches/blt4/packages/vizservers/vtkvis/TGAWriter.h
r2542 r2550 9 9 #define __RAPPTURE_VTKVIS_TGAWRITER_H__ 10 10 11 #ifdef USE_THREADS12 #include "ResponseQueue.h"13 #endif14 15 11 namespace Rappture { 16 12 namespace VtkVis { 17 #ifdef USE_THREADS 13 18 14 extern 19 void queueTGA(ResponseQueue *queue, const char *cmdName, 20 const unsigned char *data, int width, int height, 21 int bytesPerPixel); 22 #else 15 void writeTGA(int fd, const char *cmdName, const unsigned char *data, 16 int width, int height, int bytesPerPixel); 17 23 18 extern 24 void writeTGA(int fd, const char *cmdName, 25 const unsigned char *data, int width, int height, 26 int bytesPerPixel); 27 #endif 28 extern 29 void writeTGAFile(const char *filename, 30 const unsigned char *data, int width, int height, 31 int bytesPerPixel, bool srcIsRGB = false); 19 void writeTGAFile(const char *filename, const unsigned char *data, 20 int width, int height, int bytesPerPixel, 21 bool srcIsRGB = false); 22 32 23 } 33 24 } -
branches/blt4/packages/vizservers/vtkvis/Trace.cpp
r2542 r2550 3 3 * Copyright (C) 2011, Purdue Research Foundation 4 4 * 5 * Author: ?5 * Author: George A. Howlett <gah@purdue.edu> 6 6 */ 7 7 … … 21 21 */ 22 22 void 23 Rappture::VtkVis:: initLog()23 Rappture::VtkVis::InitLog() 24 24 { 25 25 openlog("vtkvis", LOG_CONS | LOG_PERROR | LOG_PID, LOG_USER); … … 30 30 */ 31 31 void 32 Rappture::VtkVis:: closeLog()32 Rappture::VtkVis::CloseLog() 33 33 { 34 34 closelog(); … … 39 39 */ 40 40 void 41 Rappture::VtkVis:: logMessage(int priority, const char *funcname,41 Rappture::VtkVis::LogMessage(int priority, const char *funcname, 42 42 const char *path, int lineNum, const char* fmt, ...) 43 43 { -
branches/blt4/packages/vizservers/vtkvis/Trace.h
r2542 r2550 3 3 * Copyright (C) 2011, Purdue Research Foundation 4 4 * 5 * Author: ?5 * Author: George A. Howlett <gah@purdue.edu> 6 6 */ 7 7 … … 14 14 namespace VtkVis { 15 15 16 extern void initLog();16 extern void InitLog(); 17 17 18 extern void closeLog();18 extern void CloseLog(); 19 19 20 extern void logMessage(int priority, const char *funcname, const char *fileName,21 int lineNum,const char* format, ...);20 extern void LogMessage(int priority, const char *funcname, const char *fileName, int lineNum, 21 const char* format, ...); 22 22 23 #define ERROR(...) Rappture::VtkVis::logMessage(LOG_ERR, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)23 #define ERROR(...) LogMessage(LOG_ERR, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) 24 24 #ifdef WANT_TRACE 25 #define TRACE(...) Rappture::VtkVis::logMessage(LOG_DEBUG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)25 #define TRACE(...) LogMessage(LOG_DEBUG, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) 26 26 #else 27 27 #define TRACE(...) 28 #endif /*WANT_TRACE*/29 #define WARN(...) Rappture::VtkVis::logMessage(LOG_WARNING, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)30 #define INFO(...) Rappture::VtkVis::logMessage(LOG_INFO, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__)28 #endif 29 #define WARN(...) LogMessage(LOG_WARNING, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) 30 #define INFO(...) LogMessage(LOG_INFO, __FUNCTION__, __FILE__, __LINE__, __VA_ARGS__) 31 31 32 32 } -
branches/blt4/packages/vizservers/vtkvis/protocol.txt
r2542 r2550 144 144 contour3d wireframe <bool> <?datasetName?> 145 145 146 glyphs add <?dataSetName?> 146 cutplane add <?dataSetName?> 147 cutplane colormap <colorMapName> <?dataSetName?> 148 cutplane colormode <scalar|vmag|vx|vy|vz> <?datasetName?> 149 Set the field used to color the object. 'scalar' uses 150 the active scalar field. 'vmag' uses the magnitude of the current 151 vector field, and 'vx','vy','vz' use the corresponding component of 152 the active vector field. 153 cutplane delete <?dataSetName?> 154 cutplane edges <bool> <?dataSetName?> 155 cutplane lighting <bool> <?dataSetName?> 156 cutplane linecolor <r> <g> <b> <?dataSetName?> 157 cutplane linewidth <width> <?dataSetName?> 158 cutplane opacity <value> <?dataSetName?> 159 cutplane orient <qw> <qx> <qy> <qz> <?dataSetName?> 160 cutplane pos <x> <y> <z> <?dataSetName?> 161 cutplane scale <sx> <sy> <sz> <?dataSetName?> 162 cutplane slice axis ratio <?dataSetName?> 163 For 3D data, select a slice along a principle axis of the volume. The 164 ratio is [0,1] 165 cutplane visible <bool> <?dataSetName?> 166 cutplane wireframe <bool> <?datasetName?> 167 168 glyphs add <shape> <?dataSetName?> 169 See 'glyphs shape' for list of shapes 147 170 glyphs ccolor r g b <?datasetName?> 148 171 glyphs colormap <colorMapName> <?dataSetName?> … … 193 216 heightmap pos <x> <y> <z> <?dataSetName?> 194 217 heightmap scale <sx> <sy> <sz> <?dataSetName?> 218 heightmap slice axis ratio <?dataSetName?> 219 For 3D data, select a slice along a principle axis of the volume. The 220 ratio is [0,1] 195 221 heightmap surface <bool> <?dataSetName?> 196 222 Toggle rendering of colormapped surface (mountain plot or cutplane) 197 223 heightmap visible <bool> <?dataSetName?> 198 heightmap volumeslice axis ratio <?dataSetName?>199 For 3D data, select a slice along a principle axis of the volume. The200 ratio is [0,1]201 224 heightmap wireframe <bool> <?datasetName?> 202 225 … … 212 235 lic pos <x> <y> <z> <?dataSetName?> 213 236 lic scale <sx> <sy> <sz> <?dataSetName?> 237 lic slice <axis> <ratio> <?datasetName?> 238 For 3D data, select a slice along a principle axis of the volume. The 239 ratio is [0,1] 214 240 lic visible <bool> <?datasetName?> 215 lic volumeslice <axis> <ratio> <?datasetName?>216 241 217 242 molecule add <?datasetName?> … … 305 330 Create a disk seed area with optional hole, filled with randomly 306 331 placed points 332 streamlines seed fmesh <numPoints> data follows <nbytes> <?datasetName?> 333 Fill a mesh supplied as a VTK data file with randomly placed points 307 334 streamlines seed fpoly <centerX> <centerY> <centerZ> <normalX> <normalY> <normalZ> <angle> <radius> <numSides> <numPoints> <?dataSetName?> 308 335 Create a regular n-sided polygonal seed area filled with randomly 309 336 placed points 337 streamlines seed mesh data follows <nbytes> <?datasetName?> 338 Use points of a mesh supplied as a VTK data file 339 streamlines seed points <?datasetName?> 340 Use points of the streamlines' dataset mesh 310 341 streamlines seed polygon <centerX> <centerY> <centerZ> <normalX> <normalY> <normalZ> <angle> <radius> <numSides> <?dataSetName?> 311 342 Create seed points from vertices of a regular n-sided polygon 312 343 streamlines seed rake <startX> <startY> <startZ> <endX> <endY> <endZ> <numPoints> <?datasetName?> 313 344 streamlines seed random <numPoints> <?datasetName?> 345 Fill the streamlines' dataset mesh with randomly placed points 314 346 streamlines seed visible <bool> <?datasetName?> 315 347 streamlines tubes <numSides> <radius> <?datasetName?> -
branches/blt4/packages/vizservers/vtkvis/vtkRpCubeAxesActor2D.cpp
r2542 r2550 439 439 // can be changed). Therefore, we can not just assign pointers otherwise 440 440 // each individual axis text prop would point to the same text prop. 441 #if def notdef441 #if 1 442 442 if (this->AxisLabelTextProperty && 443 443 this->AxisLabelTextProperty->GetMTime() > this->BuildTime) … … 1078 1078 } 1079 1079 1080 //----------------------------------------------------------------------------1081 1082 // Disable warnings about qualifiers on return types.1083 #if defined(_COMPILER_VERSION)1084 # pragma set woff 33031085 #endif1086 #if defined(__INTEL_COMPILER)1087 # pragma warning (disable:858)1088 #endif1089 1090 #ifndef VTK_LEGACY_REMOVE1091 # ifdef VTK_WORKAROUND_WINDOWS_MANGLE1092 # undef SetProp1093 # undef GetProp1094 void vtkRpCubeAxesActor2D::SetPropA(vtkProp* prop)1095 {1096 VTK_LEGACY_REPLACED_BODY(vtkRpCubeAxesActor2D::SetProp, "VTK 5.0",1097 vtkRpCubeAxesActor2D::SetViewProp);1098 this->SetViewProp(prop);1099 }1100 void vtkRpCubeAxesActor2D::SetPropW(vtkProp* prop)1101 {1102 VTK_LEGACY_REPLACED_BODY(vtkRpCubeAxesActor2D::SetProp, "VTK 5.0",1103 vtkRpCubeAxesActor2D::SetViewProp);1104 this->SetViewProp(prop);1105 }1106 vtkProp* vtkRpCubeAxesActor2D::GetPropA()1107 {1108 VTK_LEGACY_REPLACED_BODY(vtkRpCubeAxesActor2D::GetProp, "VTK 5.0",1109 vtkRpCubeAxesActor2D::GetViewProp);1110 return this->GetViewProp();1111 }1112 vtkProp* vtkRpCubeAxesActor2D::GetPropW()1113 {1114 VTK_LEGACY_REPLACED_BODY(vtkRpCubeAxesActor2D::GetProp, "VTK 5.0",1115 vtkRpCubeAxesActor2D::GetViewProp);1116 return this->GetViewProp();1117 }1118 # endif1119 void vtkRpCubeAxesActor2D::SetProp(vtkProp* prop)1120 {1121 VTK_LEGACY_REPLACED_BODY(vtkRpCubeAxesActor2D::SetProp, "VTK 5.0",1122 vtkRpCubeAxesActor2D::SetViewProp);1123 this->SetViewProp(prop);1124 }1125 vtkProp* vtkRpCubeAxesActor2D::GetProp()1126 {1127 VTK_LEGACY_REPLACED_BODY(vtkRpCubeAxesActor2D::GetProp, "VTK 5.0",1128 vtkRpCubeAxesActor2D::GetViewProp);1129 return this->GetViewProp();1130 }1131 #endif -
branches/blt4/packages/vizservers/vtkvis/vtkRpCubeAxesActor2D.h
r2322 r2550 253 253 void ShallowCopy(vtkRpCubeAxesActor2D *actor); 254 254 255 // Disable warnings about qualifiers on return types.256 #if defined(_COMPILER_VERSION)257 # pragma set woff 3303258 #endif259 #if defined(__INTEL_COMPILER)260 # pragma warning (push)261 # pragma warning (disable:858)262 #endif263 264 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE265 # define SetPropA SetProp266 # define SetPropW SetProp267 # define GetPropA GetProp268 # define GetPropW GetProp269 #endif270 271 // Description:272 // @deprecated Replaced by vtkRpCubeAxesActor2D::SetViewProp() as of VTK 5.0.273 VTK_LEGACY(virtual void SetProp(vtkProp* prop));274 275 // Description:276 // @deprecated Replaced by vtkRpCubeAxesActor2D::GetViewProp() as of VTK 5.0.277 VTK_LEGACY(virtual vtkProp* GetProp());278 279 #ifdef VTK_WORKAROUND_WINDOWS_MANGLE280 # undef SetPropW281 # undef SetPropA282 # undef GetPropW283 # undef GetPropA284 //BTX285 VTK_LEGACY(virtual void SetPropA(vtkProp* prop));286 VTK_LEGACY(virtual void SetPropW(vtkProp* prop));287 VTK_LEGACY(virtual vtkProp* GetPropA());288 VTK_LEGACY(virtual vtkProp* GetPropW());289 //ETX290 #endif291 292 // Reset disabled warning about qualifiers on return types.293 #if defined(__INTEL_COMPILER)294 # pragma warning (pop)295 #endif296 #if defined(_COMPILER_VERSION)297 # pragma reset woff 3303298 #endif299 300 255 protected: 301 256 vtkRpCubeAxesActor2D();
Note: See TracChangeset
for help on using the changeset viewer.