moab
CropTool Class Reference

#include <CropTool.hpp>

List of all members.

Public Types

enum  FuncType {
  NONE = 0, PLANEX, PLANEY, PLANEZ,
  CYLINDER, SPHERE
}

Public Member Functions

 CropTool ()
 ~CropTool ()
void type_activated (const int num, const int type_num)
void radius_value_changed (const int num, const int new_val)
void xyz_value_changed (const int num, const int xyz[3])
void rotate_value_changed (const int num, const int new_vals[2])
void toggle_changed (const int num, const bool checked)

Private Member Functions

vtkTransform * get_transform (const int num)
vtkImplicitFunction * get_the_function (const bool force=true)
void set_the_function (vtkImplicitFunction *this_func)

Private Attributes

FuncType func_types [3]
vtkImplicitBoolean * boolFunction
vtkImplicitFunction * theFunction
vtkImplicitFunction * funcs [3]

Detailed Description

Definition at line 9 of file CropTool.hpp.


Member Enumeration Documentation

Enumerator:
NONE 
PLANEX 
PLANEY 
PLANEZ 
CYLINDER 
SPHERE 

Definition at line 14 of file CropTool.hpp.


Constructor & Destructor Documentation

Definition at line 14 of file CropTool.cpp.

{
  func_types[0] = func_types[1] = func_types[2] = NONE;
  funcs[0] = funcs[1] = funcs[2] = NULL;
  boolFunction = NULL;
  theFunction = NULL;
}

Definition at line 22 of file CropTool.cpp.

{
  vtkMOABUtils::remove_geom_extractors();

  if (NULL != boolFunction) {
      // need to remove the geometry extractor from the pipeline, then delete it
    vtkMOABUtils::remove_geom_extractors();
    boolFunction->Delete();
  }
}

Member Function Documentation

vtkImplicitFunction * CropTool::get_the_function ( const bool  force = true) [private]

Definition at line 33 of file CropTool.cpp.

{
  return theFunction;
}
vtkTransform * CropTool::get_transform ( const int  num) [private]

Definition at line 178 of file CropTool.cpp.

{
  if (num < 0 || num > 2 || funcs[num] == NULL) {
    std::cerr << "No function of that type." << std::endl;
    return NULL;
  }

    // get a transform for this function
  vtkAbstractTransform *temp = funcs[num]->GetTransform();
  vtkTransform *transf;
  
  if (NULL == temp) {
    transf = vtkTransform::New();
    funcs[num]->SetTransform(transf);
  }
  else {
    transf = vtkTransform::SafeDownCast(temp);
  }
  
  return transf;
}
void CropTool::radius_value_changed ( const int  num,
const int  new_val 
)

Definition at line 113 of file CropTool.cpp.

{
  if (num < 0 || num > 2 || funcs[num] == NULL) {
    std::cerr << "No function of that type." << std::endl;
    return;
  }
  
  vtkCylinder *cyl = vtkCylinder::SafeDownCast(funcs[num]);
  if (NULL != cyl) {
    cyl->SetRadius(((double)new_val)*0.1);
    return;
  }
  
  vtkSphere *sph = vtkSphere::SafeDownCast(funcs[num]);
  if (NULL != sph) {
    sph->SetRadius(((double)new_val)*0.1);
    return;
  }
  
  std::cerr << "Can't set radius on a plane." << std::endl;
}
void CropTool::rotate_value_changed ( const int  num,
const int  new_vals[2] 
)

Definition at line 160 of file CropTool.cpp.

{
  vtkTransform *transf = get_transform(num);
  transf->Identity();
  int val_num = 0;
  if (func_types[num] == PLANEY || func_types[num] == PLANEZ || func_types[num] == CYLINDER)
    transf->RotateX((double)new_vals[val_num++]);
  if (func_types[num] == PLANEX || func_types[num] == PLANEZ || func_types[num] == CYLINDER)
    transf->RotateY((double)new_vals[val_num++]);
  if (func_types[num] == PLANEX || func_types[num] == PLANEY || func_types[num] == CYLINDER)
    transf->RotateZ((double)new_vals[val_num++]);
}
void CropTool::set_the_function ( vtkImplicitFunction *  this_func) [private]

Definition at line 38 of file CropTool.cpp.

void CropTool::toggle_changed ( const int  num,
const bool  checked 
)

Definition at line 173 of file CropTool.cpp.

{
    //geomExtractor->SetExtractInside((checked ? 1 : 0));
}
void CropTool::type_activated ( const int  num,
const int  type_num 
)

Definition at line 49 of file CropTool.cpp.

{
    //vtkImplicitFunction *the_func = NULL;
  
  vtkPlane *plane;
  vtkCylinder *cyl;
  vtkSphere *sph;
  
  switch (type_num) {
    case NONE:
      func_types[num] = NONE;
      break;
    case PLANEX:
      plane = vtkPlane::New();
      assert (NULL != plane);
      plane->SetNormal(1.0, 0.0, 0.0);
      funcs[num] = plane;
        //bool_func->AddFunction(plane);
        //theFunction = plane;
      func_types[num] = PLANEX;
      break;
    case PLANEY:
      plane = vtkPlane::New();
      assert (NULL != plane);
      plane->SetNormal(0.0, 1.0, 0.0);
      funcs[num] = plane;
        //bool_func->AddFunction(plane);
        //theFunction = plane;
      func_types[num] = PLANEY;
      break;
    case PLANEZ:
      plane = vtkPlane::New();
      assert (NULL != plane);
      plane->SetNormal(0.0, 0.0, 1.0);
      funcs[num] = plane;
        //bool_func->AddFunction(plane);
        //theFunction = plane;
      func_types[num] = PLANEZ;
      break;
    case CYLINDER:
      cyl = vtkCylinder::New();
      cyl->SetRadius(1.0);
      funcs[num] = cyl;
        //bool_func->AddFunction(cyl);
      func_types[num] = CYLINDER;
      break;
    case SPHERE:
      sph = vtkSphere::New();
      sph->SetRadius(1.0);
      funcs[num] = sph;
        //bool_func->AddFunction(sph);
      func_types[num] = SPHERE;
      break;
  }

  if (funcs[num] == NULL && theFunction != NULL) {
    vtkMOABUtils::remove_geom_extractors();
    theFunction->Delete();
    theFunction = NULL;
  }
  else
    set_the_function(funcs[num]);
}
void CropTool::xyz_value_changed ( const int  num,
const int  xyz[3] 
)

Definition at line 135 of file CropTool.cpp.

{
  double dxyz[3] = {(double) new_xyz[0], (double) new_xyz[1], (double) new_xyz[2]};
  dxyz[0] *= 0.1; dxyz[1] *= 0.1; dxyz[2] *= 0.1;
   
  if (func_types[num] >= PLANEX && func_types[num] <= PLANEZ) {
    vtkPlane *this_plane = vtkPlane::SafeDownCast(funcs[num]);
    assert(NULL != this_plane);
    this_plane->SetOrigin(dxyz);
  }
  else if (func_types[num] == CYLINDER) {
    vtkCylinder *this_cyl = vtkCylinder::SafeDownCast(funcs[num]);
    assert(NULL != this_cyl);
    this_cyl->SetCenter(dxyz);
  }
  else if (func_types[num] == SPHERE) {
    vtkSphere *this_sph = vtkSphere::SafeDownCast(funcs[num]);
    assert(NULL != this_sph);
    this_sph->SetCenter(dxyz);
  }
  else {
    std::cerr << "No cropping function there." << std::endl;
  }
}

Member Data Documentation

vtkImplicitBoolean* CropTool::boolFunction [private]

Definition at line 22 of file CropTool.hpp.

Definition at line 21 of file CropTool.hpp.

vtkImplicitFunction* CropTool::funcs[3] [private]

Definition at line 24 of file CropTool.hpp.

vtkImplicitFunction* CropTool::theFunction [private]

Definition at line 23 of file CropTool.hpp.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines