Added complete VizFwk

Added the complete VizFwk from the ResInsight branch in Perforce as of
changelist 190.
This commit is contained in:
sigurdp 2013-11-01 08:49:42 +01:00
parent fbfbdfca84
commit bbebebadd5
1164 changed files with 458144 additions and 0 deletions

View File

@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="NotBuildable|Win32">
<Configuration>NotBuildable</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{FB015304-89D5-4093-B01A-0E7F642971DC}</ProjectGuid>
<RootNamespace>CMake</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='NotBuildable|Win32'">
<ConfigurationType>Utility</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemGroup>
<None Include="..\CMakeLists.txt" />
<None Include="..\Tests\CMakeLists.txt" />
<None Include="Utils\ceeDetermineCompilerFlags.cmake" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="..\CMakeLists.txt">
<Filter>for CeeViz</Filter>
</None>
<None Include="..\Tests\CMakeLists.txt">
<Filter>for UnitTests</Filter>
</None>
<None Include="Utils\ceeDetermineCompilerFlags.cmake">
<Filter>Utils</Filter>
</None>
</ItemGroup>
<ItemGroup>
<Filter Include="for CeeViz">
<UniqueIdentifier>{3e72b0a1-06b6-459f-9607-d9fa896d7f8c}</UniqueIdentifier>
</Filter>
<Filter Include="for UnitTests">
<UniqueIdentifier>{51e511a3-e51f-4744-bff6-f658fccf0863}</UniqueIdentifier>
</Filter>
<Filter Include="Utils">
<UniqueIdentifier>{8764f605-13cc-4037-9f2b-fcae94e99ae9}</UniqueIdentifier>
</Filter>
</ItemGroup>
</Project>

View File

@ -0,0 +1,80 @@
# Setup the main platform defines
#-----------------------------------------------------
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
add_definitions(-DCVF_LINUX)
elseif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
add_definitions(-DCVF_OSX)
endif()
# Compiler specific defines
#-----------------------------------------------------
# Must add debug define manually on GCC
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -D_DEBUG")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ")
endif()
# We alwys want Unicode on Win
if (MSVC)
add_definitions(-DUNICODE -D_UNICODE)
endif()
include(CheckCXXCompilerFlag)
option(CEE_WARNINGS_AS_ERRORS "Make all warnings into errors" ON)
# Compiler flags for GCC
#-----------------------------------------------------
if (CMAKE_COMPILER_IS_GNUCXX)
# Setup our BASE compile flags
set(CEE_BASE_CXX_FLAGS "-Wall -Wextra -pedantic")
if (CEE_WARNINGS_AS_ERRORS)
set(CEE_BASE_CXX_FLAGS "-Werror ${CEE_BASE_CXX_FLAGS}")
endif()
# Setup the our STRICT compile flags
# These are the flags we would like to use on all of our own libraries
set(CEE_STRICT_CXX_FLAGS "${CEE_BASE_CXX_FLAGS} -Wconversion -Woverloaded-virtual -Wformat -Wcast-align")
# Add warning not present on older GCCs
CHECK_CXX_COMPILER_FLAG("-Wlogical-op" HAS_WLOGICAL_OP)
if (HAS_WLOGICAL_OP)
set(CEE_STRICT_CXX_FLAGS "${CEE_STRICT_CXX_FLAGS} -Wlogical-op")
endif()
endif()
# Compiler flags for MSVC
#-----------------------------------------------------
if (MSVC)
# Strip out the /W3 flag that Cmake sets by default
string (REPLACE "/W3" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
# Setup our BASE compile flags
set(CEE_BASE_CXX_FLAGS "")
if (CEE_WARNINGS_AS_ERRORS)
set(CEE_BASE_CXX_FLAGS "/WX ${CEE_BASE_CXX_FLAGS}")
endif()
# Setup the our STRICT compile flags
# These are the flags we would like to use on all of our own libraries
set(CEE_STRICT_CXX_FLAGS "${CEE_BASE_CXX_FLAGS} /Wall")
# Must add base warning level after setting up strict
set(CEE_BASE_CXX_FLAGS "${CEE_BASE_CXX_FLAGS} /W3")
endif()

67
Fwk/VizFwk/CMakeLists.txt Normal file
View File

@ -0,0 +1,67 @@
cmake_minimum_required(VERSION 2.8)
project(VizFramework)
# Determine if we're being run stand-alone or invoked from some other project
set(CEE_STAND_ALONE ON)
if (PROJECT_SOURCE_DIR STREQUAL CMAKE_SOURCE_DIR)
message("VizFramework project being built stand-alone")
else()
set(CEE_STAND_ALONE OFF)
message("VizFramework project is invoked from other project")
endif()
if (CEE_STAND_ALONE)
# Set a default build type (not relevant for WIN32)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, options are: None Debug Release RelWithDebInfo MinSizeRel." FORCE)
endif()
include(CMake/Utils/ceeDetermineCompilerFlags.cmake)
endif()
add_subdirectory(LibCore)
add_subdirectory(LibIo)
add_subdirectory(LibGeometry)
add_subdirectory(LibRender)
add_subdirectory(LibViewing)
add_subdirectory(LibRegGrid2D)
add_subdirectory(LibStructGrid)
add_subdirectory(LibFreeType)
add_subdirectory(ThirdParty/FreeType)
add_subdirectory(LibUtilities)
option(CEE_BUILD_GUI_QT "Build GUI library for Qt" ON)
if (CEE_BUILD_GUI_QT)
add_subdirectory(LibGuiQt)
endif()
if (CEE_STAND_ALONE)
option(CEE_BUILD_UNIT_TESTS "Build unit tests" ON)
if (CEE_BUILD_UNIT_TESTS)
add_subdirectory(Tests)
endif()
option(CEE_BUILD_TEST_APPS "Build test apps" ON)
if (CEE_BUILD_TEST_APPS)
if (CEE_BUILD_GUI_QT)
# For now, build the snippet libs here
add_subdirectory(Tests/SnippetsBasis)
add_subdirectory(TestApps/Qt/QtMinimal)
add_subdirectory(TestApps/Qt/QtMultiView)
add_subdirectory(TestApps/Qt/QtSnippetRunner)
endif()
endif()
endif()

View File

@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Doxygen|Win32">
<Configuration>Doxygen</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{F5FA2496-1AD3-4569-8EA1-5B5F01450B03}</ProjectGuid>
<RootNamespace>Doxygen</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Label="Configuration" Condition="'$(Configuration)|$(Platform)'=='Doxygen|Win32'">
<ConfigurationType>Utility</ConfigurationType>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Doxygen|Win32'">
<OutDir>$(ProjectDir)\html\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Doxygen|Win32'">
<IntDir>$(ProjectDir)\html\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Doxygen|Win32'">
<ExtensionsToDeleteOnClean>*.html;*.css;*.map;*.md5;*.dot;*.png;*.gif;*.js;installdox</ExtensionsToDeleteOnClean>
</PropertyGroup>
<ItemGroup>
<None Include="CeetronDoxygenGuidelines.txt" />
<None Include="html\index.html" />
<CustomBuild Include="RunDoxygen.bat">
<FileType>Document</FileType>
<Command Condition="'$(Configuration)|$(Platform)'=='Doxygen|Win32'">RunDoxygen.bat</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Doxygen|Win32'">Running Doxygen...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Doxygen|Win32'">html/ToForceRebuildEveryTime.html</Outputs>
</CustomBuild>
<None Include="VizDoxygenSetup" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="CeetronDoxygenGuidelines.txt" />
<None Include="html\index.html" />
<None Include="VizDoxygenSetup" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="RunDoxygen.bat" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,42 @@
Documentation guidelines when writing Doxygen doc for CVC.
-------------------------------------------------------------
Ripped from: http://api.haiku-os.org/apidoc.html
Relevant paragraph commands in decreasing order of importance:
\attention
* Used when the developer is bound to make a mistake, when the API is ambiguous.
The difference between this and a warning is that warnings warn about things
that are the developers fault, and attention blocks warn about things that
might go wrong because of the way the API is structured.
* Used to warn for abuse of the API that might be caused by the way the internals
of the system are structured.
\warning
* Used to warn developers about using the API in a certain way. Warnings apply
especially to new developers that aren't completely familiar with the API and that
might want to abuse it. For example, the thread safety of BString requires a warning.
\note
* Used to place references to other documentation that might not be directly related
to the text. For example, BLooper will have a direct reference to BHandler in the
class description, but BMessenger will be mentioned in a note because it does not
directly influence the use of the class.
* Can also be used for useful hints or notes that somehow need to stand out from the
rest of the text.
\remark
* Remarks are small notes that would interrupt the flow of the text. For example,
if you in a text ignore a certain condition that is so extremely rare and uncommon,
you can put a remark at the end of the text to tell that you have been lying.
* Remarks interact with the text whereas notes add something unmentioned to it.
In newer versions of Doxygen it seems that these gets tagged with a color in the
final documentation.
RED \attention
RED \warning
YELLOW \note
nocolor \remark

View File

@ -0,0 +1,2 @@
..\Tools\Doxygen\doxygen.exe VizDoxygenSetup
pause

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,320 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug MD TBB|Win32">
<Configuration>Debug MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD TBB|x64">
<Configuration>Debug MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|Win32">
<Configuration>Debug MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|x64">
<Configuration>Debug MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|Win32">
<Configuration>Release MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|x64">
<Configuration>Release MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|Win32">
<Configuration>Release MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|x64">
<Configuration>Release MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A9C7A239-B761-A892-BF34-5AECA0D9EE88}</ProjectGuid>
<RootNamespace>LibCore</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="cvfArray.h" />
<ClInclude Include="cvfAssert.h" />
<ClInclude Include="cvfBase.h" />
<ClInclude Include="cvfBase64.h" />
<ClInclude Include="cvfCharArray.h" />
<ClInclude Include="cvfCodeLocation.h" />
<ClInclude Include="cvfCollection.h" />
<ClInclude Include="cvfColor3.h" />
<ClInclude Include="cvfColor4.h" />
<ClInclude Include="cvfConfigCore.h" />
<ClInclude Include="cvfDebugTimer.h" />
<ClInclude Include="cvfFlags.h" />
<ClInclude Include="cvfFunctorRange.h" />
<ClInclude Include="cvfLibCore.h" />
<ClInclude Include="cvfLogDestination.h" />
<ClInclude Include="cvfLogDestinationConsole.h" />
<ClInclude Include="cvfLogDestinationFile.h" />
<ClInclude Include="cvfLogEvent.h" />
<ClInclude Include="cvfLogger.h" />
<ClInclude Include="cvfLogManager.h" />
<ClInclude Include="cvfMath.h" />
<ClInclude Include="cvfMatrix3.h" />
<ClInclude Include="cvfMatrix4.h" />
<ClInclude Include="cvfMutex.h" />
<ClInclude Include="cvfObject.h" />
<ClInclude Include="cvfPlane.h" />
<ClInclude Include="cvfPropertySet.h" />
<ClInclude Include="cvfPropertySetCollection.h" />
<ClInclude Include="cvfQuat.h" />
<ClInclude Include="cvfRect.h" />
<ClInclude Include="cvfString.h" />
<ClInclude Include="cvfSystem.h" />
<ClInclude Include="cvfTBBControl.h" />
<ClInclude Include="cvfTimer.h" />
<ClInclude Include="cvfTrace.h" />
<ClInclude Include="cvfValueArray.h" />
<ClInclude Include="cvfVariant.h" />
<ClInclude Include="cvfVector2.h" />
<ClInclude Include="cvfVector3.h" />
<ClInclude Include="cvfVector4.h" />
<ClInclude Include="cvfVersion.h" />
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
<None Include="cvfArray.inl" />
<None Include="cvfCollection.inl" />
<None Include="cvfFlags.inl" />
<None Include="cvfMath.inl" />
<None Include="cvfMatrix3.inl" />
<None Include="cvfMatrix4.inl" />
<None Include="cvfObject.inl" />
<None Include="cvfQuat.inl" />
<None Include="cvfRect.inl" />
<None Include="cvfVector2.inl" />
<None Include="cvfVector3.inl" />
<None Include="cvfVector4.inl" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfAssert.cpp" />
<ClCompile Include="cvfBase64.cpp" />
<ClCompile Include="cvfCharArray.cpp" />
<ClCompile Include="cvfCodeLocation.cpp" />
<ClCompile Include="cvfColor3.cpp" />
<ClCompile Include="cvfColor4.cpp" />
<ClCompile Include="cvfDebugTimer.cpp" />
<ClCompile Include="cvfLogDestinationConsole.cpp" />
<ClCompile Include="cvfLogDestinationFile.cpp" />
<ClCompile Include="cvfLogEvent.cpp" />
<ClCompile Include="cvfLogger.cpp" />
<ClCompile Include="cvfLogManager.cpp" />
<ClCompile Include="cvfMath.cpp" />
<ClCompile Include="cvfMutex.cpp" />
<ClCompile Include="cvfObject.cpp" />
<ClCompile Include="cvfPlane.cpp" />
<ClCompile Include="cvfPropertySet.cpp" />
<ClCompile Include="cvfPropertySetCollection.cpp" />
<ClCompile Include="cvfString.cpp" />
<ClCompile Include="cvfSystem.cpp" />
<ClCompile Include="cvfTBBControl.cpp" />
<ClCompile Include="cvfTimer.cpp" />
<ClCompile Include="cvfTrace.cpp" />
<ClCompile Include="cvfVariant.cpp" />
<ClCompile Include="cvfVector2.cpp" />
<ClCompile Include="cvfVector3.cpp" />
<ClCompile Include="cvfVector4.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,90 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="cvfArray.h" />
<ClInclude Include="cvfVersion.h" />
<ClInclude Include="cvfAssert.h" />
<ClInclude Include="cvfBase.h" />
<ClInclude Include="cvfCharArray.h" />
<ClInclude Include="cvfCollection.h" />
<ClInclude Include="cvfColor3.h" />
<ClInclude Include="cvfColor4.h" />
<ClInclude Include="cvfConfigCore.h" />
<ClInclude Include="cvfDebugTimer.h" />
<ClInclude Include="cvfFlags.h" />
<ClInclude Include="cvfLibCore.h" />
<ClInclude Include="cvfMath.h" />
<ClInclude Include="cvfMatrix3.h" />
<ClInclude Include="cvfMatrix4.h" />
<ClInclude Include="cvfObject.h" />
<ClInclude Include="cvfPlane.h" />
<ClInclude Include="cvfQuat.h" />
<ClInclude Include="cvfRect.h" />
<ClInclude Include="cvfString.h" />
<ClInclude Include="cvfSystem.h" />
<ClInclude Include="cvfTimer.h" />
<ClInclude Include="cvfTrace.h" />
<ClInclude Include="cvfVector2.h" />
<ClInclude Include="cvfVector3.h" />
<ClInclude Include="cvfVector4.h" />
<ClInclude Include="cvfValueArray.h" />
<ClInclude Include="cvfBase64.h" />
<ClInclude Include="cvfTBBControl.h" />
<ClInclude Include="cvfFunctorRange.h" />
<ClInclude Include="cvfLogger.h" />
<ClInclude Include="cvfVariant.h" />
<ClInclude Include="cvfPropertySet.h" />
<ClInclude Include="cvfPropertySetCollection.h" />
<ClInclude Include="cvfLogEvent.h" />
<ClInclude Include="cvfCodeLocation.h" />
<ClInclude Include="cvfMutex.h" />
<ClInclude Include="cvfLogManager.h" />
<ClInclude Include="cvfLogDestination.h" />
<ClInclude Include="cvfLogDestinationConsole.h" />
<ClInclude Include="cvfLogDestinationFile.h" />
</ItemGroup>
<ItemGroup>
<None Include="cvfArray.inl" />
<None Include="cvfCollection.inl" />
<None Include="cvfFlags.inl" />
<None Include="cvfMath.inl" />
<None Include="cvfMatrix3.inl" />
<None Include="cvfMatrix4.inl" />
<None Include="cvfObject.inl" />
<None Include="cvfQuat.inl" />
<None Include="cvfRect.inl" />
<None Include="cvfVector2.inl" />
<None Include="cvfVector3.inl" />
<None Include="cvfVector4.inl" />
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfAssert.cpp" />
<ClCompile Include="cvfVector4.cpp" />
<ClCompile Include="cvfCharArray.cpp" />
<ClCompile Include="cvfColor3.cpp" />
<ClCompile Include="cvfColor4.cpp" />
<ClCompile Include="cvfDebugTimer.cpp" />
<ClCompile Include="cvfMath.cpp" />
<ClCompile Include="cvfObject.cpp" />
<ClCompile Include="cvfPlane.cpp" />
<ClCompile Include="cvfString.cpp" />
<ClCompile Include="cvfSystem.cpp" />
<ClCompile Include="cvfTimer.cpp" />
<ClCompile Include="cvfTrace.cpp" />
<ClCompile Include="cvfVector2.cpp" />
<ClCompile Include="cvfVector3.cpp" />
<ClCompile Include="cvfBase64.cpp" />
<ClCompile Include="cvfTBBControl.cpp" />
<ClCompile Include="cvfLogger.cpp" />
<ClCompile Include="cvfVariant.cpp" />
<ClCompile Include="cvfPropertySet.cpp" />
<ClCompile Include="cvfPropertySetCollection.cpp" />
<ClCompile Include="cvfLogEvent.cpp" />
<ClCompile Include="cvfCodeLocation.cpp" />
<ClCompile Include="cvfMutex.cpp" />
<ClCompile Include="cvfLogManager.cpp" />
<ClCompile Include="cvfLogDestinationConsole.cpp" />
<ClCompile Include="cvfLogDestinationFile.cpp" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,25 @@
cmake_minimum_required(VERSION 2.8)
project(LibFreeType)
# Use our strict compile flags
#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}")
include_directories(../LibCore)
include_directories(../LibIo)
include_directories(../LibGeometry)
include_directories(../LibRender)
include_directories(../ThirdParty/FreeType/include)
set(CEE_HEADER_FILES
cvfFreeTypeFont.h
)
set(CEE_SOURCE_FILES
cvfFreeTypeFont.cpp
)
add_library(${PROJECT_NAME} ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES})

View File

@ -0,0 +1,244 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug MD TBB|Win32">
<Configuration>Debug MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD TBB|x64">
<Configuration>Debug MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|Win32">
<Configuration>Debug MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|x64">
<Configuration>Debug MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|Win32">
<Configuration>Release MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|x64">
<Configuration>Release MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|Win32">
<Configuration>Release MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|x64">
<Configuration>Release MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{2667AC1D-CA80-42F8-8644-DDB58D342FF2}</ProjectGuid>
<RootNamespace>LibFreeType</RootNamespace>
<ProjectName>LibFreeType</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibIo;../LibRender;../LibUtilities;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibIo;../LibRender;../LibUtilities;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibIo;../LibRender;../LibUtilities;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibIo;../LibRender;../LibUtilities;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibIo;../LibRender;../LibUtilities;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibIo;../LibRender;../LibUtilities;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibIo;../LibRender;../LibUtilities;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<ClCompile>
<WarningLevel>Level4</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibIo;../LibRender;../LibUtilities;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfFreeTypeFont.h" />
<ClInclude Include="cvfLibFreeType.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfFreeTypeFont.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfLibFreeType.h" />
<ClInclude Include="cvfFreeTypeFont.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfFreeTypeFont.cpp" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,722 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfGlyph.h"
#include "cvfTextureImage.h"
#include "cvfFreeTypeFont.h"
#ifdef WIN32
#define CVF_USE_FREETYPE_LIB
#endif
// Todo: Implement and check on Linux and iOS
#ifdef CVF_USE_FREETYPE_LIB
#include "cvfBase64.h"
#include <vector>
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_BITMAP_H
#endif // CVF_USE_FREETYPE_LIB
namespace cvf {
//==================================================================================================
//
// Private implementation of the FreeType font interface
//
//==================================================================================================
class FreeTypeFontInterface : public Object
{
#ifdef CVF_USE_FREETYPE_LIB
public:
FT_Library m_ftLib; // FreeType interface library
FT_Face m_ftFace; // FreeType face for currently loaded font
UByteArray m_data; // Locally stored font data. Only used when loading font via FT_New_Memory_Face(..)
uint m_dpiX; // Horizontal DPI
uint m_dpiY; // Vertical DPI
public:
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
FreeTypeFontInterface(uint dpiX, uint dpiY)
: m_ftLib(NULL),
m_ftFace(NULL),
m_dpiX(dpiX),
m_dpiY(dpiY)
{
// Initialize FreeType library
// Seems that init the reasons for failure here would be memory allocations
// Since we're inside a constructor this will amount to an exception
FT_Error error = FT_Init_FreeType(&m_ftLib);
CVF_ASSERT(!error);
CVF_UNUSED(error);
//if (error)
//{
// m_ftLib = NULL;
// CVF_ERROR(String("Unable to initialize the FreeType library: Error [%1]").arg((int)error));
//}
};
//--------------------------------------------------------------------------------------------------
/// Destructor
//--------------------------------------------------------------------------------------------------
~FreeTypeFontInterface()
{
unload();
// Unload FreeType library
FT_Done_FreeType(m_ftLib);
}
//--------------------------------------------------------------------------------------------------
/// Returns true if the font is set up properly and ready to be used, otherwise returns false.
//--------------------------------------------------------------------------------------------------
bool isEmpty() const
{
return m_ftFace ? false : true;
}
//--------------------------------------------------------------------------------------------------
/// Get the name of the font
//--------------------------------------------------------------------------------------------------
String name()
{
String fontName;
if (!isEmpty())
{
if (m_ftFace->family_name)
{
fontName += m_ftFace->family_name;
if (m_ftFace->style_name)
{
fontName += " ";
fontName += m_ftFace->style_name;
}
}
}
return fontName;
}
//--------------------------------------------------------------------------------------------------
/// Load font from FreeType data format. Note: updateResolution(..) needs to be called after this.
//--------------------------------------------------------------------------------------------------
bool load(const ubyte* data, size_t numBytes)
{
CVF_TIGHT_ASSERT(data);
CVF_TIGHT_ASSERT(numBytes > 0);
CVF_TIGHT_ASSERT(m_ftLib);
// Close currently loaded font, if any
unload();
// Make a copy of the font data to ensure it's alive as long as the font is open as required
// by FT_New_Memory_Face(..). This is, of course, not a requirement for FT_New_Face(<filename>)
m_data.assign(data, numBytes);
// Translate into FreeType data-types
const FT_Byte* file_base = static_cast<const FT_Byte*>(m_data.ptr());
FT_Long file_size = static_cast<FT_Long>(m_data.size());
FT_Error error = FT_New_Memory_Face(m_ftLib, file_base, file_size, 0, &m_ftFace);
return error ? false : true;
}
//--------------------------------------------------------------------------------------------------
/// Load font from file. Note: updateResolution(..) needs to be called after this.
//--------------------------------------------------------------------------------------------------
bool load(const cvf::String& filename)
{
// Close currently loaded font, if any
unload();
FT_Error error = FT_New_Face(m_ftLib, filename.toUtf8().ptr(), 0, &m_ftFace);
return error ? false : true;
}
//--------------------------------------------------------------------------------------------------
/// Load base64 encoded font from memory. Note: updateResolution(..) needs to be called after this.
//--------------------------------------------------------------------------------------------------
bool load(const char** data, size_t numBlocks)
{
std::string encodedFontData;
size_t i;
for (i = 0; i < numBlocks; i++)
{
encodedFontData += data[i];
}
// Todo: Optimize this!
ref<UByteArray> decodedFontData = Base64::decode(encodedFontData);
if (decodedFontData.isNull()) return false;
if (decodedFontData->size() == 0) return false;
const FT_Byte* file_base = static_cast<const FT_Byte*>(static_cast<const void*>(decodedFontData->ptr()));
FT_Long file_size = static_cast<FT_Long>(decodedFontData->size());
return load(file_base, file_size);
}
//--------------------------------------------------------------------------------------------------
/// Update font size
//--------------------------------------------------------------------------------------------------
bool setSize(uint size)
{
CVF_ASSERT(!isEmpty());
FT_Error error = FT_Set_Char_Size(m_ftFace, 0, static_cast<FT_F26Dot6>(size) << 6, m_dpiX, m_dpiY);
if (error)
{
//CVF_ERROR(String("Unable to update FreeType font size: Error [%1]").arg((int)error));
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
/// Close font if open
//--------------------------------------------------------------------------------------------------
void unload()
{
if (isEmpty()) return;
FT_Done_Face(m_ftFace);
m_ftFace = NULL;
m_data.clear();
}
//--------------------------------------------------------------------------------------------------
/// Create a glyph for the given character
//--------------------------------------------------------------------------------------------------
ref<Glyph> createGlyph(wchar_t character)
{
if (isEmpty()) return NULL;
// Look up the glyph index corresponding to the given character code in the charmap that is currently
// selected for the face. This should really be the UTF-32 representation form of Unicode; for example,
// if you want to load character U+1F028, use value 0x1F028 as the value for character.
//
// Note that FT_Get_Char_Index is one of the rare FreeType functions that do not return an error code.
// However, when a given character code has no glyph image in the face, the value 0 is returned.
// By convention, it always corresponds to a special glyph image called the missing glyph, which
// is commonly displayed as a box or a space.
FT_UInt glyph_index = FT_Get_Char_Index(m_ftFace, character);
// Load a single glyph into the glyph slot of a face object
FT_Error error = FT_Load_Glyph(m_ftFace, glyph_index, FT_LOAD_DEFAULT);
if (error)
{
//CVF_ERROR(String("Unable to load glyph from FreeType font: Error [%1]").arg((int)error));
return NULL;
}
// Convert a given glyph image to a bitmap. It does so by inspecting the glyph image format,
// finding the relevant renderer, and invoking it.
error = FT_Render_Glyph(m_ftFace->glyph, FT_RENDER_MODE_NORMAL);
if (error)
{
//CVF_ERROR(String("Unable to convert FreeType font glyph image to bitmap: Error [%1]").arg((int)error));
return NULL;
}
CVF_ASSERT(m_ftFace->glyph->advance.x == m_ftFace->glyph->metrics.horiAdvance);
//
ref<Glyph> glyph = new Glyph(character);
glyph->setHorizontalBearingX(static_cast<short>(m_ftFace->glyph->metrics.horiBearingX) >> 6); // NB! May be negative
glyph->setHorizontalBearingY(static_cast<short>(m_ftFace->glyph->metrics.horiBearingY) >> 6); // NB! May be negative
glyph->setHorizontalAdvance(m_ftFace->glyph->metrics.horiAdvance >> 6);
// Create from the given FreeType glyph, if valid
if (m_ftFace->glyph && (m_ftFace->glyph->bitmap.width > 0) && (m_ftFace->glyph->bitmap.rows > 0))
{
CVF_ASSERT(static_cast<int>(m_ftFace->glyph->metrics.width >> 6) == static_cast<int>(m_ftFace->glyph->bitmap.width));
CVF_ASSERT(static_cast<int>(m_ftFace->glyph->metrics.height >> 6) == static_cast<int>(m_ftFace->glyph->bitmap.rows));
// Safe to cast
uint bitmapWidth = static_cast<uint>(m_ftFace->glyph->bitmap.width);
uint bitmapHeight = static_cast<uint>(m_ftFace->glyph->bitmap.rows);
// Prepare texture image
TextureImage* textureImage = new TextureImage;
textureImage->allocate(bitmapWidth, bitmapHeight);
ubyte colorComponent;
// Populate m_ftFace->glyph texture image
uint x, y;
for (y = 0; y < bitmapHeight; y++)
{
for (x = 0; x < bitmapWidth; x++)
{
colorComponent = m_ftFace->glyph->bitmap.buffer[((m_ftFace->glyph->bitmap.rows-1-y)*m_ftFace->glyph->bitmap.width)+x];
// Todo: Consider replacing this with a two-channel GL_LUMINANCE_ALPHA
textureImage->setPixel(x, y, Color4ub(255, 255, 255, colorComponent));
}
}
glyph->setTextureImage(textureImage);
glyph->setWidth(textureImage->width());
glyph->setHeight(textureImage->height());
}
// Or create an empty m_ftFace->glyph
else
{
// Make sure we've got an advance.
// This will be used to create a totally transparent textureImage.
if (glyph->horizontalAdvance() == 0)
{
// Load the missing glyph and get advance from there
FT_Error error = FT_Load_Glyph(m_ftFace, 0, FT_LOAD_DEFAULT);
if (error)
{
//CVF_ERROR(String("Unable to load the 'missing-glyph' from FreeType font: Error [%1]").arg((int)error));
// Still unable to get an advance -> hardcode it
glyph->setHorizontalAdvance(10);
}
else
{
glyph->setHorizontalAdvance(m_ftFace->glyph->advance.x >> 6);
}
// Todo: Cach up value
}
CVF_ASSERT(glyph->horizontalAdvance() > 0);
// Prepare texture image
TextureImage* textureImage = new TextureImage;
textureImage->allocate(glyph->horizontalAdvance(), glyph->horizontalAdvance());
textureImage->fill(Color4ub(0, 0, 0, 0)); // Totally transparent!
glyph->setTextureImage(textureImage);
glyph->setWidth(textureImage->width());
glyph->setHeight(textureImage->height());
// Bearing is not needed since we've filled the whole area based on the advance
glyph->setHorizontalBearingX(0);
glyph->setHorizontalBearingY(0);
}
return glyph;
}
//--------------------------------------------------------------------------------------------------
/// Get kerning values for in-between-characters for given string
//--------------------------------------------------------------------------------------------------
bool getKerning(String* str, std::vector<int>* kerningVector)
{
CVF_TIGHT_ASSERT(str);
CVF_TIGHT_ASSERT(kerningVector);
if (isEmpty()) return false;
if (!FT_HAS_KERNING(m_ftFace)) return false;
size_t numCharacters = str->size();
if (numCharacters < 2) return false;
kerningVector->clear();
kerningVector->reserve(numCharacters-1);
// Initialized to 'missing glyph'.
// There is never any kerning distance associated with this glyph.
FT_UInt curr_glyph_index = 0; // Current glyph
FT_UInt prev_glyph_index = 0; // Previous glyph
FT_Vector delta;
size_t i;
for (i = 0; i < numCharacters; i++)
{
const wchar_t character = str->c_str()[i];
curr_glyph_index = FT_Get_Char_Index(m_ftFace, character);
if (i > 0)
{
FT_Get_Kerning(m_ftFace, prev_glyph_index, curr_glyph_index, FT_KERNING_DEFAULT, &delta);
// Note: We do not check the error code returned by FT_Get_Kerning. This is because
// the function always sets the content of delta to (0,0) when an error occurs.
kerningVector->push_back(delta.x >> 6);
}
prev_glyph_index = curr_glyph_index;
}
return true;
}
//--------------------------------------------------------------------------------------------------
/// Get kerning value between two characters
//--------------------------------------------------------------------------------------------------
bool getKerning(wchar_t character, wchar_t nextCharacter, int* kerning)
{
if (isEmpty()) return false;
if (!FT_HAS_KERNING(m_ftFace)) return false;
FT_UInt curr_glyph_index = FT_Get_Char_Index(m_ftFace, character);
FT_UInt next_glyph_index = FT_Get_Char_Index(m_ftFace, nextCharacter);
FT_Vector delta;
FT_Get_Kerning(m_ftFace, curr_glyph_index, next_glyph_index, FT_KERNING_DEFAULT, &delta);
// Note: We do not check the error code returned by FT_Get_Kerning. This is because
// the function always sets the content of delta to (0,0) when an error occurs.
*kerning = delta.x >> 6;
return true;
}
//--------------------------------------------------------------------------------------------------
/// Get FreeType library version
//--------------------------------------------------------------------------------------------------
static bool version(int* major, int* minor, int* patch)
{
FT_Library ftLib;
FT_Error error = FT_Init_FreeType(&ftLib);
if (error) return false;
FT_Library_Version(ftLib, major, minor, patch);
FT_Done_FreeType(ftLib);
return true;
}
//--------------------------------------------------------------------------------------------------
/// Get FreeType library copyright year.
// NB! Must be updated when upgrading the FreeType library!
//--------------------------------------------------------------------------------------------------
static String copyRightYear()
{
return String("1996-2002, 2006");
}
//--------------------------------------------------------------------------------------------------
/// Get FreeType library credit text
//--------------------------------------------------------------------------------------------------
static String credit()
{
int major = 0;
int minor = 0;
int patch = 0;
version(&major, &minor, &patch);
return String("FreeType %1.%2.%3\n"
"Portions of this software are Copyright © %4\n"
"The FreeType Project (www.freetype.org).\n"
"All rights reserved.")
.arg(major).arg(minor).arg(patch).arg(copyRightYear());
}
#endif // CVF_USE_FREETYPE_LIB
}; // FreeTypeFontInterface
//==================================================================================================
///
/// \class cvf::FreeTypeFont
/// \ingroup FreeType
///
/// Loads a given FreeType font to be used when drawing text
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
FreeTypeFont::FreeTypeFont(uint dpiX, uint dpiY)
: m_name(L"")
{
#ifdef CVF_USE_FREETYPE_LIB
m_fontInterface = new FreeTypeFontInterface(dpiX, dpiY);
#endif
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
FreeTypeFont::~FreeTypeFont()
{
unload();
}
//--------------------------------------------------------------------------------------------------
/// Get the name of the currently loaded font. An empty string is returned if no font is loaded.
//--------------------------------------------------------------------------------------------------
const String& FreeTypeFont::name() const
{
CVF_TIGHT_ASSERT(m_fontInterface.notNull());
return m_name;
}
//--------------------------------------------------------------------------------------------------
/// Get glyph for the given character. Will be created if not already present.
//--------------------------------------------------------------------------------------------------
ref<Glyph> FreeTypeFont::getGlyph(wchar_t character)
{
CVF_TIGHT_ASSERT(m_fontInterface.notNull());
ref<Glyph> glyph = NULL;
if (!isEmpty())
{
// Glyph already available?
MapType::iterator it = m_atlasMap.find(character);
if (it != m_atlasMap.end())
{
// Yes, return existing glyph
glyph = it->second;
}
else
{
#ifdef CVF_USE_FREETYPE_LIB
CVF_TIGHT_ASSERT(m_fontInterface.notNull());
glyph = m_fontInterface->createGlyph(character);
m_atlasMap.insert(MapType::value_type(character, glyph));
#endif // CVF_USE_FREETYPE_LIB
}
}
CVF_TIGHT_ASSERT(glyph.notNull());
return glyph;
}
//--------------------------------------------------------------------------------------------------
/// Get advance for character glyph in relation to the next character
//--------------------------------------------------------------------------------------------------
uint FreeTypeFont::advance(wchar_t character, wchar_t nextCharacter)
{
CVF_TIGHT_ASSERT(m_fontInterface.notNull());
int kerning = 0;
#ifdef CVF_USE_FREETYPE_LIB
m_fontInterface->getKerning(character, nextCharacter, &kerning);
#endif
ref<Glyph> characterGlyph = getGlyph(character);
CVF_TIGHT_ASSERT(characterGlyph.notNull());
CVF_TIGHT_ASSERT(characterGlyph->textureImage());
ref<Glyph> nextCharacterGlyph = getGlyph(nextCharacter);
CVF_TIGHT_ASSERT(nextCharacterGlyph.notNull());
CVF_TIGHT_ASSERT(nextCharacterGlyph->textureImage());
uint characterWidth = characterGlyph->horizontalBearingX() + characterGlyph->textureImage()->width() + kerning;
return CVF_MAX(characterWidth, characterGlyph->horizontalAdvance());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool FreeTypeFont::isEmpty()
{
#ifdef CVF_USE_FREETYPE_LIB
CVF_TIGHT_ASSERT(m_fontInterface.notNull());
return m_fontInterface->isEmpty();
#else
return true;
#endif
}
//--------------------------------------------------------------------------------------------------
/// Set font size
//--------------------------------------------------------------------------------------------------
void FreeTypeFont::setSize(uint size)
{
m_atlasMap.clear();
CVF_TIGHT_ASSERT(m_fontInterface.notNull());
#ifdef CVF_USE_FREETYPE_LIB
m_fontInterface->setSize(size);
#endif
}
//--------------------------------------------------------------------------------------------------
/// Load font from file. Note: Any existing font will be removed!
//--------------------------------------------------------------------------------------------------
bool FreeTypeFont::load(const cvf::String& path)
{
unload();
#ifdef CVF_USE_FREETYPE_LIB
CVF_TIGHT_ASSERT(m_fontInterface.notNull());
bool loaded = m_fontInterface->load(path);
m_name = m_fontInterface->name();
return loaded;
#else
CVF_UNUSED(path);
return false;
#endif
}
//--------------------------------------------------------------------------------------------------
/// Load font from memory.
///
/// Note that any existing font will be removed. Also, the the array must
/// exist as long as the font is in use.
//--------------------------------------------------------------------------------------------------
bool FreeTypeFont::load(const UByteArray* data)
{
CVF_TIGHT_ASSERT(data);
CVF_TIGHT_ASSERT(data->size() > 0);
unload();
#ifdef CVF_USE_FREETYPE_LIB
CVF_TIGHT_ASSERT(m_fontInterface.notNull());
bool loaded = m_fontInterface->load(data->ptr(), data->size());
m_name = m_fontInterface->name();
return loaded;
#else
return false;
#endif
}
//--------------------------------------------------------------------------------------------------
/// Load base64 encoded font from memory
///
/// Note that any existing font will be removed. Also, the the array must
/// exist as long as the font is in use.
//--------------------------------------------------------------------------------------------------
bool FreeTypeFont::load(const char** data, size_t numBlocks)
{
CVF_TIGHT_ASSERT(data);
CVF_TIGHT_ASSERT(numBlocks > 0);
unload();
#ifdef CVF_USE_FREETYPE_LIB
CVF_TIGHT_ASSERT(m_fontInterface.notNull());
bool loaded = m_fontInterface->load(data, numBlocks);
m_name = m_fontInterface->name();
return loaded;
#else
return false;
#endif
}
//--------------------------------------------------------------------------------------------------
/// Unload current font
//--------------------------------------------------------------------------------------------------
void FreeTypeFont::unload()
{
m_atlasMap.clear();
m_name = "";
#ifdef CVF_USE_FREETYPE_LIB
CVF_TIGHT_ASSERT(m_fontInterface.notNull());
m_fontInterface->unload();
#endif
}
//--------------------------------------------------------------------------------------------------
/// Get FreeType library version
//--------------------------------------------------------------------------------------------------
bool FreeTypeFont::version(int* major, int* minor, int* patch)
{
CVF_ASSERT(major);
CVF_ASSERT(minor);
CVF_ASSERT(patch);
#ifdef CVF_USE_FREETYPE_LIB
return FreeTypeFontInterface::version(major, minor, patch);
#else
*major = *minor = *patch = -1;
return false;
#endif
}
//--------------------------------------------------------------------------------------------------
/// Get FreeType library credit text
//--------------------------------------------------------------------------------------------------
String FreeTypeFont::credit()
{
#ifdef CVF_USE_FREETYPE_LIB
return FreeTypeFontInterface::credit();
#else
return L"";
#endif
}
} // namespace cvf

View File

@ -0,0 +1,92 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfFont.h"
#include "cvfArray.h"
#include "cvfString.h"
#include <map>
namespace cvf {
class Glyph;
class TextureImage;
class FreeTypeFontInterface;
//==================================================================================================
//
// FreeType font class used to generate glyphs for a given character
//
//==================================================================================================
class FreeTypeFont : public Font
{
public:
FreeTypeFont(uint dpiX = 96, uint dpiY = 96);
virtual ~FreeTypeFont();
// Overridden pure virtual functions
virtual const String& name() const;
virtual ref<Glyph> getGlyph(wchar_t character);
virtual uint advance(wchar_t character, wchar_t nextCharacter);
virtual bool isEmpty();
void setSize(uint size);
// Load/unload font
bool load(const String& path);
bool load(const UByteArray* data);
bool load(const char** data, size_t numBlocks);
void unload();
// Library information
static bool version(int* major, int* minor, int* patch);
static String copyRightYear();
static String credit();
private:
typedef std::map<wchar_t, ref<Glyph> > MapType;
ref<FreeTypeFontInterface> m_fontInterface;
MapType m_atlasMap; // Atlas containing cached up Glyphs
String m_name;
};
} // namespace cvf

View File

@ -0,0 +1,45 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
// Doxygen module definition
/// \ingroup VizFramework
/// @{
/// \defgroup FreeType FreeType module
/// @}
#include "cvfFreeTypeFont.h"

View File

@ -0,0 +1,283 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug MD TBB|Win32">
<Configuration>Debug MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD TBB|x64">
<Configuration>Debug MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|Win32">
<Configuration>Debug MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|x64">
<Configuration>Debug MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|Win32">
<Configuration>Release MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|x64">
<Configuration>Release MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|Win32">
<Configuration>Release MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|x64">
<Configuration>Release MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{EFD5C9AC-8988-F190-AA2C-E36EBE361E90}</ProjectGuid>
<RootNamespace>LibGeometry</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfArrowGenerator.h" />
<ClInclude Include="cvfBoundingBox.h" />
<ClInclude Include="cvfBoxGenerator.h" />
<ClInclude Include="cvfEdgeKey.h" />
<ClInclude Include="cvfFrustum.h" />
<ClInclude Include="cvfGeometryBuilder.h" />
<ClInclude Include="cvfGeometryBuilderFaceList.h" />
<ClInclude Include="cvfGeometryBuilderTriangles.h" />
<ClInclude Include="cvfGeometryUtils.h" />
<ClInclude Include="cvfLibGeometry.h" />
<ClInclude Include="cvfMeshEdgeExtractor.h" />
<ClInclude Include="cvfOutlineEdgeExtractor.h" />
<ClInclude Include="cvfPatchGenerator.h" />
<ClInclude Include="cvfRay.h" />
<ClInclude Include="cvfTriangleMeshEdgeExtractor.h" />
<ClInclude Include="cvfTriangleVertexSplitter.h" />
<ClInclude Include="cvfVertexCompactor.h" />
<ClInclude Include="cvfVertexWelder.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfArrowGenerator.cpp" />
<ClCompile Include="cvfBoundingBox.cpp" />
<ClCompile Include="cvfBoxGenerator.cpp" />
<ClCompile Include="cvfEdgeKey.cpp" />
<ClCompile Include="cvfFrustum.cpp" />
<ClCompile Include="cvfGeometryBuilder.cpp" />
<ClCompile Include="cvfGeometryBuilderFaceList.cpp" />
<ClCompile Include="cvfGeometryBuilderTriangles.cpp" />
<ClCompile Include="cvfGeometryUtils.cpp" />
<ClCompile Include="cvfMeshEdgeExtractor.cpp" />
<ClCompile Include="cvfOutlineEdgeExtractor.cpp" />
<ClCompile Include="cvfPatchGenerator.cpp" />
<ClCompile Include="cvfRay.cpp" />
<ClCompile Include="cvfTriangleMeshEdgeExtractor.cpp" />
<ClCompile Include="cvfTriangleVertexSplitter.cpp" />
<ClCompile Include="cvfVertexCompactor.cpp" />
<ClCompile Include="cvfVertexWelder.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,45 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="cvfArrowGenerator.h" />
<ClInclude Include="cvfBoundingBox.h" />
<ClInclude Include="cvfBoxGenerator.h" />
<ClInclude Include="cvfEdgeKey.h" />
<ClInclude Include="cvfFrustum.h" />
<ClInclude Include="cvfGeometryBuilder.h" />
<ClInclude Include="cvfGeometryBuilderFaceList.h" />
<ClInclude Include="cvfGeometryBuilderTriangles.h" />
<ClInclude Include="cvfGeometryUtils.h" />
<ClInclude Include="cvfLibGeometry.h" />
<ClInclude Include="cvfMeshEdgeExtractor.h" />
<ClInclude Include="cvfOutlineEdgeExtractor.h" />
<ClInclude Include="cvfPatchGenerator.h" />
<ClInclude Include="cvfRay.h" />
<ClInclude Include="cvfVertexWelder.h" />
<ClInclude Include="cvfTriangleVertexSplitter.h" />
<ClInclude Include="cvfVertexCompactor.h" />
<ClInclude Include="cvfTriangleMeshEdgeExtractor.h" />
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfArrowGenerator.cpp" />
<ClCompile Include="cvfBoundingBox.cpp" />
<ClCompile Include="cvfBoxGenerator.cpp" />
<ClCompile Include="cvfEdgeKey.cpp" />
<ClCompile Include="cvfFrustum.cpp" />
<ClCompile Include="cvfGeometryBuilder.cpp" />
<ClCompile Include="cvfGeometryBuilderFaceList.cpp" />
<ClCompile Include="cvfGeometryBuilderTriangles.cpp" />
<ClCompile Include="cvfGeometryUtils.cpp" />
<ClCompile Include="cvfMeshEdgeExtractor.cpp" />
<ClCompile Include="cvfOutlineEdgeExtractor.cpp" />
<ClCompile Include="cvfPatchGenerator.cpp" />
<ClCompile Include="cvfRay.cpp" />
<ClCompile Include="cvfVertexWelder.cpp" />
<ClCompile Include="cvfTriangleVertexSplitter.cpp" />
<ClCompile Include="cvfVertexCompactor.cpp" />
<ClCompile Include="cvfTriangleMeshEdgeExtractor.cpp" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,146 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug MD|Win32">
<Configuration>Debug MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|x64">
<Configuration>Debug MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|Win32">
<Configuration>Release MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|x64">
<Configuration>Release MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{FBFAC173-30FE-2C09-3F2E-D54477B433DE}</ProjectGuid>
<RootNamespace>LibGuiQt</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;QT_THREAD_SUPPORT;QT_CORE_LIB;QT_GUI_LIB;QT_OPENGL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(QTDIR)/include;$(QTDIR)/include/QtCore;$(QTDIR)/include/QtGui;$(QTDIR)/include/QtOpenGL;../LibCore;../LibGeometry;../LibRender;../LibViewing</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;QT_THREAD_SUPPORT;QT_CORE_LIB;QT_GUI_LIB;QT_OPENGL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(QTDIR)/include;$(QTDIR)/include/QtCore;$(QTDIR)/include/QtGui;$(QTDIR)/include/QtOpenGL;../LibCore;../LibGeometry;../LibRender;../LibViewing</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;QT_NO_DEBUG;QT_THREAD_SUPPORT;QT_CORE_LIB;QT_GUI_LIB;QT_OPENGL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(QTDIR)/include;$(QTDIR)/include/QtCore;$(QTDIR)/include/QtGui;$(QTDIR)/include/QtOpenGL;../LibCore;../LibGeometry;../LibRender;../LibViewing</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;QT_NO_DEBUG;QT_THREAD_SUPPORT;QT_CORE_LIB;QT_GUI_LIB;QT_OPENGL_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>$(QTDIR)/include;$(QTDIR)/include/QtCore;$(QTDIR)/include/QtGui;$(QTDIR)/include/QtOpenGL;../LibCore;../LibGeometry;../LibRender;../LibViewing</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="cvfqtBasicAboutDialog.cpp" />
<ClCompile Include="cvfqtCvfBoundQGLContext.cpp" />
<ClCompile Include="cvfqtMouseState.cpp" />
<ClCompile Include="cvfqtOpenGLContext.cpp" />
<ClCompile Include="cvfqtPerformanceInfoHud.cpp" />
<ClCompile Include="cvfqtUtils.cpp" />
<ClCompile Include="cvfqtOpenGLWidget.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfqtBasicAboutDialog.h" />
<ClInclude Include="cvfqtCvfBoundQGLContext.h" />
<ClInclude Include="cvfqtMouseState.h" />
<ClInclude Include="cvfqtOpenGLContext.h" />
<ClInclude Include="cvfqtOpenGLWidget.h" />
<ClInclude Include="cvfqtPerformanceInfoHud.h" />
<ClInclude Include="cvfqtUtils.h" />
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="cvfqtBasicAboutDialog.cpp" />
<ClCompile Include="cvfqtPerformanceInfoHud.cpp" />
<ClCompile Include="cvfqtUtils.cpp" />
<ClCompile Include="cvfqtOpenGLWidget.cpp" />
<ClCompile Include="cvfqtCvfBoundQGLContext.cpp" />
<ClCompile Include="cvfqtOpenGLContext.cpp" />
<ClCompile Include="cvfqtMouseState.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfqtPerformanceInfoHud.h" />
<ClInclude Include="cvfqtUtils.h" />
<ClInclude Include="cvfqtCvfBoundQGLContext.h" />
<ClInclude Include="cvfqtOpenGLContext.h" />
<ClInclude Include="cvfqtMouseState.h" />
<ClInclude Include="cvfqtBasicAboutDialog.h" />
<ClInclude Include="cvfqtOpenGLWidget.h" />
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,30 @@
cmake_minimum_required(VERSION 2.8)
project(LibIo)
# Use our strict compile flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}")
include_directories(../LibCore)
set(CEE_HEADER_FILES
cvfFile.h
cvfLibIo.h
cvfMemoryFile.h
cvfPropertyXmlSerializer.h
cvfTinyXmlFused.hpp
cvfXml.h
)
set(CEE_SOURCE_FILES
cvfFile.cpp
cvfMemoryFile.cpp
cvfPropertyXmlSerializer.cpp
cvfXml.cpp
)
add_library(${PROJECT_NAME} ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES})

View File

@ -0,0 +1,258 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug MD TBB|Win32">
<Configuration>Debug MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD TBB|x64">
<Configuration>Debug MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|Win32">
<Configuration>Debug MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|x64">
<Configuration>Debug MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|Win32">
<Configuration>Release MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|x64">
<Configuration>Release MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|Win32">
<Configuration>Release MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|x64">
<Configuration>Release MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{181472EE-4B37-01E8-49D5-6213678FE4F8}</ProjectGuid>
<RootNamespace>LibIo</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfFile.h" />
<ClInclude Include="cvfLibIo.h" />
<ClInclude Include="cvfMemoryFile.h" />
<ClInclude Include="cvfPropertyXmlSerializer.h" />
<ClInclude Include="cvfTinyXmlFused.hpp" />
<ClInclude Include="cvfXml.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfFile.cpp" />
<ClCompile Include="cvfMemoryFile.cpp" />
<ClCompile Include="cvfPropertyXmlSerializer.cpp" />
<ClCompile Include="cvfXml.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfLibIo.h" />
<ClInclude Include="cvfTinyXmlFused.hpp" />
<ClInclude Include="cvfXml.h" />
<ClInclude Include="cvfMemoryFile.h" />
<ClInclude Include="cvfFile.h" />
<ClInclude Include="cvfPropertyXmlSerializer.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfXml.cpp" />
<ClCompile Include="cvfMemoryFile.cpp" />
<ClCompile Include="cvfFile.cpp" />
<ClCompile Include="cvfPropertyXmlSerializer.cpp" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,83 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfFile.h"
#include "cvfString.h"
namespace cvf {
//==================================================================================================
///
/// \class cvf::File
/// \ingroup Io
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
FILE* File::fopen(const String& fileName, const String& mode)
{
#ifdef WIN32
FILE* filePtr = NULL;
if (_wfopen_s(&filePtr, fileName.c_str(), mode.c_str()) != 0)
{
return NULL;
}
return filePtr;
#else
FILE* filePtr = ::fopen(fileName.toUtf8().ptr(), mode.toUtf8().ptr());
if (!filePtr)
{
return NULL;
}
return filePtr;
#endif
}
} // namespace cvf

View File

@ -0,0 +1,58 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include <cstdio>
namespace cvf {
class String;
//==================================================================================================
//
//
//
//==================================================================================================
class File
{
public:
static FILE* fopen(const String& fileName, const String& mode);
};
} // namespace cvf

View File

@ -0,0 +1,47 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
// Doxygen module definition
/// \ingroup VizFramework
/// @{
/// \defgroup Io Io module
/// @}
#include "cvfFile.h"
#include "cvfMemoryFile.h"
#include "cvfXml.h"

View File

@ -0,0 +1,169 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfMemoryFile.h"
#include <cstdio>
namespace cvf {
//==================================================================================================
///
/// \class cvf::MemoryFile
/// \ingroup Io
///
/// File read into memory
//==================================================================================================
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
MemoryFile::MemoryFile()
{
}
//--------------------------------------------------------------------------------------------------
/// Destructor
//--------------------------------------------------------------------------------------------------
MemoryFile::~MemoryFile()
{
unload();
}
//--------------------------------------------------------------------------------------------------
/// Load file into memory. Old data will be destroyed.
///
/// \todo Revisit when we have error objects in production to provide fine grain feedback on error.
//--------------------------------------------------------------------------------------------------
bool MemoryFile::load(const cvf::String& filename)
{
unload();
if (filename.isEmpty()) return false;
#ifdef WIN32
// Open File;
FILE* file = NULL;
errno_t err = _wfopen_s(&file, filename.c_str(), L"rb");
if (err != 0)
{
//CVF_ERROR(String("Unable to open file [%1]. : Error [%1]").arg(filename).arg((int)err));
return false;
}
#else
// Open File;
FILE* file = fopen(filename.toUtf8().ptr(), "rb");
if (!file)
{
//CVF_ERROR(String("Unable to open file [%1].").arg(filename));
return false;
}
#endif
// Find file size
fseek(file, 0, SEEK_END);
long fileSize = ftell(file);
if (fileSize <= 0)
{
// No data, return as an error
fclose(file);
//CVF_ERROR(String("Unable to read file [%1]. It's empty.").arg(filename));
return false;
}
// Safe to cast to unsigned type
size_t bufferSize = static_cast<size_t>(fileSize) * sizeof(ubyte);
// Read data from file into memory
m_filename = filename;
m_data.resize(bufferSize);
fseek(file, 0, SEEK_SET);
size_t bytesRead = fread(m_data.ptr(), 1, bufferSize, file);
fclose(file);
if (bytesRead != bufferSize)
{
//CVF_ERROR(String("Unable to to read file [%1]\n\tFilesize: %2, Bytes read: %3").arg(m_filename).arg((uint)bufferSize).arg((uint)bytesRead));
return false;
}
return true;
}
//--------------------------------------------------------------------------------------------------
/// Destroy old data
//--------------------------------------------------------------------------------------------------
void MemoryFile::unload()
{
m_filename = L"";
m_data.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool MemoryFile::isEmpty() const
{
return m_data.size() == 0 ? true : false;
}
//--------------------------------------------------------------------------------------------------
/// Get pointer to the currently loaded file data, if any. NULL if not set.
//--------------------------------------------------------------------------------------------------
const UByteArray* MemoryFile::data() const
{
return &m_data;
}
//--------------------------------------------------------------------------------------------------
/// Get name of the currently loaded file. An empty string if not set.
//--------------------------------------------------------------------------------------------------
const String& MemoryFile::filename() const
{
return m_filename;
}
} // namespace cvf

View File

@ -0,0 +1,71 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfString.h"
#include "cvfArray.h"
namespace cvf {
//==================================================================================================
//
// Class containing a file read into memory
//
//==================================================================================================
class MemoryFile : public Object
{
public:
MemoryFile();
virtual ~MemoryFile();
bool load(const String& filename);
void unload();
bool isEmpty() const;
const UByteArray* data() const;
const String& filename() const;
protected:
String m_filename;
UByteArray m_data;
};
} // namespace cvf

View File

@ -0,0 +1,389 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfPropertyXmlSerializer.h"
#include "cvfPropertySetCollection.h"
#include "cvfXml.h"
namespace cvf {
//==================================================================================================
///
/// \class cvf::PropertyXmlSerializer
/// \ingroup Io
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PropertyXmlSerializer::toXml(const PropertySetCollection& propertySetCollection, XmlElement* parent)
{
CVF_ASSERT(parent);
XmlElement* xmlPropSetColl = parent->addChildElement("PropertySetCollection");
CVF_ASSERT(xmlPropSetColl);
size_t numPropSets = propertySetCollection.count();
for (size_t i = 0; i < numPropSets; i++)
{
const PropertySet* ps = propertySetCollection.propertySet(i);
CVF_ASSERT(ps);
createAddXmlElementFromPropertySet(*ps, xmlPropSetColl);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PropertyXmlSerializer::createAddXmlElementFromPropertySet(const PropertySet& propertySet, XmlElement* parent)
{
CVF_ASSERT(parent);
XmlElement* xmlPropSet = parent->addChildElement("PropertySet");
CVF_ASSERT(xmlPropSet);
xmlPropSet->setAttributeString("classType", propertySet.classType());
std::vector<String> keys = propertySet.allKeys();
std::vector<Variant> values = propertySet.allValues();
size_t numKeyValues = keys.size();
CVF_ASSERT(numKeyValues == values.size());
for (size_t i = 0; i < numKeyValues; i++)
{
const String& key = keys[i];
const Variant& value = values[i];
if (value.isValid())
{
XmlElement* xmlKeyValueElement = createAddXmlElementFromVariant(value, xmlPropSet);
CVF_ASSERT(xmlKeyValueElement);
xmlKeyValueElement->setAttributeString("key", key);
}
}
}
//--------------------------------------------------------------------------------------------------
/// Populate the PropertySet from the specified XML element
///
/// The XML element passed as a parameter is assumed to be a PropertySet element
//--------------------------------------------------------------------------------------------------
void PropertyXmlSerializer::toPropertySetCollection(const XmlElement& xmlPropertySetCollectionElement, PropertySetCollection* propertySetCollection)
{
CVF_ASSERT(xmlPropertySetCollectionElement.name() == "PropertySetCollection");
CVF_ASSERT(propertySetCollection);
const XmlElement* xmlElem = xmlPropertySetCollectionElement.firstChildElement("PropertySet");
while (xmlElem)
{
ref<PropertySet> ps = createPropertySetFromXmlElement(*xmlElem);
propertySetCollection->addPropertySet(ps.p());
xmlElem = xmlElem->nextSiblingElement("PropertySet");
}
}
//--------------------------------------------------------------------------------------------------
/// Add an XML element representing the variant to \a parent
///
/// Note that invalid variants will not be added
//--------------------------------------------------------------------------------------------------
XmlElement* PropertyXmlSerializer::createAddXmlElementFromVariant(const Variant& variant, XmlElement* parent)
{
CVF_ASSERT(variant.isValid());
CVF_ASSERT(parent);
Variant::Type variantType = variant.type();
switch (variantType)
{
case Variant::INT: return parent->addChildElement("Int", String(variant.getInt()));
case Variant::UINT: return parent->addChildElement("UInt", String(variant.getUInt()));
case Variant::DOUBLE: return parent->addChildElement("Double", String::number(variant.getDouble()));
case Variant::FLOAT: return parent->addChildElement("Float", String::number(variant.getFloat()));
case Variant::BOOL: return parent->addChildElement("Bool", variant.getBool() ? "true" : "false");
case Variant::VEC3D: return parent->addChildElement("Vec3d", valueTextFromVec3dVariant(variant));
case Variant::COLOR3F: return parent->addChildElement("Color3f", valueTextFromColor3fVariant(variant));
case Variant::STRING: return parent->addChildElement("String", variant.getString());
case Variant::ARRAY: return createAddXmlElementFromArrayVariant(variant, parent);
case Variant::INVALID: return NULL;
}
CVF_FAIL_MSG("Unhandled variant type");
return NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
XmlElement* PropertyXmlSerializer::createAddXmlElementFromArrayVariant(const Variant& arrayVariant, XmlElement* parent)
{
XmlElement* xmlArrayElement = parent->addChildElement("Array");
CVF_ASSERT(arrayVariant.type() == Variant::ARRAY);
std::vector<Variant> arr = arrayVariant.getArray();
size_t numArrayItems = arr.size();
for (size_t i = 0; i < numArrayItems; i++)
{
const Variant& variant = arr[i];
if (variant.isValid())
{
createAddXmlElementFromVariant(variant, xmlArrayElement);
}
}
return xmlArrayElement;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
String PropertyXmlSerializer::valueTextFromVec3dVariant(const Variant& variant)
{
CVF_ASSERT(variant.type() == Variant::VEC3D);
Vec3d val = variant.getVec3d();
String txt = String::number(val.x()) + " " + String::number(val.y()) + " " + String::number(val.z());
return txt;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
String PropertyXmlSerializer::valueTextFromColor3fVariant(const Variant& variant)
{
CVF_ASSERT(variant.type() == Variant::COLOR3F);
Color3f val = variant.getColor3f();
String txt = String::number(val.r()) + " " + String::number(val.g()) + " " + String::number(val.b());
return txt;
}
//--------------------------------------------------------------------------------------------------
/// Create a new PropertySet from the specified XML element
///
/// The XML element passed as a parameter is assumed to be a PropertySet element
//--------------------------------------------------------------------------------------------------
ref<PropertySet> PropertyXmlSerializer::createPropertySetFromXmlElement(const XmlElement& xmlPropertySetElement)
{
CVF_ASSERT(xmlPropertySetElement.name() == "PropertySet");
String propSetClassType = xmlPropertySetElement.getAttributeString("classType");
ref<PropertySet> ps = new PropertySet(propSetClassType);
const XmlElement* xmlElem = xmlPropertySetElement.firstChildElement();
while (xmlElem)
{
Variant variant = variantFromXmlElement(*xmlElem);
if (variant.isValid())
{
String key = xmlElem->getAttributeString("key");
if (!key.isEmpty())
{
ps->setValue(key, variant);
}
}
xmlElem = xmlElem->nextSiblingElement();
}
return ps;
}
//--------------------------------------------------------------------------------------------------
/// Create variant from the specified XML element
///
/// If the passed XML element is not recognized as a variant, an invalid variant will be returned
//--------------------------------------------------------------------------------------------------
cvf::Variant PropertyXmlSerializer::variantFromXmlElement(const XmlElement& xmlVariantElement)
{
const String elementName = xmlVariantElement.name().toLower();
const String valueText = xmlVariantElement.valueText();
if (elementName == "int")
{
bool ok = false;
int val = valueText.toInt(&ok);
if (ok)
{
return Variant(val);
}
}
else if (elementName == "uint")
{
bool ok = false;
uint val = valueText.toUInt(&ok);
if (ok)
{
return Variant(val);
}
}
else if (elementName == "double")
{
bool ok = false;
double val = valueText.toDouble(&ok);
if (ok)
{
return Variant(val);
}
}
else if (elementName == "float")
{
bool ok = false;
float val = valueText.toFloat(&ok);
if (ok)
{
return Variant(val);
}
}
else if (elementName == "bool")
{
String valStr = valueText.toLower();
bool val = (valStr == "true") ? true : false;
return Variant(val);
}
else if (elementName == "vec3d")
{
return variantFromVec3dValueText(valueText);
}
else if (elementName == "color3f")
{
return variantFromColor3fValueText(valueText);
}
else if (elementName == "string")
{
return Variant(valueText);
}
else if (elementName == "array")
{
return arrayVariantFromXmlElement(xmlVariantElement);
}
return Variant();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Variant PropertyXmlSerializer::arrayVariantFromXmlElement(const XmlElement& xmlArrayVariantElement)
{
CVF_ASSERT(xmlArrayVariantElement.name().toLower() == "array");
std::vector<Variant> arr;
const XmlElement* xmlElem = xmlArrayVariantElement.firstChildElement();
while (xmlElem)
{
Variant variant = variantFromXmlElement(*xmlElem);
if (variant.isValid())
{
arr.push_back(variant);
}
xmlElem = xmlElem->nextSiblingElement();
}
return Variant(arr);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Variant PropertyXmlSerializer::variantFromVec3dValueText(const String& vec3dValueText)
{
std::vector<String> components = vec3dValueText.split();
if (components.size() == 3)
{
Vec3d val(0, 0, 0);
bool ok0 = false;
bool ok1 = false;
bool ok2 = false;
val.x() = components[0].toDouble(&ok0);
val.y() = components[1].toDouble(&ok1);
val.z() = components[2].toDouble(&ok2);
if (ok0 && ok1 && ok2)
{
return Variant(val);
}
}
return Variant();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Variant PropertyXmlSerializer::variantFromColor3fValueText(const String& color3fValueText)
{
std::vector<String> components = color3fValueText.split();
if (components.size() == 3)
{
Color3f val(0, 0, 0);
bool ok0 = false;
bool ok1 = false;
bool ok2 = false;
val.r() = components[0].toFloat(&ok0);
val.g() = components[1].toFloat(&ok1);
val.b() = components[2].toFloat(&ok2);
if (ok0 && ok1 && ok2)
{
return Variant(val);
}
}
return Variant();
}
} // namespace cvf

View File

@ -0,0 +1,76 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfString.h"
#include "cvfVariant.h"
namespace cvf {
class PropertySetCollection;
class PropertySet;
class XmlDocument;
class XmlElement;
//==================================================================================================
//
//
//
//==================================================================================================
class PropertyXmlSerializer
{
public:
static void toXml(const PropertySetCollection& propertySetCollection, XmlElement* parent);
static void toPropertySetCollection(const XmlElement& xmlPropertySetCollectionElement, PropertySetCollection* propertySetCollection);
private:
static void createAddXmlElementFromPropertySet(const PropertySet& propertySet, XmlElement* parent);
static XmlElement* createAddXmlElementFromVariant(const Variant& variant, XmlElement* parent);
static XmlElement* createAddXmlElementFromArrayVariant(const Variant& arrayVariant, XmlElement* parent);
static String valueTextFromVec3dVariant(const Variant& variant);
static String valueTextFromColor3fVariant(const Variant& variant);
static ref<PropertySet> createPropertySetFromXmlElement(const XmlElement& xmlPropertySetElement);
static Variant variantFromXmlElement(const XmlElement& xmlVariantElement);
static Variant arrayVariantFromXmlElement(const XmlElement& xmlArrayVariantElement);
static Variant variantFromVec3dValueText(const String& vec3dValueText);
static Variant variantFromColor3fValueText(const String& color3fValueText);
};
} // namespace cvf

File diff suppressed because it is too large Load Diff

1000
Fwk/VizFwk/LibIo/cvfXml.cpp Normal file

File diff suppressed because it is too large Load Diff

125
Fwk/VizFwk/LibIo/cvfXml.h Normal file
View File

@ -0,0 +1,125 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfString.h"
#include "cvfColor3.h"
#include "cvfArray.h"
namespace cvf {
//==================================================================================================
//
//
//
//==================================================================================================
class XmlElement
{
public:
virtual ~XmlElement() {}
virtual void setAttributeBool(const cvf::String& attributeName, bool val) = 0;
virtual void setAttributeString(const cvf::String& attributeName, const cvf::String& val) = 0;
virtual void setAttributeInt(const cvf::String& attributeName, int val) = 0;
virtual void setAttributeInt64(const cvf::String& attributeName, cvf::int64 val) = 0;
virtual void setAttributeFloat(const cvf::String& attributeName, float val) = 0;
virtual void setAttributeDouble(const cvf::String& attributeName, double val) = 0;
virtual void setAttributeVector(const cvf::String& attributeName, const cvf::Vec3d& val) = 0;
virtual void setAttributeColor(const cvf::String& attributeName, const cvf::Color3f& color) = 0;
virtual bool getAttributeBool(const cvf::String& attributeName, bool defaultVal, bool* found = NULL) const = 0;
virtual cvf::String getAttributeString(const cvf::String& attributeName, const cvf::String& defaultVal = "", bool* found = NULL) const = 0;
virtual int getAttributeInt(const cvf::String& attributeName, int defaultVal, bool* found = NULL) const = 0;
virtual cvf::int64 getAttributeInt64(const cvf::String& attributeName, cvf::int64 defaultVal, bool* found = NULL) const = 0;
virtual float getAttributeFloat(const cvf::String& attributeName, float defaultVal, bool* found = NULL) const = 0;
virtual double getAttributeDouble(const cvf::String& attributeName, double defaultVal, bool* found = NULL) const = 0;
virtual cvf::Vec3d getAttributeVector(const cvf::String& attributeName, const cvf::Vec3d& defaultVal, bool* found = NULL) const = 0;
virtual cvf::Color3f getAttributeColor(const cvf::String& attributeName, const cvf::Color3f& defaulColor, bool* found = NULL) const = 0;
virtual void getAttributes(std::vector<cvf::String>* names, std::vector<cvf::String>* values) = 0;
virtual XmlElement* firstChildElement() = 0;
virtual const XmlElement* firstChildElement() const = 0;
virtual XmlElement* firstChildElement(const cvf::String& elementName) = 0;
virtual const XmlElement* firstChildElement(const cvf::String& elementName) const = 0;
virtual XmlElement* nextSiblingElement() = 0;
virtual const XmlElement* nextSiblingElement() const = 0;
virtual XmlElement* nextSiblingElement(const cvf::String& elementName) = 0;
virtual const XmlElement* nextSiblingElement(const cvf::String& elementName) const = 0;
virtual XmlElement* addChildElement(const cvf::String& elementName, const cvf::String& stringValue = cvf::String()) = 0;
virtual bool removeChildElement(XmlElement* element) = 0;
virtual cvf::String name() const = 0;
virtual cvf::String valueText() const = 0;
virtual bool setValueText(const cvf::String& text) = 0;
};
//==================================================================================================
//
//
//
//==================================================================================================
class XmlDocument : public cvf::Object
{
public:
static ref<XmlDocument> create();
static void preserveWhiteSpace(bool preserve);
virtual void clear() = 0;
virtual bool error() const = 0;
virtual XmlElement* createRootElement(const cvf::String& rootName, int iID = -1, const cvf::String& namespaceString = "http://ceetron.com") = 0;
virtual XmlElement* getRootElement(const cvf::String& rootName) = 0;
virtual const XmlElement* getRootElement(const cvf::String& rootName) const = 0;
virtual bool loadFile(const cvf::String& fileName) = 0;
virtual bool saveFile(const cvf::String& fileName) = 0;
virtual bool saveCompactFile(const cvf::String& fileName) = 0;
virtual bool setFromRawData(const cvf::UByteArray& buffer) = 0;
virtual void getAsRawData(cvf::UByteArray* buffer) const = 0;
};
}

View File

@ -0,0 +1,23 @@
cmake_minimum_required(VERSION 2.8)
project(LibRegGrid2D)
# Use our strict compile flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}")
include_directories(../LibCore)
include_directories(../LibIo)
include_directories(../LibGeometry)
include_directories(../LibRender)
set(CEE_SOURCE_FILES
cvfRegGrid2D.cpp
cvfRegGrid2DExportXml.cpp
cvfRegGrid2DGeometry.cpp
cvfRegGrid2DImportXml.cpp
)
add_library(${PROJECT_NAME} ${CEE_SOURCE_FILES})

View File

@ -0,0 +1,257 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug MD TBB|Win32">
<Configuration>Debug MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD TBB|x64">
<Configuration>Debug MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|Win32">
<Configuration>Debug MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|x64">
<Configuration>Debug MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|Win32">
<Configuration>Release MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|x64">
<Configuration>Release MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|Win32">
<Configuration>Release MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|x64">
<Configuration>Release MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{7AEF1888-268C-3BEF-4080-743645180A59}</ProjectGuid>
<RootNamespace>LibRegGrid2D</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfLibRegGrid2D.h" />
<ClInclude Include="cvfRegGrid2D.h" />
<ClInclude Include="cvfRegGrid2DExportXml.h" />
<ClInclude Include="cvfRegGrid2DGeometry.h" />
<ClInclude Include="cvfRegGrid2DImportXml.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfRegGrid2D.cpp" />
<ClCompile Include="cvfRegGrid2DExportXml.cpp" />
<ClCompile Include="cvfRegGrid2DGeometry.cpp" />
<ClCompile Include="cvfRegGrid2DImportXml.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfLibRegGrid2D.h" />
<ClInclude Include="cvfRegGrid2D.h" />
<ClInclude Include="cvfRegGrid2DGeometry.h" />
<ClInclude Include="cvfRegGrid2DExportXml.h" />
<ClInclude Include="cvfRegGrid2DImportXml.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfRegGrid2D.cpp" />
<ClCompile Include="cvfRegGrid2DGeometry.cpp" />
<ClCompile Include="cvfRegGrid2DExportXml.cpp" />
<ClCompile Include="cvfRegGrid2DImportXml.cpp" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,45 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
// Doxygen module definition
/// \defgroup RegGrid2D Regular 2D grid module
#include "cvfRegGrid2D.h"
#include "cvfRegGrid2DExportXml.h"
#include "cvfRegGrid2DGeometry.h"
#include "cvfRegGrid2DImportXml.h"

View File

@ -0,0 +1,557 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfRegGrid2D.h"
namespace cvf {
//==================================================================================================
///
/// \class cvf::RegGrid2D
/// \ingroup RegGrid2D
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RegGrid2D::RegGrid2D()
{
m_gridPointCountI = 0;
m_gridPointCountJ = 0;
m_spacing.set(0, 0);
m_offset.set(0, 0);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2D::allocateGrid(int gridPointCountI, int gridPointCountJ)
{
CVF_ASSERT(gridPointCountI >= 0);
CVF_ASSERT(gridPointCountJ >= 0);
m_gridPointCountI = gridPointCountI;
m_gridPointCountJ = gridPointCountJ;
m_elevations.resize(static_cast<size_t>(gridPointCount()));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RegGrid2D::gridPointCountI() const
{
return m_gridPointCountI;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RegGrid2D::gridPointCountJ() const
{
return m_gridPointCountJ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RegGrid2D::gridPointCount() const
{
return m_gridPointCountI * m_gridPointCountJ;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Vec2d RegGrid2D::spacing() const
{
return m_spacing;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2D::setSpacing(const Vec2d& spacing)
{
CVF_ASSERT(spacing.x() >= 0);
CVF_ASSERT(spacing.y() >= 0);
m_spacing = spacing;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Vec2d RegGrid2D::offset() const
{
return m_offset;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2D::setOffset(const Vec2d& offset)
{
m_offset = offset;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Rectd RegGrid2D::boundingRectangle() const
{
Vec2d min = gridPointCoordinate(0, 0);
Vec2d max = gridPointCoordinate(m_gridPointCountI - 1, m_gridPointCountJ - 1);
return Rectd::fromMinMax(min, max);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2D::setElevation(int i, int j, double elevation)
{
int index = toArrayIndex(i, j);
setElevation(index, elevation);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2D::setElevation(int arrayIndex, double elevation)
{
CVF_ASSERT(arrayIndex >= 0 && arrayIndex < gridPointCount());
m_elevations.set(static_cast<size_t>(arrayIndex), elevation);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double RegGrid2D::elevation(int i, int j) const
{
int index = toArrayIndex(i, j);
CVF_ASSERT(index >=0 && index < gridPointCount());
return m_elevations[static_cast<size_t>(index)];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2D::setAllElevations(double elevation)
{
m_elevations.setAll(elevation);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2D::setElevations(const DoubleArray& elevations)
{
setElevations(elevations.ptr(), static_cast<int>(elevations.size()));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2D::setElevations(const double* elevations, int numElevationValues)
{
CVF_ASSERT(elevations);
CVF_ASSERT(numElevationValues > 0);
CVF_ASSERT(numElevationValues == gridPointCount());
m_elevations.assign(elevations, static_cast<size_t>(numElevationValues));
}
//--------------------------------------------------------------------------------------------------
/// Use bilinear interpolation to find value at specified coordinate
///
/// Undefined is returned along the edge of the grid (between grid points)
//--------------------------------------------------------------------------------------------------
double RegGrid2D::pointElevation(const Vec2d& coord) const
{
Rectd region = boundingRectangle();
if (!region.contains(coord)) return UNDEFINED_DOUBLE;
int x1, y1;
cellFromPoint(coord, &x1, &y1);
Vec2d test = gridPointCoordinate(x1, y1);
if (test == coord)
{
// Early exit if we hit exactly at a grid point
return elevation(x1, y1);
}
// If we hit the outer edge of the reg grid, we are not able to compute the value using bilinear interpolation
if (x1 >= m_gridPointCountI - 1) return UNDEFINED_DOUBLE;
if (y1 >= m_gridPointCountJ - 1) return UNDEFINED_DOUBLE;
CVF_ASSERT(x1 >= 0);
CVF_ASSERT(y1 >= 0);
CVF_ASSERT(x1 < m_gridPointCountI - 1);
CVF_ASSERT(y1 < m_gridPointCountJ - 1);
// Variable names taken from http://en.wikipedia.org/wiki/Bilinear_interpolation
const Vec2i q11(x1, y1);
const Vec2i q21(x1 + 1, y1);
const Vec2i q22(x1 + 1, y1 + 1);
const Vec2i q12(x1, y1 + 1);
Vec2d q11Coord = gridPointCoordinate(q11.x(), q11.y());
Vec2d q22Coord = gridPointCoordinate(q22.x(), q22.y());
Vec2d localCoord = coord;// - m_offset;
// Interpolate in x-direction
double elevationR1 = ((q22Coord.x() - localCoord.x()) / m_spacing.x()) * elevation(q11.x(), q11.y()) +
((localCoord.x() - q11Coord.x()) / m_spacing.x()) * elevation(q21.x(), q21.y());
double elevationR2 = ((q22Coord.x() - localCoord.x()) / m_spacing.x()) * elevation(q12.x(), q12.y()) +
((localCoord.x() - q11Coord.x()) / m_spacing.x()) * elevation(q22.x(), q22.y());
// Interpolate intermediate results in y-direction
double elevationValue = ((q22Coord.y() - localCoord.y()) / m_spacing.y()) * elevationR1 +
((localCoord.y() - q11Coord.y()) / m_spacing.y()) * elevationR2;
return static_cast<double>(elevationValue);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2D::pointElevations(const Array<Vec2d>& coords, DoubleArray* elevations) const
{
CVF_ASSERT(elevations);
size_t i;
for (i = 0; i < coords.size(); i++)
{
elevations->add(pointElevation(coords[i]));
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2D::mapPolylineOnGrid(const Array<Vec2d>& lineCoords, Vec3dArray* elevations) const
{
CVF_ASSERT(lineCoords.size() >= 2);
CVF_ASSERT(elevations);
size_t i;
for (i = 1; i < lineCoords.size(); i++)
{
mapLineSegmentOnGrid(lineCoords[i - 1], lineCoords[i], elevations);
}
}
//--------------------------------------------------------------------------------------------------
/// Map a line segment onto the grid
///
/// Space is allocated for the incoming vector array, there are situations where number of allocated vectors
/// is larger than number of vectors used.
/// \internal See http://mathworld.wolfram.com/Line.html
//--------------------------------------------------------------------------------------------------
void RegGrid2D::mapLineSegmentOnGrid(const Vec2d& point1, const Vec2d& point2, Vec3dArray* intersections) const
{
CVF_ASSERT(intersections);
double delta = 0.00001;
Rectd gridRegion = boundingRectangle();
Vec2d intersect1, intersect2;
if (!gridRegion.segmentIntersect(point1, point2, &intersect1, &intersect2)) return;
Vec2d ab = intersect2 - intersect1;
// Find out if ij is increasing or decreasing
int changeI = ab.x() > 0.0 ? 1 : -1;
int changeJ = ab.y() > 0.0 ? 1 : -1;
int gridI, gridJ;
cellFromPoint(intersect1, &gridI, &gridJ);
if (changeI == 1) gridI++;
if (changeJ == 1) gridJ++;
int maxGridI, maxGridJ;
cellFromPoint(intersect2, &maxGridI, &maxGridJ);
if (changeI == 1) maxGridI++;
if (changeJ == 1) maxGridJ++;
// Reserve space in array once
// Will reserve number of grid points in each direction, plus endpoints
size_t numItemsToAllocate = intersections->size() + Math::abs(maxGridI - gridI) + Math::abs(maxGridJ - gridJ) + 2;
intersections->reserve(numItemsToAllocate);
// Add line segment start if it not a grid point
if ((intersect1 - gridPointCoordinate(gridI, gridJ)).lengthSquared() > delta)
{
intersections->add(Vec3d(intersect1, pointElevation(intersect1)));
}
Vec2d currentIntersection;
bool horizontalLine = Math::abs(ab.y()) < delta;
if (horizontalLine)
{
while (gridI != maxGridI)
{
Vec2d nextGridPointCoord = gridPointCoordinate(gridI, gridJ);
currentIntersection.set(nextGridPointCoord.x(), intersect1.y());
intersections->add(Vec3d(currentIntersection, pointElevation(currentIntersection)));
gridI += changeI;
}
}
bool verticalLine = Math::abs(ab.x()) < delta;
if (verticalLine)
{
while (gridJ != maxGridJ)
{
Vec2d nextGridPointCoord = gridPointCoordinate(gridI, gridJ);
currentIntersection.set(intersect1.x(), nextGridPointCoord.y());
intersections->add(Vec3d(currentIntersection, pointElevation(currentIntersection)));
gridJ += changeJ;
}
}
if (!(horizontalLine || verticalLine))
{
// y = (y2 - y1) / (x2 - x1) * (x - x1) + y1
// y = m * (x - x1) + y1
// y = mx + b
double m = (intersect2.y() - intersect1.y()) / (intersect2.x() - intersect1.x());
// b = y1 - (m * x1)
double b = intersect1.y() - (m * intersect1.x());
currentIntersection = intersect1;
while ((gridI != maxGridI || gridJ != maxGridJ))
{
Vec2d nextGridPointCoord = gridPointCoordinate(gridI, gridJ);
double nextYValue = m * nextGridPointCoord.x() + b;
double nextXValue = (nextGridPointCoord.y() - b) / m;
Vec2d horizontalIntersection(nextXValue, nextGridPointCoord.y());
Vec2d verticalIntersection(nextGridPointCoord.x(), nextYValue);
if ((horizontalIntersection - verticalIntersection).lengthSquared() < delta)
{
// Intersection at grid point, increase both i and j
currentIntersection = horizontalIntersection;
gridI += changeI;
gridJ += changeJ;
}
else
{
// Find closest candidate
if ((currentIntersection - horizontalIntersection).lengthSquared() < (currentIntersection - verticalIntersection).lengthSquared())
{
currentIntersection = horizontalIntersection;
gridJ += changeJ;
}
else
{
currentIntersection = verticalIntersection;
gridI += changeI;
}
}
intersections->add(Vec3d(currentIntersection, pointElevation(currentIntersection)));
}
}
// Add line segment end if this is not a grid point
if ((currentIntersection - intersect2).lengthSquared() > delta)
{
intersections->add(Vec3d(intersect2, pointElevation(intersect2)));
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RegGrid2D::minMaxElevation(double* minElevation, double* maxElevation) const
{
if (gridPointCount() == 0) return false;
double minValue = std::numeric_limits<double>::max();
double maxValue = -std::numeric_limits<double>::max();
size_t i;
for (i = 0; i < m_elevations.size(); i++)
{
double elevationValue = m_elevations[i];
if (elevationValue < minValue) minValue = elevationValue;
if (elevationValue > maxValue) maxValue = elevationValue;
}
if (minElevation)
{
*minElevation = minValue;
}
if (maxElevation)
{
*maxElevation = maxValue;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RegGrid2D::minMaxElevationInRegion(int minI, int minJ, int maxI, int maxJ, double* minElevation, double* maxElevation) const
{
CVF_ASSERT(minI >= 0 && minI <= maxI);
CVF_ASSERT(minJ >= 0 && minJ <= maxJ);
if (gridPointCount() == 0) return false;
double minValue = std::numeric_limits<double>::max();
double maxValue = -std::numeric_limits<double>::max();
int ix, iy;
for (ix = minI; ix <= maxI; ix++)
{
for (iy = minJ; iy <= maxJ; iy++)
{
double elevationValue = elevation(ix, iy);
if (elevationValue < minValue) minValue = elevationValue;
if (elevationValue > maxValue) maxValue = elevationValue;
}
}
if (minElevation)
{
*minElevation = minValue;
}
if (maxElevation)
{
*maxElevation = maxValue;
}
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Vec2d RegGrid2D::gridPointCoordinate(int i, int j) const
{
CVF_ASSERT(i >= 0 && i < m_gridPointCountI);
CVF_ASSERT(j >= 0 && j < m_gridPointCountJ);
Vec2d coord(m_offset);
coord.x() += m_spacing.x() * i;
coord.y() += m_spacing.y() * j;
return coord;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RegGrid2D::toArrayIndex(int i, int j) const
{
CVF_ASSERT(i >= 0 && i < m_gridPointCountI);
CVF_ASSERT(j >= 0 && j < m_gridPointCountJ);
int elevationIndex = m_gridPointCountI * j + i;
CVF_ASSERT(elevationIndex < gridPointCount());
return elevationIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2D::cellFromPoint(const Vec2d& coord, int* i, int* j) const
{
CVF_ASSERT(i && j);
int gridI = static_cast<int>(Math::floor((coord.x() - offset().x()) / spacing().x()));
int gridJ = static_cast<int>(Math::floor((coord.y() - offset().y()) / spacing().y()));
CVF_ASSERT(gridI >= 0 && gridI < m_gridPointCountI);
CVF_ASSERT(gridJ >= 0 && gridJ < m_gridPointCountJ);
*i = gridI;
*j = gridJ;
}
} // namespace cvf

View File

@ -0,0 +1,102 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfVector2.h"
#include "cvfArray.h"
#include "cvfRect.h"
namespace cvf {
//==================================================================================================
//
//
//
//==================================================================================================
class RegGrid2D : public Object
{
public:
RegGrid2D();
void allocateGrid(int gridPointCountI, int gridPointCountJ);
int gridPointCountI() const;
int gridPointCountJ() const;
int gridPointCount() const;
Vec2d spacing() const;
void setSpacing(const Vec2d& spacing);
Vec2d offset() const;
void setOffset(const Vec2d& offset);
Rectd boundingRectangle() const;
void setElevation(int i, int j, double elevation);
void setElevation(int arrayIndex, double elevation);
double elevation(int i, int j) const;
void setAllElevations(double elevation);
void setElevations(const DoubleArray& elevations);
void setElevations(const double* elevations, int numElevationValues);
double pointElevation(const Vec2d& coord) const;
void pointElevations(const Array<Vec2d>& coords, DoubleArray* elevations) const;
void mapPolylineOnGrid(const Array<Vec2d>& lineCoords, Vec3dArray* intersections) const;
void mapLineSegmentOnGrid(const Vec2d& point1, const Vec2d& point2, Vec3dArray* intersections) const;
bool minMaxElevation(double* minElevation, double* maxElevation) const;
bool minMaxElevationInRegion(int minI, int minJ, int maxI, int maxJ, double* minElevation, double* maxElevation) const;
Vec2d gridPointCoordinate(int i, int j) const;
void cellFromPoint(const Vec2d& coord, int* i, int* j) const;
private:
int toArrayIndex(int i, int j) const;
private:
int m_gridPointCountI;
int m_gridPointCountJ;
Vec2d m_spacing;
Vec2d m_offset;
DoubleArray m_elevations;
};
}

View File

@ -0,0 +1,116 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfRegGrid2DExportXml.h"
#include "cvfRegGrid2D.h"
#include "cvfXml.h"
namespace cvf {
//==================================================================================================
///
/// \class cvf::RegGrid2DExportXml
/// \ingroup RegGrid2D
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2DExportXml::exportToXml(const RegGrid2D& regGrid, uint precision, XmlElement* parent)
{
if (!parent)
{
return;
}
XmlElement* xmlRegGrid = parent->addChildElement("RegularGrid2D");
CVF_ASSERT(xmlRegGrid);
xmlRegGrid->setAttributeInt("GridPointCountI", regGrid.gridPointCountI());
xmlRegGrid->setAttributeInt("GridPointCountJ", regGrid.gridPointCountJ());
xmlRegGrid->setAttributeDouble("SpacingX", regGrid.spacing().x());
xmlRegGrid->setAttributeDouble("SpacingY", regGrid.spacing().y());
xmlRegGrid->setAttributeDouble("OffsetX", regGrid.offset().x());
xmlRegGrid->setAttributeDouble("OffsetY", regGrid.offset().y());
XmlElement* xmlElevations = xmlRegGrid->addChildElement("Elevations");
CVF_ASSERT(xmlElevations);
String valueText;
int j;
for (j = 0; j < regGrid.gridPointCountJ(); j++)
{
int i;
for (i = 0; i < regGrid.gridPointCountI(); i++)
{
valueText += String::number(regGrid.elevation(i, j), 'f', static_cast<int>(precision));
valueText += " ";
}
}
xmlElevations->setValueText(valueText);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RegGrid2DExportXml::exportToXmlFile(const RegGrid2D& regGrid, uint precision, const String& filename)
{
ref<XmlDocument> doc = XmlDocument::create();
CVF_ASSERT(doc.notNull());
XmlElement* root = doc->createRootElement("Root");
if (!root)
{
return false;
}
exportToXml(regGrid, precision, root);
return doc->saveFile(filename);
}
} // namespace cvf

View File

@ -0,0 +1,60 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
namespace cvf {
class RegGrid2D;
class XmlElement;
class String;
//==================================================================================================
//
//
//
//==================================================================================================
class RegGrid2DExportXml
{
public:
static bool exportToXmlFile(const RegGrid2D& regGrid, uint precision, const String& filename);
static void exportToXml(const RegGrid2D& regGrid, uint precision, XmlElement* parent);
};
}

View File

@ -0,0 +1,396 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfRegGrid2DGeometry.h"
#include "cvfRegGrid2D.h"
#include "cvfGeometryUtils.h"
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfGeometryBuilderDrawableGeo.h"
namespace cvf {
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RegGrid2DGeometry::RegGrid2DGeometry(const RegGrid2D* regGrid2D)
{
CVF_ASSERT(regGrid2D);
m_regGrid2D = const_cast<RegGrid2D*>(regGrid2D);
m_translation = Vec3d::ZERO;
m_elevationScaleFactor = 1.0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RegGrid2DGeometry::~RegGrid2DGeometry()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2DGeometry::setTranslation(const Vec3d& translation)
{
m_translation = translation;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RegGrid2DGeometry::setElevationScaleFactor(double scaleFactor)
{
m_elevationScaleFactor = scaleFactor;
}
//--------------------------------------------------------------------------------------------------
/// It is allowed to create a surface when elevations are undefined. Should this be allowed?
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> RegGrid2DGeometry::generateSurface() const
{
CVF_ASSERT(m_regGrid2D->gridPointCountI() >= 0);
CVF_ASSERT(m_regGrid2D->gridPointCountJ() >= 0);
uint numPointsI = static_cast<uint>(m_regGrid2D->gridPointCountI());
uint numPointsJ = static_cast<uint>(m_regGrid2D->gridPointCountJ());
if (numPointsI < 2 || numPointsJ < 2)
{
CVF_FAIL_MSG("Must have at least two grid points in each direction");
return NULL;
}
ref<UIntArray> indices = new UIntArray;
GeometryUtils::tesselatePatchAsTriangles(numPointsI, numPointsJ, 0, true, indices.p());
ref<PrimitiveSetIndexedUInt> primSet = new PrimitiveSetIndexedUInt(PT_TRIANGLES);
primSet->setIndices(indices.p());
ref<Vec3fArray> vertices = createSurfaceVertexArray();
ref<DrawableGeo> geo = new DrawableGeo;
geo->setVertexArray(vertices.p());
geo->addPrimitiveSet(primSet.p());
return geo;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> RegGrid2DGeometry::generateClosedVolume(double minimumZ) const
{
int numPointsI = m_regGrid2D->gridPointCountI();
int numPointsJ = m_regGrid2D->gridPointCountJ();
if (numPointsI < 2 || numPointsJ < 2)
{
return NULL;
}
double minElevation, maxElevation;
if (!m_regGrid2D->minMaxElevation(&minElevation, &maxElevation))
{
return NULL;
}
// Not possible to create a valid closed volume if requested minimum Z is larger than minElevation
if (minimumZ > minElevation)
{
return NULL;
}
ref<DrawableGeo> surface = generateSurface();
CVF_ASSERT(surface.notNull());
ref<DrawableGeo> sideMinimumX = generateSideMinimumX(minimumZ);
CVF_ASSERT(sideMinimumX.notNull());
ref<DrawableGeo> sideMaximumX = generateSideMaximumX(minimumZ);
CVF_ASSERT(sideMaximumX.notNull());
ref<DrawableGeo> sideMinimumY = generateSideMinimumY(minimumZ);
CVF_ASSERT(sideMinimumY.notNull());
ref<DrawableGeo> sideMaximumY = generateSideMaximumY(minimumZ);
CVF_ASSERT(sideMaximumY.notNull());
ref<DrawableGeo> sideMinimumZ = generateSideMinimumZ(minimumZ);
CVF_ASSERT(sideMinimumZ.notNull());
Collection<DrawableGeo> geoCollection;
geoCollection.push_back(surface.p());
geoCollection.push_back(sideMinimumX.p());
geoCollection.push_back(sideMaximumX.p());
geoCollection.push_back(sideMinimumY.p());
geoCollection.push_back(sideMaximumY.p());
geoCollection.push_back(sideMinimumZ.p());
ref<DrawableGeo> closedVolume = new DrawableGeo;
closedVolume->mergeInto(geoCollection);
return closedVolume;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> RegGrid2DGeometry::generateSideMinimumX(double minimumZ) const
{
int numPointsY = m_regGrid2D->gridPointCountJ();
ref<GeometryBuilderDrawableGeo> geoBuilder = new GeometryBuilderDrawableGeo;
Vec3f a, b, c, d;
for (int iy = 0; iy < numPointsY - 1; iy++)
{
{
b = transformedGridPointCoordinate(0, static_cast<uint>(iy));
a = transformedGridPointCoordinateFixedElevation(0, static_cast<uint>(iy), minimumZ);
}
{
c = transformedGridPointCoordinate(0, static_cast<uint>(iy + 1));
d = transformedGridPointCoordinateFixedElevation(0, static_cast<uint>(iy + 1), minimumZ);
}
geoBuilder->addTriangleByVertices(a, b, c);
geoBuilder->addTriangleByVertices(a, c, d);
}
return geoBuilder->drawableGeo();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> RegGrid2DGeometry::generateSideMaximumX(double minimumZ) const
{
int numPointsX = m_regGrid2D->gridPointCountI();
int numPointsY = m_regGrid2D->gridPointCountJ();
ref<GeometryBuilderDrawableGeo> geoBuilder = new GeometryBuilderDrawableGeo;
Vec3f a, b, c, d;
for (int iy = 0; iy < numPointsY - 1; iy++)
{
{
b = transformedGridPointCoordinate( static_cast<uint>(numPointsX - 1), static_cast<uint>(iy));
a = transformedGridPointCoordinateFixedElevation( static_cast<uint>(numPointsX - 1), static_cast<uint>(iy), minimumZ);
}
{
c = transformedGridPointCoordinate( static_cast<uint>(numPointsX - 1), static_cast<uint>(iy));
d = transformedGridPointCoordinateFixedElevation( static_cast<uint>(numPointsX - 1), static_cast<uint>(iy), minimumZ);
}
geoBuilder->addTriangleByVertices(b, a, c);
geoBuilder->addTriangleByVertices(a, d, c);
}
return geoBuilder->drawableGeo();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> RegGrid2DGeometry::generateSideMinimumY(double minimumZ) const
{
int numPointsX = m_regGrid2D->gridPointCountI();
ref<GeometryBuilderDrawableGeo> geoBuilder = new GeometryBuilderDrawableGeo;
Vec3f a, b, c, d;
for (int ix = 0; ix < numPointsX - 1; ix++)
{
{
b = transformedGridPointCoordinate( static_cast<uint>(ix), 0);
a = transformedGridPointCoordinateFixedElevation( static_cast<uint>(ix), 0, minimumZ);
}
{
c = transformedGridPointCoordinate( static_cast<uint>(ix + 1), 0);
d = transformedGridPointCoordinateFixedElevation( static_cast<uint>(ix + 1), 0, minimumZ);
}
geoBuilder->addTriangleByVertices(b, a, c);
geoBuilder->addTriangleByVertices(a, d, c);
}
return geoBuilder->drawableGeo();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> RegGrid2DGeometry::generateSideMaximumY(double minimumZ) const
{
int numPointsX = m_regGrid2D->gridPointCountI();
int numPointsY = m_regGrid2D->gridPointCountJ();
ref<GeometryBuilderDrawableGeo> geoBuilder = new GeometryBuilderDrawableGeo;
Vec3f a, b, c, d;
for (int ix = 0; ix < numPointsX - 1; ix++)
{
{
b = transformedGridPointCoordinate( static_cast<uint>(ix), static_cast<uint>(numPointsY - 1));
a = transformedGridPointCoordinateFixedElevation( static_cast<uint>(ix), static_cast<uint>(numPointsY - 1), minimumZ);
}
{
c = transformedGridPointCoordinate( static_cast<uint>(ix + 1), static_cast<uint>(numPointsY - 1));
d = transformedGridPointCoordinateFixedElevation( static_cast<uint>(ix + 1), static_cast<uint>(numPointsY - 1), minimumZ);
}
geoBuilder->addTriangleByVertices(a, b, c);
geoBuilder->addTriangleByVertices(d, a, c);
}
return geoBuilder->drawableGeo();
}
//--------------------------------------------------------------------------------------------------
/// NOTE: To avoid bad edges in exported STL geometry, the bottom geometry is fully tessellated.
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> RegGrid2DGeometry::generateSideMinimumZ(double minimumZ) const
{
CVF_ASSERT(m_regGrid2D->gridPointCountI() >= 0);
CVF_ASSERT(m_regGrid2D->gridPointCountJ() >= 0);
uint numPointsI = static_cast<uint>(m_regGrid2D->gridPointCountI());
uint numPointsJ = static_cast<uint>(m_regGrid2D->gridPointCountJ());
if (numPointsI < 2 || numPointsJ < 2)
{
CVF_FAIL_MSG("Must have at least two grid points in each direction");
return NULL;
}
ref<UIntArray> indices = new UIntArray;
// Use opposite winding type compared to generateSurface() to make the surface normal point out of the closed volume
GeometryUtils::tesselatePatchAsTriangles(numPointsI, numPointsJ, 0, false, indices.p());
ref<PrimitiveSetIndexedUInt> primSet = new PrimitiveSetIndexedUInt(PT_TRIANGLES);
primSet->setIndices(indices.p());
uint numPoints = numPointsI * numPointsJ;
ref<Vec3fArray> vertices = new Vec3fArray;
vertices->reserve(numPoints);
uint j;
for (j = 0; j < numPointsJ; j++)
{
uint i;
for (i = 0; i < numPointsI; i++)
{
Vec3f coord = transformedGridPointCoordinateFixedElevation(i, j, minimumZ);
vertices->add(coord);
}
}
ref<DrawableGeo> geo = new DrawableGeo;
geo->setVertexArray(vertices.p());
geo->addPrimitiveSet(primSet.p());
return geo;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ref<Vec3fArray> RegGrid2DGeometry::createSurfaceVertexArray() const
{
CVF_ASSERT(m_regGrid2D->gridPointCountI() >= 0);
CVF_ASSERT(m_regGrid2D->gridPointCountJ() >= 0);
uint gridPointCountI = static_cast<uint>(m_regGrid2D->gridPointCountI());
uint gridPointCountJ = static_cast<uint>(m_regGrid2D->gridPointCountJ());
uint numPoints = gridPointCountI * gridPointCountJ;
ref<Vec3fArray> vertices = new Vec3fArray;
vertices->reserve(numPoints);
uint j;
for (j = 0; j < gridPointCountJ; j++)
{
uint i;
for (i = 0; i < gridPointCountI; i++)
{
Vec3f coord = transformedGridPointCoordinate(i, j);
vertices->add(coord);
}
}
return vertices;
}
//--------------------------------------------------------------------------------------------------
/// Scale elevation using elevation scale factor and add translation
//--------------------------------------------------------------------------------------------------
cvf::Vec3f RegGrid2DGeometry::transformedGridPointCoordinate(uint i, uint j) const
{
double elevation = m_regGrid2D->elevation(static_cast<int>(i), static_cast<int>(j));
elevation *= m_elevationScaleFactor;
Vec2d coord2D = m_regGrid2D->gridPointCoordinate(static_cast<int>(i), static_cast<int>(j));
Vec3d gridPointCoord(coord2D, elevation);
gridPointCoord += m_translation;
return Vec3f(gridPointCoord);
}
//--------------------------------------------------------------------------------------------------
/// Create 3D point from XY coords based on grid point IJ and Z based on given elevation. Add 3D translation to this vector.
/// Note: Elevation scaling is not applied
//--------------------------------------------------------------------------------------------------
Vec3f RegGrid2DGeometry::transformedGridPointCoordinateFixedElevation(uint i, uint j, double elevation) const
{
Vec2d coord2D = m_regGrid2D->gridPointCoordinate(static_cast<int>(i), static_cast<int>(j));
Vec3d gridPointCoord(coord2D, elevation);
gridPointCoord += m_translation;
return Vec3f(gridPointCoord);
}
} // namespace cvf

View File

@ -0,0 +1,83 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfArray.h"
namespace cvf {
class RegGrid2D;
class DrawableGeo;
//==================================================================================================
//
//
//
//==================================================================================================
class RegGrid2DGeometry : public Object
{
public:
RegGrid2DGeometry(const RegGrid2D* regGrid2D);
~RegGrid2DGeometry();
void setTranslation(const Vec3d& translation);
void setElevationScaleFactor(double scaleFactor);
ref<DrawableGeo> generateSurface() const;
ref<DrawableGeo> generateClosedVolume(double minimumZ) const;
private:
ref<DrawableGeo> generateSideMinimumX(double minimumZ) const; // Does not compute normals
ref<DrawableGeo> generateSideMaximumX(double minimumZ) const; // Does not compute normals
ref<DrawableGeo> generateSideMinimumY(double minimumZ) const; // Does not compute normals
ref<DrawableGeo> generateSideMaximumY(double minimumZ) const; // Does not compute normals
ref<DrawableGeo> generateSideMinimumZ(double minimumZ) const; // Does not compute normals
ref<Vec3fArray> createSurfaceVertexArray() const;
Vec3f transformedGridPointCoordinate(uint i, uint j) const;
Vec3f transformedGridPointCoordinateFixedElevation(uint i, uint j, double elevation) const;
private:
ref<RegGrid2D> m_regGrid2D;
Vec3d m_translation;
double m_elevationScaleFactor;
};
}

View File

@ -0,0 +1,136 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfRegGrid2DImportXml.h"
#include "cvfRegGrid2D.h"
#include "cvfXml.h"
namespace cvf {
//==================================================================================================
///
/// \class cvf::RegGrid2DImportXml
/// \ingroup RegGrid2D
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RegGrid2DImportXml::importFromXmlFile(const String& filename, RegGrid2D* regGrid)
{
CVF_ASSERT(regGrid);
ref<XmlDocument> doc = XmlDocument::create();
if (!doc->loadFile(filename))
{
return false;
}
XmlElement* root = doc->getRootElement("");
if (!root)
{
return false;
}
return importFromXml(*root, regGrid);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RegGrid2DImportXml::importFromXml(const XmlElement& root, RegGrid2D* regGrid)
{
CVF_ASSERT(regGrid);
const XmlElement* xmlRegGrid = root.firstChildElement("RegularGrid2D");
if (!xmlRegGrid)
{
return false;
}
bool found = false;
int gridPointCountI = xmlRegGrid->getAttributeInt("GridPointCountI", -1, &found);
if (!found) return false;
int gridPointCountJ = xmlRegGrid->getAttributeInt("GridPointCountJ", -1, &found);
if (!found) return false;
double spacingX = xmlRegGrid->getAttributeDouble("SpacingX", -1, &found);
if (!found) return false;
double spacingY = xmlRegGrid->getAttributeDouble("SpacingY", -1, &found);
if (!found) return false;
double offsetX = xmlRegGrid->getAttributeDouble("OffsetX", -1, &found);
if (!found) return false;
double offsetY = xmlRegGrid->getAttributeDouble("OffsetY", -1, &found);
if (!found) return false;
regGrid->setOffset(Vec2d(offsetX, offsetY));
regGrid->setSpacing(Vec2d(spacingX, spacingY));
regGrid->allocateGrid(gridPointCountI, gridPointCountJ);
DoubleArray elevations;
elevations.reserve(static_cast<size_t>(regGrid->gridPointCount()));
const cvf::XmlElement* xmlElevations = xmlRegGrid->firstChildElement("Elevations");
if (!xmlElevations) return false;
String valueText = xmlElevations->valueText();
std::vector<String> elevationStrings = valueText.split();
size_t i;
for (i = 0; i < elevationStrings.size(); i++)
{
elevations.add(elevationStrings[i].toDouble());
}
regGrid->setElevations(elevations);
return true;
}
} // namespace cvf

View File

@ -0,0 +1,59 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
namespace cvf {
class RegGrid2D;
class String;
class XmlElement;
//==================================================================================================
//
//
//
//==================================================================================================
class RegGrid2DImportXml
{
public:
static bool importFromXmlFile(const String& filename, RegGrid2D* regGrid);
static bool importFromXml(const XmlElement& root, RegGrid2D* regGrid);
};
}

View File

@ -0,0 +1,584 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug MD TBB|Win32">
<Configuration>Debug MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD TBB|x64">
<Configuration>Debug MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|Win32">
<Configuration>Debug MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|x64">
<Configuration>Debug MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|Win32">
<Configuration>Release MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|x64">
<Configuration>Release MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|Win32">
<Configuration>Release MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|x64">
<Configuration>Release MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C07ADE80-5C4F-E6E3-DD1A-5A619403FA9F}</ProjectGuid>
<RootNamespace>LibRender</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>PrepareForBuild</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>PrepareForBuild</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>PrepareForBuild</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>PrepareForBuild</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>PrepareForBuild</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>PrepareForBuild</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>PrepareForBuild</CustomBuildAfterTargets>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
<CustomBuildAfterTargets>PrepareForBuild</CustomBuildAfterTargets>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibGeometry;../LibIo;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<CustomBuildStep>
<Command>..\Tools\Glsl2Include\Glsl2Include.exe glsl\ cvfShaderSourceStrings.h</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Building shader source strings</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>cvfShaderSourceStrings.h</Outputs>
<Inputs>FileWillNeverExist.txt</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibGeometry;../LibIo;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<CustomBuildStep>
<Command>..\Tools\Glsl2Include\Glsl2Include.exe glsl\ cvfShaderSourceStrings.h</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Building shader source strings</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>cvfShaderSourceStrings.h</Outputs>
<Inputs>FileWillNeverExist.txt</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibGeometry;../LibIo;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<CustomBuildStep>
<Command>..\Tools\Glsl2Include\Glsl2Include.exe glsl\ cvfShaderSourceStrings.h</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Building shader source strings</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>cvfShaderSourceStrings.h</Outputs>
<Inputs>FileWillNeverExist.txt</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibGeometry;../LibIo;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<CustomBuildStep>
<Command>..\Tools\Glsl2Include\Glsl2Include.exe glsl\ cvfShaderSourceStrings.h</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Building shader source strings</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>cvfShaderSourceStrings.h</Outputs>
<Inputs>FileWillNeverExist.txt</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibGeometry;../LibIo;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<CustomBuildStep>
<Command>..\Tools\Glsl2Include\Glsl2Include.exe glsl\ cvfShaderSourceStrings.h</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Building shader source strings</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>cvfShaderSourceStrings.h</Outputs>
<Inputs>FileWillNeverExist.txt</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibGeometry;../LibIo;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<CustomBuildStep>
<Command>..\Tools\Glsl2Include\Glsl2Include.exe glsl\ cvfShaderSourceStrings.h</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Building shader source strings</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>cvfShaderSourceStrings.h</Outputs>
<Inputs>FileWillNeverExist.txt</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibGeometry;../LibIo;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<CustomBuildStep>
<Command>..\Tools\Glsl2Include\Glsl2Include.exe glsl\ cvfShaderSourceStrings.h</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Building shader source strings</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>cvfShaderSourceStrings.h</Outputs>
<Inputs>FileWillNeverExist.txt</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibGeometry;../LibIo;../ThirdParty/FreeType/include</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<CustomBuildStep>
<Command>..\Tools\Glsl2Include\Glsl2Include.exe glsl\ cvfShaderSourceStrings.h</Command>
</CustomBuildStep>
<CustomBuildStep>
<Message>Building shader source strings</Message>
</CustomBuildStep>
<CustomBuildStep>
<Outputs>cvfShaderSourceStrings.h</Outputs>
<Inputs>FileWillNeverExist.txt</Inputs>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="cvfCameraAnimation.h" />
<ClInclude Include="cvfFramebufferObject.h" />
<ClInclude Include="cvfHitDetail.h" />
<ClInclude Include="cvfOglRc.h" />
<ClInclude Include="cvfOpenGLCapabilities.h" />
<ClInclude Include="cvfOpenGLContextGroup.h" />
<ClInclude Include="cvfOverlayImage.h" />
<ClInclude Include="cvfOverlayItem.h" />
<ClInclude Include="cvfOverlayNavigationCube.h" />
<ClInclude Include="cvfOverlayTextBox.h" />
<ClInclude Include="cvfPrimitiveSetDirect.h" />
<ClInclude Include="cvfPrimitiveSetIndexedUShortScoped.h" />
<ClInclude Include="cvfRenderbufferObject.h" />
<ClInclude Include="cvfRenderStateBlending.h" />
<ClInclude Include="cvfRenderStateColorMask.h" />
<ClInclude Include="cvfRenderStateCullFace.h" />
<ClInclude Include="cvfRenderStateDepth.h" />
<ClInclude Include="cvfRenderStateFrontFace.h" />
<ClInclude Include="cvfRenderStateLine.h" />
<ClInclude Include="cvfRenderStatePoint.h" />
<ClInclude Include="cvfRenderStatePolygonMode.h" />
<ClInclude Include="cvfRenderStatePolygonOffset.h" />
<ClInclude Include="cvfRenderStateStencil.h" />
<ClInclude Include="cvfRenderStateTextureBindings.h" />
<ClInclude Include="cvfVertexAttribute.h" />
<ClInclude Include="cvfVertexBundle.h" />
<ClInclude Include="glsl\fs_CenterLitSpherePoints.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_FixedColorMagenta.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_Shadow_v33.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_Standard.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_Text.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_Unlit.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_VectorDrawer.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_Void.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\gs_PassThroughTriangle_v33.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\light_Phong.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\light_PhongDual.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\light_SimpleHeadlight.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\src_Color.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\src_Texture.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\src_TextureGlobalAlpha.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\src_TextureFromPointCoord.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\src_TextureRectFromFragCoord_v33.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\vs_DistanceScaledPoints.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\vs_EnvironmentMapping.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\vs_FullScreenQuad.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\vs_Minimal.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\vs_MinimalTexture.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\vs_Standard.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\vs_VectorDrawer.glsl">
<FileType>Document</FileType>
</ClInclude>
<None Include="CMakeLists.txt" />
<None Include="glsl\!AddingAndModifyingGlslFiles.txt" />
<ClInclude Include="glsl\fs_GradientTopBottom.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\calcClipDistances.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\calcShadowCoord.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\checkDiscard_ClipDistances.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_GradientTopMiddleBottom.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_ParticleTraceComets.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\vs_ParticleTraceComets.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\light_Headlight.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_HighlightStencilBlur_v33.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_HighlightStencilDraw.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_HighlightStencilMix_v33.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_GaussianBlur.glsl">
<FileType>Document</FileType>
</ClInclude>
<ClInclude Include="glsl\fs_HighlightMix.glsl">
<FileType>Document</FileType>
</ClInclude>
<None Include="glsl\src_TwoSidedColor.glsl" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfBufferObjectManaged.h" />
<ClInclude Include="cvfCamera.h" />
<ClInclude Include="cvfDrawable.h" />
<ClInclude Include="cvfDrawableGeo.h" />
<ClInclude Include="cvfDrawableText.h" />
<ClInclude Include="cvfDrawableVectors.h" />
<ClInclude Include="cvfFixedAtlasFont.h" />
<ClInclude Include="cvfFont.h" />
<ClInclude Include="cvfGeometryBuilderDrawableGeo.h" />
<ClInclude Include="cvfGlyph.h" />
<ClInclude Include="cvfLibRender.h" />
<ClInclude Include="cvfMatrixState.h" />
<ClInclude Include="cvfOpenGL.h" />
<ClInclude Include="cvfOpenGLContext.h" />
<ClInclude Include="cvfOpenGLResourceManager.h" />
<ClInclude Include="cvfOpenGLTypes.h" />
<ClInclude Include="cvfOverlayAxisCross.h" />
<ClInclude Include="cvfOverlayColorLegend.h" />
<ClInclude Include="cvfPrimitiveSet.h" />
<ClInclude Include="cvfPrimitiveSetIndexedUInt.h" />
<ClInclude Include="cvfPrimitiveSetIndexedUIntScoped.h" />
<ClInclude Include="cvfPrimitiveSetIndexedUShort.h" />
<ClInclude Include="cvfRenderState.h" />
<ClInclude Include="cvfRenderStateSet.h" />
<ClInclude Include="cvfRenderStateTracker.h" />
<ClInclude Include="cvfRenderState_FF.h" />
<ClInclude Include="cvfSampler.h" />
<ClInclude Include="cvfScalarMapper.h" />
<ClInclude Include="cvfScalarMapperUniformLevels.h" />
<ClInclude Include="cvfShader.h" />
<ClInclude Include="cvfShaderSourceProvider.h" />
<ClInclude Include="cvfShaderProgram.h" />
<ClInclude Include="cvfShaderProgramGenerator.h" />
<ClInclude Include="cvfShaderSourceRepository.h" />
<ClInclude Include="cvfShaderSourceRepositoryFile.h" />
<ClInclude Include="cvfShaderSourceStrings.h" />
<ClInclude Include="cvfTextDrawer.h" />
<ClInclude Include="cvfTexture.h" />
<ClInclude Include="cvfTexture2D_FF.h" />
<ClInclude Include="cvfTextureImage.h" />
<ClInclude Include="cvfUniform.h" />
<ClInclude Include="cvfUniformSet.h" />
<ClInclude Include="cvfViewport.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfBufferObjectManaged.cpp" />
<ClCompile Include="cvfCamera.cpp" />
<ClCompile Include="cvfCameraAnimation.cpp" />
<ClCompile Include="cvfDrawable.cpp" />
<ClCompile Include="cvfDrawableGeo.cpp" />
<ClCompile Include="cvfDrawableText.cpp" />
<ClCompile Include="cvfDrawableVectors.cpp" />
<ClCompile Include="cvfFixedAtlasFont.cpp" />
<ClCompile Include="cvfFont.cpp" />
<ClCompile Include="cvfFramebufferObject.cpp" />
<ClCompile Include="cvfGeometryBuilderDrawableGeo.cpp" />
<ClCompile Include="cvfGlyph.cpp" />
<ClCompile Include="cvfHitDetail.cpp" />
<ClCompile Include="cvfMatrixState.cpp" />
<ClCompile Include="cvfOglRc.cpp" />
<ClCompile Include="cvfOpenGL.cpp" />
<ClCompile Include="cvfOpenGLCapabilities.cpp" />
<ClCompile Include="cvfOpenGLContext.cpp" />
<ClCompile Include="cvfOpenGLContextGroup.cpp" />
<ClCompile Include="cvfOpenGLResourceManager.cpp" />
<ClCompile Include="cvfOverlayAxisCross.cpp" />
<ClCompile Include="cvfOverlayColorLegend.cpp" />
<ClCompile Include="cvfOverlayImage.cpp" />
<ClCompile Include="cvfOverlayItem.cpp" />
<ClCompile Include="cvfOverlayNavigationCube.cpp" />
<ClCompile Include="cvfOverlayTextBox.cpp" />
<ClCompile Include="cvfPrimitiveSet.cpp" />
<ClCompile Include="cvfPrimitiveSetDirect.cpp" />
<ClCompile Include="cvfPrimitiveSetIndexedUInt.cpp" />
<ClCompile Include="cvfPrimitiveSetIndexedUIntScoped.cpp" />
<ClCompile Include="cvfPrimitiveSetIndexedUShort.cpp" />
<ClCompile Include="cvfPrimitiveSetIndexedUShortScoped.cpp" />
<ClCompile Include="cvfRenderbufferObject.cpp" />
<ClCompile Include="cvfRenderState.cpp" />
<ClCompile Include="cvfRenderStateBlending.cpp" />
<ClCompile Include="cvfRenderStateColorMask.cpp" />
<ClCompile Include="cvfRenderStateCullFace.cpp" />
<ClCompile Include="cvfRenderStateDepth.cpp" />
<ClCompile Include="cvfRenderStateFrontFace.cpp" />
<ClCompile Include="cvfRenderStateLine.cpp" />
<ClCompile Include="cvfRenderStatePoint.cpp" />
<ClCompile Include="cvfRenderStatePolygonMode.cpp" />
<ClCompile Include="cvfRenderStatePolygonOffset.cpp" />
<ClCompile Include="cvfRenderStateSet.cpp" />
<ClCompile Include="cvfRenderStateStencil.cpp" />
<ClCompile Include="cvfRenderStateTextureBindings.cpp" />
<ClCompile Include="cvfRenderStateTracker.cpp" />
<ClCompile Include="cvfRenderState_FF.cpp" />
<ClCompile Include="cvfSampler.cpp" />
<ClCompile Include="cvfScalarMapper.cpp" />
<ClCompile Include="cvfScalarMapperUniformLevels.cpp" />
<ClCompile Include="cvfShader.cpp" />
<ClCompile Include="cvfShaderSourceProvider.cpp" />
<ClCompile Include="cvfShaderProgram.cpp" />
<ClCompile Include="cvfShaderProgramGenerator.cpp" />
<ClCompile Include="cvfShaderSourceRepository.cpp" />
<ClCompile Include="cvfShaderSourceRepositoryFile.cpp" />
<ClCompile Include="cvfTextDrawer.cpp" />
<ClCompile Include="cvfTexture.cpp" />
<ClCompile Include="cvfTexture2D_FF.cpp" />
<ClCompile Include="cvfTextureImage.cpp" />
<ClCompile Include="cvfUniform.cpp" />
<ClCompile Include="cvfUniformSet.cpp" />
<ClCompile Include="cvfVertexAttribute.cpp" />
<ClCompile Include="cvfVertexBundle.cpp" />
<ClCompile Include="cvfViewport.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,267 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="glsl">
<UniqueIdentifier>{90f89af3-6cfb-48ea-ae6f-d85a67b4b6cd}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfCamera.h" />
<ClInclude Include="cvfDrawable.h" />
<ClInclude Include="cvfDrawableGeo.h" />
<ClInclude Include="cvfDrawableVectors.h" />
<ClInclude Include="cvfGeometryBuilderDrawableGeo.h" />
<ClInclude Include="cvfLibRender.h" />
<ClInclude Include="cvfOpenGL.h" />
<ClInclude Include="cvfOpenGLContext.h" />
<ClInclude Include="cvfOpenGLResourceManager.h" />
<ClInclude Include="cvfOpenGLTypes.h" />
<ClInclude Include="cvfOverlayAxisCross.h" />
<ClInclude Include="cvfOverlayColorLegend.h" />
<ClInclude Include="cvfPrimitiveSet.h" />
<ClInclude Include="cvfPrimitiveSetIndexedUInt.h" />
<ClInclude Include="cvfPrimitiveSetIndexedUShort.h" />
<ClInclude Include="cvfRenderState.h" />
<ClInclude Include="cvfRenderStateSet.h" />
<ClInclude Include="cvfSampler.h" />
<ClInclude Include="cvfScalarMapper.h" />
<ClInclude Include="cvfShader.h" />
<ClInclude Include="cvfShaderProgram.h" />
<ClInclude Include="cvfShaderSourceRepository.h" />
<ClInclude Include="cvfTexture.h" />
<ClInclude Include="cvfTextureImage.h" />
<ClInclude Include="cvfUniform.h" />
<ClInclude Include="cvfUniformSet.h" />
<ClInclude Include="cvfViewport.h" />
<ClInclude Include="cvfBufferObjectManaged.h" />
<ClInclude Include="cvfScalarMapperUniformLevels.h" />
<ClInclude Include="cvfRenderStateTracker.h" />
<ClInclude Include="cvfTexture2D_FF.h" />
<ClInclude Include="cvfRenderState_FF.h" />
<ClInclude Include="cvfMatrixState.h" />
<ClInclude Include="cvfShaderSourceRepositoryFile.h" />
<ClInclude Include="cvfFont.h" />
<ClInclude Include="cvfTextDrawer.h" />
<ClInclude Include="cvfGlyph.h" />
<ClInclude Include="cvfFixedAtlasFont.h" />
<ClInclude Include="cvfDrawableText.h" />
<ClInclude Include="cvfShaderProgramGenerator.h" />
<ClInclude Include="cvfShaderSourceProvider.h" />
<ClInclude Include="cvfPrimitiveSetIndexedUIntScoped.h" />
<ClInclude Include="cvfShaderSourceStrings.h" />
<ClInclude Include="glsl\vs_Standard.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\vs_MinimalTexture.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\vs_Minimal.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\vs_FullScreenQuad.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\vs_EnvironmentMapping.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\vs_DistanceScaledPoints.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\src_Texture.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\src_Color.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\light_SimpleHeadlight.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\light_PhongDual.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\light_Phong.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\gs_PassThroughTriangle_v33.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_Void.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_VectorDrawer.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_Unlit.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_Text.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_Standard.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_Shadow_v33.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_FixedColorMagenta.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\vs_VectorDrawer.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_CenterLitSpherePoints.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_GradientTopBottom.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\calcShadowCoord.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\checkDiscard_ClipDistances.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\calcClipDistances.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="cvfPrimitiveSetIndexedUShortScoped.h" />
<ClInclude Include="cvfVertexAttribute.h" />
<ClInclude Include="glsl\vs_ParticleTraceComets.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_ParticleTraceComets.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="cvfPrimitiveSetDirect.h" />
<ClInclude Include="cvfOverlayItem.h" />
<ClInclude Include="cvfHitDetail.h" />
<ClInclude Include="cvfOpenGLContextGroup.h" />
<ClInclude Include="cvfOglRc.h" />
<ClInclude Include="cvfFramebufferObject.h" />
<ClInclude Include="cvfRenderbufferObject.h" />
<ClInclude Include="cvfOpenGLCapabilities.h" />
<ClInclude Include="cvfOverlayTextBox.h" />
<ClInclude Include="glsl\src_TextureGlobalAlpha.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\src_TextureFromPointCoord.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\src_TextureRectFromFragCoord_v33.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="cvfVertexBundle.h" />
<ClInclude Include="glsl\light_Headlight.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="cvfRenderStateBlending.h" />
<ClInclude Include="cvfRenderStateColorMask.h" />
<ClInclude Include="cvfRenderStateCullFace.h" />
<ClInclude Include="cvfRenderStateDepth.h" />
<ClInclude Include="cvfRenderStateFrontFace.h" />
<ClInclude Include="cvfRenderStateLine.h" />
<ClInclude Include="cvfRenderStatePoint.h" />
<ClInclude Include="cvfRenderStatePolygonMode.h" />
<ClInclude Include="cvfRenderStatePolygonOffset.h" />
<ClInclude Include="cvfRenderStateTextureBindings.h" />
<ClInclude Include="cvfOverlayNavigationCube.h" />
<ClInclude Include="cvfRenderStateStencil.h" />
<ClInclude Include="glsl\fs_GradientTopMiddleBottom.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_GaussianBlur.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_HighlightStencilBlur_v33.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_HighlightStencilMix_v33.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_HighlightStencilDraw.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="glsl\fs_HighlightMix.glsl">
<Filter>glsl</Filter>
</ClInclude>
<ClInclude Include="cvfOverlayImage.h" />
<ClInclude Include="cvfCameraAnimation.h" />
</ItemGroup>
<ItemGroup>
<None Include="glsl\!AddingAndModifyingGlslFiles.txt">
<Filter>glsl</Filter>
</None>
<None Include="CMakeLists.txt" />
<None Include="glsl\src_TwoSidedColor.glsl">
<Filter>glsl</Filter>
</None>
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfCamera.cpp" />
<ClCompile Include="cvfDrawable.cpp" />
<ClCompile Include="cvfDrawableGeo.cpp" />
<ClCompile Include="cvfDrawableVectors.cpp" />
<ClCompile Include="cvfGeometryBuilderDrawableGeo.cpp" />
<ClCompile Include="cvfOpenGL.cpp" />
<ClCompile Include="cvfOpenGLContext.cpp" />
<ClCompile Include="cvfOpenGLResourceManager.cpp" />
<ClCompile Include="cvfOverlayAxisCross.cpp" />
<ClCompile Include="cvfOverlayColorLegend.cpp" />
<ClCompile Include="cvfPrimitiveSet.cpp" />
<ClCompile Include="cvfPrimitiveSetIndexedUInt.cpp" />
<ClCompile Include="cvfPrimitiveSetIndexedUShort.cpp" />
<ClCompile Include="cvfRenderState.cpp" />
<ClCompile Include="cvfRenderStateSet.cpp" />
<ClCompile Include="cvfSampler.cpp" />
<ClCompile Include="cvfScalarMapper.cpp" />
<ClCompile Include="cvfShader.cpp" />
<ClCompile Include="cvfShaderProgram.cpp" />
<ClCompile Include="cvfShaderSourceRepository.cpp" />
<ClCompile Include="cvfTexture.cpp" />
<ClCompile Include="cvfTextureImage.cpp" />
<ClCompile Include="cvfUniform.cpp" />
<ClCompile Include="cvfUniformSet.cpp" />
<ClCompile Include="cvfViewport.cpp" />
<ClCompile Include="cvfBufferObjectManaged.cpp" />
<ClCompile Include="cvfScalarMapperUniformLevels.cpp" />
<ClCompile Include="cvfRenderStateTracker.cpp" />
<ClCompile Include="cvfTexture2D_FF.cpp" />
<ClCompile Include="cvfRenderState_FF.cpp" />
<ClCompile Include="cvfMatrixState.cpp" />
<ClCompile Include="cvfShaderSourceRepositoryFile.cpp" />
<ClCompile Include="cvfFont.cpp" />
<ClCompile Include="cvfTextDrawer.cpp" />
<ClCompile Include="cvfGlyph.cpp" />
<ClCompile Include="cvfFixedAtlasFont.cpp" />
<ClCompile Include="cvfDrawableText.cpp" />
<ClCompile Include="cvfShaderProgramGenerator.cpp" />
<ClCompile Include="cvfShaderSourceProvider.cpp" />
<ClCompile Include="cvfPrimitiveSetIndexedUIntScoped.cpp" />
<ClCompile Include="cvfPrimitiveSetIndexedUShortScoped.cpp" />
<ClCompile Include="cvfVertexAttribute.cpp" />
<ClCompile Include="cvfPrimitiveSetDirect.cpp" />
<ClCompile Include="cvfHitDetail.cpp" />
<ClCompile Include="cvfOpenGLContextGroup.cpp" />
<ClCompile Include="cvfOglRc.cpp" />
<ClCompile Include="cvfFramebufferObject.cpp" />
<ClCompile Include="cvfRenderbufferObject.cpp" />
<ClCompile Include="cvfOpenGLCapabilities.cpp" />
<ClCompile Include="cvfOverlayTextBox.cpp" />
<ClCompile Include="cvfVertexBundle.cpp" />
<ClCompile Include="cvfOverlayItem.cpp" />
<ClCompile Include="cvfRenderStateBlending.cpp" />
<ClCompile Include="cvfRenderStateColorMask.cpp" />
<ClCompile Include="cvfRenderStateCullFace.cpp" />
<ClCompile Include="cvfRenderStateDepth.cpp" />
<ClCompile Include="cvfRenderStateFrontFace.cpp" />
<ClCompile Include="cvfRenderStateLine.cpp" />
<ClCompile Include="cvfRenderStatePoint.cpp" />
<ClCompile Include="cvfRenderStatePolygonMode.cpp" />
<ClCompile Include="cvfRenderStatePolygonOffset.cpp" />
<ClCompile Include="cvfRenderStateTextureBindings.cpp" />
<ClCompile Include="cvfOverlayNavigationCube.cpp" />
<ClCompile Include="cvfRenderStateStencil.cpp" />
<ClCompile Include="cvfOverlayImage.cpp" />
<ClCompile Include="cvfCameraAnimation.cpp" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,24 @@
cmake_minimum_required(VERSION 2.8)
project(LibStructGrid)
# Use our strict compile flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}")
include_directories("../LibCore")
include_directories("../LibGeometry")
include_directories("../LibRender")
include_directories("../LibViewing")
set(CEE_SOURCE_FILES
cvfRectilinearGrid.cpp
cvfStructGridCutPlane.cpp
cvfStructGridGeometry.cpp
cvfStructGridImport.cpp
cvfStructGridIsosurface.cpp
)
add_library(${PROJECT_NAME} ${CEE_SOURCE_FILES})

View File

@ -0,0 +1,259 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug MD TBB|Win32">
<Configuration>Debug MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD TBB|x64">
<Configuration>Debug MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|Win32">
<Configuration>Debug MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|x64">
<Configuration>Debug MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|Win32">
<Configuration>Release MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|x64">
<Configuration>Release MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|Win32">
<Configuration>Release MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|x64">
<Configuration>Release MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C22D8A0D-2318-3353-F75A-E83B82A3B29F}</ProjectGuid>
<RootNamespace>LibStructGrid</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfLibStructGrid.h" />
<ClInclude Include="cvfRectilinearGrid.h" />
<ClInclude Include="cvfStructGridCutPlane.h" />
<ClInclude Include="cvfStructGridGeometry.h" />
<ClInclude Include="cvfStructGridImport.h" />
<ClInclude Include="cvfStructGridIsosurface.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfRectilinearGrid.cpp" />
<ClCompile Include="cvfStructGridCutPlane.cpp" />
<ClCompile Include="cvfStructGridGeometry.cpp" />
<ClCompile Include="cvfStructGridImport.cpp" />
<ClCompile Include="cvfStructGridIsosurface.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,21 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfLibStructGrid.h" />
<ClInclude Include="cvfRectilinearGrid.h" />
<ClInclude Include="cvfStructGridCutPlane.h" />
<ClInclude Include="cvfStructGridGeometry.h" />
<ClInclude Include="cvfStructGridImport.h" />
<ClInclude Include="cvfStructGridIsosurface.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfRectilinearGrid.cpp" />
<ClCompile Include="cvfStructGridCutPlane.cpp" />
<ClCompile Include="cvfStructGridGeometry.cpp" />
<ClCompile Include="cvfStructGridImport.cpp" />
<ClCompile Include="cvfStructGridIsosurface.cpp" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,46 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
// Doxygen module definition
/// \defgroup StructGrid StructGrid module
#include "cvfRectilinearGrid.h"
#include "cvfStructGridCutPlane.h"
#include "cvfStructGridGeometry.h"
#include "cvfStructGridImport.h"
#include "cvfStructGridIsosurface.h"

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,143 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfArray.h"
#include "cvfCollection.h"
namespace cvf {
//==================================================================================================
//
//
//
//==================================================================================================
class RectilinearGrid : public Object
{
public:
enum Face
{
BOTTOM, // -K
TOP, // +K
FRONT, // -J
RIGHT, // +I
BACK, // +J
LEFT // -I
};
public:
RectilinearGrid();
ref<RectilinearGrid> shallowCopy() const;
void allocateGrid(uint numGridPointsI, uint numGridPointsJ, uint numGridPointsK);
uint gridPointCountI() const;
uint gridPointCountJ() const;
uint gridPointCountK() const;
size_t gridPointCount() const;
bool isLegalGridPoint(uint i, uint j, uint k) const;
uint cellCountI() const;
uint cellCountJ() const;
uint cellCountK() const;
size_t cellCount() const;
bool isLegalCell(uint i, uint j, uint k) const;
void setCoordinatesI(const DoubleArray& coords);
void setCoordinatesJ(const DoubleArray& coords);
void setCoordinatesK(const DoubleArray& coords);
void setCoordinatesToRegularGrid(const Vec3d& origo, const Vec3d& spacing);
const DoubleArray& coordinatesI() const;
const DoubleArray& coordinatesJ() const;
const DoubleArray& coordinatesK() const;
Vec3d minCoordinate() const;
Vec3d maxCoordinate() const;
bool cellNeighbor(size_t cellIndex, Face face, size_t* neighborCellIndex) const;
size_t cellIndexFromIJK(uint i, uint j, uint k) const;
bool ijkFromCellIndex(size_t cellIndex, uint* i, uint* j, uint* k) const;
bool cellIJKFromCoordinate(const Vec3d& coord, uint* i, uint* j, uint* k) const;
void cellCornerVertices(size_t cellIndex, Vec3d vertices[8]) const;
static void cellFaceVertexIndices(Face face, ubyte vertexIndices[4]);
Vec3d cellCentroid(size_t cellIndex) const;
void cellMinMaxCordinates(size_t cellIndex, Vec3d* minCoordinate, Vec3d* maxCoordinate) const;
size_t gridPointIndexFromIJK(uint i, uint j, uint k) const;
Vec3d gridPointCoordinate(uint i, uint j, uint k) const;
uint gridPointNeighborCells(uint i, uint j, uint k, size_t neighborCellIndices[8]) const;
// Scalar results
uint addScalarSet(DoubleArray* scalarValues);
uint scalarSetCount() const;
const DoubleArray* scalarSet(uint scalarSetIndex) const;
ref<DoubleArray> computeGridPointScalarSet(uint scalarSetIndex) const;
void setGridPointScalarSet(uint scalarSetIndex, DoubleArray* gridPointScalarValues);
double cellScalar(uint scalarSetIndex, uint i, uint j, uint k) const;
void cellCornerScalars(uint scalarSetIndex, uint i, uint j, uint k, double scalars[8]) const;
double gridPointScalar(uint scalarSetIndex, uint i, uint j, uint k) const;
bool pointScalar(uint scalarSetIndex, const Vec3d& p, double* scalarValue) const;
// Vector results
uint addVectorSet(Vec3dArray* vectorValues);
uint vectorSetCount() const;
const Vec3dArray* vectorSet(uint vectorSetIndex) const;
//void filteredCellCenterResultVectors(Vec3dArray& positions, Vec3dArray& resultVectors, const double minPositionDistance, const double resultVectorLengthThreshold) const;
void filteredCellCenterResultVectors(Vec3dArray& positions, Vec3dArray& resultVectors, uint vectorSetIndex, uint stride, const double resultVectorLengthThreshold) const;
private:
uint m_iCount; // Number of grid points in I direction (number of cells is numGridPoints - 1)
uint m_jCount;
uint m_kCount;
DoubleArray m_iCoordinates; // Grid point coordinates in I direction, one entry per grid point in I direction
DoubleArray m_jCoordinates;
DoubleArray m_kCoordinates;
Collection<DoubleArray> m_scalarSets; // Set of scalar results
Collection<DoubleArray> m_gridPointScalarSets; // Set of scalar results for grid points. Corresponds to the scalarSets
Collection<Vec3dArray> m_vectorSets; // Set of vector results
};
}

View File

@ -0,0 +1,922 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfStructGridCutPlane.h"
#include "cvfRectilinearGrid.h"
#include "cvfGeometryBuilderDrawableGeo.h"
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfDebugTimer.h"
#include "cvfPlane.h"
#include "cvfScalarMapper.h"
#include "cvfEdgeKey.h"
#include "cvfMeshEdgeExtractor.h"
#include <map>
#include <cstring>
namespace cvf {
//==================================================================================================
///
/// \class cvf::StructGridCutPlane
/// \ingroup StructGrid
///
///
///
//==================================================================================================
// Based on description and implementation from Paul Bourke:
// http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/
const uint StructGridCutPlane::sm_edgeTable[256] =
{
0x0 , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c,
0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac,
0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c,
0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc,
0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c,
0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc ,
0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,
0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,
0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,
0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,
0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460,
0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,
0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0,
0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,
0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230,
0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0
};
const int StructGridCutPlane::sm_triTable[256][16] =
{
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1},
{3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1},
{3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1},
{3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1},
{9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
{2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1},
{8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
{4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1},
{3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1},
{1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1},
{4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1},
{4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
{5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1},
{2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1},
{9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
{0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
{2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1},
{10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1},
{5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1},
{5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1},
{9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1},
{1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1},
{10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1},
{8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1},
{2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1},
{7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1},
{2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1},
{11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1},
{5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1},
{11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1},
{11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1},
{9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1},
{2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1},
{6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1},
{3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1},
{6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
{10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1},
{6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1},
{8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1},
{7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1},
{3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1},
{0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1},
{9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1},
{8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1},
{5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1},
{0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1},
{6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1},
{10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1},
{10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1},
{8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1},
{1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1},
{0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1},
{10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1},
{3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1},
{6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1},
{9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1},
{8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1},
{3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1},
{6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1},
{0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1},
{10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1},
{10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1},
{2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1},
{7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1},
{7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1},
{2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1},
{1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1},
{11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1},
{8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1},
{0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1},
{7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
{10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
{2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
{6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1},
{7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1},
{2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1},
{10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1},
{10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1},
{0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1},
{7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1},
{6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1},
{8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1},
{9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1},
{6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1},
{4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1},
{10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1},
{8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1},
{0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1},
{1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1},
{8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1},
{10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1},
{4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1},
{10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
{11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1},
{9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
{6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1},
{7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1},
{3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1},
{7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1},
{3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1},
{6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1},
{9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1},
{1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1},
{4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1},
{7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1},
{6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1},
{3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1},
{0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1},
{6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1},
{0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1},
{11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1},
{6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1},
{5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1},
{9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1},
{1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1},
{1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1},
{10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1},
{0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1},
{5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1},
{10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1},
{11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1},
{9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1},
{7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1},
{2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1},
{8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1},
{9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1},
{9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1},
{1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1},
{9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1},
{5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1},
{0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1},
{10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1},
{2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1},
{0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1},
{0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1},
{9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1},
{5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1},
{3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1},
{5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1},
{8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1},
{0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1},
{9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1},
{1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1},
{3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1},
{4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1},
{9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1},
{11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1},
{11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1},
{2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1},
{9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1},
{3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1},
{1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1},
{4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1},
{3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1},
{0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1},
{1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}
};
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
StructGridCutPlane::StructGridCutPlane(const RectilinearGrid* grid)
: m_grid(grid),
m_mapScalarSetIndex(UNDEFINED_UINT),
m_scalarMapper(NULL),
m_mapNodeAveragedScalars(false),
m_mustRecompute(true)
{
CVF_ASSERT(grid);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
StructGridCutPlane::~StructGridCutPlane()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridCutPlane::setPlane(const Plane& plane)
{
m_plane = plane;
m_mustRecompute = true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridCutPlane::setMapScalar(uint scalarSetIndex, const ScalarMapper* mapper, bool nodeAveragedScalars)
{
CVF_ASSERT(scalarSetIndex < m_grid->scalarSetCount());
CVF_ASSERT(mapper);
m_mapScalarSetIndex = scalarSetIndex;
m_scalarMapper = mapper;
m_mapNodeAveragedScalars = nodeAveragedScalars;
m_mustRecompute = true;
}
//--------------------------------------------------------------------------------------------------
/// Generate cut plane geometry from current configuration
///
/// \return Reference to created DrawableGeo object. Returns NULL if no cut plane was generated
///
/// \todo Remove duplicate nodes from returned geometry
/// Current implementation is not optimized in any way
/// Should set normal from plane normal instead of relying on caller to compute them
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> StructGridCutPlane::generateSurface()
{
if (m_mustRecompute)
{
computeCutPlane();
m_mustRecompute = false;
}
size_t numVertices = m_vertices.size();
size_t numTriangles = m_triangleIndices.size()/3;
if (numVertices == 0 || numTriangles == 0)
{
return NULL;
}
bool doMapScalar = false;
if (m_mapScalarSetIndex != UNDEFINED_UINT && m_scalarMapper.notNull())
{
CVF_ASSERT(numVertices == m_vertexScalars.size());
doMapScalar = true;
}
ref<Vec3fArray> vertexArr = new Vec3fArray(m_vertices);
ref<UIntArray> indices = new UIntArray(m_triangleIndices);
ref<PrimitiveSetIndexedUInt> primSet = new PrimitiveSetIndexedUInt(PT_TRIANGLES);
primSet->setIndices(indices.p());
ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;;
geo->setVertexArray(vertexArr.p());
geo->addPrimitiveSet(primSet.p());
if (doMapScalar)
{
CVF_ASSERT(numVertices == m_vertexScalars.size());
ref<Color3ubArray> vertexColors = new Color3ubArray;
ref<Vec2fArray> textureCoords = new Vec2fArray;
vertexColors->reserve(numVertices);
textureCoords->reserve(numVertices);
size_t i;
for (i = 0; i < numVertices; i++)
{
Color3ub clr = m_scalarMapper->mapToColor(m_vertexScalars[i]);
vertexColors->add(clr);
Vec2f texCoord = m_scalarMapper->mapToTextureCoord(m_vertexScalars[i]);
textureCoords->add(texCoord);
}
geo->setColorArray(vertexColors.p());
geo->setTextureCoordArray(textureCoords.p());
}
//Trace::show("generateSurface(): Vertices:%d TriConns:%d Tris:%d", vertexArr->size(), indices->size(), indices->size()/3);
return geo;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> StructGridCutPlane::generateMesh()
{
if (m_mustRecompute)
{
computeCutPlane();
m_mustRecompute = false;
}
size_t numVertices = m_vertices.size();
size_t numLines = m_meshLineIndices.size()/2;
if (numVertices == 0 || numLines == 0)
{
return NULL;
}
MeshEdgeExtractor ee;
ee.addPrimitives(2, &m_meshLineIndices[0], m_meshLineIndices.size());
ref<UIntArray> indices = ee.lineIndices();
ref<PrimitiveSetIndexedUInt> primSet = new PrimitiveSetIndexedUInt(PT_LINES);
primSet->setIndices(indices.p());
ref<Vec3fArray> vertexArr = new Vec3fArray(m_vertices);
ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;;
geo->setVertexArray(vertexArr.p());
geo->addPrimitiveSet(primSet.p());
//Trace::show("generateMesh(): Vertices:%d LineConns:%d Lines:%d", vertexArr->size(), indices->size(), indices->size()/2);
return geo;
}
//--------------------------------------------------------------------------------------------------
/// Generate surface representation of the specified cut plane
///
/// \note Will compute normals before returning geometry
//--------------------------------------------------------------------------------------------------
void StructGridCutPlane::computeCutPlane()
{
DebugTimer tim("StructGridCutPlane::computeCutPlane", DebugTimer::DISABLED);
bool doMapScalar = false;
if (m_mapScalarSetIndex != UNDEFINED_UINT && m_scalarMapper.notNull())
{
doMapScalar = true;
}
uint cellCountI = m_grid->cellCountI();
uint cellCountJ = m_grid->cellCountJ();
uint cellCountK = m_grid->cellCountK();
// Clear any current data
m_vertices.clear();
m_vertexScalars.clear();
m_triangleIndices.clear();
m_meshLineIndices.clear();
// The indexing conventions for vertices and
// edges used in the algorithm:
// edg verts
// 4-------------5 *------4------* 0 0 - 1
// /| /| /| /| 1 1 - 2
// / | / | 7/ | 5/ | 2 2 - 3
// / | / | |z / 8 / 9 3 3 - 0
// 7-------------6 | | /y *------6------* | 4 4 - 5
// | | | | |/ | | | | 5 5 - 6
// | 0---------|---1 *---x | *------0--|---* 6 6 - 7
// | / | / 11 / 10 / 7 7 - 4
// | / | / | /3 | /1 8 0 - 4
// |/ |/ |/ |/ 9 1 - 5
// 3-------------2 *------2------* 10 2 - 6
// vertex indices edge indices 11 3 - 7
//
uint k;
for (k = 0; k < cellCountK; k++)
{
uint j;
for (j = 0; j < cellCountJ; j++)
{
uint i;
for (i = 0; i < cellCountI; i++)
{
size_t cellIndex = m_grid->cellIndexFromIJK(i, j, k);
Vec3d minCoord;
Vec3d maxCoord;
m_grid->cellMinMaxCordinates(cellIndex, &minCoord, &maxCoord);
// Early reject for cells outside clipping box
if (m_clippingBoundingBox.isValid())
{
BoundingBox cellBB(minCoord, maxCoord);
if (!m_clippingBoundingBox.intersects(cellBB))
{
continue;
}
}
// Check if plane intersects this cell and skip if it doesn't
if (!isCellIntersectedByPlane(m_plane, minCoord, maxCoord))
{
continue;
}
GridCell cell;
bool isClipped = false;
if (m_clippingBoundingBox.isValid())
{
if (!m_clippingBoundingBox.contains(minCoord) || !m_clippingBoundingBox.contains(maxCoord))
{
isClipped = true;
minCoord.x() = CVF_MAX(minCoord.x(), m_clippingBoundingBox.min().x());
minCoord.y() = CVF_MAX(minCoord.y(), m_clippingBoundingBox.min().y());
minCoord.z() = CVF_MAX(minCoord.z(), m_clippingBoundingBox.min().z());
maxCoord.x() = CVF_MIN(maxCoord.x(), m_clippingBoundingBox.max().x());
maxCoord.y() = CVF_MIN(maxCoord.y(), m_clippingBoundingBox.max().y());
maxCoord.z() = CVF_MIN(maxCoord.z(), m_clippingBoundingBox.max().z());
}
}
cell.p[0].set(minCoord.x(), maxCoord.y(), minCoord.z());
cell.p[1].set(maxCoord.x(), maxCoord.y(), minCoord.z());
cell.p[2].set(maxCoord.x(), minCoord.y(), minCoord.z());
cell.p[3].set(minCoord.x(), minCoord.y(), minCoord.z());
cell.p[4].set(minCoord.x(), maxCoord.y(), maxCoord.z());
cell.p[5].set(maxCoord.x(), maxCoord.y(), maxCoord.z());
cell.p[6].set(maxCoord.x(), minCoord.y(), maxCoord.z());
cell.p[7].set(minCoord.x(), minCoord.y(), maxCoord.z());
// Fetch scalar values
double cellScalarValue = 0;
if (doMapScalar)
{
cellScalarValue = m_grid->cellScalar(m_mapScalarSetIndex, i, j, k);
// If we're doing node averaging we must populate grid cell with scalar values interpolated to the grid points
if (m_mapNodeAveragedScalars)
{
if (isClipped)
{
double scalarVal;
if (m_grid->pointScalar(m_mapScalarSetIndex, cell.p[0], &scalarVal)) cell.s[0] = scalarVal;
if (m_grid->pointScalar(m_mapScalarSetIndex, cell.p[1], &scalarVal)) cell.s[1] = scalarVal;
if (m_grid->pointScalar(m_mapScalarSetIndex, cell.p[2], &scalarVal)) cell.s[2] = scalarVal;
if (m_grid->pointScalar(m_mapScalarSetIndex, cell.p[3], &scalarVal)) cell.s[3] = scalarVal;
if (m_grid->pointScalar(m_mapScalarSetIndex, cell.p[4], &scalarVal)) cell.s[4] = scalarVal;
if (m_grid->pointScalar(m_mapScalarSetIndex, cell.p[5], &scalarVal)) cell.s[5] = scalarVal;
if (m_grid->pointScalar(m_mapScalarSetIndex, cell.p[6], &scalarVal)) cell.s[6] = scalarVal;
if (m_grid->pointScalar(m_mapScalarSetIndex, cell.p[7], &scalarVal)) cell.s[7] = scalarVal;
}
else
{
cell.s[0] = m_grid->gridPointScalar(m_mapScalarSetIndex, i, j + 1, k);
cell.s[1] = m_grid->gridPointScalar(m_mapScalarSetIndex, i + 1, j + 1, k);
cell.s[2] = m_grid->gridPointScalar(m_mapScalarSetIndex, i + 1, j, k);
cell.s[3] = m_grid->gridPointScalar(m_mapScalarSetIndex, i, j, k);
cell.s[4] = m_grid->gridPointScalar(m_mapScalarSetIndex, i, j + 1, k + 1);
cell.s[5] = m_grid->gridPointScalar(m_mapScalarSetIndex, i + 1, j + 1, k + 1);
cell.s[6] = m_grid->gridPointScalar(m_mapScalarSetIndex, i + 1, j, k + 1);
cell.s[7] = m_grid->gridPointScalar(m_mapScalarSetIndex, i, j, k + 1);
}
}
}
Triangles triangles;
uint numTriangles = polygonise(m_plane, cell, &triangles);
if (numTriangles > 0)
{
// Add all the referenced vertices
// At the same time registering their index in the 'global' vertex list
uint globalVertexIndices[12];
int iv;
for (iv = 0; iv < 12; iv++)
{
if (triangles.usedVertices[iv])
{
globalVertexIndices[iv] = static_cast<uint>(m_vertices.size());
m_vertices.push_back(Vec3f(triangles.vertices[iv]));
if (doMapScalar)
{
if (m_mapNodeAveragedScalars)
{
m_vertexScalars.push_back(triangles.scalars[iv]);
}
else
{
m_vertexScalars.push_back(cellScalarValue);
}
}
}
else
{
globalVertexIndices[iv] = UNDEFINED_UINT;
}
}
// Build triangles from the cell
const size_t prevNumTriangleIndices = m_triangleIndices.size();
uint t;
for (t = 0; t < numTriangles; t++)
{
m_triangleIndices.push_back(globalVertexIndices[triangles.triangleIndices[3*t]]);
m_triangleIndices.push_back(globalVertexIndices[triangles.triangleIndices[3*t + 1]]);
m_triangleIndices.push_back(globalVertexIndices[triangles.triangleIndices[3*t + 2]]);
}
// Add mesh line indices
addMeshLineIndices(&m_triangleIndices[prevNumTriangleIndices], numTriangles);
}
}
}
}
//Trace::show("Vertices:%d TriConns:%d Tris:%d", m_vertices.size(), m_triangleIndices.size(), m_triangleIndices.size()/3);
tim.reportTimeMS();
}
//--------------------------------------------------------------------------------------------------
/// Add mesh line indices by analyzing the triangle indices and only adding 'unique' edges
//--------------------------------------------------------------------------------------------------
void StructGridCutPlane::addMeshLineIndices(const uint* triangleIndices, uint triangleCount)
{
std::vector<int64> edges;
edges.reserve(3*triangleCount);
std::vector<int64>::iterator it;
uint t;
for (t = 0; t < triangleCount; t++)
{
uint i;
for (i = 0; i < 3; i++)
{
const uint vertexIdx1 = triangleIndices[3*t + i];
const uint vertexIdx2 = (i < 2) ? triangleIndices[3*t + i + 1] : triangleIndices[3*t];
int64 edgeKeyVal = EdgeKey(vertexIdx1, vertexIdx2).toKeyVal();
it = find(edges.begin(), edges.end(), edgeKeyVal);
if (it == edges.end())
{
edges.push_back(edgeKeyVal);
}
else
{
edges.erase(it);
}
}
}
for (it = edges.begin(); it != edges.end(); ++it)
{
EdgeKey ek = EdgeKey::fromkeyVal(*it);
m_meshLineIndices.push_back(ek.index1());
m_meshLineIndices.push_back(ek.index2());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
uint StructGridCutPlane::polygonise(const Plane& plane, const GridCell& cell, Triangles* triangles)
{
int cubeindex = 0;
if (plane.distanceSquared(cell.p[0]) < 0) cubeindex |= 1;
if (plane.distanceSquared(cell.p[1]) < 0) cubeindex |= 2;
if (plane.distanceSquared(cell.p[2]) < 0) cubeindex |= 4;
if (plane.distanceSquared(cell.p[3]) < 0) cubeindex |= 8;
if (plane.distanceSquared(cell.p[4]) < 0) cubeindex |= 16;
if (plane.distanceSquared(cell.p[5]) < 0) cubeindex |= 32;
if (plane.distanceSquared(cell.p[6]) < 0) cubeindex |= 64;
if (plane.distanceSquared(cell.p[7]) < 0) cubeindex |= 128;
if (sm_edgeTable[cubeindex] == 0)
{
return 0;
}
// Compute vertex coordinates on the edges where we have intersections
if (sm_edgeTable[cubeindex] & 1) triangles->vertices[0] = planeLineIntersection(plane, cell.p[0], cell.p[1], cell.s[0], cell.s[1], &triangles->scalars[0] );
if (sm_edgeTable[cubeindex] & 2) triangles->vertices[1] = planeLineIntersection(plane, cell.p[1], cell.p[2], cell.s[1], cell.s[2], &triangles->scalars[1] );
if (sm_edgeTable[cubeindex] & 4) triangles->vertices[2] = planeLineIntersection(plane, cell.p[2], cell.p[3], cell.s[2], cell.s[3], &triangles->scalars[2] );
if (sm_edgeTable[cubeindex] & 8) triangles->vertices[3] = planeLineIntersection(plane, cell.p[3], cell.p[0], cell.s[3], cell.s[0], &triangles->scalars[3] );
if (sm_edgeTable[cubeindex] & 16) triangles->vertices[4] = planeLineIntersection(plane, cell.p[4], cell.p[5], cell.s[4], cell.s[5], &triangles->scalars[4] );
if (sm_edgeTable[cubeindex] & 32) triangles->vertices[5] = planeLineIntersection(plane, cell.p[5], cell.p[6], cell.s[5], cell.s[6], &triangles->scalars[5] );
if (sm_edgeTable[cubeindex] & 64) triangles->vertices[6] = planeLineIntersection(plane, cell.p[6], cell.p[7], cell.s[6], cell.s[7], &triangles->scalars[6] );
if (sm_edgeTable[cubeindex] & 128) triangles->vertices[7] = planeLineIntersection(plane, cell.p[7], cell.p[4], cell.s[7], cell.s[4], &triangles->scalars[7] );
if (sm_edgeTable[cubeindex] & 256) triangles->vertices[8] = planeLineIntersection(plane, cell.p[0], cell.p[4], cell.s[0], cell.s[4], &triangles->scalars[8] );
if (sm_edgeTable[cubeindex] & 512) triangles->vertices[9] = planeLineIntersection(plane, cell.p[1], cell.p[5], cell.s[1], cell.s[5], &triangles->scalars[9] );
if (sm_edgeTable[cubeindex] & 1024) triangles->vertices[10] = planeLineIntersection(plane, cell.p[2], cell.p[6], cell.s[2], cell.s[6], &triangles->scalars[10]);
if (sm_edgeTable[cubeindex] & 2048) triangles->vertices[11] = planeLineIntersection(plane, cell.p[3], cell.p[7], cell.s[3], cell.s[7], &triangles->scalars[11]);
// Create the triangles
memset(triangles->usedVertices, 0, sizeof(triangles->usedVertices));
const int* triConnects = sm_triTable[cubeindex];
uint n = 0;
while (triConnects[n] != -1)
{
triangles->triangleIndices[n] = triConnects[n];
triangles->usedVertices[triConnects[n]] = true;
n++;
}
uint numTriangles = n/3;
return numTriangles;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Vec3d StructGridCutPlane::planeLineIntersection(const Plane& plane, const Vec3d& p1, const Vec3d& p2, const double s1, const double s2, double* s)
{
// From http://local.wasp.uwa.edu.au/~pbourke/geometry/planeline/
//
// P1 (x1,y1,z1) and P2 (x2,y2,z2)
//
// P = P1 + u (P2 - P1)
//
// A*x1 + B*y1 + C*z1 + D
// u = ---------------------------------
// A*(x1-x2) + B*(y1-y2) + C*(z1-z2)
CVF_ASSERT(s);
const Vec3d v = p2 - p1;
double denominator = -(plane.A()*v.x() + plane.B()*v.y() + plane.C()*v.z());
if (denominator != 0)
{
double u = (plane.A()*p1.x() + plane.B()*p1.y() + plane.C()*p1.z() + plane.D())/denominator;
if (u > 0.0 && u < 1.0)
{
*s = s1 + u*(s2 - s1);
return (p1 + u*v);
}
else
{
if (u >= 1.0)
{
*s = s2;
return p2;
}
else
{
*s = s1;
return p1;
}
}
}
else
{
*s = s1;
return p1;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool StructGridCutPlane::isCellIntersectedByPlane(const Plane& plane, const Vec3d& cellMinCoord, const Vec3d& cellMaxCoord)
{
// See http://zach.in.tu-clausthal.de/teaching/cg_literatur/lighthouse3d_view_frustum_culling/index.html
// Start by finding the "positive vertex" and the "negative vertex" relative to plane normal
Vec3d pVertex(cellMinCoord);
Vec3d nVertex(cellMaxCoord);
if (plane.A() >= 0)
{
pVertex.x() = cellMaxCoord.x();
nVertex.x() = cellMinCoord.x();
}
if (plane.B() >= 0)
{
pVertex.y() = cellMaxCoord.y();
nVertex.y() = cellMinCoord.y();
}
if (plane.C() >= 0)
{
pVertex.z() = cellMaxCoord.z();
nVertex.z() = cellMinCoord.z();
}
// Chek if both positive and negative vertex are on same side of plane
if (plane.distanceSquared(pVertex) < 0)
{
if (plane.distanceSquared(nVertex) < 0)
{
return false;
}
else
{
return true;
}
}
else
{
if (plane.distanceSquared(nVertex) >= 0)
{
return false;
}
else
{
return true;
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridCutPlane::setClippingBoundingBox(const BoundingBox& boundingBox)
{
m_clippingBoundingBox = boundingBox;
}
} // namespace cvf

View File

@ -0,0 +1,111 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfPlane.h"
#include "cvfBoundingBox.h"
#include <vector>
namespace cvf {
class DrawableGeo;
class RectilinearGrid;
class ScalarMapper;
//==================================================================================================
//
//
//
//==================================================================================================
class StructGridCutPlane : public Object
{
public:
StructGridCutPlane(const RectilinearGrid* grid);
~StructGridCutPlane();
void setPlane(const Plane& plane);
void setClippingBoundingBox(const BoundingBox& boundingBox);
void setMapScalar(uint scalarSetIndex, const ScalarMapper* mapper, bool nodeAveragedScalars);
ref<DrawableGeo> generateSurface();
ref<DrawableGeo> generateMesh();
private:
struct GridCell
{
Vec3d p[8]; // Cell's corner coordinates
double s[8]; // Scalar values in cell corners
};
struct Triangles
{
Vec3d vertices[12]; // The vertices, one on each edge in the cell
double scalars[12]; // Interpolated scalar values for the vertices
bool usedVertices[12]; // Flag to indicate which of the vertices (and scalars) are being referenced by the triangle indices
int triangleIndices[15];// Triangle indices (into vertices), max 5 triangles.
};
private:
void computeCutPlane();
void addMeshLineIndices(const uint* triangleIndices, uint triangleCount);
static uint polygonise(const Plane& plane, const GridCell& cell, Triangles* triangles);
static Vec3d planeLineIntersection(const Plane& plane, const Vec3d& p1, const Vec3d& p2, const double s1, const double s2, double* s);
static bool isCellIntersectedByPlane(const Plane& plane, const Vec3d& cellMinCoord, const Vec3d& cellMaxCoord);
private:
cref<RectilinearGrid> m_grid;
Plane m_plane;
BoundingBox m_clippingBoundingBox;
uint m_mapScalarSetIndex; // Index of scalar set that should be mapped onto the cut plane. -1 for no mapping
cref<ScalarMapper> m_scalarMapper; // Scalar mapper to use when mapping. Both scalar set index and mapper must be set in order to get scalar mapping
bool m_mapNodeAveragedScalars; // If true we'll compute node averaged scalars before mapping them on the cut plane. If false per cell scalars will be mapped.
bool m_mustRecompute; // Flag to indicate that cut plane must be recomputed
std::vector<Vec3f> m_vertices; // Vertices of computed surface
std::vector<double> m_vertexScalars; // Scalar values for vertices
std::vector<uint> m_triangleIndices; // Triangle connectivities
std::vector<uint> m_meshLineIndices; // Mesh line connectivities
static const uint sm_edgeTable[256];
static const int sm_triTable[256][16];
};
}

View File

@ -0,0 +1,528 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfStructGridGeometry.h"
#include "cvfRectilinearGrid.h"
#include "cvfDebugTimer.h"
#include "cvfGeometryBuilderDrawableGeo.h"
#include "cvfPrimitiveSetIndexedUInt.h"
#include "cvfScalarMapper.h"
namespace cvf {
//==================================================================================================
///
/// \class cvf::StructGridGeometry
/// \ingroup StructGrid
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
StructGridGeometry::StructGridGeometry(const RectilinearGrid* grid)
: m_grid(grid),
m_cellMinI(UNDEFINED_UINT),
m_cellMinJ(UNDEFINED_UINT),
m_cellMinK(UNDEFINED_UINT),
m_cellMaxI(UNDEFINED_UINT),
m_cellMaxJ(UNDEFINED_UINT),
m_cellMaxK(UNDEFINED_UINT),
m_scalarSetIndex(UNDEFINED_UINT),
m_mapNodeAveragedScalars(false)
{
CVF_ASSERT(grid);
setCellRegionFullGrid();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
StructGridGeometry::~StructGridGeometry()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridGeometry::setCellRegion(uint minI, uint minJ, uint minK, uint maxI, uint maxJ, uint maxK)
{
m_cellMinI = minI;
m_cellMinJ = minJ;
m_cellMinK = minK;
m_cellMaxI = maxI;
m_cellMaxJ = maxJ;
m_cellMaxK = maxK;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridGeometry::setCellRegionSlabI(uint i)
{
setCellRegionFullGrid();
m_cellMinI = i;
m_cellMaxI = i;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridGeometry::setCellRegionSlabJ(uint j)
{
setCellRegionFullGrid();
m_cellMinJ = j;
m_cellMaxJ = j;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridGeometry::setCellRegionSlabK(uint k)
{
setCellRegionFullGrid();
m_cellMinK = k;
m_cellMaxK = k;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridGeometry::setCellRegionFullGrid()
{
uint cellCountI = m_grid->cellCountI();
uint cellCountJ = m_grid->cellCountJ();
uint cellCountK = m_grid->cellCountK();
if (cellCountI >= 1 && cellCountJ >= 1 && cellCountK >= 1)
{
m_cellMinI = 0;
m_cellMinJ = 0;
m_cellMinK = 0;
m_cellMaxI = cellCountI - 1;
m_cellMaxJ = cellCountJ - 1;
m_cellMaxK = cellCountK - 1;
}
else
{
resetCellRegion();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool StructGridGeometry::isCellRegionValid() const
{
if (m_cellMinI == UNDEFINED_UINT || m_cellMinJ == UNDEFINED_UINT || m_cellMinK == UNDEFINED_UINT) return false;
if (m_cellMaxI == UNDEFINED_UINT || m_cellMaxJ == UNDEFINED_UINT || m_cellMaxK == UNDEFINED_UINT) return false;
if (m_cellMaxI < m_cellMinI) return false;
if (m_cellMaxJ < m_cellMinJ) return false;
if (m_cellMaxK < m_cellMinK) return false;
uint cellCountI = m_grid->cellCountI();
uint cellCountJ = m_grid->cellCountJ();
uint cellCountK = m_grid->cellCountK();
if (m_cellMaxI >= cellCountI) return false;
if (m_cellMaxJ >= cellCountJ) return false;
if (m_cellMaxK >= cellCountK) return false;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridGeometry::resetCellRegion()
{
m_cellMinI = UNDEFINED_UINT;
m_cellMinJ = UNDEFINED_UINT;
m_cellMinK = UNDEFINED_UINT;
m_cellMaxI = UNDEFINED_UINT;
m_cellMaxJ = UNDEFINED_UINT;
m_cellMaxK = UNDEFINED_UINT;
}
//--------------------------------------------------------------------------------------------------
/// Configure scalar field that should be mapped onto the surface
///
/// \param scalarSetIndex Index of the cell scalar set that should be mapped
/// \param mapper Mapper to use
/// \param nodeAveragedScalars If true, node averaged scalar values will be computed based on the cell
/// scalar set and these values will be mapped onto the surface.
//--------------------------------------------------------------------------------------------------
void StructGridGeometry::setMapScalar(uint scalarSetIndex, const ScalarMapper* mapper, bool nodeAveragedScalars)
{
CVF_ASSERT(scalarSetIndex < m_grid->scalarSetCount());
CVF_ASSERT(mapper);
m_scalarSetIndex = scalarSetIndex;
m_scalarMapper = mapper;
m_mapNodeAveragedScalars = nodeAveragedScalars;
}
//--------------------------------------------------------------------------------------------------
/// Generate surface drawable geo from the specified region
///
/// If a map scalar has been set, the returned drawable will have both colors and texture coordinates
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> StructGridGeometry::generateSurface() const
{
//DebugTimer tim("StructGridGeometry::generateSurface()");
if (!isCellRegionValid())
{
return NULL;
}
uint numCellsI = (m_cellMaxI - m_cellMinI) + 1;
uint numCellsJ = (m_cellMaxJ - m_cellMinJ) + 1;
uint numCellsK = (m_cellMaxK - m_cellMinK) + 1;
uint numQuads = 2*numCellsI*numCellsJ + 2*numCellsI*numCellsK + 2*numCellsJ*numCellsK;
uint numVerts = 4*numQuads;
ref<Vec3fArray> vertices = new Vec3fArray;
vertices->reserve(numVerts);
bool doMapScalar = false;
ref<Vec2fArray> textureCoordArray;
ref<Color3ubArray> colorArray;
if (m_scalarSetIndex != UNDEFINED_UINT && m_scalarMapper.notNull())
{
textureCoordArray = new Vec2fArray;
textureCoordArray->reserve(numVerts);
colorArray = new Color3ubArray;
colorArray->reserve(numVerts);
doMapScalar = true;
}
ubyte connBottom[4];
ubyte connTop[4];
ubyte connFront[4];
ubyte connRight[4];
ubyte connBack[4];
ubyte connLeft[4];
m_grid->cellFaceVertexIndices(RectilinearGrid::BOTTOM, connBottom);
m_grid->cellFaceVertexIndices(RectilinearGrid::TOP, connTop);
m_grid->cellFaceVertexIndices(RectilinearGrid::FRONT, connFront);
m_grid->cellFaceVertexIndices(RectilinearGrid::RIGHT, connRight);
m_grid->cellFaceVertexIndices(RectilinearGrid::BACK, connBack);
m_grid->cellFaceVertexIndices(RectilinearGrid::LEFT, connLeft);
uint k;
for (k = m_cellMinK; k <= m_cellMaxK; k++)
{
uint j;
for (j = m_cellMinJ; j <= m_cellMaxJ; j++)
{
uint i;
for (i = m_cellMinI; i <= m_cellMaxI; i++)
{
// Only consider cells at the edges of the region
if (k == m_cellMinK || k == m_cellMaxK ||
j == m_cellMinJ || j == m_cellMaxJ ||
i == m_cellMinI || i == m_cellMaxI)
{
// Count number of visible faces in this cell and add pointer to the face's local connectivity table
uint numVisibleFaces = 0;
const ubyte* visibleFacesConnects[6];
if (k == m_cellMinK) visibleFacesConnects[numVisibleFaces++] = connBottom;
if (k == m_cellMaxK) visibleFacesConnects[numVisibleFaces++] = connTop;
if (j == m_cellMinJ) visibleFacesConnects[numVisibleFaces++] = connFront;
if (j == m_cellMaxJ) visibleFacesConnects[numVisibleFaces++] = connBack;
if (i == m_cellMinI) visibleFacesConnects[numVisibleFaces++] = connLeft;
if (i == m_cellMaxI) visibleFacesConnects[numVisibleFaces++] = connRight;
CVF_TIGHT_ASSERT(numVisibleFaces > 0);
size_t cellIndex = m_grid->cellIndexFromIJK(i, j, k);
Vec3d cornerVerts[8];
m_grid->cellCornerVertices(cellIndex, cornerVerts);
double cornerScalars[8];
if (doMapScalar)
{
if (m_mapNodeAveragedScalars)
{
m_grid->cellCornerScalars(m_scalarSetIndex, i, j, k, cornerScalars);
}
else
{
// When not doing node averaging, just use the the cell center scalar value for all corners
// Not very elegant, nor optimal with regards to performance, but keeps the code simple
double cellScalarValue = m_grid->cellScalar(m_scalarSetIndex, i, j, k);
int n;
for (n = 0; n < 8; n++)
{
cornerScalars[n] = cellScalarValue;
}
}
}
uint face;
for (face = 0; face < numVisibleFaces; face++)
{
const ubyte* faceConn = visibleFacesConnects[face];
int n;
for (n = 0; n < 4; n++)
{
vertices->add(Vec3f(cornerVerts[faceConn[n]]));
if (doMapScalar)
{
textureCoordArray->add(m_scalarMapper->mapToTextureCoord(cornerScalars[faceConn[n]]));
colorArray->add(m_scalarMapper->mapToColor(cornerScalars[faceConn[n]]));
}
}
}
}
}
}
}
ref<DrawableGeo> geo = new DrawableGeo;
geo->setFromQuadVertexArray(vertices.p());
if (doMapScalar)
{
CVF_ASSERT(colorArray.notNull());
CVF_ASSERT(textureCoordArray.notNull());
CVF_ASSERT(colorArray->size() == vertices->size());
CVF_ASSERT(textureCoordArray->size() == vertices->size());
geo->setColorArray(colorArray.p());
geo->setTextureCoordArray(textureCoordArray.p());
}
//Trace::show("StructGridGeometry::generateSurface() #verts=%d #quads=%d", vertices->size(), vertices->size()/4);
//tim.reportTimeMS();
return geo;
}
//--------------------------------------------------------------------------------------------------
/// Generates simplified mesh as line drawing
///
/// This function does not generate all the nodes on the surface of the grid. Nodes are only
/// generated on the edges of the structured grid
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> StructGridGeometry::generateSimplifiedMeshLines() const
{
if (!isCellRegionValid())
{
return NULL;
}
uint numCellsI = (m_cellMaxI - m_cellMinI) + 1;
uint numCellsJ = (m_cellMaxJ - m_cellMinJ) + 1;
uint numCellsK = (m_cellMaxK - m_cellMinK) + 1;
uint numLines = 4*(numCellsI + 1) + 4*(numCellsJ + 1) + 4*(numCellsK + 1);
uint numVerts = numLines;
Vec3d min = m_grid->gridPointCoordinate(m_cellMinI, m_cellMinJ, m_cellMinK);
Vec3d max = m_grid->gridPointCoordinate(m_cellMaxI + 1, m_cellMaxJ + 1, m_cellMaxK + 1);
ref<Vec3fArray> vertices = new Vec3fArray;
vertices->reserve(numVerts);
ref<UIntArray> indices = new UIntArray;
indices->reserve(2*numLines);
uint i;
for (i = m_cellMinI; i <= m_cellMaxI + 1; i++)
{
uint baseIdx = static_cast<uint>(vertices->size());
double coordX = m_grid->coordinatesI()[i];
Vec3d v1(coordX, min.y(), min.z());
Vec3d v2(coordX, max.y(), min.z());
Vec3d v3(coordX, max.y(), max.z());
Vec3d v4(coordX, min.y(), max.z());
vertices->add(Vec3f(v1));
vertices->add(Vec3f(v2));
vertices->add(Vec3f(v3));
vertices->add(Vec3f(v4));
indices->add(baseIdx);
indices->add(baseIdx + 1);
indices->add(baseIdx + 1);
indices->add(baseIdx + 2);
indices->add(baseIdx + 2);
indices->add(baseIdx + 3);
indices->add(baseIdx + 3);
indices->add(baseIdx);
}
uint j;
for (j = m_cellMinJ; j <= m_cellMaxJ + 1; j++)
{
uint baseIdx = static_cast<uint>(vertices->size());
double coordY = m_grid->coordinatesJ()[j];
Vec3d v1(min.x(), coordY, min.z());
Vec3d v2(max.x(), coordY, min.z());
Vec3d v3(max.x(), coordY, max.z());
Vec3d v4(min.x(), coordY, max.z());
vertices->add(Vec3f(v1));
vertices->add(Vec3f(v2));
vertices->add(Vec3f(v3));
vertices->add(Vec3f(v4));
indices->add(baseIdx);
indices->add(baseIdx + 1);
indices->add(baseIdx + 1);
indices->add(baseIdx + 2);
indices->add(baseIdx + 2);
indices->add(baseIdx + 3);
indices->add(baseIdx + 3);
indices->add(baseIdx);
}
uint k;
for (k = m_cellMinK; k <= m_cellMaxK + 1; k++)
{
uint baseIdx = static_cast<uint>(vertices->size());
double coordZ = m_grid->coordinatesK()[k];
Vec3d v1(min.x(), min.y(), coordZ);
Vec3d v2(max.x(), min.y(), coordZ);
Vec3d v3(max.x(), max.y(), coordZ);
Vec3d v4(min.x(), max.y(), coordZ);
vertices->add(Vec3f(v1));
vertices->add(Vec3f(v2));
vertices->add(Vec3f(v3));
vertices->add(Vec3f(v4));
indices->add(baseIdx);
indices->add(baseIdx + 1);
indices->add(baseIdx + 1);
indices->add(baseIdx + 2);
indices->add(baseIdx + 2);
indices->add(baseIdx + 3);
indices->add(baseIdx + 3);
indices->add(baseIdx);
}
ref<DrawableGeo> geo = new DrawableGeo;
geo->setVertexArray(vertices.p());
ref<PrimitiveSetIndexedUInt> primSet = new PrimitiveSetIndexedUInt(PT_LINES);
primSet->setIndices(indices.p());
geo->addPrimitiveSet(primSet.p());
return geo;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> StructGridGeometry::generateOutline() const
{
if (!isCellRegionValid())
{
return NULL;
}
Vec3f min(m_grid->minCoordinate());
Vec3f max(m_grid->maxCoordinate());
ref<Vec3fArray> verts = new Vec3fArray;
verts->reserve(8);
verts->add(Vec3f(min.x(), min.y(), min.z()));
verts->add(Vec3f(max.x(), min.y(), min.z()));
verts->add(Vec3f(max.x(), max.y(), min.z()));
verts->add(Vec3f(min.x(), max.y(), min.z()));
verts->add(Vec3f(min.x(), min.y(), max.z()));
verts->add(Vec3f(max.x(), min.y(), max.z()));
verts->add(Vec3f(max.x(), max.y(), max.z()));
verts->add(Vec3f(min.x(), max.y(), max.z()));
ref<UIntArray> indices = new UIntArray;
indices->reserve(24);
indices->add(0); indices->add(1);
indices->add(1); indices->add(2);
indices->add(2); indices->add(3);
indices->add(3); indices->add(0);
indices->add(4); indices->add(5);
indices->add(5); indices->add(6);
indices->add(6); indices->add(7);
indices->add(7); indices->add(4);
indices->add(0); indices->add(4);
indices->add(1); indices->add(5);
indices->add(2); indices->add(6);
indices->add(3); indices->add(7);
ref<PrimitiveSetIndexedUInt> ps = new PrimitiveSetIndexedUInt(PT_LINES);
ps->setIndices(indices.p());
ref<DrawableGeo> geo = new DrawableGeo;
geo->setVertexArray(verts.p());
geo->addPrimitiveSet(ps.p());
return geo;
}
} // namespace cvf

View File

@ -0,0 +1,88 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
namespace cvf {
class RectilinearGrid;
class DrawableGeo;
class ScalarMapper;
//==================================================================================================
//
//
//
//==================================================================================================
class StructGridGeometry : public Object
{
public:
StructGridGeometry(const RectilinearGrid* grid);
~StructGridGeometry();
void setCellRegion(uint minI, uint minJ, uint minK, uint maxI, uint maxJ, uint maxK);
void setCellRegionFullGrid();
void setCellRegionSlabI(uint i);
void setCellRegionSlabJ(uint j);
void setCellRegionSlabK(uint k);
bool isCellRegionValid() const;
void resetCellRegion();
void setMapScalar(uint scalarSetIndex, const ScalarMapper* mapper, bool nodeAveragedScalars);
ref<DrawableGeo> generateSurface() const;
ref<DrawableGeo> generateSimplifiedMeshLines() const;
ref<DrawableGeo> generateOutline() const;
private:
cref<RectilinearGrid> m_grid; // The grid being processed
uint m_cellMinI; // Minimum cell in region
uint m_cellMinJ; //
uint m_cellMinK; //
uint m_cellMaxI; // Max cell in region
uint m_cellMaxJ; //
uint m_cellMaxK; //
uint m_scalarSetIndex; // Index of scalar set that should be mapped onto the cut plane. UNDEFINED_UINT for no mapping
cref<ScalarMapper> m_scalarMapper; // Scalar mapper to use when mapping. Both scalar set index and mapper must be set in order to get scalar mapping
bool m_mapNodeAveragedScalars; // If true we'll compute node averaged scalars before mapping them on the surface. If false per cell scalars will be mapped.
};
}

View File

@ -0,0 +1,127 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfString.h"
#include "cvfTrace.h"
#include "cvfStructGridImport.h"
#include <stdio.h>
namespace cvf {
//==================================================================================================
///
/// \class cvf::StructGridImport
/// \ingroup StructGrid
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool StructGridImport::import(const cvf::String& filename, DataType dataType, uint countI, uint countJ, uint countK, cvf::DoubleArray* dataset)
{
if (!dataset) return false;
size_t numValues = countI * countJ * countK;
dataset->resize(numValues);
#ifdef WIN32
FILE* stream = NULL;
errno_t err = fopen_s(&stream, filename.toUtf8().ptr(), "rb");
if (err != 0 || !stream) return false;
#else
FILE* stream = fopen(filename.toUtf8().ptr(), "rb");
if (!stream) return false;
#endif
Trace::show("Successfully opened " + filename);
Trace::show("Starting to read %d", numValues);
if (dataType == UBYTE)
{
UByteArray buffer;
buffer.resize(numValues);
size_t numRead = fread(buffer.ptr(), sizeof(ubyte), numValues, stream);
if (numRead != numValues)
{
fclose(stream);
return false;
}
size_t i;
for (i = 0; i < numValues; i++)
{
dataset->set(i, buffer[i]);
}
}
else if (dataType == USHORT)
{
UShortArray buffer;
buffer.resize(numValues);
size_t numRead = fread(buffer.ptr(), sizeof(ushort), numValues, stream);
if (numRead != numValues)
{
fclose(stream);
return false;
}
size_t i;
for (i = 0; i < numValues; i++)
{
dataset->set(i, buffer[i]);
}
}
fclose(stream);
Trace::show("Compleated reading data");
return true;
}
} // namespace cvf

View File

@ -0,0 +1,62 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfArray.h"
namespace cvf {
//==================================================================================================
//
//
//
//==================================================================================================
class StructGridImport
{
public:
enum DataType
{
UBYTE, ///< Byte
USHORT ///< Short
};
static bool import(const cvf::String& filename, DataType dataType, uint countI, uint countJ, uint countK, cvf::DoubleArray* dataset);
};
}

View File

@ -0,0 +1,974 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfStructGridIsosurface.h"
#include "cvfGeometryBuilderDrawableGeo.h"
#include "cvfPrimitiveSetIndexedUShort.h"
#include "cvfDebugTimer.h"
#include "cvfPlane.h"
#include "cvfScalarMapper.h"
#include "cvfRectilinearGrid.h"
#include <map>
namespace cvf {
//==================================================================================================
///
/// \class cvf::StructGridIsosurface
/// \ingroup StructGrid
///
///
///
//==================================================================================================
// Based on description and implementation from Paul Bourke:
// http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/
const uint StructGridIsosurface::sm_edgeTable[256] =
{
0x0 , 0x109, 0x203, 0x30a, 0x406, 0x50f, 0x605, 0x70c,
0x80c, 0x905, 0xa0f, 0xb06, 0xc0a, 0xd03, 0xe09, 0xf00,
0x190, 0x99 , 0x393, 0x29a, 0x596, 0x49f, 0x795, 0x69c,
0x99c, 0x895, 0xb9f, 0xa96, 0xd9a, 0xc93, 0xf99, 0xe90,
0x230, 0x339, 0x33 , 0x13a, 0x636, 0x73f, 0x435, 0x53c,
0xa3c, 0xb35, 0x83f, 0x936, 0xe3a, 0xf33, 0xc39, 0xd30,
0x3a0, 0x2a9, 0x1a3, 0xaa , 0x7a6, 0x6af, 0x5a5, 0x4ac,
0xbac, 0xaa5, 0x9af, 0x8a6, 0xfaa, 0xea3, 0xda9, 0xca0,
0x460, 0x569, 0x663, 0x76a, 0x66 , 0x16f, 0x265, 0x36c,
0xc6c, 0xd65, 0xe6f, 0xf66, 0x86a, 0x963, 0xa69, 0xb60,
0x5f0, 0x4f9, 0x7f3, 0x6fa, 0x1f6, 0xff , 0x3f5, 0x2fc,
0xdfc, 0xcf5, 0xfff, 0xef6, 0x9fa, 0x8f3, 0xbf9, 0xaf0,
0x650, 0x759, 0x453, 0x55a, 0x256, 0x35f, 0x55 , 0x15c,
0xe5c, 0xf55, 0xc5f, 0xd56, 0xa5a, 0xb53, 0x859, 0x950,
0x7c0, 0x6c9, 0x5c3, 0x4ca, 0x3c6, 0x2cf, 0x1c5, 0xcc ,
0xfcc, 0xec5, 0xdcf, 0xcc6, 0xbca, 0xac3, 0x9c9, 0x8c0,
0x8c0, 0x9c9, 0xac3, 0xbca, 0xcc6, 0xdcf, 0xec5, 0xfcc,
0xcc , 0x1c5, 0x2cf, 0x3c6, 0x4ca, 0x5c3, 0x6c9, 0x7c0,
0x950, 0x859, 0xb53, 0xa5a, 0xd56, 0xc5f, 0xf55, 0xe5c,
0x15c, 0x55 , 0x35f, 0x256, 0x55a, 0x453, 0x759, 0x650,
0xaf0, 0xbf9, 0x8f3, 0x9fa, 0xef6, 0xfff, 0xcf5, 0xdfc,
0x2fc, 0x3f5, 0xff , 0x1f6, 0x6fa, 0x7f3, 0x4f9, 0x5f0,
0xb60, 0xa69, 0x963, 0x86a, 0xf66, 0xe6f, 0xd65, 0xc6c,
0x36c, 0x265, 0x16f, 0x66 , 0x76a, 0x663, 0x569, 0x460,
0xca0, 0xda9, 0xea3, 0xfaa, 0x8a6, 0x9af, 0xaa5, 0xbac,
0x4ac, 0x5a5, 0x6af, 0x7a6, 0xaa , 0x1a3, 0x2a9, 0x3a0,
0xd30, 0xc39, 0xf33, 0xe3a, 0x936, 0x83f, 0xb35, 0xa3c,
0x53c, 0x435, 0x73f, 0x636, 0x13a, 0x33 , 0x339, 0x230,
0xe90, 0xf99, 0xc93, 0xd9a, 0xa96, 0xb9f, 0x895, 0x99c,
0x69c, 0x795, 0x49f, 0x596, 0x29a, 0x393, 0x99 , 0x190,
0xf00, 0xe09, 0xd03, 0xc0a, 0xb06, 0xa0f, 0x905, 0x80c,
0x70c, 0x605, 0x50f, 0x406, 0x30a, 0x203, 0x109, 0x0
};
const int StructGridIsosurface::sm_triTable[256][16] =
{
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 8, 3, 9, 8, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 2, 10, 0, 2, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 8, 3, 2, 10, 8, 10, 9, 8, -1, -1, -1, -1, -1, -1, -1},
{3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 11, 2, 8, 11, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 11, 2, 1, 9, 11, 9, 8, 11, -1, -1, -1, -1, -1, -1, -1},
{3, 10, 1, 11, 10, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 10, 1, 0, 8, 10, 8, 11, 10, -1, -1, -1, -1, -1, -1, -1},
{3, 9, 0, 3, 11, 9, 11, 10, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 3, 0, 7, 3, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 1, 9, 4, 7, 1, 7, 3, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 4, 7, 3, 0, 4, 1, 2, 10, -1, -1, -1, -1, -1, -1, -1},
{9, 2, 10, 9, 0, 2, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
{2, 10, 9, 2, 9, 7, 2, 7, 3, 7, 9, 4, -1, -1, -1, -1},
{8, 4, 7, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 4, 7, 11, 2, 4, 2, 0, 4, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 1, 8, 4, 7, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
{4, 7, 11, 9, 4, 11, 9, 11, 2, 9, 2, 1, -1, -1, -1, -1},
{3, 10, 1, 3, 11, 10, 7, 8, 4, -1, -1, -1, -1, -1, -1, -1},
{1, 11, 10, 1, 4, 11, 1, 0, 4, 7, 11, 4, -1, -1, -1, -1},
{4, 7, 8, 9, 0, 11, 9, 11, 10, 11, 0, 3, -1, -1, -1, -1},
{4, 7, 11, 4, 11, 9, 9, 11, 10, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 5, 4, 1, 5, 0, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 5, 4, 8, 3, 5, 3, 1, 5, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 1, 2, 10, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
{5, 2, 10, 5, 4, 2, 4, 0, 2, -1, -1, -1, -1, -1, -1, -1},
{2, 10, 5, 3, 2, 5, 3, 5, 4, 3, 4, 8, -1, -1, -1, -1},
{9, 5, 4, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 11, 2, 0, 8, 11, 4, 9, 5, -1, -1, -1, -1, -1, -1, -1},
{0, 5, 4, 0, 1, 5, 2, 3, 11, -1, -1, -1, -1, -1, -1, -1},
{2, 1, 5, 2, 5, 8, 2, 8, 11, 4, 8, 5, -1, -1, -1, -1},
{10, 3, 11, 10, 1, 3, 9, 5, 4, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 5, 0, 8, 1, 8, 10, 1, 8, 11, 10, -1, -1, -1, -1},
{5, 4, 0, 5, 0, 11, 5, 11, 10, 11, 0, 3, -1, -1, -1, -1},
{5, 4, 8, 5, 8, 10, 10, 8, 11, -1, -1, -1, -1, -1, -1, -1},
{9, 7, 8, 5, 7, 9, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 3, 0, 9, 5, 3, 5, 7, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 7, 8, 0, 1, 7, 1, 5, 7, -1, -1, -1, -1, -1, -1, -1},
{1, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 7, 8, 9, 5, 7, 10, 1, 2, -1, -1, -1, -1, -1, -1, -1},
{10, 1, 2, 9, 5, 0, 5, 3, 0, 5, 7, 3, -1, -1, -1, -1},
{8, 0, 2, 8, 2, 5, 8, 5, 7, 10, 5, 2, -1, -1, -1, -1},
{2, 10, 5, 2, 5, 3, 3, 5, 7, -1, -1, -1, -1, -1, -1, -1},
{7, 9, 5, 7, 8, 9, 3, 11, 2, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 7, 9, 7, 2, 9, 2, 0, 2, 7, 11, -1, -1, -1, -1},
{2, 3, 11, 0, 1, 8, 1, 7, 8, 1, 5, 7, -1, -1, -1, -1},
{11, 2, 1, 11, 1, 7, 7, 1, 5, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 8, 8, 5, 7, 10, 1, 3, 10, 3, 11, -1, -1, -1, -1},
{5, 7, 0, 5, 0, 9, 7, 11, 0, 1, 0, 10, 11, 10, 0, -1},
{11, 10, 0, 11, 0, 3, 10, 5, 0, 8, 0, 7, 5, 7, 0, -1},
{11, 10, 5, 7, 11, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 1, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 8, 3, 1, 9, 8, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 5, 2, 6, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 5, 1, 2, 6, 3, 0, 8, -1, -1, -1, -1, -1, -1, -1},
{9, 6, 5, 9, 0, 6, 0, 2, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 9, 8, 5, 8, 2, 5, 2, 6, 3, 2, 8, -1, -1, -1, -1},
{2, 3, 11, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 0, 8, 11, 2, 0, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 1, 9, 2, 9, 11, 2, 9, 8, 11, -1, -1, -1, -1},
{6, 3, 11, 6, 5, 3, 5, 1, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 11, 0, 11, 5, 0, 5, 1, 5, 11, 6, -1, -1, -1, -1},
{3, 11, 6, 0, 3, 6, 0, 6, 5, 0, 5, 9, -1, -1, -1, -1},
{6, 5, 9, 6, 9, 11, 11, 9, 8, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 3, 0, 4, 7, 3, 6, 5, 10, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 5, 10, 6, 8, 4, 7, -1, -1, -1, -1, -1, -1, -1},
{10, 6, 5, 1, 9, 7, 1, 7, 3, 7, 9, 4, -1, -1, -1, -1},
{6, 1, 2, 6, 5, 1, 4, 7, 8, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 5, 5, 2, 6, 3, 0, 4, 3, 4, 7, -1, -1, -1, -1},
{8, 4, 7, 9, 0, 5, 0, 6, 5, 0, 2, 6, -1, -1, -1, -1},
{7, 3, 9, 7, 9, 4, 3, 2, 9, 5, 9, 6, 2, 6, 9, -1},
{3, 11, 2, 7, 8, 4, 10, 6, 5, -1, -1, -1, -1, -1, -1, -1},
{5, 10, 6, 4, 7, 2, 4, 2, 0, 2, 7, 11, -1, -1, -1, -1},
{0, 1, 9, 4, 7, 8, 2, 3, 11, 5, 10, 6, -1, -1, -1, -1},
{9, 2, 1, 9, 11, 2, 9, 4, 11, 7, 11, 4, 5, 10, 6, -1},
{8, 4, 7, 3, 11, 5, 3, 5, 1, 5, 11, 6, -1, -1, -1, -1},
{5, 1, 11, 5, 11, 6, 1, 0, 11, 7, 11, 4, 0, 4, 11, -1},
{0, 5, 9, 0, 6, 5, 0, 3, 6, 11, 6, 3, 8, 4, 7, -1},
{6, 5, 9, 6, 9, 11, 4, 7, 9, 7, 11, 9, -1, -1, -1, -1},
{10, 4, 9, 6, 4, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 10, 6, 4, 9, 10, 0, 8, 3, -1, -1, -1, -1, -1, -1, -1},
{10, 0, 1, 10, 6, 0, 6, 4, 0, -1, -1, -1, -1, -1, -1, -1},
{8, 3, 1, 8, 1, 6, 8, 6, 4, 6, 1, 10, -1, -1, -1, -1},
{1, 4, 9, 1, 2, 4, 2, 6, 4, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 1, 2, 9, 2, 4, 9, 2, 6, 4, -1, -1, -1, -1},
{0, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 3, 2, 8, 2, 4, 4, 2, 6, -1, -1, -1, -1, -1, -1, -1},
{10, 4, 9, 10, 6, 4, 11, 2, 3, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 2, 2, 8, 11, 4, 9, 10, 4, 10, 6, -1, -1, -1, -1},
{3, 11, 2, 0, 1, 6, 0, 6, 4, 6, 1, 10, -1, -1, -1, -1},
{6, 4, 1, 6, 1, 10, 4, 8, 1, 2, 1, 11, 8, 11, 1, -1},
{9, 6, 4, 9, 3, 6, 9, 1, 3, 11, 6, 3, -1, -1, -1, -1},
{8, 11, 1, 8, 1, 0, 11, 6, 1, 9, 1, 4, 6, 4, 1, -1},
{3, 11, 6, 3, 6, 0, 0, 6, 4, -1, -1, -1, -1, -1, -1, -1},
{6, 4, 8, 11, 6, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 10, 6, 7, 8, 10, 8, 9, 10, -1, -1, -1, -1, -1, -1, -1},
{0, 7, 3, 0, 10, 7, 0, 9, 10, 6, 7, 10, -1, -1, -1, -1},
{10, 6, 7, 1, 10, 7, 1, 7, 8, 1, 8, 0, -1, -1, -1, -1},
{10, 6, 7, 10, 7, 1, 1, 7, 3, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 6, 1, 6, 8, 1, 8, 9, 8, 6, 7, -1, -1, -1, -1},
{2, 6, 9, 2, 9, 1, 6, 7, 9, 0, 9, 3, 7, 3, 9, -1},
{7, 8, 0, 7, 0, 6, 6, 0, 2, -1, -1, -1, -1, -1, -1, -1},
{7, 3, 2, 6, 7, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 11, 10, 6, 8, 10, 8, 9, 8, 6, 7, -1, -1, -1, -1},
{2, 0, 7, 2, 7, 11, 0, 9, 7, 6, 7, 10, 9, 10, 7, -1},
{1, 8, 0, 1, 7, 8, 1, 10, 7, 6, 7, 10, 2, 3, 11, -1},
{11, 2, 1, 11, 1, 7, 10, 6, 1, 6, 7, 1, -1, -1, -1, -1},
{8, 9, 6, 8, 6, 7, 9, 1, 6, 11, 6, 3, 1, 3, 6, -1},
{0, 9, 1, 11, 6, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 8, 0, 7, 0, 6, 3, 11, 0, 11, 6, 0, -1, -1, -1, -1},
{7, 11, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 8, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 9, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 1, 9, 8, 3, 1, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
{10, 1, 2, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 3, 0, 8, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
{2, 9, 0, 2, 10, 9, 6, 11, 7, -1, -1, -1, -1, -1, -1, -1},
{6, 11, 7, 2, 10, 3, 10, 8, 3, 10, 9, 8, -1, -1, -1, -1},
{7, 2, 3, 6, 2, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{7, 0, 8, 7, 6, 0, 6, 2, 0, -1, -1, -1, -1, -1, -1, -1},
{2, 7, 6, 2, 3, 7, 0, 1, 9, -1, -1, -1, -1, -1, -1, -1},
{1, 6, 2, 1, 8, 6, 1, 9, 8, 8, 7, 6, -1, -1, -1, -1},
{10, 7, 6, 10, 1, 7, 1, 3, 7, -1, -1, -1, -1, -1, -1, -1},
{10, 7, 6, 1, 7, 10, 1, 8, 7, 1, 0, 8, -1, -1, -1, -1},
{0, 3, 7, 0, 7, 10, 0, 10, 9, 6, 10, 7, -1, -1, -1, -1},
{7, 6, 10, 7, 10, 8, 8, 10, 9, -1, -1, -1, -1, -1, -1, -1},
{6, 8, 4, 11, 8, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 6, 11, 3, 0, 6, 0, 4, 6, -1, -1, -1, -1, -1, -1, -1},
{8, 6, 11, 8, 4, 6, 9, 0, 1, -1, -1, -1, -1, -1, -1, -1},
{9, 4, 6, 9, 6, 3, 9, 3, 1, 11, 3, 6, -1, -1, -1, -1},
{6, 8, 4, 6, 11, 8, 2, 10, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 3, 0, 11, 0, 6, 11, 0, 4, 6, -1, -1, -1, -1},
{4, 11, 8, 4, 6, 11, 0, 2, 9, 2, 10, 9, -1, -1, -1, -1},
{10, 9, 3, 10, 3, 2, 9, 4, 3, 11, 3, 6, 4, 6, 3, -1},
{8, 2, 3, 8, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1},
{0, 4, 2, 4, 6, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 9, 0, 2, 3, 4, 2, 4, 6, 4, 3, 8, -1, -1, -1, -1},
{1, 9, 4, 1, 4, 2, 2, 4, 6, -1, -1, -1, -1, -1, -1, -1},
{8, 1, 3, 8, 6, 1, 8, 4, 6, 6, 10, 1, -1, -1, -1, -1},
{10, 1, 0, 10, 0, 6, 6, 0, 4, -1, -1, -1, -1, -1, -1, -1},
{4, 6, 3, 4, 3, 8, 6, 10, 3, 0, 3, 9, 10, 9, 3, -1},
{10, 9, 4, 6, 10, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 5, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 4, 9, 5, 11, 7, 6, -1, -1, -1, -1, -1, -1, -1},
{5, 0, 1, 5, 4, 0, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
{11, 7, 6, 8, 3, 4, 3, 5, 4, 3, 1, 5, -1, -1, -1, -1},
{9, 5, 4, 10, 1, 2, 7, 6, 11, -1, -1, -1, -1, -1, -1, -1},
{6, 11, 7, 1, 2, 10, 0, 8, 3, 4, 9, 5, -1, -1, -1, -1},
{7, 6, 11, 5, 4, 10, 4, 2, 10, 4, 0, 2, -1, -1, -1, -1},
{3, 4, 8, 3, 5, 4, 3, 2, 5, 10, 5, 2, 11, 7, 6, -1},
{7, 2, 3, 7, 6, 2, 5, 4, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 5, 4, 0, 8, 6, 0, 6, 2, 6, 8, 7, -1, -1, -1, -1},
{3, 6, 2, 3, 7, 6, 1, 5, 0, 5, 4, 0, -1, -1, -1, -1},
{6, 2, 8, 6, 8, 7, 2, 1, 8, 4, 8, 5, 1, 5, 8, -1},
{9, 5, 4, 10, 1, 6, 1, 7, 6, 1, 3, 7, -1, -1, -1, -1},
{1, 6, 10, 1, 7, 6, 1, 0, 7, 8, 7, 0, 9, 5, 4, -1},
{4, 0, 10, 4, 10, 5, 0, 3, 10, 6, 10, 7, 3, 7, 10, -1},
{7, 6, 10, 7, 10, 8, 5, 4, 10, 4, 8, 10, -1, -1, -1, -1},
{6, 9, 5, 6, 11, 9, 11, 8, 9, -1, -1, -1, -1, -1, -1, -1},
{3, 6, 11, 0, 6, 3, 0, 5, 6, 0, 9, 5, -1, -1, -1, -1},
{0, 11, 8, 0, 5, 11, 0, 1, 5, 5, 6, 11, -1, -1, -1, -1},
{6, 11, 3, 6, 3, 5, 5, 3, 1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 10, 9, 5, 11, 9, 11, 8, 11, 5, 6, -1, -1, -1, -1},
{0, 11, 3, 0, 6, 11, 0, 9, 6, 5, 6, 9, 1, 2, 10, -1},
{11, 8, 5, 11, 5, 6, 8, 0, 5, 10, 5, 2, 0, 2, 5, -1},
{6, 11, 3, 6, 3, 5, 2, 10, 3, 10, 5, 3, -1, -1, -1, -1},
{5, 8, 9, 5, 2, 8, 5, 6, 2, 3, 8, 2, -1, -1, -1, -1},
{9, 5, 6, 9, 6, 0, 0, 6, 2, -1, -1, -1, -1, -1, -1, -1},
{1, 5, 8, 1, 8, 0, 5, 6, 8, 3, 8, 2, 6, 2, 8, -1},
{1, 5, 6, 2, 1, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 3, 6, 1, 6, 10, 3, 8, 6, 5, 6, 9, 8, 9, 6, -1},
{10, 1, 0, 10, 0, 6, 9, 5, 0, 5, 6, 0, -1, -1, -1, -1},
{0, 3, 8, 5, 6, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{10, 5, 6, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 5, 10, 7, 5, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{11, 5, 10, 11, 7, 5, 8, 3, 0, -1, -1, -1, -1, -1, -1, -1},
{5, 11, 7, 5, 10, 11, 1, 9, 0, -1, -1, -1, -1, -1, -1, -1},
{10, 7, 5, 10, 11, 7, 9, 8, 1, 8, 3, 1, -1, -1, -1, -1},
{11, 1, 2, 11, 7, 1, 7, 5, 1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 1, 2, 7, 1, 7, 5, 7, 2, 11, -1, -1, -1, -1},
{9, 7, 5, 9, 2, 7, 9, 0, 2, 2, 11, 7, -1, -1, -1, -1},
{7, 5, 2, 7, 2, 11, 5, 9, 2, 3, 2, 8, 9, 8, 2, -1},
{2, 5, 10, 2, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1},
{8, 2, 0, 8, 5, 2, 8, 7, 5, 10, 2, 5, -1, -1, -1, -1},
{9, 0, 1, 5, 10, 3, 5, 3, 7, 3, 10, 2, -1, -1, -1, -1},
{9, 8, 2, 9, 2, 1, 8, 7, 2, 10, 2, 5, 7, 5, 2, -1},
{1, 3, 5, 3, 7, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 7, 0, 7, 1, 1, 7, 5, -1, -1, -1, -1, -1, -1, -1},
{9, 0, 3, 9, 3, 5, 5, 3, 7, -1, -1, -1, -1, -1, -1, -1},
{9, 8, 7, 5, 9, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{5, 8, 4, 5, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1},
{5, 0, 4, 5, 11, 0, 5, 10, 11, 11, 3, 0, -1, -1, -1, -1},
{0, 1, 9, 8, 4, 10, 8, 10, 11, 10, 4, 5, -1, -1, -1, -1},
{10, 11, 4, 10, 4, 5, 11, 3, 4, 9, 4, 1, 3, 1, 4, -1},
{2, 5, 1, 2, 8, 5, 2, 11, 8, 4, 5, 8, -1, -1, -1, -1},
{0, 4, 11, 0, 11, 3, 4, 5, 11, 2, 11, 1, 5, 1, 11, -1},
{0, 2, 5, 0, 5, 9, 2, 11, 5, 4, 5, 8, 11, 8, 5, -1},
{9, 4, 5, 2, 11, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 5, 10, 3, 5, 2, 3, 4, 5, 3, 8, 4, -1, -1, -1, -1},
{5, 10, 2, 5, 2, 4, 4, 2, 0, -1, -1, -1, -1, -1, -1, -1},
{3, 10, 2, 3, 5, 10, 3, 8, 5, 4, 5, 8, 0, 1, 9, -1},
{5, 10, 2, 5, 2, 4, 1, 9, 2, 9, 4, 2, -1, -1, -1, -1},
{8, 4, 5, 8, 5, 3, 3, 5, 1, -1, -1, -1, -1, -1, -1, -1},
{0, 4, 5, 1, 0, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{8, 4, 5, 8, 5, 3, 9, 0, 5, 0, 3, 5, -1, -1, -1, -1},
{9, 4, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 11, 7, 4, 9, 11, 9, 10, 11, -1, -1, -1, -1, -1, -1, -1},
{0, 8, 3, 4, 9, 7, 9, 11, 7, 9, 10, 11, -1, -1, -1, -1},
{1, 10, 11, 1, 11, 4, 1, 4, 0, 7, 4, 11, -1, -1, -1, -1},
{3, 1, 4, 3, 4, 8, 1, 10, 4, 7, 4, 11, 10, 11, 4, -1},
{4, 11, 7, 9, 11, 4, 9, 2, 11, 9, 1, 2, -1, -1, -1, -1},
{9, 7, 4, 9, 11, 7, 9, 1, 11, 2, 11, 1, 0, 8, 3, -1},
{11, 7, 4, 11, 4, 2, 2, 4, 0, -1, -1, -1, -1, -1, -1, -1},
{11, 7, 4, 11, 4, 2, 8, 3, 4, 3, 2, 4, -1, -1, -1, -1},
{2, 9, 10, 2, 7, 9, 2, 3, 7, 7, 4, 9, -1, -1, -1, -1},
{9, 10, 7, 9, 7, 4, 10, 2, 7, 8, 7, 0, 2, 0, 7, -1},
{3, 7, 10, 3, 10, 2, 7, 4, 10, 1, 10, 0, 4, 0, 10, -1},
{1, 10, 2, 8, 7, 4, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 1, 4, 1, 7, 7, 1, 3, -1, -1, -1, -1, -1, -1, -1},
{4, 9, 1, 4, 1, 7, 0, 8, 1, 8, 7, 1, -1, -1, -1, -1},
{4, 0, 3, 7, 4, 3, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{4, 8, 7, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{9, 10, 8, 10, 11, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 9, 3, 9, 11, 11, 9, 10, -1, -1, -1, -1, -1, -1, -1},
{0, 1, 10, 0, 10, 8, 8, 10, 11, -1, -1, -1, -1, -1, -1, -1},
{3, 1, 10, 11, 3, 10, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 2, 11, 1, 11, 9, 9, 11, 8, -1, -1, -1, -1, -1, -1, -1},
{3, 0, 9, 3, 9, 11, 1, 2, 9, 2, 11, 9, -1, -1, -1, -1},
{0, 2, 11, 8, 0, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{3, 2, 11, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 8, 2, 8, 10, 10, 8, 9, -1, -1, -1, -1, -1, -1, -1},
{9, 10, 2, 0, 9, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{2, 3, 8, 2, 8, 10, 0, 1, 8, 1, 10, 8, -1, -1, -1, -1},
{1, 10, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{1, 3, 8, 9, 1, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 9, 1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{0, 3, 8, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1},
{-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}
};
//--------------------------------------------------------------------------------------------------
/// Constructor
//--------------------------------------------------------------------------------------------------
StructGridIsosurface::StructGridIsosurface(const RectilinearGrid* grid)
: m_grid(grid),
m_scalarSetIndex(0),
m_isoValue(0),
m_mapScalarSetIndex(UNDEFINED_UINT),
m_scalarMapper(NULL)
{
CVF_ASSERT(grid);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
StructGridIsosurface::~StructGridIsosurface()
{
}
//--------------------------------------------------------------------------------------------------
/// Set index of scalar set that should be used to generate the isosurface
///
/// \param scalarSetIndex Index of the scalar set. Must be a valid index. The default index is 0.
//--------------------------------------------------------------------------------------------------
void StructGridIsosurface::setScalarSetIndex(uint scalarSetIndex)
{
CVF_ASSERT(m_grid.notNull());
CVF_ASSERT(scalarSetIndex < m_grid->scalarSetCount());
m_scalarSetIndex = scalarSetIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridIsosurface::setIsoValue(double value)
{
m_isoValue = value;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void StructGridIsosurface::setMapScalar(uint scalarSetIndex, const ScalarMapper* mapper)
{
CVF_ASSERT(scalarSetIndex < m_grid->scalarSetCount());
CVF_ASSERT(mapper);
m_mapScalarSetIndex = scalarSetIndex;
m_scalarMapper = mapper;
}
//--------------------------------------------------------------------------------------------------
/// Generate isosurface geometry based on grid point scalars (cell corner)
///
/// \return Reference to created DrawableGeo object. Returns NULL if no isosurface was generated.
/// If a scalar mapper is defined, texture coords are generated based on scalar field used
/// to map onto the isosurface
///
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> StructGridIsosurface::generateSurface() const
{
DebugTimer tim("StructGridIsosurface::generateSurface()", DebugTimer::DISABLED);
uint cellCountI = m_grid->cellCountI();
uint cellCountJ = m_grid->cellCountJ();
uint cellCountK = m_grid->cellCountK();
std::vector<Vec3f> isoVertices;
std::vector<double> isoVertexScalars;
std::vector<uint> isoIndices;
bool useTextureMapping = mapScalar();
// Maps from edge IDs in original grid to vertex indices in the generated isosurface
std::map<size_t, size_t> edgeIdToIsoVertexIdxMap;
// The indexing conventions for vertices and
// edges used in the algorithm:
// edg verts
// 4-------------5 *------4------* 0 0 - 1
// /| /| /| /| 1 1 - 2
// / | / | 7/ | 5/ | 2 2 - 3
// / | / | |z / 8 / 9 3 3 - 0
// 7-------------6 | | /y *------6------* | 4 4 - 5
// | | | | |/ | | | | 5 5 - 6
// | 0---------|---1 *---x | *------0--|---* 6 6 - 7
// | / | / 11 / 10 / 7 7 - 4
// | / | / | /3 | /1 8 0 - 4
// |/ |/ |/ |/ 9 1 - 5
// 3-------------2 *------2------* 10 2 - 6
// vertex indices edge indices 11 3 - 7
//
GridCell cell;
uint k;
for (k = 0; k < cellCountK; k++)
{
uint j;
for (j = 0; j < cellCountJ; j++)
{
uint i;
for (i = 0; i < cellCountI; i++)
{
// Corner scalar values
cell.val[0] = m_grid->gridPointScalar(m_scalarSetIndex, i, j + 1, k);
cell.val[1] = m_grid->gridPointScalar(m_scalarSetIndex, i + 1, j + 1, k);
cell.val[2] = m_grid->gridPointScalar(m_scalarSetIndex, i + 1, j, k);
cell.val[3] = m_grid->gridPointScalar(m_scalarSetIndex, i, j, k);
cell.val[4] = m_grid->gridPointScalar(m_scalarSetIndex, i, j + 1, k + 1);
cell.val[5] = m_grid->gridPointScalar(m_scalarSetIndex, i + 1, j + 1, k + 1);
cell.val[6] = m_grid->gridPointScalar(m_scalarSetIndex, i + 1, j, k + 1);
cell.val[7] = m_grid->gridPointScalar(m_scalarSetIndex, i, j, k + 1);
// Inexpensive optimization
// Check if iso value intersects this cell before proceeding
int aboveCount = 0;
int belowCount = 0;
int n;
for (n = 0; n < 8; n++)
{
if (cell.val[n] < m_isoValue) belowCount++;
else if (cell.val[n] > m_isoValue) aboveCount++;
}
if (aboveCount == 8 || belowCount == 8)
{
continue;
}
if (useTextureMapping)
{
cell.mapVal[0] = m_grid->gridPointScalar(m_mapScalarSetIndex, i, j + 1, k);
cell.mapVal[1] = m_grid->gridPointScalar(m_mapScalarSetIndex, i + 1, j + 1, k);
cell.mapVal[2] = m_grid->gridPointScalar(m_mapScalarSetIndex, i + 1, j, k);
cell.mapVal[3] = m_grid->gridPointScalar(m_mapScalarSetIndex, i, j, k);
cell.mapVal[4] = m_grid->gridPointScalar(m_mapScalarSetIndex, i, j + 1, k + 1);
cell.mapVal[5] = m_grid->gridPointScalar(m_mapScalarSetIndex, i + 1, j + 1, k + 1);
cell.mapVal[6] = m_grid->gridPointScalar(m_mapScalarSetIndex, i + 1, j, k + 1);
cell.mapVal[7] = m_grid->gridPointScalar(m_mapScalarSetIndex, i, j, k + 1);
}
// Corner coordinates
cell.p[0] = m_grid->gridPointCoordinate(i, j + 1, k);
cell.p[1] = m_grid->gridPointCoordinate(i + 1, j + 1, k);
cell.p[2] = m_grid->gridPointCoordinate(i + 1, j, k);
cell.p[3] = m_grid->gridPointCoordinate(i, j, k);
cell.p[4] = m_grid->gridPointCoordinate(i, j + 1, k + 1);
cell.p[5] = m_grid->gridPointCoordinate(i + 1, j + 1, k + 1);
cell.p[6] = m_grid->gridPointCoordinate(i + 1, j, k + 1);
cell.p[7] = m_grid->gridPointCoordinate(i, j, k + 1);
// Edged IDs
cell.eid[ 0] = 3*m_grid->gridPointIndexFromIJK(i, j + 1, k);
cell.eid[ 1] = 3*m_grid->gridPointIndexFromIJK(i + 1, j, k) + 1;
cell.eid[ 2] = 3*m_grid->gridPointIndexFromIJK(i, j, k);
cell.eid[ 3] = 3*m_grid->gridPointIndexFromIJK(i, j, k) + 1;
cell.eid[ 4] = 3*m_grid->gridPointIndexFromIJK(i, j + 1, k + 1);
cell.eid[ 5] = 3*m_grid->gridPointIndexFromIJK(i + 1, j, k + 1) + 1;
cell.eid[ 6] = 3*m_grid->gridPointIndexFromIJK(i, j, k + 1);
cell.eid[ 7] = 3*m_grid->gridPointIndexFromIJK(i, j, k + 1) + 1;
cell.eid[ 8] = 3*m_grid->gridPointIndexFromIJK(i, j + 1, k) + 2;
cell.eid[ 9] = 3*m_grid->gridPointIndexFromIJK(i + 1, j + 1, k) + 2;
cell.eid[10] = 3*m_grid->gridPointIndexFromIJK(i + 1, j, k) + 2;
cell.eid[11] = 3*m_grid->gridPointIndexFromIJK(i, j, k) + 2;
Triangle triangles[5];
int numTriangles = polygonise(m_isoValue, cell, triangles, useTextureMapping);
for (n = 0; n < numTriangles; n++)
{
int m;
for (m = 0; m < 3; m++)
{
size_t vertexIdx = 0;
size_t sourceEdgeId = triangles[n].peid[m];
std::map<size_t,size_t>::iterator it = edgeIdToIsoVertexIdxMap.find(sourceEdgeId);
if (it == edgeIdToIsoVertexIdxMap.end())
{
Vec3f v(triangles[n].p[m]);
isoVertices.push_back(v);
if (useTextureMapping)
{
isoVertexScalars.push_back(triangles[n].scalars[m]);
}
vertexIdx = isoVertices.size() - 1;
edgeIdToIsoVertexIdxMap[sourceEdgeId] = vertexIdx;
}
else
{
vertexIdx = it->second;
}
isoIndices.push_back(static_cast<uint>(vertexIdx));
}
}
}
}
}
tim.reportTime("Time generating iso");
//Trace::show("Vertices:%d Conns:%d Tris:%d", isoVertices.size(), isoIndices.size(), isoIndices.size()/3);
if (isoVertices.size() > 0 && isoIndices.size() > 0)
{
GeometryBuilderDrawableGeo builder;
builder.addVertices(Vec3fArray(isoVertices));
builder.addTriangles(UIntArray(isoIndices));
ref<cvf::DrawableGeo> geo = builder.drawableGeo();
if (useTextureMapping)
{
ref<Color3ubArray> vertexColors = new Color3ubArray;
ref<Vec2fArray> textureCoords = new Vec2fArray;
vertexColors->reserve(isoVertices.size());
textureCoords->reserve(isoVertices.size());
size_t i;
for (i = 0; i < isoVertices.size(); i++)
{
Color3ub clr = m_scalarMapper->mapToColor(isoVertexScalars[i]);
vertexColors->add(clr);
Vec2f texCoord = m_scalarMapper->mapToTextureCoord(isoVertexScalars[i]);
textureCoords->add(texCoord);
}
geo->setColorArray(vertexColors.p());
geo->setTextureCoordArray(textureCoords.p());
}
return geo;
}
else
{
return NULL;
}
}
//--------------------------------------------------------------------------------------------------
/// Generate isosurface geometry from current configuration
///
/// \return Reference to created DrawableGeo object. Returns NULL if no isosurface was generated
///
/// \remarks Currently, the isosurface is generated only from cell center scalar values.
/// \todo Must implement special handling of the outer edges of the grid. Currently half of the
/// outer edge cells is ignored in the isosurface computation.
//--------------------------------------------------------------------------------------------------
ref<DrawableGeo> StructGridIsosurface::generateSurfaceCellCenterBased() const
{
//DebugTimer tim;
uint cellCountI = m_grid->cellCountI();
uint cellCountJ = m_grid->cellCountJ();
uint cellCountK = m_grid->cellCountK();
std::vector<Vec3f> isoVertices;
std::vector<uint> isoIndices;
// Maps from edge IDs in original grid to vertex indices in the generated isosurface
std::map<size_t, size_t> edgeIdToIsoVertexIdxMap;
// The indexing conventions for vertices and
// edges used in the algorithm:
// edg verts
// 4-------------5 *------4------* 0 0 - 1
// /| /| /| /| 1 1 - 2
// / | / | 7/ | 5/ | 2 2 - 3
// / | / | |z / 8 / 9 3 3 - 0
// 7-------------6 | | /y *------6------* | 4 4 - 5
// | | | | |/ | | | | 5 5 - 6
// | 0---------|---1 *---x | *------0--|---* 6 6 - 7
// | / | / 11 / 10 / 7 7 - 4
// | / | / | /3 | /1 8 0 - 4
// |/ |/ |/ |/ 9 1 - 5
// 3-------------2 *------2------* 10 2 - 6
// vertex indices edge indices 11 3 - 7
//
GridCell cell;
const DoubleArray* scalarSet = m_grid->scalarSet(m_scalarSetIndex);
CVF_ASSERT(scalarSet);
uint k;
for (k = 0; k < cellCountK - 1; k++)
{
uint j;
for (j = 0; j < cellCountJ - 1; j++)
{
uint i;
for (i = 0; i < cellCountI - 1; i++)
{
size_t cellIndex0 = m_grid->cellIndexFromIJK(i, j + 1, k);
size_t cellIndex1 = m_grid->cellIndexFromIJK(i + 1, j + 1, k);
size_t cellIndex2 = m_grid->cellIndexFromIJK(i + 1, j, k);
size_t cellIndex3 = m_grid->cellIndexFromIJK(i, j, k);
size_t cellIndex4 = m_grid->cellIndexFromIJK(i, j + 1, k + 1);
size_t cellIndex5 = m_grid->cellIndexFromIJK(i + 1, j + 1, k + 1);
size_t cellIndex6 = m_grid->cellIndexFromIJK(i + 1, j, k + 1);
size_t cellIndex7 = m_grid->cellIndexFromIJK(i, j, k + 1);
// Corner scalar values
cell.val[0] = scalarSet->get(cellIndex0);
cell.val[1] = scalarSet->get(cellIndex1);
cell.val[2] = scalarSet->get(cellIndex2);
cell.val[3] = scalarSet->get(cellIndex3);
cell.val[4] = scalarSet->get(cellIndex4);
cell.val[5] = scalarSet->get(cellIndex5);
cell.val[6] = scalarSet->get(cellIndex6);
cell.val[7] = scalarSet->get(cellIndex7);
// Inexpensive optimization
// Check if iso value intersects this cell before proceeding
int aboveCount = 0;
int belowCount = 0;
int n;
for (n = 0; n < 8; n++)
{
if (cell.val[n] < m_isoValue) belowCount++;
else if (cell.val[n] > m_isoValue) aboveCount++;
}
if (aboveCount == 8 || belowCount == 8)
{
continue;
}
// Corner coordinates
cell.p[0] = m_grid->cellCentroid(cellIndex0);
cell.p[1] = m_grid->cellCentroid(cellIndex1);
cell.p[2] = m_grid->cellCentroid(cellIndex2);
cell.p[3] = m_grid->cellCentroid(cellIndex3);
cell.p[4] = m_grid->cellCentroid(cellIndex4);
cell.p[5] = m_grid->cellCentroid(cellIndex5);
cell.p[6] = m_grid->cellCentroid(cellIndex6);
cell.p[7] = m_grid->cellCentroid(cellIndex7);
// Edged IDs
cell.eid[ 0] = 3*m_grid->gridPointIndexFromIJK(i, j + 1, k);
cell.eid[ 1] = 3*m_grid->gridPointIndexFromIJK(i + 1, j, k) + 1;
cell.eid[ 2] = 3*m_grid->gridPointIndexFromIJK(i, j, k);
cell.eid[ 3] = 3*m_grid->gridPointIndexFromIJK(i, j, k) + 1;
cell.eid[ 4] = 3*m_grid->gridPointIndexFromIJK(i, j + 1, k + 1);
cell.eid[ 5] = 3*m_grid->gridPointIndexFromIJK(i + 1, j, k + 1) + 1;
cell.eid[ 6] = 3*m_grid->gridPointIndexFromIJK(i, j, k + 1);
cell.eid[ 7] = 3*m_grid->gridPointIndexFromIJK(i, j, k + 1) + 1;
cell.eid[ 8] = 3*m_grid->gridPointIndexFromIJK(i, j + 1, k) + 2;
cell.eid[ 9] = 3*m_grid->gridPointIndexFromIJK(i + 1, j + 1, k) + 2;
cell.eid[10] = 3*m_grid->gridPointIndexFromIJK(i + 1, j, k) + 2;
cell.eid[11] = 3*m_grid->gridPointIndexFromIJK(i, j, k) + 2;
Triangle triangles[5];
int numTriangles = polygonise(m_isoValue, cell, triangles, false);
for (n = 0; n < numTriangles; n++)
{
int m;
for (m = 0; m < 3; m++)
{
size_t vertexIdx = 0;
size_t sourceEdgeId = triangles[n].peid[m];
std::map<size_t,size_t>::iterator it = edgeIdToIsoVertexIdxMap.find(sourceEdgeId);
if (it == edgeIdToIsoVertexIdxMap.end())
{
Vec3f v(triangles[n].p[m]);
isoVertices.push_back(v);
vertexIdx = isoVertices.size() - 1;
edgeIdToIsoVertexIdxMap[sourceEdgeId] = vertexIdx;
}
else
{
vertexIdx = it->second;
}
isoIndices.push_back(static_cast<uint>(vertexIdx));
}
}
}
}
}
//tim.reportTime("Time generating iso");
//Trace::show("Vertices:%d Conns:%d Tris:%d", isoVertices.size(), isoIndices.size(), isoIndices.size()/3);
if (isoVertices.size() > 0 && isoIndices.size() > 0)
{
GeometryBuilderDrawableGeo builder;
builder.addVertices(Vec3fArray(isoVertices));
builder.addTriangles(UIntArray(isoIndices));
return builder.drawableGeo();
}
else
{
return NULL;
}
}
//--------------------------------------------------------------------------------------------------
/// Given a cell and an isolevel, calculate the triangular facets to represent the isosurface through the cell
///
/// \return Return the number of triangular facets. 0 will be returned if the grid cell is either
/// totally above of totally below the isolevel.
///
/// The array "triangles" will be loaded up with the vertices at most 5 triangular facets.
//--------------------------------------------------------------------------------------------------
int StructGridIsosurface::polygonise(double isolevel, const GridCell& grid, Triangle triangles[5], bool useTextureMapping)
{
// Determine the index into the edge table which tells us which vertices are inside of the surface
// Calculate from those vertices which are below the isolevel.
int cubeindex = 0;
if (grid.val[0] < isolevel) cubeindex |= 1;
if (grid.val[1] < isolevel) cubeindex |= 2;
if (grid.val[2] < isolevel) cubeindex |= 4;
if (grid.val[3] < isolevel) cubeindex |= 8;
if (grid.val[4] < isolevel) cubeindex |= 16;
if (grid.val[5] < isolevel) cubeindex |= 32;
if (grid.val[6] < isolevel) cubeindex |= 64;
if (grid.val[7] < isolevel) cubeindex |= 128;
// Cube is entirely in/out of the surface
if (sm_edgeTable[cubeindex] == 0)
{
return 0;
}
// Find the vertices where the surface intersects the cube
Vec3d vertlist[12];
double mapScalars[12];
if (useTextureMapping)
{
if (sm_edgeTable[cubeindex] & 1) vertlist[ 0] = vertexInterpolateWithMapping(isolevel, grid.p[0], grid.p[1], grid.val[0], grid.val[1], grid.mapVal[0], grid.mapVal[1], &mapScalars[ 0]);
if (sm_edgeTable[cubeindex] & 2) vertlist[ 1] = vertexInterpolateWithMapping(isolevel, grid.p[1], grid.p[2], grid.val[1], grid.val[2], grid.mapVal[1], grid.mapVal[2], &mapScalars[ 1]);
if (sm_edgeTable[cubeindex] & 4) vertlist[ 2] = vertexInterpolateWithMapping(isolevel, grid.p[2], grid.p[3], grid.val[2], grid.val[3], grid.mapVal[2], grid.mapVal[3], &mapScalars[ 2]);
if (sm_edgeTable[cubeindex] & 8) vertlist[ 3] = vertexInterpolateWithMapping(isolevel, grid.p[3], grid.p[0], grid.val[3], grid.val[0], grid.mapVal[3], grid.mapVal[0], &mapScalars[ 3]);
if (sm_edgeTable[cubeindex] & 16) vertlist[ 4] = vertexInterpolateWithMapping(isolevel, grid.p[4], grid.p[5], grid.val[4], grid.val[5], grid.mapVal[4], grid.mapVal[5], &mapScalars[ 4]);
if (sm_edgeTable[cubeindex] & 32) vertlist[ 5] = vertexInterpolateWithMapping(isolevel, grid.p[5], grid.p[6], grid.val[5], grid.val[6], grid.mapVal[5], grid.mapVal[6], &mapScalars[ 5]);
if (sm_edgeTable[cubeindex] & 64) vertlist[ 6] = vertexInterpolateWithMapping(isolevel, grid.p[6], grid.p[7], grid.val[6], grid.val[7], grid.mapVal[6], grid.mapVal[7], &mapScalars[ 6]);
if (sm_edgeTable[cubeindex] & 128) vertlist[ 7] = vertexInterpolateWithMapping(isolevel, grid.p[7], grid.p[4], grid.val[7], grid.val[4], grid.mapVal[7], grid.mapVal[4], &mapScalars[ 7]);
if (sm_edgeTable[cubeindex] & 256) vertlist[ 8] = vertexInterpolateWithMapping(isolevel, grid.p[0], grid.p[4], grid.val[0], grid.val[4], grid.mapVal[0], grid.mapVal[4], &mapScalars[ 8]);
if (sm_edgeTable[cubeindex] & 512) vertlist[ 9] = vertexInterpolateWithMapping(isolevel, grid.p[1], grid.p[5], grid.val[1], grid.val[5], grid.mapVal[1], grid.mapVal[5], &mapScalars[ 9]);
if (sm_edgeTable[cubeindex] & 1024) vertlist[10] = vertexInterpolateWithMapping(isolevel, grid.p[2], grid.p[6], grid.val[2], grid.val[6], grid.mapVal[2], grid.mapVal[6], &mapScalars[10]);
if (sm_edgeTable[cubeindex] & 2048) vertlist[11] = vertexInterpolateWithMapping(isolevel, grid.p[3], grid.p[7], grid.val[3], grid.val[7], grid.mapVal[3], grid.mapVal[7], &mapScalars[11]);
}
else
{
if (sm_edgeTable[cubeindex] & 1) vertlist[0] = vertexInterpolate(isolevel, grid.p[0], grid.p[1], grid.val[0], grid.val[1]);
if (sm_edgeTable[cubeindex] & 2) vertlist[1] = vertexInterpolate(isolevel, grid.p[1], grid.p[2], grid.val[1], grid.val[2]);
if (sm_edgeTable[cubeindex] & 4) vertlist[2] = vertexInterpolate(isolevel, grid.p[2], grid.p[3], grid.val[2], grid.val[3]);
if (sm_edgeTable[cubeindex] & 8) vertlist[3] = vertexInterpolate(isolevel, grid.p[3], grid.p[0], grid.val[3], grid.val[0]);
if (sm_edgeTable[cubeindex] & 16) vertlist[4] = vertexInterpolate(isolevel, grid.p[4], grid.p[5], grid.val[4], grid.val[5]);
if (sm_edgeTable[cubeindex] & 32) vertlist[5] = vertexInterpolate(isolevel, grid.p[5], grid.p[6], grid.val[5], grid.val[6]);
if (sm_edgeTable[cubeindex] & 64) vertlist[6] = vertexInterpolate(isolevel, grid.p[6], grid.p[7], grid.val[6], grid.val[7]);
if (sm_edgeTable[cubeindex] & 128) vertlist[7] = vertexInterpolate(isolevel, grid.p[7], grid.p[4], grid.val[7], grid.val[4]);
if (sm_edgeTable[cubeindex] & 256) vertlist[8] = vertexInterpolate(isolevel, grid.p[0], grid.p[4], grid.val[0], grid.val[4]);
if (sm_edgeTable[cubeindex] & 512) vertlist[9] = vertexInterpolate(isolevel, grid.p[1], grid.p[5], grid.val[1], grid.val[5]);
if (sm_edgeTable[cubeindex] & 1024) vertlist[10] = vertexInterpolate(isolevel, grid.p[2], grid.p[6], grid.val[2], grid.val[6]);
if (sm_edgeTable[cubeindex] & 2048) vertlist[11] = vertexInterpolate(isolevel, grid.p[3], grid.p[7], grid.val[3], grid.val[7]);
}
// Create the triangles
int ntriang = 0;
int i;
for (i = 0; sm_triTable[cubeindex][i] != -1; i += 3)
{
triangles[ntriang].p[0] = vertlist[sm_triTable[cubeindex][i ]];
triangles[ntriang].p[1] = vertlist[sm_triTable[cubeindex][i+1]];
triangles[ntriang].p[2] = vertlist[sm_triTable[cubeindex][i+2]];
triangles[ntriang].peid[0] = grid.eid[sm_triTable[cubeindex][i ]];
triangles[ntriang].peid[1] = grid.eid[sm_triTable[cubeindex][i+1]];
triangles[ntriang].peid[2] = grid.eid[sm_triTable[cubeindex][i+2]];
if (useTextureMapping)
{
triangles[ntriang].scalars[0] = mapScalars[sm_triTable[cubeindex][i ]];
triangles[ntriang].scalars[1] = mapScalars[sm_triTable[cubeindex][i+1]];
triangles[ntriang].scalars[2] = mapScalars[sm_triTable[cubeindex][i+2]];
}
ntriang++;
}
return ntriang;
}
//--------------------------------------------------------------------------------------------------
/// Linearly interpolate the position where an isosurface cuts an edge between two vertices, each with their own scalar value
//--------------------------------------------------------------------------------------------------
Vec3d StructGridIsosurface::vertexInterpolate(double isoLevel, const Vec3d& p1, const Vec3d& p2, double valp1, double valp2)
{
if (valp1 == valp2)
{
return p1;
}
else
{
double t = (isoLevel - valp1)/(valp2 - valp1);
CVF_ASSERT(t >= 0.0 && t <= 1.0);
if (t > 0.0 && t < 1.0)
{
Vec3d p;
p.x() = p1.x() + t * (p2.x() - p1.x());
p.y() = p1.y() + t * (p2.y() - p1.y());
p.z() = p1.z() + t * (p2.z() - p1.z());
return p;
}
else
{
if (t >= 1.0)
{
return p2;
}
else
{
return p1;
}
}
}
}
//--------------------------------------------------------------------------------------------------
/// Linearly interpolate the position where an isosurface cuts an edge between two vertices, each with their own scalar value.
/// Also compute the mapping scalar value computed position
//--------------------------------------------------------------------------------------------------
Vec3d StructGridIsosurface::vertexInterpolateWithMapping(double isoLevel, const Vec3d& p1, const Vec3d& p2, const double valp1, const double valp2, const double mapValP1, const double mapValP2, double* mapVal)
{
if (valp1 == valp2)
{
*mapVal = mapValP1;
return p1;
}
else
{
double t = (isoLevel - valp1)/(valp2 - valp1);
CVF_ASSERT(t >= 0.0 && t <= 1.0);
if (t > 0.0 && t < 1.0)
{
Vec3d p;
p.x() = p1.x() + t * (p2.x() - p1.x());
p.y() = p1.y() + t * (p2.y() - p1.y());
p.z() = p1.z() + t * (p2.z() - p1.z());
*mapVal = mapValP1 + t * (mapValP2 - mapValP1);
return p;
}
else
{
if (t >= 1.0)
{
*mapVal = mapValP2;
return p2;
}
else
{
*mapVal = mapValP1;
return p1;
}
}
}
}
//--------------------------------------------------------------------------------------------------
/// In order to get texture mapping, map scalar set index and scalar mapper object must be defined,
/// and the map scalar set index must be different to the scalar index used as basis for the iso surface
//--------------------------------------------------------------------------------------------------
bool StructGridIsosurface::mapScalar() const
{
if (m_mapScalarSetIndex == UNDEFINED_UINT)
{
return false;
}
if (m_mapScalarSetIndex == m_scalarSetIndex)
{
return false;
}
if (m_scalarMapper.isNull())
{
return false;
}
return true;
}
} // namespace cvf

View File

@ -0,0 +1,102 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfVector3.h"
namespace cvf {
class RectilinearGrid;
class DrawableGeo;
class ScalarMapper;
//==================================================================================================
//
//
//
//==================================================================================================
class StructGridIsosurface : public Object
{
public:
StructGridIsosurface(const RectilinearGrid* grid);
~StructGridIsosurface();
void setScalarSetIndex(uint scalarSetIndex);
void setIsoValue(double value);
void setMapScalar(uint scalarSetIndex, const ScalarMapper* mapper);
ref<DrawableGeo> generateSurface() const;
ref<DrawableGeo> generateSurfaceCellCenterBased() const;
private:
struct GridCell
{
Vec3d p[8]; // Cell's corner coordinates
double val[8]; // Scalar value in cell corners used to find isosurface
double mapVal[8]; // Scalar value in cell corners used to map onto isosurface
size_t eid[12]; // Global edge IDs for each of the cell's edges
};
struct Triangle
{
Vec3d p[3]; // Triangle vertices
size_t peid[3]; // Source edge ID for the vertices
double scalars[3]; // Interpolated scalar values for the vertices
};
bool mapScalar() const;
static int polygonise(double isoLevel, const GridCell& grid, Triangle triangles[5], bool useTextureMapping);
static Vec3d vertexInterpolate(double isoLevel, const Vec3d& p1, const Vec3d& p2, const double valp1, const double valp2);
static Vec3d vertexInterpolateWithMapping(double isoLevel, const Vec3d& p1, const Vec3d& p2, const double valp1, const double valp2, const double mapValp1, const double mapValp2, double* mapVal);
private:
cref<RectilinearGrid> m_grid;
uint m_scalarSetIndex; // Index of the value set that is used to generate the isosurface. Default 0
double m_isoValue; // Scalar value used to find isosurface for
uint m_mapScalarSetIndex; // Index of scalar set that is mapped onto the cut plane. -1 for no mapping
cref<ScalarMapper> m_scalarMapper; // Scalar mapper to use when mapping. Both scalar set index and mapper must be set in order to get scalar mapping
static const uint sm_edgeTable[256];
static const int sm_triTable[256][16];
};
}

View File

@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 2.8)
project(LibUtilities)
# Use our strict compile flags
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}")
if (CMAKE_COMPILER_IS_GNUCXX)
# Don't allow the compiler to assume strict aliasing when doing optimizations (the culprit is JPEG code)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing")
endif()
include_directories(../LibCore)
include_directories(../LibIo)
include_directories(../LibGeometry)
include_directories(../LibRender)
include_directories(../LibViewing)
set(CEE_SOURCE_FILES
cvfuImageJpeg.cpp
cvfuImageTga.cpp
cvfuInputEvents.cpp
cvfuPartCompoundGenerator.cpp
cvfuPointLight.cpp
cvfuProperty.cpp
cvfuSampleFactory.cpp
cvfuSnippetFactory.cpp
cvfuSnippetPropertyPublisher.cpp
cvfuTestSnippet.cpp
cvfuWavefrontObjImport.cpp
)
add_library(${PROJECT_NAME} ${CEE_SOURCE_FILES})

View File

@ -0,0 +1,272 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug MD TBB|Win32">
<Configuration>Debug MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD TBB|x64">
<Configuration>Debug MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|Win32">
<Configuration>Debug MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|x64">
<Configuration>Debug MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|Win32">
<Configuration>Release MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|x64">
<Configuration>Release MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|Win32">
<Configuration>Release MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|x64">
<Configuration>Release MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{ECF1BECD-E624-F971-C70A-F84686A36084}</ProjectGuid>
<RootNamespace>LibUtilities</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibViewing;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibViewing;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibViewing;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibViewing;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibViewing;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibViewing;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibViewing;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../LibViewing;../LibIo</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfuImageJpeg.cpp" />
<ClCompile Include="cvfuImageTga.cpp" />
<ClCompile Include="cvfuInputEvents.cpp" />
<ClCompile Include="cvfuPartCompoundGenerator.cpp" />
<ClCompile Include="cvfuPointLight.cpp" />
<ClCompile Include="cvfuProperty.cpp" />
<ClCompile Include="cvfuSampleFactory.cpp" />
<ClCompile Include="cvfuSnippetFactory.cpp" />
<ClCompile Include="cvfuSnippetPropertyPublisher.cpp" />
<ClCompile Include="cvfuTestSnippet.cpp" />
<ClCompile Include="cvfuWavefrontObjImport.cpp" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfuImageJpeg.h" />
<ClInclude Include="cvfuImageTga.h" />
<ClInclude Include="cvfuInputEvents.h" />
<ClInclude Include="cvfuInputTypes.h" />
<ClInclude Include="cvfuLibUtilities.h" />
<ClInclude Include="cvfuPartCompoundGenerator.h" />
<ClInclude Include="cvfuPointLight.h" />
<ClInclude Include="cvfuProperty.h" />
<ClInclude Include="cvfuSampleFactory.h" />
<ClInclude Include="cvfuSnippetFactory.h" />
<ClInclude Include="cvfuSnippetPropertyPublisher.h" />
<ClInclude Include="cvfuTestSnippet.h" />
<ClInclude Include="cvfuWavefrontObjImport.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,34 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="cvfuInputEvents.cpp" />
<ClCompile Include="cvfuSnippetFactory.cpp" />
<ClCompile Include="cvfuTestSnippet.cpp" />
<ClCompile Include="cvfuSampleFactory.cpp" />
<ClCompile Include="cvfuImageJpeg.cpp" />
<ClCompile Include="cvfuWavefrontObjImport.cpp" />
<ClCompile Include="cvfuProperty.cpp" />
<ClCompile Include="cvfuSnippetPropertyPublisher.cpp" />
<ClCompile Include="cvfuPointLight.cpp" />
<ClCompile Include="cvfuPartCompoundGenerator.cpp" />
<ClCompile Include="cvfuImageTga.cpp" />
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfuInputEvents.h" />
<ClInclude Include="cvfuInputTypes.h" />
<ClInclude Include="cvfuSnippetFactory.h" />
<ClInclude Include="cvfuTestSnippet.h" />
<ClInclude Include="cvfuSampleFactory.h" />
<ClInclude Include="cvfuImageJpeg.h" />
<ClInclude Include="cvfuWavefrontObjImport.h" />
<ClInclude Include="cvfuLibUtilities.h" />
<ClInclude Include="cvfuProperty.h" />
<ClInclude Include="cvfuSnippetPropertyPublisher.h" />
<ClInclude Include="cvfuPointLight.h" />
<ClInclude Include="cvfuPartCompoundGenerator.h" />
<ClInclude Include="cvfuImageTga.h" />
</ItemGroup>
</Project>

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,62 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfString.h"
#include "cvfTextureImage.h"
namespace cvfu {
//==================================================================================================
//
//
//
//==================================================================================================
class ImageJpeg
{
public:
static cvf::ref<cvf::TextureImage> loadImage(cvf::String filename);
static bool saveImage(const cvf::TextureImage& image, cvf::String filename);
static cvf::ref<cvf::TextureImage> loadImageFromMemory(std::vector<cvf::ubyte>& buffer);
static bool saveImageToMemory(const cvf::TextureImage& image, std::vector<cvf::ubyte>* buffer);
};
}

View File

@ -0,0 +1,320 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfFile.h"
#include "cvfuImageTga.h"
#include <stdio.h>
#include <vector>
#include <string.h>
#ifdef CVF_LINUX
CVF_GCC_DIAGNOSTIC_IGNORE("-Wconversion")
CVF_GCC_DIAGNOSTIC_IGNORE("-Wunused-result")
#endif
namespace cvfu {
using cvf::ref;
using cvf::Vec3f;
using cvf::Vec2f;
using cvf::Vec3d;
//==================================================================================================
//
// Small class to load a TGA-file into a memory buffer.
//
//==================================================================================================
class TgaLoader
{
public:
TgaLoader();
bool LoadTGA (const char* szFile);
int getWidth() const { return (m_iImageWidth); }
int getHeight() const { return (m_iImageHeight); }
//! Returns the pixel at location (x,y).
// ATTENTION:
// "getPixel(x,y)[0]" is BLUE
// "getPixel(x,y)[1]" is GREEN
// "getPixel(x,y)[2]" is RED
// "getPixel(x,y)[3]" is ALPHA
const unsigned char* getPixel (int x, int y) const {return (&m_Pixels[(static_cast<size_t>(y * m_iImageWidth + x) *4)]);}
private:
void LoadCompressedTGA (FILE* pFile);
void LoadUncompressedTGA (FILE* pFile);
std::vector<unsigned char> m_Pixels;
int m_iImageWidth;
int m_iImageHeight;
int m_iBytesPerPixel;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TgaLoader::TgaLoader ()
{
m_iImageWidth = 0;
m_iImageHeight = 0;
m_iBytesPerPixel = 0;
}
//--------------------------------------------------------------------------------------------------
/// Loads a TGA. Can be 8, 24 or 32 Bits per pixel, uncompressed or (RLE) compressed. Returns false, if the TGA could not be loaded.
//--------------------------------------------------------------------------------------------------
bool TgaLoader::LoadTGA (const char* szFile)
{
FILE* pFile = cvf::File::fopen (szFile, "rb");
if (!pFile)
return (false);
// Read the header of the TGA, compare it with the known headers for compressed and uncompressed TGAs
unsigned char ucHeader[18];
fread (ucHeader, sizeof (unsigned char) * 18, 1, pFile);
while (ucHeader[0] > 0)
{
--ucHeader[0];
unsigned char temp;
fread (&temp, sizeof (unsigned char), 1, pFile);
}
m_iImageWidth = ucHeader[13] * 256 + ucHeader[12];
m_iImageHeight = ucHeader[15] * 256 + ucHeader[14];
m_iBytesPerPixel = ucHeader[16] / 8;
// check whether width, height an BitsPerPixel are valid
if ((m_iImageWidth <= 0) || (m_iImageHeight <= 0) || ((m_iBytesPerPixel != 1) && (m_iBytesPerPixel != 3) && (m_iBytesPerPixel != 4)))
{
fclose (pFile);
return (false);
}
// allocate the image-buffer
m_Pixels.resize(static_cast<size_t>(m_iImageWidth * m_iImageHeight * 4));
// call the appropriate loader-routine
if (ucHeader[2] == 2)
{
LoadUncompressedTGA (pFile);
}
else
if (ucHeader[2] == 10)
{
LoadCompressedTGA (pFile);
}
else
{
fclose (pFile);
return (false);
}
fclose (pFile);
return (true);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TgaLoader::LoadUncompressedTGA (FILE* pFile)
{
unsigned char ucBuffer[4] = {255, 255, 255, 255};
unsigned int* pIntPointer = (unsigned int*) &m_Pixels[0];
unsigned int* pIntBuffer = (unsigned int*) &ucBuffer[0];
const int iPixelCount = m_iImageWidth * m_iImageHeight;
for (int i = 0; i < iPixelCount; ++i)
{
fread (ucBuffer, sizeof (unsigned char) * m_iBytesPerPixel, 1, pFile);
// if this is an 8-Bit TGA only, store the one channel in all four channels
// if it is a 24-Bit TGA (3 channels), the fourth channel stays at 255 all the time, since the 4th value in ucBuffer is never overwritten
if (m_iBytesPerPixel == 1)
{
ucBuffer[1] = ucBuffer[0];
ucBuffer[2] = ucBuffer[0];
ucBuffer[3] = ucBuffer[0];
}
// copy all four values in one operation
(*pIntPointer) = (*pIntBuffer);
++pIntPointer;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TgaLoader::LoadCompressedTGA (FILE* pFile)
{
int iCurrentPixel = 0;
//int iCurrentByte = 0;
unsigned char ucBuffer[4] = {255, 255, 255, 255};
const int iPixelCount = m_iImageWidth * m_iImageHeight;
unsigned int* pIntPointer = (unsigned int*) &m_Pixels[0];
unsigned int* pIntBuffer = (unsigned int*) &ucBuffer[0];
do
{
unsigned char ucChunkHeader = 0;
fread (&ucChunkHeader, sizeof (unsigned char), 1, pFile);
if (ucChunkHeader < 128)
{
// If the header is < 128, it means it is the number of RAW color packets minus 1
// that follow the header
// add 1 to get number of following color values
ucChunkHeader++;
// Read RAW color values
for (int i = 0; i < (int) ucChunkHeader; ++i)
{
fread (&ucBuffer[0], static_cast<size_t>(m_iBytesPerPixel), 1, pFile);
// if this is an 8-Bit TGA only, store the one channel in all four channels
// if it is a 24-Bit TGA (3 channels), the fourth channel stays at 255 all the time, since the 4th value in ucBuffer is never overwritten
if (m_iBytesPerPixel == 1)
{
ucBuffer[1] = ucBuffer[0];
ucBuffer[2] = ucBuffer[0];
ucBuffer[3] = ucBuffer[0];
}
// copy all four values in one operation
(*pIntPointer) = (*pIntBuffer);
++pIntPointer;
++iCurrentPixel;
}
}
else // chunkheader > 128 RLE data, next color reapeated (chunkheader - 127) times
{
ucChunkHeader -= 127; // Subteact 127 to get rid of the ID bit
// read the current color
fread (&ucBuffer[0], static_cast<size_t>(m_iBytesPerPixel), 1, pFile);
// if this is an 8-Bit TGA only, store the one channel in all four channels
// if it is a 24-Bit TGA (3 channels), the fourth channel stays at 255 all the time, since the 4th value in ucBuffer is never overwritten
if (m_iBytesPerPixel == 1)
{
ucBuffer[1] = ucBuffer[0];
ucBuffer[2] = ucBuffer[0];
ucBuffer[3] = ucBuffer[0];
}
// copy the color into the image data as many times as dictated
for (int i = 0; i < (int) ucChunkHeader; ++i)
{
(*pIntPointer) = (*pIntBuffer);
++pIntPointer;
++iCurrentPixel;
}
}
}
while (iCurrentPixel < iPixelCount);
}
//==================================================================================================
///
/// \class cvfu::ImageTga
/// \ingroup Utilities
///
/// Reading of TGA image files.
/// Supports 24 and 32 bit images, both RLE compressed and uncompressed.
/// Does not support color mapped images, nor 8 and 16 bit images.
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::TextureImage> ImageTga::loadImage(cvf::String fileName)
{
TgaLoader tgaImg;
if (!tgaImg.LoadTGA(fileName.toAscii().ptr()))
{
return NULL;
}
int width = tgaImg.getWidth();
int height = tgaImg.getHeight();
if (width <= 0 || height <= 0)
{
return NULL;
}
cvf::ref<cvf::TextureImage> image = new cvf::TextureImage;
image->allocate(static_cast<cvf::uint>(width), static_cast<cvf::uint>(height));
for (int y = 0; y < height; y++)
{
for (int x = 0; x < width; x++)
{
const unsigned char* pixBGRA = tgaImg.getPixel(x, y);
cvf::Color4ub pixelClr(pixBGRA[2], pixBGRA[1], pixBGRA[0], pixBGRA[3]);
image->setPixel(static_cast<cvf::uint>(x), static_cast<cvf::uint>(y), pixelClr);
}
}
return image;
}
} // namespace cvfu

View File

@ -0,0 +1,58 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfString.h"
#include "cvfTextureImage.h"
namespace cvfu {
//==================================================================================================
//
//
//
//==================================================================================================
class ImageTga
{
public:
static cvf::ref<cvf::TextureImage> loadImage(cvf::String fileName);
};
}

View File

@ -0,0 +1,326 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfSystem.h"
#include "cvfuInputEvents.h"
namespace cvfu {
//==================================================================================================
///
/// \class cvfu::MouseEvent
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
MouseEvent::MouseEvent(int x, int y, MouseButtons buttonsDown, KeyboardModifiers modifiersDown)
{
m_x = x;
m_y = y;
m_mouseButtonsDown = buttonsDown;
m_keyboardModifiersDown = modifiersDown;
m_requestedAction = NONE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int MouseEvent::x() const
{
return m_x;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int MouseEvent::y() const
{
return m_y;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
MouseButtons MouseEvent::buttons() const
{
return m_mouseButtonsDown;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
KeyboardModifiers MouseEvent::modifiers() const
{
return m_keyboardModifiersDown;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void MouseEvent::setRequestedAction(PostEventAction actionRequest)
{
m_requestedAction = actionRequest;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PostEventAction MouseEvent::requestedAction() const
{
return m_requestedAction;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::String MouseEvent::toString() const
{
cvf::String btn;
if (m_mouseButtonsDown.testFlag(LeftButton)) btn += "L";
if (m_mouseButtonsDown.testFlag(MiddleButton)) btn += "M";
if (m_mouseButtonsDown.testFlag(RightButton)) btn += "R";
cvf::String mod;
if (m_keyboardModifiersDown.testFlag(ShiftModifier)) mod += "S";
if (m_keyboardModifiersDown.testFlag(ControlModifier)) mod += "C";
cvf::String str = "MouseEvent:";
str += " x=" + cvf::String(m_x) + " y=" + cvf::String(m_y) + " buttons=" + btn + " modifiers=" + mod;
return str;
}
//==================================================================================================
///
/// \class cvfu::KeyEvent
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
KeyEvent::KeyEvent(Key key, unsigned short unicodeChar)
{
m_key = key;
m_unicodeChar = unicodeChar;
m_requestedAction = NONE;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Key KeyEvent::key() const
{
return m_key;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
char KeyEvent::character() const
{
if (m_unicodeChar <= 0xff)
{
return static_cast<char>(m_unicodeChar);
}
else
{
return 0;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
unsigned short KeyEvent::unicodeCharacter() const
{
return m_unicodeChar;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void KeyEvent::setRequestedAction(PostEventAction actionRequest)
{
m_requestedAction = actionRequest;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PostEventAction KeyEvent::requestedAction() const
{
return m_requestedAction;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::String KeyEvent::toString() const
{
char szBuf[1024];
cvf::String keyString = toString(m_key);
unsigned char aChar = static_cast<unsigned char>(character());
cvf::System::sprintf(szBuf, 1024, "KeyEvent: key=%s unicodeChar=0x%04x character=0x%02x", keyString.toAscii().ptr(), m_unicodeChar, aChar);
cvf::String str(szBuf);
return str;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::String KeyEvent::toString(Key key)
{
switch (key)
{
case Key_None: return "Key_None";
case Key_0: return "Key_0";
case Key_1: return "Key_1";
case Key_2: return "Key_2";
case Key_3: return "Key_3";
case Key_4: return "Key_4";
case Key_5: return "Key_5";
case Key_6: return "Key_6";
case Key_7: return "Key_7";
case Key_8: return "Key_8";
case Key_9: return "Key_9";
case Key_A: return "Key_A";
case Key_B: return "Key_B";
case Key_C: return "Key_C";
case Key_D: return "Key_D";
case Key_E: return "Key_E";
case Key_F: return "Key_F";
case Key_G: return "Key_G";
case Key_H: return "Key_H";
case Key_I: return "Key_I";
case Key_J: return "Key_J";
case Key_K: return "Key_K";
case Key_L: return "Key_L";
case Key_M: return "Key_M";
case Key_N: return "Key_N";
case Key_O: return "Key_O";
case Key_P: return "Key_P";
case Key_Q: return "Key_Q";
case Key_R: return "Key_R";
case Key_S: return "Key_S";
case Key_T: return "Key_T";
case Key_U: return "Key_U";
case Key_V: return "Key_V";
case Key_W: return "Key_W";
case Key_X: return "Key_X";
case Key_Y: return "Key_Y";
case Key_Z: return "Key_Z";
case Key_Return: return "Key_Return";
case Key_Backspace: return "Key_Backspace";
case Key_Tab: return "Key_Tab";
case Key_Space: return "Key_Space";
case Key_Control: return "Key_Control";
case Key_Alt: return "Key_Alt";
case Key_Shift: return "Key_Shift";
case Key_Insert: return "Key_Insert";
case Key_Delete: return "Key_Delete";
case Key_Home: return "Key_Home";
case Key_End: return "Key_End";
case Key_PageUp: return "Key_PageUp";
case Key_PageDown: return "Key_PageDown";
case Key_Left: return "Key_Left";
case Key_Right: return "Key_Right";
case Key_Up: return "Key_Up";
case Key_Down: return "Key_Down";
case Key_Clear: return "Key_Clear";
case Key_Escape: return "Key_Escape";
case Key_Plus: return "Key_Plus";
case Key_Minus: return "Key_Minus";
case Key_Comma: return "Key_Comma";
case Key_Period: return "Key_Period";
case Key_F1: return "Key_F1";
case Key_F2: return "Key_F2";
case Key_F3: return "Key_F3";
case Key_F4: return "Key_F4";
case Key_F5: return "Key_F5";
case Key_F6: return "Key_F6";
case Key_F7: return "Key_F7";
case Key_F8: return "Key_F8";
case Key_F9: return "Key_F9";
case Key_F10: return "Key_F10";
case Key_F11: return "Key_F11";
case Key_F12: return "Key_F12";
case Key_Unknown: return "Key_Unknown";
default: return "UNKNOWN";
}
}
} // namespace cvfu

View File

@ -0,0 +1,105 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfString.h"
#include "cvfuInputTypes.h"
namespace cvfu {
//==================================================================================================
//
// MouseEvent
//
//==================================================================================================
class MouseEvent
{
public:
MouseEvent(int x, int y, MouseButtons buttonsDown, KeyboardModifiers modifiersDown);
int x() const;
int y() const;
MouseButtons buttons() const;
KeyboardModifiers modifiers() const;
void setRequestedAction(PostEventAction actionRequest);
PostEventAction requestedAction() const;
cvf::String toString() const;
private:
int m_x; // X-coordinate
int m_y; // OpenGL style Y-coordinate with origin in lower left corner of the window
MouseButtons m_mouseButtonsDown; // Combination of mouse buttons that are down
KeyboardModifiers m_keyboardModifiersDown; // Combination of modifier keys that are down.
PostEventAction m_requestedAction;
};
//==================================================================================================
//
// KeyEvent
//
//==================================================================================================
class KeyEvent
{
public:
KeyEvent(Key key, unsigned short unicodeChar);
Key key() const;
char character() const;
unsigned short unicodeCharacter() const;
void setRequestedAction(PostEventAction actionRequest);
PostEventAction requestedAction() const;
cvf::String toString() const;
static cvf::String toString(Key key);
public:
Key m_key;
unsigned short m_unicodeChar;
PostEventAction m_requestedAction;
};
}

View File

@ -0,0 +1,157 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfFlags.h"
namespace cvfu {
enum Key
{
Key_None,
Key_Unknown,
Key_0,
Key_1,
Key_2,
Key_3,
Key_4,
Key_5,
Key_6,
Key_7,
Key_8,
Key_9,
Key_A,
Key_B,
Key_C,
Key_D,
Key_E,
Key_F,
Key_G,
Key_H,
Key_I,
Key_J,
Key_K,
Key_L,
Key_M,
Key_N,
Key_O,
Key_P,
Key_Q,
Key_R,
Key_S,
Key_T,
Key_U,
Key_V,
Key_W,
Key_X,
Key_Y,
Key_Z,
Key_Return,
Key_Backspace,
Key_Tab,
Key_Space,
Key_Control,
Key_Alt,
Key_Shift,
Key_Insert,
Key_Delete,
Key_Home,
Key_End,
Key_PageUp,
Key_PageDown,
Key_Left,
Key_Right,
Key_Up,
Key_Down,
Key_Clear, // Center key (5) on number pad
Key_Escape,
Key_Plus,
Key_Minus,
Key_Comma,
Key_Period,
Key_F1,
Key_F2,
Key_F3,
Key_F4,
Key_F5,
Key_F6,
Key_F7,
Key_F8,
Key_F9,
Key_F10,
Key_F11,
Key_F12
};
enum MouseButton
{
NoButton = 0x00000000,
LeftButton = 0x00000001,
RightButton = 0x00000002,
MiddleButton = 0x00000004
};
typedef cvf::Flags<MouseButton> MouseButtons;
enum KeyboardModifier
{
NoModifier = 0x00000000,
ShiftModifier = 0x00000010,
ControlModifier = 0x00000020
};
typedef cvf::Flags<KeyboardModifier> KeyboardModifiers;
// Rename to ActionRequest
enum PostEventAction
{
NONE,
REDRAW
};
}

View File

@ -0,0 +1,52 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
// Doxygen module definition
/// \defgroup Utilities Utilities module
#include "cvfuImageJpeg.h"
#include "cvfuInputEvents.h"
#include "cvfuInputTypes.h"
#include "cvfuPartCompoundGenerator.h"
#include "cvfuPointLight.h"
#include "cvfuProperty.h"
#include "cvfuSampleFactory.h"
#include "cvfuSnippetFactory.h"
#include "cvfuSnippetPropertyPublisher.h"
#include "cvfuTestSnippet.h"
#include "cvfuWavefrontObjImport.h"

View File

@ -0,0 +1,380 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfDrawableGeo.h"
#include "cvfTransform.h"
#include "cvfEffect.h"
#include "cvfGeometryUtils.h"
#include "cvfGeometryBuilderFaceList.h"
#include "cvfRenderState_FF.h"
#include "cvfUniform.h"
#include "cvfShaderProgram.h"
#include "cvfShaderProgramGenerator.h"
#include "cvfShaderSourceProvider.h"
#include "cvfuPartCompoundGenerator.h"
#ifndef WIN32
#include <cstdlib>
#endif
namespace cvfu {
using cvf::ref;
using cvf::uint;
using cvf::Vec3d;
using cvf::Vec3f;
//==================================================================================================
///
/// \class cvf::PartCompoundGenerator
/// \ingroup Utilities
///
/// Utility class for generating collections of parts for performance testing
///
//==================================================================================================
// Std. colors used for the effects
const cvf::Color3f DEFAULT_EFFECT_COLORS[] =
{
cvf::Color3f(1.0f, 0.0f, 0.0f),
cvf::Color3f(0.0f, 1.0f, 0.0f),
cvf::Color3f(1.0f, 1.0f, 0.0f),
cvf::Color3f(0.0f, 0.0f, 1.0f),
cvf::Color3f(1.0f, 0.0f, 1.0f),
cvf::Color3f(0.0f, 1.0f, 1.0f),
cvf::Color3f(1.0f, 0.5f, 0.0f),
cvf::Color3f(0.25f, 0.5f, 1.0f),
cvf::Color3f(1.0f, 0.0f, 0.0f),
cvf::Color3f(0.0f, 1.0f, 0.0f),
cvf::Color3f(1.0f, 1.0f, 0.0f),
cvf::Color3f(0.0f, 0.0f, 1.0f),
cvf::Color3f(1.0f, 0.0f, 1.0f),
cvf::Color3f(0.0f, 1.0f, 1.0f),
cvf::Color3f(1.0f, 0.5f, 0.0f),
cvf::Color3f(0.25f, 0.5f, 1.0f)
};
const int NUM_EFFECTS = sizeof(DEFAULT_EFFECT_COLORS)/sizeof(cvf::Color3f);
//--------------------------------------------------------------------------------------------------
/// Setup default config wiht 3x3x3 primitives
//--------------------------------------------------------------------------------------------------
PartCompoundGenerator::PartCompoundGenerator()
: m_partDistribution(3, 3, 3),
m_extent(1.0f, 1.0f, 1.0f),
m_origin(0.0f, 0.0f, 0.0f),
m_useShaders(false),
m_numEffects(-1),
m_numDrawableGeos(-1),
m_randomEffectAssignment(false),
m_randomGeoAssignment(false)
{
}
//--------------------------------------------------------------------------------------------------
/// Returns the number of parts that will be generated
//--------------------------------------------------------------------------------------------------
int PartCompoundGenerator::numParts() const
{
return m_partDistribution.x()*m_partDistribution.y()*m_partDistribution.z();
}
//--------------------------------------------------------------------------------------------------
/// Set the total extent the parts occupies
//--------------------------------------------------------------------------------------------------
void PartCompoundGenerator::setExtent(Vec3f extent)
{
m_extent = extent;
}
//--------------------------------------------------------------------------------------------------
/// Set the origin ("lower left corner") of the
//--------------------------------------------------------------------------------------------------
void PartCompoundGenerator::setOrigin(Vec3f origin)
{
m_origin = origin;
}
//--------------------------------------------------------------------------------------------------
/// Set the number of parts in each direction. Total number will be x*y*z
//--------------------------------------------------------------------------------------------------
void PartCompoundGenerator::setPartDistribution(cvf::Vec3i partDistribution)
{
m_partDistribution = partDistribution;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PartCompoundGenerator::setUseShaders(bool useShaders)
{
m_useShaders = useShaders;
}
//--------------------------------------------------------------------------------------------------
/// Set the (maximum) number of effects to use. Up to 16 different colors are (re)used.
/// \sa useRandomEffectAssignment
//--------------------------------------------------------------------------------------------------
void PartCompoundGenerator::setNumEffects(int numEffects)
{
m_numEffects = numEffects;
}
//--------------------------------------------------------------------------------------------------
/// Set the (maximum) number of effects to use. Up to 16 different colors are (re)used.
/// \sa useRandomEffectAssignment
//--------------------------------------------------------------------------------------------------
void PartCompoundGenerator::setNumDrawableGeos(int numDrawableGeos)
{
m_numDrawableGeos = numDrawableGeos;
}
//--------------------------------------------------------------------------------------------------
/// Set if effects should be randomly or sequentially assigned.
//--------------------------------------------------------------------------------------------------
void PartCompoundGenerator::useRandomEffectAssignment(bool use)
{
m_randomEffectAssignment = use;
}
//--------------------------------------------------------------------------------------------------
/// Generate the parts using box primitives
//--------------------------------------------------------------------------------------------------
void PartCompoundGenerator::generateBoxes(cvf::Collection<cvf::Part>* parts)
{
generateParts(BOX, cvf::UNDEFINED_INT, cvf::UNDEFINED_INT, parts);
}
//--------------------------------------------------------------------------------------------------
/// Generate the parts using sphere primitives
//--------------------------------------------------------------------------------------------------
void PartCompoundGenerator::generateSpheres(uint numSlices, uint numStacks, cvf::Collection<cvf::Part>* parts)
{
generateParts(SPHERE, numSlices, numStacks, parts);
}
//--------------------------------------------------------------------------------------------------
/// Generate the parts using sphere primitives
//--------------------------------------------------------------------------------------------------
void PartCompoundGenerator::generateTriangles(cvf::Collection<cvf::Part>* parts)
{
generateParts(TRIANGLE, cvf::UNDEFINED_INT, cvf::UNDEFINED_INT, parts);
}
//--------------------------------------------------------------------------------------------------
/// Generate x*y*z parts with either spheres or boxes
//--------------------------------------------------------------------------------------------------
void PartCompoundGenerator::generateParts(GenPrimType primType, uint numSlices, uint numStacks, cvf::Collection<cvf::Part>* parts)
{
// -1 -> one effect/geo per part
uint numEffects = m_numEffects > 0 ? static_cast<uint>(m_numEffects) : numParts();
uint numDrawableGeos = m_numDrawableGeos > 0 ? static_cast<uint>(m_numDrawableGeos) : numParts();
// Setup effects
cvf::Collection<cvf::Effect> effectCollection;
cvf::ShaderProgramGenerator shaderGen("SimpleHeadlight", cvf::ShaderSourceProvider::instance());
shaderGen.configureStandardHeadlightColor();
//shaderGen.addVertexCode(cvf::ShaderSourceRepository::vs_Minimal);
//shaderGen.addFragmentCode(cvf::ShaderSourceRepository::src_Color);
//shaderGen.addFragmentCode(cvf::ShaderSourceRepository::fs_Unlit);
uint i;
for (i = 0; i < numEffects; i++)
{
ref<cvf::Effect> effect = new cvf::Effect;
ref<cvf::RenderStateMaterial_FF> material = new cvf::RenderStateMaterial_FF;
material->setAmbientAndDiffuse(DEFAULT_EFFECT_COLORS[i % NUM_EFFECTS]);
material->setSpecular(cvf::Color3f(0.4f, 0.4f, 0.4f));
material->setShininess(10.0f);
effect->setRenderState(material.p());
// Also create a uniform for the color
effect->setUniform(new cvf::UniformFloat("u_color", cvf::Color4f(DEFAULT_EFFECT_COLORS[i % NUM_EFFECTS])));
if (m_useShaders)
{
ref<cvf::ShaderProgram> prog = shaderGen.generate();
effect->setShaderProgram(prog.p());
}
effectCollection.push_back(effect.p());
}
// Setup Geometries
Vec3f delta;
delta.x() = m_extent.x()/static_cast<float>(m_partDistribution.x());
delta.y() = m_extent.y()/static_cast<float>(m_partDistribution.y());
delta.z() = m_extent.z()/static_cast<float>(m_partDistribution.z());
// Find min delta and set the diameter of the sphere to 80% of the smallest delta, hence radius is * 0.4
double radius = static_cast<double>(CVF_MIN(CVF_MIN(delta.x(), delta.y()), delta.z()))*0.4f;
cvf::Collection<cvf::DrawableGeo> drawableGeoCollection;
for (i = 0; i < numDrawableGeos; i++)
{
ref<cvf::DrawableGeo> geo = new cvf::DrawableGeo;
cvf::GeometryBuilderFaceList builder;
switch (primType)
{
case SPHERE:
{
cvf::GeometryUtils::createSphere(radius, numSlices, numStacks, &builder);
break;
}
case BOX:
{
cvf::GeometryUtils::createBox(Vec3f(0,0,0), delta.x()*0.8f, delta.y()*0.8f, delta.z()*0.8f, &builder);
break;
}
case TRIANGLE:
{
cvf::Vec3fArray vertices;
vertices.reserve(3);
vertices.add(Vec3f(-0.4f*delta.x(), -0.4f*delta.y(), 0));
vertices.add(Vec3f( 0.4f*delta.x(), -0.4f*delta.y(), 0));
vertices.add(Vec3f( 0, 0.4f*delta.y(), 0));
builder.addTriangle(0,1,2);
builder.addVertices(vertices);
break;
}
default:
{
CVF_FAIL_MSG("Unknown type!");
break;
}
}
ref<cvf::Vec3fArray> vertices = builder.vertices();
ref<cvf::UIntArray> faceList = builder.faceList();
geo->setVertexArray(vertices.p());
geo->setFromFaceList(*faceList);
geo->computeNormals();
drawableGeoCollection.push_back(geo.p());
}
// Generate the parts
int partIndex = 0;
int z;
for (z = 0; z < m_partDistribution.z(); z++)
{
int y;
for (y = 0; y < m_partDistribution.y(); y++)
{
int x;
for (x = 0; x < m_partDistribution.x(); x++)
{
// Effect selection
uint effectIndex = 0;
if (m_randomEffectAssignment)
{
effectIndex = rand() % static_cast<uint>(numEffects);
}
else
{
effectIndex = partIndex%static_cast<uint>(numEffects);
}
// Geometry selection
uint drawableGeoIndex = 0;
if (m_randomGeoAssignment)
{
drawableGeoIndex = rand() % static_cast<uint>(numDrawableGeos);
}
else
{
drawableGeoIndex = partIndex%static_cast<uint>(numDrawableGeos);
}
// Setup the transform
cvf::Mat4d transMat;
Vec3d translation( m_origin.x() + delta.x()*(0.5f + static_cast<float>(x)),
m_origin.y() + delta.y()*(0.5f + static_cast<float>(y)),
m_origin.z() + delta.z()*(0.5f + static_cast<float>(z)));
transMat.setTranslation(translation);
cvf::Transform* transform = new cvf::Transform;
transform->setLocalTransform(transMat);
// Configure the part
ref<cvf::Part> part = new cvf::Part;
part->setId(partIndex);
part->setName("Part " + cvf::String(partIndex));
part->setEffect(effectCollection[effectIndex].p());
part->setDrawable(drawableGeoCollection[drawableGeoIndex].p());
part->setTransform(transform);
parts->push_back(part.p());
partIndex++;
}
}
}
}
} // namespace cvfu

View File

@ -0,0 +1,91 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfCollection.h"
#include "cvfPart.h"
#include "cvfVector3.h"
namespace cvfu {
//==================================================================================================
//
// PartCompoundGenerator
//
//==================================================================================================
class PartCompoundGenerator : public cvf::Object
{
public:
PartCompoundGenerator();
void setExtent(cvf::Vec3f extent);
void setOrigin(cvf::Vec3f origin);
void setPartDistribution(cvf::Vec3i partDistribution);
void setUseShaders(bool useShaders);
void setNumEffects(int numEffects);
void setNumDrawableGeos(int numDrawableGeos);
void useRandomEffectAssignment(bool use);
void generateBoxes(cvf::Collection<cvf::Part>* parts);
void generateSpheres(cvf::uint numSlices, cvf::uint numStacks, cvf::Collection<cvf::Part>* parts);
void generateTriangles(cvf::Collection<cvf::Part>* parts);
int numParts() const;
private:
enum GenPrimType
{
BOX,
SPHERE,
TRIANGLE
};
cvf::Vec3i m_partDistribution;
cvf::Vec3f m_extent;
cvf::Vec3f m_origin;
bool m_useShaders;
int m_numEffects;
int m_numDrawableGeos;
bool m_randomEffectAssignment;
bool m_randomGeoAssignment;
void generateParts(GenPrimType primType, cvf::uint numSlices, cvf::uint numStacks, cvf::Collection<cvf::Part>* parts);
};
}

View File

@ -0,0 +1,141 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfUniform.h"
#include "cvfUniformSet.h"
#include "cvfTransform.h"
#include "cvfCamera.h"
#include "cvfRendering.h"
#include "cvfuPointLight.h"
namespace cvfu {
using cvf::ref;
using cvf::Vec3d;
using cvf::Vec3f;
using cvf::Mat4d;
//==================================================================================================
///
/// \class cvfu::PointLight
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PointLight::PointLight()
: m_position(0, 0, 0),
m_uniformSet(new cvf::UniformSet),
m_markerTransform(new cvf::Transform)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PointLight::~PointLight()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PointLight::setPosition(Vec3d position)
{
m_position = position;
Mat4d m;
m.setTranslation(m_position);
m_markerTransform->setLocalTransform(m);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Vec3d PointLight::position() const
{
return m_position;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PointLight::update(cvf::Rendering* rendering)
{
m_uniformSet->setUniform(new cvf::UniformFloat("u_wcLightPosition", Vec3f(m_position)));
cvf::Camera* cam = rendering->camera();
const Mat4d& vm = cam->viewMatrix();
Vec3f ecPos = Vec3f(m_position.getTransformedPoint(vm));
m_uniformSet->setUniform(new cvf::UniformFloat("u_ecLightPosition", ecPos));
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::UniformSet* PointLight::uniformSet()
{
return m_uniformSet.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Transform* PointLight::markerTransform()
{
return m_markerTransform.p();
}
} // namespace cvfu

View File

@ -0,0 +1,79 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfDynamicUniformSet.h"
#include "cvfVector3.h"
namespace cvf {
class UniformSet;
class Transform;
}
namespace cvfu {
//==================================================================================================
//
//
//
//==================================================================================================
class PointLight : public cvf::DynamicUniformSet
{
public:
PointLight();
~PointLight();
void setPosition(cvf::Vec3d position);
cvf::Vec3d position() const;
virtual void update(cvf::Rendering* rendering);
virtual cvf::UniformSet* uniformSet();
cvf::Transform* markerTransform();
private:
cvf::Vec3d m_position;
cvf::ref<cvf::UniformSet> m_uniformSet;
cvf::ref<cvf::Transform> m_markerTransform;
};
}

View File

@ -0,0 +1,520 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfMath.h"
#include "cvfuProperty.h"
namespace cvfu {
//==================================================================================================
///
/// \class cvfu::Property
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Property::Property(const cvf::String& name)
: m_name(name)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::String& Property::name() const
{
return m_name;
}
//==================================================================================================
///
/// \class cvfu::PropertyBool
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PropertyBool::PropertyBool(const cvf::String& name, bool value)
: Property(name),
m_value(value)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PropertyBool::value() const
{
return m_value;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PropertyBool::setValue(bool val)
{
m_value = val;
}
//==================================================================================================
///
/// \class cvfu::PropertyInt
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PropertyInt::PropertyInt(const cvf::String& name, int value)
: Property(name),
m_min(0),
m_max(-1),
m_guiStep(-1),
m_value(value)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int PropertyInt::value() const
{
return m_value;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PropertyInt::setValue(int val)
{
if (m_min <= m_max)
{
if (!cvf::Math::valueInRange(val, m_min, m_max))
{
return false;
}
}
m_value = val;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PropertyInt::setRange(int min, int max)
{
m_min = min;
m_max = max;
if (m_min <= m_max)
{
m_value = cvf::Math::clamp(m_value, m_min, m_max);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int PropertyInt::min() const
{
return m_min;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int PropertyInt::max() const
{
return m_max;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PropertyInt::setGuiStep(int step)
{
m_guiStep = step;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int PropertyInt::guiStep() const
{
if (m_guiStep > 0)
{
return m_guiStep;
}
else
{
int singleStep = CVF_MAX(1, (m_max - m_min)/100);
return singleStep;
}
}
//==================================================================================================
///
/// \class cvfu::PropertyDouble
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PropertyDouble::PropertyDouble(const cvf::String& name, double value)
: Property(name),
m_min(0),
m_max(-1),
m_guiStep(-1),
m_decimals(2),
m_value(value)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double PropertyDouble::value() const
{
return m_value;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PropertyDouble::setValue(double val)
{
if (m_min <= m_max)
{
if (!cvf::Math::valueInRange(val, m_min, m_max))
{
return false;
}
}
m_value = val;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PropertyDouble::setRange(double min, double max)
{
m_min = min;
m_max = max;
if (m_min <= m_max)
{
m_value = cvf::Math::clamp(m_value, m_min, m_max);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double PropertyDouble::min() const
{
return m_min;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double PropertyDouble::max() const
{
return m_max;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PropertyDouble::setGuiStep(double step)
{
m_guiStep = step;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double PropertyDouble::guiStep() const
{
if (m_guiStep > 0)
{
return m_guiStep;
}
else
{
double singleStep = CVF_MAX(0.0, (m_max - m_min)/100.0);
return singleStep;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PropertyDouble::setDecimals(cvf::uint numDecimals)
{
m_decimals = numDecimals;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::uint PropertyDouble::decimals() const
{
return m_decimals;
}
//==================================================================================================
///
/// \class cvfu::PropertyEnum
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PropertyEnum::PropertyEnum(const cvf::String& name)
: Property(name),
m_currentIndex(0)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::uint PropertyEnum::itemCount() const
{
return static_cast<cvf::uint>(m_itemTexts.size());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PropertyEnum::addItem(const cvf::String& ident, const cvf::String& text)
{
m_itemIds.push_back(ident);
m_itemTexts.push_back(text);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PropertyEnum::clearAllItems()
{
m_itemIds.clear();
m_itemTexts.clear();
m_currentIndex = 0;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::String PropertyEnum::itemText(cvf::uint index) const
{
return m_itemTexts[index];
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::uint PropertyEnum::currentIndex() const
{
return m_currentIndex;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PropertyEnum::setCurrentIndex(cvf::uint index)
{
if (index >= itemCount())
{
return false;
}
m_currentIndex = index;
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::String PropertyEnum::currentIdent() const
{
if (m_currentIndex < itemCount())
{
return m_itemIds[m_currentIndex];
}
else
{
return "";
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool PropertyEnum::setCurrentIdent(cvf::String ident)
{
std::vector<cvf::String>::iterator it = std::find(m_itemIds.begin(), m_itemIds.end(), ident);
if (it == m_itemIds.end())
{
return false;
}
m_currentIndex = static_cast<cvf::uint>(it - m_itemIds.begin());
return true;
}
//==================================================================================================
///
/// \class cvfu::PropertySet
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PropertySet::PropertySet()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t PropertySet::count() const
{
return m_properties.size();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void PropertySet::add(Property* property)
{
CVF_ASSERT(property);
// Illegal to add a property twice
CVF_ASSERT(std::find(m_properties.begin(), m_properties.end(), property) == m_properties.end());
m_properties.push_back(property);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Property* PropertySet::property(size_t index)
{
return m_properties.at(index);
}
} // namespace cvfu

View File

@ -0,0 +1,185 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfCollection.h"
#include "cvfString.h"
namespace cvfu {
//==================================================================================================
//
// Property
//
//==================================================================================================
class Property : public cvf::Object
{
public:
Property(const cvf::String& name);
const cvf::String& name() const;
private:
cvf::String m_name;
};
//==================================================================================================
//
// PropertyBool
//
//==================================================================================================
class PropertyBool : public Property
{
public:
PropertyBool(const cvf::String& name, bool value);
bool value() const;
void setValue(bool val);
private:
bool m_value;
};
//==================================================================================================
//
// PropertyInt
//
//==================================================================================================
class PropertyInt : public Property
{
public:
PropertyInt(const cvf::String& name, int value);
void setRange(int min, int max);
int min() const;
int max() const;
void setGuiStep(int step);
int guiStep() const;
int value() const;
bool setValue(int val);
private:
int m_min; // Min/max legal values
int m_max; // If min > max, the range is unlimited
int m_guiStep; // Stepping when stepping is allowed in GUI. A value of 0 or less means auto.
int m_value;
};
//==================================================================================================
//
// PropertyDouble
//
//==================================================================================================
class PropertyDouble : public Property
{
public:
PropertyDouble(const cvf::String& name, double value);
void setRange(double min, double max);
double min() const;
double max() const;
void setGuiStep(double step);
double guiStep() const;
void setDecimals(cvf::uint numDecimals);
cvf::uint decimals() const;
double value() const;
bool setValue(double val);
private:
double m_min;
double m_max;
double m_guiStep;
cvf::uint m_decimals;
double m_value;
};
//==================================================================================================
//
// PropertyEnum
//
//==================================================================================================
class PropertyEnum : public Property
{
public:
PropertyEnum(const cvf::String& name);
cvf::uint itemCount() const;
void addItem(const cvf::String& ident, const cvf::String& text);
void clearAllItems();
cvf::String itemText(cvf::uint index) const;
cvf::uint currentIndex() const;
bool setCurrentIndex(cvf::uint index);
cvf::String currentIdent() const;
bool setCurrentIdent(cvf::String ident);
private:
std::vector<cvf::String> m_itemIds;
std::vector<cvf::String> m_itemTexts;
cvf::uint m_currentIndex;
};
//==================================================================================================
//
// PropertySet
//
//==================================================================================================
class PropertySet : public cvf::Object
{
public:
PropertySet();
size_t count() const;
void add(Property* property);
Property* property(size_t index);
private:
cvf::Collection<Property> m_properties;
};
}

View File

@ -0,0 +1,196 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfuSampleFactory.h"
#include "cvfCamera.h"
#include "cvfScene.h"
#include "cvfPrimitiveSetIndexedUShort.h"
#include "cvfArray.h"
#include "cvfModelBasicList.h"
#include "cvfSampler.h"
#include "cvfDrawableGeo.h"
#include "cvfEffect.h"
#include "cvfShaderProgram.h"
#include "cvfShaderSourceProvider.h"
#include "cvfGeometryBuilderDrawableGeo.h"
#include "cvfGeometryUtils.h"
#include "cvfUniform.h"
#include "cvfShaderProgramGenerator.h"
#include "cvfRenderStateTextureBindings.h"
namespace cvfu {
using cvf::ref;
using cvf::Vec3f;
using cvf::Vec2f;
using cvf::Vec3d;
//==================================================================================================
///
/// \class cvfu::SampleFactory
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ref<cvf::Part> SampleFactory::createTexturedQuad(cvf::Texture* texture, float aspectRatio)
{
ref<cvf::Sampler> sampler = new cvf::Sampler;
sampler->setWrapMode(cvf::Sampler::CLAMP_TO_EDGE);
sampler->setMinFilter(cvf::Sampler::NEAREST);
sampler->setMagFilter(cvf::Sampler::NEAREST);
return createTexturedQuad(texture, sampler.p(), aspectRatio);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> SampleFactory::createTexturedQuad(cvf::Texture* texture, cvf::Sampler* sampler, float aspectRatio)
{
CVF_ASSERT(texture);
CVF_ASSERT(sampler);
ref<cvf::PrimitiveSetIndexedUShort> quad = new cvf::PrimitiveSetIndexedUShort(cvf::PT_TRIANGLES);
ref<cvf::UShortArray> triIndices = new cvf::UShortArray;
triIndices->reserve(6);
triIndices->add(0);
triIndices->add(1);
triIndices->add(2);
triIndices->add(0);
triIndices->add(2);
triIndices->add(3);
quad->setIndices(triIndices.p());
ref<cvf::Vec3fArray> quadVerts = new cvf::Vec3fArray;
quadVerts->reserve(4);
float scaleX = 1.0f;
float scaleY = 1.0f;
if (aspectRatio > 1.0)
{
scaleY /= aspectRatio;
}
if (aspectRatio < 1.0)
{
scaleX *= aspectRatio;
}
quadVerts->add(Vec3f(0,0,0));
quadVerts->add(Vec3f(1*scaleX,0,0));
quadVerts->add(Vec3f(1*scaleX,1*scaleY,0));
quadVerts->add(Vec3f(0,1*scaleY,0));
ref<cvf::Vec2fArray> textureCoords = new cvf::Vec2fArray;
textureCoords->reserve(4);
textureCoords->add(Vec2f(0,0));
textureCoords->add(Vec2f(1,0));
textureCoords->add(Vec2f(1,1));
textureCoords->add(Vec2f(0,1));
ref<cvf::DrawableGeo> geo1 = new cvf::DrawableGeo;
geo1->addPrimitiveSet(quad.p());
geo1->setVertexArray(quadVerts.p());
geo1->setTextureCoordArray(textureCoords.p());
geo1->computeNormals();
ref<cvf::Part> part1 = new cvf::Part;
part1->setDrawable(geo1.p());
ref<cvf::Effect> eff1 = new cvf::Effect;
part1->setEffect(eff1.p());
// Setup the texture binding render state
ref<cvf::RenderStateTextureBindings> textureBindings = new cvf::RenderStateTextureBindings;
textureBindings->addBinding(texture, sampler, "u_texture2D");
eff1->setRenderState(textureBindings.p());
cvf::ShaderProgramGenerator gen("TexturedQuad", cvf::ShaderSourceProvider::instance());
gen.addVertexCode(cvf::ShaderSourceRepository::vs_Standard);
gen.addFragmentCode(cvf::ShaderSourceRepository::src_Texture);
gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Unlit);
ref<cvf::ShaderProgram> prog = gen.generate();
eff1->setShaderProgram(prog.p());
part1->updateBoundingBox();
return part1;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ref<cvf::Part> SampleFactory::createUnlitSphere(double radius, cvf::Color3f color)
{
cvf::GeometryBuilderDrawableGeo builder;
cvf::GeometryUtils::createSphere(radius, 10, 10, &builder);
ref<cvf::DrawableGeo> geo = builder.drawableGeo();
geo->computeNormals();
ref<cvf::Part> part = new cvf::Part;
part->setDrawable(geo.p());
cvf::ShaderProgramGenerator gen("UnlitSphere", cvf::ShaderSourceProvider::instance());
gen.addVertexCode(cvf::ShaderSourceRepository::vs_Minimal);
gen.addFragmentCode(cvf::ShaderSourceRepository::src_Color);
gen.addFragmentCode(cvf::ShaderSourceRepository::fs_Unlit);
ref<cvf::ShaderProgram> prog = gen.generate();
ref<cvf::Effect> eff = new cvf::Effect;
eff->setShaderProgram(prog.p());
eff->setUniform(new cvf::UniformFloat("u_color", cvf::Color4f(color)));
part->setEffect(eff.p());
return part;
}
} // namespace cvfu

View File

@ -0,0 +1,62 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfRendering.h"
#include "cvfPart.h"
#include "cvfTexture.h"
namespace cvfu {
//==================================================================================================
//
// SampleFactory
//
//==================================================================================================
class SampleFactory
{
public:
static cvf::ref<cvf::Part> createTexturedQuad(cvf::Texture* texture, float aspectRatio);
static cvf::ref<cvf::Part> createTexturedQuad(cvf::Texture* texture, cvf::Sampler* sampler, float aspectRatio);
static cvf::ref<cvf::Part> createUnlitSphere(double radius, cvf::Color3f color);
};
}

View File

@ -0,0 +1,221 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfuSnippetFactory.h"
namespace cvfu {
using cvf::ref;
//==================================================================================================
///
/// \class cvfu::SnippetInfo
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
SnippetInfo::SnippetInfo(const cvf::String& id_, const cvf::String& name_)
: id(id_),
name(name_)
{
}
//==================================================================================================
///
/// \class cvfu::SnippetFactory
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SnippetFactory::setTestDataDir(const cvf::String& testDataDir)
{
m_testDataDir = testDataDir;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<SnippetInfo> SnippetFactory::availableSnippets(SnippetCategoryFlags categoryFlags) const
{
std::vector<SnippetInfo> si;
std::vector<SnippetMeta>::const_iterator it;
for (it = m_registeredSnippets.begin(); it != m_registeredSnippets.end(); it++)
{
if (categoryFlags.testFlag(it->category))
{
cvf::String id = it->id;
create_inst_func_ptr_type createSnipInstFuncPtr = it->createInstFuncPtr;
// Create a live object and query for name
TestSnippet* snippet = createSnipInstFuncPtr();
si.push_back(SnippetInfo(id, snippet->name()));
}
}
return si;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ref<TestSnippet> SnippetFactory::createSnippet(const cvf::String& id) const
{
std::vector<SnippetMeta>::const_iterator it;
for (it = m_registeredSnippets.begin(); it != m_registeredSnippets.end(); it++)
{
if (it->id == id)
{
// Looks funky, but is actually a function pointer.
// The effect is to call the function that performs new on the snippet
ref<TestSnippet> snippet = it->createInstFuncPtr();
snippet->setTestDataDir(m_testDataDir);
return snippet;
}
}
return NULL;
}
//==================================================================================================
///
/// \class cvfu::SnippetRegistry
/// \ingroup Utilities
///
///
///
//==================================================================================================
SnippetRegistry* SnippetRegistry::m_instance = NULL;
//--------------------------------------------------------------------------------------------------
/// Private constructor
//--------------------------------------------------------------------------------------------------
SnippetRegistry::SnippetRegistry()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
SnippetRegistry* SnippetRegistry::instance()
{
if (!m_instance)
{
m_instance = new SnippetRegistry;
}
return m_instance;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SnippetRegistry::addFactory(SnippetFactory* factory)
{
m_factories.push_back(factory);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<SnippetInfo> SnippetRegistry::availableSnippets(SnippetCategoryFlags categoryFlags) const
{
std::vector<SnippetInfo> availableSI;
size_t numFactories = m_factories.size();
size_t i;
for (i = 0; i < numFactories; i++)
{
const SnippetFactory* factory = m_factories[i];
std::vector<SnippetInfo> si = factory->availableSnippets(categoryFlags);
availableSI.insert(availableSI.end(), si.begin(), si.end());
}
return availableSI;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
ref<TestSnippet> SnippetRegistry::createSnippet(const cvf::String& id) const
{
ref<TestSnippet> newSnippet;
size_t numFactories = m_factories.size();
size_t i;
for (i = 0; i < numFactories; i++)
{
const SnippetFactory* factory = m_factories[i];
ref<TestSnippet> newSnippet = factory->createSnippet(id);
if (newSnippet.notNull())
{
return newSnippet;
}
}
return NULL;
}
} // namespace cvfu

View File

@ -0,0 +1,148 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfuTestSnippet.h"
namespace cvfu {
// Categorization of snippets
enum SnippetCategory
{
SC_TEST = 0x00000001, // Ordinary test snippets
SC_TEST_HEAVY = 0x00000002, // Test snippets, heavy (long load time, high memory usage, etc)
SC_EXPERIMENT = 0x00000004, //
SC_ALL = 0xffffffff, // All categories
SC_ALL_TESTS = SC_TEST | SC_TEST_HEAVY // All test categories
};
typedef cvf::Flags<SnippetCategory> SnippetCategoryFlags;
//==================================================================================================
//
//
//
//==================================================================================================
class SnippetInfo
{
public:
SnippetInfo(const cvf::String& id, const cvf::String& name);
public:
cvf::String id; // Textual ID of the snippet
cvf::String name; // Human readable name of the snippet
};
//==================================================================================================
//
// Base class for factory for creating instances of TestSnippets
//
//==================================================================================================
class SnippetFactory
{
public:
void setTestDataDir(const cvf::String& testDataDir);
std::vector<SnippetInfo> availableSnippets(SnippetCategoryFlags categoryFlags) const;
cvf::ref<TestSnippet> createSnippet(const cvf::String& id) const;
protected:
template<typename T>
void registerSnippet(const cvf::String& snippetId, SnippetCategory snippetCategory)
{
SnippetMeta snipMeta;
snipMeta.id = snippetId;
snipMeta.category = snippetCategory;
snipMeta.createInstFuncPtr = &SnippetFactory::createSnippetInstance<T>;
m_registeredSnippets.push_back(snipMeta);
}
private:
template<typename T>
static TestSnippet* createSnippetInstance()
{
return new T;
}
private:
typedef TestSnippet*(*create_inst_func_ptr_type)();
struct SnippetMeta
{
cvf::String id;
SnippetCategory category;
create_inst_func_ptr_type createInstFuncPtr;
};
cvf::String m_testDataDir; // Directory for test data available to snippets
std::vector<SnippetMeta> m_registeredSnippets; // Array of snippets that this factory is capable of creating
};
//==================================================================================================
//
// Registry for registering factories to create instances of all TestSnippets
//
//==================================================================================================
class SnippetRegistry
{
public:
static SnippetRegistry* instance();
void addFactory(SnippetFactory* factory);
std::vector<SnippetInfo> availableSnippets(SnippetCategoryFlags categoryFlags) const;
cvf::ref<TestSnippet> createSnippet(const cvf::String& id) const;
private:
SnippetRegistry();
private:
static SnippetRegistry* m_instance;
std::vector<SnippetFactory*> m_factories;
};
}
// Helper macro to use when registering snippets in a snippet factory constructor
#define CVFU_REGISTER_SNIPPET(SNIPPET_CLASS, SNIPPET_CAT) registerSnippet<SNIPPET_CLASS>(#SNIPPET_CLASS, SNIPPET_CAT);

View File

@ -0,0 +1,132 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfuSnippetPropertyPublisher.h"
#include "cvfuProperty.h"
namespace cvfu {
//==================================================================================================
///
/// \class cvfu::SnippetPropertyPublisher
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
SnippetPropertyPublisher::SnippetPropertyPublisher()
: m_publishedPropertySet(new PropertySet),
m_callback(NULL)
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
SnippetPropertyPublisher::~SnippetPropertyPublisher()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SnippetPropertyPublisher::publishProperty(Property* property)
{
m_publishedPropertySet->add(property);
if (m_callback)
{
m_callback->onPublishedPropertySetChanged();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
PropertySet* SnippetPropertyPublisher::publishedPropertySet()
{
return m_publishedPropertySet.p();
}
//--------------------------------------------------------------------------------------------------
/// Should be called when a snippet modifies a property in some way (including the value and config)
//--------------------------------------------------------------------------------------------------
void SnippetPropertyPublisher::notifyPropertyChangedBySnippet(Property* property)
{
if (m_callback)
{
m_callback->onPropertyChangedBySnippet(property);
}
}
//--------------------------------------------------------------------------------------------------
/// Should be called when a snippet changes the value of a property
//--------------------------------------------------------------------------------------------------
void SnippetPropertyPublisher::notifyPropertyValueChangedBySnippet(Property* property)
{
if (m_callback)
{
m_callback->onPropertyValueChangedBySnippet(property);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void SnippetPropertyPublisher::registerCallback(SnippetPropertyPublisherCallback* callback)
{
m_callback = callback;
}
} // namespace cvfu

View File

@ -0,0 +1,92 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
namespace cvfu {
class Property;
class PropertySet;
class SnippetPropertyPublisherCallback;
//==================================================================================================
//
// SnippetPropertyPublisher
//
//==================================================================================================
class SnippetPropertyPublisher : public cvf::Object
{
public:
SnippetPropertyPublisher();
virtual ~SnippetPropertyPublisher();
void publishProperty(Property* property);
PropertySet* publishedPropertySet();
void notifyPropertyChangedBySnippet(Property* property);
void notifyPropertyValueChangedBySnippet(Property* property);
void registerCallback(SnippetPropertyPublisherCallback* callback);
private:
cvf::ref<PropertySet> m_publishedPropertySet; // The set of properties that are currently published
SnippetPropertyPublisherCallback* m_callback; // Should really hold a ref here, but prefer not to derive from Object
};
//==================================================================================================
//
// SnippetPropertyPublisherCallback
//
//==================================================================================================
class SnippetPropertyPublisherCallback
{
public:
virtual ~SnippetPropertyPublisherCallback() {}
virtual void onPublishedPropertySetChanged() = 0;
virtual void onPropertyChangedBySnippet(cvfu::Property* property) = 0;
virtual void onPropertyValueChangedBySnippet(cvfu::Property* property) = 0;
};
}

View File

@ -0,0 +1,389 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfRenderSequence.h"
#include "cvfRendering.h"
#include "cvfScene.h"
#include "cvfModel.h"
#include "cvfCamera.h"
#include "cvfRenderQueueSorter.h"
#include "cvfRayIntersectSpec.h"
#include "cvfHitItemCollection.h"
#include "cvfHitItem.h"
#include "cvfOpenGL.h"
#include "cvfOpenGLResourceManager.h"
#include "cvfTrace.h"
#include "cvfDebugTimer.h"
#include "cvfuTestSnippet.h"
#include "cvfuInputEvents.h"
#include "cvfuSnippetPropertyPublisher.h"
namespace cvfu {
using cvf::ref;
//==================================================================================================
///
/// \class cvfu::TestSnippet
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TestSnippet::TestSnippet()
{
m_propertyPublisher = new SnippetPropertyPublisher;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
TestSnippet::~TestSnippet()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TestSnippet::setTestDataDir(const cvf::String& testDataDir)
{
m_testDataDir = testDataDir;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool TestSnippet::initializeSnippet(cvf::OpenGLContext* oglContext)
{
CVF_ASSERT(oglContext);
m_openGLContext = oglContext;
m_renderSequence = new cvf::RenderSequence;
m_camera = new cvf::Camera;
m_trackball = new cvf::ManipulatorTrackball;
m_trackball->setCamera(m_camera.p());
ref<cvf::Scene> scene = new cvf::Scene;
ref<cvf::Rendering> rendering = new cvf::Rendering("snipRendering");
rendering->setScene(scene.p());
rendering->setCamera(m_camera.p());
ref<cvf::RenderQueueSorter> sorter = new cvf::RenderQueueSorterBasic(cvf::RenderQueueSorterBasic::EFFECT_ONLY);
rendering->setRenderQueueSorter(sorter.p());
m_renderSequence->addRendering(rendering.p());
m_openGLContext->makeCurrent();
CVF_CHECK_OGL(m_openGLContext.p());
bool initOK = onInitialize();
CVF_CHECK_OGL(m_openGLContext.p());
return initOK;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TestSnippet::destroySnippet()
{
CVF_ASSERT(m_openGLContext.notNull());
m_openGLContext->makeCurrent();
if (m_renderSequence.notNull())
{
m_renderSequence->deleteOrReleaseOpenGLResources(m_openGLContext.p());
}
cvf::OpenGLResourceManager* resourceManager = m_openGLContext->resourceManager();
CVF_ASSERT(resourceManager);
resourceManager->deleteAllOpenGLResources(m_openGLContext.p());
m_openGLContext = NULL;
m_trackball = NULL;
m_camera = NULL;
m_renderSequence = NULL;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::RenderSequence* TestSnippet::renderSequence()
{
return m_renderSequence.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::RenderSequence* TestSnippet::renderSequence() const
{
return m_renderSequence.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::Camera* TestSnippet::camera()
{
return m_camera.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const cvf::Camera* TestSnippet::camera() const
{
return m_camera.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TestSnippet::onResizeEvent(int width, int height)
{
cvf::uint uiWidth = width > 0 ? static_cast<cvf::uint>(width) : 0;
cvf::uint uiHeight = height > 0 ? static_cast<cvf::uint>(height) : 0;
if (m_camera.notNull())
{
m_camera->setViewport(0, 0, uiWidth, uiHeight);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TestSnippet::onUpdateAnimation(double animationTime, PostEventAction* postEventAction)
{
CVF_UNUSED(animationTime);
if (postEventAction)
{
*postEventAction = NONE;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TestSnippet::onPaintEvent(PostEventAction* postEventAction)
{
CVF_ASSERT(m_openGLContext.notNull());
m_openGLContext->makeCurrent();
CVF_CHECK_OGL(m_openGLContext.p());
m_renderSequence->render(m_openGLContext.p());
CVF_CHECK_OGL(m_openGLContext.p());
if (postEventAction)
{
*postEventAction = NONE;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TestSnippet::onMousePressEvent(MouseButton buttonPressed, MouseEvent* mouseEvent)
{
//cvf::Trace::show("onMousePressEvent() bn=%d %s", buttonPressed, mouseEvent->toString().toAscii().ptr());
CVF_UNUSED(buttonPressed);
if (buttonPressed == LeftButton && mouseEvent->modifiers() == ControlModifier)
{
cvf::DebugTimer tim("Pick time");
cvf::Rendering* r = m_renderSequence->firstRendering();
ref<cvf::RayIntersectSpec> ris = r->rayIntersectSpecFromWindowCoordinates(mouseEvent->x(), mouseEvent->y());
cvf::HitItemCollection hic;
if (r->rayIntersect(*ris, &hic))
{
const cvf::HitItem* item = hic.firstItem();
CVF_ASSERT(item && item->part());
cvf::Vec3d rotPt = item->intersectionPoint();
m_trackball->setRotationPoint(rotPt);
cvf::Trace::show("Rotation point set to: %lf %lf %lf", rotPt.x(), rotPt.y(), rotPt.z());
}
tim.reportTimeMS();
return;
}
cvf::ManipulatorTrackball::NavigationType navType = getNavigationTypeFromMouseButtons(mouseEvent->buttons(), mouseEvent->modifiers());
m_trackball->startNavigation(navType, mouseEvent->x(), mouseEvent->y());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TestSnippet::onMouseMoveEvent(MouseEvent* mouseEvent)
{
//cvf::Trace::show("onMouseMoveEvent() %s", mouseEvent->toString().toAscii().ptr());
cvf::ManipulatorTrackball::NavigationType navType = getNavigationTypeFromMouseButtons(mouseEvent->buttons(), mouseEvent->modifiers());
if (navType != m_trackball->activeNavigation())
{
m_trackball->startNavigation(navType, mouseEvent->x(), mouseEvent->y());
}
bool needRedraw = m_trackball->updateNavigation(mouseEvent->x(), mouseEvent->y());
if (needRedraw)
{
mouseEvent->setRequestedAction(REDRAW);
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TestSnippet::onMouseReleaseEvent(MouseButton buttonReleased, MouseEvent* mouseEvent)
{
//cvf::Trace::show("onMouseReleaseEvent() bn=%d %s", buttonReleased, mouseEvent->toString().toAscii().ptr());
CVF_UNUSED(buttonReleased);
cvf::ManipulatorTrackball::NavigationType navType = getNavigationTypeFromMouseButtons(mouseEvent->buttons(), mouseEvent->modifiers());
if (navType != cvf::ManipulatorTrackball::NONE)
{
m_trackball->startNavigation(navType, mouseEvent->x(), mouseEvent->y());
}
else
{
m_trackball->endNavigation();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::ManipulatorTrackball::NavigationType TestSnippet::getNavigationTypeFromMouseButtons(MouseButtons mouseButtons, KeyboardModifiers keyboardModifiers)
{
if (mouseButtons == LeftButton)
{
return cvf::ManipulatorTrackball::PAN;
}
else if (mouseButtons == RightButton)
{
return cvf::ManipulatorTrackball::ROTATE;
}
else if (mouseButtons == MiddleButton || mouseButtons == (LeftButton | RightButton))
{
if (keyboardModifiers == ShiftModifier)
{
return cvf::ManipulatorTrackball::ZOOM;
}
else
{
return cvf::ManipulatorTrackball::WALK;
}
}
else
{
return cvf::ManipulatorTrackball::NONE;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TestSnippet::onKeyPressEvent(KeyEvent* keyEvent)
{
CVF_UNUSED(keyEvent);
//cvf::Trace::show("onKeyPressEvent() %s", keyEvent->toString().toAscii().ptr());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
SnippetPropertyPublisher* TestSnippet::propertyPublisher()
{
return m_propertyPublisher.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void TestSnippet::onPropertyChanged(Property* property, PostEventAction* postEventAction)
{
CVF_UNUSED(property);
CVF_UNUSED(postEventAction);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<cvf::String> TestSnippet::helpText() const
{
std::vector<cvf::String> defaultHelpText;
defaultHelpText.push_back("Default help text for this snippet. Please update.");
return defaultHelpText;
}
} // namespace cvfu

View File

@ -0,0 +1,114 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfObject.h"
#include "cvfuInputTypes.h"
#include "cvfManipulatorTrackball.h"
#include "cvfCollection.h"
#include "cvfString.h"
namespace cvf {
class OpenGLContext;
class RenderSequence;
class Camera;
}
namespace cvfu {
class MouseEvent;
class KeyEvent;
class Property;
class SnippetPropertyPublisher;
//==================================================================================================
//
// Base class for test snippets
//
//==================================================================================================
class TestSnippet : public cvf::Object
{
public:
TestSnippet();
virtual ~TestSnippet();
virtual const char* name() const = 0;
void setTestDataDir(const cvf::String& testDataDir);
bool initializeSnippet(cvf::OpenGLContext* oglContext);
void destroySnippet();
cvf::RenderSequence* renderSequence();
const cvf::RenderSequence* renderSequence() const;
cvf::Camera* camera();
const cvf::Camera* camera() const;
virtual bool onInitialize() = 0;
virtual void onResizeEvent(int width, int height);
virtual void onUpdateAnimation(double animationTime, PostEventAction* postEventAction);
virtual void onPaintEvent(PostEventAction* postEventAction);
virtual void onMousePressEvent(MouseButton buttonPressed, MouseEvent* mouseEvent);
virtual void onMouseMoveEvent(MouseEvent* mouseEvent);
virtual void onMouseReleaseEvent(MouseButton buttonReleased, MouseEvent* mouseEvent);
virtual void onKeyPressEvent(KeyEvent* keyEvent);
SnippetPropertyPublisher* propertyPublisher();
virtual void onPropertyChanged(Property* property, PostEventAction* postEventAction);
virtual std::vector<cvf::String> helpText() const;
private:
static cvf::ManipulatorTrackball::NavigationType getNavigationTypeFromMouseButtons(MouseButtons mouseButtons, KeyboardModifiers keyboardModifiers);
protected:
cvf::String m_testDataDir; // Directory where test data resides (set by snippet runner)
cvf::ref<cvf::OpenGLContext> m_openGLContext; //
cvf::ref<cvf::RenderSequence> m_renderSequence; // A render sequence configured with one Rendering containing one Scene
cvf::ref<cvf::Camera> m_camera; // Direct reference to the Rendering's Camera
cvf::ref<cvf::ManipulatorTrackball> m_trackball; // Manipulator, already configured with the camera
cvf::ref<SnippetPropertyPublisher> m_propertyPublisher; // For publishing any properties the snippet wants to expose
};
}
// Macro to use in header file when declaring a new snippet
#define CVFU_DECLARE_SNIPPET(SNIPPET_NAME) \
virtual const char* name() const { return SNIPPET_NAME; }

View File

@ -0,0 +1,272 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfBase.h"
#include "cvfGeometryBuilder.h"
#include "cvfuWavefrontObjImport.h"
#include <iostream>
#include <fstream>
#include <sstream>
#ifdef WIN32
#pragma warning (disable: 4996)
#endif
namespace cvfu {
using cvf::ref;
using cvf::Vec3f;
using cvf::Vec2f;
using cvf::Vec3d;
//==================================================================================================
///
/// \class cvfu::WavefrontObjImport
/// \ingroup Utilities
///
///
///
//==================================================================================================
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
WavefrontObjImport::WavefrontObjImport()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool WavefrontObjImport::readFile(const cvf::String& fileName)
{
std::ifstream file;
#ifdef WIN32
file.open(fileName.toAscii().ptr(), std::ios::in);
#else
file.open(fileName.toStdString().c_str(), std::ios::in);
#endif
if (!file.is_open())
{
return false;
}
std::string record = nextRecord(&file);
int vertexCount = 0;
while (!file.eof())
{
if (record.length() > 1)
{
if (record[0] == 'v' && record[1] == ' ')
{
// The v block contains vertex data
// format:
// v 0.1 0.2 0.3
// v 1.2 3.1 3.5
//
// Need to check for space as second character, as the file can also contain normals with block 'vn' and
// texture coordinates with block 'vt'
//
// No support for line continuation here, as this is never so far seen "in the wild"
//
char dummy;
double x = cvf::UNDEFINED_DOUBLE;
double y = cvf::UNDEFINED_DOUBLE;
double z = cvf::UNDEFINED_DOUBLE;
sscanf(record.c_str(), "%c %lf %lf %lf", &dummy, &x, &y, &z);
if (x > cvf::UNDEFINED_DOUBLE_THRESHOLD ||
y > cvf::UNDEFINED_DOUBLE_THRESHOLD ||
z > cvf::UNDEFINED_DOUBLE_THRESHOLD)
{
CVF_FAIL_MSG("Error reading file. Need error handling!");
return false;
}
// Add the node
m_nodes.push_back(x);
m_nodes.push_back(y);
m_nodes.push_back(z);
vertexCount++;
}
else if (record[0] == 'f' && record[1] == ' ')
{
// The f block contains face definitions
// All values are ONE based indices into the given vertex, normal or texture arrays
//
// Format:
// f v1 v2 v3 v4 ...
// f v1/vt1 v2/vt2 v3/vt3 ....
// f v1/vt1/vn1 v2/vt2/vn2 v3/vt3/vn3 ...
// f v1//vn1 v2//vn2 v3//vn3 ...
//
// Relative and absolute indices:
// The format also supports relative indices, so specifying a negative index means counting backwards from the last index defined
// -1 means the last index defined
//
// # example: 8 indices already defined
// f -2 -1 -4 -3
// # is equivalent to:
// f 7 8 5 6
std::vector<std::string> elems;
split(record, ' ', elems);
m_faceList.push_back(static_cast<cvf::uint>(elems.size()) - 1);
size_t i;
for (i = 1; i < elems.size(); i++)
{
int vertex = atoi(elems[i].c_str());
if (vertex > 0)
{
m_faceList.push_back(static_cast<cvf::uint>(vertex - 1));
}
else
{
// Note that vertex is negative, so this will subtract from vertexCount
// -1 is last index, so this will give zero based indices (file has one based)
int actualIndexZeroBased = vertexCount + vertex;
m_faceList.push_back(static_cast<cvf::uint>(actualIndexZeroBased));
}
}
}
}
record = nextRecord(&file);
}
// We now have a valid faceList and nodes.
// Update the IMesh with this data
//mesh->setFromFaceList(faceList);
//mesh->setNodes(nodes);
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::string WavefrontObjImport::nextRecord(std::ifstream* stream)
{
CVF_ASSERT(stream);
std::string record;
getline(*stream, record);
if (record.length() > 0)
{
while (record[record.length() - 1] == '\\')
{
std::string line;
getline(*stream, line);
record[record.length() - 1] = ' ';
record += line;
}
}
return record;
}
//--------------------------------------------------------------------------------------------------
/// Helper to split a string into elements based on a limiter. To be moved
//--------------------------------------------------------------------------------------------------
std::vector<std::string>& WavefrontObjImport::split(const std::string& s, char delim, std::vector<std::string>& elems)
{
std::stringstream ss(s);
std::string item;
while(std::getline(ss, item, delim))
{
if (item.length() > 0)
{
elems.push_back(item);
}
}
return elems;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void WavefrontObjImport::buildGeometry(cvf::GeometryBuilder* builder)
{
size_t numVertices = m_nodes.size()/3;
cvf::Vec3fArray vertexArray;
vertexArray.reserve(numVertices);
size_t i;
for (i = 0; i < numVertices; i++)
{
Vec3f v(static_cast<float>(m_nodes[3*i]), static_cast<float>(m_nodes[3*i + 1]), static_cast<float>(m_nodes[3*i + 2]));
vertexArray.add(v);
}
builder->addVertices(vertexArray);
size_t numFaceListEntries = m_faceList.size();
cvf::UIntArray faceIndices;
i = 0;
while (i < numFaceListEntries)
{
cvf::uint numFaceVertices = m_faceList[i++];
faceIndices.reserve(numFaceVertices);
faceIndices.setSizeZero();
size_t j;
for (j = 0; j < numFaceVertices; j++)
{
faceIndices.add((m_faceList[i++]));
}
builder->addFace(faceIndices);
}
}
} // namespace cvfu

View File

@ -0,0 +1,73 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfDrawableGeo.h"
namespace cvf {
class GeometryBuilder;
}
namespace cvfu {
//==================================================================================================
//
// Import of (partial) Wavefront OBJ files
//
//==================================================================================================
class WavefrontObjImport
{
public:
WavefrontObjImport();
bool readFile(const cvf::String& fileName);
void buildGeometry(cvf::GeometryBuilder* builder);
private:
static std::string nextRecord(std::ifstream* stream);
static std::vector<std::string>& split(const std::string& s, char delim, std::vector<std::string>& elems);
private:
std::vector<double> m_nodes;
std::vector<cvf::uint> m_faceList;
};
}

View File

@ -0,0 +1,305 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug MD TBB|Win32">
<Configuration>Debug MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD TBB|x64">
<Configuration>Debug MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|Win32">
<Configuration>Debug MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|x64">
<Configuration>Debug MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|Win32">
<Configuration>Release MD TBB</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD TBB|x64">
<Configuration>Release MD TBB</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|Win32">
<Configuration>Release MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|x64">
<Configuration>Release MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{122D4663-11D6-D12F-8748-629A34E9075E}</ProjectGuid>
<RootNamespace>LibViewing</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="Configuration">
<ConfigurationType>StaticLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../ThirdParty/TBB/include</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;_DEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../ThirdParty/TBB/include</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|Win32'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../ThirdParty/TBB/include</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD TBB|x64'">
<ClCompile>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>WIN32;NDEBUG;CVF_USE_TBB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>../LibCore;../LibRender;../LibGeometry;../ThirdParty/TBB/include</AdditionalIncludeDirectories>
<TreatWarningAsError>true</TreatWarningAsError>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="cvfClipPlaneSet.h" />
<ClInclude Include="cvfConstantFrameRate.h" />
<ClInclude Include="cvfCullSettings.h" />
<ClInclude Include="cvfDynamicUniformSet.h" />
<ClInclude Include="cvfEffect.h" />
<ClInclude Include="cvfFixedSizeTransform.h" />
<ClInclude Include="cvfGaussianBlur.h" />
<ClInclude Include="cvfHitItem.h" />
<ClInclude Include="cvfHitItemCollection.h" />
<ClInclude Include="cvfLibViewing.h" />
<ClInclude Include="cvfLocators.h" />
<ClInclude Include="cvfManipulatorTrackball.h" />
<ClInclude Include="cvfModel.h" />
<ClInclude Include="cvfModelBasicList.h" />
<ClInclude Include="cvfModelBasicTree.h" />
<ClInclude Include="cvfPart.h" />
<ClInclude Include="cvfPartHighlighter.h" />
<ClInclude Include="cvfPartRenderHintCollection.h" />
<ClInclude Include="cvfPerformanceInfo.h" />
<ClInclude Include="cvfRayIntersectSpec.h" />
<ClInclude Include="cvfRenderEngine.h" />
<ClInclude Include="cvfRendering.h" />
<ClInclude Include="cvfRenderQueue.h" />
<ClInclude Include="cvfRenderQueueBuilder.h" />
<ClInclude Include="cvfRenderQueueSorter.h" />
<ClInclude Include="cvfScene.h" />
<ClInclude Include="cvfSingleQuadRenderingGenerator.h" />
<ClInclude Include="cvfTransform.h" />
<ClInclude Include="cvfRenderSequence.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfClipPlaneSet.cpp" />
<ClCompile Include="cvfConstantFrameRate.cpp" />
<ClCompile Include="cvfCullSettings.cpp" />
<ClCompile Include="cvfDynamicUniformSet.cpp" />
<ClCompile Include="cvfEffect.cpp" />
<ClCompile Include="cvfFixedSizeTransform.cpp" />
<ClCompile Include="cvfGaussianBlur.cpp" />
<ClCompile Include="cvfHitItem.cpp" />
<ClCompile Include="cvfHitItemCollection.cpp" />
<ClCompile Include="cvfLocators.cpp" />
<ClCompile Include="cvfManipulatorTrackball.cpp" />
<ClCompile Include="cvfModel.cpp" />
<ClCompile Include="cvfModelBasicList.cpp" />
<ClCompile Include="cvfModelBasicTree.cpp" />
<ClCompile Include="cvfPart.cpp" />
<ClCompile Include="cvfPartHighlighter.cpp" />
<ClCompile Include="cvfPartRenderHintCollection.cpp" />
<ClCompile Include="cvfPerformanceInfo.cpp" />
<ClCompile Include="cvfRayIntersectSpec.cpp" />
<ClCompile Include="cvfRenderEngine.cpp" />
<ClCompile Include="cvfRendering.cpp" />
<ClCompile Include="cvfRenderQueue.cpp" />
<ClCompile Include="cvfRenderQueueBuilder.cpp" />
<ClCompile Include="cvfRenderQueueSorter.cpp" />
<ClCompile Include="cvfScene.cpp" />
<ClCompile Include="cvfSingleQuadRenderingGenerator.cpp" />
<ClCompile Include="cvfTransform.cpp" />
<ClCompile Include="cvfRenderSequence.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,67 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClInclude Include="cvfConstantFrameRate.h" />
<ClInclude Include="cvfCullSettings.h" />
<ClInclude Include="cvfEffect.h" />
<ClInclude Include="cvfLibViewing.h" />
<ClInclude Include="cvfLocators.h" />
<ClInclude Include="cvfManipulatorTrackball.h" />
<ClInclude Include="cvfModel.h" />
<ClInclude Include="cvfModelBasicList.h" />
<ClInclude Include="cvfModelBasicTree.h" />
<ClInclude Include="cvfPart.h" />
<ClInclude Include="cvfPartRenderHintCollection.h" />
<ClInclude Include="cvfPerformanceInfo.h" />
<ClInclude Include="cvfRenderEngine.h" />
<ClInclude Include="cvfRendering.h" />
<ClInclude Include="cvfRenderQueue.h" />
<ClInclude Include="cvfRenderQueueBuilder.h" />
<ClInclude Include="cvfRenderQueueSorter.h" />
<ClInclude Include="cvfScene.h" />
<ClInclude Include="cvfTransform.h" />
<ClInclude Include="cvfSingleQuadRenderingGenerator.h" />
<ClInclude Include="cvfDynamicUniformSet.h" />
<ClInclude Include="cvfRayIntersectSpec.h" />
<ClInclude Include="cvfHitItemCollection.h" />
<ClInclude Include="cvfHitItem.h" />
<ClInclude Include="cvfRenderSequence.h" />
<ClInclude Include="cvfClipPlaneSet.h" />
<ClInclude Include="cvfPartHighlighter.h" />
<ClInclude Include="cvfGaussianBlur.h" />
<ClInclude Include="cvfFixedSizeTransform.h" />
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="cvfConstantFrameRate.cpp" />
<ClCompile Include="cvfCullSettings.cpp" />
<ClCompile Include="cvfEffect.cpp" />
<ClCompile Include="cvfLocators.cpp" />
<ClCompile Include="cvfManipulatorTrackball.cpp" />
<ClCompile Include="cvfModel.cpp" />
<ClCompile Include="cvfModelBasicList.cpp" />
<ClCompile Include="cvfModelBasicTree.cpp" />
<ClCompile Include="cvfPart.cpp" />
<ClCompile Include="cvfPartRenderHintCollection.cpp" />
<ClCompile Include="cvfPerformanceInfo.cpp" />
<ClCompile Include="cvfRenderEngine.cpp" />
<ClCompile Include="cvfRendering.cpp" />
<ClCompile Include="cvfRenderQueue.cpp" />
<ClCompile Include="cvfRenderQueueBuilder.cpp" />
<ClCompile Include="cvfRenderQueueSorter.cpp" />
<ClCompile Include="cvfScene.cpp" />
<ClCompile Include="cvfTransform.cpp" />
<ClCompile Include="cvfSingleQuadRenderingGenerator.cpp" />
<ClCompile Include="cvfDynamicUniformSet.cpp" />
<ClCompile Include="cvfRayIntersectSpec.cpp" />
<ClCompile Include="cvfHitItemCollection.cpp" />
<ClCompile Include="cvfHitItem.cpp" />
<ClCompile Include="cvfRenderSequence.cpp" />
<ClCompile Include="cvfClipPlaneSet.cpp" />
<ClCompile Include="cvfPartHighlighter.cpp" />
<ClCompile Include="cvfGaussianBlur.cpp" />
<ClCompile Include="cvfFixedSizeTransform.cpp" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,61 @@
cmake_minimum_required(VERSION 2.8)
project(QtMinimal)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_BASE_CXX_FLAGS}")
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-long-long")
endif()
find_package(OpenGL)
find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
include(${QT_USE_FILE})
include_directories(${LibCore_SOURCE_DIR})
include_directories(${LibGeometry_SOURCE_DIR})
include_directories(${LibRender_SOURCE_DIR})
include_directories(${LibViewing_SOURCE_DIR})
include_directories(${LibGuiQt_SOURCE_DIR})
set(CEE_LIBS LibGuiQt LibViewing LibRender LibGeometry LibCore)
set(CEE_SOURCE_FILES
QMMain.cpp
QMMainWindow.cpp
QMWidget.cpp
)
# Headers that need MOCing
set(MOC_HEADER_FILES
QMMainWindow.h
QMWidget.h
)
# Run MOC on the headers
add_definitions(-DCVF_USING_CMAKE)
set(MOC_SOURCE_FILES)
qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} )
add_executable(${PROJECT_NAME} ${CEE_SOURCE_FILES} ${MOC_SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${CEE_LIBS} ${OPENGL_LIBRARIES} ${QT_LIBRARIES})
# Copy Qt Dlls
if (MSVC)
set (QTLIBLIST QtCore QtGui QtOpenGl)
foreach (qtlib ${QTLIBLIST})
# Debug
execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}d4.dll ${CMAKE_BINARY_DIR}/Debug/${qtlib}d4.dll)
# Release
execute_process(COMMAND cmake -E copy_if_different ${QT_BINARY_DIR}/${qtlib}4.dll ${CMAKE_BINARY_DIR}/Release/${qtlib}4.dll)
endforeach( qtlib )
endif(MSVC)

View File

@ -0,0 +1,62 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfLibCore.h"
#include "QMMainWindow.h"
#include "QtGui/QApplication"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
// On Linux, Qt will use the system locale, force number formatting settings back to "C" locale
setlocale(LC_NUMERIC,"C");
QMMainWindow window;
QString platform = cvf::System::is64Bit() ? "(64bit)" : "(32bit)";
window.setWindowTitle("Qt Minimal " + platform);
window.resize(1000, 800);;
window.show();
return app.exec();
}

View File

@ -0,0 +1,161 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfLibCore.h"
#include "cvfLibRender.h"
#include "cvfLibGeometry.h"
#include "cvfLibViewing.h"
#include "QMMainWindow.h"
#include "QMWidget.h"
#include <QtGui/QFrame>
#include <QtGui/QHBoxLayout>
#include <QtGui/QAction>
#include <QtGui/QMenu>
#include <QtGui/QMenuBar>
using cvf::ref;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QMMainWindow::QMMainWindow()
{
QFrame* mainFrame = new QFrame;
QHBoxLayout* frameLayout = new QHBoxLayout(mainFrame);
setCentralWidget(mainFrame);
m_contextGroup = new cvf::OpenGLContextGroup;
m_vizWidget = new QMWidget(m_contextGroup.p(), mainFrame);
m_vizWidget->setFocus();
frameLayout->addWidget(m_vizWidget);
m_createDefaultSceneAction = new QAction("Default Scene", this);
m_clearSceneAction = new QAction("Clear Scene", this);
connect(m_createDefaultSceneAction, SIGNAL(triggered()), SLOT(slotCreateDefaultScene()));
connect(m_clearSceneAction, SIGNAL(triggered()), SLOT(slotClearScene()));
QMenu* menu = menuBar()->addMenu("&Scenes");
menu->addAction(m_createDefaultSceneAction);
menu->addSeparator();
menu->addAction(m_clearSceneAction);
slotCreateDefaultScene();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void QMMainWindow::slotCreateDefaultScene()
{
ref<cvf::ModelBasicList> model = new cvf::ModelBasicList;
{
cvf::GeometryBuilderDrawableGeo builder;
cvf::GeometryUtils::createSphere(2, 10, 10, &builder);
ref<cvf::Effect> eff = new cvf::Effect;
eff->setRenderState(new cvf::RenderStateMaterial_FF(cvf::Color3::BLUE));
ref<cvf::Part> part = new cvf::Part;
part->setName("MySphere");
part->setDrawable(0, builder.drawableGeo().p());
part->setEffect(eff.p());
model->addPart(part.p());
}
{
cvf::GeometryBuilderDrawableGeo builder;
cvf::GeometryUtils::createBox(cvf::Vec3f(5, 0, 0), 2, 3, 4, &builder);
ref<cvf::Effect> eff = new cvf::Effect;
eff->setRenderState(new cvf::RenderStateMaterial_FF(cvf::Color3::RED));
ref<cvf::Part> part = new cvf::Part;
part->setName("MyBox");
part->setDrawable(0, builder.drawableGeo().p());
part->setEffect(eff.p());
model->addPart(part.p());
}
model->updateBoundingBoxesRecursive();
ref<cvf::Scene> scene = new cvf::Scene;
scene->addModel(model.p());
CVF_ASSERT(m_vizWidget);
m_vizWidget->setScene(scene.p());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void QMMainWindow::slotClearScene()
{
CVF_ASSERT(m_vizWidget);
m_vizWidget->setScene(NULL);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void QMMainWindow::closeEvent(QCloseEvent* /*event*/)
{
CVF_ASSERT(m_contextGroup.notNull());
CVF_ASSERT(m_vizWidget);
// Shut down the CeeViz OpenGL context contained in the widget
// Deletes all OpenGL resources and removes context from context group
m_vizWidget->cvfShutdownOpenGLContext();
}
#ifndef CVF_USING_CMAKE
//########################################################
#include "qt-generated/moc_QMMainWindow.cpp"
//########################################################
#endif

View File

@ -0,0 +1,73 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfOpenGLContextGroup.h"
#include <QtGui/QMainWindow>
class QMWidget;
//==================================================================================================
//
//
//
//==================================================================================================
class QMMainWindow : public QMainWindow
{
Q_OBJECT
public:
QMMainWindow();
private slots:
void slotCreateDefaultScene();
void slotClearScene();
private:
void closeEvent(QCloseEvent* event);
private:
cvf::ref<cvf::OpenGLContextGroup> m_contextGroup;
QMWidget* m_vizWidget;
QAction* m_createDefaultSceneAction;
QAction* m_clearSceneAction;
};

View File

@ -0,0 +1,230 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#include "cvfLibCore.h"
#include "cvfLibRender.h"
#include "cvfLibGeometry.h"
#include "cvfLibViewing.h"
#include "QMWidget.h"
#include "cvfqtOpenGLContext.h"
#include <QtGui/QMouseEvent>
using cvf::ref;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QMWidget::QMWidget(cvf::OpenGLContextGroup* contextGroup, QWidget* parent)
: cvfqt::OpenGLWidget(contextGroup, QGLFormat(), parent)
{
m_camera = new cvf::Camera;
ref<cvf::Rendering> rendering = new cvf::Rendering;
rendering->setCamera(m_camera.p());
rendering->addOverlayItem(new cvf::OverlayAxisCross(m_camera.p(), new cvf::FixedAtlasFont(cvf::FixedAtlasFont::STANDARD)));
m_renderSequence = new cvf::RenderSequence;
m_renderSequence->addRendering(rendering.p());
m_trackball = new cvf::ManipulatorTrackball;
m_trackball->setCamera(m_camera.p());
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QMWidget::~QMWidget()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void QMWidget::setScene(cvf::Scene* scene)
{
ref<cvf::Rendering> rendering = m_renderSequence->firstRendering();
CVF_ASSERT(rendering.notNull());
rendering->setScene(scene);
if (scene)
{
cvf::BoundingBox bb = scene->boundingBox();
if (bb.isValid())
{
m_camera->fitView(bb, -cvf::Vec3d::Z_AXIS, cvf::Vec3d::Y_AXIS);
m_trackball->setRotationPoint(bb.center());
}
}
update();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void QMWidget::resizeGL(int width, int height)
{
if (m_camera.notNull())
{
m_camera->viewport()->set(0, 0, width, height);
m_camera->setProjectionAsPerspective(m_camera->fieldOfViewYDeg(), m_camera->nearPlane(), m_camera->farPlane());
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void QMWidget::paintEvent(QPaintEvent* /*event*/)
{
QPainter painter(this);
makeCurrent();
cvf::OpenGLContext* currentOglContext = cvfOpenGLContext();
CVF_ASSERT(currentOglContext);
CVF_CHECK_OGL(currentOglContext);
#if QT_VERSION >= 0x040600
painter.beginNativePainting();
#endif
cvfqt::OpenGLContext::saveOpenGLState(currentOglContext);
if (m_renderSequence.notNull())
{
m_renderSequence->render(currentOglContext);
}
cvfqt::OpenGLContext::restoreOpenGLState(currentOglContext);
#if QT_VERSION >= 0x040600
painter.endNativePainting();
#endif
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void QMWidget::mouseMoveEvent(QMouseEvent* event)
{
if (m_renderSequence.isNull()) return;
Qt::MouseButtons mouseBn = event->buttons();
int posX = event->x();
int posY = height() - event->y();
cvf::ManipulatorTrackball::NavigationType navType = cvf::ManipulatorTrackball::NONE;
if (mouseBn == Qt::LeftButton)
{
navType = cvf::ManipulatorTrackball::PAN;
}
else if (mouseBn == Qt::RightButton)
{
navType = cvf::ManipulatorTrackball::ROTATE;
}
else if (mouseBn == (Qt::LeftButton | Qt::RightButton) || mouseBn == Qt::MidButton)
{
navType = cvf::ManipulatorTrackball::WALK;
}
if (navType != m_trackball->activeNavigation())
{
m_trackball->startNavigation(navType, posX, posY);
}
bool needRedraw = m_trackball->updateNavigation(posX, posY);
if (needRedraw)
{
update();
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void QMWidget::mousePressEvent(QMouseEvent* event)
{
if (m_renderSequence.isNull()) return;
if (event->buttons() == Qt::LeftButton && event->modifiers() == Qt::ControlModifier)
{
cvf::Rendering* r = m_renderSequence->firstRendering();
ref<cvf::RayIntersectSpec> ris = r->rayIntersectSpecFromWindowCoordinates(event->x(), height() - event->y());
cvf::HitItemCollection hic;
if (r->rayIntersect(*ris, &hic))
{
cvf::HitItem* item = hic.firstItem();
CVF_ASSERT(item && item->part());
cvf::Vec3d isect = item->intersectionPoint();
m_trackball->setRotationPoint(isect);
cvf::Trace::show("hitting part: '%s' coords: %.3f %.3f %.3f", item->part()->name().toAscii().ptr(), isect.x(), isect.y(), isect.z());
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void QMWidget::mouseReleaseEvent(QMouseEvent* /*event*/)
{
m_trackball->endNavigation();
}
#ifndef CVF_USING_CMAKE
//########################################################
#include "qt-generated/moc_QMWidget.cpp"
//########################################################
#endif

View File

@ -0,0 +1,80 @@
//##################################################################################################
//
// Custom Visualization Core library
// Copyright (C) 2011-2013 Ceetron AS
//
// This library may be used under the terms of either the GNU General Public License or
// the GNU Lesser General Public License as follows:
//
// GNU General Public License Usage
// This library is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <<http://www.gnu.org/licenses/gpl.html>>
// for more details.
//
// GNU Lesser General Public License Usage
// This library is free software; you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation; either version 2.1 of the License, or
// (at your option) any later version.
//
// This library is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU Lesser General Public License at <<http://www.gnu.org/licenses/lgpl-2.1.html>>
// for more details.
//
//##################################################################################################
#pragma once
#include "cvfBase.h"
#include "cvfObject.h"
#include "cvfRenderSequence.h"
#include "cvfManipulatorTrackball.h"
#include "cvfScene.h"
#include "cvfOpenGLContextGroup.h"
#include "cvfqtOpenGLWidget.h"
//==================================================================================================
//
//
//
//==================================================================================================
class QMWidget : public cvfqt::OpenGLWidget
{
Q_OBJECT
public:
QMWidget(cvf::OpenGLContextGroup* contextGroup, QWidget* parent);
~QMWidget();
void setScene(cvf::Scene* scene);
protected:
void resizeGL(int width, int height);
void paintEvent(QPaintEvent *event);
void mousePressEvent(QMouseEvent* event);
void mouseMoveEvent(QMouseEvent* event);
void mouseReleaseEvent(QMouseEvent* event);
private:
cvf::ref<cvf::RenderSequence> m_renderSequence;
cvf::ref<cvf::Camera> m_camera;
cvf::ref<cvf::ManipulatorTrackball> m_trackball;
};

View File

@ -0,0 +1,206 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug MD|Win32">
<Configuration>Debug MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug MD|x64">
<Configuration>Debug MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|Win32">
<Configuration>Release MD</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release MD|x64">
<Configuration>Release MD</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{9EDEF87F-EC72-4422-8CB7-33DD68E5F2A9}</ProjectGuid>
<RootNamespace>QtMinimal</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<OutDir>$(Platform)_VS2010\$(Configuration)\</OutDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<IntDir>$(Platform)_VS2010\$(Configuration)\</IntDir>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(QTDIR)/include;$(QTDIR)/include/Qt;../../../LibCore;../../../LibRender;../../../LibGeometry;../../../LibViewing;../../../LibGuiQt;.</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>qtmaind.lib;QtCored4.lib;QtGuid4.lib;QtOpenGLd4.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(QTDIR)\lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>$(QTDIR)/include;$(QTDIR)/include/Qt;../../../LibCore;../../../LibRender;../../../LibGeometry;../../../LibViewing;../../../LibGuiQt;.</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>qtmaind.lib;QtCored4.lib;QtGuid4.lib;QtOpenGLd4.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(QTDIR)\lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(QTDIR)/include;$(QTDIR)/include/Qt;../../../LibCore;../../../LibRender;../../../LibGeometry;../../../LibViewing;../../../LibGuiQt;.</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>qtmain.lib;QtCore4.lib;QtGui4.lib;QtOpenGL4.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(QTDIR)\lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>$(QTDIR)/include;$(QTDIR)/include/Qt;../../../LibCore;../../../LibRender;../../../LibGeometry;../../../LibViewing;../../../LibGuiQt;.</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_WINDOWS;NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>qtmain.lib;QtCore4.lib;QtGui4.lib;QtOpenGL4.lib;opengl32.lib;glu32.lib;%(AdditionalDependencies)</AdditionalDependencies>
<AdditionalLibraryDirectories>$(QTDIR)\lib</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="QMMain.cpp" />
<ClCompile Include="QMMainWindow.cpp" />
<ClCompile Include="QMWidget.cpp" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="QMMainWindow.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">%QTDIR%\bin\moc.exe %(FullPath) -o Qt-Generated\moc_%(Filename).cpp</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">%QTDIR%\bin\moc.exe %(FullPath) -o Qt-Generated\moc_%(Filename).cpp</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">MOCing %(FullPath)...</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">MOCing %(FullPath)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">Qt-Generated\moc_%(FileName).cpp</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">Qt-Generated\moc_%(FileName).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">%QTDIR%\bin\moc.exe %(FullPath) -o Qt-Generated\moc_%(Filename).cpp</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">%QTDIR%\bin\moc.exe %(FullPath) -o Qt-Generated\moc_%(Filename).cpp</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">MOCing %(FullPath)...</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">MOCing %(FullPath)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">Qt-Generated\moc_%(FileName).cpp</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">Qt-Generated\moc_%(FileName).cpp</Outputs>
</CustomBuild>
<CustomBuild Include="QMWidget.h">
<Command Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">%QTDIR%\bin\moc.exe %(FullPath) -o Qt-Generated\moc_%(Filename).cpp</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">%QTDIR%\bin\moc.exe %(FullPath) -o Qt-Generated\moc_%(Filename).cpp</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">MOCing %(FullPath)...</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">MOCing %(FullPath)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug MD|Win32'">Qt-Generated\moc_%(FileName).cpp</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Debug MD|x64'">Qt-Generated\moc_%(FileName).cpp</Outputs>
<Command Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">%QTDIR%\bin\moc.exe %(FullPath) -o Qt-Generated\moc_%(Filename).cpp</Command>
<Command Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">%QTDIR%\bin\moc.exe %(FullPath) -o Qt-Generated\moc_%(Filename).cpp</Command>
<Message Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">MOCing %(FullPath)...</Message>
<Message Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">MOCing %(FullPath)...</Message>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release MD|Win32'">Qt-Generated\moc_%(FileName).cpp</Outputs>
<Outputs Condition="'$(Configuration)|$(Platform)'=='Release MD|x64'">Qt-Generated\moc_%(FileName).cpp</Outputs>
</CustomBuild>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\LibViewing\LibViewing.vcxproj">
<Project>{122d4663-11d6-d12f-8748-629a34e9075e}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\LibCore\LibCore.vcxproj">
<Project>{a9c7a239-b761-a892-bf34-5aeca0d9ee88}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\LibGeometry\LibGeometry.vcxproj">
<Project>{efd5c9ac-8988-f190-aa2c-e36ebe361e90}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\LibGuiQt\LibGuiQt.vcxproj">
<Project>{fbfac173-30fe-2c09-3f2e-d54477b433de}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\LibRender\LibRender.vcxproj">
<Project>{c07ade80-5c4f-e6e3-dd1a-5a619403fa9f}</Project>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ClCompile Include="QMMain.cpp" />
<ClCompile Include="QMMainWindow.cpp" />
<ClCompile Include="QMWidget.cpp" />
</ItemGroup>
<ItemGroup>
<CustomBuild Include="QMWidget.h" />
<CustomBuild Include="QMMainWindow.h" />
</ItemGroup>
<ItemGroup>
<None Include="CMakeLists.txt" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,51 @@
cmake_minimum_required(VERSION 2.8)
project(QtMultiView)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_BASE_CXX_FLAGS}")
if (CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-long-long")
endif()
find_package(OpenGL)
find_package(Qt4 COMPONENTS QtCore QtGui QtOpenGL REQUIRED)
include(${QT_USE_FILE})
include_directories(${LibCore_SOURCE_DIR})
include_directories(${LibGeometry_SOURCE_DIR})
include_directories(${LibRender_SOURCE_DIR})
include_directories(${LibViewing_SOURCE_DIR})
include_directories(${LibGuiQt_SOURCE_DIR})
include_directories(${LibUtilities_SOURCE_DIR})
set(CEE_LIBS LibUtilities LibGuiQt LibViewing LibRender LibGeometry LibIo LibCore)
set(CEE_SOURCE_FILES
QMVFactory.cpp
QMVMain.cpp
QMVMainWindow.cpp
QMVWidget.cpp
)
# Headers that need MOCing
set(MOC_HEADER_FILES
QMVMainWindow.h
QMVWidget.h
)
# Run MOC on the headers
add_definitions(-DCVF_USING_CMAKE)
set(MOC_SOURCE_FILES)
qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} )
add_executable(${PROJECT_NAME} ${CEE_SOURCE_FILES} ${MOC_SOURCE_FILES})
target_link_libraries(${PROJECT_NAME} ${CEE_LIBS} ${OPENGL_LIBRARIES} ${QT_LIBRARIES})

Some files were not shown because too many files have changed in this diff Show More