Changeset 3696
- Timestamp:
- Jun 17, 2013, 1:48:27 AM (11 years ago)
- Location:
- trunk/packages/vizservers/vtkvis
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/packages/vizservers/vtkvis/Arc.cpp
r3616 r3696 28 28 { 29 29 if (_arc == NULL) { 30 _arc = vtkSmartPointer<vtkArcSource>::New(); 30 _arc = vtkSmartPointer<vtkArcSource>::New(); 31 _arc->SetResolution(4); 32 _arc->UseNormalAndAngleOn(); 31 33 } 32 34 -
trunk/packages/vizservers/vtkvis/Arc.h
r3621 r3696 42 42 } 43 43 44 void set EndPoints(double pt1[3], double pt2[3])44 void setStartPoint(double pt[3]) 45 45 { 46 46 if (_arc != NULL) { 47 _arc->SetPoint1(pt1); 48 _arc->SetPoint2(pt2); 47 double polarVec[3]; 48 for (int i = 0; i < 3; i++) { 49 polarVec[i] = pt[i] - _arc->GetCenter()[i]; 50 } 51 setPolarVector(polarVec); 52 } 53 } 54 55 void setNormal(double norm[3]) 56 { 57 if (_arc != NULL) { 58 _arc->SetNormal(norm); 49 59 } 60 } 61 62 void setPolarVector(double vec[3]) 63 { 64 if (_arc != NULL) { 65 _arc->SetPolarVector(vec); 66 } 67 } 68 69 void setAngle(double angle) 70 { 71 if (_arc != NULL) { 72 _arc->SetAngle(angle); 73 } 50 74 } 51 75 -
trunk/packages/vizservers/vtkvis/Glyphs.cpp
r3695 r3696 20 20 #include <vtkArrowSource.h> 21 21 #include <vtkConeSource.h> 22 #include <vtkCubeSource.h> 22 23 #include <vtkCylinderSource.h> 23 24 #include <vtkPlatonicSolidSource.h> … … 110 111 switch (_glyphShape) { 111 112 case LINE: 113 // Length of 1, centered at origin 112 114 _glyphSource = vtkSmartPointer<vtkLineSource>::New(); 113 115 break; 114 116 case ARROW: { 117 // Height of 1, Tip radius .1, tip length .35, shaft radius .03 115 118 _glyphSource = vtkSmartPointer<vtkArrowSource>::New(); 116 119 vtkSmartPointer<vtkArrowSource> arrow = vtkArrowSource::SafeDownCast(_glyphSource); … … 121 124 break; 122 125 case CONE: { 126 // base length of 1, height 1, centered at origin 123 127 _glyphSource = vtkSmartPointer<vtkConeSource>::New(); 124 128 vtkSmartPointer<vtkConeSource> cone = vtkConeSource::SafeDownCast(_glyphSource); … … 128 132 break; 129 133 case CUBE: 130 _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New();131 vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToCube();134 // Sides of length 1 135 _glyphSource = vtkSmartPointer<vtkCubeSource>::New(); 132 136 break; 133 137 case CYLINDER: { 138 // base length of 1, height 1, centered at origin 134 139 vtkSmartPointer<vtkCylinderSource> csource = vtkSmartPointer<vtkCylinderSource>::New(); 135 140 csource->SetResolution(8); … … 142 147 break; 143 148 case DODECAHEDRON: 149 // Radius of 1 144 150 _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New(); 145 151 vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToDodecahedron(); … … 148 154 break; 149 155 case ICOSAHEDRON: 156 // Radius of 1 150 157 _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New(); 151 158 vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToIcosahedron(); … … 154 161 break; 155 162 case OCTAHEDRON: 163 // Radius of 1 156 164 _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New(); 157 165 vtkPlatonicSolidSource::SafeDownCast(_glyphSource)->SetSolidTypeToOctahedron(); … … 167 175 break; 168 176 case SPHERE: { 177 // Default radius 0.5 169 178 _glyphSource = vtkSmartPointer<vtkSphereSource>::New(); 170 179 vtkSmartPointer<vtkSphereSource> sphere = vtkSphereSource::SafeDownCast(_glyphSource); … … 174 183 break; 175 184 case TETRAHEDRON: 185 // Radius of 1 176 186 // FIXME: need to rotate inital orientation 177 187 _glyphSource = vtkSmartPointer<vtkPlatonicSolidSource>::New(); … … 205 215 void Glyphs::setQuality(double quality) 206 216 { 217 if (quality > 10.0) 218 quality = 10.0; 219 207 220 switch (_glyphShape) { 208 221 case ARROW: { -
trunk/packages/vizservers/vtkvis/Line.h
r3621 r3696 9 9 #define VTKVIS_LINE_H 10 10 11 #include <vector> 12 11 13 #include <vtkSmartPointer.h> 12 14 #include <vtkPolyDataMapper.h> 13 15 #include <vtkActor.h> 14 16 #include <vtkLineSource.h> 17 #include <vtkPoints.h> 15 18 16 19 #include "Shape.h" … … 22 25 * \brief VTK PolyData Line 23 26 * 24 * This class creates a line27 * This class creates a polyline 25 28 */ 26 29 class Line : public Shape … … 35 38 } 36 39 40 /** 41 * \brief This interface creates a single line 42 */ 37 43 void setEndPoints(double pt1[3], double pt2[3]) 38 44 { 39 45 if (_line != NULL) { 40 46 _line->SetPoint1(pt1); 41 _line->SetPoint2(pt2); 42 } 47 _line->SetPoint2(pt2); 48 _line->SetPoints(NULL); 49 } 50 } 51 52 /** 53 * \brief This interface creates a polyline 54 */ 55 void setPoints(std::vector<double> pts) 56 { 57 if (_line == NULL) 58 return; 59 vtkPoints *points = vtkPoints::New(); 60 for (size_t i = 0; i < pts.size(); i+=3) { 61 points->InsertNextPoint(pts[i], pts[i+1], pts[i+2]); 62 } 63 _line->SetPoints(points); 43 64 } 44 65 -
trunk/packages/vizservers/vtkvis/Renderer.h
r3695 r3696 577 577 // Arcs 578 578 579 bool addArc(const DataSetId& id, double center[3], double pt1[3], double pt2[3]); 579 bool addArc(const DataSetId& id, double center[3], double pt1[3], 580 double normal[3], double angle); 580 581 581 582 void setArcResolution(const DataSetId& id, int res); … … 583 584 // Arrows 584 585 585 bool addArrow(const DataSetId& id, double tipRadius, double shaftRadius, double tipLength, bool flipNormals = false); 586 bool addArrow(const DataSetId& id, double tipRadius, double shaftRadius, 587 double tipLength, bool flipNormals = false); 586 588 587 589 void setArrowResolution(const DataSetId& id, int resTip, int resShaft); … … 589 591 // Boxes 590 592 591 bool addBox(const DataSetId& id, double xLen, double yLen, double zLen, bool flipNormals = false); 593 bool addBox(const DataSetId& id, double xLen, double yLen, double zLen, 594 bool flipNormals = false); 592 595 593 596 // Cones 594 597 595 bool addCone(const DataSetId& id, double radius, double height, bool cap, bool flipNormals = false); 598 bool addCone(const DataSetId& id, double radius, double height, bool cap, 599 bool flipNormals = false); 596 600 597 601 void setConeResolution(const DataSetId& id, int res); … … 741 745 742 746 bool addLine(const DataSetId& id, double pt1[3], double pt2[3]); 747 748 bool addLine(const DataSetId& id, std::vector<double> points); 743 749 744 750 // Molecules -
trunk/packages/vizservers/vtkvis/RendererCmd.cpp
r3695 r3696 13 13 #include <string> 14 14 #include <sstream> 15 #include <vector> 15 16 #include <unistd.h> 16 17 #include <sys/select.h> … … 131 132 Tcl_Obj *const *objv) 132 133 { 133 double center[3], pt1[3], pt2[3];134 double center[3], pt1[3], norm[3], angle; 134 135 if (Tcl_GetDoubleFromObj(interp, objv[2], ¢er[0]) != TCL_OK || 135 136 Tcl_GetDoubleFromObj(interp, objv[3], ¢er[1]) != TCL_OK || … … 138 139 Tcl_GetDoubleFromObj(interp, objv[6], &pt1[1]) != TCL_OK || 139 140 Tcl_GetDoubleFromObj(interp, objv[7], &pt1[2]) != TCL_OK || 140 Tcl_GetDoubleFromObj(interp, objv[8], &pt2[0]) != TCL_OK || 141 Tcl_GetDoubleFromObj(interp, objv[9], &pt2[1]) != TCL_OK || 142 Tcl_GetDoubleFromObj(interp, objv[10], &pt2[2]) != TCL_OK) { 143 return TCL_ERROR; 144 } 145 const char *name = Tcl_GetString(objv[11]); 146 if (!g_renderer->addArc(name, center, pt1, pt2)) { 141 Tcl_GetDoubleFromObj(interp, objv[8], &norm[0]) != TCL_OK || 142 Tcl_GetDoubleFromObj(interp, objv[9], &norm[1]) != TCL_OK || 143 Tcl_GetDoubleFromObj(interp, objv[10], &norm[2]) != TCL_OK || 144 Tcl_GetDoubleFromObj(interp, objv[11], &angle) != TCL_OK) { 145 return TCL_ERROR; 146 } 147 const char *name = Tcl_GetString(objv[12]); 148 if (!g_renderer->addArc(name, center, pt1, norm, angle)) { 147 149 Tcl_AppendResult(interp, "Failed to create arc", (char*)NULL); 148 150 return TCL_ERROR; … … 329 331 330 332 static Rappture::CmdSpec arcOps[] = { 331 {"add", 1, ArcAddOp, 1 2, 12, "centerX centerY centerZ x1 y1 z1 x2 y2 z2name"},333 {"add", 1, ArcAddOp, 13, 13, "centerX centerY centerZ startX startY startZ normX normY normZ angle name"}, 332 334 {"color", 1, ArcColorOp, 5, 6, "r g b ?name?"}, 333 335 {"delete", 1, ArcDeleteOp, 2, 3, "?name?"}, … … 721 723 {"orient", 4, ArrowOrientOp, 6, 7, "qw qx qy qz ?name?"}, 722 724 {"origin", 4, ArrowOriginOp, 5, 6, "x y z ?name?"}, 723 {"pos", 2, ArrowPositionOp, 5, 6, "x y z ?name?"},725 {"pos", 1, ArrowPositionOp, 5, 6, "x y z ?name?"}, 724 726 {"resolution",1, ArrowResolutionOp, 4, 5, "tipRes shaftRes ?name?"}, 725 727 {"scale", 2, ArrowScaleOp, 5, 6, "sx sy sz ?name?"}, … … 7075 7077 Tcl_Obj *const *objv) 7076 7078 { 7077 double pt1[3]; 7078 double pt2[3]; 7079 if (Tcl_GetDoubleFromObj(interp, objv[2], &pt1[0]) != TCL_OK || 7080 Tcl_GetDoubleFromObj(interp, objv[3], &pt1[1]) != TCL_OK || 7081 Tcl_GetDoubleFromObj(interp, objv[4], &pt1[2]) != TCL_OK || 7082 Tcl_GetDoubleFromObj(interp, objv[5], &pt2[0]) != TCL_OK || 7083 Tcl_GetDoubleFromObj(interp, objv[6], &pt2[1]) != TCL_OK || 7084 Tcl_GetDoubleFromObj(interp, objv[7], &pt2[2]) != TCL_OK) { 7085 return TCL_ERROR; 7086 } 7087 const char *name = Tcl_GetString(objv[8]); 7088 if (!g_renderer->addLine(name, pt1, pt2)) { 7079 std::vector<double> points; 7080 int ptlistc; 7081 Tcl_Obj **ptlistv; 7082 if (Tcl_ListObjGetElements(interp, objv[2], &ptlistc, &ptlistv) != TCL_OK) { 7083 return TCL_ERROR; 7084 } 7085 if (ptlistc < 6 || ptlistc % 3 != 0) { 7086 Tcl_AppendResult(interp, "Points list size must be 6 or more and a multiple of 3", (char*)NULL); 7087 return TCL_ERROR; 7088 } 7089 for (int i = 0; i < ptlistc; i++) { 7090 double val; 7091 if (Tcl_GetDoubleFromObj(interp, ptlistv[i], &val) != TCL_OK) { 7092 return TCL_ERROR; 7093 } 7094 points.push_back(val); 7095 } 7096 const char *name = Tcl_GetString(objv[3]); 7097 if (!g_renderer->addLine(name, points)) { 7089 7098 Tcl_AppendResult(interp, "Failed to create line", (char*)NULL); 7090 7099 return TCL_ERROR; … … 7254 7263 7255 7264 static Rappture::CmdSpec lineOps[] = { 7256 {"add", 1, LineAddOp, 9, 9, "x1 y1 z1 x2 y2 z2name"},7265 {"add", 1, LineAddOp, 4, 4, "points name"}, 7257 7266 {"color", 1, LineColorOp, 5, 6, "r g b ?name?"}, 7258 7267 {"delete", 1, LineDeleteOp, 2, 3, "?name?"}, -
trunk/packages/vizservers/vtkvis/RendererGraphicsObjs.cpp
r3695 r3696 8 8 #include <cstring> 9 9 #include <typeinfo> 10 #include <vector> 10 11 11 12 #include <vtkVersion.h> … … 394 395 * \brief Create a new Arc and associate it with an ID 395 396 */ 396 bool Renderer::addArc(const DataSetId& id, double center[3], 397 double pt1[3], double pt2[3]) 397 bool Renderer::addArc(const DataSetId& id, 398 double center[3], 399 double pt1[3], 400 double normal[3], 401 double angle) 398 402 { 399 403 Arc *gobj; … … 419 423 420 424 gobj->setCenter(center); 421 gobj->setEndPoints(pt1, pt2); 425 gobj->setStartPoint(pt1); 426 gobj->setNormal(normal); 427 gobj->setAngle(angle); 422 428 423 429 getGraphicsObjectHashmap<Arc>()[id] = gobj; … … 2299 2305 2300 2306 /** 2307 * \brief Create a new Line and associate it with an ID 2308 */ 2309 bool Renderer::addLine(const DataSetId& id, std::vector<double> points) 2310 { 2311 Line *gobj; 2312 if ((gobj = getGraphicsObject<Line>(id)) != NULL) { 2313 WARN("Replacing existing %s %s", gobj->getClassName(), id.c_str()); 2314 deleteGraphicsObject<Line>(id); 2315 } 2316 2317 gobj = new Line(); 2318 2319 gobj->setDataSet(NULL, this); 2320 2321 if (gobj->getProp() == NULL && 2322 gobj->getOverlayProp() == NULL) { 2323 delete gobj; 2324 return false; 2325 } else { 2326 if (gobj->getProp()) 2327 _renderer->AddViewProp(gobj->getProp()); 2328 if (gobj->getOverlayProp()) 2329 _renderer->AddViewProp(gobj->getOverlayProp()); 2330 } 2331 2332 gobj->setPoints(points); 2333 2334 getGraphicsObjectHashmap<Line>()[id] = gobj; 2335 2336 sceneBoundsChanged(); 2337 _needsRedraw = true; 2338 return true; 2339 } 2340 2341 /** 2301 2342 * \brief Set atom sphere resolution 2302 2343 */ -
trunk/packages/vizservers/vtkvis/protocol.txt
r3693 r3696 258 258 == Graphics objects == 259 259 260 arc add <centerX> <centerY> <centerZ> <pt1X> <pt1Y> <pt1Z> <pt2X> <pt2Y> <pt2Z> <name> 260 arc add <centerX> <centerY> <centerZ> <startX> <startY> <startZ> <normX> <normY> <normZ> <angle> <name> 261 Creates a circular arc given a center and starting point, a normal and a 262 sweep angle. 261 263 arc color <r> <g> <b> <?name?> 262 264 arc delete <?name?> … … 492 494 glyphs pos <x> <y> <z> <?dataSetName?> 493 495 glyphs ptsize <size> <?dataSetName?> 496 glyphs quality <val> <?dataSetName?> 497 Set glyph shape resolution quality val=[0,10], 1 is default 494 498 glyphs scale <sx> <sy> <sz> <?dataSetName?> 495 499 glyphs shape <arrow|cone|cube|cylinder|dodecahedron|icosahedron|line|octahedron|point|sphere|tetrahedron> <?datasetName?> … … 577 581 lic visible <bool> <?datasetName?> 578 582 579 line add <pt1X> <pt1Y> <pt1Z> <pt2X> <pt2Y> <pt2Z> <name> 583 line add <points> <name> 584 Create a polyline from the list of point coordinates in <points>. The 585 list size must be a multiple of 3 (each point's x,y,z coordinates) 580 586 line color <r> <g> <b> <?name?> 581 587 line delete <?name?>
Note: See TracChangeset
for help on using the changeset viewer.