├── .gitignore ├── BuildSupport.py ├── CHANGES ├── CMakeLists.txt ├── COPYING ├── ExampleSite.py ├── Field3D.doxyfile ├── README ├── SConscript ├── SConstruct ├── apps ├── f3dinfo │ ├── .gitignore │ ├── SConscript │ ├── SConstruct │ └── main.cpp ├── f3dmakemip │ ├── .gitignore │ ├── SConscript │ ├── SConstruct │ └── main.cpp ├── f3dmerge │ ├── .gitignore │ ├── SConscript │ ├── SConstruct │ └── main.cpp ├── f3dsample │ ├── .gitignore │ ├── SConscript │ ├── SConstruct │ └── main.cpp └── sample_code │ ├── create_and_write │ ├── SConscript │ ├── SConstruct │ └── main.cpp │ ├── mixed_types │ ├── SConscript │ ├── SConstruct │ └── main.cpp │ ├── read │ ├── SConscript │ ├── SConstruct │ └── main.cpp │ └── sparse_field_io │ ├── SConscript │ ├── SConstruct │ └── main.cpp ├── cmake └── FindILMBase.cmake ├── contrib └── maya_plugin │ └── exportF3d │ ├── Makefile.gnu │ └── exportF3d.cpp ├── export ├── ClassFactory.h ├── CoordSys.h ├── Curve.h ├── DenseField.h ├── Documentation.h ├── EmptyField.h ├── Exception.h ├── Field.h ├── Field3DFile.h ├── Field3DFileHDF5.h ├── FieldCache.h ├── FieldGroup.h ├── FieldIO.h ├── FieldInterp.h ├── FieldMapping.h ├── FieldMappingIO.h ├── FieldMetadata.h ├── FieldSampler.h ├── FieldWrapper.h ├── FileSequence.h ├── Hdf5Util.h ├── InitIO.h ├── Log.h ├── MACField.h ├── MACFieldUtil.h ├── MIPBase.h ├── MIPField.h ├── MIPInterp.h ├── MIPUtil.h ├── MinMaxUtil.h ├── OgawaFwd.h ├── PatternMatch.h ├── PluginLoader.h ├── ProceduralField.h ├── RefCount.h ├── Resample.h ├── SparseDataReader.h ├── SparseField.h ├── SparseFile.h ├── SpiMathLib.h ├── StdMathLib.h ├── Traits.h ├── Types.h └── ns.h ├── include ├── All.h ├── DenseFieldIO.h ├── Foundation.h ├── IArchive.h ├── IData.h ├── IGroup.h ├── IStreams.h ├── MACFieldIO.h ├── MIPFieldIO.h ├── OArchive.h ├── OData.h ├── OGroup.h ├── OStream.h ├── OgIAttribute.h ├── OgIDataset.h ├── OgIGroup.h ├── OgIO.h ├── OgOAttribute.h ├── OgODataset.h ├── OgOGroup.h ├── OgSparseDataReader.h ├── OgUtil.h ├── OgawaUtil.h ├── SparseFieldIO.h ├── UtilFoundation.h └── UtilPlainOldDataType.h ├── man └── f3dinfo.1 ├── ogawaToF3D.sh ├── src ├── ClassFactory.cpp ├── DenseFieldIO.cpp ├── Field.cpp ├── Field3DFile.cpp ├── Field3DFile.cpp.bk ├── Field3DFileHDF5.cpp ├── FieldCache.cpp ├── FieldInterp.cpp ├── FieldMapping.cpp ├── FieldMappingIO.cpp ├── FieldMetadata.cpp ├── FileSequence.cpp ├── Hdf5Util.cpp ├── IArchive.cpp ├── IData.cpp ├── IGroup.cpp ├── IStreams.cpp ├── InitIO.cpp ├── Log.cpp ├── MACFieldIO.cpp ├── MIPFieldIO.cpp ├── MIPUtil.cpp ├── MinMaxUtil.cpp ├── OArchive.cpp ├── OData.cpp ├── OGroup.cpp ├── OStream.cpp ├── OgIGroup.cpp ├── OgUtil.cpp ├── PatternMatch.cpp ├── PluginLoader.cpp ├── ProceduralField.cpp ├── Resample.cpp ├── SparseFieldIO.cpp └── SparseFile.cpp └── test ├── misc_tests ├── access_speed │ ├── SConscript │ ├── SConstruct │ └── main.cpp ├── lib_perf_test │ ├── .gitignore │ ├── Field3D_here │ │ └── .gitignore │ ├── INSTRUCTIONS │ ├── OpenVDB_here │ │ └── .gitignore │ ├── SConscript │ ├── SConstruct │ ├── src │ │ └── main.cpp │ └── test_results │ │ ├── graypage_tests.csv │ │ ├── graypage_tests.numbers │ │ ├── graypage_tests.pdf │ │ ├── graypage_tests.txt │ │ └── statstocsv.py └── threading_and_virtual_calls │ ├── SConscript │ ├── SConstruct │ └── main.cpp └── unit_tests ├── .gitignore ├── SConscript ├── SConstruct └── UnitTest.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | build/* 2 | docs/* 3 | Field3D/* 4 | install/* 5 | 6 | *.dblite 7 | *.pyc 8 | -------------------------------------------------------------------------------- /CHANGES: -------------------------------------------------------------------------------- 1 | Apr 21, 2010 2 | * Added CMake build system. (Contributed by Nicholas Yue) 3 | 4 | Nov 3, 2009 5 | * Added dynamic loading of sparse fields. 6 | * Merged all the various class factory into single ClassFactory. 7 | * Created base class for reference counted objects, before each 8 | class implemented the same ref count functions. 9 | * Fixed bug in sparse block iterators 10 | * Main branch is now at version 1.1 11 | 12 | Aug 21 2009 13 | * First "release" into the wild. The official v1.0.0 release branch 14 | will be created once any initial kinks have been worked out. 15 | 16 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | Copyright (c) 2008,2009 Sony Pictures Imageworks Inc 2 | 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the 14 | distribution. Neither the name of Sony Pictures Imageworks nor the 15 | names of its contributors may be used to endorse or promote 16 | products derived from this software without specific prior written 17 | permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | OF THE POSSIBILITY OF SUCH DAMAGE. 31 | -------------------------------------------------------------------------------- /ExampleSite.py: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2009 Sony Pictures Imageworks Inc. 3 | # 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions 8 | # are met: 9 | # 10 | # Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the 15 | # distribution. Neither the name of Sony Pictures Imageworks nor the 16 | # names of its contributors may be used to endorse or promote 17 | # products derived from this software without specific prior written 18 | # permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | # OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | mathInc = "SpiMathLib.h" 34 | mathIncPaths = ["/usr/local64/openexr/1.4.0/include"] 35 | mathLibs = ["Half", "Imath", "Iex"] 36 | mathLibPaths = ["/usr/local64/openexr/1.4.0/lib64"] 37 | 38 | incPaths = [ 39 | "/usr/local64/include/hdf5", 40 | "/usr/local64/include/boost-1_34_1/" 41 | ] 42 | 43 | libPaths = [ 44 | "/usr/local64/lib", 45 | "/usr/local64/lib64", 46 | "/usr/local64/lib/boost-1_34_1" 47 | ] 48 | 49 | boostThreadLib = "boost_thread-gcc34-mt" 50 | 51 | extraNamespace = "SPI" 52 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | ------------------------------------------------------------------------ 2 | ABOUT THE FIELD3D LIBRARY 3 | ------------------------------------------------------------------------ 4 | 5 | Field3D is an open source library for storing voxel data. It provides C++ 6 | classes that handle in-memory storage and a file format based on HDF5 that 7 | allows the C++ objects to be written to and read from disk. 8 | 9 | The majority of the documentation is available in the project Wiki at 10 | https://sites.google.com/site/field3d/ 11 | 12 | *********** NOTE: FIELD3D IS NO LONGER MAINTAINED ********************** 13 | 14 | ------------------------------------------------------------------------ 15 | LICENSE 16 | ------------------------------------------------------------------------ 17 | 18 | The Field3D source code is distributed under the "New BSD" license. 19 | See the file called COPYING for details. 20 | 21 | ------------------------------------------------------------------------ 22 | PACKAGES 23 | ------------------------------------------------------------------------ 24 | 25 | On MacOS X, MacPorts provides a package that downloads, compiles and 26 | installs Field3d into /opt/local (by default). The installation files 27 | for MacPorts can be found at http://www.macports.org/ . 28 | 29 | After installing MacPorts, just type: 30 | 31 | > sudo port install field3d 32 | 33 | ------------------------------------------------------------------------ 34 | FIELD3D DEPENDENCIES 35 | ------------------------------------------------------------------------ 36 | 37 | Field3D was originally developed under CentOS. It has also been tested 38 | under MacOS X Leopard. 39 | 40 | The make system used by Field3D is SCons. You will need to install it 41 | before compiling Field3D if you want to use the supplied setup. 42 | More information about SCons is available at: http://www.scons.org/ 43 | 44 | The libraries required for Field3D are: 45 | 46 | boost (1.34.0) 47 | IlmBase (1.0.1) 48 | HDF5 (1.8.x) 49 | 50 | Boost can be downloaded from 51 | http://www.boost.org/ 52 | 53 | More information about HDF5 can be found at: 54 | http://www.hdfgroup.org/HDF5/ 55 | 56 | Field3D has only been compiled and tested using the IlmBase 1.0.1, 57 | though earlier versions of the combined OpenEXR, which included the 58 | Imath library, may also work. 59 | More information about IlmBase/OpenEXR can be found at: 60 | http://www.openexr.com/ 61 | 62 | To use a math library other than Imath - see the section USING A 63 | CUSTOM MATH LIBRARY below. 64 | 65 | ------------------------------------------------------------------------ 66 | BUILDING FIELD3D 67 | ------------------------------------------------------------------------ 68 | 69 | Field3D was originally developed under CentOS. It has also been tested 70 | under MacOS X Leopard. 71 | 72 | By default, Field3D will look in your platform's standard directories 73 | for include files and libraries. If your libraries reside elsewhere, 74 | refer to the CUSTOMIZING THE BUILD ENVIRONMENT section below. 75 | 76 | If you are compiling on an untested platform, you may need to extend the 77 | "systemIncludePaths" and "systemLibPaths" dictionaries in the file 78 | called BuildSupport.py. 79 | 80 | To build Field3D, go to the root directory and type "scons". This will 81 | build a shared and a static library and place them in the "install" 82 | folder. By default an optimized/release build is created. 83 | 84 | To build a debug version, type "scons debug=1". 85 | 86 | To build a 64-bit version, type "scons do64=1". 87 | 88 | ------------------------------------------------------------------------ 89 | CUSTOMIZING THE BUILD ENVIRONMENT 90 | ------------------------------------------------------------------------ 91 | 92 | Field3D will look in your platform's standard directories for include 93 | files and libraries. If you need to add further library paths, include 94 | paths etc., add a "Site.py" file in the root directory. 95 | 96 | The file ExampleSite.py can be used for reference. 97 | 98 | ------------------------------------------------------------------------ 99 | USING A CUSTOM MATH LIBRARY 100 | ------------------------------------------------------------------------ 101 | 102 | The "Site.py" file can be used to change the math library used by 103 | Field3D. The only current requirement is that the other library is 104 | syntactically equivalent to Imath. At Sony Imageworks, the Imath library 105 | is wrapped in an "SPI" namespace - the ExampleSite.py and SpiMathLib.h 106 | files shows an example of how to configure it. 107 | 108 | ------------------------------------------------------------------------ 109 | AUTHORS 110 | ------------------------------------------------------------------------ 111 | 112 | Original development at Sony Pictures Imageworks: 113 | 114 | Magnus Wrenninge 115 | Chris Allen 116 | Sosh Mirsepassi 117 | Stephen Marshall 118 | Chris Burdorf 119 | Henrik Falt 120 | Scot Shinderman 121 | Doug Bloom 122 | 123 | Contributors: 124 | 125 | Nicholas Yue, Dr. D Studios (CMake setup) 126 | 127 | ------------------------------------------------------------------------ 128 | QUESTIONS AND COMMENTS 129 | ------------------------------------------------------------------------ 130 | 131 | For questions and/or comments, please join the field3d-dev discussion 132 | group at Google Groups. http://groups.google.com/group/field3d-dev 133 | 134 | The project web page URL is: https://sites.google.com/site/field3d/ 135 | 136 | 137 | -------------------------------------------------------------------------------- /SConscript: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2009 Sony Pictures Imageworks Inc. 3 | # 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions 8 | # are met: 9 | # 10 | # Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the 15 | # distribution. Neither the name of Sony Pictures Imageworks nor the 16 | # names of its contributors may be used to endorse or promote 17 | # products derived from this software without specific prior written 18 | # permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | # OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | # ------------------------------------------------------------------------------ 34 | 35 | from BuildSupport import * 36 | 37 | # ------------------------------------------------------------------------------ 38 | 39 | buildPath = buildDir() 40 | installPath = installDir() 41 | sharedLibPath = join(buildPath, field3DName) 42 | 43 | # ------------------------------------------------------------------------------ 44 | 45 | Import("env") 46 | 47 | libEnv = env.Clone() 48 | 49 | setupEnv(libEnv) 50 | setupLibBuildEnv(libEnv) 51 | 52 | libEnv.VariantDir(buildPath, src, duplicate = 0) 53 | files = Glob(join(buildPath, "*.cpp")) 54 | 55 | # Declare library 56 | dyLib = libEnv.SharedLibrary(sharedLibPath, files) 57 | stLib = libEnv.Library(sharedLibPath, files) 58 | 59 | # Set up install area 60 | headerDir = join(installPath, include, field3DName) 61 | headerFiles = Glob(join(export, "*.h")) 62 | headerFiles.remove(File(join(export, typesHeader))) 63 | headerInstall = libEnv.Install(headerDir, headerFiles) 64 | stLibInstall = libEnv.Install(join(installPath, "lib"), [stLib]) 65 | 66 | # Set up the dynamic library properly on OSX 67 | dylibInstall = None 68 | if sys.platform == "darwin": 69 | dylibName = os.path.basename(str(dyLib[0])) 70 | dylibInstallPath = os.path.abspath(join(installPath, "lib", dylibName)) 71 | # Create the builder 72 | dylibEnv = env.Clone() 73 | dylibBuilder = Builder(action = setDylibInternalPath, 74 | suffix = ".dylib", src_suffix = ".dylib") 75 | dylibEnv.Append(BUILDERS = {"SetDylibPath" : dylibBuilder}) 76 | # Call builder 77 | dyLibInstall = dylibEnv.SetDylibPath(dylibInstallPath, dyLib) 78 | else: 79 | dyLibInstall = libEnv.Install(join(installPath, "lib"), [dyLib]) 80 | 81 | 82 | # Bake in math library in Types.h 83 | bakeEnv = env.Clone() 84 | bakeBuilder = Builder(action = bakeMathLibHeader, 85 | suffix = ".h", src_suffix = ".h") 86 | bakeEnv.Append(BUILDERS = {"BakeMathLibHeader" : bakeBuilder}) 87 | bakeTarget = bakeEnv.BakeMathLibHeader(join(headerDir, typesHeader), 88 | join(export, typesHeader)) 89 | 90 | # Default targets --- 91 | 92 | libEnv.Default(dyLib) 93 | libEnv.Default(stLib) 94 | libEnv.Default(headerInstall) 95 | libEnv.Default(stLibInstall) 96 | libEnv.Default(dyLibInstall) 97 | bakeEnv.Default(bakeTarget) 98 | 99 | # ------------------------------------------------------------------------------ 100 | 101 | -------------------------------------------------------------------------------- /SConstruct: -------------------------------------------------------------------------------- 1 | # 2 | # Copyright (c) 2009 Sony Pictures Imageworks Inc. 3 | # 4 | # All rights reserved. 5 | # 6 | # Redistribution and use in source and binary forms, with or without 7 | # modification, are permitted provided that the following conditions 8 | # are met: 9 | # 10 | # Redistributions of source code must retain the above copyright 11 | # notice, this list of conditions and the following disclaimer. 12 | # Redistributions in binary form must reproduce the above copyright 13 | # notice, this list of conditions and the following disclaimer in the 14 | # documentation and/or other materials provided with the 15 | # distribution. Neither the name of Sony Pictures Imageworks nor the 16 | # names of its contributors may be used to endorse or promote 17 | # products derived from this software without specific prior written 18 | # permission. 19 | # 20 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 21 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 23 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 24 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 30 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 31 | # OF THE POSSIBILITY OF SUCH DAMAGE. 32 | 33 | # ------------------------------------------------------------------------------ 34 | 35 | from BuildSupport import * 36 | 37 | # ------------------------------------------------------------------------------ 38 | 39 | env = Environment(CXXFLAGS="-std=c++11") 40 | 41 | Export("env") 42 | 43 | SConscript("SConscript") 44 | 45 | # ------------------------------------------------------------------------------ 46 | 47 | -------------------------------------------------------------------------------- /apps/f3dinfo/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.dblite 3 | -------------------------------------------------------------------------------- /apps/f3dinfo/SConscript: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | import os 4 | import sys 5 | 6 | # ------------------------------------------------------------------------------ 7 | 8 | pathToRoot = "../.." 9 | 10 | sys.path.append(pathToRoot) 11 | 12 | from BuildSupport import * 13 | 14 | appName = "f3dinfo" 15 | buildPath = buildDir() 16 | binPath = join(buildPath, appName) 17 | 18 | # ------------------------------------------------------------------------------ 19 | 20 | Import("env") 21 | appEnv = env.Clone() 22 | 23 | setupEnv(appEnv, pathToRoot) 24 | addField3DInstall(appEnv, pathToRoot) 25 | 26 | appEnv.Append(LIBS = ["boost_program_options-mt", "boost_regex-mt"]) 27 | 28 | appEnv.VariantDir(buildPath, ".", duplicate = 0) 29 | files = Glob(join(buildPath, "*.cpp")) 30 | 31 | app = appEnv.Program(binPath, files) 32 | appEnv.Default(app) 33 | 34 | # ------------------------------------------------------------------------------ 35 | -------------------------------------------------------------------------------- /apps/f3dinfo/SConstruct: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | env = Environment() 4 | 5 | Export("env") 6 | 7 | SConscript("SConscript") 8 | 9 | # ------------------------------------------------------------------------------ 10 | 11 | -------------------------------------------------------------------------------- /apps/f3dmakemip/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.dblite 3 | -------------------------------------------------------------------------------- /apps/f3dmakemip/SConscript: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | import os 4 | import sys 5 | 6 | # ------------------------------------------------------------------------------ 7 | 8 | pathToRoot = "../.." 9 | 10 | sys.path.append(pathToRoot) 11 | 12 | from BuildSupport import * 13 | 14 | appName = "f3dmakemip" 15 | buildPath = buildDir() 16 | binPath = join(buildPath, appName) 17 | 18 | # ------------------------------------------------------------------------------ 19 | 20 | Import("env") 21 | appEnv = env.Clone() 22 | 23 | setupEnv(appEnv, pathToRoot) 24 | addField3DInstall(appEnv, pathToRoot) 25 | 26 | appEnv.Append(LIBS = ["boost_program_options-mt"]) 27 | 28 | appEnv.VariantDir(buildPath, ".", duplicate = 0) 29 | files = Glob(join(buildPath, "*.cpp")) 30 | 31 | app = appEnv.Program(binPath, files) 32 | appEnv.Default(app) 33 | 34 | # ------------------------------------------------------------------------------ 35 | -------------------------------------------------------------------------------- /apps/f3dmakemip/SConstruct: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | env = Environment() 4 | 5 | Export("env") 6 | 7 | SConscript("SConscript") 8 | 9 | # ------------------------------------------------------------------------------ 10 | 11 | -------------------------------------------------------------------------------- /apps/f3dmerge/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.dblite 3 | -------------------------------------------------------------------------------- /apps/f3dmerge/SConscript: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | import os 4 | import sys 5 | 6 | # ------------------------------------------------------------------------------ 7 | 8 | pathToRoot = "../.." 9 | 10 | sys.path.append(pathToRoot) 11 | 12 | from BuildSupport import * 13 | 14 | appName = "f3dmerge" 15 | buildPath = buildDir() 16 | binPath = join(buildPath, appName) 17 | 18 | # ------------------------------------------------------------------------------ 19 | 20 | Import("env") 21 | appEnv = env.Clone() 22 | 23 | setupEnv(appEnv, pathToRoot) 24 | addField3DInstall(appEnv, pathToRoot) 25 | 26 | appEnv.Append(LIBS = ["boost_program_options-mt"]) 27 | 28 | appEnv.VariantDir(buildPath, ".", duplicate = 0) 29 | files = Glob(join(buildPath, "*.cpp")) 30 | 31 | app = appEnv.Program(binPath, files) 32 | appEnv.Default(app) 33 | 34 | # ------------------------------------------------------------------------------ 35 | -------------------------------------------------------------------------------- /apps/f3dmerge/SConstruct: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | env = Environment() 4 | 5 | Export("env") 6 | 7 | SConscript("SConscript") 8 | 9 | # ------------------------------------------------------------------------------ 10 | 11 | -------------------------------------------------------------------------------- /apps/f3dsample/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.dblite 3 | -------------------------------------------------------------------------------- /apps/f3dsample/SConscript: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | import os 4 | import sys 5 | 6 | # ------------------------------------------------------------------------------ 7 | 8 | pathToRoot = "../.." 9 | 10 | sys.path.append(pathToRoot) 11 | 12 | from BuildSupport import * 13 | 14 | appName = "f3dsample" 15 | buildPath = buildDir() 16 | binPath = join(buildPath, appName) 17 | 18 | # ------------------------------------------------------------------------------ 19 | 20 | Import("env") 21 | appEnv = env.Clone() 22 | 23 | setupEnv(appEnv, pathToRoot) 24 | addField3DInstall(appEnv, pathToRoot) 25 | 26 | appEnv.Append(LIBS = ["boost_program_options-mt"]) 27 | 28 | appEnv.VariantDir(buildPath, ".", duplicate = 0) 29 | files = Glob(join(buildPath, "*.cpp")) 30 | 31 | app = appEnv.Program(binPath, files) 32 | appEnv.Default(app) 33 | 34 | # ------------------------------------------------------------------------------ 35 | -------------------------------------------------------------------------------- /apps/f3dsample/SConstruct: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | env = Environment() 4 | 5 | Export("env") 6 | 7 | SConscript("SConscript") 8 | 9 | # ------------------------------------------------------------------------------ 10 | 11 | -------------------------------------------------------------------------------- /apps/sample_code/create_and_write/SConscript: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | import os 4 | import sys 5 | 6 | # ------------------------------------------------------------------------------ 7 | 8 | pathToRoot = "../../.." 9 | 10 | sys.path.append(pathToRoot) 11 | 12 | from BuildSupport import * 13 | 14 | buildPath = buildDir() 15 | binPath = join(buildPath, os.path.basename(os.getcwd())) 16 | 17 | # ------------------------------------------------------------------------------ 18 | 19 | Import("env") 20 | appEnv = env.Clone() 21 | 22 | setupEnv(appEnv, pathToRoot) 23 | addField3DInstall(appEnv, pathToRoot) 24 | 25 | appEnv.VariantDir(buildPath, ".", duplicate = 0) 26 | files = Glob(join(buildPath, "*.cpp")) 27 | 28 | app = appEnv.Program(binPath, files) 29 | appEnv.Default(app) 30 | 31 | # ------------------------------------------------------------------------------ 32 | -------------------------------------------------------------------------------- /apps/sample_code/create_and_write/SConstruct: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | env = Environment() 4 | 5 | Export("env") 6 | 7 | SConscript("SConscript") 8 | 9 | # ------------------------------------------------------------------------------ 10 | 11 | -------------------------------------------------------------------------------- /apps/sample_code/create_and_write/main.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /* Field3D examples - create and write 39 | 40 | This sample application creates a DenseField object and writes it to disk. 41 | 42 | */ 43 | 44 | //----------------------------------------------------------------------------// 45 | 46 | #include 47 | #include 48 | 49 | #include 50 | #include 51 | #include 52 | 53 | //----------------------------------------------------------------------------// 54 | 55 | using namespace std; 56 | 57 | using namespace Field3D; 58 | 59 | //----------------------------------------------------------------------------// 60 | 61 | int main(int argc, char **argv) 62 | { 63 | // Call initIO() to initialize standard I/O methods and load plugins 64 | Field3D::initIO(); 65 | 66 | DenseField::Ptr field(new DenseField); 67 | field->name = "hello"; 68 | field->attribute = "world"; 69 | field->setSize(V3i(50, 50, 50)); 70 | field->clear(1.0f); 71 | field->metadata().setStrMetadata("my_attribute", "my_value"); 72 | 73 | Field3DOutputFile out; 74 | out.create("field3d_file.f3d"); 75 | out.writeScalarLayer(field); 76 | } 77 | 78 | //----------------------------------------------------------------------------// 79 | 80 | -------------------------------------------------------------------------------- /apps/sample_code/mixed_types/SConscript: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | import os 4 | import sys 5 | 6 | # ------------------------------------------------------------------------------ 7 | 8 | pathToRoot = "../../.." 9 | 10 | sys.path.append(pathToRoot) 11 | 12 | from BuildSupport import * 13 | 14 | buildPath = buildDir() 15 | binPath = join(buildPath, os.path.basename(os.getcwd())) 16 | 17 | # ------------------------------------------------------------------------------ 18 | 19 | Import("env") 20 | appEnv = env.Clone() 21 | 22 | setupEnv(appEnv, pathToRoot) 23 | addField3DInstall(appEnv, pathToRoot) 24 | 25 | appEnv.VariantDir(buildPath, ".", duplicate = 0) 26 | files = Glob(join(buildPath, "*.cpp")) 27 | 28 | app = appEnv.Program(binPath, files) 29 | appEnv.Default(app) 30 | 31 | # ------------------------------------------------------------------------------ 32 | -------------------------------------------------------------------------------- /apps/sample_code/mixed_types/SConstruct: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | env = Environment() 4 | 5 | Export("env") 6 | 7 | SConscript("SConscript") 8 | 9 | # ------------------------------------------------------------------------------ 10 | 11 | -------------------------------------------------------------------------------- /apps/sample_code/mixed_types/main.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /* Field3D examples - mixed types 39 | 40 | This sample application creates multiple fields and writes them all to 41 | the same file. 42 | 43 | */ 44 | 45 | //----------------------------------------------------------------------------// 46 | 47 | #include 48 | #include 49 | 50 | #include 51 | #include 52 | #include 53 | 54 | #include 55 | #include 56 | 57 | #include 58 | 59 | //----------------------------------------------------------------------------// 60 | 61 | using namespace std; 62 | 63 | using namespace Field3D; 64 | 65 | //----------------------------------------------------------------------------// 66 | 67 | int main(int argc, char **argv) 68 | { 69 | typedef Field3D::half half; 70 | 71 | // Call initIO() to initialize standard I/O methods and load plugins --- 72 | 73 | Field3D::initIO(); 74 | 75 | // Create a set of fields with different types and bit depths --- 76 | 77 | // ... First a DenseField 78 | 79 | DenseField::Ptr denseField(new DenseField); 80 | denseField->name = "density_source"; 81 | denseField->attribute = "density"; 82 | denseField->setSize(V3i(50, 50, 50)); 83 | denseField->clear(0.0f); 84 | 85 | // ... Then two SparseFields to make up a moving levelset 86 | 87 | SparseField::Ptr sparseField(new SparseField); 88 | sparseField->name = "character"; 89 | sparseField->attribute = "levelset"; 90 | sparseField->setSize(V3i(250, 250, 250)); 91 | sparseField->clear(0.0f); 92 | 93 | SparseField::Ptr sparseVField(new SparseField); 94 | sparseVField->name = "character"; 95 | sparseVField->attribute = "v"; 96 | sparseVField->setSize(V3i(50, 50, 50)); 97 | sparseVField->clear(V3f(0.0f)); 98 | 99 | // ... Finally a MACField, using the typedefs 100 | 101 | MACField3f::Ptr macField(new MACField3f); 102 | macField->name = "simulation"; 103 | macField->attribute = "v"; 104 | macField->setSize(V3i(120, 50, 100)); 105 | macField->clear(V3f(0.0f)); 106 | 107 | // Write the output --- 108 | 109 | Field3DOutputFile out; 110 | out.create("mixed_file.f3d"); 111 | out.writeScalarLayer(denseField); 112 | out.writeScalarLayer(sparseField); 113 | out.writeVectorLayer(sparseVField); 114 | out.writeVectorLayer(macField); 115 | } 116 | 117 | //----------------------------------------------------------------------------// 118 | 119 | -------------------------------------------------------------------------------- /apps/sample_code/read/SConscript: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | import os 4 | import sys 5 | 6 | # ------------------------------------------------------------------------------ 7 | 8 | pathToRoot = "../../.." 9 | 10 | sys.path.append(pathToRoot) 11 | 12 | from BuildSupport import * 13 | 14 | buildPath = buildDir() 15 | binPath = join(buildPath, os.path.basename(os.getcwd())) 16 | 17 | # ------------------------------------------------------------------------------ 18 | 19 | Import("env") 20 | appEnv = env.Clone() 21 | 22 | setupEnv(appEnv, pathToRoot) 23 | addField3DInstall(appEnv, pathToRoot) 24 | 25 | appEnv.VariantDir(buildPath, ".", duplicate = 0) 26 | files = Glob(join(buildPath, "*.cpp")) 27 | 28 | app = appEnv.Program(binPath, files) 29 | appEnv.Default(app) 30 | 31 | # ------------------------------------------------------------------------------ 32 | -------------------------------------------------------------------------------- /apps/sample_code/read/SConstruct: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | env = Environment() 4 | 5 | Export("env") 6 | 7 | SConscript("SConscript") 8 | 9 | # ------------------------------------------------------------------------------ 10 | 11 | -------------------------------------------------------------------------------- /apps/sample_code/read/main.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /* Field3D examples - read 39 | 40 | This sample application reads all fields found in a given .f3d file and 41 | prints their types, names and attributes. 42 | 43 | */ 44 | 45 | //----------------------------------------------------------------------------// 46 | 47 | #include 48 | #include 49 | 50 | #include 51 | #include 52 | #include 53 | #include 54 | #include 55 | 56 | //----------------------------------------------------------------------------// 57 | 58 | using namespace std; 59 | 60 | using namespace Field3D; 61 | 62 | //----------------------------------------------------------------------------// 63 | 64 | template 65 | void readLayersAndPrintInfo(Field3DInputFile &in, const std::string &name) 66 | { 67 | typedef FIELD3D_VEC3_T VecData_T; 68 | typedef typename Field::Vec SFieldList; 69 | typedef typename Field >::Vec VFieldList; 70 | 71 | // Note that both scalar and vector calls take the scalar type as argument 72 | SFieldList sFields = in.readScalarLayers(name); 73 | VFieldList vFields = in.readVectorLayers(name); 74 | 75 | // Print info about the found fields --- 76 | 77 | if (sFields.size() > 0) { 78 | 79 | for (typename SFieldList::const_iterator i = sFields.begin(); 80 | i != sFields.end(); ++i) { 81 | 82 | if (field_dynamic_cast >(*i)) { 83 | cout << " DenseField" << endl; 84 | } 85 | else if (field_dynamic_cast >(*i)) { 86 | cout << " SparseField" << endl; 87 | } 88 | 89 | cout << " Name: " << (**i).name << endl; 90 | cout << " Attribute: " << (**i).attribute << endl; 91 | 92 | } 93 | 94 | } else { 95 | cout << " Found no scalar fields" << endl; 96 | } 97 | 98 | if (vFields.size() > 0) { 99 | 100 | for (typename VFieldList::const_iterator i = vFields.begin(); 101 | i != vFields.end(); ++i) { 102 | 103 | if (field_dynamic_cast >(*i)) { 104 | cout << " DenseField" << endl; 105 | } 106 | else if (field_dynamic_cast >(*i)) { 107 | cout << " SparseField" << endl; 108 | } 109 | else if (field_dynamic_cast >(*i)) { 110 | cout << " MACField" << endl; 111 | } 112 | 113 | cout << " Name: " << (**i).name << endl; 114 | cout << " Attribute: " << (**i).attribute << endl; 115 | 116 | } 117 | 118 | } else { 119 | cout << " Found no vector fields" << endl; 120 | } 121 | 122 | } 123 | 124 | //----------------------------------------------------------------------------// 125 | 126 | int main(int argc, char **argv) 127 | { 128 | typedef Field3D::half half; 129 | 130 | // Call initIO() to initialize standard I/O methods and load plugins --- 131 | 132 | Field3D::initIO(); 133 | 134 | // Process command line --- 135 | 136 | if (argc < 2) { 137 | cout << "Usage: read [name]" << endl; 138 | return 1; 139 | } 140 | 141 | string filename = string(argv[1]); 142 | string name; 143 | 144 | if (argc == 3) { 145 | name = string(argv[2]); 146 | } 147 | 148 | // Load file --- 149 | 150 | Field3DInputFile in; 151 | if (!in.open(filename)) { 152 | cout << "Aborting because of errors" << endl; 153 | return 1; 154 | } 155 | 156 | cout << "Reading layers" << endl; 157 | readLayersAndPrintInfo(in, name); 158 | 159 | cout << "Reading layers" << endl; 160 | readLayersAndPrintInfo(in, name); 161 | 162 | cout << "Reading layers" << endl; 163 | readLayersAndPrintInfo(in, name); 164 | 165 | } 166 | 167 | //----------------------------------------------------------------------------// 168 | 169 | -------------------------------------------------------------------------------- /apps/sample_code/sparse_field_io/SConscript: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | import os 4 | import sys 5 | 6 | # ------------------------------------------------------------------------------ 7 | 8 | pathToRoot = "../../.." 9 | 10 | sys.path.append(pathToRoot) 11 | 12 | from BuildSupport import * 13 | 14 | buildPath = buildDir() 15 | binPath = join(buildPath, os.path.basename(os.getcwd())) 16 | 17 | # ------------------------------------------------------------------------------ 18 | 19 | Import("env") 20 | appEnv = env.Clone() 21 | 22 | setupEnv(appEnv, pathToRoot) 23 | addField3DInstall(appEnv, pathToRoot) 24 | 25 | appEnv.VariantDir(buildPath, ".", duplicate = 0) 26 | files = Glob(join(buildPath, "*.cpp")) 27 | 28 | app = appEnv.Program(binPath, files) 29 | appEnv.Default(app) 30 | 31 | # ------------------------------------------------------------------------------ 32 | -------------------------------------------------------------------------------- /apps/sample_code/sparse_field_io/SConstruct: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | env = Environment() 4 | 5 | Export("env") 6 | 7 | SConscript("SConscript") 8 | 9 | # ------------------------------------------------------------------------------ 10 | 11 | -------------------------------------------------------------------------------- /apps/sample_code/sparse_field_io/main.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | #include 39 | 40 | #include 41 | #include 42 | 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | 50 | //----------------------------------------------------------------------------// 51 | 52 | using namespace boost; 53 | using namespace std; 54 | 55 | using namespace Field3D; 56 | 57 | //----------------------------------------------------------------------------// 58 | 59 | //! Converts any class with operator<< to a string using boost::lexical_cast 60 | template 61 | std::string str(const T& t) 62 | { 63 | return boost::lexical_cast(t); 64 | } 65 | 66 | //----------------------------------------------------------------------------// 67 | 68 | int main(int argc, char **argv) 69 | { 70 | std::string filename("test_file.f3d"); 71 | std::string attribName("attrib"); 72 | 73 | // Initialize IO 74 | initIO(); 75 | 76 | int numFields = 5; 77 | 78 | if (argc == 2) { 79 | try { 80 | numFields = lexical_cast(argv[1]); 81 | } 82 | catch (boost::bad_lexical_cast &e) { 83 | Msg::print("Couldn't parse integer number. Aborting"); 84 | exit(1); 85 | } 86 | } else { 87 | // No voxel res given 88 | Msg::print("Usage: " + str(argv[0]) + 89 | " "); 90 | Msg::print("Got no number of fields. Using default."); 91 | } 92 | 93 | // Create fields --- 94 | 95 | Msg::print("Creating " + str(numFields) + " fields"); 96 | 97 | SparseFieldf::Vec fields; 98 | 99 | for (int i = 0; i < numFields; i++) { 100 | // Create 101 | SparseFieldf::Ptr field(new SparseFieldf); 102 | field->setSize(V3i(128)); 103 | field->name = str(i); 104 | field->attribute = attribName; 105 | // Fill with values 106 | SparseFieldf::iterator fi = field->begin(), fend = field->end(); 107 | for (; fi != fend; ++fi) { 108 | *fi = i; 109 | } 110 | fields.push_back(field); 111 | } 112 | 113 | // Write fields --- 114 | 115 | Msg::print("Writing fields"); 116 | 117 | Field3DOutputFile out; 118 | out.create(filename); 119 | 120 | for (int i = 0; i < numFields; i++) { 121 | out.writeScalarLayer(fields[i]); 122 | } 123 | 124 | // Read with dynamic loading --- 125 | 126 | Msg::print("Reading fields"); 127 | 128 | SparseFileManager::singleton().setLimitMemUse(true); 129 | 130 | Field::Vec loadedFields; 131 | 132 | Field3DInputFile in; 133 | in.open(filename); 134 | 135 | for (int i = 0; i < numFields; i++) { 136 | Field::Vec fields = in.readScalarLayers(str(i), attribName); 137 | if (fields.size() != 1) { 138 | Msg::print("Got the wrong # of fields. Aborting."); 139 | exit(1); 140 | } 141 | loadedFields.push_back(fields[0]); 142 | } 143 | 144 | // Compare fields --- 145 | 146 | Msg::print("Comparing fields"); 147 | 148 | FIELD3D_RAND48 rng(10512); 149 | 150 | Msg::print(" Mem use before access: "); 151 | 152 | for (int i = 0; i < numFields; i++) { 153 | Msg::print(" Field " + str(i) + " : " + 154 | str(fields[i]->memSize())); 155 | Msg::print(" Loaded field " + str(i) + ": " + 156 | str(loadedFields[i]->memSize())); 157 | } 158 | 159 | LinearFieldInterp interp; 160 | for (int sample = 0; sample < 1000; sample++) { 161 | V3d lsP(rng.nextf(), rng.nextf(), rng.nextf()), vsP; 162 | for (int i = 0; i < numFields; i++) { 163 | fields[i]->mapping()->localToVoxel(lsP, vsP); 164 | float value = interp.sample(*fields[i], vsP); 165 | float loadedValue = interp.sample(*loadedFields[i], vsP); 166 | if (value != loadedValue) { 167 | Msg::print("Got a bad value at " + str(vsP)); 168 | exit(1); 169 | } 170 | } 171 | } 172 | 173 | Msg::print(" Mem use after access: "); 174 | 175 | for (int i = 0; i < numFields; i++) { 176 | Msg::print(" Field " + str(i) + " : " + 177 | str(fields[i]->memSize())); 178 | Msg::print(" Loaded field " + str(i) + ": " + 179 | str(loadedFields[i]->memSize())); 180 | } 181 | 182 | } 183 | 184 | //----------------------------------------------------------------------------// 185 | -------------------------------------------------------------------------------- /cmake/FindILMBase.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2009 Sony Pictures Imageworks Inc. et al. 2 | # 3 | # All rights reserved. 4 | # 5 | # Redistribution and use in source and binary forms, with or without 6 | # modification, are permitted provided that the following conditions 7 | # are met: 8 | # 9 | # Redistributions of source code must retain the above copyright 10 | # notice, this list of conditions and the following disclaimer. 11 | # Redistributions in binary form must reproduce the above copyright 12 | # notice, this list of conditions and the following disclaimer in the 13 | # documentation and/or other materials provided with the 14 | # distribution. Neither the name of Sony Pictures Imageworks nor the 15 | # names of its contributors may be used to endorse or promote 16 | # products derived from this software without specific prior written 17 | # permission. 18 | # 19 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 20 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 21 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 22 | # FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 23 | # COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 24 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | # (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 27 | # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 28 | # STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 29 | # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 30 | # OF THE POSSIBILITY OF SUCH DAMAGE. 31 | 32 | # Author : Nicholas Yue yue.nicholas@gmail.com 33 | 34 | # This module will define the following variables: 35 | # ILMBASE_INCLUDE_DIRS - Location of the ilmbase includes 36 | # ILMBASE_LIBRARIES - [TODO] Required libraries for all requested bindings 37 | # ILMBASE_FOUND - true if ILMBASE was found on the system 38 | # ILMBASE_LIBRARY_DIRS - the full set of library directories 39 | 40 | FIND_PATH ( Ilmbase_Base_Dir NAMES include/OpenEXR/IlmBaseConfig.h 41 | PATHS ${ILMBASE_ROOT} 42 | ) 43 | 44 | IF ( Ilmbase_Base_Dir ) 45 | 46 | SET ( ILMBASE_INCLUDE_DIRS 47 | ${Ilmbase_Base_Dir}/include 48 | ${Ilmbase_Base_Dir}/include/OpenEXR 49 | CACHE STRING "ILMBase include directories") 50 | SET ( ILMBASE_LIBRARY_DIRS ${Ilmbase_Base_Dir}/lib64 51 | CACHE STRING "ILMBase library directories") 52 | SET ( ILMBASE_FOUND TRUE ) 53 | 54 | ENDIF ( Ilmbase_Base_Dir ) 55 | -------------------------------------------------------------------------------- /contrib/maya_plugin/exportF3d/Makefile.gnu: -------------------------------------------------------------------------------- 1 | # edit this if your maya installation is somewhere else. 2 | MAYA_LOCATION = /net/apps/spinux1/aw/maya2012 3 | 4 | #edit this for the Field3D installation directory 5 | FIELD3D_ROOT = /usr/3rd_party_software/Field3D 6 | FIELD3D_INC = $(FIELD3D_ROOT)/include 7 | FIELD3D_LIB = $(FIELD3D_ROOT)/lib 8 | 9 | C++ = g++ 10 | 11 | CFLAGS = -DBits64_ -m64 -DUNIX -D_BOOL -DLINUX -DFUNCPROTO -D_GNU_SOURCE \ 12 | -DLINUX_64 -fPIC \ 13 | -fno-strict-aliasing -DREQUIRE_IOSTREAM -Wno-deprecated -O3 -Wall \ 14 | -Wno-multichar -Wno-comment -Wno-sign-compare -funsigned-char \ 15 | -Wno-reorder -fno-gnu-keywords -ftemplate-depth-25 -pthread 16 | 17 | C++FLAGS = $(CFLAGS) $(WARNFLAGS) -Wno-deprecated -fno-gnu-keywords 18 | 19 | INCLUDES = -I. -I.. -I$(MAYA_LOCATION)/include \ 20 | -I/usr/X11R6/include \ 21 | -I/usr/include/OpenEXR \ 22 | -I$(FIELD3D_INC) 23 | 24 | LD = $(C++) -shared $(NO_TRANS_LINK) $(C++FLAGS) 25 | 26 | # add more libs if you need to for your plugin 27 | LIBS = -L$(MAYA_LOCATION)/lib -lOpenMaya\ 28 | -Wl,-rpath,$(FIELD3D_LIB) -L$(FIELD3D_LIB) -lField3D 29 | 30 | 31 | exportF3d.so: exportF3d.o 32 | -rm -f $@ 33 | $(LD) -o $@ $^ $(LIBS) -lOpenMayaAnim -lOpenMayaFX 34 | 35 | 36 | depend: 37 | makedepend $(INCLUDES) -I/usr/include/CC *.cc 38 | 39 | clean: 40 | -rm -f *.o 41 | 42 | Clean: 43 | -rm -f *.o *.so *.lib *.bak *.bundle 44 | 45 | ################## 46 | # Generic Rules # 47 | ################## 48 | 49 | %.o : %.cpp 50 | $(C++) -c $(INCLUDES) $(C++FLAGS) $< 51 | 52 | %.$(so) : %.cpp 53 | -rm -f $@ 54 | $(C++) -o $@ $(INCLUDES) $(C++FLAGS) $< $(LFLAGS) $(LIBS) 55 | 56 | %.$(so) : %.o 57 | -rm -f $@ 58 | $(LD) -o $@ $< $(LIBS) 59 | 60 | -------------------------------------------------------------------------------- /export/Documentation.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file Documentation.h 39 | \brief Only contains doxygen documentation. 40 | */ 41 | 42 | //----------------------------------------------------------------------------// 43 | // Modules 44 | //----------------------------------------------------------------------------// 45 | 46 | /*! \defgroup field Fields 47 | \brief These are the main parts of the library that a user would deal with. 48 | */ 49 | 50 | /*! \defgroup file File I/O 51 | \brief These are the main parts of the library that a user would deal with. 52 | */ 53 | 54 | /*! \defgroup internal Classes and functions used to implement this library 55 | \brief These classes are used to implement the library and are of interest 56 | to anyone maintaining or changing the library. 57 | */ 58 | 59 | /*! \defgroup exc Exceptions used in the library 60 | \ingroup internal 61 | */ 62 | 63 | /*! \defgroup hdf5 Hdf5 Utility Classes and Functions 64 | \ingroup internal 65 | */ 66 | 67 | /*! \defgroup file_int Field IO classes under-the-hood 68 | \ingroup internal 69 | */ 70 | 71 | /*! \defgroup field_int Field classes under-the-hood 72 | \ingroup internal 73 | */ 74 | 75 | /*! \defgroup template_util Templated utility classes 76 | \ingroup internal 77 | */ 78 | 79 | //----------------------------------------------------------------------------// 80 | // Main Documentation page 81 | //----------------------------------------------------------------------------// 82 | 83 | /*! \mainpage Field3D 84 | 85 | Field3D is an open source library for storing voxel data. It provides C++ 86 | classes that handle in-memory storage and a file format based on HDF5 that 87 | allows the C++ objects to be written to and read from disk. 88 | 89 | \n 90 | 91 | The majority of the documentation is available in the project Wiki at 92 | https://sites.google.com/site/field3d/ 93 | 94 | */ // \mainpage 95 | -------------------------------------------------------------------------------- /export/FieldIO.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file FieldIO.h 39 | \brief Contains FieldIO class. 40 | */ 41 | 42 | //----------------------------------------------------------------------------// 43 | 44 | #ifndef _INCLUDED_Field3D_FieldIO_H_ 45 | #define _INCLUDED_Field3D_FieldIO_H_ 46 | 47 | //----------------------------------------------------------------------------// 48 | 49 | #include 50 | 51 | #include 52 | #include 53 | #include 54 | 55 | #include 56 | #include 57 | 58 | #include "Field.h" 59 | #include "OgawaFwd.h" 60 | #include "Log.h" 61 | 62 | //----------------------------------------------------------------------------// 63 | 64 | #include "ns.h" 65 | 66 | FIELD3D_NAMESPACE_OPEN 67 | 68 | //----------------------------------------------------------------------------// 69 | // FieldIO 70 | //----------------------------------------------------------------------------// 71 | 72 | /*! \class FieldIO 73 | \ingroup file_int 74 | A creation class. The application needs to derive from this class 75 | for any new voxel field data structions. Within the read and write methods 76 | it is expected that the derived object knows how to read and write to an 77 | hdf5 file through the layerGroup id. 78 | 79 | \todo Merge this into ClassFactory. 80 | */ 81 | 82 | //----------------------------------------------------------------------------// 83 | 84 | class FieldIO : public RefBase 85 | { 86 | 87 | public: 88 | 89 | // Typedefs ------------------------------------------------------------------ 90 | 91 | typedef boost::intrusive_ptr Ptr; 92 | 93 | // RTTI replacement ---------------------------------------------------------- 94 | 95 | typedef FieldIO class_type; 96 | DEFINE_FIELD_RTTI_ABSTRACT_CLASS; 97 | 98 | static const char * staticClassType() 99 | { 100 | return "FieldIO"; 101 | } 102 | 103 | // Ctors, dtor --------------------------------------------------------------- 104 | 105 | //! Ctor 106 | FieldIO() 107 | : RefBase() 108 | { } 109 | 110 | //! Dtor 111 | virtual ~FieldIO() {} 112 | 113 | // Methods to be implemented by subclasses ----------------------------------- 114 | 115 | //! Read the field at the given hdf5 group 116 | //! \returns Pointer to the created field, or a null pointer if the field 117 | //! couldn't be read. 118 | virtual FieldBase::Ptr read(hid_t layerGroup, const std::string &filename, 119 | const std::string &layerPath, 120 | DataTypeEnum typeEnum) = 0; 121 | 122 | //! Read the field at the given Ogawa group 123 | //! \returns Pointer to the created field, or a null pointer if the field 124 | //! couldn't be read. 125 | virtual FieldBase::Ptr read(const OgIGroup &layerGroup, 126 | const std::string &filename, 127 | const std::string &layerPath, 128 | OgDataType typeEnum) = 0; 129 | 130 | //! Write the field to the given layer group 131 | //! \returns Whether the operation was successful 132 | virtual bool write(hid_t layerGroup, FieldBase::Ptr field) = 0; 133 | 134 | //! Write the field to the given layer group 135 | //! \returns Whether the operation was successful 136 | virtual bool write(OgOGroup &layerGroup, FieldBase::Ptr field) = 0; 137 | 138 | //! Returns the class name. This is used when registering the class to the 139 | //! FieldIOFactory object. 140 | virtual std::string className() const = 0; 141 | 142 | // Strings used when reading/writing ----------------------------------------- 143 | 144 | private: 145 | 146 | // Typedefs ------------------------------------------------------------------ 147 | 148 | //! Convenience typedef for referring to base class 149 | typedef RefBase base; 150 | 151 | }; 152 | 153 | //----------------------------------------------------------------------------// 154 | 155 | FIELD3D_NAMESPACE_HEADER_CLOSE 156 | 157 | //----------------------------------------------------------------------------// 158 | 159 | #endif 160 | -------------------------------------------------------------------------------- /export/FileSequence.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2014 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file FileSequence.h 39 | \brief Contains the FileSequence class which can be used to turn strings 40 | such as "file.1-20#.f3d" into a vector of strings 41 | */ 42 | 43 | //----------------------------------------------------------------------------// 44 | 45 | #ifndef _INCLUDED_Field3D_FileSequence_H_ 46 | #define _INCLUDED_Field3D_FileSequence_H_ 47 | 48 | //----------------------------------------------------------------------------// 49 | 50 | #include 51 | #include 52 | 53 | //----------------------------------------------------------------------------// 54 | 55 | #include "ns.h" 56 | 57 | FIELD3D_NAMESPACE_OPEN 58 | 59 | //----------------------------------------------------------------------------// 60 | // FileSequence 61 | //----------------------------------------------------------------------------// 62 | 63 | class FileSequence 64 | { 65 | 66 | public: 67 | 68 | // Typedefs --- 69 | 70 | typedef std::vector StringVec; 71 | 72 | // Ctors, dtor --- 73 | 74 | //! Default constructor. Creates an empty sequence 75 | FileSequence() 76 | { } 77 | //! Construct from a sequence string. If the sequence string is an actual 78 | //! filename, we become a 1-length sequence. If the sequence can't be 79 | //! resolved, we become a 0-length sequence. 80 | //! \note Apart from checking if the sequence is itself a filename, no 81 | //! checks are made to see that the actual resulting files exist. 82 | FileSequence(const std::string &sequence); 83 | 84 | //! Number of files in sequence 85 | size_t size() const 86 | { return m_filenames.size(); } 87 | 88 | //! Returns a single filename 89 | const std::string& filename(const size_t idx) const 90 | { return m_filenames[idx]; } 91 | 92 | //! Returns the full list of all filenames 93 | const StringVec& filenames() const 94 | { return m_filenames; } 95 | 96 | private: 97 | 98 | // Data members ------------------------------------------------------------ 99 | 100 | //! Stores the resulting filenames 101 | std::vector m_filenames; 102 | 103 | }; 104 | 105 | //----------------------------------------------------------------------------// 106 | 107 | FIELD3D_NAMESPACE_HEADER_CLOSE 108 | 109 | //----------------------------------------------------------------------------// 110 | 111 | #endif // Include guard 112 | -------------------------------------------------------------------------------- /export/InitIO.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file InitIO.h 39 | \brief Contains the initIO function. 40 | \ingroup field 41 | */ 42 | 43 | //----------------------------------------------------------------------------// 44 | 45 | #ifndef _INCLUDED_Field3D_InitIO_H_ 46 | #define _INCLUDED_Field3D_InitIO_H_ 47 | 48 | //----------------------------------------------------------------------------// 49 | 50 | #include "Types.h" 51 | 52 | //----------------------------------------------------------------------------// 53 | 54 | #include "ns.h" 55 | 56 | FIELD3D_NAMESPACE_OPEN 57 | 58 | //----------------------------------------------------------------------------// 59 | 60 | //! Initializes the built-in Field3D IO classes. 61 | //! \ingroup file 62 | FIELD3D_API void initIO(); 63 | 64 | //----------------------------------------------------------------------------// 65 | 66 | //! Sets the number of threads to use for I/O multi-threading 67 | FIELD3D_API void setNumIOThreads(const size_t numThreads); 68 | 69 | //----------------------------------------------------------------------------// 70 | 71 | //! Returns the number of I/O threads to use 72 | FIELD3D_API size_t numIOThreads(); 73 | 74 | //----------------------------------------------------------------------------// 75 | 76 | FIELD3D_NAMESPACE_HEADER_CLOSE 77 | 78 | //----------------------------------------------------------------------------// 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /export/Log.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file Log.h 39 | \brief Contains the Log class which can be used to redirect output to an 40 | arbitrary destination. 41 | */ 42 | 43 | //----------------------------------------------------------------------------// 44 | 45 | #ifndef _INCLUDED_Field3D_Log_H_ 46 | #define _INCLUDED_Field3D_Log_H_ 47 | 48 | //----------------------------------------------------------------------------// 49 | 50 | #include 51 | 52 | //----------------------------------------------------------------------------// 53 | 54 | #include "ns.h" 55 | 56 | FIELD3D_NAMESPACE_OPEN 57 | 58 | //----------------------------------------------------------------------------// 59 | // Msg namespace 60 | //----------------------------------------------------------------------------// 61 | 62 | //! Contains logging-related functions. 63 | namespace Msg { 64 | 65 | //! Used by the Msg::print() call 66 | enum Severity { 67 | SevMessage, 68 | SevWarning 69 | }; 70 | 71 | //! Sends the string to the assigned output, prefixing the message with 72 | //! the severity 73 | FIELD3D_API void print(Severity severity, const std::string &message); 74 | 75 | //! Sends the string to the assigned output 76 | inline void print(const std::string &message) 77 | { print(SevMessage, message); } 78 | 79 | //! Set the verbosity level of console output: 0 = do not echo anything 80 | //! to the console; >=1 = echo all messages and warnings to the console. 81 | FIELD3D_API void setVerbosity (int level=1); 82 | 83 | } // namespace Msg 84 | 85 | //----------------------------------------------------------------------------// 86 | // Logging helper functions 87 | //----------------------------------------------------------------------------// 88 | 89 | //! Converts a byte count into a human-readable string 90 | std::string bytesToString(int64_t bytes); 91 | 92 | //----------------------------------------------------------------------------// 93 | 94 | //! Returns the current resident memory size 95 | //! \warning Currently only supported on Linux platform. Returns 0 for others. 96 | size_t currentRSS(); 97 | 98 | //----------------------------------------------------------------------------// 99 | 100 | FIELD3D_NAMESPACE_HEADER_CLOSE 101 | 102 | //----------------------------------------------------------------------------// 103 | 104 | #endif // Include guard 105 | -------------------------------------------------------------------------------- /export/MinMaxUtil.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2015 Sony Pictures Imageworks Inc, 5 | * Pixar Animation Studios 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the 18 | * distribution. Neither the name of Sony Pictures Imageworks nor the 19 | * names of its contributors may be used to endorse or promote 20 | * products derived from this software without specific prior written 21 | * permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | //----------------------------------------------------------------------------// 38 | 39 | /*! \file MinMaxUtil.h 40 | \brief Contains MIP-related utility functions 41 | */ 42 | 43 | //----------------------------------------------------------------------------// 44 | 45 | #ifndef _INCLUDED_Field3D_MinMaxUtil_H_ 46 | #define _INCLUDED_Field3D_MinMaxUtil_H_ 47 | 48 | //----------------------------------------------------------------------------// 49 | 50 | #include 51 | 52 | #include 53 | #include 54 | 55 | #include "MIPUtil.h" 56 | 57 | //----------------------------------------------------------------------------// 58 | 59 | #include "ns.h" 60 | 61 | FIELD3D_NAMESPACE_OPEN 62 | 63 | //----------------------------------------------------------------------------// 64 | // Functions 65 | //----------------------------------------------------------------------------// 66 | 67 | //! Constructs a min/max MIP representation of the given field. 68 | template 69 | std::pair 70 | makeMinMax(const typename MIPField_T::NestedType &base, 71 | const float resMult, const size_t numThreads); 72 | 73 | //----------------------------------------------------------------------------// 74 | // Constants 75 | //----------------------------------------------------------------------------// 76 | 77 | //! The standard 'min' suffix - "_min" 78 | extern const char* k_minSuffix; 79 | //! The standard 'max' suffix - "_max" 80 | extern const char* k_maxSuffix; 81 | 82 | //----------------------------------------------------------------------------// 83 | // Function implementations 84 | //----------------------------------------------------------------------------// 85 | 86 | template 87 | std::pair 88 | makeMinMax(const typename MIPField_T::NestedType &base, 89 | const float resMult, const size_t numThreads) 90 | { 91 | typedef typename MIPField_T::Ptr MipPtr; 92 | typedef typename MIPField_T::NestedType Field; 93 | typedef typename MIPField_T::NestedType::Ptr FieldPtr; 94 | 95 | // Storage for results 96 | std::pair result; 97 | 98 | // First, downsample the field into a min and max representation --- 99 | 100 | V3i srcRes = base.dataWindow().size() + Field3D::V3i(1); 101 | V3i res = V3f(srcRes) * std::min(1.0f, resMult); 102 | 103 | // Corner case handling 104 | res.x = std::max(res.x, 2); 105 | res.y = std::max(res.y, 2); 106 | res.z = std::max(res.z, 2); 107 | 108 | // Storage for min/max fields 109 | FieldPtr minSrc(new Field); 110 | FieldPtr maxSrc(new Field); 111 | 112 | // Resample 113 | resample(base, *minSrc, res, MinFilter()); 114 | resample(base, *maxSrc, res, MaxFilter()); 115 | 116 | // Second, generate MIP representations --- 117 | 118 | result.first = makeMIP(*minSrc, 2, numThreads); 119 | result.second = makeMIP(*maxSrc, 2, numThreads); 120 | 121 | return result; 122 | } 123 | 124 | //----------------------------------------------------------------------------// 125 | 126 | FIELD3D_NAMESPACE_HEADER_CLOSE 127 | 128 | //----------------------------------------------------------------------------// 129 | 130 | #endif // Include guard 131 | -------------------------------------------------------------------------------- /export/OgawaFwd.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2014 Sony Pictures Imageworks Inc., 5 | * Pixar Animation Studios Inc. 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the 18 | * distribution. Neither the name of Sony Pictures Imageworks nor the 19 | * names of its contributors may be used to endorse or promote 20 | * products derived from this software without specific prior written 21 | * permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | //----------------------------------------------------------------------------// 38 | 39 | /*! \file OgawaFwd.h 40 | \brief Contains forward declarations for Ogawa classes 41 | */ 42 | 43 | //----------------------------------------------------------------------------// 44 | 45 | #ifndef _INCLUDED_Field3D_OgawaFwd_H_ 46 | #define _INCLUDED_Field3D_OgawaFwd_H_ 47 | 48 | #include 49 | 50 | #include "ns.h" 51 | 52 | //----------------------------------------------------------------------------// 53 | // Forward declarations 54 | //----------------------------------------------------------------------------// 55 | 56 | FIELD3D_NAMESPACE_OPEN 57 | 58 | class OgIGroup; 59 | class OgOGroup; 60 | 61 | template 62 | class OgIAttribute; 63 | template 64 | class OgOAttribute; 65 | 66 | template 67 | class OgIDataset; 68 | template 69 | class OgODataset; 70 | 71 | typedef boost::shared_ptr OgIGroupPtr; 72 | 73 | FIELD3D_NAMESPACE_HEADER_CLOSE 74 | 75 | //----------------------------------------------------------------------------// 76 | 77 | namespace Alembic { 78 | namespace Ogawa { 79 | namespace v7 { 80 | class OArchive; 81 | class IArchive; 82 | } 83 | using namespace v7; 84 | } 85 | } 86 | 87 | typedef boost::shared_ptr IArchivePtr; 88 | 89 | //----------------------------------------------------------------------------// 90 | 91 | #endif // include guard 92 | -------------------------------------------------------------------------------- /export/PatternMatch.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file PatternMatch.h 39 | \brief Contains functions for pattern matching field name/attributes. 40 | */ 41 | 42 | //----------------------------------------------------------------------------// 43 | 44 | #ifndef _INCLUDED_PatternMatch_H_ 45 | #define _INCLUDED_PatternMatch_H_ 46 | 47 | #include 48 | 49 | // Boost includes 50 | #include 51 | #include 52 | #include 53 | 54 | #include "Field.h" 55 | 56 | //----------------------------------------------------------------------------// 57 | 58 | #include "ns.h" 59 | 60 | FIELD3D_NAMESPACE_OPEN 61 | 62 | //----------------------------------------------------------------------------// 63 | 64 | enum MatchFlags { 65 | MatchNoFlags = 0, 66 | MatchEmptyPattern = 1 << 0 67 | }; 68 | 69 | //----------------------------------------------------------------------------// 70 | 71 | //! Splits a string into a vector of strings, using ',' as the separator 72 | std::vector 73 | split(const std::string &s); 74 | 75 | //----------------------------------------------------------------------------// 76 | 77 | //! Splits a string into a vector of strings, given separator characters 78 | std::vector 79 | split(const std::string &s, const std::string &separatorChars); 80 | 81 | //----------------------------------------------------------------------------// 82 | 83 | //! Matches a : string against a set of patterns 84 | bool 85 | match(const std::string &name, const std::string &attribute, 86 | const std::vector &patterns, 87 | const MatchFlags flags = MatchEmptyPattern); 88 | bool 89 | match(const std::string &name, const std::string &attribute, 90 | const std::string &patterns, 91 | const MatchFlags flags = MatchEmptyPattern); 92 | 93 | //----------------------------------------------------------------------------// 94 | 95 | //! Matches an string against a set of patterns 96 | bool 97 | match(const std::string &attribute, const std::vector &patterns, 98 | const MatchFlags flags = MatchEmptyPattern); 99 | bool 100 | match(const std::string &attribute, const std::string &patterns, 101 | const MatchFlags flags = MatchEmptyPattern); 102 | 103 | //----------------------------------------------------------------------------// 104 | 105 | //! Matches a field's name and attribute against a set of patterns. 106 | bool 107 | match(const FieldRes *f, const std::vector &patterns, 108 | const MatchFlags flags = MatchEmptyPattern); 109 | bool 110 | match(const FieldRes *f, const std::string &patterns, 111 | const MatchFlags flags = MatchEmptyPattern); 112 | 113 | //----------------------------------------------------------------------------// 114 | 115 | FIELD3D_NAMESPACE_HEADER_CLOSE 116 | 117 | //----------------------------------------------------------------------------// 118 | 119 | #endif // Include guard 120 | -------------------------------------------------------------------------------- /export/PluginLoader.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file PluginLoader.h 39 | \brief Contains the PluginLoader class. 40 | */ 41 | 42 | //----------------------------------------------------------------------------// 43 | 44 | #ifndef _INCLUDED_Field3D_PluginLoader_H_ 45 | #define _INCLUDED_Field3D_PluginLoader_H_ 46 | 47 | #include 48 | #include 49 | 50 | //----------------------------------------------------------------------------// 51 | 52 | #include "ns.h" 53 | 54 | FIELD3D_NAMESPACE_OPEN 55 | 56 | //----------------------------------------------------------------------------// 57 | // PluginLoader 58 | //----------------------------------------------------------------------------// 59 | 60 | /*! \class PluginLoader 61 | \brief This class provides methods for loading Field plugins from disk. 62 | \ingroup file_int 63 | \todo Look into adding maya-style single-plugin load and unload functions 64 | */ 65 | 66 | //----------------------------------------------------------------------------// 67 | 68 | class PluginLoader 69 | { 70 | 71 | public: 72 | 73 | // Constructors -------------------------------------------------------------- 74 | 75 | //! Default constructor 76 | PluginLoader(); 77 | //! Destructor 78 | ~PluginLoader(); 79 | 80 | // Main methods -------------------------------------------------------------- 81 | 82 | //! Checks all paths in $FIELD3D_DSO_PATH and loads the plugins it finds 83 | static void loadPlugins(); 84 | 85 | #if 0 86 | //! Doesn't appear to be needed yet, but leave in the library just in case 87 | bool resolveGlobalsForPlugins(const char *dso); 88 | bool getDso(char *cptr,const char *dso, std::string &dsoPath); 89 | #endif 90 | 91 | private: 92 | 93 | // Private data members ------------------------------------------------------ 94 | 95 | //! List of plugins loaded 96 | static std::vector ms_pluginsLoaded; 97 | 98 | }; 99 | 100 | //----------------------------------------------------------------------------// 101 | // Utility functions 102 | //----------------------------------------------------------------------------// 103 | 104 | bool getDirSos(std::vector &sos, std::string &dir); 105 | 106 | //----------------------------------------------------------------------------// 107 | 108 | FIELD3D_NAMESPACE_HEADER_CLOSE 109 | 110 | //----------------------------------------------------------------------------// 111 | 112 | #endif // Include guard 113 | -------------------------------------------------------------------------------- /export/StdMathLib.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | #ifndef _INCLUDED_Field3D_StdMathLib_H_ 39 | #define _INCLUDED_Field3D_StdMathLib_H_ 40 | 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | #include 51 | #include 52 | 53 | //----------------------------------------------------------------------------// 54 | 55 | #include "ns.h" 56 | 57 | FIELD3D_NAMESPACE_OPEN 58 | 59 | //----------------------------------------------------------------------------// 60 | 61 | typedef ::half half; 62 | typedef Imath::V2i V2i; 63 | typedef Imath::V2d V2d; 64 | typedef Imath::C3f C3f; 65 | typedef Imath::V3i V3i; 66 | typedef Imath::Vec3 V3h; 67 | typedef Imath::V3f V3f; 68 | typedef Imath::V3d V3d; 69 | typedef Imath::Box3i Box3i; 70 | typedef Imath::Box3d Box3d; 71 | typedef Imath::Line3d Ray3d; 72 | typedef Imath::M44d M44d; 73 | typedef Imath::Plane3d Plane3d; 74 | 75 | #define FIELD3D_BOX_T Imath::Box 76 | #define FIELD3D_MTX_T Imath::Matrix44 77 | #define FIELD3D_VEC3_T Imath::Vec3 78 | 79 | #define FIELD3D_CLIP Imath::clip 80 | #define FIELD3D_LERP Imath::lerp 81 | #define FIELD3D_LERPFACTOR Imath::lerpfactor 82 | #define FIELD3D_EXTRACT_SHRT Imath::extractSHRT 83 | 84 | #define FIELD3D_RAND48 Imath::Rand48 85 | 86 | //----------------------------------------------------------------------------// 87 | 88 | FIELD3D_NAMESPACE_HEADER_CLOSE 89 | 90 | //----------------------------------------------------------------------------// 91 | 92 | #endif // Include guard 93 | -------------------------------------------------------------------------------- /export/Types.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file Types.h 39 | \brief Contains typedefs for the commonly used types in Field3D. 40 | \ingroup field 41 | */ 42 | 43 | //----------------------------------------------------------------------------// 44 | 45 | #ifndef _INCLUDED_Field3D_Types_H_ 46 | #define _INCLUDED_Field3D_Types_H_ 47 | 48 | //----------------------------------------------------------------------------// 49 | 50 | #include 51 | #include 52 | 53 | #ifdef FIELD3D_CUSTOM_MATH_LIB 54 | # include FIELD3D_MATH_LIB_INCLUDE 55 | #else 56 | # include "StdMathLib.h" 57 | #endif 58 | 59 | //----------------------------------------------------------------------------// 60 | // Interval 61 | //----------------------------------------------------------------------------// 62 | 63 | //! Represents a single integration interval. 64 | //! The interval is assumed to be inclusive, i.e. [t0,t1]. 65 | struct Interval 66 | { 67 | // Constructor --------------------------------------------------------------- 68 | 69 | //! Default constructor 70 | Interval(double start, double end, double step) 71 | : t0(start), t1(end), stepLength(step) 72 | { } 73 | 74 | // Public data members ------------------------------------------------------- 75 | 76 | //! The start of the interval (inclusive) 77 | double t0; 78 | //! The end of the interval (inclusive) 79 | double t1; 80 | //! The world space step length that is reasonable to use for the given 81 | //! interval. 82 | double stepLength; 83 | }; 84 | 85 | //----------------------------------------------------------------------------// 86 | 87 | typedef std::vector IntervalVec; 88 | 89 | //----------------------------------------------------------------------------// 90 | // Utilities 91 | //----------------------------------------------------------------------------// 92 | 93 | template 94 | To_T clampForType(const From_T v) 95 | { 96 | // Different behavior for integer vs fp types 97 | To_T lowestTo; 98 | From_T lowest; 99 | if (std::numeric_limits::is_integer) { 100 | lowestTo = std::numeric_limits::min(); 101 | lowest = static_cast(lowestTo); 102 | } else { 103 | lowestTo = -std::numeric_limits::max(); 104 | lowest = static_cast(lowestTo); 105 | } 106 | const To_T highestTo = std::numeric_limits::max(); 107 | const From_T highest = static_cast(highestTo); 108 | // Perform check 109 | if (v < lowest) { 110 | return lowest; 111 | } else if (v > highest) { 112 | return highest; 113 | } 114 | return v; 115 | } 116 | 117 | //----------------------------------------------------------------------------// 118 | 119 | #endif // Include guard 120 | 121 | -------------------------------------------------------------------------------- /export/ns.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | #define FIELD3D_MAJOR_VER 1 39 | #define FIELD3D_MINOR_VER 7 40 | #define FIELD3D_MICRO_VER 3 41 | 42 | #define FIELD3D_VERSION_NS v1_7 43 | 44 | #ifdef FIELD3D_EXTRA_NAMESPACE 45 | 46 | # define FIELD3D_NAMESPACE_OPEN \ 47 | namespace FIELD3D_EXTRA_NAMESPACE { \ 48 | namespace Field3D { namespace FIELD3D_VERSION_NS { 49 | # define FIELD3D_NAMESPACE_HEADER_CLOSE \ 50 | } using namespace FIELD3D_VERSION_NS; } } 51 | # define FIELD3D_NAMESPACE_SOURCE_CLOSE \ 52 | } } } 53 | 54 | #else 55 | 56 | # define FIELD3D_NAMESPACE_OPEN \ 57 | namespace Field3D { namespace FIELD3D_VERSION_NS { 58 | # define FIELD3D_NAMESPACE_HEADER_CLOSE \ 59 | } using namespace FIELD3D_VERSION_NS; } 60 | # define FIELD3D_NAMESPACE_SOURCE_CLOSE \ 61 | } } 62 | 63 | #endif 64 | 65 | #ifdef WIN32 66 | 67 | # ifdef FIELD3D_STATIC 68 | # define FIELD3D_API 69 | # else 70 | # ifdef FIELD3D_EXPORT 71 | # define FIELD3D_API __declspec(dllexport) 72 | # else 73 | # define FIELD3D_API __declspec(dllimport) 74 | # endif 75 | # endif 76 | #else 77 | # define FIELD3D_API 78 | #endif 79 | 80 | #ifdef __APPLE__ 81 | #include 82 | #endif 83 | 84 | //----------------------------------------------------------------------------// 85 | -------------------------------------------------------------------------------- /include/All.h: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Sony Pictures Imageworks, nor 19 | // Industrial Light & Magic, nor the names of their contributors may be used 20 | // to endorse or promote products derived from this software without specific 21 | // prior written permission. 22 | // 23 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 26 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 27 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 28 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 29 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 30 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 31 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 32 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 33 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 34 | // 35 | //-***************************************************************************** 36 | 37 | #ifndef _Alembic_Ogawa_All_h_ 38 | #define _Alembic_Ogawa_All_h_ 39 | 40 | #include "Foundation.h" 41 | #include "IArchive.h" 42 | #include "IData.h" 43 | #include "IGroup.h" 44 | #include "IStreams.h" 45 | #include "OArchive.h" 46 | #include "OData.h" 47 | #include "OGroup.h" 48 | #include "OStream.h" 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /include/Foundation.h: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Industrial Light & Magic nor the names of 19 | // its contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | //-***************************************************************************** 35 | 36 | #ifndef _Alembic_Ogawa_Foundation_h_ 37 | #define _Alembic_Ogawa_Foundation_h_ 38 | 39 | #include "UtilFoundation.h" 40 | #include "UtilPlainOldDataType.h" 41 | 42 | namespace Alembic { 43 | namespace Ogawa { 44 | namespace ALEMBIC_VERSION_NS { 45 | 46 | // a few useful constant values 47 | const Alembic::Util::uint64_t INVALID_GROUP = 0x7fffffffffffffffULL; 48 | const Alembic::Util::uint64_t EMPTY_GROUP = 0x0000000000000000ULL; 49 | const Alembic::Util::uint64_t INVALID_DATA = 0xffffffffffffffffULL; 50 | const Alembic::Util::uint64_t EMPTY_DATA = 0x8000000000000000ULL; 51 | 52 | } // End namespace ALEMBIC_VERSION_NS 53 | 54 | using namespace ALEMBIC_VERSION_NS; 55 | 56 | } // End namespace Ogawa 57 | 58 | } // End namespace Alembic 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /include/IArchive.h: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Industrial Light & Magic nor the names of 19 | // its contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | //-***************************************************************************** 35 | 36 | #ifndef _Alembic_Ogawa_IArchive_h_ 37 | #define _Alembic_Ogawa_IArchive_h_ 38 | 39 | #include "Foundation.h" 40 | #include "IStreams.h" 41 | #include "IGroup.h" 42 | 43 | #include 44 | 45 | namespace Alembic { 46 | namespace Ogawa { 47 | namespace ALEMBIC_VERSION_NS { 48 | 49 | class IArchive 50 | { 51 | public: 52 | IArchive(const std::string & iFileName, std::size_t iNumStreams=1); 53 | IArchive(const std::vector< std::istream * > & iStreams); 54 | ~IArchive(); 55 | 56 | bool isValid() const; 57 | 58 | bool isFrozen() const; 59 | 60 | Alembic::Util::uint16_t getVersion() const; 61 | 62 | IGroupPtr getGroup() const; 63 | 64 | private: 65 | void init(); 66 | IStreamsPtr mStreams; 67 | IGroupPtr mGroup; 68 | }; 69 | 70 | typedef Alembic::Util::shared_ptr< IArchive > IArchivePtr; 71 | 72 | } // End namespace ALEMBIC_VERSION_NS 73 | 74 | using namespace ALEMBIC_VERSION_NS; 75 | 76 | } // End namespace Ogawa 77 | 78 | } // End namespace Alembic 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /include/IData.h: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Industrial Light & Magic nor the names of 19 | // its contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | //-***************************************************************************** 35 | 36 | #ifndef _Alembic_Ogawa_IData_h_ 37 | #define _Alembic_Ogawa_IData_h_ 38 | 39 | #include "Foundation.h" 40 | #include "IStreams.h" 41 | 42 | namespace Alembic { 43 | namespace Ogawa { 44 | namespace ALEMBIC_VERSION_NS { 45 | 46 | class IData 47 | { 48 | public: 49 | 50 | ~IData(); 51 | 52 | void read(Alembic::Util::uint64_t iSize, void * iData, 53 | Alembic::Util::uint64_t iOffset, std::size_t iThreadId); 54 | 55 | Alembic::Util::uint64_t getSize() const; 56 | 57 | // not really necessary for most workflows, it could be used by some 58 | // Ogawa utilities to detect when this IData is shared 59 | Alembic::Util::uint64_t getPos() const; 60 | 61 | private: 62 | friend class IGroup; 63 | IData(IStreamsPtr iStreams, Alembic::Util::uint64_t iPos, 64 | std::size_t iThreadId); 65 | 66 | class PrivateData; 67 | std::auto_ptr< PrivateData > mData; 68 | }; 69 | 70 | typedef Alembic::Util::shared_ptr< IData > IDataPtr; 71 | 72 | } // End namespace ALEMBIC_VERSION_NS 73 | 74 | using namespace ALEMBIC_VERSION_NS; 75 | 76 | } // End namespace Ogawa 77 | 78 | } // End namespace Alembic 79 | 80 | #endif 81 | -------------------------------------------------------------------------------- /include/IGroup.h: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Industrial Light & Magic nor the names of 19 | // its contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | //-***************************************************************************** 35 | 36 | #ifndef _Alembic_Ogawa_IGroup_h_ 37 | #define _Alembic_Ogawa_IGroup_h_ 38 | 39 | #include "Foundation.h" 40 | #include "IStreams.h" 41 | #include "IData.h" 42 | 43 | namespace Alembic { 44 | namespace Ogawa { 45 | namespace ALEMBIC_VERSION_NS { 46 | 47 | class IGroup; 48 | typedef Alembic::Util::shared_ptr< IGroup > IGroupPtr; 49 | 50 | class IGroup 51 | { 52 | public: 53 | ~IGroup(); 54 | 55 | IGroupPtr getGroup(Alembic::Util::uint64_t iIndex, bool iLight, 56 | std::size_t iThreadIndex); 57 | 58 | IDataPtr getData(Alembic::Util::uint64_t iIndex, std::size_t iThreadIndex); 59 | 60 | Alembic::Util::uint64_t getNumChildren() const; 61 | 62 | bool isChildGroup(Alembic::Util::uint64_t iIndex) const; 63 | bool isChildData(Alembic::Util::uint64_t iIndex) const; 64 | 65 | bool isEmptyChildGroup(Alembic::Util::uint64_t iIndex) const; 66 | bool isEmptyChildData(Alembic::Util::uint64_t iIndex) const; 67 | 68 | bool isLight() const; 69 | 70 | private: 71 | friend class IArchive; 72 | IGroup(IStreamsPtr iStreams, Alembic::Util::uint64_t iPos, bool iLight, 73 | std::size_t iThreadIndex); 74 | 75 | class PrivateData; 76 | Alembic::Util::auto_ptr< PrivateData > mData; 77 | }; 78 | 79 | } // End namespace ALEMBIC_VERSION_NS 80 | 81 | using namespace ALEMBIC_VERSION_NS; 82 | 83 | } // End namespace Ogawa 84 | 85 | } // End namespace Alembic 86 | 87 | #endif 88 | -------------------------------------------------------------------------------- /include/IStreams.h: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Industrial Light & Magic nor the names of 19 | // its contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | //-***************************************************************************** 35 | 36 | #ifndef _Alembic_Ogawa_IStreams_h_ 37 | #define _Alembic_Ogawa_IStreams_h_ 38 | 39 | #include "Foundation.h" 40 | 41 | #include 42 | 43 | namespace Alembic { 44 | namespace Ogawa { 45 | namespace ALEMBIC_VERSION_NS { 46 | 47 | class IStreams 48 | { 49 | public: 50 | IStreams(const std::string & iFileName, std::size_t iNumStreams=1); 51 | IStreams(const std::vector< std::istream * > & iStreams); 52 | ~IStreams(); 53 | 54 | bool isValid(); 55 | bool isFrozen(); 56 | Alembic::Util::uint16_t getVersion(); 57 | 58 | // locks on the threadId, seeks to iPos, and reads iSize bytes into oBuf 59 | void read(std::size_t iThreadId, Alembic::Util::uint64_t iPos, 60 | Alembic::Util::uint64_t iSize, void * oBuf); 61 | 62 | private: 63 | // noncopyable 64 | IStreams(const IStreams &); 65 | const IStreams & operator=(const IStreams &); 66 | 67 | void init(); 68 | 69 | class PrivateData; 70 | Alembic::Util::auto_ptr< PrivateData > mData; 71 | }; 72 | typedef Alembic::Util::shared_ptr< IStreams > IStreamsPtr; 73 | 74 | } // End namespace ALEMBIC_VERSION_NS 75 | 76 | using namespace ALEMBIC_VERSION_NS; 77 | 78 | } // End namespace Ogawa 79 | 80 | } // End namespace Alembic 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /include/OArchive.h: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Industrial Light & Magic nor the names of 19 | // its contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | //-***************************************************************************** 35 | 36 | #ifndef _Alembic_Ogawa_OArchive_h_ 37 | #define _Alembic_Ogawa_OArchive_h_ 38 | 39 | #include "Foundation.h" 40 | #include "OGroup.h" 41 | #include "OStream.h" 42 | 43 | namespace Alembic { 44 | namespace Ogawa { 45 | namespace ALEMBIC_VERSION_NS { 46 | 47 | class OArchive 48 | { 49 | public: 50 | OArchive(const std::string & iFileName); 51 | OArchive(std::ostream * iStream); 52 | ~OArchive(); 53 | 54 | OGroupPtr getGroup(); 55 | 56 | bool isValid(); 57 | 58 | private: 59 | OStreamPtr mStream; 60 | OGroupPtr mGroup; 61 | }; 62 | 63 | typedef Alembic::Util::shared_ptr< OArchive > OArchivePtr; 64 | 65 | } // End namespace ALEMBIC_VERSION_NS 66 | 67 | using namespace ALEMBIC_VERSION_NS; 68 | 69 | } // End namespace Ogawa 70 | 71 | } // End namespace Alembic 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /include/OData.h: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Industrial Light & Magic nor the names of 19 | // its contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | //-***************************************************************************** 35 | 36 | #ifndef _Alembic_Ogawa_OData_h_ 37 | #define _Alembic_Ogawa_OData_h_ 38 | 39 | #include "Foundation.h" 40 | #include "OStream.h" 41 | 42 | namespace Alembic { 43 | namespace Ogawa { 44 | namespace ALEMBIC_VERSION_NS { 45 | 46 | class OData 47 | { 48 | public: 49 | 50 | // creates a default empty group 51 | OData(); 52 | 53 | ~OData(); 54 | 55 | // rewrites over part of the already written data, does not change 56 | // the size of the already written data. If what is attempting 57 | // to be rewritten exceeds the boundaries of what is already written, 58 | // the existing data will be unchanged 59 | void rewrite(Alembic::Util::uint64_t iSize, void * iData, 60 | Alembic::Util::uint64_t iOffset=0); 61 | 62 | Alembic::Util::uint64_t getSize() const; 63 | 64 | private: 65 | friend class OGroup; // friend so we can call the constructor below 66 | OData(OStreamPtr iStream, Alembic::Util::uint64_t iPos, 67 | Alembic::Util::uint64_t iSize); 68 | 69 | Alembic::Util::uint64_t getPos() const; 70 | 71 | class PrivateData; 72 | Alembic::Util::auto_ptr< PrivateData > mData; 73 | }; 74 | 75 | typedef Alembic::Util::shared_ptr< OData > ODataPtr; 76 | 77 | } // End namespace ALEMBIC_VERSION_NS 78 | 79 | using namespace ALEMBIC_VERSION_NS; 80 | 81 | } // End namespace Ogawa 82 | 83 | } // End namespace Alembic 84 | 85 | #endif 86 | -------------------------------------------------------------------------------- /include/OGroup.h: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Industrial Light & Magic nor the names of 19 | // its contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | //-***************************************************************************** 35 | 36 | #ifndef _Alembic_Ogawa_OGroup_h_ 37 | #define _Alembic_Ogawa_OGroup_h_ 38 | 39 | #include "Foundation.h" 40 | #include "OStream.h" 41 | #include "OData.h" 42 | 43 | namespace Alembic { 44 | namespace Ogawa { 45 | namespace ALEMBIC_VERSION_NS { 46 | 47 | class OGroup; 48 | typedef Alembic::Util::shared_ptr< OGroup > OGroupPtr; 49 | 50 | class OGroup : public Alembic::Util::enable_shared_from_this< OGroup > 51 | { 52 | public: 53 | ~OGroup(); 54 | 55 | // create a group and add it as a child to this group 56 | OGroupPtr addGroup(); 57 | 58 | // write the data stream and add it as a child to this group 59 | ODataPtr addData(Alembic::Util::uint64_t iSize, const void * iData); 60 | 61 | // write data streams from multiple sources as one continuous data stream 62 | // and add it as a child to this group 63 | ODataPtr addData(Alembic::Util::uint64_t iNumData, 64 | const Alembic::Util::uint64_t * iSizes, 65 | const void ** iDatas); 66 | 67 | // write a data stream but DON'T add it as a child to this group 68 | // If ODataPtr isn't added to this or any other group, you will 69 | // end up abandoning it within the file and waste disk space. 70 | ODataPtr createData(Alembic::Util::uint64_t iSize, const void * iData); 71 | 72 | // write data streams as one continuous data stream but DON'T add it as a 73 | // child to this group. 74 | // If ODataPtr isn't added to this or any other group, you will 75 | // end up abandoning it within the file and waste disk space. 76 | ODataPtr createData(Alembic::Util::uint64_t iNumData, 77 | const Alembic::Util::uint64_t * iSizes, 78 | const void ** iDatas); 79 | 80 | // reference existing data 81 | void addData(ODataPtr iData); 82 | 83 | // reference an existing group 84 | void addGroup(OGroupPtr iGroup); 85 | 86 | // convenience function for adding a default NULL group 87 | void addEmptyGroup(); 88 | 89 | // convenience function for adding empty data 90 | void addEmptyData(); 91 | 92 | // can no longer add any more children, we can still update them 93 | // via the replace calls though 94 | void freeze(); 95 | 96 | bool isFrozen(); 97 | 98 | Alembic::Util::uint64_t getNumChildren() const; 99 | 100 | bool isChildGroup(Alembic::Util::uint64_t iIndex) const; 101 | 102 | bool isChildData(Alembic::Util::uint64_t iIndex) const; 103 | 104 | bool isChildEmptyGroup(Alembic::Util::uint64_t iIndex) const; 105 | 106 | bool isChildEmptyData(Alembic::Util::uint64_t iIndex) const; 107 | 108 | void replaceData(Alembic::Util::uint64_t iIndex, ODataPtr iData); 109 | 110 | // currently I'm going to leave this out, because a bad implementation 111 | // could cause all sorts of subtle race conditions when unfrozen children 112 | // are suddenly frozen. It may also not be necessary (you can still 113 | // reference an existing group) 114 | // if this is necessary, an easy compromise might be that iGroup HAS to 115 | // be frozen, much like how replaceData deals with something implicitly 116 | // frozen 117 | //void replaceGroup(Alembic::Util::uint64_t iIndex, OGroupPtr iGroup); 118 | 119 | private: 120 | friend class OArchive; 121 | OGroup(OStreamPtr iStream); 122 | 123 | OGroup(OGroupPtr iParent, Alembic::Util::uint64_t iIndex); 124 | 125 | class PrivateData; 126 | Alembic::Util::auto_ptr< PrivateData > mData; 127 | }; 128 | 129 | } // End namespace ALEMBIC_VERSION_NS 130 | 131 | using namespace ALEMBIC_VERSION_NS; 132 | 133 | } // End namespace Ogawa 134 | 135 | } // End namespace Alembic 136 | 137 | #endif 138 | -------------------------------------------------------------------------------- /include/OStream.h: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Industrial Light & Magic nor the names of 19 | // its contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | //-***************************************************************************** 35 | 36 | #ifndef _Alembic_Ogawa_OStream_h_ 37 | #define _Alembic_Ogawa_OStream_h_ 38 | 39 | #include "Foundation.h" 40 | 41 | #include 42 | 43 | namespace Alembic { 44 | namespace Ogawa { 45 | namespace ALEMBIC_VERSION_NS { 46 | 47 | class OStream 48 | { 49 | public: 50 | OStream(const std::string & iFileName); 51 | OStream(std::ostream * iStream); 52 | ~OStream(); 53 | 54 | bool isValid(); 55 | 56 | Alembic::Util::uint64_t getAndSeekEndPos(); 57 | void write(const void * iBuf, Alembic::Util::uint64_t iSize); 58 | void seek(Alembic::Util::uint64_t iPos); 59 | 60 | private: 61 | // noncopyable 62 | OStream(const OStream &); 63 | const OStream & operator=(const OStream &); 64 | 65 | class PrivateData; 66 | Alembic::Util::auto_ptr< PrivateData > mData; 67 | 68 | void init(); 69 | }; 70 | 71 | typedef Alembic::Util::shared_ptr< OStream > OStreamPtr; 72 | 73 | 74 | } // End namespace ALEMBIC_VERSION_NS 75 | 76 | using namespace ALEMBIC_VERSION_NS; 77 | 78 | } // End namespace Ogawa 79 | 80 | } // End namespace Alembic 81 | 82 | #endif 83 | -------------------------------------------------------------------------------- /include/OgIAttribute.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | #ifndef _INCLUDED_Field3D_OgIAttribute_H_ 4 | #define _INCLUDED_Field3D_OgIAttribute_H_ 5 | 6 | //----------------------------------------------------------------------------// 7 | // Includes 8 | //----------------------------------------------------------------------------// 9 | 10 | #include "OgUtil.h" 11 | 12 | #include 13 | 14 | //----------------------------------------------------------------------------// 15 | 16 | #include "ns.h" 17 | 18 | FIELD3D_NAMESPACE_OPEN 19 | 20 | //----------------------------------------------------------------------------// 21 | // OgIAttribute 22 | //----------------------------------------------------------------------------// 23 | 24 | /*! \class OgIAttribute 25 | Ogawa input attribute. Reads a single attribute from an F3D-style 26 | Ogawa file. 27 | 28 | Attributes should not be relied on for performance input of large data sets, 29 | use OgIDataset for that. 30 | */ 31 | 32 | //----------------------------------------------------------------------------// 33 | 34 | template 35 | class OgIAttribute : public OgIBase 36 | { 37 | 38 | public: 39 | 40 | // Typedefs ------------------------------------------------------------------ 41 | 42 | typedef T value_type; 43 | 44 | // Ctor, dtor ---------------------------------------------------------------- 45 | 46 | //! The default constructor leaves m_group initialized, which implies it 47 | //! is in an invalid state. 48 | OgIAttribute(); 49 | 50 | //! Initialize from an existing IGroup. The constructor will check that the 51 | //! type enum matches the template parameter, otherwise the attribute is 52 | //! marked invalid. 53 | OgIAttribute(Alembic::Ogawa::IGroupPtr group); 54 | 55 | // Main methods -------------------------------------------------------------- 56 | 57 | //! Returns the value of the attribute. This will be zero if the attribute 58 | //! is invalid. 59 | T value() const; 60 | 61 | }; 62 | 63 | //----------------------------------------------------------------------------// 64 | // Template implementations 65 | //----------------------------------------------------------------------------// 66 | 67 | template 68 | OgIAttribute::OgIAttribute() 69 | { 70 | // Empty 71 | } 72 | 73 | //----------------------------------------------------------------------------// 74 | 75 | template 76 | OgIAttribute::OgIAttribute(Alembic::Ogawa::IGroupPtr group) 77 | : OgIBase(group) 78 | { 79 | // Handle null pointer 80 | if (!OgIBase::m_group) { 81 | return; 82 | } 83 | // Check data type 84 | OgDataType dataType = readDataType(group, 2); 85 | if (dataType != OgawaTypeTraits::typeEnum()) { 86 | OgIBase::m_group.reset(); 87 | return; 88 | } 89 | // Update name 90 | getGroupName(OgIBase::m_group, OgIBase::m_name); 91 | } 92 | 93 | //----------------------------------------------------------------------------// 94 | 95 | template 96 | T OgIAttribute::value() const 97 | { 98 | T v; 99 | if (readData(m_group, 3, v)) { 100 | return v; 101 | } 102 | return OgawaTypeTraits::defaultValue(); 103 | } 104 | 105 | //----------------------------------------------------------------------------// 106 | 107 | FIELD3D_NAMESPACE_HEADER_CLOSE 108 | 109 | //----------------------------------------------------------------------------// 110 | 111 | #endif // include guard 112 | 113 | //----------------------------------------------------------------------------// 114 | -------------------------------------------------------------------------------- /include/OgIGroup.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | #ifndef _INCLUDED_Field3D_OgIGroup_H_ 4 | #define _INCLUDED_Field3D_OgIGroup_H_ 5 | 6 | //----------------------------------------------------------------------------// 7 | // Includes 8 | //----------------------------------------------------------------------------// 9 | 10 | #include "OgUtil.h" 11 | #include "OgIAttribute.h" 12 | #include "OgIDataset.h" 13 | 14 | //----------------------------------------------------------------------------// 15 | 16 | #include "ns.h" 17 | 18 | FIELD3D_NAMESPACE_OPEN 19 | 20 | //----------------------------------------------------------------------------// 21 | // OgIGroup 22 | //----------------------------------------------------------------------------// 23 | 24 | /*! \class OgIGroup 25 | Ogawa input group. Opens a group in an F3D-style Ogawa file. 26 | 27 | Groups can contain other groups, as well as attributes and data sets. 28 | */ 29 | 30 | //----------------------------------------------------------------------------// 31 | 32 | class OgIGroup : public OgIBase 33 | { 34 | 35 | public: 36 | 37 | // Ctor, dtor ---------------------------------------------------------------- 38 | 39 | //! Construct from archive 40 | OgIGroup(Alembic::Ogawa::IArchive &archive); 41 | 42 | // Main methods -------------------------------------------------------------- 43 | 44 | //! Returns the type 45 | OgGroupType type() const; 46 | 47 | //! Returns a list of F3D group names (always unique) 48 | std::vector groupNames() const; 49 | 50 | //! Returns a list of F3D attribute names (always unique) 51 | std::vector attributeNames() const; 52 | 53 | //! Returns a list of F3D dataset names (always unique) 54 | std::vector datasetNames() const; 55 | 56 | //! Returns a list of compressed F3D dataset names (always unique) 57 | std::vector compressedDatasetNames() const; 58 | 59 | //! Finds an F3D group. The returned OgIGroup will not be valid if the name 60 | //! wasn't found. The name may be a full path including '/'-separators, 61 | //! in which case the nested group will be searched for. 62 | OgIGroup findGroup(const std::string &path) const; 63 | 64 | //! Finds an F3D group. The returned OgIAttribute will not be valid if the 65 | //! name wasn't found. 66 | template 67 | OgIAttribute findAttribute(const std::string &name) const; 68 | 69 | //! Finds an F3D dataset. The returned OgIGroup will not be valid if the name 70 | //! wasn't found. 71 | template 72 | OgIDataset findDataset(const std::string &name) const; 73 | 74 | //! Finds a compressed F3D dataset. The returned OgIGroup will not be valid 75 | //! if the name wasn't found. 76 | template 77 | OgICDataset findCompressedDataset(const std::string &name) const; 78 | 79 | //! Returns the data type of an attribute 80 | OgDataType attributeType(const std::string &name) const; 81 | 82 | //! Returns the data type of a dataset 83 | OgDataType datasetType(const std::string &name) const; 84 | 85 | //! Returns the data type of a compressed dataset 86 | OgDataType compressedDatasetType(const std::string &name) const; 87 | 88 | private: 89 | 90 | // Private ctors ------------------------------------------------------------- 91 | 92 | //! Construct invalid group 93 | OgIGroup(); 94 | 95 | //! Construct by opening group 96 | OgIGroup(Alembic::Ogawa::IGroupPtr group); 97 | 98 | // Utility methods ----------------------------------------------------------- 99 | 100 | //! Finds an ogawa-level group 101 | Alembic::Ogawa::IGroupPtr findGroup(const std::string &name, 102 | const OgGroupType groupType) const; 103 | 104 | //! Recursively finds an ogawa-level group 105 | Alembic::Ogawa::IGroupPtr recursiveFindGroup 106 | (const std::string &name, const OgGroupType groupType) const; 107 | 108 | //! Retrieves list of ogawa-level groups of the given type 109 | std::vector groupNames(const OgGroupType groupType) const; 110 | 111 | //! Validates the current group 112 | void validate(); 113 | 114 | }; 115 | 116 | //----------------------------------------------------------------------------// 117 | // Template implementations 118 | //----------------------------------------------------------------------------// 119 | 120 | template 121 | OgIAttribute OgIGroup::findAttribute(const std::string &name) const 122 | { 123 | Alembic::Ogawa::IGroupPtr group = findGroup(name, F3DAttributeType); 124 | 125 | if (group) { 126 | return OgIAttribute(group); 127 | } 128 | 129 | return OgIAttribute(); 130 | } 131 | 132 | //----------------------------------------------------------------------------// 133 | 134 | template 135 | OgIDataset OgIGroup::findDataset(const std::string &name) const 136 | { 137 | Alembic::Ogawa::IGroupPtr group = findGroup(name, F3DDatasetType); 138 | 139 | if (group) { 140 | return OgIDataset(group); 141 | } 142 | 143 | return OgIDataset(); 144 | } 145 | 146 | //----------------------------------------------------------------------------// 147 | 148 | template 149 | OgICDataset OgIGroup::findCompressedDataset(const std::string &name) const 150 | { 151 | Alembic::Ogawa::IGroupPtr group = findGroup(name, F3DCompressedDatasetType); 152 | 153 | if (group) { 154 | return OgICDataset(group); 155 | } 156 | 157 | return OgICDataset(); 158 | } 159 | 160 | //----------------------------------------------------------------------------// 161 | 162 | FIELD3D_NAMESPACE_HEADER_CLOSE 163 | 164 | //----------------------------------------------------------------------------// 165 | 166 | #endif // include guard 167 | 168 | //----------------------------------------------------------------------------// 169 | -------------------------------------------------------------------------------- /include/OgIO.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | #ifndef _INCLUDED_Field3D_OgIO_H_ 4 | #define _INCLUDED_Field3D_OgIO_H_ 5 | 6 | //----------------------------------------------------------------------------// 7 | // Includes 8 | //----------------------------------------------------------------------------// 9 | 10 | #include "OgIAttribute.h" 11 | #include "OgIDataset.h" 12 | #include "OgIGroup.h" 13 | #include "OgOAttribute.h" 14 | #include "OgODataset.h" 15 | #include "OgOGroup.h" 16 | 17 | //----------------------------------------------------------------------------// 18 | 19 | #endif // include guard 20 | 21 | //----------------------------------------------------------------------------// 22 | -------------------------------------------------------------------------------- /include/OgOAttribute.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | #ifndef _INCLUDED_Field3D_OgOAttribute_H_ 4 | #define _INCLUDED_Field3D_OgOAttribute_H_ 5 | 6 | //----------------------------------------------------------------------------// 7 | // Includes 8 | //----------------------------------------------------------------------------// 9 | 10 | #include "OgUtil.h" 11 | #include "OgOGroup.h" 12 | 13 | //----------------------------------------------------------------------------// 14 | 15 | #include "ns.h" 16 | 17 | FIELD3D_NAMESPACE_OPEN 18 | 19 | //----------------------------------------------------------------------------// 20 | // OgOAttribute 21 | //----------------------------------------------------------------------------// 22 | 23 | /*! \class OgOAttribute 24 | Ogawa output attribute. Writes a variable as an attribute into an F3D-style 25 | Ogawa file. 26 | */ 27 | 28 | //----------------------------------------------------------------------------// 29 | 30 | template 31 | class OgOAttribute 32 | { 33 | 34 | public: 35 | 36 | // Typedefs ------------------------------------------------------------------ 37 | 38 | typedef T value_type; 39 | 40 | // Ctors, dtor --------------------------------------------------------------- 41 | 42 | //! Creates the attribute and writes the data. 43 | OgOAttribute(OgOGroup &parent, const std::string &name, const T &value) 44 | { 45 | using Field3D::Exc::OgOAttributeException; 46 | 47 | // Create a group to store the attribute data 48 | Alembic::Ogawa::OGroupPtr group = parent.addSubGroup(); 49 | // Index 0 is the name 50 | if (!writeString(group, name)) { 51 | throw OgOAttributeException("Couldn't write attribute name for " + name); 52 | } 53 | // Index 1 is the type 54 | if (!writeData(group, F3DAttributeType)) { 55 | throw OgOAttributeException("Couldn't write attribute group type for " + 56 | name); 57 | } 58 | // Index 2 is the data type 59 | if (!writeDataType(group)) { 60 | throw OgOAttributeException("Couldn't write attribute data type for " + 61 | name); 62 | } 63 | // Index 3 is the data 64 | if (!writeData(group, value)) { 65 | throw OgOAttributeException("Couldn't write attribute data for " + name); 66 | } 67 | } 68 | }; 69 | 70 | //----------------------------------------------------------------------------// 71 | 72 | FIELD3D_NAMESPACE_HEADER_CLOSE 73 | 74 | //----------------------------------------------------------------------------// 75 | 76 | #endif // include guard 77 | 78 | //----------------------------------------------------------------------------// 79 | -------------------------------------------------------------------------------- /include/OgODataset.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | #ifndef _INCLUDED_Field3D_OgODataset_H_ 4 | #define _INCLUDED_Field3D_OgODataset_H_ 5 | 6 | //----------------------------------------------------------------------------// 7 | // Includes 8 | //----------------------------------------------------------------------------// 9 | 10 | #include "OgUtil.h" 11 | 12 | //----------------------------------------------------------------------------// 13 | 14 | #include "ns.h" 15 | 16 | FIELD3D_NAMESPACE_OPEN 17 | 18 | //----------------------------------------------------------------------------// 19 | // OgODataset 20 | //----------------------------------------------------------------------------// 21 | 22 | /*! \class OgOAttribute 23 | Ogawa output attribute. Writes a variable as an attribute into an F3D-style 24 | Ogawa file. 25 | */ 26 | 27 | //----------------------------------------------------------------------------// 28 | 29 | template 30 | class OgODataset 31 | { 32 | 33 | public: 34 | 35 | // Typedefs ------------------------------------------------------------------ 36 | 37 | typedef T value_type; 38 | 39 | // Ctors, dtor --------------------------------------------------------------- 40 | 41 | //! Creates the data set, but does not write any data. 42 | OgODataset(OgOGroup &parent, const std::string &name); 43 | 44 | // Main methods -------------------------------------------------------------- 45 | 46 | //! Adds a data element to the data set. Each element may be of different 47 | //! length 48 | void addData(const size_t length, const T *data); 49 | 50 | private: 51 | 52 | //! Pointer to the enclosing group 53 | Alembic::Ogawa::OGroupPtr m_group; 54 | 55 | }; 56 | 57 | //----------------------------------------------------------------------------// 58 | // OgOCDataset 59 | //----------------------------------------------------------------------------// 60 | 61 | /*! \class OgOCDataset 62 | Ogawa output compressed dataset. 63 | \note This class is templated to preserve data type, but calls to add 64 | actual data elements to the data sets deal with uint8_t, since compressed 65 | data lengths are not necessarily an even multiplier of sizeof(T) 66 | */ 67 | 68 | //----------------------------------------------------------------------------// 69 | 70 | template 71 | class OgOCDataset 72 | { 73 | 74 | public: 75 | 76 | // Typedefs ------------------------------------------------------------------ 77 | 78 | typedef T value_type; 79 | 80 | // Ctors, dtor --------------------------------------------------------------- 81 | 82 | //! Creates the data set, but does not write any data. 83 | OgOCDataset(OgOGroup &parent, const std::string &name); 84 | 85 | // Main methods -------------------------------------------------------------- 86 | 87 | //! Adds a data element to the data set. Each element may be of different 88 | //! length 89 | //! \note The length is measured in bytes (sizeof(uint8_t)) 90 | void addData(const size_t byteLength, const uint8_t *data); 91 | 92 | private: 93 | 94 | //! Pointer to the enclosing group 95 | Alembic::Ogawa::OGroupPtr m_group; 96 | 97 | }; 98 | 99 | //----------------------------------------------------------------------------// 100 | // Template instantiations 101 | //----------------------------------------------------------------------------// 102 | 103 | template 104 | OgODataset::OgODataset(OgOGroup &parent, const std::string &name) 105 | { 106 | // Create a group to store the basic data 107 | m_group = parent.addSubGroup(); 108 | // Index 0 is the name 109 | writeString(m_group, name); 110 | // Index 1 is the type 111 | writeData(m_group, F3DDatasetType); 112 | // Index 2 is the data type 113 | writeDataType(m_group); 114 | // Index 3 onwards are the actual dataset entries 115 | } 116 | 117 | //----------------------------------------------------------------------------// 118 | 119 | template 120 | void OgODataset::addData(const size_t length, const T *data) 121 | { 122 | m_group->addData(length * sizeof(T), data); 123 | } 124 | 125 | //----------------------------------------------------------------------------// 126 | 127 | template 128 | OgOCDataset::OgOCDataset(OgOGroup &parent, const std::string &name) 129 | { 130 | // Create a group to store the basic data 131 | m_group = parent.addSubGroup(); 132 | // Index 0 is the name 133 | writeString(m_group, name); 134 | // Index 1 is the type 135 | writeData(m_group, F3DCompressedDatasetType); 136 | // Index 2 is the data type 137 | writeDataType(m_group); 138 | // Index 3 onwards are the actual dataset entries 139 | } 140 | 141 | //----------------------------------------------------------------------------// 142 | 143 | template 144 | void OgOCDataset::addData(const size_t byteLength, const uint8_t *data) 145 | { 146 | m_group->addData(byteLength * sizeof(uint8_t), data); 147 | } 148 | 149 | //----------------------------------------------------------------------------// 150 | 151 | FIELD3D_NAMESPACE_HEADER_CLOSE 152 | 153 | //----------------------------------------------------------------------------// 154 | 155 | #endif // include guard 156 | 157 | //----------------------------------------------------------------------------// 158 | -------------------------------------------------------------------------------- /include/OgOGroup.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | #ifndef _INCLUDED_Field3D_OgOGroup_H_ 4 | #define _INCLUDED_Field3D_OgOGroup_H_ 5 | 6 | //----------------------------------------------------------------------------// 7 | // Includes 8 | //----------------------------------------------------------------------------// 9 | 10 | #include "OgUtil.h" 11 | #include "Exception.h" 12 | 13 | //----------------------------------------------------------------------------// 14 | 15 | #include "ns.h" 16 | 17 | FIELD3D_NAMESPACE_OPEN 18 | 19 | //----------------------------------------------------------------------------// 20 | // OgOGroup 21 | //----------------------------------------------------------------------------// 22 | 23 | /*! \class OgOAttribute 24 | Ogawa output attribute. Writes a variable as an attribute into an F3D-style 25 | Ogawa file. 26 | */ 27 | 28 | //----------------------------------------------------------------------------// 29 | 30 | class OgOGroup : public Alembic::Util::noncopyable 31 | { 32 | 33 | public: 34 | 35 | // Ctor, dtor ---------------------------------------------------------------- 36 | 37 | //! Constructs the root group in an Ogawa archive 38 | OgOGroup(Alembic::Ogawa::OArchive &archive) 39 | : m_name("f3droot") 40 | { 41 | // Reference the root group 42 | m_group = archive.getGroup(); 43 | // Base data sets 44 | addBaseData(); 45 | } 46 | 47 | //! Constructs a group as a child to an existing group. 48 | OgOGroup(OgOGroup &parent, const std::string &name) 49 | : m_name(name) 50 | { 51 | // Make sure there is no '/' in the name 52 | if (name.find("/") != std::string::npos) { 53 | throw Field3D::Exc::OgOGroupException("'/' character in group name."); 54 | } 55 | // Construct the group 56 | m_group = parent.m_group->addGroup(); 57 | // Base data sets 58 | addBaseData(); 59 | } 60 | 61 | // Main methods -------------------------------------------------------------- 62 | 63 | //! Adds an ogawa-level subgroup. Called from OgOAttribute and OgODataset. 64 | Alembic::Ogawa::OGroupPtr addSubGroup() 65 | { 66 | return m_group->addGroup(); 67 | } 68 | 69 | private: 70 | 71 | // Utility methods ----------------------------------------------------------- 72 | 73 | void addBaseData() 74 | { 75 | // Index 0 is the name 76 | if (!writeString(m_group, m_name)) { 77 | throw Field3D::Exc::OgOGroupException("Failed to write group name."); 78 | } 79 | // Index 1 is the type 80 | if (!writeData(m_group, F3DGroupType)) { 81 | throw Field3D::Exc::OgOGroupException("Failed to write group type."); 82 | } 83 | } 84 | 85 | // Data members -------------------------------------------------------------- 86 | 87 | //! Pointer to the enclosing Ogawa-level group. 88 | Alembic::Ogawa::OGroupPtr m_group; 89 | //! Name of the curren 90 | std::string m_name; 91 | }; 92 | 93 | //----------------------------------------------------------------------------// 94 | 95 | FIELD3D_NAMESPACE_HEADER_CLOSE 96 | 97 | //----------------------------------------------------------------------------// 98 | 99 | #endif // include guard 100 | 101 | //----------------------------------------------------------------------------// 102 | -------------------------------------------------------------------------------- /include/OgawaUtil.h: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | // Includes 3 | //----------------------------------------------------------------------------// 4 | 5 | #include 6 | #include 7 | 8 | #include "All.h" 9 | #include "UtilFoundation.h" 10 | #include "UtilPlainOldDataType.h" 11 | 12 | #include "OgIAttribute.h" 13 | #include "OgOAttribute.h" 14 | #include "OgIDataset.h" 15 | #include "OgODataset.h" 16 | #include "OgIGroup.h" 17 | #include "OgOGroup.h" 18 | 19 | //----------------------------------------------------------------------------// 20 | // To Do 21 | //----------------------------------------------------------------------------// 22 | 23 | /* 24 | x Only explicitly allow certain data types. 25 | x All hell will break loose if we don't stick to int64_t, etc. 26 | 27 | 28 | 29 | */ 30 | 31 | //----------------------------------------------------------------------------// 32 | 33 | -------------------------------------------------------------------------------- /man/f3dinfo.1: -------------------------------------------------------------------------------- 1 | .TH F3DINFO "1" "12 Nov 2011" "User Commands" "Field3D Info" 2 | .SH NAME 3 | f3dinfo \- Field3D Info 4 | .SH SYNOPSIS 5 | f3dinfo 6 | .SH DESCRIPTION 7 | Displays information about one or more Field3D (.f3d) file. 8 | .SH OPTIONS 9 | .HP 10 | \fB\--help\fR Display help 11 | .HP 12 | \fB\--input-file arg\fR Input files 13 | .HP 14 | \fB\-n [ --name ] arg\fR Load field(s) by name 15 | .HP 16 | \fB\-a [ --attribute ] arg\fR Load field(s) by attribute 17 | .SH BUGS 18 | No known bugs for this program. 19 | .SH AUTHOR 20 | Magnus Wrenninge, et al. (magnus.wrenninge@gmail.com) 21 | -------------------------------------------------------------------------------- /ogawaToF3D.sh: -------------------------------------------------------------------------------- 1 | sed -i 's//\"Util\1\"/g' include/*.h 2 | sed -i 's//\"\1\"/g' include/*.h 3 | sed -i 's//\"\1\"/g' src/*.cpp 4 | -------------------------------------------------------------------------------- /src/Field.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file Field.cpp 39 | Contains some template specializations for FieldTraits. 40 | */ 41 | 42 | //----------------------------------------------------------------------------// 43 | 44 | #include "Field.h" 45 | 46 | //----------------------------------------------------------------------------// 47 | 48 | FIELD3D_NAMESPACE_OPEN 49 | 50 | //----------------------------------------------------------------------------// 51 | // FieldBase 52 | //----------------------------------------------------------------------------// 53 | 54 | FieldBase::FieldBase() 55 | : RefBase(), 56 | m_metadata(this) 57 | { 58 | // Empty 59 | } 60 | 61 | FieldBase::FieldBase(const FieldBase &other) 62 | : RefBase(), 63 | name(other.name), 64 | attribute(other.attribute), 65 | m_metadata(this) 66 | { 67 | m_metadata = other.m_metadata; 68 | } 69 | 70 | 71 | //----------------------------------------------------------------------------// 72 | 73 | FieldBase::~FieldBase() 74 | { 75 | // Empty 76 | } 77 | 78 | //----------------------------------------------------------------------------// 79 | 80 | FIELD3D_NAMESPACE_SOURCE_CLOSE 81 | 82 | //----------------------------------------------------------------------------// 83 | -------------------------------------------------------------------------------- /src/FieldCache.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2015 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file FieldCache.cpp 39 | Contains implementation of FieldCache class. 40 | */ 41 | 42 | //----------------------------------------------------------------------------// 43 | 44 | #include "FieldCache.h" 45 | 46 | #include "Traits.h" 47 | 48 | //----------------------------------------------------------------------------// 49 | 50 | FIELD3D_NAMESPACE_OPEN 51 | 52 | //----------------------------------------------------------------------------// 53 | // FieldCache static member instantiation 54 | //----------------------------------------------------------------------------// 55 | 56 | template 57 | boost::mutex FieldCache::ms_creationMutex; 58 | template 59 | boost::mutex FieldCache::ms_accessMutex; 60 | template 61 | boost::scoped_ptr > FieldCache::ms_singleton; 62 | 63 | template class FieldCache; 64 | template class FieldCache; 65 | template class FieldCache; 66 | template class FieldCache; 67 | template class FieldCache; 68 | template class FieldCache; 69 | 70 | //----------------------------------------------------------------------------// 71 | 72 | FIELD3D_NAMESPACE_SOURCE_CLOSE 73 | 74 | //----------------------------------------------------------------------------// 75 | 76 | -------------------------------------------------------------------------------- /src/FieldInterp.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file FieldInterp.cpp 39 | Contains implementations of interpolation-related functions. 40 | */ 41 | 42 | //----------------------------------------------------------------------------// 43 | 44 | #include "FieldInterp.h" 45 | 46 | //----------------------------------------------------------------------------// 47 | 48 | FIELD3D_NAMESPACE_OPEN 49 | 50 | //----------------------------------------------------------------------------// 51 | 52 | bool isPointInField(const FieldRes::Ptr f, const V3d &wsP) 53 | { 54 | V3d lsP; 55 | f->mapping()->worldToLocal(wsP, lsP); 56 | return (lsP.x > 0.0 && lsP.x <= 1.0 && 57 | lsP.y > 0.0 && lsP.y <= 1.0 && 58 | lsP.z > 0.0 && lsP.z <= 1.0); 59 | } 60 | 61 | //----------------------------------------------------------------------------// 62 | 63 | bool isLegalVoxelCoord(const V3d &vsP, const Box3d &vsDataWindow) 64 | { 65 | return vsP.x > (vsDataWindow.min.x) && 66 | vsP.x < (vsDataWindow.max.x) && 67 | vsP.y > (vsDataWindow.min.y) && 68 | vsP.y < (vsDataWindow.max.y) && 69 | vsP.z > (vsDataWindow.min.z) && 70 | vsP.z < (vsDataWindow.max.z); 71 | } 72 | 73 | //----------------------------------------------------------------------------// 74 | 75 | FIELD3D_NAMESPACE_SOURCE_CLOSE 76 | 77 | //----------------------------------------------------------------------------// 78 | -------------------------------------------------------------------------------- /src/FileSequence.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2014 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file FileSequence.cpp 39 | Contains file sequence implementations 40 | */ 41 | 42 | //----------------------------------------------------------------------------// 43 | 44 | // Header include 45 | #include "FileSequence.h" 46 | 47 | // System includes 48 | #include 49 | #include 50 | 51 | // Library includes 52 | #include "Log.h" 53 | #include "Field3DFile.h" 54 | 55 | //----------------------------------------------------------------------------// 56 | 57 | FIELD3D_NAMESPACE_OPEN 58 | 59 | //----------------------------------------------------------------------------// 60 | // FileSequence implementations 61 | //----------------------------------------------------------------------------// 62 | 63 | 64 | FileSequence::FileSequence(const std::string &sequence) 65 | { 66 | // Example sequences: myfile.1-2@.f3d, myfile1-21#.f3d 67 | // The number '1' in each of these is the 'sequence start' 68 | // The numbers '2' and '21' are the 'sequence end' 69 | 70 | const std::string k_numbers = "0123456789"; 71 | const std::string k_seqMarks = "#@"; 72 | const std::string k_framePlaceholder = "####"; 73 | const size_t npos = std::string::npos; 74 | 75 | // Check for file by that name. If it exists, we are just that one file 76 | if (fileExists(sequence)) { 77 | m_filenames.push_back(sequence); 78 | return; 79 | } 80 | 81 | // Find the sequence mark 82 | const size_t seqMarkIdx = sequence.find_first_of(k_seqMarks); 83 | 84 | // If no sequence mark was found, there is no sequence. 85 | if (seqMarkIdx == npos) { 86 | return; 87 | } 88 | 89 | // Make sure there is not more than one sequence mark 90 | if (sequence.find_first_of(k_seqMarks, seqMarkIdx + 1) != npos) { 91 | std::stringstream warning; 92 | warning << "Multiple sequence marks in filename: " << sequence; 93 | Msg::print(Msg::SevWarning, warning.str()); 94 | return; 95 | } 96 | 97 | // Get the end range index 98 | size_t seqEndIdx = sequence.find_last_not_of(k_numbers, seqMarkIdx - 1); 99 | if (seqEndIdx == npos) { 100 | std::stringstream warning; 101 | warning << "Sequence mark but no sequence range in filename: " 102 | << sequence; 103 | Msg::print(Msg::SevWarning, warning.str()); 104 | return; 105 | } else { 106 | seqEndIdx += 1; 107 | } 108 | if (seqEndIdx == 0) { 109 | std::stringstream warning; 110 | warning << "Sequence mark preceded by single number: " 111 | << sequence; 112 | Msg::print(Msg::SevWarning, warning.str()); 113 | return; 114 | } 115 | 116 | // Make sure the preceding character is '-' 117 | if (sequence[seqEndIdx - 1] != '-') { 118 | std::stringstream warning; 119 | warning << "Sequence mark preceded by single number but no '-': " 120 | << sequence; 121 | Msg::print(Msg::SevWarning, warning.str()); 122 | return; 123 | } 124 | 125 | // Get the start range index 126 | size_t seqStartIdx = sequence.find_last_not_of(k_numbers, seqEndIdx - 2); 127 | if (seqStartIdx == npos) { 128 | std::stringstream warning; 129 | warning << "No sequence start in filename: " 130 | << sequence; 131 | Msg::print(Msg::SevWarning, warning.str()); 132 | return; 133 | } else { 134 | seqStartIdx += 1; 135 | } 136 | 137 | // String versions of frame numbers 138 | const std::string startStr = sequence.substr(seqStartIdx, seqEndIdx - 1); 139 | const std::string endStr = sequence.substr(seqEndIdx, seqMarkIdx); 140 | 141 | // Get the integers 142 | const int start = atoi(startStr.c_str()); 143 | const int end = atoi(endStr.c_str()); 144 | 145 | // Create the file basename for replacement 146 | const std::string baseStart = sequence.substr(0, seqStartIdx); 147 | const std::string baseEnd = sequence.substr(seqMarkIdx + 1); 148 | 149 | // Create the filenames 150 | for (int i = start; i <= end; ++i) { 151 | std::stringstream filename; 152 | filename << baseStart << i << baseEnd; 153 | m_filenames.push_back(filename.str()); 154 | } 155 | } 156 | 157 | //----------------------------------------------------------------------------// 158 | 159 | FIELD3D_NAMESPACE_SOURCE_CLOSE 160 | 161 | //----------------------------------------------------------------------------// 162 | -------------------------------------------------------------------------------- /src/IArchive.cpp: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Industrial Light & Magic nor the names of 19 | // its contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | //-***************************************************************************** 35 | 36 | #include "IArchive.h" 37 | 38 | namespace Alembic { 39 | namespace Ogawa { 40 | namespace ALEMBIC_VERSION_NS { 41 | 42 | IArchive::IArchive(const std::string & iFileName, std::size_t iNumStreams) : 43 | mStreams(new IStreams(iFileName, iNumStreams)) 44 | { 45 | init(); 46 | } 47 | 48 | IArchive::IArchive(const std::vector< std::istream * > & iStreams) : 49 | mStreams(new IStreams(iStreams)) 50 | { 51 | init(); 52 | } 53 | 54 | void IArchive::init() 55 | { 56 | if (mStreams->isValid()) 57 | { 58 | Alembic::Util::uint64_t pos = 0; 59 | mStreams->read(0, 8, 8, &pos); 60 | mGroup.reset(new IGroup(mStreams, pos, false, 0)); 61 | } 62 | } 63 | 64 | IArchive::~IArchive() 65 | { 66 | } 67 | 68 | bool IArchive::isValid() const 69 | { 70 | return mStreams->isValid(); 71 | } 72 | 73 | bool IArchive::isFrozen() const 74 | { 75 | return mStreams->isFrozen(); 76 | } 77 | 78 | Alembic::Util::uint16_t IArchive::getVersion() const 79 | { 80 | return mStreams->getVersion(); 81 | } 82 | 83 | IGroupPtr IArchive::getGroup() const 84 | { 85 | return mGroup; 86 | } 87 | 88 | } // End namespace ALEMBIC_VERSION_NS 89 | } // End namespace Ogawa 90 | } // End namespace Alembic 91 | -------------------------------------------------------------------------------- /src/IData.cpp: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Industrial Light & Magic nor the names of 19 | // its contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | //-***************************************************************************** 35 | 36 | #include "Foundation.h" 37 | #include "IGroup.h" 38 | #include "IData.h" 39 | #include "IStreams.h" 40 | 41 | namespace Alembic { 42 | namespace Ogawa { 43 | namespace ALEMBIC_VERSION_NS { 44 | 45 | class IData::PrivateData 46 | { 47 | public: 48 | PrivateData(IStreamsPtr iStreams) 49 | { 50 | streams = iStreams; 51 | }; 52 | 53 | ~PrivateData() {}; 54 | 55 | IStreamsPtr streams; 56 | 57 | // set after freeze 58 | Alembic::Util::uint64_t pos; 59 | Alembic::Util::uint64_t size; 60 | }; 61 | 62 | IData::~IData() 63 | { 64 | 65 | } 66 | 67 | IData::IData(IStreamsPtr iStreams, 68 | Alembic::Util::uint64_t iPos, 69 | std::size_t iThreadId) : 70 | mData(new IData::PrivateData(iStreams)) 71 | { 72 | mData->size = 0; 73 | 74 | // strip off the top bit (indicates data) to get our seek position 75 | mData->pos = iPos & INVALID_GROUP; 76 | 77 | Alembic::Util::uint64_t size = 0; 78 | 79 | // not the empty group? then figure out our size 80 | if ( mData->pos != 0 ) 81 | { 82 | mData->streams->read(iThreadId, mData->pos, 8, &size); 83 | mData->size = size; 84 | } 85 | } 86 | 87 | void IData::read(Alembic::Util::uint64_t iSize, void * iData, 88 | Alembic::Util::uint64_t iOffset, std::size_t iThreadId) 89 | { 90 | // don't read anything if we will read beyond our buffer 91 | if (iSize == 0 || mData->size == 0 || iOffset + iSize > mData->size) 92 | { 93 | return; 94 | } 95 | 96 | // +8 is to account for the size 97 | mData->streams->read(iThreadId, mData->pos + iOffset + 8, iSize, iData); 98 | } 99 | 100 | Alembic::Util::uint64_t IData::getSize() const 101 | { 102 | return mData->size; 103 | } 104 | 105 | Alembic::Util::uint64_t IData::getPos() const 106 | { 107 | return mData->pos; 108 | } 109 | 110 | } // End namespace ALEMBIC_VERSION_NS 111 | } // End namespace Ogawa 112 | } // End namespace Alembic 113 | -------------------------------------------------------------------------------- /src/InitIO.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file InitIO.cpp 39 | Contains implementation of initIO function. 40 | */ 41 | 42 | //----------------------------------------------------------------------------// 43 | 44 | #include "InitIO.h" 45 | 46 | #include "DenseFieldIO.h" 47 | #include "SparseFieldIO.h" 48 | #include "MACFieldIO.h" 49 | #include "FieldMappingIO.h" 50 | #include "MIPFieldIO.h" 51 | 52 | //----------------------------------------------------------------------------// 53 | 54 | FIELD3D_NAMESPACE_OPEN 55 | 56 | //----------------------------------------------------------------------------// 57 | 58 | namespace { 59 | 60 | size_t g_numIOThreads = 1; 61 | 62 | } 63 | 64 | //----------------------------------------------------------------------------// 65 | 66 | void initIO() 67 | { 68 | static boost::mutex mutex; 69 | boost::mutex::scoped_lock lock(mutex); 70 | 71 | ClassFactory &factory = ClassFactory::singleton(); 72 | 73 | factory.registerFieldIO(DenseFieldIO::create); 74 | factory.registerFieldIO(SparseFieldIO::create); 75 | factory.registerFieldIO(MACFieldIO::create); 76 | factory.registerFieldIO(MIPFieldIO::create); 77 | 78 | factory.registerFieldMappingIO(NullFieldMappingIO::create); 79 | factory.registerFieldMappingIO(MatrixFieldMappingIO::create); 80 | factory.registerFieldMappingIO(FrustumFieldMappingIO::create); 81 | } 82 | 83 | //----------------------------------------------------------------------------// 84 | 85 | void setNumIOThreads(const size_t numThreads) 86 | { 87 | g_numIOThreads = numThreads; 88 | } 89 | 90 | //----------------------------------------------------------------------------// 91 | 92 | size_t numIOThreads() 93 | { 94 | return g_numIOThreads; 95 | } 96 | 97 | //----------------------------------------------------------------------------// 98 | 99 | FIELD3D_NAMESPACE_SOURCE_CLOSE 100 | 101 | //----------------------------------------------------------------------------// 102 | 103 | -------------------------------------------------------------------------------- /src/Log.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file Log.cpp 39 | \brief Contains implementations of the logging-related functions. 40 | */ 41 | 42 | //----------------------------------------------------------------------------// 43 | 44 | #include 45 | #include 46 | #include 47 | 48 | #include 49 | 50 | #include "Log.h" 51 | 52 | //----------------------------------------------------------------------------// 53 | 54 | using namespace std; 55 | 56 | //----------------------------------------------------------------------------// 57 | 58 | FIELD3D_NAMESPACE_OPEN 59 | 60 | //----------------------------------------------------------------------------// 61 | 62 | namespace Msg { 63 | 64 | //----------------------------------------------------------------------------// 65 | 66 | static int g_verbosity = 1; 67 | 68 | //----------------------------------------------------------------------------// 69 | 70 | void print(Severity severity, const std::string &message) 71 | { 72 | if (g_verbosity < 1) 73 | return; 74 | 75 | switch(severity) { 76 | case SevWarning: 77 | cout << "WARNING: "; 78 | break; 79 | case SevMessage: 80 | default: 81 | break; 82 | // Do nothing 83 | } 84 | 85 | cout << message << endl; 86 | } 87 | 88 | //----------------------------------------------------------------------------// 89 | 90 | void setVerbosity (int level) 91 | { 92 | g_verbosity = level; 93 | } 94 | 95 | //----------------------------------------------------------------------------// 96 | 97 | } // namespace Log 98 | 99 | //----------------------------------------------------------------------------// 100 | 101 | std::string bytesToString(int64_t bytes) 102 | { 103 | using std::stringstream; 104 | 105 | stringstream ss; 106 | ss.precision(3); 107 | ss.setf(std::ios::fixed, std:: ios::floatfield); 108 | 109 | // Make it work for negative numbers 110 | if (bytes < 0) { 111 | ss << "-"; 112 | bytes = -bytes; 113 | } 114 | 115 | if (bytes < 1024) { 116 | // Bytes 117 | ss << bytes << " B"; 118 | return ss.str(); 119 | } else if (bytes < (1024 * 1024)) { 120 | // Kilobytes 121 | ss << bytes / static_cast(1024) << " KB"; 122 | return ss.str(); 123 | } else if (bytes < (1024 * 1024 * 1024)) { 124 | // Megabytes 125 | ss << bytes / static_cast(1024 * 1024) << " MB"; 126 | return ss.str(); 127 | } else { 128 | // Gigabytes 129 | ss << bytes / static_cast(1024 * 1024 * 1024) << " GB"; 130 | return ss.str(); 131 | } 132 | } 133 | 134 | //----------------------------------------------------------------------------// 135 | 136 | size_t currentRSS() 137 | { 138 | //! Only implemented for Linux at the moment. 139 | 140 | #ifdef __linux__ 141 | 142 | using std::ios_base; 143 | using std::ifstream; 144 | using std::string; 145 | ifstream stat_stream("/proc/self/stat", ios_base::in); 146 | 147 | string pid, comm, state, ppid, pgrp, session, tty_nr; 148 | string tpgid, flags, minflt, cminflt, majflt, cmajflt; 149 | string utime, stime, cutime, cstime, priority, nice; 150 | string O, itrealvalue, starttime; 151 | 152 | unsigned long vsize; 153 | long rss; 154 | 155 | stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr 156 | >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt 157 | >> utime >> stime >> cutime >> cstime >> priority >> nice 158 | >> O >> itrealvalue >> starttime 159 | >> vsize >> rss; // don't care about the rest 160 | 161 | stat_stream.close(); 162 | 163 | // in case x86-64 is configured to use 2MB pages 164 | long page_size = sysconf(_SC_PAGE_SIZE); 165 | 166 | // vm_usage = vsize / 1024.0; 167 | // resident_set = rss * page_size; 168 | 169 | return rss * page_size; 170 | 171 | #else 172 | 173 | return 0; 174 | 175 | #endif 176 | 177 | } 178 | 179 | //----------------------------------------------------------------------------// 180 | 181 | FIELD3D_NAMESPACE_SOURCE_CLOSE 182 | 183 | //----------------------------------------------------------------------------// 184 | -------------------------------------------------------------------------------- /src/MinMaxUtil.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2015 Sony Pictures Imageworks Inc, 5 | * Pixar Animation Studios 6 | * 7 | * All rights reserved. 8 | * 9 | * Redistribution and use in source and binary forms, with or without 10 | * modification, are permitted provided that the following conditions 11 | * are met: 12 | * 13 | * Redistributions of source code must retain the above copyright 14 | * notice, this list of conditions and the following disclaimer. 15 | * Redistributions in binary form must reproduce the above copyright 16 | * notice, this list of conditions and the following disclaimer in the 17 | * documentation and/or other materials provided with the 18 | * distribution. Neither the name of Sony Pictures Imageworks nor the 19 | * names of its contributors may be used to endorse or promote 20 | * products derived from this software without specific prior written 21 | * permission. 22 | * 23 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 24 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 25 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 26 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 27 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 28 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 29 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 32 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 34 | * OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | //----------------------------------------------------------------------------// 38 | 39 | /*! \file MinMaxUtil.cpp 40 | Contains some implementation constants 41 | */ 42 | 43 | //----------------------------------------------------------------------------// 44 | 45 | #include "MinMaxUtil.h" 46 | 47 | //----------------------------------------------------------------------------// 48 | 49 | FIELD3D_NAMESPACE_OPEN 50 | 51 | //----------------------------------------------------------------------------// 52 | // Constants 53 | //----------------------------------------------------------------------------// 54 | 55 | const char* k_minSuffix = "_min"; 56 | const char* k_maxSuffix = "_max"; 57 | 58 | //----------------------------------------------------------------------------// 59 | 60 | FIELD3D_NAMESPACE_SOURCE_CLOSE 61 | 62 | //----------------------------------------------------------------------------// 63 | -------------------------------------------------------------------------------- /src/OArchive.cpp: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Industrial Light & Magic nor the names of 19 | // its contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | //-***************************************************************************** 35 | 36 | #include "OArchive.h" 37 | #include "OStream.h" 38 | #include "OGroup.h" 39 | 40 | namespace Alembic { 41 | namespace Ogawa { 42 | namespace ALEMBIC_VERSION_NS { 43 | 44 | OArchive::OArchive(const std::string & iFileName) : 45 | mStream(new OStream(iFileName)) 46 | { 47 | mGroup.reset(new OGroup(mStream)); 48 | } 49 | 50 | OArchive::OArchive(std::ostream * iStream) : 51 | mStream(new OStream(iStream)), mGroup(new OGroup(mStream)) 52 | { 53 | } 54 | 55 | OArchive::~OArchive() 56 | { 57 | } 58 | 59 | bool OArchive::isValid() 60 | { 61 | return mStream->isValid(); 62 | } 63 | 64 | OGroupPtr OArchive::getGroup() 65 | { 66 | return mGroup; 67 | } 68 | 69 | } // End namespace ALEMBIC_VERSION_NS 70 | } // End namespace Ogawa 71 | } // End namespace Alembic 72 | -------------------------------------------------------------------------------- /src/OData.cpp: -------------------------------------------------------------------------------- 1 | //-***************************************************************************** 2 | // 3 | // Copyright (c) 2013, 4 | // Sony Pictures Imageworks Inc. and 5 | // Industrial Light & Magic, a division of Lucasfilm Entertainment Company Ltd. 6 | // 7 | // All rights reserved. 8 | // 9 | // Redistribution and use in source and binary forms, with or without 10 | // modification, are permitted provided that the following conditions are 11 | // met: 12 | // * Redistributions of source code must retain the above copyright 13 | // notice, this list of conditions and the following disclaimer. 14 | // * Redistributions in binary form must reproduce the above 15 | // copyright notice, this list of conditions and the following disclaimer 16 | // in the documentation and/or other materials provided with the 17 | // distribution. 18 | // * Neither the name of Industrial Light & Magic nor the names of 19 | // its contributors may be used to endorse or promote products derived 20 | // from this software without specific prior written permission. 21 | // 22 | // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 25 | // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 26 | // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 27 | // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 28 | // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 29 | // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 30 | // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 31 | // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 32 | // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 33 | // 34 | //-***************************************************************************** 35 | 36 | #include "OGroup.h" 37 | #include "OData.h" 38 | #include "OStream.h" 39 | 40 | namespace Alembic { 41 | namespace Ogawa { 42 | namespace ALEMBIC_VERSION_NS { 43 | 44 | class OData::PrivateData 45 | { 46 | public: 47 | 48 | // for the empty dataset 49 | PrivateData() 50 | { 51 | pos = 0; 52 | size = 0; 53 | } 54 | 55 | PrivateData(OStreamPtr iStream, 56 | Alembic::Util::uint64_t iPos, 57 | Alembic::Util::uint64_t iSize) : 58 | stream(iStream), pos(iPos), size(iSize) {} 59 | 60 | ~PrivateData() {} 61 | 62 | OStreamPtr stream; 63 | 64 | Alembic::Util::uint64_t pos; 65 | Alembic::Util::uint64_t size; 66 | }; 67 | 68 | OData::OData() : mData(new OData::PrivateData()) 69 | { 70 | } 71 | 72 | OData::OData(OStreamPtr iStream, 73 | Alembic::Util::uint64_t iPos, 74 | Alembic::Util::uint64_t iSize) 75 | : mData(new OData::PrivateData(iStream, iPos, iSize)) 76 | { 77 | } 78 | 79 | OData::~OData() 80 | { 81 | } 82 | 83 | void OData::rewrite(Alembic::Util::uint64_t iSize, void * iData, 84 | Alembic::Util::uint64_t iOffset) 85 | { 86 | 87 | // don't write anything if we will write beyond our buffer or the 88 | // stream is invalid 89 | if (!mData->stream || iSize == 0 || mData->size == 0 || 90 | iOffset + iSize > mData->size) 91 | { 92 | return; 93 | } 94 | 95 | // +8 is to account for the written out size 96 | mData->stream->seek(mData->pos + iOffset + 8); 97 | mData->stream->write(iData, iSize); 98 | } 99 | 100 | Alembic::Util::uint64_t OData::getSize() const 101 | { 102 | return mData->size; 103 | } 104 | 105 | Alembic::Util::uint64_t OData::getPos() const 106 | { 107 | return mData->pos; 108 | } 109 | 110 | } // End namespace ALEMBIC_VERSION_NS 111 | } // End namespace Ogawa 112 | } // End namespace Alembic 113 | -------------------------------------------------------------------------------- /src/OgUtil.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | // Includes 3 | //----------------------------------------------------------------------------// 4 | 5 | #include "OgUtil.h" 6 | 7 | //----------------------------------------------------------------------------// 8 | 9 | FIELD3D_NAMESPACE_OPEN 10 | 11 | //----------------------------------------------------------------------------// 12 | // Helper functions 13 | //----------------------------------------------------------------------------// 14 | 15 | const char* ogGroupTypeToString(OgGroupType type) 16 | { 17 | switch(type) 18 | { 19 | case F3DGroupType: 20 | return "group"; 21 | case F3DAttributeType: 22 | return "attribute"; 23 | case F3DDatasetType: 24 | return "dataset"; 25 | default: 26 | return ""; 27 | } 28 | } 29 | 30 | //----------------------------------------------------------------------------// 31 | 32 | bool readString(Alembic::Ogawa::IGroupPtr group, const size_t idx, 33 | std::string &s) 34 | { 35 | // Grab data 36 | Alembic::Ogawa::IDataPtr data = group->getData(idx, OGAWA_THREAD); 37 | // Check that we got something 38 | if (!data) { 39 | std::cout << "OgUtil::readString() got null data for index " 40 | << idx << std::endl; 41 | std::cout << " numChildren(): " << group->getNumChildren() << std::endl; 42 | return false; 43 | } 44 | // Check data length 45 | const size_t length = data->getSize(); 46 | if (length % sizeof(std::string::value_type) != 0) { 47 | return false; 48 | } 49 | // String length 50 | const size_t stringLength = length / sizeof(std::string::value_type); 51 | // Read into temp buffer. Reading straight into std::string is Bad. 52 | std::vector temp(stringLength + 1); 53 | // Add null terminator 54 | temp[stringLength] = 0; 55 | // Read the data 56 | data->read(length, &temp[0], 0, OGAWA_THREAD); 57 | // Construct string. The string see the temp buffer as a const char *. 58 | s = std::string(&temp[0]); 59 | // Done 60 | return true; 61 | } 62 | 63 | //----------------------------------------------------------------------------// 64 | 65 | OgDataType readDataType(Alembic::Ogawa::IGroupPtr group, const size_t idx) 66 | { 67 | // Data type 68 | OgDataType dataType;; 69 | // Grab data 70 | Alembic::Ogawa::IDataPtr data = group->getData(idx, OGAWA_THREAD); 71 | // Check data length 72 | const size_t sizeLength = sizeof(OgDataType); 73 | const size_t length = data->getSize(); 74 | if (length != sizeLength) { 75 | std::cout << "readDataType() " << sizeLength << " != " << length << std::endl; 76 | return F3DInvalidDataType; 77 | } 78 | // Read the data directly to the input param 79 | data->read(length, &dataType, 0, OGAWA_THREAD); 80 | // Done 81 | return dataType; 82 | } 83 | 84 | //----------------------------------------------------------------------------// 85 | 86 | bool writeString(Alembic::Ogawa::OGroupPtr group, const std::string &s) 87 | { 88 | // Strings are written without zero terminator 89 | Alembic::Ogawa::ODataPtr data = 90 | group->addData(s.size() * sizeof(std::string::value_type), s.c_str()); 91 | return data != NULL; 92 | } 93 | 94 | //----------------------------------------------------------------------------// 95 | 96 | bool getGroupName(Alembic::Ogawa::IGroupPtr group, 97 | std::string &name) 98 | { 99 | return readString(group, 0, name); 100 | } 101 | 102 | //----------------------------------------------------------------------------// 103 | 104 | FIELD3D_NAMESPACE_SOURCE_CLOSE 105 | 106 | //----------------------------------------------------------------------------// 107 | 108 | -------------------------------------------------------------------------------- /src/ProceduralField.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file ProceduralField.cpp 39 | contains template instantiations for ProceduralField class 40 | */ 41 | 42 | //----------------------------------------------------------------------------// 43 | 44 | #include "ProceduralField.h" 45 | 46 | //----------------------------------------------------------------------------// 47 | 48 | FIELD3D_NAMESPACE_OPEN 49 | 50 | //----------------------------------------------------------------------------// 51 | // ProceduralField 52 | //----------------------------------------------------------------------------// 53 | 54 | //----------------------------------------------------------------------------// 55 | //static template member 56 | //----------------------------------------------------------------------------// 57 | 58 | // template 59 | // TemplatedFieldType > ProceduralField::ms_classType; 60 | 61 | // template TemplatedFieldType > ProceduralField::ms_classType; 62 | // template TemplatedFieldType > ProceduralField::ms_classType; 63 | // template TemplatedFieldType > ProceduralField::ms_classType; 64 | // template TemplatedFieldType > ProceduralField::ms_classType; 65 | // template TemplatedFieldType > ProceduralField::ms_classType; 66 | // template TemplatedFieldType > ProceduralField::ms_classType; 67 | 68 | //----------------------------------------------------------------------------// 69 | 70 | FIELD3D_NAMESPACE_SOURCE_CLOSE 71 | 72 | //----------------------------------------------------------------------------// 73 | -------------------------------------------------------------------------------- /src/Resample.cpp: -------------------------------------------------------------------------------- 1 | //----------------------------------------------------------------------------// 2 | 3 | /* 4 | * Copyright (c) 2009 Sony Pictures Imageworks Inc 5 | * 6 | * All rights reserved. 7 | * 8 | * Redistribution and use in source and binary forms, with or without 9 | * modification, are permitted provided that the following conditions 10 | * are met: 11 | * 12 | * Redistributions of source code must retain the above copyright 13 | * notice, this list of conditions and the following disclaimer. 14 | * Redistributions in binary form must reproduce the above copyright 15 | * notice, this list of conditions and the following disclaimer in the 16 | * documentation and/or other materials provided with the 17 | * distribution. Neither the name of Sony Pictures Imageworks nor the 18 | * names of its contributors may be used to endorse or promote 19 | * products derived from this software without specific prior written 20 | * permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 23 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 24 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 25 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 26 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 27 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 28 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 29 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 31 | * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 32 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 33 | * OF THE POSSIBILITY OF SUCH DAMAGE. 34 | */ 35 | 36 | //----------------------------------------------------------------------------// 37 | 38 | /*! \file Resample.cpp 39 | Contains implementations of resampling-related functions. 40 | */ 41 | 42 | //----------------------------------------------------------------------------// 43 | 44 | #include "Resample.h" 45 | 46 | //----------------------------------------------------------------------------// 47 | 48 | FIELD3D_NAMESPACE_OPEN 49 | 50 | //----------------------------------------------------------------------------// 51 | 52 | namespace detail { 53 | 54 | //--------------------------------------------------------------------------// 55 | 56 | Box3i srcSupportBBox(const V3f &tgtP, const float support, const V3i &doUpres, 57 | const V3f &srcSize, const V3f &tgtSize) 58 | { 59 | Box3i srcBox; 60 | for (int dim = 0; dim < 3; ++dim) { 61 | if (doUpres[dim]) { 62 | srcBox.min[dim] = 63 | static_cast(std::floor(tgtP[dim] * tgtSize[dim] / srcSize[dim] - 64 | support)); 65 | srcBox.max[dim] = 66 | static_cast(std::ceil(tgtP[dim] * tgtSize[dim] / srcSize[dim] + 67 | support)) - 1; 68 | } else { 69 | srcBox.min[dim] = 70 | static_cast(std::floor((tgtP[dim] - support) * 71 | tgtSize[dim] / srcSize[dim])); 72 | srcBox.max[dim] = 73 | static_cast(std::ceil((tgtP[dim] + support) * 74 | tgtSize[dim] / srcSize[dim])); 75 | } 76 | } 77 | return srcBox; 78 | } 79 | 80 | //--------------------------------------------------------------------------// 81 | 82 | std::pair 83 | srcSupportBBox(const float &tgtP, const float support, const bool doUpres, 84 | const float &srcSize, const float &tgtSize) 85 | { 86 | std::pair srcInterval; 87 | if (doUpres) { 88 | srcInterval.first = 89 | static_cast(std::floor(tgtP * tgtSize / srcSize - support)); 90 | srcInterval.second = 91 | static_cast(std::ceil(tgtP * tgtSize / srcSize + support)) - 1; 92 | } else { 93 | srcInterval.first = 94 | static_cast(std::floor((tgtP - support) * tgtSize / srcSize)); 95 | srcInterval.second = 96 | static_cast(std::ceil((tgtP + support) * tgtSize / srcSize)); 97 | } 98 | return srcInterval; 99 | } 100 | 101 | //--------------------------------------------------------------------------// 102 | 103 | V3f getDist(const V3i &doUpres, const V3f &srcP, const V3f &tgtP, 104 | const V3f &srcSize, const V3f &tgtSize) 105 | { 106 | V3f dist; 107 | for (int dim = 0; dim < 3; ++dim) { 108 | if (doUpres[dim]) { 109 | const float tgtSrc = tgtP[dim] * tgtSize[dim] / srcSize[dim]; 110 | dist[dim] = std::abs(tgtSrc - srcP[dim]); 111 | } else { 112 | const float srcTgt = srcP[dim] * srcSize[dim] / tgtSize[dim]; 113 | dist[dim] = std::abs(srcTgt - tgtP[dim]); 114 | } 115 | } 116 | return dist; 117 | } 118 | 119 | //--------------------------------------------------------------------------// 120 | 121 | float getDist(const bool doUpres, const float &srcP, const float &tgtP, 122 | const float &srcSize, const float &tgtSize) 123 | { 124 | if (doUpres) { 125 | const float tgtSrc = tgtP * tgtSize / srcSize; 126 | return std::abs(tgtSrc - srcP); 127 | } else { 128 | const float srcTgt = srcP * srcSize / tgtSize; 129 | return std::abs(srcTgt - tgtP); 130 | } 131 | } 132 | 133 | //--------------------------------------------------------------------------// 134 | 135 | } // namespace detail 136 | 137 | //----------------------------------------------------------------------------// 138 | 139 | FIELD3D_NAMESPACE_SOURCE_CLOSE 140 | 141 | //----------------------------------------------------------------------------// 142 | -------------------------------------------------------------------------------- /test/misc_tests/access_speed/SConscript: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | import os 4 | import sys 5 | 6 | # ------------------------------------------------------------------------------ 7 | 8 | pathToRoot = "../../.." 9 | 10 | sys.path.append(pathToRoot) 11 | 12 | from BuildSupport import * 13 | 14 | buildPath = buildDir() 15 | binPath = join(buildPath, os.path.basename(os.getcwd())) 16 | 17 | # ------------------------------------------------------------------------------ 18 | 19 | Import("env") 20 | appEnv = env.Clone() 21 | 22 | setupEnv(appEnv, pathToRoot) 23 | addField3DInstall(appEnv, pathToRoot) 24 | 25 | appEnv.VariantDir(buildPath, ".", duplicate = 0) 26 | files = Glob(join(buildPath, "*.cpp")) 27 | 28 | app = appEnv.Program(binPath, files) 29 | appEnv.Default(app) 30 | 31 | # ------------------------------------------------------------------------------ 32 | -------------------------------------------------------------------------------- /test/misc_tests/access_speed/SConstruct: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | env = Environment() 4 | 5 | Export("env") 6 | 7 | SConscript("SConscript") 8 | 9 | # ------------------------------------------------------------------------------ 10 | 11 | -------------------------------------------------------------------------------- /test/misc_tests/lib_perf_test/.gitignore: -------------------------------------------------------------------------------- 1 | build/ 2 | src/*.o 3 | -------------------------------------------------------------------------------- /test/misc_tests/lib_perf_test/Field3D_here/.gitignore: -------------------------------------------------------------------------------- 1 | *.h 2 | *.cpp 3 | -------------------------------------------------------------------------------- /test/misc_tests/lib_perf_test/INSTRUCTIONS: -------------------------------------------------------------------------------- 1 | This test suite does not require that you build or install either 2 | of the Field3D and OpenVDB libraries. 3 | 4 | In order to build the test, take the following steps: 5 | 6 | 1 Copy the 'export' and 'src' folders from your Field3D distribution 7 | into 'Field3D_here'. 8 | 2 Copy the entire 'openvdb' folder from you OpenVDB distribution 9 | into 'OpenVDB_here' 10 | 3 'scons' 11 | 4 Run test from build///release/vdb_test 12 | 13 | -------------------------------------------------------------------------------- /test/misc_tests/lib_perf_test/OpenVDB_here/.gitignore: -------------------------------------------------------------------------------- 1 | openvdb 2 | -------------------------------------------------------------------------------- /test/misc_tests/lib_perf_test/SConstruct: -------------------------------------------------------------------------------- 1 | SConscript("SConscript") 2 | -------------------------------------------------------------------------------- /test/misc_tests/lib_perf_test/test_results/graypage_tests.numbers: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imageworks/Field3D/b0ff0cd67893a4cbfa322676eb3eef10100d904d/test/misc_tests/lib_perf_test/test_results/graypage_tests.numbers -------------------------------------------------------------------------------- /test/misc_tests/lib_perf_test/test_results/graypage_tests.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/imageworks/Field3D/b0ff0cd67893a4cbfa322676eb3eef10100d904d/test/misc_tests/lib_perf_test/test_results/graypage_tests.pdf -------------------------------------------------------------------------------- /test/misc_tests/lib_perf_test/test_results/statstocsv.py: -------------------------------------------------------------------------------- 1 | #! /usr/bin/env python 2 | 3 | # Imports --- 4 | 5 | import re, sys, os 6 | 7 | # Constants --- 8 | 9 | data = \ 10 | """Contiguous write access 800^3 11 | - Dense | alloc: 434 | run: 380 | total: 814 | mem: 2048000744 | rss: 2048204800 | check sum: 512000000 12 | - Sparse 8 | alloc: 3 | run: 5174 | total: 5177 | mem: 2064000400 | rss: 2080235520 | check sum: 512000000 13 | - VDB 8 | alloc: 0 | run: 4904 | total: 4904 | mem: 2143866376 | rss: 2172227584 | check sum: 512000000 14 | - Sparse 16 | alloc: 0 | run: 6339 | total: 6339 | mem: 2050000400 | rss: 2052349952 | check sum: 512000000 15 | - VDB 16 | alloc: 0 | run: 5623 | total: 5623 | mem: 2116935060 | rss: 2120822784 | check sum: 512000000 16 | - Sparse 32 | alloc: 0 | run: 4594 | total: 4594 | mem: 2048250400 | rss: 2048884736 | check sum: 512000000 17 | - VDB 32 | alloc: 0 | run: 3945 | total: 3945 | mem: 2112854536 | rss: 2113699840 | check sum: 512000000 18 | Contiguous write access (preallocated) 800^3 19 | - Dense | alloc: 0 | run: 193 | total: 193 | mem: 2048000744 | rss: 2048819200 | check sum: 512000000 20 | - Sparse 8 | alloc: 0 | run: 6127 | total: 6127 | mem: 2064000400 | rss: 2080415744 | check sum: 512000000 21 | - VDB 8 | alloc: 0 | run: 5506 | total: 5506 | mem: 2143866376 | rss: 2172313600 | check sum: 512000000 22 | - Sparse 16 | alloc: 0 | run: 6102 | total: 6102 | mem: 2050000400 | rss: 2052435968 | check sum: 512000000 23 | - VDB 16 | alloc: 0 | run: 5198 | total: 5198 | mem: 2116935060 | rss: 2120896512 | check sum: 512000000 24 | - Sparse 32 | alloc: 0 | run: 3875 | total: 3875 | mem: 2048250400 | rss: 2048958464 | check sum: 512000000 25 | - VDB 32 | alloc: 0 | run: 3141 | total: 3141 | mem: 2112854536 | rss: 2113769472 | check sum: 512000000 26 | """ 27 | 28 | # Script --- 29 | 30 | input = open(sys.argv[1]).readlines() 31 | 32 | output = open(sys.argv[1][:-3] + "csv", "w") 33 | 34 | for line in input: 35 | x = line.split("|") 36 | if len(x) == 1: 37 | print x[0] 38 | output.writelines([x[0]]) 39 | if len(x) == 7: 40 | items = [x[0].strip()[2:], 41 | x[1].split()[1], 42 | x[2].split()[1], 43 | x[3].split()[1], 44 | x[4].split()[1], 45 | x[5].split()[1]] 46 | print ", ".join(items) 47 | output.writelines([",".join(items) + "\n"]) 48 | 49 | -------------------------------------------------------------------------------- /test/misc_tests/threading_and_virtual_calls/SConscript: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | import os 4 | import sys 5 | 6 | # ------------------------------------------------------------------------------ 7 | 8 | pathToRoot = "../../.." 9 | 10 | sys.path.append(pathToRoot) 11 | 12 | from BuildSupport import * 13 | 14 | buildPath = buildDir() 15 | binPath = join(buildPath, os.path.basename(os.getcwd())) 16 | 17 | # ------------------------------------------------------------------------------ 18 | 19 | Import("env") 20 | appEnv = env.Clone() 21 | 22 | setupEnv(appEnv, pathToRoot) 23 | addField3DInstall(appEnv, pathToRoot) 24 | 25 | appEnv.VariantDir(buildPath, ".", duplicate = 0) 26 | files = Glob(join(buildPath, "*.cpp")) 27 | 28 | app = appEnv.Program(binPath, files) 29 | appEnv.Default(app) 30 | 31 | # ------------------------------------------------------------------------------ 32 | -------------------------------------------------------------------------------- /test/misc_tests/threading_and_virtual_calls/SConstruct: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | env = Environment() 4 | 5 | Export("env") 6 | 7 | SConscript("SConscript") 8 | 9 | # ------------------------------------------------------------------------------ 10 | 11 | -------------------------------------------------------------------------------- /test/unit_tests/.gitignore: -------------------------------------------------------------------------------- 1 | build 2 | *.dblite 3 | -------------------------------------------------------------------------------- /test/unit_tests/SConscript: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | import os 4 | import sys 5 | 6 | # ------------------------------------------------------------------------------ 7 | 8 | pathToRoot = "../.." 9 | 10 | sys.path.append(pathToRoot) 11 | 12 | from BuildSupport import * 13 | 14 | buildPath = buildDir() 15 | binPath = join(buildPath, os.path.basename(os.getcwd())) 16 | 17 | # ------------------------------------------------------------------------------ 18 | 19 | Import("env") 20 | appEnv = env.Clone() 21 | 22 | setupEnv(appEnv, pathToRoot) 23 | addField3DInstall(appEnv, pathToRoot) 24 | 25 | appEnv.VariantDir(buildPath, ".", duplicate = 0) 26 | files = Glob(join(buildPath, "*.cpp")) 27 | 28 | app = appEnv.Program(binPath, files) 29 | appEnv.Default(app) 30 | 31 | # ------------------------------------------------------------------------------ 32 | -------------------------------------------------------------------------------- /test/unit_tests/SConstruct: -------------------------------------------------------------------------------- 1 | # ------------------------------------------------------------------------------ 2 | 3 | env = Environment() 4 | 5 | Export("env") 6 | 7 | SConscript("SConscript") 8 | 9 | # ------------------------------------------------------------------------------ 10 | 11 | --------------------------------------------------------------------------------