Ignore:
Timestamp:
Jun 17, 2013, 1:48:27 AM (11 years ago)
Author:
ldelgass
Message:

Use imroved Arc API (arc can only represent a circular section, and setting
two endpoints could cause problems with endpts and center colinear and radii
from center to two endpoints differing). New API uses a center, start point,
normal and sweep angle. Also change Line to support polylines: protocol is
changed to require a Tcl list for point coordinates instead of a fixed 2
endpoints.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/packages/vizservers/vtkvis/RendererCmd.cpp

    r3695 r3696  
    1313#include <string>
    1414#include <sstream>
     15#include <vector>
    1516#include <unistd.h>
    1617#include <sys/select.h>
     
    131132         Tcl_Obj *const *objv)
    132133{
    133     double center[3], pt1[3], pt2[3];
     134    double center[3], pt1[3], norm[3], angle;
    134135    if (Tcl_GetDoubleFromObj(interp, objv[2], &center[0]) != TCL_OK ||
    135136        Tcl_GetDoubleFromObj(interp, objv[3], &center[1]) != TCL_OK ||
     
    138139        Tcl_GetDoubleFromObj(interp, objv[6], &pt1[1]) != TCL_OK ||
    139140        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)) {
    147149        Tcl_AppendResult(interp, "Failed to create arc", (char*)NULL);
    148150        return TCL_ERROR;
     
    329331
    330332static Rappture::CmdSpec arcOps[] = {
    331     {"add",       1, ArcAddOp, 12, 12, "centerX centerY centerZ x1 y1 z1 x2 y2 z2 name"},
     333    {"add",       1, ArcAddOp, 13, 13, "centerX centerY centerZ startX startY startZ normX normY normZ angle name"},
    332334    {"color",     1, ArcColorOp, 5, 6, "r g b ?name?"},
    333335    {"delete",    1, ArcDeleteOp, 2, 3, "?name?"},
     
    721723    {"orient",    4, ArrowOrientOp, 6, 7, "qw qx qy qz ?name?"},
    722724    {"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?"},
    724726    {"resolution",1, ArrowResolutionOp, 4, 5, "tipRes shaftRes ?name?"},
    725727    {"scale",     2, ArrowScaleOp, 5, 6, "sx sy sz ?name?"},
     
    70757077          Tcl_Obj *const *objv)
    70767078{
    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)) {
    70897098        Tcl_AppendResult(interp, "Failed to create line", (char*)NULL);
    70907099        return TCL_ERROR;
     
    72547263
    72557264static Rappture::CmdSpec lineOps[] = {
    7256     {"add",       1, LineAddOp, 9, 9, "x1 y1 z1 x2 y2 z2 name"},
     7265    {"add",       1, LineAddOp, 4, 4, "points name"},
    72577266    {"color",     1, LineColorOp, 5, 6, "r g b ?name?"},
    72587267    {"delete",    1, LineDeleteOp, 2, 3, "?name?"},
Note: See TracChangeset for help on using the changeset viewer.