From a7caeb1fe691a3aea6d5258691152536ef0f4a1f Mon Sep 17 00:00:00 2001 From: Johan Andruejol Date: Tue, 8 Jan 2013 09:14:17 -0500 Subject: [PATCH] Add vtkCapsuleSource vtkCapsuleSource is polydata algorithm that generates a polygonal capsule. See Issue #13680 --- Libs/VTK/CMakeLists.txt | 1 + Libs/VTK/Filters/Sources/CMakeLists.txt | 83 ++++ .../Filters/Sources/Testing/CMakeLists.txt | 35 ++ .../Sources/Testing/vtkCapsuleSourceTest.cxx | 79 ++++ Libs/VTK/Filters/Sources/vtkCapsuleSource.cxx | 419 ++++++++++++++++++ Libs/VTK/Filters/Sources/vtkCapsuleSource.h | 111 +++++ 6 files changed, 728 insertions(+) create mode 100644 Libs/VTK/Filters/Sources/CMakeLists.txt create mode 100644 Libs/VTK/Filters/Sources/Testing/CMakeLists.txt create mode 100644 Libs/VTK/Filters/Sources/Testing/vtkCapsuleSourceTest.cxx create mode 100644 Libs/VTK/Filters/Sources/vtkCapsuleSource.cxx create mode 100644 Libs/VTK/Filters/Sources/vtkCapsuleSource.h diff --git a/Libs/VTK/CMakeLists.txt b/Libs/VTK/CMakeLists.txt index e39c82c..464d0ab 100644 --- a/Libs/VTK/CMakeLists.txt +++ b/Libs/VTK/CMakeLists.txt @@ -19,4 +19,5 @@ #============================================================================ add_subdirectory(Common) +add_subdirectory(Filters/Sources) add_subdirectory(Widgets) diff --git a/Libs/VTK/Filters/Sources/CMakeLists.txt b/Libs/VTK/Filters/Sources/CMakeLists.txt new file mode 100644 index 0000000..c35198b --- /dev/null +++ b/Libs/VTK/Filters/Sources/CMakeLists.txt @@ -0,0 +1,83 @@ +#============================================================================ +# +# Program: Bender +# +# Copyright (c) Kitware Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0.txt +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +#============================================================================ + +# +# Create the VTK Widgets projects for bone manipulation and animation. +# + +cmake_minimum_required(VERSION 2.6) + +set(KIT Sources) +project(vtkBender${KIT}) +string(TOUPPER ${KIT} KIT_UPPER) + +#----------------------------------------------------------------------------- +# Get VTK + +find_package(VTK REQUIRED) +include(${VTK_USE_FILE}) + +find_package(OpenGL) + +#----------------------------------------------------------------------------- +# Create library + +include_directories( + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${vtkBenderCommon_SOURCE_DIR} + ) + +set(${KIT}_SRCS + vtkCapsuleSource.cxx + vtkCapsuleSource.h + ) + +add_library(${PROJECT_NAME} ${${KIT}_SRCS}) +target_link_libraries(${PROJECT_NAME} + ${VTK_LIBRARIES} + ${OPENGL_LIBRARIES} + ) +bender_export_library() + +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${Bender_INSTALL_BIN_DIR} COMPONENT RuntimeLibraries + LIBRARY DESTINATION ${Bender_INSTALL_LIB_DIR} COMPONENT RuntimeLibraries + ARCHIVE DESTINATION ${Bender_INSTALL_LIB_DIR} COMPONENT Development + ) + +#----------------------------------------------------------------------------- +# Configure export file + +set(MyLibraryExportDirective "VTK_BENDER_${KIT_UPPER}_EXPORT") +set(MyExportHeaderPrefix ${PROJECT_NAME}) +set(MyLibName ${PROJECT_NAME}) + +configure_file( + ${Bender_SOURCE_DIR}/CMake/BenderExport.h.in + ${PROJECT_NAME}Export.h + ) + +set(dynamicHeaders + "${dynamicHeaders};${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Export.h") + +#----------------------------------------------------------------------------- +# Add testing +add_subdirectory(Testing) diff --git a/Libs/VTK/Filters/Sources/Testing/CMakeLists.txt b/Libs/VTK/Filters/Sources/Testing/CMakeLists.txt new file mode 100644 index 0000000..3c35735 --- /dev/null +++ b/Libs/VTK/Filters/Sources/Testing/CMakeLists.txt @@ -0,0 +1,35 @@ +#============================================================================ +# +# Program: Bender +# +# Copyright (c) Kitware Inc. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0.txt +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +#============================================================================ + +# +# VTK Bone Widgets Testing +# + +create_test_sourcelist(${KIT}_TEST_SRCS + vtkBenderSourcesTests.cxx + vtkCapsuleSourceTest.cxx + ) + +add_executable (${PROJECT_NAME}Tests ${${KIT}_TEST_SRCS}) +target_link_libraries(${PROJECT_NAME}Tests + ${PROJECT_NAME} + ) + +add_test(vtkCapsuleSourceTest ${CXX_TEST_PATH}/BenderWidgetTests vtkCapsuleSourceTest) diff --git a/Libs/VTK/Filters/Sources/Testing/vtkCapsuleSourceTest.cxx b/Libs/VTK/Filters/Sources/Testing/vtkCapsuleSourceTest.cxx new file mode 100644 index 0000000..c5d9308 --- /dev/null +++ b/Libs/VTK/Filters/Sources/Testing/vtkCapsuleSourceTest.cxx @@ -0,0 +1,79 @@ +/*========================================================================= + + Program: Bender + + Copyright (c) Kitware Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0.txt + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=========================================================================*/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include "vtkCapsuleSource.h" + +int vtkCapsuleSourceTest(int, char *[]) +{ + vtkSmartPointer renderer = + vtkSmartPointer::New(); + vtkSmartPointer renderWindow = + vtkSmartPointer::New(); + renderWindow->AddRenderer(renderer); + + // An interactor + vtkSmartPointer renderWindowInteractor = + vtkSmartPointer::New(); + renderWindowInteractor->SetRenderWindow(renderWindow); + + vtkSmartPointer capsuleSource = + vtkSmartPointer::New(); + capsuleSource->SetThetaResolution(4); + capsuleSource->SetPhiResolution(4); + capsuleSource->SetCylinderLength(10.0); + capsuleSource->SetRadius(10.0); + capsuleSource->SetLatLongTessellation(true); + + //vtkSmartPointer w = vtkSmartPointer::New(); + //w->SetInputConnection(capsuleSource->GetOutputPort()); + //w->SetFileName("./capsule.vtk"); + //w->Write(); + + vtkSmartPointer mapper = + vtkSmartPointer::New(); + mapper->SetInputConnection(capsuleSource->GetOutputPort()); + vtkSmartPointer actor = + vtkSmartPointer::New(); + actor->SetMapper(mapper); + + // Render + renderer->AddActor(actor); + renderWindow->Render(); + renderWindowInteractor->Initialize(); + renderWindow->Render(); + + // Begin mouse interaction + renderWindowInteractor->Start(); + + return EXIT_SUCCESS; +} + diff --git a/Libs/VTK/Filters/Sources/vtkCapsuleSource.cxx b/Libs/VTK/Filters/Sources/vtkCapsuleSource.cxx new file mode 100644 index 0000000..7ea2a3b --- /dev/null +++ b/Libs/VTK/Filters/Sources/vtkCapsuleSource.cxx @@ -0,0 +1,419 @@ +/*========================================================================= + + Program: Bender + + Copyright (c) Kitware Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0.txt + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=========================================================================*/ +#include "vtkCapsuleSource.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +vtkStandardNewMacro(vtkCapsuleSource); + +//---------------------------------------------------------------------------- +// Construct sphere with radius=0.5 and default resolution 8 in both Phi +// and Theta directions. Theta ranges from (0,360) and phi (0,180) degrees. +// \todo +vtkCapsuleSource::vtkCapsuleSource(int res) +{ + res = res < 8 ? 8 : res; + this->Radius = 0.5; + this->Center[0] = 0.0; + this->Center[1] = 0.0; + this->Center[2] = 0.0; + + this->ThetaResolution = res; + this->PhiResolution = res; + this->LatLongTessellation = 0; + this->CylinderLength = 1.0; + + this->SetNumberOfInputPorts(0); +} + +namespace +{ +void InsertPole(vtkPoints* points, vtkFloatArray *normals, + double center[3], double radius, double halfHeight) +{ + double x[3]; + x[0] = center[0]; + x[1] = center[1] + halfHeight; + x[2] = center[2] + radius; + points->InsertNextPoint(x); + + x[0] = x[1] = 0.0; + x[2] = (radius > 0 ? 1.0 : -1.0); + normals->InsertNextTuple(x); +} + +void FillHalfSphere(vtkPoints* points, vtkFloatArray *normals, + double thetaResolution, double phiResolution, + double startAngle /* In radians*/, double sign, + double center[3], double radius, double halfHeight) +{ + double n[3], x[3], norm; + + double deltaTheta = vtkMath::DoublePi() / (thetaResolution - 1); + double deltaPhi = vtkMath::DoublePi() / (phiResolution - 1); + for (int i=0; i < thetaResolution; ++i) + { + double theta = startAngle + sign*i*deltaTheta; + + for (int j= 1; j < phiResolution- 1; ++j) + { + double phi = j*deltaPhi; + double r = radius * sin(phi); + n[0] = r * cos(theta); + n[1] = r * sin(theta); + n[2] = radius * cos(phi); + x[0] = n[0] + center[0]; + x[1] = n[1] + center[1] + halfHeight; + x[2] = n[2] + center[2]; + points->InsertNextPoint(x); + + if ( (norm = vtkMath::Norm(n)) == 0.0 ) + { + norm = 1.0; + } + n[0] /= norm; + n[1] /= norm; + n[2] /= norm; + normals->InsertNextTuple(n); + } + } +} + +void ConnectCylinderSide(vtkCellArray* faces, + int minusPoleId, int plusPoleId, + int clockwise, int increment, bool quadrangle) +{ + vtkIdType pts[4]; + for (int i = 0; i < increment; ++i) + { + pts[0] = minusPoleId + clockwise*i; + pts[1] = plusPoleId + clockwise*i; + + if ( !quadrangle ) + { + pts[2] = pts[0] + clockwise; + faces->InsertNextCell(3, pts); + + pts[0] = pts[2]; + pts[2] = pts[1] + clockwise; + faces->InsertNextCell(3, pts); + } + else + { + pts[2] = pts[1] + clockwise; + pts[3] = pts[0] + clockwise; + faces->InsertNextCell(4, pts); + } + } +} + +} // end namespace + +//---------------------------------------------------------------------------- +int vtkCapsuleSource::RequestData( + vtkInformation *vtkNotUsed(request), + vtkInformationVector **vtkNotUsed(inputVector), + vtkInformationVector *outputVector) +{ + // get the info object + vtkInformation *outInfo = outputVector->GetInformationObject(0); + + // get the ouptut + vtkPolyData *output = vtkPolyData::SafeDownCast( + outInfo->Get(vtkDataObject::DATA_OBJECT())); + + vtkPoints *newPoints; + vtkFloatArray *newNormals; + vtkCellArray *newPolys; + + // Set number of points.; + int halfSphereNumPts = (this->PhiResolution - 2) * this->ThetaResolution + 2; + int numPts = halfSphereNumPts * 2; + + // Set number of faces + int halfSpheresNumsPolys = (this->ThetaResolution - 1) * 2 //top and bottom + + (this->PhiResolution - 3) * (this->ThetaResolution - 1) * 2; //middle + int cylinderNumPolys = (this->PhiResolution -1) * 4; + int numPolys = halfSpheresNumsPolys * 2 + cylinderNumPolys; + + // Allocate ! + newPoints = vtkPoints::New(); + newPoints->Allocate(numPts); + newNormals = vtkFloatArray::New(); + newNormals->SetNumberOfComponents(3); + newNormals->Allocate(3*numPts); + newNormals->SetName("Normals"); + + newPolys = vtkCellArray::New(); + newPolys->Allocate(newPolys->EstimateSize(numPolys, 3)); + + // + // Create half sphere 1, plus side + // + double halfHeight = this->CylinderLength / 2.0; + + // North pole + InsertPole(newPoints, newNormals, this->Center, this->Radius, halfHeight); + this->UpdateProgress(0.05); + + // Create intermediate points + FillHalfSphere(newPoints, newNormals, + this->ThetaResolution, this->PhiResolution, + 0.0, 1.0, + this->Center, this->Radius, halfHeight); + this->UpdateProgress (0.255); + + // South pole + InsertPole(newPoints, newNormals, this->Center, -1*this->Radius, halfHeight); + this->UpdateProgress(0.30); // First half sphere done ! + + // + // Create half sphere 2, minus side + // + + // North pole + InsertPole(newPoints, newNormals, this->Center, this->Radius, -1*halfHeight); + this->UpdateProgress(0.305); + + // Create intermediate points + FillHalfSphere(newPoints, newNormals, + this->ThetaResolution, this->PhiResolution, + vtkMath::DoubleTwoPi(), -1, + this->Center, this->Radius, -1.0*halfHeight); + this->UpdateProgress (0.555); + + // South pole + InsertPole(newPoints, newNormals, + this->Center, -1*this->Radius, -1*halfHeight); + this->UpdateProgress (0.60); // Second half sphere done ! + + // + // Generate mesh connectivity + // + + vtkIdType pts[4]; + // increment represent how many ids have passed every + // time we change by one delta theta + int increment = this->PhiResolution - 2; + // Ids of the poles + int northPoleMinusId = 0; + int southPoleMinusId = halfSphereNumPts -1; + int northPolePlusId = halfSphereNumPts; + int southPolePlusId = numPts - 1; + + //First half sphere + // Connect the minus side half sphere north pole. + for (int i = 0; i < this->ThetaResolution - 1; ++i) + { + pts[0] = northPoleMinusId; + pts[1] = (i * increment) + 1; + pts[2] = pts[1] + increment; + newPolys->InsertNextCell(3, pts); + } + this->UpdateProgress (0.605); + + // South pole connectivity + for (int i = 1; i < this->ThetaResolution; ++i) + { + pts[0] = i*increment; + pts[1] = southPoleMinusId; + pts[2] = pts[0] + increment; + newPolys->InsertNextCell(3, pts); + } + this->UpdateProgress (0.75); //First half-sphere done ! + + // Seconde half sphere + // North pole connectivity + for (int i = 0; i < this->ThetaResolution - 1; ++i) + { + pts[2] = northPolePlusId; + pts[1] = (i * increment) + 1 + northPolePlusId; + pts[0] = pts[1] + increment; + newPolys->InsertNextCell(3, pts); + } + this->UpdateProgress (0.755); + + // South pole connectivity + for (int i = 1; i < this->ThetaResolution; i++) + { + pts[0] = northPolePlusId + i*increment; + pts[2] = southPolePlusId; + pts[1] = pts[0] + increment; + newPolys->InsertNextCell(3, pts); + } + this->UpdateProgress (0.9); + + // Both half sphere at the same time, connectivity of the band. + vtkIdType ptsOtherSide[4]; + for (int i = 1; i < northPolePlusId - 1 - increment; i += increment) + { + for (int j = 0; j < increment - 1; ++j) + { + pts[0] = j + i; + pts[1] = j + i + 1; + pts[2] = j + i + increment + 1; + + ptsOtherSide[0] = pts[0] + northPolePlusId; + ptsOtherSide[1] = pts[2] + northPolePlusId; + ptsOtherSide[2] = pts[1] + northPolePlusId; + + if ( !this->LatLongTessellation ) + { + newPolys->InsertNextCell(3, pts); + newPolys->InsertNextCell(3, ptsOtherSide); + pts[1] = pts[2]; + pts[2] = j + i + increment; + + ptsOtherSide[1] = pts[2] + northPolePlusId; + ptsOtherSide[2] = pts[1] + northPolePlusId; + + newPolys->InsertNextCell(3, pts); + newPolys->InsertNextCell(3, ptsOtherSide); + } + else + { + pts[3] = j + i + increment; + + ptsOtherSide[1] = pts[3] + northPolePlusId; + ptsOtherSide[3] = ptsOtherSide[2]; + ptsOtherSide[2] = pts[2] + northPolePlusId; + + newPolys->InsertNextCell(4, pts); + newPolys->InsertNextCell(4, ptsOtherSide); + } + } + } + + // Cylinder pole connectivity + // first side + ConnectCylinderSide(newPolys, + northPoleMinusId, northPolePlusId, 1, + increment, this->LatLongTessellation); + + // second side + ConnectCylinderSide(newPolys, + southPoleMinusId, southPolePlusId, -1, + increment, this->LatLongTessellation); + this->UpdateProgress (0.99); + + // Weird south pole minus face case + pts[0] = northPoleMinusId + increment; + pts[1] = northPolePlusId + increment; + if ( !this->LatLongTessellation ) + { + pts[2] = southPoleMinusId; + newPolys->InsertNextCell(3, pts); + + pts[0] = pts[1]; + pts[1] = southPolePlusId; + newPolys->InsertNextCell(3, pts); + } + else + { + pts[2] = southPolePlusId; + pts[3] = southPoleMinusId; + newPolys->InsertNextCell(4, pts); + } + + // Weird north pole 2 face case + pts[0] = southPoleMinusId - increment; + pts[1] = southPolePlusId - increment; + if ( !this->LatLongTessellation ) + { + pts[2] = northPoleMinusId; + newPolys->InsertNextCell(3, pts); + + pts[0] = pts[1]; + pts[1] = northPolePlusId; + newPolys->InsertNextCell(3, pts); + } + else + { + pts[2] = northPolePlusId; + pts[3] = northPoleMinusId; + newPolys->InsertNextCell(4, pts); + } + + // Update ourselves and release memeory + // + newPoints->Squeeze(); + output->SetPoints(newPoints); + newPoints->Delete(); + + newNormals->Squeeze(); + output->GetPointData()->SetNormals(newNormals); + newNormals->Delete(); + + newPolys->Squeeze(); + output->SetPolys(newPolys); + newPolys->Delete(); + + return 1; +} + +//---------------------------------------------------------------------------- +void vtkCapsuleSource::PrintSelf(ostream& os, vtkIndent indent) +{ + this->Superclass::PrintSelf(os,indent); + + os << indent << "Theta Resolution: " << this->ThetaResolution << "\n"; + os << indent << "Phi Resolution: " << this->PhiResolution << "\n"; + os << indent << "Radius: " << this->Radius << "\n"; + os << indent << "Center: (" << this->Center[0] << ", " + << this->Center[1] << ", " << this->Center[2] << ")\n"; + os << indent + << "LatLong Tessellation: " << this->LatLongTessellation << "\n"; + os << indent << "Cylinder Length: " << this->CylinderLength << "\n"; +} + +//---------------------------------------------------------------------------- +int vtkCapsuleSource::RequestInformation( + vtkInformation *vtkNotUsed(request), + vtkInformationVector **vtkNotUsed(inputVector), + vtkInformationVector *outputVector) +{ + // get the info object + vtkInformation *outInfo = outputVector->GetInformationObject(0); + + outInfo->Set(vtkStreamingDemandDrivenPipeline::MAXIMUM_NUMBER_OF_PIECES(), + -1); + + double halfLength = this->CylinderLength / 2.0; + outInfo->Set(vtkStreamingDemandDrivenPipeline::WHOLE_BOUNDING_BOX(), + this->Center[0] - this->Radius - halfLength, + this->Center[0] + this->Radius + halfLength, + this->Center[1] - this->Radius, + this->Center[1] + this->Radius, + this->Center[2] - this->Radius, + this->Center[2] + this->Radius); + + return 1; +} diff --git a/Libs/VTK/Filters/Sources/vtkCapsuleSource.h b/Libs/VTK/Filters/Sources/vtkCapsuleSource.h new file mode 100644 index 0000000..778deaa --- /dev/null +++ b/Libs/VTK/Filters/Sources/vtkCapsuleSource.h @@ -0,0 +1,111 @@ +/*========================================================================= + + Program: Bender + + Copyright (c) Kitware Inc. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0.txt + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + +=========================================================================*/ +// .NAME vtkCapsuleSource - Generate a capsule centered at the origin +// .SECTION Description +// vtkCapsuleSource creates a capsule (represented by polygons) of specified +// radius centered at the origin. The resolution (polygonal discretization) +// in both the latitude (phi) and longitude (theta) directions can be +// specified as well as the length of the capsule cylinder (CylinderLength). +// By default, the surface tessellation of the sphere uses triangles; +// however you can set LatLongTessellation to +// produce a tessellation using quadrilaterals (except at the poles of the +// capsule). + +#ifndef __vtkCapsuleSource_h +#define __vtkCapsuleSource_h + +// VTK includes +#include + +// Bender includes +#include "vtkBenderSourcesExport.h" + +#define VTK_MAX_SPHERE_RESOLUTION 1024 + +class VTK_BENDER_SOURCES_EXPORT vtkCapsuleSource : public vtkPolyDataAlgorithm +{ +public: + vtkTypeMacro(vtkCapsuleSource,vtkPolyDataAlgorithm); + void PrintSelf(ostream& os, vtkIndent indent); + + // Description: + // Construct sphere with radius=0.5 and default resolution 8 in both Phi + // and Theta directions. + static vtkCapsuleSource *New(); + + // Description: + // Set radius of sphere. Default is 0.5. + vtkSetClampMacro(Radius,double,0.0,VTK_DOUBLE_MAX); + vtkGetMacro(Radius,double); + + // Description: + // Set the center of the sphere. Default is 0,0,0. + vtkSetVector3Macro(Center,double); + vtkGetVectorMacro(Center,double,3); + + // Description: + // Set the length of the cylinder. Default is 1.0. + vtkSetClampMacro(CylinderLength,double, 0.0, VTK_DOUBLE_MAX); + vtkGetMacro(CylinderLength,double); + + // Description: + // Set the number of points used in the longitude direction + // for the capsule extremities. + vtkSetClampMacro(ThetaResolution,int,3,VTK_MAX_SPHERE_RESOLUTION); + vtkGetMacro(ThetaResolution,int); + + // Description: + // Set the number of points used in the lattitude direction + // for the capsule extremities. + vtkSetClampMacro(PhiResolution,int,3,VTK_MAX_SPHERE_RESOLUTION); + vtkGetMacro(PhiResolution,int); + + // Description: + // Cause the sphere to be tessellated with edges along the latitude + // and longitude lines. If off, triangles are generated at non-polar + // regions, which results in edges that are not parallel to latitude and + // longitude lines. If on, quadrilaterals are generated everywhere + // except at the poles. This can be useful for generating a wireframe + // sphere with natural latitude and longitude lines. + vtkSetMacro(LatLongTessellation,int); + vtkGetMacro(LatLongTessellation,int); + vtkBooleanMacro(LatLongTessellation,int); + +protected: + vtkCapsuleSource(int res=8); + ~vtkCapsuleSource() {} + + int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *); + int RequestInformation(vtkInformation *, vtkInformationVector **, vtkInformationVector *); + + double Radius; + double Center[3]; + int ThetaResolution; + int PhiResolution; + int LatLongTessellation; + int FillPoles; + double CylinderLength; + +private: + vtkCapsuleSource(const vtkCapsuleSource&); // Not implemented. + void operator=(const vtkCapsuleSource&); // Not implemented. +}; + +#endif