Skip to content

Commit

Permalink
Add vtkCapsuleSource
Browse files Browse the repository at this point in the history
vtkCapsuleSource is polydata algorithm that generates a polygonal capsule.

See Issue #13680
  • Loading branch information
vovythevov committed Jan 8, 2013
1 parent 8446c5c commit a7caeb1
Show file tree
Hide file tree
Showing 6 changed files with 728 additions and 0 deletions.
1 change: 1 addition & 0 deletions Libs/VTK/CMakeLists.txt
Expand Up @@ -19,4 +19,5 @@
#============================================================================

add_subdirectory(Common)
add_subdirectory(Filters/Sources)
add_subdirectory(Widgets)
83 changes: 83 additions & 0 deletions 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)
35 changes: 35 additions & 0 deletions 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)
79 changes: 79 additions & 0 deletions 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 <vtkActor.h>
#include <vtkCommand.h>
#include <vtkNew.h>
#include <vtkObjectFactory.h>
#include <vtkPolyDataMapper.h>
#include <vtkRenderWindow.h>
#include <vtkRenderer.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkSmartPointer.h>

#include <vtkPolyDataWriter.h>

#include "vtkCapsuleSource.h"

int vtkCapsuleSourceTest(int, char *[])
{
vtkSmartPointer<vtkRenderer> renderer =
vtkSmartPointer<vtkRenderer>::New();
vtkSmartPointer<vtkRenderWindow> renderWindow =
vtkSmartPointer<vtkRenderWindow>::New();
renderWindow->AddRenderer(renderer);

// An interactor
vtkSmartPointer<vtkRenderWindowInteractor> renderWindowInteractor =
vtkSmartPointer<vtkRenderWindowInteractor>::New();
renderWindowInteractor->SetRenderWindow(renderWindow);

vtkSmartPointer<vtkCapsuleSource> capsuleSource =
vtkSmartPointer<vtkCapsuleSource>::New();
capsuleSource->SetThetaResolution(4);
capsuleSource->SetPhiResolution(4);
capsuleSource->SetCylinderLength(10.0);
capsuleSource->SetRadius(10.0);
capsuleSource->SetLatLongTessellation(true);

//vtkSmartPointer<vtkPolyDataWriter> w = vtkSmartPointer<vtkPolyDataWriter>::New();
//w->SetInputConnection(capsuleSource->GetOutputPort());
//w->SetFileName("./capsule.vtk");
//w->Write();

vtkSmartPointer<vtkPolyDataMapper> mapper =
vtkSmartPointer<vtkPolyDataMapper>::New();
mapper->SetInputConnection(capsuleSource->GetOutputPort());
vtkSmartPointer<vtkActor> actor =
vtkSmartPointer<vtkActor>::New();
actor->SetMapper(mapper);

// Render
renderer->AddActor(actor);
renderWindow->Render();
renderWindowInteractor->Initialize();
renderWindow->Render();

// Begin mouse interaction
renderWindowInteractor->Start();

return EXIT_SUCCESS;
}

0 comments on commit a7caeb1

Please sign in to comment.