| 30 | } |
| 31 | |
| 32 | void ImplicitFunctionConverter::Set(vtkImplicitFunction* function) |
| 33 | { |
| 34 | vtkBox* box = nullptr; |
| 35 | vtkCylinder* cylinder = nullptr; |
| 36 | vtkPlane* plane = nullptr; |
| 37 | vtkSphere* sphere = nullptr; |
| 38 | |
| 39 | if (function->GetTransform()) |
| 40 | { |
| 41 | throw viskores::cont::ErrorBadType( |
| 42 | "Viskores's implicit functions currently do not support transformations."); |
| 43 | } |
| 44 | |
| 45 | if ((box = vtkBox::SafeDownCast(function))) |
| 46 | { |
| 47 | double xmin[3], xmax[3]; |
| 48 | box->GetXMin(xmin); |
| 49 | box->GetXMax(xmax); |
| 50 | |
| 51 | this->OutFunction = viskores::Box(MakeFVec3(xmin), MakeFVec3(xmax)); |
| 52 | } |
| 53 | else if ((cylinder = vtkCylinder::SafeDownCast(function))) |
| 54 | { |
| 55 | double center[3], axis[3], radius; |
| 56 | cylinder->GetCenter(center); |
| 57 | cylinder->GetAxis(axis); |
| 58 | radius = cylinder->GetRadius(); |
| 59 | |
| 60 | this->OutFunction = viskores::Cylinder( |
| 61 | MakeFVec3(center), MakeFVec3(axis), static_cast<viskores::FloatDefault>(radius)); |
| 62 | } |
| 63 | else if ((plane = vtkPlane::SafeDownCast(function))) |
| 64 | { |
| 65 | double origin[3], normal[3]; |
| 66 | plane->GetOrigin(origin); |
| 67 | plane->GetNormal(normal); |
| 68 | |
| 69 | this->OutFunction = viskores::Plane(MakeFVec3(origin), MakeFVec3(normal)); |
| 70 | } |
| 71 | else if ((sphere = vtkSphere::SafeDownCast(function))) |
| 72 | { |
| 73 | double center[3], radius; |
| 74 | sphere->GetCenter(center); |
| 75 | radius = sphere->GetRadius(); |
| 76 | |
| 77 | this->OutFunction = |
| 78 | viskores::Sphere(MakeFVec3(center), static_cast<viskores::FloatDefault>(radius)); |
| 79 | } |
| 80 | else |
| 81 | { |
| 82 | std::string message = std::string("The implicit functions ") + function->GetClassName() + |
| 83 | std::string(" is not supported by viskores."); |
| 84 | throw viskores::cont::ErrorBadType(message); |
| 85 | } |
| 86 | |
| 87 | this->MTime = function->GetMTime(); |
| 88 | this->InFunction = function; |
| 89 | } |
no test coverage detected