pax_global_header00006660000000000000000000000064136322046740014521gustar00rootroot0000000000000052 comment=0cf75ad982917e0919f59e5cb3d483517d06d7da Field3D-1.7.3/000077500000000000000000000000001363220467400127435ustar00rootroot00000000000000Field3D-1.7.3/.gitignore000066400000000000000000000000631363220467400147320ustar00rootroot00000000000000build/* docs/* Field3D/* install/* *.dblite *.pyc Field3D-1.7.3/BuildSupport.py000066400000000000000000000250611363220467400157550ustar00rootroot00000000000000# # Copyright (c) 2009 Sony Pictures Imageworks Inc. # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the # distribution. Neither the name of Sony Pictures Imageworks nor the # names of its contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------ # Contains various helper functions for the SCons build system # ------------------------------------------------------------------------------ import os import sys from SCons.Script import * from os.path import join # ------------------------------------------------------------------------------ # Strings # ------------------------------------------------------------------------------ field3DName = "Field3D" buildDirPath = "build" installDirPath = "install" release = "release" debug = "debug" export = "export" include = "include" src = "src" stdMathHeader = "StdMathLib.h" siteFile = "Site.py" typesHeader = "Types.h" arch32 = "m32" arch64 = "m64" # ------------------------------------------------------------------------------ # Paths # ------------------------------------------------------------------------------ systemIncludePaths = { "darwin" : { arch32 : ["/usr/local/include", "/opt/local/include"], arch64 : ["/usr/local/include", "/opt/local/include"]}, "linux2" : { arch32 : ["/usr/local/include"], arch64 : ["/usr/local64/include"]} } systemLibPaths = { "darwin" : { arch32 : ["/usr/local/lib", "/opt/local/lib"], arch64 : ["/usr/local/lib", "/opt/local/lib"]}, "linux2" : { arch32 : ["/usr/local/lib"], arch64 : ["/usr/local64/lib"]} } systemLibs = { "darwin" : [], "linux2" : ["dl"] } # ------------------------------------------------------------------------------ # Functions # ------------------------------------------------------------------------------ def isDebugBuild(): return ARGUMENTS.get('debug', 0) # ------------------------------------------------------------------------------ def red(s): return "\033[1m" + s + "\033[0m" # ------------------------------------------------------------------------------ def architectureStr(): if ARGUMENTS.get('do64', 1): return arch64 else: return arch32 # ------------------------------------------------------------------------------ def buildDir(): basePath = join(buildDirPath, sys.platform, architectureStr()) if isDebugBuild(): return join(basePath, debug) else: return join(basePath, release) # ------------------------------------------------------------------------------ def installDir(): basePath = join(installDirPath, sys.platform, architectureStr()) if isDebugBuild(): return join(basePath, debug) else: return join(basePath, release) # ------------------------------------------------------------------------------ def getMathHeader(): if os.path.exists(siteFile): import Site if hasattr(Site, "mathInc"): return Site.mathInc return stdMathHeader # ------------------------------------------------------------------------------ def setupLibBuildEnv(env, pathToRoot = "."): # Project headers env.Append(CPPPATH = [join(pathToRoot, export)]) env.Append(CPPPATH = [join(pathToRoot, include)]) # Check if Site.py exists siteExists = False if os.path.exists(join(pathToRoot, siteFile)): sys.path.append(pathToRoot) import Site siteExists = True if siteExists and \ hasattr(Site, "mathInc") and \ hasattr(Site, "mathIncPaths") and \ hasattr(Site, "mathLibs") and \ hasattr(Site, "mathLibPaths"): mathIncStr = '\\"' + Site.mathInc + '\\"' env.Append(CPPDEFINES = {"FIELD3D_CUSTOM_MATH_LIB" : None}) env.Append(CPPDEFINES = {"FIELD3D_MATH_LIB_INCLUDE" : mathIncStr}) # ------------------------------------------------------------------------------ def setupEnv(env, pathToRoot = "."): baseIncludePaths = systemIncludePaths[sys.platform][architectureStr()] baseLibPaths = systemLibPaths[sys.platform][architectureStr()] baseLibs = systemLibs[sys.platform] # Compiler compiler = ARGUMENTS.get('compiler', '') if compiler != '': env.Replace(CXX = compiler) # System include paths env.Append(CPPPATH = baseIncludePaths) # System lib paths env.Append(LIBPATH = baseLibPaths) # System libs env.Append(LIBS = baseLibs) # Check if Site.py exists siteExists = False if os.path.exists(join(pathToRoot, siteFile)): sys.path.append(pathToRoot) import Site siteExists = True # Choose math library if siteExists and \ hasattr(Site, "mathInc") and \ hasattr(Site, "mathIncPaths") and \ hasattr(Site, "mathLibs") and \ hasattr(Site, "mathLibPaths"): env.Append(CPPPATH = Site.mathIncPaths) env.Append(LIBS = Site.mathLibs) env.Append(LIBPATH = Site.mathLibPaths) env.Append(RPATH = Site.mathLibPaths) else: for path in baseIncludePaths: env.Append(CPPPATH = join(path, "OpenEXR")) env.Append(LIBS = ["Half"]) env.Append(LIBS = ["Iex"]) env.Append(LIBS = ["Imath"]) # Add in site-specific paths if siteExists and hasattr(Site, "incPaths"): env.AppendUnique(CPPPATH = Site.incPaths) if siteExists and hasattr(Site, "libPaths"): env.AppendUnique(LIBPATH = Site.libPaths) env.AppendUnique(RPATH = Site.libPaths) # Custom namespace if siteExists and hasattr(Site, "extraNamespace"): namespaceDict = {"FIELD3D_EXTRA_NAMESPACE" : Site.extraNamespace} env.AppendUnique(CPPDEFINES = namespaceDict) # System libs env.Append(LIBS = ["z", "pthread"]) # Hdf5 lib env.Append(LIBS = ["hdf5"]) # Boost system env.Append(LIBS = ["boost_system-mt"]) # Boost threads if siteExists and hasattr(Site, "boostThreadLib"): env.Append(LIBS = [Site.boostThreadLib]) else: env.Append(LIBS = ["boost_thread-mt"]) # Compile flags if isDebugBuild(): env.Append(CCFLAGS = ["-g"]) else: env.Append(CCFLAGS = ["-g", "-O3"]) env.Append(CCFLAGS = ["-Wall"]) env.Append(CCFLAGS = ["-Wextra"]) env.Append(CCFLAGS = ["-Wno-unused-local-typedef"]) # Set number of jobs to use env.SetOption('num_jobs', numCPUs()) # 64 bit setup if architectureStr() == arch64: env.Append(CCFLAGS = ["-m64"]) env.Append(LINKFLAGS = ["-m64"]) else: env.Append(CCFLAGS = ["-m32"]) env.Append(LINKFLAGS = ["-m32"]) # Prettify SCons output if ARGUMENTS.get("verbose", 0) != "1": env["ARCOMSTR"] = "AR $TARGET" env["CXXCOMSTR"] = "Compiling " + red("$TARGET") env["SHCXXCOMSTR"] = "Compiling " + red("$TARGET") env["LDMODULECOMSTR"] = "Compiling " + red("$TARGET") env["LINKCOMSTR"] = "Linking " + red("$TARGET") env["SHLINKCOMSTR"] = "Linking " + red("$TARGET") env["INSTALLSTR"] = "Installing " + red("$TARGET") # ------------------------------------------------------------------------------ def addField3DInstall(env, pathToRoot): env.Prepend(CPPPATH = [join(pathToRoot, installDir(), "include")]) env.Prepend(LIBS = [field3DName]) env.Prepend(LIBPATH = [join(pathToRoot, installDir(), "lib")]) env.Prepend(RPATH = [join(pathToRoot, installDir(), "lib")]) # ------------------------------------------------------------------------------ def numCPUs(): if os.sysconf_names.has_key("SC_NPROCESSORS_ONLN"): nCPUs = os.sysconf("SC_NPROCESSORS_ONLN") if isinstance(nCPUs, int) and nCPUs > 0: return nCPUs else: return int(os.popen2("sysctl -n hw.ncpu")[1].read()) if os.environ.has_key("NUMBER_OF_PROCESSORS"): nCPUs = int(os.environ["NUMBER_OF_PROCESSORS"]); if nCPUs > 0: return nCPUs return 1 # ------------------------------------------------------------------------------ def setDylibInternalPath(target, source, env): # Copy the library file srcName = str(source[0]) tgtName = str(target[0]) Execute(Copy(tgtName, srcName)) # Then run install_name_tool cmd = "install_name_tool " cmd += "-id " + os.path.abspath(tgtName) + " " cmd += tgtName print cmd os.system(cmd) # ------------------------------------------------------------------------------ def bakeMathLibHeader(target, source, env): if len(target) != 1 or len(source) != 1: print "Wrong number of arguments to bakeTypesIncludeFile" return out = open(str(target[0]), "w") inFile = open(str(source[0])) skip = False for line in inFile.readlines(): if not skip and "#ifdef FIELD3D_CUSTOM_MATH_LIB" in line: skip = True newLine = '#include "' + getMathHeader() + '"\n' out.writelines(newLine) if not skip: out.writelines(line) if skip and "#endif" in line: skip = False # ------------------------------------------------------------------------------ Field3D-1.7.3/CHANGES000066400000000000000000000010411363220467400137320ustar00rootroot00000000000000Apr 21, 2010 * Added CMake build system. (Contributed by Nicholas Yue) Nov 3, 2009 * Added dynamic loading of sparse fields. * Merged all the various class factory into single ClassFactory. * Created base class for reference counted objects, before each class implemented the same ref count functions. * Fixed bug in sparse block iterators * Main branch is now at version 1.1 Aug 21 2009 * First "release" into the wild. The official v1.0.0 release branch will be created once any initial kinks have been worked out. Field3D-1.7.3/CMakeLists.txt000066400000000000000000000200521363220467400155020ustar00rootroot00000000000000# Copyright (c) 2009 Sony Pictures Imageworks Inc. et al. # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the # distribution. Neither the name of Sony Pictures Imageworks nor the # names of its contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. # Author : Nicholas Yue yue.nicholas@gmail.com CMAKE_MINIMUM_REQUIRED( VERSION 2.8 ) PROJECT ( field3d ) set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake ) FIND_PACKAGE (Doxygen) FIND_PACKAGE (HDF5 COMPONENTS C) IF ( CMAKE_HOST_WIN32 ) # f3dinfo relies on program_options but don't include it, since # for some reason, unlike all the other boost components, a link is # forced via a pragma. FIND_PACKAGE (Boost COMPONENTS regex thread) ELSE () FIND_PACKAGE (Boost COMPONENTS regex thread program_options system) FIND_PACKAGE (MPI) ENDIF () FIND_PACKAGE (ILMBase) # Allow the developer to select if Dynamic or Static libraries are built OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" ON) OPTION (INSTALL_DOCS "Automatically install documentation." ON) # Duplicate the export directory to Field3D FILE ( REMOVE_RECURSE ${CMAKE_HOME_DIRECTORY}/Field3D) FILE ( COPY export/ DESTINATION ${CMAKE_HOME_DIRECTORY}/Field3D) # includes INCLUDE_DIRECTORIES ( . ) INCLUDE_DIRECTORIES ( src ) INCLUDE_DIRECTORIES ( export ) INCLUDE_DIRECTORIES ( include ) INCLUDE_DIRECTORIES ( ${ILMBASE_INCLUDE_DIRS} ) INCLUDE_DIRECTORIES ( ${HDF5_INCLUDE_DIRS} ) INCLUDE_DIRECTORIES ( ${Boost_INCLUDE_DIR} ) # link directories LINK_DIRECTORIES ( ${Boost_LIBRARY_DIRS} ) LINK_DIRECTORIES ( ${HDF5_LIBRARY_DIRS} ) LINK_DIRECTORIES ( ${ILMBASE_LIBRARY_DIRS} ) IF ( CMAKE_HOST_UNIX ) ADD_DEFINITIONS ( -fPIC -DREQUIRE_IOSTREAM -Wno-invalid-offsetof ) ENDIF ( ) IF ( CMAKE_HOST_WIN32 ) ADD_DEFINITIONS ( -D_HAS_ITERATOR_DEBUGGING=0 -D_CRT_SECURE_NO_WARNINGS=1 ) ENDIF ( ) SET ( LIB_TYPE SHARED ) IF ( NOT BUILD_SHARED_LIBS ) IF ( CMAKE_HOST_WIN32 ) # User wants to build static libraries, so change the LIB_TYPE variable to CMake keyword 'STATIC' SET ( LIB_TYPE STATIC ) ADD_DEFINITIONS( -DFIELD3D_STATIC ) ENDIF() ELSE () IF ( CMAKE_HOST_WIN32 ) ADD_DEFINITIONS ( -DOPENEXR_DLL -D_HDF5USEDLL_ -DHDF5CPP_USEDLL ) ENDIF() ENDIF ( NOT BUILD_SHARED_LIBS ) ADD_LIBRARY ( Field3D ${LIB_TYPE} src/ClassFactory.cpp src/DenseFieldIO.cpp src/Field3DFile.cpp src/Field3DFileHDF5.cpp src/FieldCache.cpp src/Field.cpp src/FieldInterp.cpp src/FieldMapping.cpp src/FieldMappingIO.cpp src/FieldMetadata.cpp src/FileSequence.cpp src/Hdf5Util.cpp src/IArchive.cpp src/IData.cpp src/IGroup.cpp src/InitIO.cpp src/IStreams.cpp src/Log.cpp src/MACFieldIO.cpp src/MIPFieldIO.cpp src/MIPUtil.cpp src/OArchive.cpp src/OData.cpp src/OgIGroup.cpp src/OGroup.cpp src/OgUtil.cpp src/OStream.cpp src/PatternMatch.cpp src/PluginLoader.cpp src/ProceduralField.cpp src/Resample.cpp src/SparseFieldIO.cpp src/SparseFile.cpp ) SET ( Field3D_Libraries_Shared ${HDF5_LIBRARIES} ) IF ( CMAKE_HOST_UNIX ) IF ( MPI_FOUND ) LIST ( APPEND Field3D_Libraries_Shared ${MPI_LIBRARIES} ) ENDIF ( MPI_FOUND ) LIST ( APPEND Field3D_Libraries_Shared Iex Half IlmThread Imath pthread dl z ) SET ( Field3D_DSO_Libraries ${Field3D_Libraries_Shared} ) SET ( Field3D_BIN_Libraries Field3D ${Field3D_Libraries_Shared} ${Boost_LIBRARIES} ) ENDIF ( ) IF ( CMAKE_HOST_WIN32 ) # Add OpenEXR and zlib release/debug FOREACH ( lib Iex Half IlmThread Imath zdll ) LIST ( APPEND Field3D_Libraries_Shared optimized ${lib} debug ${lib}_d ) ENDFOREACH() SET ( Field3D_DSO_Libraries ${Field3D_Libraries_Shared} Shlwapi.lib) SET ( Field3D_BIN_Libraries Field3D ${Boost_LIBRARIES} ) ENDIF () TARGET_LINK_LIBRARIES ( Field3D ${Field3D_DSO_Libraries} ${Boost_LIBRARIES}) # Parase version and soversion from export/ns.h file(STRINGS export/ns.h FIELD3D_MAJOR_VER REGEX "^#define FIELD3D_MAJOR_VER") file(STRINGS export/ns.h FIELD3D_MINOR_VER REGEX "^#define FIELD3D_MINOR_VER") file(STRINGS export/ns.h FIELD3D_MICRO_VER REGEX "^#define FIELD3D_MICRO_VER") string(REPLACE "#define FIELD3D_MAJOR_VER " "" FIELD3D_MAJOR_VER ${FIELD3D_MAJOR_VER}) string(REPLACE "#define FIELD3D_MINOR_VER " "" FIELD3D_MINOR_VER ${FIELD3D_MINOR_VER}) string(REPLACE "#define FIELD3D_MICRO_VER " "" FIELD3D_MICRO_VER ${FIELD3D_MICRO_VER}) SET ( FIELD3D_VERSION ${FIELD3D_MAJOR_VER}.${FIELD3D_MINOR_VER}.${FIELD3D_MICRO_VER} ) SET ( FIELD3D_SOVERSION ${FIELD3D_MAJOR_VER}.${FIELD3D_MINOR_VER} ) message(STATUS "Library soversion will be: ${FIELD3D_SOVERSION}") SET_TARGET_PROPERTIES ( Field3D PROPERTIES VERSION ${FIELD3D_VERSION}) SET_TARGET_PROPERTIES ( Field3D PROPERTIES SOVERSION ${FIELD3D_SOVERSION}) IF ( CMAKE_HOST_WIN32 ) SET_TARGET_PROPERTIES( Field3D PROPERTIES ENABLE_EXPORTS ON ) IF ( BUILD_SHARED_LIBS ) SET_TARGET_PROPERTIES( Field3D PROPERTIES COMPILE_DEFINITIONS FIELD3D_EXPORT ) ELSE () SET_TARGET_PROPERTIES( Field3D PROPERTIES COMPILE_DEFINITIONS FIELD3D_STATIC ) ENDIF() SET_TARGET_PROPERTIES( Field3D PROPERTIES COMPILE_FLAGS -EHsc ) SET_TARGET_PROPERTIES( Field3D PROPERTIES COMPILE_FLAGS -MD ) SET_TARGET_PROPERTIES( Field3D PROPERTIES COMPILE_FLAGS -wd4251 ) ENDIF ( ) # field3d - unitTest ADD_EXECUTABLE ( unitTest test/unit_tests/UnitTest.cpp ) TARGET_LINK_LIBRARIES ( unitTest ${Field3D_BIN_Libraries} ) IF ( CMAKE_HOST_WIN32 ) SET_TARGET_PROPERTIES( unitTest PROPERTIES COMPILE_FLAGS -bigobj ) ENDIF ( ) # field3d - f3dinfo ADD_EXECUTABLE ( f3dinfo apps/f3dinfo/main.cpp ) TARGET_LINK_LIBRARIES ( f3dinfo ${Field3D_BIN_Libraries} ) # field3d - sparse_field_io ADD_EXECUTABLE ( sparse_field_io apps/sample_code/sparse_field_io/main.cpp ) TARGET_LINK_LIBRARIES ( sparse_field_io ${Field3D_BIN_Libraries} ) # field3d - read ADD_EXECUTABLE ( read apps/sample_code/read/main.cpp ) TARGET_LINK_LIBRARIES ( read ${Field3D_BIN_Libraries} ) # field3d - mixed_types ADD_EXECUTABLE ( mixed_types apps/sample_code/mixed_types/main.cpp ) TARGET_LINK_LIBRARIES ( mixed_types ${Field3D_BIN_Libraries} ) # field3d - create_and_write ADD_EXECUTABLE ( create_and_write apps/sample_code/create_and_write/main.cpp ) TARGET_LINK_LIBRARIES ( create_and_write ${Field3D_BIN_Libraries} ) IF (DOXYGEN_FOUND) ADD_CUSTOM_TARGET ( doc ALL ${DOXYGEN_EXECUTABLE} Field3D.doxyfile WORKING_DIRECTORY ${CMAKE_HOME_DIRECTORY} ) IF (INSTALL_DOCS) INSTALL (DIRECTORY ${CMAKE_HOME_DIRECTORY}/docs DESTINATION ${CMAKE_INSTALL_PREFIX} ) ENDIF (INSTALL_DOCS) ENDIF (DOXYGEN_FOUND) INSTALL ( TARGETS Field3D DESTINATION lib${LIB_SUFFIX} ) FILE(GLOB Field3d_Includes "${CMAKE_CURRENT_SOURCE_DIR}/export/*.h") INSTALL ( FILES ${Field3d_Includes} DESTINATION include/Field3D ) INSTALL ( TARGETS f3dinfo RUNTIME DESTINATION bin ) Field3D-1.7.3/COPYING000066400000000000000000000027321363220467400140020ustar00rootroot00000000000000Copyright (c) 2008,2009 Sony Pictures Imageworks Inc All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of Sony Pictures Imageworks nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Field3D-1.7.3/ExampleSite.py000066400000000000000000000037051363220467400155420ustar00rootroot00000000000000# # Copyright (c) 2009 Sony Pictures Imageworks Inc. # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the # distribution. Neither the name of Sony Pictures Imageworks nor the # names of its contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. mathInc = "SpiMathLib.h" mathIncPaths = ["/usr/local64/openexr/1.4.0/include"] mathLibs = ["Half", "Imath", "Iex"] mathLibPaths = ["/usr/local64/openexr/1.4.0/lib64"] incPaths = [ "/usr/local64/include/hdf5", "/usr/local64/include/boost-1_34_1/" ] libPaths = [ "/usr/local64/lib", "/usr/local64/lib64", "/usr/local64/lib/boost-1_34_1" ] boostThreadLib = "boost_thread-gcc34-mt" extraNamespace = "SPI" Field3D-1.7.3/Field3D.doxyfile000066400000000000000000001563601363220467400157350ustar00rootroot00000000000000# Doxyfile 1.5.5 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project # # All text after a hash (#) is considered a comment and will be ignored # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" ") #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or a sequence of words surrounded # by quotes) that should identify the project. PROJECT_NAME = Field3D # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. # PROJECT_NUMBER = v2 # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = docs # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Farsi, Finnish, French, German, Greek, # Hungarian, Italian, Japanese, Japanese-en (Japanese with English messages), # Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, Polish, # Portuguese, Romanian, Russian, Serbian, Slovak, Slovene, Spanish, Swedish, # and Ukrainian. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful is your file systems # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = YES # If the DETAILS_AT_TOP tag is set to YES then Doxygen # will output the detailed description near the top, like JavaDoc. # If set to NO, the detailed description appears after the member # documentation. DETAILS_AT_TOP = YES # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 2 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also make the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = NO # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = YES # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = YES # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = NO # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespace are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = NO # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = YES # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = YES # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if sectionname ... \endif. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or define consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and defines in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # If the sources in your project are distributed over multiple directories # then setting the SHOW_DIRECTORIES tag to YES will show the directory hierarchy # in the documentation. The default is NO. SHOW_DIRECTORIES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # This WARN_NO_PARAMDOC option can be abled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = export src # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx # *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90 FILE_PATTERNS = *.h \ *.cpp # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. EXCLUDE = build install docs test # The EXCLUDE_SYMLINKS tag can be used select whether or not files or # directories that are symbolic links (a Unix filesystem feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = .svn # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = NO # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. Doxygen will compare the file name with each pattern and apply the # filter if there is a match. The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty, INPUT_FILTER # is applied to all files. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = YES # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C and C++ comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES (the default) # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES (the default) # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. Otherwise they will link to the documentstion. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If the tag is left blank doxygen # will generate a default style sheet. Note that doxygen will try to copy # the style sheet file to the HTML output directory, so don't put your own # stylesheet in the HTML output directory as well, or it will be erased! HTML_STYLESHEET = # If the HTML_ALIGN_MEMBERS tag is set to YES, the members of classes, # files or namespaces will be aligned in HTML using tables. If set to # NO a bullet list will be used. HTML_ALIGN_MEMBERS = YES # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. For this to work a browser that supports # JavaScript and DHTML is required (for instance Mozilla 1.0+, Firefox # Netscape 6.0+, Internet explorer 5.0+, Konqueror, or Safari). HTML_DYNAMIC_SECTIONS = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # The DISABLE_INDEX tag can be used to turn on/off the condensed index at # top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. DISABLE_INDEX = NO # This tag can be used to set the number of enum values (range [1..20]) # that doxygen will group on one line in the generated HTML documentation. ENUM_VALUES_PER_LINE = 4 # If the GENERATE_TREEVIEW tag is set to YES, a side panel will be # generated containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (for instance Mozilla 1.0+, # Netscape 6.0+, Internet explorer 5.0+, or Konqueror). Windows users are # probably better off using the HTML help feature. GENERATE_TREEVIEW = YES # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = NO # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = NO # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, a4wide, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4wide # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = NO # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = NO # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load stylesheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = NO # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. This is useful # if you want to understand what is going on. On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # in the INCLUDE_PATH (see below) will be search if a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all function-like macros that are alone # on a line, have an all uppercase name, and do not end with a semicolon. Such # function macros are typically used for boiler-plate code, and will confuse # the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. # Optionally an initial location of the external documentation # can be added for each tagfile. The format of a tag file without # this location is as follows: # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths or # URLs. If a location is present for each tag, the installdox tool # does not have to be run to correct the links. # Note that each tag file must have a unique name # (where the name does NOT include the path) # If a tag file is not located in the directory in which doxygen # is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option is superseded by the HAVE_DOT option below. This is only a # fallback. It is recommended to install and use dot, since it yields more # powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = YES # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = NO # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # the CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = NO # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = NO # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH, SHOW_DIRECTORIES and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are png, jpg, or gif # If left blank png will be used. DOT_IMAGE_FORMAT = png # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MAX_DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is enabled by default, which results in a transparent # background. Warning: Depending on the platform used, enabling this option # may lead to badly anti-aliased labels on the edges of a graph (i.e. they # become hard to read). DOT_TRANSPARENT = YES # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = NO # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES #--------------------------------------------------------------------------- # Configuration::additions related to the search engine #--------------------------------------------------------------------------- # The SEARCHENGINE tag specifies whether or not a search engine should be # used. If set to NO the values of all tags below this one will be ignored. SEARCHENGINE = NO Field3D-1.7.3/README000066400000000000000000000114051363220467400136240ustar00rootroot00000000000000------------------------------------------------------------------------ ABOUT THE FIELD3D LIBRARY ------------------------------------------------------------------------ Field3D is an open source library for storing voxel data. It provides C++ classes that handle in-memory storage and a file format based on HDF5 that allows the C++ objects to be written to and read from disk. The majority of the documentation is available in the project Wiki at https://sites.google.com/site/field3d/ ------------------------------------------------------------------------ LICENSE ------------------------------------------------------------------------ The Field3D source code is distributed under the "New BSD" license. See the file called COPYING for details. ------------------------------------------------------------------------ PACKAGES ------------------------------------------------------------------------ On MacOS X, MacPorts provides a package that downloads, compiles and installs Field3d into /opt/local (by default). The installation files for MacPorts can be found at http://www.macports.org/ . After installing MacPorts, just type: > sudo port install field3d ------------------------------------------------------------------------ FIELD3D DEPENDENCIES ------------------------------------------------------------------------ Field3D was originally developed under CentOS. It has also been tested under MacOS X Leopard. The make system used by Field3D is SCons. You will need to install it before compiling Field3D if you want to use the supplied setup. More information about SCons is available at: http://www.scons.org/ The libraries required for Field3D are: boost (1.34.0) IlmBase (1.0.1) HDF5 (1.8.x) Boost can be downloaded from http://www.boost.org/ More information about HDF5 can be found at: http://www.hdfgroup.org/HDF5/ Field3D has only been compiled and tested using the IlmBase 1.0.1, though earlier versions of the combined OpenEXR, which included the Imath library, may also work. More information about IlmBase/OpenEXR can be found at: http://www.openexr.com/ To use a math library other than Imath - see the section USING A CUSTOM MATH LIBRARY below. ------------------------------------------------------------------------ BUILDING FIELD3D ------------------------------------------------------------------------ Field3D was originally developed under CentOS. It has also been tested under MacOS X Leopard. By default, Field3D will look in your platform's standard directories for include files and libraries. If your libraries reside elsewhere, refer to the CUSTOMIZING THE BUILD ENVIRONMENT section below. If you are compiling on an untested platform, you may need to extend the "systemIncludePaths" and "systemLibPaths" dictionaries in the file called BuildSupport.py. To build Field3D, go to the root directory and type "scons". This will build a shared and a static library and place them in the "install" folder. By default an optimized/release build is created. To build a debug version, type "scons debug=1". To build a 64-bit version, type "scons do64=1". ------------------------------------------------------------------------ CUSTOMIZING THE BUILD ENVIRONMENT ------------------------------------------------------------------------ Field3D will look in your platform's standard directories for include files and libraries. If you need to add further library paths, include paths etc., add a "Site.py" file in the root directory. The file ExampleSite.py can be used for reference. ------------------------------------------------------------------------ USING A CUSTOM MATH LIBRARY ------------------------------------------------------------------------ The "Site.py" file can be used to change the math library used by Field3D. The only current requirement is that the other library is syntactically equivalent to Imath. At Sony Imageworks, the Imath library is wrapped in an "SPI" namespace - the ExampleSite.py and SpiMathLib.h files shows an example of how to configure it. ------------------------------------------------------------------------ AUTHORS ------------------------------------------------------------------------ Original development at Sony Pictures Imageworks: Magnus Wrenninge Chris Allen Sosh Mirsepassi Stephen Marshall Chris Burdorf Henrik Falt Scot Shinderman Doug Bloom Contributors: Nicholas Yue, Dr. D Studios (CMake setup) ------------------------------------------------------------------------ QUESTIONS AND COMMENTS ------------------------------------------------------------------------ For questions and/or comments, please join the field3d-dev discussion group at Google Groups. http://groups.google.com/group/field3d-dev The project web page URL is: https://sites.google.com/site/field3d/ Field3D-1.7.3/SConscript000066400000000000000000000072441363220467400147640ustar00rootroot00000000000000# # Copyright (c) 2009 Sony Pictures Imageworks Inc. # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the # distribution. Neither the name of Sony Pictures Imageworks nor the # names of its contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------ from BuildSupport import * # ------------------------------------------------------------------------------ buildPath = buildDir() installPath = installDir() sharedLibPath = join(buildPath, field3DName) # ------------------------------------------------------------------------------ Import("env") libEnv = env.Clone() setupEnv(libEnv) setupLibBuildEnv(libEnv) libEnv.VariantDir(buildPath, src, duplicate = 0) files = Glob(join(buildPath, "*.cpp")) # Declare library dyLib = libEnv.SharedLibrary(sharedLibPath, files) stLib = libEnv.Library(sharedLibPath, files) # Set up install area headerDir = join(installPath, include, field3DName) headerFiles = Glob(join(export, "*.h")) headerFiles.remove(File(join(export, typesHeader))) headerInstall = libEnv.Install(headerDir, headerFiles) stLibInstall = libEnv.Install(join(installPath, "lib"), [stLib]) # Set up the dynamic library properly on OSX dylibInstall = None if sys.platform == "darwin": dylibName = os.path.basename(str(dyLib[0])) dylibInstallPath = os.path.abspath(join(installPath, "lib", dylibName)) # Create the builder dylibEnv = env.Clone() dylibBuilder = Builder(action = setDylibInternalPath, suffix = ".dylib", src_suffix = ".dylib") dylibEnv.Append(BUILDERS = {"SetDylibPath" : dylibBuilder}) # Call builder dyLibInstall = dylibEnv.SetDylibPath(dylibInstallPath, dyLib) else: dyLibInstall = libEnv.Install(join(installPath, "lib"), [dyLib]) # Bake in math library in Types.h bakeEnv = env.Clone() bakeBuilder = Builder(action = bakeMathLibHeader, suffix = ".h", src_suffix = ".h") bakeEnv.Append(BUILDERS = {"BakeMathLibHeader" : bakeBuilder}) bakeTarget = bakeEnv.BakeMathLibHeader(join(headerDir, typesHeader), join(export, typesHeader)) # Default targets --- libEnv.Default(dyLib) libEnv.Default(stLib) libEnv.Default(headerInstall) libEnv.Default(stLibInstall) libEnv.Default(dyLibInstall) bakeEnv.Default(bakeTarget) # ------------------------------------------------------------------------------ Field3D-1.7.3/SConstruct000066400000000000000000000035711363220467400150030ustar00rootroot00000000000000# # Copyright (c) 2009 Sony Pictures Imageworks Inc. # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the # distribution. Neither the name of Sony Pictures Imageworks nor the # names of its contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. # ------------------------------------------------------------------------------ from BuildSupport import * # ------------------------------------------------------------------------------ env = Environment(CXXFLAGS="-std=c++11") Export("env") SConscript("SConscript") # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/000077500000000000000000000000001363220467400137065ustar00rootroot00000000000000Field3D-1.7.3/apps/f3dinfo/000077500000000000000000000000001363220467400152365ustar00rootroot00000000000000Field3D-1.7.3/apps/f3dinfo/.gitignore000066400000000000000000000000171363220467400172240ustar00rootroot00000000000000build *.dblite Field3D-1.7.3/apps/f3dinfo/SConscript000066400000000000000000000014761363220467400172600ustar00rootroot00000000000000# ------------------------------------------------------------------------------ import os import sys # ------------------------------------------------------------------------------ pathToRoot = "../.." sys.path.append(pathToRoot) from BuildSupport import * appName = "f3dinfo" buildPath = buildDir() binPath = join(buildPath, appName) # ------------------------------------------------------------------------------ Import("env") appEnv = env.Clone() setupEnv(appEnv, pathToRoot) addField3DInstall(appEnv, pathToRoot) appEnv.Append(LIBS = ["boost_program_options-mt", "boost_regex-mt"]) appEnv.VariantDir(buildPath, ".", duplicate = 0) files = Glob(join(buildPath, "*.cpp")) app = appEnv.Program(binPath, files) appEnv.Default(app) # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/f3dinfo/SConstruct000066400000000000000000000003421363220467400172670ustar00rootroot00000000000000# ------------------------------------------------------------------------------ env = Environment() Export("env") SConscript("SConscript") # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/f3dinfo/main.cpp000066400000000000000000000256421363220467400166770ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks Inc. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// #include #include #include #include #include #include #include #include #include #include #include #include //----------------------------------------------------------------------------// using namespace std; using namespace Field3D; //----------------------------------------------------------------------------// // Options struct //----------------------------------------------------------------------------// struct Options { vector inputFiles; vector names; vector attributes; }; //----------------------------------------------------------------------------// // Function prototypes //----------------------------------------------------------------------------// //! Parses command line options, puts them in Options struct. Options parseOptions(int argc, char **argv); //! Prints information about all fields in file. void printFileInfo(const std::string &filename, const Options &options); //! Prints the information about a single field template void printFieldInfo(typename Field::Ptr field, const Options &options); //! Prints a std::map. Used for metadata. Called from printFieldInfo. template void printMap(const map m, const string &indent); //! Prints information about a mapping. Called from printFieldInfo. void printMapping(FieldMapping::Ptr mapping); //! Pattern matching used for field names and attributes bool matchString(const std::string &str, const vector &patterns); //----------------------------------------------------------------------------// // Function implementations //----------------------------------------------------------------------------// int main(int argc, char **argv) { Field3D::initIO(); Options options = parseOptions(argc, argv); BOOST_FOREACH (const string &file, options.inputFiles) { printFileInfo(file, options); } } //----------------------------------------------------------------------------// Options parseOptions(int argc, char **argv) { namespace po = boost::program_options; Options options; po::options_description desc("Available options"); desc.add_options() ("help,h", "Display help") ("input-file", po::value >(), "Input files") ("name,n", po::value >(), "Load field(s) by name") ("attribute,a", po::value >(), "Load field(s) by attribute") ; po::variables_map vm; try { po::store(po::parse_command_line(argc, argv, desc), vm); } catch(...) { cerr << "Unknown command line option.\n"; cout << desc << endl; exit(1); } po::notify(vm); po::positional_options_description p; p.add("input-file", -1); try { po::store(po::command_line_parser(argc, argv). options(desc).positional(p).run(), vm); } catch(...) { cerr << "Unknown command line option.\n"; cout << desc << endl; exit(1); } po::notify(vm); if (vm.count("help")) { cout << desc << endl; exit(0); } if (vm.count("input-file")) { options.inputFiles = vm["input-file"].as >(); } if (vm.count("name")) { options.names = vm["name"].as >(); } if (vm.count("attribute")) { options.attributes = vm["attribute"].as >(); } return options; } //----------------------------------------------------------------------------// template void printMap(const map m, const string &indent) { typedef pair KeyValuePair; if (m.size() == 0) { cout << indent << "None" << endl; } BOOST_FOREACH(const KeyValuePair &i, m) { cout << indent << i.first << " : " << i.second << endl; } } //----------------------------------------------------------------------------// void printMapping(FieldMapping::Ptr mapping) { cout << " Mapping:" << endl; cout << " Type: " << mapping->className() << endl; // In the case of a MatrixFieldMapping, we print the local to world matrix. MatrixFieldMapping::Ptr matrixMapping = boost::dynamic_pointer_cast(mapping); if (matrixMapping) { M44d m = matrixMapping->localToWorld(); cout << " Local to world transform:" << endl; for (int j = 0; j < 4; ++j) { cout << " "; for (int i = 0; i < 4; ++i) { cout << m[i][j] << " "; } cout << endl; } } } //----------------------------------------------------------------------------// template void printFieldInfo(typename Field::Ptr field, const Options &options) { Box3i dataWindow = field->dataWindow(); Box3i extents = field->extents(); cout << " Field: " << endl << " Name: " << field->name << endl << " Attribute: " << field->attribute << endl << " Field type: " << field->className() << endl << " Data type: " << field->dataTypeString() << endl << " Extents: " << extents.min << " " << extents.max << endl << " Data window: " << dataWindow.min << " " << dataWindow.max << endl; printMapping(field->mapping()); cout << " Int metadata:" << endl; printMap(field->metadata().intMetadata(), " "); cout << " Float metadata:" << endl; printMap(field->metadata().floatMetadata(), " "); cout << " V3i metadata:" << endl; printMap(field->metadata().vecIntMetadata(), " "); cout << " V3f metadata:" << endl; printMap(field->metadata().vecFloatMetadata(), " "); cout << " String metadata:" << endl; printMap(field->metadata().strMetadata(), " "); } //----------------------------------------------------------------------------// bool matchString(const std::string &str, const vector &patterns) { // If patterns is empty all strings match if (patterns.size() == 0) { return true; } // Check all patterns BOOST_FOREACH (const string &pattern, patterns) { boost::regex re(pattern, boost::regex::normal | boost::regex::no_except); if (boost::regex_match(str, re)) { return true; } } // If no pattern matched return false return false; } //----------------------------------------------------------------------------// void printFileInfo(const std::string &filename, const Options &options) { typedef Field3D::half half; Field3DInputFile in; if (!in.open(filename)) { cout << "Error: Couldn't open f3d file: " << filename << endl; exit(1); } cout << "Field3D file: " << filename << endl << " Encoding: " << endl << " " << in.encoding() << endl; vector partitions; in.getPartitionNames(partitions); BOOST_FOREACH (const string &partition, partitions) { if (!matchString(partition, options.names)) { continue; } vector scalarLayers, vectorLayers; in.getScalarLayerNames(scalarLayers, partition); in.getVectorLayerNames(vectorLayers, partition); BOOST_FOREACH (const string &scalarLayer, scalarLayers) { if (!matchString(scalarLayer, options.attributes)) { continue; } Field::Vec hScalarFields = in.readScalarLayers(partition, scalarLayer); BOOST_FOREACH (Field::Ptr field, hScalarFields) { printFieldInfo(field, options); } Field::Vec fScalarFields = in.readScalarLayers(partition, scalarLayer); BOOST_FOREACH (Field::Ptr field, fScalarFields) { printFieldInfo(field, options); } Field::Vec dScalarFields = in.readScalarLayers(partition, scalarLayer); BOOST_FOREACH (Field::Ptr field, dScalarFields) { printFieldInfo(field, options); } } BOOST_FOREACH (const string &vectorLayer, vectorLayers) { if (!matchString(vectorLayer, options.attributes)) { continue; } Field::Vec hVectorFields = in.readVectorLayers(partition, vectorLayer); BOOST_FOREACH (Field::Ptr field, hVectorFields) { printFieldInfo(field, options); } Field::Vec fVectorFields = in.readVectorLayers(partition, vectorLayer); BOOST_FOREACH (Field::Ptr field, fVectorFields) { printFieldInfo(field, options); } Field::Vec dVectorFields = in.readVectorLayers(partition, vectorLayer); BOOST_FOREACH (Field::Ptr field, dVectorFields) { printFieldInfo(field, options); } } } cout << " Global metadata" << endl; cout << " Int metadata:" << endl; printMap(in.metadata().intMetadata(), " "); cout << " Float metadata:" << endl; printMap(in.metadata().floatMetadata(), " "); cout << " V3i metadata:" << endl; printMap(in.metadata().vecIntMetadata(), " "); cout << " V3f metadata:" << endl; printMap(in.metadata().vecFloatMetadata(), " "); cout << " String metadata:" << endl; printMap(in.metadata().strMetadata(), " "); } //----------------------------------------------------------------------------// Field3D-1.7.3/apps/f3dmakemip/000077500000000000000000000000001363220467400157265ustar00rootroot00000000000000Field3D-1.7.3/apps/f3dmakemip/.gitignore000066400000000000000000000000171363220467400177140ustar00rootroot00000000000000build *.dblite Field3D-1.7.3/apps/f3dmakemip/SConscript000066400000000000000000000014571363220467400177470ustar00rootroot00000000000000# ------------------------------------------------------------------------------ import os import sys # ------------------------------------------------------------------------------ pathToRoot = "../.." sys.path.append(pathToRoot) from BuildSupport import * appName = "f3dmakemip" buildPath = buildDir() binPath = join(buildPath, appName) # ------------------------------------------------------------------------------ Import("env") appEnv = env.Clone() setupEnv(appEnv, pathToRoot) addField3DInstall(appEnv, pathToRoot) appEnv.Append(LIBS = ["boost_program_options-mt"]) appEnv.VariantDir(buildPath, ".", duplicate = 0) files = Glob(join(buildPath, "*.cpp")) app = appEnv.Program(binPath, files) appEnv.Default(app) # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/f3dmakemip/SConstruct000066400000000000000000000003421363220467400177570ustar00rootroot00000000000000# ------------------------------------------------------------------------------ env = Environment() Export("env") SConscript("SConscript") # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/f3dmakemip/main.cpp000066400000000000000000000324141363220467400173620ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks Inc. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //----------------------------------------------------------------------------// using namespace std; using namespace Field3D; //----------------------------------------------------------------------------// // Options struct //----------------------------------------------------------------------------// struct Options { Options() : minRes(4), numThreads(8), doMinMax(false), minMaxResMult(0.5), doOgawa(true) { } vector inputFiles; string outputFile; vector names; vector attributes; int minRes; size_t numThreads; bool doMinMax; float minMaxResMult; bool doOgawa; }; //----------------------------------------------------------------------------// // Function prototypes //----------------------------------------------------------------------------// //! Parses command line options, puts them in Options struct. Options parseOptions(int argc, char **argv); //! Prints information about all fields in file. void makeMIP(const std::string &filename, const Options &options, Field3DOutputFile &out); //----------------------------------------------------------------------------// // Function implementations //----------------------------------------------------------------------------// int main(int argc, char **argv) { Field3D::initIO(); Options options = parseOptions(argc, argv); // Set num threads --- Field3D::setNumIOThreads(options.numThreads); // Set HDF5/Ogawa --- Field3DOutputFile::useOgawa(options.doOgawa); if (options.doOgawa) { cout << "Writing Ogawa." << endl; } else { cout << "Writing HDF5." << endl; } // Open output file --- Field3DOutputFile out; if (!out.create(options.outputFile)) { cout << "ERROR: Couldn't create output file: " << options.outputFile << endl; return 1; } BOOST_FOREACH (const string &file, options.inputFiles) { makeMIP(file, options, out); } } //----------------------------------------------------------------------------// Options parseOptions(int argc, char **argv) { namespace po = boost::program_options; Options options; po::options_description desc("Available options"); desc.add_options() ("help,h", "Display help") ("input-file,i", po::value >(), "Input files") ("name,n", po::value >(), "Load field(s) by name") ("attribute,a", po::value >(), "Load field(s) by attribute") ("min-res,m", po::value(), "Smallest MIP level to produce.") ("min-max,x", po::value(), "Whether to generate min/max attributes.") ("min-max-res,r", po::value(), "Resolution multiplier on min/max attributes.") ("num-threads,t", po::value(), "Number of threads to use") ("output-file,o", po::value(), "Output file") ("ogawa,g", po::value(), "Whether to output an Ogawa file.") ; po::variables_map vm; try { po::store(po::parse_command_line(argc, argv, desc), vm); } catch(...) { cerr << "Unknown command line option.\n"; cout << desc << endl; exit(1); } po::notify(vm); po::positional_options_description p; p.add("input-file", -1); try { po::store(po::command_line_parser(argc, argv). options(desc).positional(p).run(), vm); } catch(...) { cerr << "Unknown command line option.\n"; cout << desc << endl; exit(1); } po::notify(vm); if (vm.count("help")) { cout << desc << endl; exit(0); } if (vm.count("input-file")) { options.inputFiles = vm["input-file"].as >(); } if (vm.count("min-res")) { options.minRes = vm["min-res"].as(); } if (vm.count("num-threads")) { options.numThreads = vm["num-threads"].as(); } if (vm.count("name")) { options.names = vm["name"].as >(); } if (vm.count("attribute")) { options.attributes = vm["attribute"].as >(); } if (vm.count("output-file")) { options.outputFile = vm["output-file"].as(); } if (vm.count("min-max")) { options.doMinMax = vm["min-max"].as(); } if (vm.count("min-max-res")) { options.minMaxResMult = vm["min-max-res"].as(); } if (vm.count("ogawa")) { options.doOgawa = vm["ogawa"].as(); } return options; } //----------------------------------------------------------------------------// template void writeField(const typename Field >::Ptr f, Field3DOutputFile &out) { cout << " Writing \"" << f->attribute << "\"" << endl; out.writeVectorLayer(f); } //----------------------------------------------------------------------------// template void writeField(const typename Field::Ptr &f, Field3DOutputFile &out) { cout << " Writing \"" << f->attribute << "\"" << endl; out.writeScalarLayer(f); } //----------------------------------------------------------------------------// template void makeMIP(typename Field::Ptr field, const Options &options, Field3DOutputFile &out) { typedef DenseField DenseType; typedef SparseField SparseType; typedef MIPDenseField MIPDenseType; typedef MIPSparseField MIPSparseType; cout << " Filtering \"" << field->name << ":" << field->attribute << "\" (" << field->classType() << ")" << endl; const V3i offset = computeOffset(*field); // Handle dense fields if (DenseType *dense = dynamic_cast(field.get())) { // MIP typename MIPDenseType::Ptr mip = makeMIP (*dense, options.minRes, offset, options.numThreads); writeField(mip, out); // Min/Max if (options.doMinMax) { std::pair p = makeMinMax(*dense, options.minMaxResMult, options.numThreads); p.first->attribute += k_minSuffix; p.second->attribute += k_maxSuffix; writeField(p.first, out); writeField(p.second, out); } return; } // Handle sparse fields if (SparseType *sparse = dynamic_cast(field.get())) { // MIP typename MIPSparseType::Ptr mip = makeMIP (*sparse, options.minRes, offset, options.numThreads); writeField(mip, out); // Min/Max if (options.doMinMax) { std::pair p = makeMinMax(*sparse, options.minMaxResMult, options.numThreads); p.first->attribute += k_minSuffix; p.second->attribute += k_maxSuffix; writeField(p.first, out); writeField(p.second, out); } return; } // Handle MIP dense fields if (MIPDenseType *dense = dynamic_cast(field.get())) { // MIP typename MIPDenseType::Ptr mip = makeMIP (*dense->concreteMipLevel(0), options.minRes, offset, options.numThreads); writeField(mip, out); // Min/Max if (options.doMinMax) { std::pair p = makeMinMax(*dense->concreteMipLevel(0), options.minMaxResMult, options.numThreads); p.first->attribute += k_minSuffix; p.second->attribute += k_maxSuffix; writeField(p.first, out); writeField(p.second, out); } return; } // Handle MIP sparse fields if (MIPSparseType *sparse = dynamic_cast(field.get())) { // MIP typename MIPSparseType::Ptr mip = makeMIP (*sparse->concreteMipLevel(0), options.minRes, offset, options.numThreads); writeField(mip, out); // Min/Max if (options.doMinMax) { std::pair p = makeMinMax(*sparse->concreteMipLevel(0), options.minMaxResMult, options.numThreads); p.first->attribute += k_minSuffix; p.second->attribute += k_maxSuffix; writeField(p.first, out); writeField(p.second, out); } return; } } //----------------------------------------------------------------------------// void makeMIP(const std::string &filename, const Options &options, Field3DOutputFile &out) { typedef Field3D::half half; Field3DInputFile in; if (!in.open(filename)) { cout << "Error: Couldn't open f3d file: " << filename << endl; exit(1); } cout << "Opening file: " << endl << " " << filename << endl; vector partitions; in.getPartitionNames(partitions); BOOST_FOREACH (const string &partition, partitions) { if (!match(partition, options.names)) { continue; } vector scalarLayers, vectorLayers; in.getScalarLayerNames(scalarLayers, partition); in.getVectorLayerNames(vectorLayers, partition); BOOST_FOREACH (const string &scalarLayer, scalarLayers) { if (!match(scalarLayer, options.attributes)) { continue; } // Skip _min and _max fields if (scalarLayer.find(k_minSuffix) != std::string::npos || scalarLayer.find(k_maxSuffix) != std::string::npos) { cout << " ... skipping " << scalarLayer << endl; } Field::Vec hScalarFields = in.readScalarLayers(partition, scalarLayer); BOOST_FOREACH (Field::Ptr field, hScalarFields) { makeMIP(field, options, out); } Field::Vec fScalarFields = in.readScalarLayers(partition, scalarLayer); BOOST_FOREACH (Field::Ptr field, fScalarFields) { makeMIP(field, options, out); } Field::Vec dScalarFields = in.readScalarLayers(partition, scalarLayer); BOOST_FOREACH (Field::Ptr field, dScalarFields) { makeMIP(field, options, out); } } BOOST_FOREACH (const string &vectorLayer, vectorLayers) { if (!match(vectorLayer, options.attributes)) { continue; } Field::Vec hVectorFields = in.readVectorLayers(partition, vectorLayer); BOOST_FOREACH (Field::Ptr field, hVectorFields) { makeMIP(field, options, out); } Field::Vec fVectorFields = in.readVectorLayers(partition, vectorLayer); BOOST_FOREACH (Field::Ptr field, fVectorFields) { makeMIP(field, options, out); } Field::Vec dVectorFields = in.readVectorLayers(partition, vectorLayer); BOOST_FOREACH (Field::Ptr field, dVectorFields) { makeMIP(field, options, out); } } } } //----------------------------------------------------------------------------// Field3D-1.7.3/apps/f3dmerge/000077500000000000000000000000001363220467400154025ustar00rootroot00000000000000Field3D-1.7.3/apps/f3dmerge/.gitignore000066400000000000000000000000171363220467400173700ustar00rootroot00000000000000build *.dblite Field3D-1.7.3/apps/f3dmerge/SConscript000066400000000000000000000014551363220467400174210ustar00rootroot00000000000000# ------------------------------------------------------------------------------ import os import sys # ------------------------------------------------------------------------------ pathToRoot = "../.." sys.path.append(pathToRoot) from BuildSupport import * appName = "f3dmerge" buildPath = buildDir() binPath = join(buildPath, appName) # ------------------------------------------------------------------------------ Import("env") appEnv = env.Clone() setupEnv(appEnv, pathToRoot) addField3DInstall(appEnv, pathToRoot) appEnv.Append(LIBS = ["boost_program_options-mt"]) appEnv.VariantDir(buildPath, ".", duplicate = 0) files = Glob(join(buildPath, "*.cpp")) app = appEnv.Program(binPath, files) appEnv.Default(app) # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/f3dmerge/SConstruct000066400000000000000000000003421363220467400174330ustar00rootroot00000000000000# ------------------------------------------------------------------------------ env = Environment() Export("env") SConscript("SConscript") # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/f3dmerge/main.cpp000066400000000000000000000210631363220467400170340ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks Inc. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// #include #include #include #include #include #include #include #include #include #include //----------------------------------------------------------------------------// using namespace std; using namespace Field3D; //----------------------------------------------------------------------------// // Options struct //----------------------------------------------------------------------------// struct Options { Options() : numThreads(1), doOgawa(true) { } vector inputFiles; string outputFile; vector names; vector attributes; size_t numThreads; bool doOgawa; }; //----------------------------------------------------------------------------// // Function prototypes //----------------------------------------------------------------------------// //! Parses command line options, puts them in Options struct. Options parseOptions(int argc, char **argv); //! Prints information about all fields in file. void writeOutput(const std::string &filename, const Options &options, Field3DOutputFile &out); //----------------------------------------------------------------------------// // Function implementations //----------------------------------------------------------------------------// int main(int argc, char **argv) { Field3D::initIO(); Options options = parseOptions(argc, argv); // Set num threads --- Field3D::setNumIOThreads(options.numThreads); // Set HDF5/Ogawa --- Field3DOutputFile::useOgawa(options.doOgawa); if (options.doOgawa) { cout << "Converting to Ogawa." << endl; } else { cout << "Converting to HDF5." << endl; } // Open output file --- Field3DOutputFile out; if (!out.create(options.outputFile)) { cout << "ERROR: Couldn't create output file: " << options.outputFile << endl; return 1; } // Write inputs to output --- BOOST_FOREACH (const string &file, options.inputFiles) { writeOutput(file, options, out); } } //----------------------------------------------------------------------------// Options parseOptions(int argc, char **argv) { namespace po = boost::program_options; Options options; po::options_description desc("Available options"); desc.add_options() ("help,h", "Display help") ("input-file,i", po::value >(), "Input files") ("name,n", po::value >(), "Load field(s) by name") ("attribute,a", po::value >(), "Load field(s) by attribute") ("ogawa,g", po::value(), "Whether to output an Ogawa file.") ("num-threads,t", po::value(), "Number of threads to use") ("output-file,o", po::value(), "Output file") ; po::variables_map vm; try { po::store(po::parse_command_line(argc, argv, desc), vm); } catch(...) { cerr << "Unknown command line option.\n"; cout << desc << endl; exit(1); } po::notify(vm); po::positional_options_description p; p.add("input-file", -1); try { po::store(po::command_line_parser(argc, argv). options(desc).positional(p).run(), vm); } catch(...) { cerr << "Unknown command line option.\n"; cout << desc << endl; exit(1); } po::notify(vm); if (vm.count("help")) { cout << desc << endl; exit(0); } if (vm.count("input-file")) { options.inputFiles = vm["input-file"].as >(); } if (vm.count("ogawa")) { options.doOgawa = vm["ogawa"].as(); } if (vm.count("num-threads")) { options.numThreads = vm["num-threads"].as(); } if (vm.count("name")) { options.names = vm["name"].as >(); } if (vm.count("attribute")) { options.attributes = vm["attribute"].as >(); } if (vm.count("output-file")) { options.outputFile = vm["output-file"].as(); } return options; } //----------------------------------------------------------------------------// template void writeField(const typename Field >::Ptr f, Field3DOutputFile &out) { out.writeVectorLayer(f); } //----------------------------------------------------------------------------// template void writeField(const typename Field::Ptr &f, Field3DOutputFile &out) { out.writeScalarLayer(f); } //----------------------------------------------------------------------------// void writeOutput(const std::string &filename, const Options &options, Field3DOutputFile &out) { typedef Field3D::half half; Field3DInputFile in; if (!in.open(filename)) { cout << "Error: Couldn't open f3d file: " << filename << endl; exit(1); } cout << "Opening file: " << endl << " " << filename << endl; vector partitions; in.getPartitionNames(partitions); BOOST_FOREACH (const string &partition, partitions) { if (!match(partition, options.names)) { continue; } vector scalarLayers, vectorLayers; in.getScalarLayerNames(scalarLayers, partition); in.getVectorLayerNames(vectorLayers, partition); BOOST_FOREACH (const string &scalarLayer, scalarLayers) { if (!match(scalarLayer, options.attributes)) { continue; } Field::Vec hScalarFields = in.readScalarLayers(partition, scalarLayer); BOOST_FOREACH (Field::Ptr field, hScalarFields) { writeField(field, out); } Field::Vec fScalarFields = in.readScalarLayers(partition, scalarLayer); BOOST_FOREACH (Field::Ptr field, fScalarFields) { writeField(field, out); } Field::Vec dScalarFields = in.readScalarLayers(partition, scalarLayer); BOOST_FOREACH (Field::Ptr field, dScalarFields) { writeField(field, out); } } BOOST_FOREACH (const string &vectorLayer, vectorLayers) { if (!match(vectorLayer, options.attributes)) { continue; } Field::Vec hVectorFields = in.readVectorLayers(partition, vectorLayer); BOOST_FOREACH (Field::Ptr field, hVectorFields) { writeField(field, out); } Field::Vec fVectorFields = in.readVectorLayers(partition, vectorLayer); BOOST_FOREACH (Field::Ptr field, fVectorFields) { writeField(field, out); } Field::Vec dVectorFields = in.readVectorLayers(partition, vectorLayer); BOOST_FOREACH (Field::Ptr field, dVectorFields) { writeField(field, out); } } } } //----------------------------------------------------------------------------// Field3D-1.7.3/apps/f3dsample/000077500000000000000000000000001363220467400155645ustar00rootroot00000000000000Field3D-1.7.3/apps/f3dsample/.gitignore000066400000000000000000000000171363220467400175520ustar00rootroot00000000000000build *.dblite Field3D-1.7.3/apps/f3dsample/SConscript000066400000000000000000000014561363220467400176040ustar00rootroot00000000000000# ------------------------------------------------------------------------------ import os import sys # ------------------------------------------------------------------------------ pathToRoot = "../.." sys.path.append(pathToRoot) from BuildSupport import * appName = "f3dsample" buildPath = buildDir() binPath = join(buildPath, appName) # ------------------------------------------------------------------------------ Import("env") appEnv = env.Clone() setupEnv(appEnv, pathToRoot) addField3DInstall(appEnv, pathToRoot) appEnv.Append(LIBS = ["boost_program_options-mt"]) appEnv.VariantDir(buildPath, ".", duplicate = 0) files = Glob(join(buildPath, "*.cpp")) app = appEnv.Program(binPath, files) appEnv.Default(app) # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/f3dsample/SConstruct000066400000000000000000000003421363220467400176150ustar00rootroot00000000000000# ------------------------------------------------------------------------------ env = Environment() Export("env") SConscript("SConscript") # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/f3dsample/main.cpp000066400000000000000000000221411363220467400172140ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks Inc. * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// #include #include #include #include #include #include #include #include #include #include #include //----------------------------------------------------------------------------// using namespace std; using namespace Field3D; //----------------------------------------------------------------------------// // Options struct //----------------------------------------------------------------------------// struct Options { Options() : name("field_name"), attribute("field_attribute"), resolution(64), fieldType("DenseField"), fill("small_sphere"), bits(32), isVectorField(false) { } string filename; string name; string attribute; Imath::V3i resolution; string fieldType; string fill; int bits; bool isVectorField; }; //----------------------------------------------------------------------------// // Function prototypes //----------------------------------------------------------------------------// Options parseOptions(int argc, char **argv); void createField(const Options &options); void writeGlobalMetadata(Field3DOutputFile &out); template void createConcreteScalarField(const Options &options); template void createConcreteVectorField(const Options &options); void setCommon(const FieldRes::Ptr field, const Options &options); //----------------------------------------------------------------------------// // Function implementations //----------------------------------------------------------------------------// int main(int argc, char **argv) { Field3D::initIO(); Options options = parseOptions(argc, argv); createField(options); } //----------------------------------------------------------------------------// Options parseOptions(int argc, char **argv) { namespace po = boost::program_options; Options options; po::options_description desc("Available options"); desc.add_options() ("help", "Display help") ("output-file", po::value >(), "Output file(s)") ("name,n", po::value(), "Field name") ("attribute,a", po::value(), "Field attribute") ("type,t", po::value(), "Field type (DenseField/SparseField/MACField)") ("fill,f", po::value(), "Fill with (full_sphere/small_sphere)") ("xres,x", po::value(), "X resolution") ("yres,y", po::value(), "Y resolution") ("zres,z", po::value(), "Z resolution") ("bits,b", po::value(), "Bit depth (16/32/64)") ("vector,v", "Whether to create a vector field") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); po::notify(vm); po::positional_options_description p; p.add("output-file", -1); po::store(po::command_line_parser(argc, argv). options(desc).positional(p).run(), vm); po::notify(vm); if (vm.count("help")) { cout << desc << endl; exit(0); } if (vm.count("output-file")) { if (vm.count("output-file") > 1) { cout << "WARNING: Got more than one output filename. " << "First entry will be used." << endl; } options.filename = vm["output-file"].as >()[0]; } else { cout << "No output file specified." << endl; exit(0); } if (vm.count("name")) { options.name = vm["name"].as(); } if (vm.count("attribute")) { options.attribute = vm["attribute"].as(); } if (vm.count("type")) { options.fieldType = vm["type"].as(); } if (vm.count("xres")) { options.resolution.x = vm["xres"].as(); } if (vm.count("yres")) { options.resolution.y = vm["yres"].as(); } if (vm.count("zres")) { options.resolution.z = vm["zres"].as(); } if (vm.count("bits")) { options.bits = vm["bits"].as(); } if (vm.count("vector")) { options.isVectorField = true; } return options; } //----------------------------------------------------------------------------// void createField(const Options &options) { if (options.isVectorField) { switch (options.bits) { case 64: createConcreteVectorField(options); break; case 32: createConcreteVectorField(options); break; case 16: default: createConcreteVectorField(options); break; } } else { switch (options.bits) { case 64: createConcreteScalarField(options); break; case 32: createConcreteScalarField(options); break; case 16: default: createConcreteScalarField(options); break; } } } //----------------------------------------------------------------------------// void writeGlobalMetadata(Field3DOutputFile &out) { out.metadata().setFloatMetadata("float_global_metadata", 1.0f); out.metadata().setVecFloatMetadata("vec_float_global_metadata", V3f(1.0f)); out.metadata().setIntMetadata("int_global_metadata", 1); out.metadata().setVecIntMetadata("vec_int_global_metadata", V3i(1)); out.metadata().setStrMetadata("str_global_metadata", "string"); out.writeGlobalMetadata(); } //----------------------------------------------------------------------------// template void createConcreteScalarField(const Options &options) { typedef typename ResizableField::Ptr Ptr; Ptr field; if (options.fieldType == "SparseField") { field = Ptr(new SparseField); } else { field = Ptr(new DenseField); } field->setSize(options.resolution); setCommon(field, options); Field3DOutputFile out; out.create(options.filename); out.writeScalarLayer(field); writeGlobalMetadata(out); } //----------------------------------------------------------------------------// template void createConcreteVectorField(const Options &options) { typedef typename ResizableField >::Ptr Ptr; Ptr field; if (options.fieldType == "SparseField") { field = Ptr(new SparseField >); } else if (options.fieldType == "MACField") { field = Ptr(new MACField >); } else { field = Ptr(new DenseField >); } field->setSize(options.resolution); setCommon(field, options); Field3DOutputFile out; out.create(options.filename); out.writeVectorLayer(field); writeGlobalMetadata(out); } //----------------------------------------------------------------------------// void setCommon(const FieldRes::Ptr field, const Options &options) { field->name = options.name; field->attribute = options.attribute; field->metadata().setFloatMetadata("float_metadata", 1.0f); field->metadata().setVecFloatMetadata("vec_float_metadata", V3f(1.0f)); field->metadata().setIntMetadata("int_metadata", 1); field->metadata().setVecIntMetadata("vec_int_metadata", V3i(1)); field->metadata().setStrMetadata("str_metadata", "string"); M44d localToWorld; localToWorld.setScale(options.resolution); localToWorld *= M44d().setTranslation(V3d(1.0, 2.0, 3.0)); MatrixFieldMapping::Ptr mapping(new MatrixFieldMapping); mapping->setLocalToWorld(localToWorld); field->setMapping(mapping); } //----------------------------------------------------------------------------// Field3D-1.7.3/apps/sample_code/000077500000000000000000000000001363220467400161615ustar00rootroot00000000000000Field3D-1.7.3/apps/sample_code/create_and_write/000077500000000000000000000000001363220467400214605ustar00rootroot00000000000000Field3D-1.7.3/apps/sample_code/create_and_write/SConscript000066400000000000000000000013751363220467400235000ustar00rootroot00000000000000# ------------------------------------------------------------------------------ import os import sys # ------------------------------------------------------------------------------ pathToRoot = "../../.." sys.path.append(pathToRoot) from BuildSupport import * buildPath = buildDir() binPath = join(buildPath, os.path.basename(os.getcwd())) # ------------------------------------------------------------------------------ Import("env") appEnv = env.Clone() setupEnv(appEnv, pathToRoot) addField3DInstall(appEnv, pathToRoot) appEnv.VariantDir(buildPath, ".", duplicate = 0) files = Glob(join(buildPath, "*.cpp")) app = appEnv.Program(binPath, files) appEnv.Default(app) # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/sample_code/create_and_write/SConstruct000066400000000000000000000003421363220467400235110ustar00rootroot00000000000000# ------------------------------------------------------------------------------ env = Environment() Export("env") SConscript("SConscript") # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/sample_code/create_and_write/main.cpp000066400000000000000000000054301363220467400231120ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// /* Field3D examples - create and write This sample application creates a DenseField object and writes it to disk. */ //----------------------------------------------------------------------------// #include #include #include #include #include //----------------------------------------------------------------------------// using namespace std; using namespace Field3D; //----------------------------------------------------------------------------// int main(int argc, char **argv) { // Call initIO() to initialize standard I/O methods and load plugins Field3D::initIO(); DenseField::Ptr field(new DenseField); field->name = "hello"; field->attribute = "world"; field->setSize(V3i(50, 50, 50)); field->clear(1.0f); field->metadata().setStrMetadata("my_attribute", "my_value"); Field3DOutputFile out; out.create("field3d_file.f3d"); out.writeScalarLayer(field); } //----------------------------------------------------------------------------// Field3D-1.7.3/apps/sample_code/mixed_types/000077500000000000000000000000001363220467400205135ustar00rootroot00000000000000Field3D-1.7.3/apps/sample_code/mixed_types/SConscript000066400000000000000000000013751363220467400225330ustar00rootroot00000000000000# ------------------------------------------------------------------------------ import os import sys # ------------------------------------------------------------------------------ pathToRoot = "../../.." sys.path.append(pathToRoot) from BuildSupport import * buildPath = buildDir() binPath = join(buildPath, os.path.basename(os.getcwd())) # ------------------------------------------------------------------------------ Import("env") appEnv = env.Clone() setupEnv(appEnv, pathToRoot) addField3DInstall(appEnv, pathToRoot) appEnv.VariantDir(buildPath, ".", duplicate = 0) files = Glob(join(buildPath, "*.cpp")) app = appEnv.Program(binPath, files) appEnv.Default(app) # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/sample_code/mixed_types/SConstruct000066400000000000000000000003421363220467400225440ustar00rootroot00000000000000# ------------------------------------------------------------------------------ env = Environment() Export("env") SConscript("SConscript") # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/sample_code/mixed_types/main.cpp000066400000000000000000000075211363220467400221500ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// /* Field3D examples - mixed types This sample application creates multiple fields and writes them all to the same file. */ //----------------------------------------------------------------------------// #include #include #include #include #include #include #include #include //----------------------------------------------------------------------------// using namespace std; using namespace Field3D; //----------------------------------------------------------------------------// int main(int argc, char **argv) { typedef Field3D::half half; // Call initIO() to initialize standard I/O methods and load plugins --- Field3D::initIO(); // Create a set of fields with different types and bit depths --- // ... First a DenseField DenseField::Ptr denseField(new DenseField); denseField->name = "density_source"; denseField->attribute = "density"; denseField->setSize(V3i(50, 50, 50)); denseField->clear(0.0f); // ... Then two SparseFields to make up a moving levelset SparseField::Ptr sparseField(new SparseField); sparseField->name = "character"; sparseField->attribute = "levelset"; sparseField->setSize(V3i(250, 250, 250)); sparseField->clear(0.0f); SparseField::Ptr sparseVField(new SparseField); sparseVField->name = "character"; sparseVField->attribute = "v"; sparseVField->setSize(V3i(50, 50, 50)); sparseVField->clear(V3f(0.0f)); // ... Finally a MACField, using the typedefs MACField3f::Ptr macField(new MACField3f); macField->name = "simulation"; macField->attribute = "v"; macField->setSize(V3i(120, 50, 100)); macField->clear(V3f(0.0f)); // Write the output --- Field3DOutputFile out; out.create("mixed_file.f3d"); out.writeScalarLayer(denseField); out.writeScalarLayer(sparseField); out.writeVectorLayer(sparseVField); out.writeVectorLayer(macField); } //----------------------------------------------------------------------------// Field3D-1.7.3/apps/sample_code/read/000077500000000000000000000000001363220467400170745ustar00rootroot00000000000000Field3D-1.7.3/apps/sample_code/read/SConscript000066400000000000000000000013751363220467400211140ustar00rootroot00000000000000# ------------------------------------------------------------------------------ import os import sys # ------------------------------------------------------------------------------ pathToRoot = "../../.." sys.path.append(pathToRoot) from BuildSupport import * buildPath = buildDir() binPath = join(buildPath, os.path.basename(os.getcwd())) # ------------------------------------------------------------------------------ Import("env") appEnv = env.Clone() setupEnv(appEnv, pathToRoot) addField3DInstall(appEnv, pathToRoot) appEnv.VariantDir(buildPath, ".", duplicate = 0) files = Glob(join(buildPath, "*.cpp")) app = appEnv.Program(binPath, files) appEnv.Default(app) # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/sample_code/read/SConstruct000066400000000000000000000003421363220467400211250ustar00rootroot00000000000000# ------------------------------------------------------------------------------ env = Environment() Export("env") SConscript("SConscript") # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/sample_code/read/main.cpp000066400000000000000000000116561363220467400205350ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// /* Field3D examples - read This sample application reads all fields found in a given .f3d file and prints their types, names and attributes. */ //----------------------------------------------------------------------------// #include #include #include #include #include #include #include //----------------------------------------------------------------------------// using namespace std; using namespace Field3D; //----------------------------------------------------------------------------// template void readLayersAndPrintInfo(Field3DInputFile &in, const std::string &name) { typedef FIELD3D_VEC3_T VecData_T; typedef typename Field::Vec SFieldList; typedef typename Field >::Vec VFieldList; // Note that both scalar and vector calls take the scalar type as argument SFieldList sFields = in.readScalarLayers(name); VFieldList vFields = in.readVectorLayers(name); // Print info about the found fields --- if (sFields.size() > 0) { for (typename SFieldList::const_iterator i = sFields.begin(); i != sFields.end(); ++i) { if (field_dynamic_cast >(*i)) { cout << " DenseField" << endl; } else if (field_dynamic_cast >(*i)) { cout << " SparseField" << endl; } cout << " Name: " << (**i).name << endl; cout << " Attribute: " << (**i).attribute << endl; } } else { cout << " Found no scalar fields" << endl; } if (vFields.size() > 0) { for (typename VFieldList::const_iterator i = vFields.begin(); i != vFields.end(); ++i) { if (field_dynamic_cast >(*i)) { cout << " DenseField" << endl; } else if (field_dynamic_cast >(*i)) { cout << " SparseField" << endl; } else if (field_dynamic_cast >(*i)) { cout << " MACField" << endl; } cout << " Name: " << (**i).name << endl; cout << " Attribute: " << (**i).attribute << endl; } } else { cout << " Found no vector fields" << endl; } } //----------------------------------------------------------------------------// int main(int argc, char **argv) { typedef Field3D::half half; // Call initIO() to initialize standard I/O methods and load plugins --- Field3D::initIO(); // Process command line --- if (argc < 2) { cout << "Usage: read [name]" << endl; return 1; } string filename = string(argv[1]); string name; if (argc == 3) { name = string(argv[2]); } // Load file --- Field3DInputFile in; if (!in.open(filename)) { cout << "Aborting because of errors" << endl; return 1; } cout << "Reading layers" << endl; readLayersAndPrintInfo(in, name); cout << "Reading layers" << endl; readLayersAndPrintInfo(in, name); cout << "Reading layers" << endl; readLayersAndPrintInfo(in, name); } //----------------------------------------------------------------------------// Field3D-1.7.3/apps/sample_code/sparse_field_io/000077500000000000000000000000001363220467400213105ustar00rootroot00000000000000Field3D-1.7.3/apps/sample_code/sparse_field_io/SConscript000066400000000000000000000013751363220467400233300ustar00rootroot00000000000000# ------------------------------------------------------------------------------ import os import sys # ------------------------------------------------------------------------------ pathToRoot = "../../.." sys.path.append(pathToRoot) from BuildSupport import * buildPath = buildDir() binPath = join(buildPath, os.path.basename(os.getcwd())) # ------------------------------------------------------------------------------ Import("env") appEnv = env.Clone() setupEnv(appEnv, pathToRoot) addField3DInstall(appEnv, pathToRoot) appEnv.VariantDir(buildPath, ".", duplicate = 0) files = Glob(join(buildPath, "*.cpp")) app = appEnv.Program(binPath, files) appEnv.Default(app) # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/sample_code/sparse_field_io/SConstruct000066400000000000000000000003421363220467400233410ustar00rootroot00000000000000# ------------------------------------------------------------------------------ env = Environment() Export("env") SConscript("SConscript") # ------------------------------------------------------------------------------ Field3D-1.7.3/apps/sample_code/sparse_field_io/main.cpp000066400000000000000000000124761363220467400227520ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// #include #include #include #include #include #include #include #include #include //----------------------------------------------------------------------------// using namespace boost; using namespace std; using namespace Field3D; //----------------------------------------------------------------------------// //! Converts any class with operator<< to a string using boost::lexical_cast template std::string str(const T& t) { return boost::lexical_cast(t); } //----------------------------------------------------------------------------// int main(int argc, char **argv) { std::string filename("test_file.f3d"); std::string attribName("attrib"); // Initialize IO initIO(); int numFields = 5; if (argc == 2) { try { numFields = lexical_cast(argv[1]); } catch (boost::bad_lexical_cast &e) { Msg::print("Couldn't parse integer number. Aborting"); exit(1); } } else { // No voxel res given Msg::print("Usage: " + str(argv[0]) + " "); Msg::print("Got no number of fields. Using default."); } // Create fields --- Msg::print("Creating " + str(numFields) + " fields"); SparseFieldf::Vec fields; for (int i = 0; i < numFields; i++) { // Create SparseFieldf::Ptr field(new SparseFieldf); field->setSize(V3i(128)); field->name = str(i); field->attribute = attribName; // Fill with values SparseFieldf::iterator fi = field->begin(), fend = field->end(); for (; fi != fend; ++fi) { *fi = i; } fields.push_back(field); } // Write fields --- Msg::print("Writing fields"); Field3DOutputFile out; out.create(filename); for (int i = 0; i < numFields; i++) { out.writeScalarLayer(fields[i]); } // Read with dynamic loading --- Msg::print("Reading fields"); SparseFileManager::singleton().setLimitMemUse(true); Field::Vec loadedFields; Field3DInputFile in; in.open(filename); for (int i = 0; i < numFields; i++) { Field::Vec fields = in.readScalarLayers(str(i), attribName); if (fields.size() != 1) { Msg::print("Got the wrong # of fields. Aborting."); exit(1); } loadedFields.push_back(fields[0]); } // Compare fields --- Msg::print("Comparing fields"); FIELD3D_RAND48 rng(10512); Msg::print(" Mem use before access: "); for (int i = 0; i < numFields; i++) { Msg::print(" Field " + str(i) + " : " + str(fields[i]->memSize())); Msg::print(" Loaded field " + str(i) + ": " + str(loadedFields[i]->memSize())); } LinearFieldInterp interp; for (int sample = 0; sample < 1000; sample++) { V3d lsP(rng.nextf(), rng.nextf(), rng.nextf()), vsP; for (int i = 0; i < numFields; i++) { fields[i]->mapping()->localToVoxel(lsP, vsP); float value = interp.sample(*fields[i], vsP); float loadedValue = interp.sample(*loadedFields[i], vsP); if (value != loadedValue) { Msg::print("Got a bad value at " + str(vsP)); exit(1); } } } Msg::print(" Mem use after access: "); for (int i = 0; i < numFields; i++) { Msg::print(" Field " + str(i) + " : " + str(fields[i]->memSize())); Msg::print(" Loaded field " + str(i) + ": " + str(loadedFields[i]->memSize())); } } //----------------------------------------------------------------------------// Field3D-1.7.3/cmake/000077500000000000000000000000001363220467400140235ustar00rootroot00000000000000Field3D-1.7.3/cmake/FindILMBase.cmake000066400000000000000000000044521363220467400170470ustar00rootroot00000000000000# Copyright (c) 2009 Sony Pictures Imageworks Inc. et al. # # All rights reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # # Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the # distribution. Neither the name of Sony Pictures Imageworks nor the # names of its contributors may be used to endorse or promote # products derived from this software without specific prior written # permission. # # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED # OF THE POSSIBILITY OF SUCH DAMAGE. # Author : Nicholas Yue yue.nicholas@gmail.com # This module will define the following variables: # ILMBASE_INCLUDE_DIRS - Location of the ilmbase includes # ILMBASE_LIBRARIES - [TODO] Required libraries for all requested bindings # ILMBASE_FOUND - true if ILMBASE was found on the system # ILMBASE_LIBRARY_DIRS - the full set of library directories FIND_PATH ( Ilmbase_Base_Dir NAMES include/OpenEXR/IlmBaseConfig.h PATHS ${ILMBASE_ROOT} ) IF ( Ilmbase_Base_Dir ) SET ( ILMBASE_INCLUDE_DIRS ${Ilmbase_Base_Dir}/include ${Ilmbase_Base_Dir}/include/OpenEXR CACHE STRING "ILMBase include directories") SET ( ILMBASE_LIBRARY_DIRS ${Ilmbase_Base_Dir}/lib64 CACHE STRING "ILMBase library directories") SET ( ILMBASE_FOUND TRUE ) ENDIF ( Ilmbase_Base_Dir ) Field3D-1.7.3/contrib/000077500000000000000000000000001363220467400144035ustar00rootroot00000000000000Field3D-1.7.3/contrib/maya_plugin/000077500000000000000000000000001363220467400167105ustar00rootroot00000000000000Field3D-1.7.3/contrib/maya_plugin/exportF3d/000077500000000000000000000000001363220467400205665ustar00rootroot00000000000000Field3D-1.7.3/contrib/maya_plugin/exportF3d/Makefile.gnu000066400000000000000000000026771363220467400230320ustar00rootroot00000000000000# edit this if your maya installation is somewhere else. MAYA_LOCATION = /net/apps/spinux1/aw/maya2012 #edit this for the Field3D installation directory FIELD3D_ROOT = /usr/3rd_party_software/Field3D FIELD3D_INC = $(FIELD3D_ROOT)/include FIELD3D_LIB = $(FIELD3D_ROOT)/lib C++ = g++ CFLAGS = -DBits64_ -m64 -DUNIX -D_BOOL -DLINUX -DFUNCPROTO -D_GNU_SOURCE \ -DLINUX_64 -fPIC \ -fno-strict-aliasing -DREQUIRE_IOSTREAM -Wno-deprecated -O3 -Wall \ -Wno-multichar -Wno-comment -Wno-sign-compare -funsigned-char \ -Wno-reorder -fno-gnu-keywords -ftemplate-depth-25 -pthread C++FLAGS = $(CFLAGS) $(WARNFLAGS) -Wno-deprecated -fno-gnu-keywords INCLUDES = -I. -I.. -I$(MAYA_LOCATION)/include \ -I/usr/X11R6/include \ -I/usr/include/OpenEXR \ -I$(FIELD3D_INC) LD = $(C++) -shared $(NO_TRANS_LINK) $(C++FLAGS) # add more libs if you need to for your plugin LIBS = -L$(MAYA_LOCATION)/lib -lOpenMaya\ -Wl,-rpath,$(FIELD3D_LIB) -L$(FIELD3D_LIB) -lField3D exportF3d.so: exportF3d.o -rm -f $@ $(LD) -o $@ $^ $(LIBS) -lOpenMayaAnim -lOpenMayaFX depend: makedepend $(INCLUDES) -I/usr/include/CC *.cc clean: -rm -f *.o Clean: -rm -f *.o *.so *.lib *.bak *.bundle ################## # Generic Rules # ################## %.o : %.cpp $(C++) -c $(INCLUDES) $(C++FLAGS) $< %.$(so) : %.cpp -rm -f $@ $(C++) -o $@ $(INCLUDES) $(C++FLAGS) $< $(LFLAGS) $(LIBS) %.$(so) : %.o -rm -f $@ $(LD) -o $@ $< $(LIBS) Field3D-1.7.3/contrib/maya_plugin/exportF3d/exportF3d.cpp000066400000000000000000000466561363220467400231710ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks Inc * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// /*! \file exportF3d.cpp \brief Simple exporter for Maya Fluid to f3d format. density, temperature, fuel are exported automatically if they are valid, all other fields require flags. */ #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define ERRCHKR \ if ( MS::kSuccess != stat ) { \ cerr << stat.errorString(); \ return stat; \ } #define ERRCHK \ if ( MS::kSuccess != stat ) { \ cerr << stat.errorString(); \ } using namespace std; using namespace Field3D; //----------------------------------------------------------------------------// class exportF3d : public MPxCommand { public: exportF3d(); virtual ~exportF3d() {} MStatus doIt(const MArgList&); static void* creator(){ return new exportF3d(); } static MSyntax newSyntax(); private: void setF3dField(MFnFluid &fluidFn, const char *outputPath, const MDagPath &dagPath); private: MStatus parseArgs( const MArgList& args ); MString m_outputPath; bool m_verbose; MSelectionList m_slist; int m_start; //<-start of simulation int m_end; //<-end of simulation bool m_density; //<- export densiyt as well bool m_temperature; //<- export temprature as well bool m_fuel; //<- export fuel as well bool m_color; //<- export color as well bool m_vel; //<- export velocity as well bool m_pressure; //<- export presurre as well bool m_texture; //<- export texture as well bool m_falloff; //<- export falloff as well int m_numOversample; //<- oversamples the fluids but only writes out on whole frames }; //----------------------------------------------------------------------------// exportF3d::exportF3d() { m_start = 1; m_end = 1; m_verbose = false; m_density = true; m_temperature = true; m_fuel = true; m_color = false; m_vel = false; m_pressure = false; m_texture = false; m_falloff = false; m_numOversample = 1; } //----------------------------------------------------------------------------// MSyntax exportF3d::newSyntax() { MSyntax syntax; MStatus stat; stat = syntax.addFlag("-st", "-startTime", MSyntax::kLong);ERRCHK; stat = syntax.addFlag("-et", "-endTime", MSyntax::kLong);ERRCHK; stat = syntax.addFlag("-o", "-outputPath", MSyntax::kString);ERRCHK; stat = syntax.addFlag("-av", "-addVelocity", MSyntax::kNoArg);ERRCHK; stat = syntax.addFlag("-ac", "-addColor",MSyntax::kNoArg);ERRCHK; stat = syntax.addFlag("-ap", "-addPressure",MSyntax::kNoArg);ERRCHK; stat = syntax.addFlag("-at", "-addTexture",MSyntax::kNoArg);ERRCHK; stat = syntax.addFlag("-af", "-addFalloff",MSyntax::kNoArg);ERRCHK; stat = syntax.addFlag("-ns", "-numOversample",MSyntax::kLong);ERRCHK; stat = syntax.addFlag("-d", "-debug");ERRCHK; syntax.addFlag("-h", "-help"); // DEFINE BEHAVIOUR OF COMMAND ARGUMENT THAT SPECIFIES THE MESH NODE: syntax.useSelectionAsDefault(true); stat = syntax.setObjectType(MSyntax::kSelectionList, 1); // MAKE COMMAND QUERYABLE AND NON-EDITABLE: syntax.enableQuery(false); syntax.enableEdit(false); return syntax; } MStatus exportF3d::parseArgs( const MArgList &args ) { MStatus status; MArgDatabase argData(syntax(), args); if (argData.isFlagSet("-debug")) m_verbose = true; if (argData.isFlagSet("-help")) { MString help = ( "\nexportF3d is used to export 3D fluid data to either f3d\n" "Synopsis: exportF3d [flags] [fluidObject... ]\n" "Flags:\n" " -o -outputPath String outputPath won't work with element name\n" " -st -startTime int Start of simulation\n" " -et -endTime int End of simulation\n" " -av -addVelocity Export velocity as v_mac\n" " -ac -addColor Export color data\n" " -ap -addPressure Export pressure data\n" " -at -addTexture Export texture\n" " -af -addFalloff Export falloff\n" " -ns -numOversample Oversamples the solver at each sum frame but\n" " only writes out whole frame sim data\n" " -d -debug\n" " -h -help\n" "Example:\n" "1- exportF3d -st 1 -et 100 -o \"/tmp/\" fluidObject \n\n" ); MGlobal::displayInfo(help); return MS::kFailure; } if (argData.isFlagSet("-startTime")) { status = argData.getFlagArgument("-startTime", 0, m_start); } if (argData.isFlagSet("-endTime")) { status = argData.getFlagArgument("-endTime", 0, m_end); }else m_end = m_start; if (argData.isFlagSet("-addColor")) m_color = true; if (argData.isFlagSet("-addVelocity")) m_vel = true; if (argData.isFlagSet("-addPressure")) m_pressure = true; if (argData.isFlagSet("-addTexture")) m_texture = true; if (argData.isFlagSet("-addFalloff")) m_falloff = true; if (argData.isFlagSet("-outputPath")) { status = argData.getFlagArgument("-outputPath", 0, m_outputPath); } if (!argData.isFlagSet("-outputPath") ) { MGlobal::displayInfo("outputPath is required"); return MS::kFailure; } if (argData.isFlagSet("-numOversample")) { status = argData.getFlagArgument("-numOversample", 0, m_numOversample); if (m_numOversample < 1) { m_numOversample = 1; MGlobal::displayWarning("numOversample can't be less than one, setting it to 1"); } } status = argData.getObjects(m_slist); if (!status) { status.perror("no fluid object was selected"); return status; } // Get the selected Fluid Systems if (m_slist.length() > 1) { MGlobal::displayWarning("[exportF3d]: only first fluid object is used to export"); } return MS::kSuccess; } MStatus exportF3d::doIt(const MArgList& args) { MStatus status; MString result; status = parseArgs(args); if (!status) { status.perror("Parsing error"); return status; } float currentFrame = MAnimControl::currentTime().value(); MItSelectionList selListIter(m_slist, MFn::kFluid, &status); for (; !selListIter.isDone(); selListIter.next()) { MDagPath dagPath; MObject selectedObject; status = selListIter.getDependNode(selectedObject); status = selListIter.getDagPath(dagPath); // Create function set for the fluid MFnFluid fluidFn(dagPath, &status); if (status != MS::kSuccess) continue; if (m_verbose) { cout << "------------------------------------------------------" << endl; cout << " Selected object: " << fluidFn.name() << endl; cout << " Selected object type: " << selectedObject.apiTypeStr() << endl; cout << endl << endl; } MFnFluid::FluidMethod method; MFnFluid::FluidGradient gradient; status = fluidFn.getDensityMode(method, gradient); if(method != MFnFluid::kStaticGrid && method != MFnFluid::kDynamicGrid) { m_density = false; } status = fluidFn.getTemperatureMode(method, gradient); if(method != MFnFluid::kStaticGrid && method != MFnFluid::kDynamicGrid) { m_temperature = false; } status = fluidFn.getFuelMode(method, gradient); if(method != MFnFluid::kStaticGrid && method != MFnFluid::kDynamicGrid) { m_fuel = false; } status = fluidFn.getVelocityMode(method, gradient); if(method != MFnFluid::kStaticGrid && method != MFnFluid::kDynamicGrid) { m_vel = false; } if (m_color) { MFnFluid::ColorMethod colorMethod; fluidFn.getColorMode(colorMethod); if(colorMethod == MFnFluid::kUseShadingColor) { m_color = false; } } if (!m_vel) { // Note that the pressure data only exists if the velocity method // is kStaticGrid or kDynamicGrid m_pressure = false; } if (m_falloff) { MFnFluid::FalloffMethod falloffMethod; status = fluidFn.getFalloffMode(falloffMethod); if(falloffMethod != MFnFluid::kNoFalloffGrid ) { m_falloff = false; } } // Go through the selected frame range MComputation computation; computation.beginComputation(); char fluidPath[1024]; for(int frame=m_start ; frame <= m_end; ++frame) { int numOversample = m_numOversample; if (frame == m_start) numOversample = 1; float dt = 1.0/double(numOversample); for ( int s=numOversample-1 ; s >= 0 ; --s) { if (computation.isInterruptRequested()) break ; float time = frame - s*dt; status = MAnimControl::setCurrentTime(time); //MPlug plugGrid = fluidFn.findPlug( "outGrid",true,&status); MGlobal::displayInfo(MString("Setting Current frame ")+time); } sprintf(fluidPath, "%s/%s.%04d.f3d", m_outputPath.asChar(), fluidFn.name().asChar(),frame); MGlobal::displayInfo(MString("Writting: ")+fluidPath); setF3dField(fluidFn, fluidPath, dagPath); } computation.endComputation(); // only one fluid object break; } setResult(result); MAnimControl::setCurrentTime(currentFrame); return MS::kSuccess; } ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// void exportF3d::setF3dField(MFnFluid &fluidFn, const char *outputPath, const MDagPath &dagPath) { try { MStatus stat; unsigned int i, xres = 0, yres = 0, zres = 0; double xdim,ydim,zdim; // Get the resolution of the fluid container stat = fluidFn.getResolution(xres, yres, zres); stat = fluidFn.getDimensions(xdim, ydim, zdim); V3d size(xdim,ydim,zdim); const V3i res(xres, yres, zres); int psizeTot = fluidFn.gridSize(); /// get the transform and rotation MObject parentObj = fluidFn.parent(0, &stat); if (stat != MS::kSuccess) { MGlobal::displayError("Can't find fluid's parent node"); return; } MDagPath parentPath = dagPath; parentPath.pop(); MTransformationMatrix tmatFn(dagPath.inclusiveMatrix()); if (stat != MS::kSuccess) { MGlobal::displayError("Failed to get transformation matrix of fluid's parent node"); return; } MFnTransform fnXform(parentPath, &stat); if (stat != MS::kSuccess) { MGlobal::displayError("Can't create a MFnTransform from fluid's parent node"); return; } if (m_verbose) { fprintf(stderr, "cellnum: %dx%dx%d = %d\n", xres, yres, zres,psizeTot); } float *density(NULL), *temp(NULL), *fuel(NULL); float *pressure(NULL), *falloff(NULL); density = fluidFn.density( &stat ); if ( stat.error() ) m_density = false; temp = fluidFn.temperature( &stat ); if ( stat.error() ) m_temperature = false; fuel = fluidFn.fuel( &stat ); if ( stat.error() ) m_fuel = false; pressure= fluidFn.pressure( &stat ); if ( stat.error() ) m_pressure = false; falloff = fluidFn.falloff( &stat ); if ( stat.error() ) m_falloff = false; float *r,*g,*b; if (m_color) { stat = fluidFn.getColors(r,b,g); if ( stat.error() ) m_color = false; }else m_color = false; float *u,*v,*w; if (m_texture) { stat = fluidFn.getCoordinates(u,v,w); if ( stat.error() ) m_texture = false; }else m_texture = false; /// velocity info float *Xvel(NULL),*Yvel(NULL), *Zvel(NULL); if (m_vel) { stat = fluidFn.getVelocity( Xvel,Yvel,Zvel ); if ( stat.error() ) m_vel = false; } if (m_density == false && m_temperature==false && m_fuel==false && m_pressure==false && m_falloff==false && m_vel == false && m_color == false && m_texture==false) { MGlobal::displayError("No fluid attributes found for writing, please check fluids settings"); return; } /// Fields DenseFieldf::Ptr densityFld, tempFld, fuelFld, pressureFld, falloffFld; DenseField3f::Ptr CdFld, uvwFld; MACField3f::Ptr vMac; MPlug autoResizePlug = fluidFn.findPlug("autoResize", &stat); bool autoResize; autoResizePlug.getValue(autoResize); // maya's fluid transformation V3d dynamicOffset(0); M44d localToWorld; MatrixFieldMapping::Ptr mapping(new MatrixFieldMapping()); M44d fluid_mat(tmatFn.asMatrix().matrix); if(autoResize) { fluidFn.findPlug("dofx").getValue(dynamicOffset[0]); fluidFn.findPlug("dofy").getValue(dynamicOffset[1]); fluidFn.findPlug("dofz").getValue(dynamicOffset[2]); } Box3i extents; extents.max = res - V3i(1); extents.min = V3i(0); mapping->setExtents(extents); localToWorld.setScale(size); localToWorld *= M44d().setTranslation( -(size*0.5) ); localToWorld *= M44d().setTranslation( dynamicOffset ); localToWorld *= fluid_mat; mapping->setLocalToWorld(localToWorld); if (m_density){ densityFld = new DenseFieldf; densityFld->setSize(res); densityFld->setMapping(mapping); } if (m_fuel){ fuelFld = new DenseFieldf; fuelFld->setSize(res); fuelFld->setMapping(mapping); } if (m_temperature){ tempFld = new DenseFieldf; tempFld->setSize(res); tempFld->setMapping(mapping); } if (m_pressure){ pressureFld = new DenseFieldf; pressureFld->setSize(res); pressureFld->setMapping(mapping); } if (m_falloff){ falloffFld = new DenseFieldf; falloffFld->setSize(res); falloffFld->setMapping(mapping); } if (m_vel){ vMac = new MACField3f; vMac->setSize(res); vMac->setMapping(mapping); } if (m_color){ CdFld = new DenseField3f; CdFld->setSize(res); CdFld->setMapping(mapping); } if (m_texture){ uvwFld = new DenseField3f; uvwFld->setSize(res); uvwFld->setMapping(mapping); } size_t iX, iY, iZ; for( iZ = 0; iZ < zres; iZ++ ) { for( iX = 0; iX < xres; iX++ ) { for( iY = 0; iY < yres ; iY++ ) { /// data is in x major but we are writting in z major order i = fluidFn.index( iX, iY, iZ); if ( m_density ) densityFld->lvalue(iX, iY, iZ) = density[i]; if ( m_temperature ) tempFld->lvalue(iX, iY, iZ) = temp[i]; if ( m_fuel ) fuelFld->lvalue(iX, iY, iZ) = fuel[i]; if ( m_pressure ) pressureFld->lvalue(iX, iY, iZ) = pressure[i]; if ( m_falloff ) falloffFld->lvalue(iX, iY, iZ) = falloff[i]; if (m_color) CdFld->lvalue(iX, iY, iZ) = V3f(r[i], g[i], b[i]); if (m_texture) uvwFld->lvalue(iX, iY, iZ) = V3f(u[i], v[i], w[i]); } } } if (m_vel) { unsigned x,y,z; for(z=0;zu(x,y,z) = *Xvel++; } for(z=0;zv(x,y,z) = *Yvel++; } for(z=0;zw(x,y,z) = *Zvel++; } } Field3DOutputFile out; if (!out.create(outputPath)) { MGlobal::displayError("Couldn't create file: "+ MString(outputPath)); return; } string fieldname("maya"); if (m_density){ out.writeScalarLayer(fieldname, "density", densityFld); } if (m_fuel) { out.writeScalarLayer(fieldname,"fuel", fuelFld); } if (m_temperature){ out.writeScalarLayer(fieldname,"temperature", tempFld); } if (m_color) { out.writeVectorLayer(fieldname,"Cd", CdFld); } if (m_vel) out.writeVectorLayer(fieldname,"v_mac", vMac); out.close(); } catch(const std::exception &e) { MGlobal::displayError( MString(e.what()) ); return; } } ///////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////// MStatus initializePlugin( MObject obj ) { MStatus status; MFnPlugin plugin( obj, "Open Source Field3D, Sosh Mirsepassi", "1.3.1", "Any" ); status = plugin.registerCommand("exportF3d", exportF3d::creator, exportF3d::newSyntax); if (!status) { status.perror("registerCommand"); return status; } Field3D::initIO(); return status; } MStatus uninitializePlugin( MObject obj) { MStatus status; MFnPlugin plugin( obj ); status = plugin.deregisterCommand("exportF3d"); if (!status) { status.perror("deregisterCommand"); return status; } return status; } ///////////////////////////////////////////////////////////////////// Field3D-1.7.3/export/000077500000000000000000000000001363220467400142645ustar00rootroot00000000000000Field3D-1.7.3/export/ClassFactory.h000066400000000000000000000133171363220467400170370ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks Inc * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// /*! \file ClassFactory.h \brief Contains the ClassFactory class for registering Field3D classes. */ //----------------------------------------------------------------------------// #ifndef _INCLUDED_Field3D_ClassFactory_H_ #define _INCLUDED_Field3D_ClassFactory_H_ #include #include #include #include "Field.h" #include "FieldIO.h" #include "FieldMappingIO.h" //----------------------------------------------------------------------------// #include "ns.h" FIELD3D_NAMESPACE_OPEN //----------------------------------------------------------------------------// // ClassFactory //----------------------------------------------------------------------------// /*! \class ClassFactory \ingroup field_int */ //----------------------------------------------------------------------------// class FIELD3D_API ClassFactory { public: // Typedefs ------------------------------------------------------------------ typedef FieldRes::Ptr (*CreateFieldFnPtr) (); typedef FieldIO::Ptr (*CreateFieldIOFnPtr) (); typedef FieldMapping::Ptr (*CreateFieldMappingFnPtr) (); typedef FieldMappingIO::Ptr (*CreateFieldMappingIOFnPtr) (); // Ctors, dtor --------------------------------------------------------------- //! Standard constructor ClassFactory(); // Main methods -------------------------------------------------------------- //! \name Field class //! \{ //! Registers a class with the class pool. //! \param createFunc Pointer to creation function void registerField(CreateFieldFnPtr createFunc); //! Instances an object by name FieldRes::Ptr createField(const std::string &className) const; //! Registers an IO class with the class pool. //! \param createFunc Pointer to creation function void registerFieldIO(CreateFieldIOFnPtr createFunc); //! Instances an IO object by name FieldIO::Ptr createFieldIO(const std::string &className) const; //! } //! \name FieldMapping class //! \{ //! Registers a class with the class pool. //! \param createFunc Pointer to creation function void registerFieldMapping(CreateFieldMappingFnPtr createFunc); //! Instances an object by name FieldMapping::Ptr createFieldMapping(const std::string &className) const; //! Registers an IO class with the class pool. //! \param createFunc Pointer to creation function void registerFieldMappingIO(CreateFieldMappingIOFnPtr createFunc); //! Instances an IO object by name FieldMappingIO::Ptr createFieldMappingIO(const std::string &className) const; //! } //! Access point for the singleton instance. static ClassFactory& singleton(); private: // Typedefs ------------------------------------------------------------------ typedef std::vector NameVec; typedef std::map FieldFuncMap; typedef std::map FieldIOFuncMap; typedef std::map FieldMappingFuncMap; typedef std::map FieldMappingIOFuncMap; // Data members -------------------------------------------------------------- //! Map of create functions for Fields. The key is the class name. FieldFuncMap m_fields; //! NameVec m_fieldNames; //! Map of create functions for FieldIO classes. The key is the class name. FieldIOFuncMap m_fieldIOs; //! NameVec m_fieldIONames; //! Map of create functions for FieldMappings. The key is the class name. FieldMappingFuncMap m_mappings; //! NameVec m_fieldMappingNames; //! Map of create functions for FieldMapping IO classes. //! The key is the class name. FieldMappingIOFuncMap m_mappingIOs; //! NameVec m_fieldMappingIONames; //! Pointer to static instance static boost::scoped_ptr ms_instance; }; //----------------------------------------------------------------------------// FIELD3D_NAMESPACE_HEADER_CLOSE //----------------------------------------------------------------------------// #endif // Include guard Field3D-1.7.3/export/CoordSys.h000066400000000000000000000160651363220467400162120ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2014 Sony Pictures Imageworks Inc * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// /*! \file CoordSys.h \brief Contains utility functions for constructing coordinate systems. */ //----------------------------------------------------------------------------// #ifndef _INCLUDED_Field3D_CoordSys_H_ #define _INCLUDED_Field3D_CoordSys_H_ //----------------------------------------------------------------------------// // System includes #include #include "Types.h" //----------------------------------------------------------------------------// #include "ns.h" FIELD3D_NAMESPACE_OPEN //----------------------------------------------------------------------------// // Utility functions //----------------------------------------------------------------------------// //! Constructs a coordinate systems given a set of basis vectors and an origin. template FIELD3D_MTX_T coordinateSystem(const FIELD3D_VEC3_T &e1, const FIELD3D_VEC3_T &e2, const FIELD3D_VEC3_T &e3, const FIELD3D_VEC3_T &origin); //! Constructs a coordinate system given a bounding box template FIELD3D_MTX_T coordinateSystem(const FIELD3D_BOX_T > &wsBounds); //! Constructs a coordinate system that has its lower left corner at an //! even multiplier of the voxel-size, to ensure that voxel centers don't //! shift as the domain grows template FIELD3D_MTX_T coordinateSystem(const FIELD3D_BOX_T > &wsBounds, const FIELD3D_VEC3_T &wsVoxelSize, Box3i &extents); //! Constructs a coordinate system that has its lower left corner at an //! even multiplier of the voxel-size, to ensure that voxel centers don't //! shift as the domain grows template FIELD3D_MTX_T coordinateSystem(const FIELD3D_BOX_T > &wsBounds, const FIELD3D_VEC3_T &wsVoxelSize); //----------------------------------------------------------------------------// // Detail namespace //----------------------------------------------------------------------------// namespace detail { //--------------------------------------------------------------------------// //! Floor function for Vec3 template FIELD3D_VEC3_T floor(const FIELD3D_VEC3_T &v) { return FIELD3D_VEC3_T(std::floor(v.x), std::floor(v.y), std::floor(v.z)); } //--------------------------------------------------------------------------// //! Ceil function for Vec3 template FIELD3D_VEC3_T ceil(const FIELD3D_VEC3_T &v) { return FIELD3D_VEC3_T(std::ceil(v.x), std::ceil(v.y), std::ceil(v.z)); } //--------------------------------------------------------------------------// } // Detail namespace //----------------------------------------------------------------------------// // Template implementations //----------------------------------------------------------------------------// template FIELD3D_MTX_T coordinateSystem(const FIELD3D_VEC3_T &e1, const FIELD3D_VEC3_T &e2, const FIELD3D_VEC3_T &e3, const FIELD3D_VEC3_T &origin) { FIELD3D_MTX_T m; m[0][0] = e1.x; m[0][1] = e1.y; m[0][2] = e1.z; m[1][0] = e2.x; m[1][1] = e2.y; m[1][2] = e2.z; m[2][0] = e3.x; m[2][1] = e3.y; m[2][2] = e3.z; m[3][0] = origin.x; m[3][1] = origin.y; m[3][2] = origin.z; return m; } //----------------------------------------------------------------------------// template FIELD3D_MTX_T coordinateSystem(const FIELD3D_BOX_T > &wsBounds, const FIELD3D_VEC3_T &wsVoxelSize, Box3i &extents) { const FIELD3D_VEC3_T voxelMin = detail::floor(wsBounds.min / wsVoxelSize) * wsVoxelSize; const FIELD3D_VEC3_T voxelMax = detail::ceil(wsBounds.max / wsVoxelSize) * wsVoxelSize; // Resolution extents.min = V3i(detail::floor(voxelMin / wsVoxelSize) + V3f(0.5)); extents.max = V3i(detail::floor(voxelMax / wsVoxelSize) + V3f(0.5)); // Bounding box const FIELD3D_BOX_T > box(voxelMin, voxelMax); return coordinateSystem(box); } //----------------------------------------------------------------------------// template FIELD3D_MTX_T coordinateSystem (const FIELD3D_BOX_T > &wsBounds, const FIELD3D_VEC3_T &wsVoxelSize) { Box3i dummy; return coordinateSystem(wsBounds, wsVoxelSize, dummy); } //----------------------------------------------------------------------------// template FIELD3D_MTX_T coordinateSystem (const FIELD3D_BOX_T > &wsBounds) { FIELD3D_VEC3_T e1(wsBounds.max.x - wsBounds.min.x, 0, 0); FIELD3D_VEC3_T e2(0, wsBounds.max.y - wsBounds.min.y, 0); FIELD3D_VEC3_T e3(0, 0, wsBounds.max.z - wsBounds.min.z); FIELD3D_VEC3_T origin(wsBounds.min); return coordinateSystem(e1, e2, e3, origin); } //----------------------------------------------------------------------------// FIELD3D_NAMESPACE_HEADER_CLOSE //----------------------------------------------------------------------------// #endif // Include guard Field3D-1.7.3/export/Curve.h000066400000000000000000000205001363220467400155160ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks Inc * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// /*! \file Curve.h \brief Contains the Curve class which is used to interpolate attributes in time. */ //----------------------------------------------------------------------------// #ifndef _INCLUDED_Field3D_Curve_H_ #define _INCLUDED_Field3D_Curve_H_ //----------------------------------------------------------------------------// #include #include #include #include #include #include //----------------------------------------------------------------------------// #include "ns.h" FIELD3D_NAMESPACE_OPEN //----------------------------------------------------------------------------// // Curve //----------------------------------------------------------------------------// /*! \class Curve \brief Implements a simple function curve where samples of type T can be added along a 1D axis. Once samples exist they can be interpolated using the linear() call. */ //----------------------------------------------------------------------------// template class Curve { public: // Typedefs ------------------------------------------------------------------ typedef std::pair Sample; typedef std::vector SampleVec; // Main methods -------------------------------------------------------------- //! Adds a sample point to the curve. //! \param t Sample position //! \param value Sample value void addSample(const float t, const T &value); //! Linearly interpolates a value from the curve. //! \param t Position along curve T linear(const float t) const; //! Returns the number of samples in the curve size_t numSamples() const { return m_samples.size(); } //! Returns a const reference to the samples in the curve. const SampleVec& samples() const { return m_samples; } //! Clears all samples in curve void clear() { SampleVec().swap(m_samples); } private: // Structs ------------------------------------------------------------------- //! Used when finding values in the m_samples vector. struct CheckTGreaterThan : public std::unary_function, bool> { CheckTGreaterThan(float match) : m_match(match) { } bool operator()(std::pair test) { return test.first > m_match; } private: float m_match; }; //! Used when finding values in the m_samples vector. struct CheckTEqual : public std::unary_function, bool> { CheckTEqual(float match) : m_match(match) { } bool operator()(std::pair test) { return test.first == m_match; } private: float m_match; }; // Utility methods ----------------------------------------------------------- //! The default return value is used when no sample points are available. //! This defaults to zero, but for some types (for example Quaternion), //! We need more arguments to the constructor. In these cases the method //! is specialized for the given T type. T defaultReturnValue() const { return T(0); } //! The default implementation for linear interpolation. Works for all classes //! for which Imath::lerp is implemented (i.e float/double, V2f, V3f). //! For other types this method needs to be specialized. T lerp(const Sample &lower, const Sample &upper, const float t) const { return Imath::lerp(lower.second, upper.second, t); } // Private data members ------------------------------------------------------ //! Stores the samples that define the curve. Sample insertion ensures //! that the samples are sorted according to Sample.first. SampleVec m_samples; }; //----------------------------------------------------------------------------// // Template implementations //----------------------------------------------------------------------------// template void Curve::addSample(const float t, const T &value) { using namespace std; // Check that sample time is not already in curve typename SampleVec::iterator i = find_if(m_samples.begin(), m_samples.end(), CheckTEqual(t)); if (i != m_samples.end()) { // Sample position already exists, so we replace it i->second = value; return; } // Find the first sample location that is greater than the interpolation // position i = find_if(m_samples.begin(), m_samples.end(), CheckTGreaterThan(t)); // If we get something other than end() back then we insert the new // sample before that. If there wasn't a larger value we add this sample // to the end of the vector. if (i != m_samples.end()) { m_samples.insert(i, make_pair(t, value)); } else { m_samples.push_back(make_pair(t, value)); } } //----------------------------------------------------------------------------// template T Curve::linear(const float t) const { using namespace std; // If there are no samples, return zero if (m_samples.size() == 0) { return defaultReturnValue(); } // Find the first sample location that is greater than the interpolation // position typename SampleVec::const_iterator i = find_if(m_samples.begin(), m_samples.end(), CheckTGreaterThan(t)); // If we get end() back then there was no sample larger, so we return the // last value. If we got the first value then there is only one value and // we return that. if (i == m_samples.end()) { return m_samples.back().second; } else if (i == m_samples.begin()) { return m_samples.front().second; } // Interpolate between the nearest two samples. const Sample &upper = *i; const Sample &lower = *(--i); const float interpT = Imath::lerpfactor(t, lower.first, upper.first); return lerp(lower, upper, interpT); } //----------------------------------------------------------------------------// // Template specializations //----------------------------------------------------------------------------// template <> inline Imath::Matrix44 Curve >::defaultReturnValue() const { Imath::Matrix44 identity; identity.makeIdentity(); return identity; } //----------------------------------------------------------------------------// template <> inline Imath::Matrix44 Curve >::defaultReturnValue() const { Imath::Matrix44 identity; identity.makeIdentity(); return identity; } //----------------------------------------------------------------------------// FIELD3D_NAMESPACE_HEADER_CLOSE //----------------------------------------------------------------------------// #endif // Include guard Field3D-1.7.3/export/DenseField.h000066400000000000000000000515041363220467400164440ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks Inc * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// /*! \file DenseField.h \brief Contains the DenseField class. */ //----------------------------------------------------------------------------// #ifndef _INCLUDED_Field3D_DenseField_H_ #define _INCLUDED_Field3D_DenseField_H_ #include #include #include "Field.h" //----------------------------------------------------------------------------// #include "ns.h" FIELD3D_NAMESPACE_OPEN //----------------------------------------------------------------------------// // Forward declarations //----------------------------------------------------------------------------// template class LinearGenericFieldInterp; template class CubicGenericFieldInterp; //----------------------------------------------------------------------------// // DenseField //----------------------------------------------------------------------------// /*! \class DenseField \ingroup field \brief This subclass of Field stores data in a contiguous std::vector. Regarding threading granularity - DenseField considers each scanline (i.e. continuous X coords) to be one grain. Thus, numGrains is res.y * res.z. Refer to \ref using_fields for examples of how to use this in your code. */ //----------------------------------------------------------------------------// template class DenseField : public ResizableField { public: // Typedefs ------------------------------------------------------------------ typedef boost::intrusive_ptr Ptr; typedef std::vector Vec; typedef LinearGenericFieldInterp > LinearInterp; typedef CubicGenericFieldInterp > CubicInterp; typedef ResizableField base; // Constructors -------------------------------------------------------------- //! \name Constructors & destructor //! \{ //! Constructs an empty buffer DenseField(); // \} // Main methods -------------------------------------------------------------- //! Clears all the voxels in the storage virtual void clear(const Data_T &value); // Threading-related --------------------------------------------------------- //! Number of 'grains' to use with threaded access size_t numGrains() const; //! Bounding box of the given 'grain' bool getGrainBounds(const size_t idx, Box3i &vsBounds) const; // From Field base class ----------------------------------------------------- //! \name From Field //! \{ virtual Data_T value(int i, int j, int k) const; virtual long long int memSize() const; //! \} // RTTI replacement ---------------------------------------------------------- typedef DenseField class_type; DEFINE_FIELD_RTTI_CONCRETE_CLASS static const char *staticClassName() { return "DenseField"; } static const char *staticClassType() { return DenseField::ms_classType.name(); } // From WritableField base class --------------------------------------------- //! \name From WritableField //! \{ virtual Data_T& lvalue(int i, int j, int k); //! \} // Concrete voxel access ----------------------------------------------------- //! Read access to voxel. Notice that this is non-virtual. const Data_T& fastValue(int i, int j, int k) const; //! Write access to voxel. Notice that this is non-virtual. Data_T& fastLValue(int i, int j, int k); // Iterators ----------------------------------------------------------------- //! \name Iterators //! \{ //! Const iterator for traversing the values in a Field object. class const_iterator; //! Non-const iterator for traversing the values in a Field object. class iterator; //! Const iterator to first element. "cbegin" matches the tr1 c++ standard. const_iterator cbegin() const; //! Const iterator to first element of specific subset const_iterator cbegin(const Box3i &subset) const; //! Const iterator pointing one element past the last valid one. const_iterator cend() const; //! Const iterator pointing one element past the last valid one (for a //! subset) const_iterator cend(const Box3i &subset) const; //! Iterator to first element. iterator begin(); //! Iterator to first element of specific subset iterator begin(const Box3i &subset); //! Iterator pointing one element past the last valid one. iterator end(); //! Iterator pointing one element past the last valid one (for a //! subset) iterator end(const Box3i &subset); //! \} // Utility methods ----------------------------------------------------------- //! Returns the internal memory size in each dimension. This is used for //! example in LinearInterpolator, where it optimizes random access to //! voxels. const FIELD3D_VEC3_T &internalMemSize() const { return m_memSize; } // From FieldBase ------------------------------------------------------------ //! \name From FieldBase //! \{ FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION; virtual FieldBase::Ptr clone() const { return Ptr(new DenseField(*this)); } //! \} protected: // From ResizableField class ------------------------------------------------- virtual void sizeChanged(); // Data members -------------------------------------------------------------- //! Memory allocation size in each dimension FIELD3D_VEC3_T m_memSize; //! X scanline * Y scanline size size_t m_memSizeXY; //! Field storage std::vector m_data; private: // Static data members ------------------------------------------------------- static TemplatedFieldType > ms_classType; // Direct access to memory for iterators ------------------------------------- //! Returns a pointer to a given element. Used by the iterators mainly. inline Data_T* ptr(int i, int j, int k); //! Returns a pointer to a given element. Used by the iterators mainly. inline const Data_T* ptr(int i, int j, int k) const; }; //----------------------------------------------------------------------------// // Typedefs //----------------------------------------------------------------------------// typedef DenseField DenseFieldh; typedef DenseField DenseFieldf; typedef DenseField DenseFieldd; typedef DenseField DenseField3h; typedef DenseField DenseField3f; typedef DenseField DenseField3d; //----------------------------------------------------------------------------// // DenseField::const_iterator //----------------------------------------------------------------------------// template class DenseField::const_iterator { public: #if defined(WIN32) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 typedef std::forward_iterator_tag iterator_category; typedef Data_T value_type; typedef ptrdiff_t difference_type; typedef ptrdiff_t distance_type; typedef const Data_T *pointer; typedef const Data_T& reference; #endif // Typedefs ------------------------------------------------------------------ typedef DenseField class_type; // Constructors -------------------------------------------------------------- const_iterator(const class_type &field, const Box3i &window, const V3i ¤tPos) : x(currentPos.x), y(currentPos.y), z(currentPos.z), m_window(window), m_field(field) { if (window.intersects(currentPos)) m_p = m_field.ptr(x, y, z); else m_p = 0; } // Operators ----------------------------------------------------------------- const const_iterator& operator ++ () { if (x == m_window.max.x) { if (y == m_window.max.y) { if (z == m_window.max.z) { m_p = 0; } else { m_p = m_field.ptr(x = m_window.min.x, y = m_window.min.y, ++z); } } else { m_p = m_field.ptr(x = m_window.min.x, ++y, z); } } else { ++x; ++m_p; } return *this; } template inline bool operator == (const Iter_T &rhs) const { return m_p == &(*rhs); } template inline bool operator != (const Iter_T &rhs) const { return m_p != &(*rhs); } inline const Data_T& operator * () const { return *m_p; } inline const Data_T* operator -> () const { return m_p; } // Public data members ------------------------------------------------------- //! Current position int x, y, z; private: // Private data members ------------------------------------------------------ //! Pointer to current element const Data_T *m_p; //! Window to traverse Box3i m_window; //! Reference to field being iterated over const class_type &m_field; }; //----------------------------------------------------------------------------// // DenseField::iterator //----------------------------------------------------------------------------// template class DenseField::iterator { public: #if defined(WIN32) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 typedef std::forward_iterator_tag iterator_category; typedef Data_T value_type; typedef ptrdiff_t difference_type; typedef ptrdiff_t distance_type; typedef Data_T *pointer; typedef Data_T& reference; #endif // Typedefs ------------------------------------------------------------------ typedef DenseField class_type; // Constructors -------------------------------------------------------------- iterator(class_type &field, const Box3i &window, const V3i ¤tPos) : x(currentPos.x), y(currentPos.y), z(currentPos.z), m_window(window), m_field(field) { if (window.intersects(currentPos)) m_p = m_field.ptr(x, y, z); else m_p = 0; } // Operators ----------------------------------------------------------------- const iterator& operator ++ () { if (x == m_window.max.x) { if (y == m_window.max.y) { if (z == m_window.max.z) { m_p = 0; } else { m_p = m_field.ptr(x = m_window.min.x, y = m_window.min.y, ++z); } } else { m_p = m_field.ptr(x = m_window.min.x, ++y, z); } } else { ++x; ++m_p; } return *this; } template inline bool operator == (const Iter_T &rhs) const { return m_p == &(*rhs); } template inline bool operator != (const Iter_T &rhs) const { return m_p != &(*rhs); } inline Data_T& operator * () const { return *m_p; } inline Data_T* operator -> () const { return m_p; } // Public data members ------------------------------------------------------- //! Current position int x, y, z; private: // Private data members ------------------------------------------------------ //! Pointer to current element Data_T *m_p; //! Window to traverse Box3i m_window; //! Reference to field being iterated over class_type &m_field; }; //----------------------------------------------------------------------------// // DenseField implementations //----------------------------------------------------------------------------// template DenseField::DenseField() : base(), m_memSize(0), m_memSizeXY(0) { // Empty } //----------------------------------------------------------------------------// template void DenseField::clear(const Data_T &value) { std::fill(m_data.begin(), m_data.end(), value); } //----------------------------------------------------------------------------// template size_t DenseField::numGrains() const { // Grain resolution const V3i res = base::m_dataWindow.size() + V3i(1); // Num grains is Y * Z return res.y * res.z; } //----------------------------------------------------------------------------// template bool DenseField::getGrainBounds(const size_t idx, Box3i &bounds) const { // Grain resolution const V3i res = base::m_dataWindow.size() + V3i(1); // Compute coordinate const int y = idx % res.y; const int z = idx / res.y; // Build bbox const V3i start = base::m_dataWindow.min + V3i(0, y, z); const V3i end = base::m_dataWindow.min + V3i(res.x, y, z); bounds = Field3D::clipBounds(Box3i(start, end), base::m_dataWindow); // Done return true; } //----------------------------------------------------------------------------// template Data_T DenseField::value(int i, int j, int k) const { return fastValue(i, j, k); } //----------------------------------------------------------------------------// template long long int DenseField::memSize() const { long long int superClassMemSize = base::memSize(); long long int vectorMemSize = m_data.capacity() * sizeof(Data_T); return sizeof(*this) + vectorMemSize + superClassMemSize; } //----------------------------------------------------------------------------// template Data_T& DenseField::lvalue(int i, int j, int k) { return fastLValue(i, j, k); } //----------------------------------------------------------------------------// template const Data_T& DenseField::fastValue(int i, int j, int k) const { assert (i >= base::m_dataWindow.min.x); assert (i <= base::m_dataWindow.max.x); assert (j >= base::m_dataWindow.min.y); assert (j <= base::m_dataWindow.max.y); assert (k >= base::m_dataWindow.min.z); assert (k <= base::m_dataWindow.max.z); // Add crop window offset i -= base::m_dataWindow.min.x; j -= base::m_dataWindow.min.y; k -= base::m_dataWindow.min.z; // Access data return m_data[i + j * m_memSize.x + k * m_memSizeXY]; } //----------------------------------------------------------------------------// template Data_T& DenseField::fastLValue(int i, int j, int k) { assert (i >= base::m_dataWindow.min.x); assert (i <= base::m_dataWindow.max.x); assert (j >= base::m_dataWindow.min.y); assert (j <= base::m_dataWindow.max.y); assert (k >= base::m_dataWindow.min.z); assert (k <= base::m_dataWindow.max.z); // Add crop window offset i -= base::m_dataWindow.min.x; j -= base::m_dataWindow.min.y; k -= base::m_dataWindow.min.z; // Access data return m_data[i + j * m_memSize.x + k * m_memSizeXY]; } //----------------------------------------------------------------------------// template typename DenseField::const_iterator DenseField::cbegin() const { if (FieldRes::dataResolution() == V3i(0)) return cend(); return const_iterator(*this, base::m_dataWindow, base::m_dataWindow.min); } //----------------------------------------------------------------------------// template typename DenseField::const_iterator DenseField::cbegin(const Box3i &subset) const { if (subset.isEmpty()) return cend(subset); return const_iterator(*this, subset, subset.min); } //----------------------------------------------------------------------------// template typename DenseField::const_iterator DenseField::cend() const { return const_iterator(*this, base::m_dataWindow, V3i(base::m_dataWindow.min.x, base::m_dataWindow.min.y, base::m_dataWindow.max.z + 1)); } //----------------------------------------------------------------------------// template typename DenseField::const_iterator DenseField::cend(const Box3i &subset) const { return const_iterator(*this, subset, V3i(subset.min.x, subset.min.y, subset.max.z + 1)); } //----------------------------------------------------------------------------// template typename DenseField::iterator DenseField::begin() { if (FieldRes::dataResolution() == V3i(0)) return end(); return iterator(*this, base::m_dataWindow, base::m_dataWindow.min); } //----------------------------------------------------------------------------// template typename DenseField::iterator DenseField::begin(const Box3i &subset) { if (subset.isEmpty()) return end(subset); return iterator(*this, subset, subset.min); } //----------------------------------------------------------------------------// template typename DenseField::iterator DenseField::end() { return iterator(*this, base::m_dataWindow, V3i(base::m_dataWindow.min.x, base::m_dataWindow.min.y, base::m_dataWindow.max.z + 1)); } //----------------------------------------------------------------------------// template typename DenseField::iterator DenseField::end(const Box3i &subset) { return iterator(*this, subset, V3i(subset.min.x, subset.min.y, subset.max.z + 1)); } //----------------------------------------------------------------------------// template void DenseField::sizeChanged() { // Call base class base::sizeChanged(); // Calculate offsets m_memSize = base::m_dataWindow.max - base::m_dataWindow.min + V3i(1); m_memSizeXY = m_memSize.x * m_memSize.y; // Check that mem size is >= 0 in all dimensions if (base::m_dataWindow.max.x < base::m_dataWindow.min.x || base::m_dataWindow.max.y < base::m_dataWindow.min.y || base::m_dataWindow.max.z < base::m_dataWindow.min.z) throw Exc::ResizeException("Attempt to resize ResizableField object " "using negative size. Data window was: " + boost::lexical_cast( base::m_dataWindow.min) + " - " + boost::lexical_cast( base::m_dataWindow.max)); // Allocate memory try { std::vector().swap(m_data); m_data.resize(m_memSize.x * m_memSize.y * m_memSize.z); } catch (std::bad_alloc &) { throw Exc::MemoryException("Couldn't allocate DenseField of size " + boost::lexical_cast(m_memSize)); } } //----------------------------------------------------------------------------// template inline Data_T* DenseField::ptr(int i, int j, int k) { // Add crop window offset i -= base::m_dataWindow.min.x; j -= base::m_dataWindow.min.y; k -= base::m_dataWindow.min.z; // Access data return &m_data[i + j * m_memSize.x + k * m_memSizeXY]; } //----------------------------------------------------------------------------// template inline const Data_T* DenseField::ptr(int i, int j, int k) const { // Add crop window offset i -= base::m_dataWindow.min.x; j -= base::m_dataWindow.min.y; k -= base::m_dataWindow.min.z; // Access data return &m_data[i + j * m_memSize.x + k * m_memSizeXY]; } //----------------------------------------------------------------------------// // Static data member instantiation //----------------------------------------------------------------------------// FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION(DenseField); //----------------------------------------------------------------------------// FIELD3D_NAMESPACE_HEADER_CLOSE //----------------------------------------------------------------------------// #endif // Include guard Field3D-1.7.3/export/Documentation.h000066400000000000000000000064521363220467400172550ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks Inc * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// /*! \file Documentation.h \brief Only contains doxygen documentation. */ //----------------------------------------------------------------------------// // Modules //----------------------------------------------------------------------------// /*! \defgroup field Fields \brief These are the main parts of the library that a user would deal with. */ /*! \defgroup file File I/O \brief These are the main parts of the library that a user would deal with. */ /*! \defgroup internal Classes and functions used to implement this library \brief These classes are used to implement the library and are of interest to anyone maintaining or changing the library. */ /*! \defgroup exc Exceptions used in the library \ingroup internal */ /*! \defgroup hdf5 Hdf5 Utility Classes and Functions \ingroup internal */ /*! \defgroup file_int Field IO classes under-the-hood \ingroup internal */ /*! \defgroup field_int Field classes under-the-hood \ingroup internal */ /*! \defgroup template_util Templated utility classes \ingroup internal */ //----------------------------------------------------------------------------// // Main Documentation page //----------------------------------------------------------------------------// /*! \mainpage Field3D Field3D is an open source library for storing voxel data. It provides C++ classes that handle in-memory storage and a file format based on HDF5 that allows the C++ objects to be written to and read from disk. \n The majority of the documentation is available in the project Wiki at https://sites.google.com/site/field3d/ */ // \mainpage Field3D-1.7.3/export/EmptyField.h000066400000000000000000000172541363220467400165100ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks Inc * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// /*! \file EmptyField.h \brief Contains the EmptyField class */ //----------------------------------------------------------------------------// #ifndef _INCLUDED_Field3D_EmptyField_H_ #define _INCLUDED_Field3D_EmptyField_H_ #include #include #include "Field.h" //----------------------------------------------------------------------------// #include "ns.h" FIELD3D_NAMESPACE_OPEN //----------------------------------------------------------------------------// // gets rid of warnings (N.B. not on clang, where self-assignment is warned!) #ifdef __clang__ # define UNUSED(p) #else # define UNUSED(p) ((p)=(p)) #endif //----------------------------------------------------------------------------// /*! \class EmptyField \ingroup field \brief This subclass of Field does not store any data. Its primary purpose is to be used as a proxy field. It can carry the same resolution, metadata and mapping as a regular field. Usage is similar to a DenseField, except that it does not contain any data. It stores a default value that may be set and queried, so it can be treated as a constant field. */ //----------------------------------------------------------------------------// template class EmptyField : public ResizableField { public: // Typedefs ------------------------------------------------------------------ typedef boost::intrusive_ptr Ptr; typedef std::vector Vec; // Constructors -------------------------------------------------------------- //! \name Constructors & destructor //! \{ //! Constructs an empty buffer EmptyField(); // \} // Main methods -------------------------------------------------------------- //! Clears all the voxels in the storage virtual void clear(const Data_T &value); //! Returns the constant value const Data_T& constantvalue() const; //! Sets the constant value void setConstantvalue(const Data_T &val); // From Field base class ------------------------------------------------- //! \name From Field //! \{ virtual Data_T value(int i, int j, int k) const; virtual long long int memSize() const; //! \} // RTTI replacement ---------------------------------------------------------- typedef EmptyField class_type; DEFINE_FIELD_RTTI_CONCRETE_CLASS static const char *staticClassName() { return staticClassType(); } static const char *staticClassType() { return "EmptyField"; } // From WritableField base class ----------------------------------------- //! \name From WritableField //! \{ virtual Data_T& lvalue(int i, int j, int k); //! \} // From FieldBase ------------------------------------------------------------ //! \name From FieldBase //! \{ FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION virtual FieldBase::Ptr clone() const { return Ptr(new EmptyField(*this)); } //! \} protected: // Data members -------------------------------------------------------------- //! Field default value Data_T m_default; //! Dummy variable for assignment Data_T m_ignoredData; //! Field constant value Data_T m_constantData; private: // Typedefs ------------------------------------------------------------------ typedef ResizableField base; }; //----------------------------------------------------------------------------// // EmptyField implementations //----------------------------------------------------------------------------// template EmptyField::EmptyField() : base() { // Empty } //----------------------------------------------------------------------------// template void EmptyField::clear(const Data_T &value) { m_constantData = m_default = value; } //----------------------------------------------------------------------------// template Data_T EmptyField::value(int i, int j, int k) const { assert (i >= base::m_dataWindow.min.x); assert (i <= base::m_dataWindow.max.x); assert (j >= base::m_dataWindow.min.y); assert (j <= base::m_dataWindow.max.y); assert (k >= base::m_dataWindow.min.z); assert (k <= base::m_dataWindow.max.z); UNUSED(i); UNUSED(j); UNUSED(k); // Access data return m_default; } //----------------------------------------------------------------------------// template long long int EmptyField::memSize() const { long long int superClassMemSize = base::memSize(); return sizeof(*this) + superClassMemSize; } //----------------------------------------------------------------------------// template Data_T& EmptyField::lvalue(int i, int j, int k) { assert (i >= base::m_dataWindow.min.x); assert (i <= base::m_dataWindow.max.x); assert (j >= base::m_dataWindow.min.y); assert (j <= base::m_dataWindow.max.y); assert (k >= base::m_dataWindow.min.z); assert (k <= base::m_dataWindow.max.z); UNUSED(i); UNUSED(j); UNUSED(k); // Access data return m_ignoredData; } //----------------------------------------------------------------------------// template inline void EmptyField::setConstantvalue(const Data_T &val) { m_constantData = val; } //----------------------------------------------------------------------------// template inline const Data_T& EmptyField::constantvalue() const { return m_constantData; } //----------------------------------------------------------------------------// // Typedefs //----------------------------------------------------------------------------// typedef EmptyField Proxy; typedef EmptyField::Ptr ProxyPtr; typedef std::vector Proxies; //----------------------------------------------------------------------------// FIELD3D_NAMESPACE_HEADER_CLOSE //----------------------------------------------------------------------------// #undef UNUSED //----------------------------------------------------------------------------// #endif // Include guard Field3D-1.7.3/export/Exception.h000066400000000000000000000145161363220467400164020ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks Inc * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// /*! \file Exception.h \brief Contains Exception base class. */ //----------------------------------------------------------------------------// #ifndef _INCLUDED_Field3D_Exception_H_ #define _INCLUDED_Field3D_Exception_H_ #include //----------------------------------------------------------------------------// #include "ns.h" FIELD3D_NAMESPACE_OPEN //! Namespace for Exception objects //! \ingroup exc namespace Exc { //----------------------------------------------------------------------------// // Exception //----------------------------------------------------------------------------// /*! \class Exception \ingroup exc Base class for Exceptions. Currently very minimal. Really only makes a convenient class to subclass from. \note This is only intended for use within the SpComp2 - don't ever pass an Exception class across the .so boundary. */ //----------------------------------------------------------------------------// class Exception : public std::exception { public: // Ctor, dtor ---------------------------------------------------------------- //! Construct from string Exception(const std::string &what) throw() : std::exception(), m_what(what) { } //! Destructor. virtual ~Exception() throw() { } // std::exception ------------------------------------------------------------ virtual const char* what() const throw() { return m_what.c_str(); } protected: // Data members -------------------------------------------------------------- //! What string for the expection std::string m_what; }; //----------------------------------------------------------------------------// // Exceptions used in Field3D //----------------------------------------------------------------------------// //! Used to declare a generic but named exception #define DECLARE_FIELD3D_GENERIC_EXCEPTION(name, base_class) \ class name : public base_class \ { \ public: \ explicit name(const std::string &what = "") throw() \ : base_class(what) \ { } \ ~name() throw() \ { } \ }; \ //----------------------------------------------------------------------------// DECLARE_FIELD3D_GENERIC_EXCEPTION(AttrGetNativeTypeException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(AttrGetSpaceException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(AttrGetTypeException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(BadFileHierarchyException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(BadHdf5IdException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(CreateDataSetException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(CreateDataSpaceException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(CreateDataTypeException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(CreateGroupException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(ErrorCreatingFileException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(FileIntegrityException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(GetDataSpaceException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(GetDataTypeException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(Hdf5DataReadException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(MissingAttributeException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(MissingGroupException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(NoSuchFileException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(OpenDataSetException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(ReadHyperSlabException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(ReadMappingException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(UnsupportedVersionException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteAttributeException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteHyperSlabException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteLayerException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteMACFieldDataException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteMappingException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(WriteSimpleDataException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(OgIGroupException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(OgIDatasetException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(OgIAttributeException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(OgOGroupException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(OgODatasetException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(OgOAttributeException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(ReadDataException, Exception) //----------------------------------------------------------------------------// } // namespace Exc FIELD3D_NAMESPACE_HEADER_CLOSE //----------------------------------------------------------------------------// #endif // Include guard Field3D-1.7.3/export/Field.h000066400000000000000000001105431363220467400154640ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks Inc * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// /*! \file Field.h \brief Contains Field, WritableField and ResizableField classes. \ingroup field */ //----------------------------------------------------------------------------// #ifndef _INCLUDED_Field3D_Field_H_ #define _INCLUDED_Field3D_Field_H_ #include #include #include #include #include #include "Traits.h" #include "Exception.h" #include "FieldMapping.h" #include "FieldMetadata.h" #include "Log.h" #include "RefCount.h" #include "Types.h" //----------------------------------------------------------------------------// #include "ns.h" FIELD3D_NAMESPACE_OPEN //----------------------------------------------------------------------------// // Exceptions //----------------------------------------------------------------------------// namespace Exc { DECLARE_FIELD3D_GENERIC_EXCEPTION(MemoryException, Exception) DECLARE_FIELD3D_GENERIC_EXCEPTION(ResizeException, Exception) } // namespace Exc //----------------------------------------------------------------------------// // FieldBase //----------------------------------------------------------------------------// /*! \class FieldBase \ingroup field This class provides a common base for all Field objects. It serves the purpose of providing the className() virtual function and as a container for the metadata map */ class FIELD3D_API FieldBase : public RefBase, public MetadataCallback { public: // Typedefs ------------------------------------------------------------------ typedef boost::intrusive_ptr Ptr; typedef FieldBase class_type; // Constructors -------------------------------------------------------------- //! \name Constructors, destructors, copying //! \{ //! Constructor FieldBase(); //! Copy Constructor FieldBase(const FieldBase &); //! Destructor virtual ~FieldBase(); //! \} // RTTI replacement ---------------------------------------------------------- static const char *staticClassName() { return "FieldBase"; } static const char* staticClassType() { return staticClassName(); } // To be implemented by subclasses ------------------------------------------- //! \name To be implemented by subclasses //! \{ //! Returns the class name of the object. Used by the class pool and when //! writing the data to disk. //! \note This is different from classType for any templated class, //! as staticClassType() will include the template parameter(s) but className //! remains just the name of the template itself. virtual std::string className() const = 0; //! Returns the full class type string. virtual std::string classType() const = 0; //! Returns a pointer to a copy of the field, pure virtual so ensure //! derived classes properly implement it virtual Ptr clone() const = 0; //! \} // Access to metadata -------------------------------------------------------- //! \name Metadata //! \{ //! accessor to the m_metadata class FieldMetadata& metadata() { return m_metadata; } //! Read only access to the m_metadata class const FieldMetadata& metadata() const { return m_metadata; } //! Copies the metadata from a second field void copyMetadata(const FieldBase &field) { m_metadata = field.metadata(); } //! \} // Public data members ------------------------------------------------------- //! Optional name of the field std::string name; //! Optional name of the attribute the field represents std::string attribute; private: // Private data members ------------------------------------------------------ //! metadata FieldMetadata m_metadata; }; //----------------------------------------------------------------------------// // FieldRes //----------------------------------------------------------------------------// /*! \class FieldRes \ingroup field This class serves to isolate the extents and data window from its templated subclasses. Thus, anything that needs to access the extents or data window don't need to know about what data type the subclass is templated on. It also owns the field's mapping. Why do we have both an extent and a data window? The extents are used to define which range of voxels define the [0..1] local coordinate system. The data window in turn defines the voxels that are legal to read/write from. Thus, for optimization we may have a large extents but a small data window, or a small extents and a larger data window which would let us apply large-kernel filters without having to deal with boundary conditions. */ //----------------------------------------------------------------------------// class FieldRes : public FieldBase { public: // Typedefs ------------------------------------------------------------------ typedef boost::intrusive_ptr Ptr; typedef std::vector Vec; // RTTI replacement ---------------------------------------------------------- typedef FieldRes class_type; DEFINE_FIELD_RTTI_ABSTRACT_CLASS; virtual std::string dataTypeString() const { return std::string("FieldRes"); } static const char *staticClassName() { return "FieldRes"; } static const char *staticClassType() { return staticClassName(); } // Ctor, dtor ---------------------------------------------------------------- //! This constructor ensures that we have a valid mapping at all times FieldRes(); //! Base class copy constructor //! \todo OSS Go over the copy constructing - is it implemented right? 8hr FieldRes(const FieldRes &src); // Main methods -------------------------------------------------------------- //! Returns the extents of the data. This signifies the relevant area that //! the data exists over. However, the data window (below) may be smaller //! than the extents, in which case it is only safe to call value() for //! those coordinate inside the data window. inline const Box3i& extents() const { return m_extents; } //! Returns the data window. Any coordinate inside this window is safe to //! pass to value() in the Field subclass. inline const Box3i& dataWindow() const { return m_dataWindow; } inline V3i const dataResolution() const { return m_dataWindow.max - m_dataWindow.min + V3i(1); } //! Sets the field's mapping void setMapping(FieldMapping::Ptr mapping); //! Returns a pointer to the mapping FieldMapping::Ptr mapping() { return m_mapping; } //! Returns a pointer to the mapping const FieldMapping::Ptr mapping() const { return m_mapping; } //! Returns true is the indicies are in bounds of the data window bool isInBounds(int i, int j, int k) const; // To be implemented by subclasses ------------------------------------------- //! Returns the memory usage (in bytes) //! \note This needs to be re-implemented for any subclass that adds data //! members. Those classes should also call their superclass and add the //! combined memory use. virtual long long int memSize() const { return sizeof(*this); } //! Tells the subclass that the mapping changed virtual void mappingChanged() { /* Empty */ } //! Counts the number of voxels. For most fields, this is just the volume //! of the data window, but sparse data structures can override this to //! return a better value virtual size_t voxelCount() const { V3i res = m_dataWindow.size() + V3i(1); return res.x * res.y * res.z; } protected: // Typedefs ------------------------------------------------------------------ typedef MatrixFieldMapping default_mapping; // Data members -------------------------------------------------------------- //! Defines the extents of the the storage. This may be larger or smaller //! than the data window, and in the case where it is larger, care must be //! taken not to access voxels outside the data window. This should be treated //! as a closed (i.e. inclusive) interval. Box3i m_extents; //! Defines the area where data is allocated. This should be treated as a //! closed (i.e. inclusive) interval. Box3i m_dataWindow; //! Pointer to the field's mapping FieldMapping::Ptr m_mapping; private: // Typedefs ------------------------------------------------------------------ //! Convenience typedef for referring to base class typedef FieldBase base; }; //----------------------------------------------------------------------------// inline FieldRes::FieldRes() : m_mapping(new default_mapping) { m_extents = Box3i(V3i(0), V3i(-1)); m_dataWindow = m_extents; m_mapping->setExtents(m_extents); } //----------------------------------------------------------------------------// inline FieldRes::FieldRes(const FieldRes &src) : FieldBase(src) { // Call base class first // FieldBase(src); // Copy self *this = src; m_mapping = src.mapping()->clone(); } //----------------------------------------------------------------------------// inline void FieldRes::setMapping(FieldMapping::Ptr mapping) { if (mapping) { m_mapping = mapping->clone(); m_mapping->setExtents(m_extents); } else { Msg::print(Msg::SevWarning, "Tried to call FieldRes::setMapping with null pointer"); } // Tell subclasses about the mapping change mappingChanged(); } //----------------------------------------------------------------------------// inline bool FieldRes::isInBounds(int i, int j, int k) const { // Check bounds if (i < m_dataWindow.min.x || i > m_dataWindow.max.x || j < m_dataWindow.min.y || j > m_dataWindow.max.y || k < m_dataWindow.min.z || k > m_dataWindow.max.z) { return false; } return true; } //----------------------------------------------------------------------------// // Field //----------------------------------------------------------------------------// /*! \class Field \ingroup field This class provides read-only access to voxels. A read-only buffer can not be resized. Resizing is added by ResizableField. The object still has a size of course, but it can only be set by subclass-specific methods. \note Regarding the template type Data_T. This does not necessarily have to be the internal data storage format, it only defines the -return type- that the particular Field instance provides. */ template class Field : public FieldRes { public: // Typedefs ------------------------------------------------------------------ typedef boost::intrusive_ptr Ptr; //! Allows us to reference the template class typedef Data_T value_type; //! This is a convenience typedef for the list that //! Field3DInputFile::readScalarLayers() and //! Field3DInputFile::readVectorLayers() will return its data in typedef std::vector Vec; // RTTI replacement ---------------------------------------------------------- typedef Field class_type; DEFINE_FIELD_RTTI_ABSTRACT_CLASS; static const char *staticClassName() { return "Field"; } static const char* staticClassType() { return Field::ms_classType.name(); } // Constructors -------------------------------------------------------------- //! Dtor virtual ~Field() { /* Empty */ } // Iterators ----------------------------------------------------------------- //! Const iterator for traversing the values in a Field object. //! \ingroup field class const_iterator; //! Const iterator to first element. "cbegin" matches the tr1 c++ standard. const_iterator cbegin() const; //! Const iterator to first element of specific subset const_iterator cbegin(const Box3i &subset) const; //! Const iterator pointing one element past the last valid one. const_iterator cend() const; //! Const iterator pointing one element past the last valid one (for a //! subset) const_iterator cend(const Box3i &subset) const; // To be implemented by subclasses ------------------------------------------- //! Read access to a voxel. The coordinates are in integer voxel space . //! \note Before the internal storage is accessed, the subclass must compute //! the data window coordinates by looking at Field::m_dataWindow. //! \note Virtual functions are known not to play nice with threading. //! Therefor, concrete classes can implement (by convention) fastValue() //! as a non-virtual function. virtual Data_T value(int i, int j, int k) const = 0; // Other member functions ---------------------------------------------------- virtual std::string dataTypeString() const { return DataTypeTraits::name(); } private: // Static data members ------------------------------------------------------- static TemplatedFieldType > ms_classType; // Typedefs ------------------------------------------------------------------ //! Convenience typedef for referring to base class typedef FieldRes base; }; //----------------------------------------------------------------------------// #define FIELD3D_CLASSNAME_CLASSTYPE_IMPLEMENTATION \ virtual std::string className() const \ { return staticClassName(); } \ virtual std::string classType() const \ { return staticClassType(); } \ #define FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION(field) \ template \ TemplatedFieldType > field::ms_classType = \ TemplatedFieldType >(); \ FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION(Field); //----------------------------------------------------------------------------// // Field::const_iterator //----------------------------------------------------------------------------// template class Field::const_iterator { public: #if defined(WIN32) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 typedef std::forward_iterator_tag iterator_category; typedef Data_T value_type; typedef ptrdiff_t difference_type; typedef ptrdiff_t distance_type; typedef Data_T *pointer; typedef Data_T& reference; #endif // Constructors -------------------------------------------------------------- const_iterator(const const_iterator &i) : x(i.x), y(i.y), z(i.z), m_window(i.m_window), m_field(i.m_field) { } const_iterator(const Field &field, const Box3i &window, const V3i ¤tPos) : x(currentPos.x), y(currentPos.y), z(currentPos.z), m_window(window), m_field(field) { } // Operators ----------------------------------------------------------------- inline const const_iterator& operator ++ () { if (x == m_window.max.x) { if (y == m_window.max.y) { x = m_window.min.x; y = m_window.min.y; ++z; } else { x = m_window.min.x; ++y; } } else { ++x; } return *this; } template bool operator == (const Iter_T &rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z; } template bool operator != (const Iter_T &rhs) const { return x != rhs.x || y != rhs.y || z != rhs.z; } inline Data_T operator * () const { return m_field.value(x, y, z); } // Public data members ------------------------------------------------------- //! Current position int x, y, z; private: // Private data members ------------------------------------------------------ //! Window to traverse Box3i m_window; //! Reference to field being iterated over const Field &m_field; }; //----------------------------------------------------------------------------// template typename Field::const_iterator Field::cbegin() const { if (FieldRes::dataResolution() == V3i(0)) return cend(); return const_iterator(*this, m_dataWindow, m_dataWindow.min); } //----------------------------------------------------------------------------// template typename Field::const_iterator Field::cbegin(const Box3i &subset) const { if (subset.isEmpty()) return cend(subset); return const_iterator(*this, subset, subset.min); } //----------------------------------------------------------------------------// template typename Field::const_iterator Field::cend() const { return const_iterator(*this, m_dataWindow, V3i(m_dataWindow.min.x, m_dataWindow.min.y, m_dataWindow.max.z + 1)); } //----------------------------------------------------------------------------// template typename Field::const_iterator Field::cend(const Box3i &subset) const { return const_iterator(*this, subset, V3i(subset.min.x, subset.min.y, subset.max.z + 1)); } //----------------------------------------------------------------------------// // WritableField //----------------------------------------------------------------------------// /*! \class WritableField \ingroup field This class brings together both read- and write-access to voxels. The buffer can not be resized. Resizing is added by ResizableField. */ //----------------------------------------------------------------------------// template class WritableField : public Field { public: // Typedefs ------------------------------------------------------------------ typedef boost::intrusive_ptr Ptr; // RTTI replacement ---------------------------------------------------------- typedef WritableField class_type; DEFINE_FIELD_RTTI_ABSTRACT_CLASS; static const char *staticClassName() { return "WritableField"; } static const char* staticClassType() { return WritableField::ms_classType.name(); } // Iterators ----------------------------------------------------------------- //! Non-const iterator for traversing the values in a Field object. //! \ingroup field class iterator; //! Iterator to first element. inline iterator begin(); //! Iterator to first element of specific subset inline iterator begin(const Box3i &subset); //! Iterator pointing one element past the last valid one. inline iterator end(); //! Iterator pointing one element past the last valid one (for a //! subset) inline iterator end(const Box3i &subset); // To be implemented by subclasses ------------------------------------------- //! Write access to a voxel. The coordinates are global coordinates. //! \note Before the internal storage is accessed, the subclass must compute //! the crop window coordinates by looking at Field::m_dataWindow. //! \note This is named differently from the const value so that non-const //! objects still have a clear way of accessing data in a const way. //! \note Virtual functions are known not to play nice with threading. //! Therefor, concrete classes can implement (by convention) fastLValue() //! as a non-virtual function. virtual Data_T& lvalue(int i, int j, int k) = 0; // Main methods -------------------------------------------------------------- //! Clears all the voxels in the storage. Should be re-implemented by //! subclasses that can provide a more efficient version. virtual void clear(const Data_T &value) { std::fill(begin(), end(), value); } private: // Static data members ------------------------------------------------------- static TemplatedFieldType > ms_classType; // Typedefs ------------------------------------------------------------------ typedef Field base; }; //----------------------------------------------------------------------------// FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION(WritableField); //----------------------------------------------------------------------------// // WritableField::iterator //----------------------------------------------------------------------------// template class WritableField::iterator { public: #if defined(WIN32) || __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090 typedef std::forward_iterator_tag iterator_category; typedef Data_T value_type; typedef ptrdiff_t difference_type; typedef ptrdiff_t distance_type; typedef Data_T *pointer; typedef Data_T& reference; #endif // Constructors -------------------------------------------------------------- iterator(WritableField &field, const Box3i &window, const V3i ¤tPos) : x(currentPos.x), y(currentPos.y), z(currentPos.z), m_window(window), m_field(field) { } // Operators ----------------------------------------------------------------- inline const iterator& operator ++ () { if (x == m_window.max.x) { if (y == m_window.max.y) { x = m_window.min.x; y = m_window.min.y; ++z; } else { x = m_window.min.x; ++y; } } else { ++x; } return *this; } template bool operator == (const Iter_T &rhs) const { return x == rhs.x && y == rhs.y && z == rhs.z; } template bool operator != (const Iter_T &rhs) const { return x != rhs.x || y != rhs.y || z != rhs.z; } inline Data_T& operator * () const { return m_field.lvalue(x, y, z); } // Public data members ------------------------------------------------------- //! Current position int x, y, z; private: // Private data members ------------------------------------------------------ //! Window to traverse Box3i m_window; //! Reference to field being iterated over WritableField &m_field; }; //----------------------------------------------------------------------------// template inline typename WritableField::iterator WritableField::begin() { if (FieldRes::dataResolution() == V3i(0)) return end(); return iterator(*this, Field::m_dataWindow, Field::m_dataWindow.min); } //----------------------------------------------------------------------------// template inline typename WritableField::iterator WritableField::begin(const Box3i &subset) { if (subset.isEmpty()) return end(subset); return iterator(*this, subset, subset.min); } //----------------------------------------------------------------------------// template inline typename WritableField::iterator WritableField::end() { return iterator(*this, Field::m_dataWindow, V3i(Field::m_dataWindow.min.x, Field::m_dataWindow.min.y, Field::m_dataWindow.max.z + 1)); } //----------------------------------------------------------------------------// template inline typename WritableField::iterator WritableField::end(const Box3i &subset) { return iterator(*this, subset, V3i(subset.min.x, subset.min.y, subset.max.z + 1)); } //----------------------------------------------------------------------------// // ResizableField //----------------------------------------------------------------------------// /*! \class ResizableField \ingroup field This class adds the ability to resize the data storage object. Most Field subclasses will derive from this class. Only classes that cannot implement sizeChanged() in a reasonable manner should derive from Field or WritableField. */ //----------------------------------------------------------------------------// template class ResizableField : public WritableField { public: // Typedefs ------------------------------------------------------------------ typedef boost::intrusive_ptr Ptr; // RTTI replacement ---------------------------------------------------------- typedef ResizableField class_type; DEFINE_FIELD_RTTI_ABSTRACT_CLASS; static const char *staticClassName() { return "ResizableField"; } static const char* staticClassType() { return ResizableField::ms_classType.name(); } // Main methods -------------------------------------------------------------- //! Resizes the object //! \warning Never call this from a constructor. It calls the virtual //! function sizeChanged(). void setSize(const V3i &size); //! Resizes the object //! \warning Never call this from a constructor. It calls the virtual //! function sizeChanged(). void setSize(const Box3i &extents); //! Resizes the object //! \warning Never call this from a constructor. It calls the virtual //! function sizeChanged(). void setSize(const Box3i &extents, const Box3i &dataWindow); //! Resizes the object with padding //! \warning Never call this from a constructor. It calls the virtual //! function sizeChanged(). void setSize(const V3i &size, int padding); //! Copies the data from another Field, also resizes void copyFrom(typename Field::Ptr other); //! Copies the data from another Field of another template class, //! also resizes template void copyFrom(typename Field::Ptr other); //! Sets up this field so that resolution and mapping matches the other void matchDefinition(FieldRes::Ptr fieldToMatch); protected: // Static data members ------------------------------------------------------- static TemplatedFieldType > ms_classType; // Typedefs ------------------------------------------------------------------ typedef WritableField base; // To be implemented by subclasses ------------------------------------------- //! Subclasses should re-implement this if they need to perform memory //! allocations, etc. every time the size of the storage changes. //! \note Make sure to call the base class version in subclasses! virtual void sizeChanged() { base::m_mapping->setExtents(base::m_extents); } }; //----------------------------------------------------------------------------// FIELD3D_CLASSTYPE_TEMPL_INSTANTIATION(ResizableField); //----------------------------------------------------------------------------// template void ResizableField::setSize(const V3i &size) { assert(size.x >= 0); assert(size.y >= 0); assert(size.z >= 0); Field::m_extents.min = V3i(0); Field::m_extents.max = size - V3i(1); Field::m_dataWindow = Field::m_extents; // Tell subclasses that the size changed so they can update themselves. sizeChanged(); } //----------------------------------------------------------------------------// template void ResizableField::setSize(const Box3i &extents) { Field::m_extents = extents; Field::m_dataWindow = extents; // Tell subclasses that the size changed so they can update themselves. sizeChanged(); } //----------------------------------------------------------------------------// template void ResizableField::setSize(const Box3i &extents, const Box3i &dataWindow) { Field::m_extents = extents; Field::m_dataWindow = dataWindow; // Tell subclasses that the size changed so they can update themselves. sizeChanged(); } //----------------------------------------------------------------------------// template void ResizableField::setSize(const V3i &size, int padding) { assert(size.x >= 0); assert(size.y >= 0); assert(size.z >= 0); assert(padding >= 0); setSize(Box3i(V3i(0), size - V3i(1)), Box3i(V3i(-padding), size + V3i(padding - 1))); } //----------------------------------------------------------------------------// template void ResizableField::copyFrom(typename Field::Ptr other) { // Set mapping FieldRes::setMapping(other->mapping()); // Set size to match setSize(other->extents(), other->dataWindow()); // Copy over the data typename base::iterator i = base::begin(); typename base::iterator end = base::end(); typename Field::const_iterator c = other->cbegin(); for (; i != end; ++i, ++c) *i = *c; } //----------------------------------------------------------------------------// template template void ResizableField::copyFrom(typename Field::Ptr other) { // Set mapping FieldRes::setMapping(other->mapping()); // Set size to match setSize(other->extents(), other->dataWindow()); // Copy over the data typename base::iterator i = base::begin(); typename base::iterator end = base::end(); typename Field::const_iterator c = other->cbegin(); for (; i != end; ++i, ++c) *i = *c; } //----------------------------------------------------------------------------// template void ResizableField::matchDefinition(FieldRes::Ptr fieldToMatch) { setSize(fieldToMatch->extents(), fieldToMatch->dataWindow()); FieldRes::setMapping(fieldToMatch->mapping()); } //----------------------------------------------------------------------------// // Field-related utility functions //----------------------------------------------------------------------------// //! Checks whether the mapping and resolution in two different fields are //! identical template bool sameDefinition(typename Field::Ptr a, typename Field::Ptr b, double tolerance = 0.0) { if (a->extents() != b->extents()) { return false; } if (a->dataWindow() != b->dataWindow()) { return false; } if (!a->mapping()->isIdentical(b->mapping(), tolerance)) { return false; } return true; } //----------------------------------------------------------------------------// //! Checks whether the span and data in two different fields are identical //! \todo This should also check the mapping template bool isIdentical(typename Field::Ptr a, typename Field::Ptr b) { if (!sameDefinition(a, b)) { return false; } // If data window is the same, we can safely assume that the range of // both fields' iterators are the same. typename Field::const_iterator is1 = a->cbegin(); typename Field::const_iterator is2 = b->cbegin(); typename Field::const_iterator ie1 = a->cend(); bool same = true; for (; is1 != ie1; ++is1, ++is2) { if (*is1 != *is2) { same = false; break; } } return same; } //----------------------------------------------------------------------------// //! Goes from continuous coordinates to discrete coordinates //! See Graphics Gems - What is a pixel inline int contToDisc(double contCoord) { return static_cast(std::floor(contCoord)); } //----------------------------------------------------------------------------// //! Goes from discrete coordinates to continuous coordinates //! See Graphics Gems - What is a pixel inline double discToCont(int discCoord) { return static_cast(discCoord) + 0.5; } //----------------------------------------------------------------------------// //! Goes from continuous coords to discrete for a 2-vector inline V2i contToDisc(const V2d &contCoord) { return V2i(contToDisc(contCoord.x), contToDisc(contCoord.y)); } //----------------------------------------------------------------------------// //! Goes from discrete coords to continuous for a 2-vector inline V2d discToCont(const V2i &discCoord) { return V2d(discToCont(discCoord.x), discToCont(discCoord.y)); } //----------------------------------------------------------------------------// //! Goes from continuous coords to discrete for a 3-vector inline V3i contToDisc(const V3d &contCoord) { return V3i(contToDisc(contCoord.x), contToDisc(contCoord.y), contToDisc(contCoord.z)); } //----------------------------------------------------------------------------// //! Goes from discrete coords to continuous for a 3-vector inline V3d discToCont(const V3i &discCoord) { return V3d(discToCont(discCoord.x), discToCont(discCoord.y), discToCont(discCoord.z)); } //----------------------------------------------------------------------------// inline Box3d continuousBounds(const Box3i &bbox) { Box3d result; result.min.x = static_cast(bbox.min.x); result.min.y = static_cast(bbox.min.y); result.min.z = static_cast(bbox.min.z); result.max.x = static_cast(bbox.max.x + 1); result.max.y = static_cast(bbox.max.y + 1); result.max.z = static_cast(bbox.max.z + 1); return result; } //----------------------------------------------------------------------------// //! Converts a floating point bounding box to an integer bounding box. //! \note If the float-to-int conversion overflows, the result is //! set to be std::numeric_limits::max() inline Box3i discreteBounds(const Box3d &bbox) { using std::floor; using std::ceil; Box3i result; result.min.x = static_cast(floor(clampForType(bbox.min.x))); result.min.y = static_cast(floor(clampForType(bbox.min.y))); result.min.z = static_cast(floor(clampForType(bbox.min.z))); result.max.x = static_cast(ceil(clampForType(bbox.max.x))); result.max.y = static_cast(ceil(clampForType(bbox.max.y))); result.max.z = static_cast(ceil(clampForType(bbox.max.z))); return result; } //----------------------------------------------------------------------------// inline Box3i clipBounds(const Box3i &bbox, const Box3i &bounds) { Box3i result; result.min.x = std::max(bbox.min.x, bounds.min.x); result.min.y = std::max(bbox.min.y, bounds.min.y); result.min.z = std::max(bbox.min.z, bounds.min.z); result.max.x = std::min(bbox.max.x, bounds.max.x); result.max.y = std::min(bbox.max.y, bounds.max.y); result.max.z = std::min(bbox.max.z, bounds.max.z); return result; } //----------------------------------------------------------------------------// //! \ingroup template_util template void advance(Iter_T &iter, int num) { if (num <= 0) { return; } for (int i=0; i void advance(Iter_T &iter, int num, const Iter_T &end) { if (num <= 0) { return; } for (int i=0; i #include #include #include #include "EmptyField.h" #include "Field.h" #include "Field3DFileHDF5.h" #include "FieldMetadata.h" #include "ClassFactory.h" #include "OgawaFwd.h" //----------------------------------------------------------------------------// #include "ns.h" //----------------------------------------------------------------------------// FIELD3D_NAMESPACE_OPEN //----------------------------------------------------------------------------// // Forward declarations //----------------------------------------------------------------------------// class Field3DInputFileHDF5; class Field3DOutputFileHDF5; //----------------------------------------------------------------------------// // Layer //----------------------------------------------------------------------------// //! Namespace for file I/O specifics //! \ingroup file_int namespace File { /*! \class Layer \ingroup file_int This class wraps up information about a single "Layer" in a .f3d file. A layer is a "Field" with a name. The mapping lives on the Partition object, so the layer only knows about the location of the field in the file. */ class Layer { public: //! The name of the layer (always available) std::string name; //! The name of the parent partition. We need this in order to open //! its group. std::string parent; }; } // namespace File //----------------------------------------------------------------------------// // Partition //----------------------------------------------------------------------------// namespace File { /*! \class Partition \ingroup file_int This class represents the partition-level node in a f3D file. The partition contains one "Mapping" and N "Fields" that all share that mapping. */ class FIELD3D_API Partition : public RefBase { public: typedef std::vector LayerList; typedef boost::intrusive_ptr Ptr; typedef boost::intrusive_ptr CPtr; // RTTI replacement ---------------------------------------------------------- typedef Partition class_type; DEFINE_FIELD_RTTI_CONCRETE_CLASS; static const char *staticClassType() { return "Partition"; } // Ctors, dtor --------------------------------------------------------------- //! Ctor Partition() : RefBase() { } // From RefBase -------------------------------------------------------------- //! \name From RefBase //! \{ virtual std::string className() const; //! \} // Main methods -------------------------------------------------------------- //! Adds a layer void addLayer(const File::Layer &layer); //! Finds a layer const File::Layer* layer(const std::string &name) const; //! Gets all the layer names. void getLayerNames(std::vector &names) const; //! Returns a reference to the OgOGroup OgOGroup& group() const; //! Sets the group pointer void setGroup(boost::shared_ptr ptr); // Public data members ------------------------------------------------------- //! Name of the partition std::string name; //! Pointer to the mapping object. FieldMapping::Ptr mapping; private: // Private data members ------------------------------------------------------ //! The layers belonging to this partition LayerList m_layers; //! Group representing the partition boost::shared_ptr m_group; // Typedefs ------------------------------------------------------------------ //! Convenience typedef for referring to base class typedef RefBase base; }; } // namespace File //----------------------------------------------------------------------------// // Field3DFileBase //----------------------------------------------------------------------------// /*! \class Field3DFileBase \ingroup file Provides some common functionality for Field3DInputFile and Field3DOutputFile. It hold the partition->layer data structures, but knows nothing about how to actually get them to/from disk. */ //----------------------------------------------------------------------------// class FIELD3D_API Field3DFileBase : public MetadataCallback { public: // Structs ------------------------------------------------------------------- struct LayerInfo { std::string name; std::string parentName; int components; LayerInfo(std::string par, std::string nm, int cpt) : name(nm), parentName(par), components(cpt) { /* Empty */ } }; // Typedefs ------------------------------------------------------------------ typedef std::map GroupMembershipMap; // Ctor, dtor ---------------------------------------------------------------- //! \name Constructors & destructor //! \{ Field3DFileBase(); //! Pure virtual destructor to ensure we never instantiate this class virtual ~Field3DFileBase() = 0; //! \} // Main methods -------------------------------------------------------------- //! Clear the data structures and close the file. void clear(); //! Closes the file. No need to call this unless you specifically want to //! close the file early. It will close once the File object goes out of //! scope. bool close(); //! \name Retreiving partition and layer names //! \{ //! Gets the names of all the partitions in the file void getPartitionNames(std::vector &names) const; //! Gets the names of all the scalar layers in a given partition void getScalarLayerNames(std::vector &names, const std::string &partitionName) const; //! Gets the names of all the vector layers in a given partition void getVectorLayerNames(std::vector &names, const std::string &partitionName) const; //! \} //! \name Convenience methods for partitionName //! \{ //! Add to the group membership void addGroupMembership(const GroupMembershipMap &groupMembers); //! \} // Access to metadata -------------------------------------------------------- //! accessor to the m_metadata class FieldMetadata& metadata() { if (m_hdf5Base) { return m_hdf5Base->metadata(); } return m_metadata; } //! Read only access to the m_metadata class const FieldMetadata& metadata() const { if (m_hdf5Base) { return m_hdf5Base->metadata(); } return m_metadata; } //! This function should implemented by concrete classes to //! get the callback when metadata changes virtual void metadataHasChanged(const std::string &/* name */) { /* Empty */ } // Debug --------------------------------------------------------------------- //! \name Debug //! \{ void printHierarchy() const; //! \} protected: // Internal typedefs --------------------------------------------------------- typedef std::vector PartitionList; typedef std::map PartitionCountMap; // Convenience methods ------------------------------------------------------- //! \name Convenience methods //! \{ //! Returns a pointer to the given partition //! \returns NULL if no partition was found of that name File::Partition::Ptr getPartition(const std::string &partitionName) const { return partition(partitionName); } //! Closes the file if open. virtual void closeInternal() = 0; //! Returns a pointer to the given partition //! \returns NULL if no partition was found of that name File::Partition::Ptr partition(const std::string &partitionName); //! Returns a pointer to the given partition //! \returns NULL if no partition was found of that name File::Partition::Ptr partition(const std::string &partitionName) const; //! Gets the names of all the -internal- partitions in the file void getIntPartitionNames(std::vector &names) const; //! Gets the names of all the scalar layers in a given partition, but //! assumes that partition name is the -internal- partition name void getIntScalarLayerNames(std::vector &names, const std::string &intPartitionName) const; //! Gets the names of all the vector layers in a given partition, but //! assumes that partition name is the -internal- partition name void getIntVectorLayerNames(std::vector &names, const std::string &intPartitionName) const; //! Returns the number of internal partitions for a given partition name int numIntPartitions(const std::string &partitionName) const; //! Makes an internal partition name given the external partition name. //! Effectively just tacks on .X to the name, where X is the number std::string makeIntPartitionName(const std::string &partitionsName, int i) const; //! Returns a unique partition name given the requested name. This ensures //! that partitions with matching mappings get the same name but each //! subsequent differing mapping gets a new, separate name std::string intPartitionName(const std::string &partitionName, const std::string &layerName, FieldRes::Ptr field); //! Strips any unique identifiers from the partition name and returns //! the original name std::string removeUniqueId(const std::string &partitionName) const; //! \} // Data members -------------------------------------------------------------- //! This stores layer info std::vector m_layerInfo; //! Vector of partitions. PartitionList m_partitions; //! This stores partition names std::vector m_partitionNames; //! Contains a counter for each partition name. This is used to keep multiple //! fields with the same name unique in the file PartitionCountMap m_partitionCount; //! Keeps track of group membership for each layer of partition name. //! The key is the "group" and the value is a space separated list of //! "partitionName.0:Layer1 partitionName.1:Layer0 ..." GroupMembershipMap m_groupMembership; //! metadata FieldMetadata m_metadata; //! HDF5 fallback boost::shared_ptr m_hdf5Base; private: // Private member functions -------------------------------------------------- Field3DFileBase(const Field3DFileBase&); void operator =(const Field3DFileBase&); }; //----------------------------------------------------------------------------// // Field3DInputFile //----------------------------------------------------------------------------// /*! \class Field3DInputFile \brief Provides reading of .f3d (internally, hdf5 or Ogawa) files. \ingroup file Refer to \ref using_files for examples of how to use this in your code. */ //----------------------------------------------------------------------------// class FIELD3D_API Field3DInputFile : public Field3DFileBase { public: // Ctors, dtor --------------------------------------------------------------- //! \name Constructors & destructor //! \{ Field3DInputFile(); virtual ~Field3DInputFile(); //! \} // Main interface ------------------------------------------------------------ //! Opens the given file //! \returns Whether successful bool open(const std::string &filename); //! Returns an encoding descriptor of the given file const std::string &encoding() const { const static std::string encodings[2] = { "Ogawa", "HDF5" }; return encodings[m_hdf5 ? 1 : 0]; } //! \name Reading layers from disk //! \{ template typename Field::Vec readLayers(const std::string &layerName = std::string("")) const; template typename Field::Vec readLayers(const std::string &partitionName, const std::string &layerName) const; //! \name Backward compatibility //! \{ //! Retrieves all the layers of scalar type and maintains their on-disk //! data types //! \param layerName If a string is passed in, only layers of that name will //! be read from disk. template typename Field::Vec readScalarLayers(const std::string &layerName = std::string("")) const { if (m_hdf5) { return m_hdf5->readScalarLayers(layerName); } return readLayers(layerName); } //! This one allows the allows the partitionName to be passed in template typename Field::Vec readScalarLayers(const std::string &partitionName, const std::string &layerName) const { if (m_hdf5) { return m_hdf5->readScalarLayers(partitionName, layerName); } return readLayers(partitionName, layerName); } //! Retrieves all the layers of vector type and maintains their on-disk //! data types //! \param layerName If a string is passed in, only layers of that name will //! be read from disk. template typename Field >::Vec readVectorLayers(const std::string &layerName = std::string("")) const { if (m_hdf5) { return m_hdf5->readVectorLayers(layerName); } return readLayers >(layerName); } //! This version allows you to pass in the partition name template typename Field >::Vec readVectorLayers(const std::string &partitionName, const std::string &layerName) const { if (m_hdf5) { return m_hdf5->readVectorLayers(partitionName, layerName); } return readLayers >(partitionName, layerName); } //! \} //! \name Reading proxy data from disk //! \{ //! Retrieves a proxy version (EmptyField) of each layer . //! \note Although the call is templated, all fields are read, regardless //! of bit depth. //! \param name If a string is passed in, only layers of that name will //! be read from disk. template typename EmptyField::Vec readProxyLayer(const std::string &partitionName, const std::string &layerName, bool isVectorLayer) const; //! Retrieves a proxy version (EmptyField) of each scalar layer //! \note Although the call is templated, all fields are read, regardless //! of bit depth. //! \param name If a string is passed in, only layers of that name will //! be read from disk. template typename EmptyField::Vec readProxyScalarLayers(const std::string &name = std::string("")) const; //! Retrieves a proxy version (EmptyField) of each vector layer //! \note Although the call is templated, all fields are read, regardless //! of bit depth. //! \param name If a string is passed in, only layers of that name will //! be read from disk. template typename EmptyField::Vec readProxyVectorLayers(const std::string &name = std::string("")) const; //! \} private: // From Field3DFileBase ------------------------------------------------------ virtual void closeInternal() { if (m_hdf5) { m_hdf5->closeInternal(); return; } cleanup(); } void cleanup() { // The destruction of the various Ogawa components must happen in the // right order // First, the partition groups m_partitions.clear(); // Then the root group m_root.reset(); // Finally, the archive m_archive.reset(); } // Convenience methods ------------------------------------------------------- //! This call does the actual reading of a layer. Notice that it expects //! a unique -internal- partition name. template typename Field::Ptr readLayer(const std::string &intPartitionName, const std::string &layerName) const; //! Retrieves a proxy version (EmptyField) from a given Ogawa location //! \note Although the call is templated, all fields are read, regardless //! of bit depth. template typename EmptyField::Ptr readProxyLayer(OgIGroup &location, const std::string &name, const std::string &attribute, FieldMapping::Ptr mapping) const; //! Sets up all the partitions and layers, but does not load any data bool readPartitionAndLayerInfo(); //! Read metadata for this layer bool readMetadata(const OgIGroup &metadataGroup, FieldBase::Ptr field) const; //! Read global metadata for this file bool readMetadata(const OgIGroup &metadataGroup); // Data members -------------------------------------------------------------- //! Filename, only to be set by open(). std::string m_filename; //! Pointer to the Ogawa archive boost::shared_ptr m_archive; //! Pointer to root group boost::shared_ptr m_root; //! HDF5 fallback boost::shared_ptr m_hdf5; }; //----------------------------------------------------------------------------// // Utility functions //----------------------------------------------------------------------------// /*! \brief checks to see if a file/directory exists or not \param[in] filename the file/directory to check \retval true if it exists \retval false if it does not exist */ bool fileExists(const std::string &filename); //----------------------------------------------------------------------------// // Field3DOutputFile //----------------------------------------------------------------------------// /*! \class Field3DOutputFile \ingroup file \brief Provides writing of .f3d (internally, hdf5 or Ogawa) files. Refer to \ref using_files for examples of how to use this in your code. */ //----------------------------------------------------------------------------// class FIELD3D_API Field3DOutputFile : public Field3DFileBase { public: // Enums --------------------------------------------------------------------- enum CreateMode { OverwriteMode, FailOnExisting }; // Ctors, dtor --------------------------------------------------------------- //! \name Constructors & destructor //! \{ Field3DOutputFile(); virtual ~Field3DOutputFile(); //! \} // Main interface ------------------------------------------------------------ //! Creates a .f3d file on disk bool create(const std::string &filename, CreateMode cm = OverwriteMode); //! Whether to output ogawa files static void useOgawa(const bool enabled) { // simple temporary endian check union { uint32_t l; char c[4]; } u; u.l = 0x01234567; if (u.c[0] == 0x67) { ms_doOgawa = enabled; } else { std::cerr << "WARNING: Field3D only supports Ogawa-backed files " << "on little-endian systems." << std::endl; ms_doOgawa = false; } } //! \name Writing layer to disk //! \{ //! Writes a scalar layer to the "Default" partition. template bool writeLayer(const std::string &layerName, typename Field::Ptr layer) { return writeLayer(std::string("default"), layerName, layer); } //! Writes a layer to a specific partition. The partition will be created if //! not specified. template bool writeLayer(const std::string &partitionName, const std::string &layerName, typename Field::Ptr layer); //! Writes a layer to a specific partition. The field name and attribute //! name are used for partition and layer, respectively template bool writeLayer(typename Field::Ptr layer) { return writeLayer(layer->name, layer->attribute, layer); } //! \} //! \name Backward compatibility //! \{ //! Writes a scalar layer to the "Default" partition. template bool writeScalarLayer(const std::string &layerName, typename Field::Ptr layer) { if (m_hdf5) { return m_hdf5->writeScalarLayer(layerName, layer); } return writeScalarLayer(std::string("default"), layerName, layer); } //! Writes a layer to a specific partition. The partition will be created if //! not specified. template bool writeScalarLayer(const std::string &partitionName, const std::string &layerName, typename Field::Ptr layer) { if (m_hdf5) { return m_hdf5->writeScalarLayer(partitionName, layerName, layer); } return writeLayer(partitionName, layerName, layer); } //! Writes a layer to a specific partition. The field name and attribute //! name are used for partition and layer, respectively template bool writeScalarLayer(typename Field::Ptr layer) { if (m_hdf5) { return m_hdf5->writeScalarLayer(layer); } return writeLayer(layer); } //! Writes a scalar layer to the "Default" partition. template bool writeVectorLayer(const std::string &layerName, typename Field >::Ptr layer) { if (m_hdf5) { return m_hdf5->writeVectorLayer(layerName, layer); } return writeVectorLayer(std::string("default"), layerName, layer); } //! Writes a layer to a specific partition. The partition will be created if //! not specified. template bool writeVectorLayer(const std::string &partitionName, const std::string &layerName, typename Field >::Ptr layer) { if (m_hdf5) { return m_hdf5->writeVectorLayer(partitionName, layerName, layer); } return writeLayer >(partitionName, layerName, layer); } //! Writes a layer to a specific partition. The field name and attribute //! name are used for partition and layer, respectively template bool writeVectorLayer(typename Field >::Ptr layer) { if (m_hdf5) { return m_hdf5->writeVectorLayer(layer); } return writeLayer >(layer); } //! This routine is call if you want to write out global metadata to disk bool writeGlobalMetadata(); //! This routine is called just before closing to write out any group //! membership to disk. bool writeGroupMembership(); //! \} private: // From Field3DFileBase ------------------------------------------------------ virtual void closeInternal() { if (m_hdf5) { m_hdf5->closeInternal(); return; } cleanup(); } void cleanup() { // The destruction of the various Ogawa components must happen in the // right order // First, the partition groups m_partitions.clear(); // Then the root group m_root.reset(); // Finally, the archive m_archive.reset(); } // Convenience methods ------------------------------------------------------- //! Increment the partition or make it zero if there's not an integer suffix std::string incrementPartitionName(std::string &pname); //! Create newPartition given the input config File::Partition::Ptr createNewPartition(const std::string &partitionName, const std::string &layerName, FieldRes::Ptr field); //! Writes the mapping to the given Og node. //! Mappings are assumed to be light-weight enough to be stored as //! plain attributes under a group. bool writeMapping(OgOGroup &partitionGroup, FieldMapping::Ptr mapping); //! Writes metadata for this layer bool writeMetadata(OgOGroup &metadataGroup, FieldBase::Ptr layer); //! Writes metadata for this file bool writeMetadata(OgOGroup &metadataGroup); // Data members -------------------------------------------------------------- //! Whether to output ogawa files static bool ms_doOgawa; //! Pointer to the Ogawa archive boost::shared_ptr m_archive; //! Pointer to root group boost::shared_ptr m_root; //! HDF5 fallback boost::shared_ptr m_hdf5; }; //----------------------------------------------------------------------------// FIELD3D_NAMESPACE_HEADER_CLOSE //----------------------------------------------------------------------------// #endif Field3D-1.7.3/export/Field3DFileHDF5.h000066400000000000000000001527511363220467400170710ustar00rootroot00000000000000//----------------------------------------------------------------------------// /* * Copyright (c) 2009 Sony Pictures Imageworks Inc * * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the * distribution. Neither the name of Sony Pictures Imageworks nor the * names of its contributors may be used to endorse or promote * products derived from this software without specific prior written * permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED * OF THE POSSIBILITY OF SUCH DAMAGE. */ //----------------------------------------------------------------------------// /*! \file Field3DFileHDF5.h \brief Contains the Field3DFileHDF5 classes \ingroup field OSS sanitized */ //----------------------------------------------------------------------------// #ifndef _INCLUDED_Field3D_Field3DFileHDF5_H_ #define _INCLUDED_Field3D_Field3DFileHDF5_H_ //----------------------------------------------------------------------------// #include #include #include #include #include #include "EmptyField.h" #include "Field.h" #include "FieldCache.h" #include "FieldMetadata.h" #include "ClassFactory.h" #include "Hdf5Util.h" //----------------------------------------------------------------------------// #include "ns.h" FIELD3D_NAMESPACE_OPEN //----------------------------------------------------------------------------// // Function Declarations //----------------------------------------------------------------------------// //! \name classFactory IO functions // \{ //! This function creates a FieldIO instance based on className //! which then reads the field data from layerGroup location template typename Field::Ptr readField(const std::string &className, hid_t layerGroup, const std::string &filename, const std::string &layerPath); //! This function creates a FieldIO instance based on field->className() //! which then writes the field data in layerGroup location FIELD3D_API bool writeField(hid_t layerGroup, FieldBase::Ptr field); //! This function creates a FieldMappingIO instance based on className //! read from mappingGroup location which then reads FieldMapping data FIELD3D_API FieldMapping::Ptr readFieldMapping(hid_t mappingGroup); //! This function creates a FieldMappingIO instance based on //! mapping->className() which then writes FieldMapping //! data to mappingGroup location FIELD3D_API bool writeFieldMapping(hid_t mappingGroup, FieldMapping::Ptr mapping); //! \} //----------------------------------------------------------------------------// // Layer //----------------------------------------------------------------------------// //! Namespace for file I/O specifics //! \ingroup file_int namespace FileHDF5 { /*! \class Layer \ingroup file_int This class wraps up information about a single "Layer" in a .f3d file. A layer is a "Field" with a name. The mapping lives on the Partition object, so the layer only knows about the location of the field in the file. */ class Layer { public: //! The name of the layer (always available) std::string name; //! The name of the parent partition. We need this in order to open //! its group. std::string parent; }; } // namespace FileHDF5 //----------------------------------------------------------------------------// // Partition //----------------------------------------------------------------------------// namespace FileHDF5 { /*! \class Partition \ingroup file_int This class represents the partition-level node in a f3D file. The partition contains one "Mapping" and N "Fields" that all share that mapping. */ class FIELD3D_API Partition : public RefBase { public: typedef std::vector ScalarLayerList; typedef std::vector VectorLayerList; typedef boost::intrusive_ptr Ptr; typedef boost::intrusive_ptr CPtr; // RTTI replacement ---------------------------------------------------------- typedef Partition class_type; DEFINE_FIELD_RTTI_CONCRETE_CLASS; static const char *staticClassType() { return "Partition"; } // Ctors, dtor --------------------------------------------------------------- //! Ctor Partition() : RefBase() { } // From RefBase -------------------------------------------------------------- //! \name From RefBase //! \{ virtual std::string className() const; //! \} // Main methods -------------------------------------------------------------- //! Adds a scalar layer void addScalarLayer(const FileHDF5::Layer &layer); //! Adds a vector layer void addVectorLayer(const FileHDF5::Layer &layer); //! Finds a scalar layer const FileHDF5::Layer* scalarLayer(const std::string &name) const; //! Finds a vector layer const FileHDF5::Layer* vectorLayer(const std::string &name) const; //! Gets all the scalar layer names. void getScalarLayerNames(std::vector &names) const; //! Gets all the vector layer names void getVectorLayerNames(std::vector &names) const; // Public data members ------------------------------------------------------- //! Name of the partition std::string name; //! Pointer to the mapping object. FieldMapping::Ptr mapping; private: // Private data members ------------------------------------------------------ //! The scalar-valued layers belonging to this partition ScalarLayerList m_scalarLayers; //! The vector-valued layers belonging to this partition VectorLayerList m_vectorLayers; // Typedefs ------------------------------------------------------------------ //! Convenience typedef for referring to base class typedef RefBase base; }; } // namespace FileHDF5 //----------------------------------------------------------------------------// // Field3DFileHDF5Base //----------------------------------------------------------------------------// /*! \class Field3DFileHDF5Base \ingroup file Provides some common functionality for Field3DInputFileHDF5 and Field3DOutputFileHDF5. It hold the partition->layer data structures, but knows nothing about how to actually get them to/from disk. */ //----------------------------------------------------------------------------// class FIELD3D_API Field3DFileHDF5Base : public MetadataCallback { public: friend class Field3DInputFile; friend class Field3DOutputFile; // Structs ------------------------------------------------------------------- struct LayerInfo { std::string name; std::string parentName; int components; LayerInfo(std::string par, std::string nm, int cpt) : name(nm), parentName(par), components(cpt) { /* Empty */ } }; // Typedefs ------------------------------------------------------------------ typedef std::map GroupMembershipMap; // Ctor, dtor ---------------------------------------------------------------- //! \name Constructors & destructor //! \{ Field3DFileHDF5Base(); //! Pure virtual destructor to ensure we never instantiate this class virtual ~Field3DFileHDF5Base() = 0; //! \} // Main methods -------------------------------------------------------------- //! Clear the data structures and close the file. void clear(); //! Closes the file. No need to call this unless you specifically want to //! close the file early. It will close once the FileHDF5 object goes out of //! scope. bool close(); //! \name Retreiving partition and layer names //! \{ //! Gets the names of all the partitions in the file void getPartitionNames(std::vector &names) const; //! Gets the names of all the scalar layers in a given partition void getScalarLayerNames(std::vector &names, const std::string &partitionName) const; //! Gets the names of all the vector layers in a given partition void getVectorLayerNames(std::vector &names, const std::string &partitionName) const; //! Returns a pointer to the given partition //! \returns NULL if no partition was found of that name FileHDF5::Partition::Ptr getPartition(const std::string &partitionName) const { return partition(partitionName); } //! \} //! \name Convenience methods for partitionName //! \{ //! Returns a unique partition name given the requested name. This ensures //! that partitions with matching mappings get the same name but each //! subsequent differing mapping gets a new, separate name std::string intPartitionName(const std::string &partitionName, const std::string &layerName, FieldRes::Ptr field); //! Strips any unique identifiers from the partition name and returns //! the original name std::string removeUniqueId(const std::string &partitionName) const; //! Add to the group membership void addGroupMembership(const GroupMembershipMap &groupMembers); //! \} // Access to metadata -------------------------------------------------------- //! accessor to the m_metadata class FieldMetadata& metadata() { return m_metadata; } //! Read only access to the m_metadata class const FieldMetadata& metadata() const { return m_metadata; } //! This function should implemented by concrete classes to //! get the callback when metadata changes virtual void metadataHasChanged(const std::string &/* name */) { /* Empty */ } // Debug --------------------------------------------------------------------- //! \name Debug //! \{ void printHierarchy() const; //! \} protected: // Internal typedefs --------------------------------------------------------- typedef std::vector PartitionList; typedef std::map PartitionCountMap; // Convenience methods ------------------------------------------------------- //! \name Convenience methods //! \{ //! Closes the file if open. void closeInternal(); //! Returns a pointer to the given partition //! \returns NULL if no partition was found of that name FileHDF5::Partition::Ptr partition(const std::string &partitionName); //! Returns a pointer to the given partition //! \returns NULL if no partition was found of that name FileHDF5::Partition::Ptr partition(const std::string &partitionName) const; //! Gets the names of all the -internal- partitions in the file void getIntPartitionNames(std::vector &names) const; //! Gets the names of all the scalar layers in a given partition, but //! assumes that partition name is the -internal- partition name void getIntScalarLayerNames(std::vector &names, const std::string &intPartitionName) const; //! Gets the names of all the vector layers in a given partition, but //! assumes that partition name is the -internal- partition name void getIntVectorLayerNames(std::vector &names, const std::string &intPartitionName) const; //! Returns the number of internal partitions for a given partition name int numIntPartitions(const std::string &partitionName) const; //! Makes an internal partition name given the external partition name. //! Effectively just tacks on .X to the name, where X is the number std::string makeIntPartitionName(const std::string &partitionsName, int i) const; //! \} // Data members -------------------------------------------------------------- //! This stores layer info std::vector m_layerInfo; //! The hdf5 id of the current file. Will be -1 if no file is open. hid_t m_file; //! Vector of partitions. PartitionList m_partitions; //! This stores partition names std::vector m_partitionNames; //! Contains a counter for each partition name. This is used to keep multiple //! fields with the same name unique in the file PartitionCountMap m_partitionCount; //! Keeps track of group membership for each layer of partition name. //! The key is the "group" and the value is a space separated list of //! "partitionName.0:Layer1 partitionName.1:Layer0 ..." GroupMembershipMap m_groupMembership; //! metadata FieldMetadata m_metadata; private: // Private member functions -------------------------------------------------- Field3DFileHDF5Base(const Field3DFileHDF5Base&); void operator =(const Field3DFileHDF5Base&); }; //----------------------------------------------------------------------------// // Field3DInputFileHDF5 //----------------------------------------------------------------------------// /*! \class Field3DInputFileHDF5 \brief Provides reading of .f3d (internally, hdf5) files. \ingroup file Refer to \ref using_files for examples of how to use this in your code. \note We distinguish between scalar and vector layers even though both are templated. A scalarField layer is interchangeable with a scalarField (conceptually) but not with a scalar, and thus not with vectorField. */ //----------------------------------------------------------------------------// class FIELD3D_API Field3DInputFileHDF5 : public Field3DFileHDF5Base { public: friend class Field3DInputFile; friend class Field3DOutputFile; // Ctors, dtor --------------------------------------------------------------- //! \name Constructors & destructor //! \{ Field3DInputFileHDF5(); virtual ~Field3DInputFileHDF5(); //! \} // Main interface ------------------------------------------------------------ //! \name Reading layers from disk //! \{ //! Retrieves all the layers of scalar type and maintains their on-disk //! data types //! \param layerName If a string is passed in, only layers of that name will //! be read from disk. template typename Field::Vec readScalarLayers(const std::string &layerName = std::string("")) const; //! This one allows the allows the partitionName to be passed in template typename Field::Vec readScalarLayers(const std::string &partitionName, const std::string &layerName) const; //! Retrieves all the layers of vector type and maintains their on-disk //! data types //! \param layerName If a string is passed in, only layers of that name will //! be read from disk. template typename Field >::Vec readVectorLayers(const std::string &layerName = std::string("")) const; //! This version allows you to pass in the partition name template typename Field >::Vec readVectorLayers(const std::string &partitionName, const std::string &layerName) const; //! Retrieves all layers for all partitions. //! Converts it to the given template type if needed template